Skip to content

Commit

Permalink
qt: Add "Copy address" item to the context menu in the Peers table
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Mar 30, 2021
1 parent b1ab2d1 commit 03a2b74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,26 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
assert(false);
} else if (role == StatsRole) {
switch (index.column()) {
case NetNodeId: return QVariant::fromValue(rec);
default: return QVariant();
}
case NetNodeId:
return QVariant::fromValue(rec);
case Address:
return QString::fromStdString(rec->nodeStats.addrName);
case ConnectionType:
[[fallthrough]];
case Network:
[[fallthrough]];
case Ping:
[[fallthrough]];
case Sent:
[[fallthrough]];
case Received:
[[fallthrough]];
case Subversion:
return {};
} // no default case, so the compiler can warn about missing cases
}

return QVariant();
return {};
}

QVariant PeerTableModel::headerData(int section, Qt::Orientation orientation, int role) const
Expand Down
4 changes: 4 additions & 0 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,10 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_

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

0 comments on commit 03a2b74

Please sign in to comment.