Skip to content

Commit 6d6219b

Browse files
committed
qt: Add "Copy address" item to the context menu in the Peers table
1 parent 4cfe6c3 commit 6d6219b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/qt/peertablemodel.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,24 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
146146
} // no default case, so the compiler can warn about missing cases
147147
assert(false);
148148
} else if (role == StatsRole) {
149-
return QVariant::fromValue(rec);
149+
switch (index.column()) {
150+
case NetNodeId:
151+
return QVariant::fromValue(rec);
152+
case Address:
153+
return QString::fromStdString(rec->nodeStats.addrName);
154+
case ConnectionType:
155+
[[fallthrough]];
156+
case Network:
157+
[[fallthrough]];
158+
case Ping:
159+
[[fallthrough]];
160+
case Sent:
161+
[[fallthrough]];
162+
case Received:
163+
[[fallthrough]];
164+
case Subversion:
165+
return {};
166+
} // no default case, so the compiler can warn about missing cases
150167
}
151168

152169
return QVariant();

src/qt/rpcconsole.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,10 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
619619

620620
// create peer table context menu
621621
peersTableContextMenu = new QMenu(this);
622+
peersTableContextMenu->addAction(tr("Copy address"), [this] {
623+
GUIUtil::copyEntryData(ui->peerWidget, PeerTableModel::Address, PeerTableModel::StatsRole);
624+
});
625+
peersTableContextMenu->addSeparator();
622626
peersTableContextMenu->addAction(tr("Disconnect"), this, &RPCConsole::disconnectSelectedNode);
623627
peersTableContextMenu->addAction(ts.ban_for + " " + tr("1 hour"), [this] { banSelectedNode(60 * 60); });
624628
peersTableContextMenu->addAction(ts.ban_for + " " + tr("1 day"), [this] { banSelectedNode(60 * 60 * 24); });

0 commit comments

Comments
 (0)