Skip to content

Commit bb36f6e

Browse files
committed
qt: Add "Copy address" item to the context menu in the Peers table
1 parent 16c157d commit bb36f6e

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/qt/peertablemodel.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,26 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
195195
assert(false);
196196
} else if (role == StatsRole) {
197197
switch (index.column()) {
198-
case NetNodeId: return QVariant::fromValue(rec);
199-
default: return QVariant();
200-
}
198+
case NetNodeId:
199+
return QVariant::fromValue(rec);
200+
case Address:
201+
return QString::fromStdString(rec->nodeStats.addrName);
202+
case ConnectionType:
203+
[[fallthrough]];
204+
case Network:
205+
[[fallthrough]];
206+
case Ping:
207+
[[fallthrough]];
208+
case Sent:
209+
[[fallthrough]];
210+
case Received:
211+
[[fallthrough]];
212+
case Subversion:
213+
return {};
214+
} // no default case, so the compiler can warn about missing cases
201215
}
202216

203-
return QVariant();
217+
return {};
204218
}
205219

206220
QVariant PeerTableModel::headerData(int section, Qt::Orientation orientation, int role) const

src/qt/rpcconsole.cpp

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

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

0 commit comments

Comments
 (0)