Skip to content

Commit 531214f

Browse files
committed
gui: add NodeID to the peer table
1 parent ddc3080 commit 531214f

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

src/qt/guiutil.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,17 +291,17 @@ void copyEntryData(QAbstractItemView *view, int column, int role)
291291
}
292292
}
293293

294-
QString getEntryData(QAbstractItemView *view, int column, int role)
294+
QVariant getEntryData(QAbstractItemView *view, int column, int role)
295295
{
296296
if(!view || !view->selectionModel())
297-
return QString();
297+
return QVariant();
298298
QModelIndexList selection = view->selectionModel()->selectedRows(column);
299299

300300
if(!selection.isEmpty()) {
301301
// Return first item
302-
return (selection.at(0).data(role).toString());
302+
return (selection.at(0).data(role));
303303
}
304-
return QString();
304+
return QVariant();
305305
}
306306

307307
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir,

src/qt/guiutil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace GUIUtil
7070
@param[in] role Data role to extract from the model
7171
@see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress
7272
*/
73-
QString getEntryData(QAbstractItemView *view, int column, int role);
73+
QVariant getEntryData(QAbstractItemView *view, int column, int role);
7474

7575
void setClipboard(const QString& str);
7676

src/qt/peertablemodel.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
2424

2525
switch(column)
2626
{
27+
case PeerTableModel::NetNodeId:
28+
return pLeft->nodeid < pRight->nodeid;
2729
case PeerTableModel::Address:
2830
return pLeft->addrName.compare(pRight->addrName) < 0;
2931
case PeerTableModel::Subversion:
@@ -114,7 +116,7 @@ PeerTableModel::PeerTableModel(ClientModel *parent) :
114116
clientModel(parent),
115117
timer(0)
116118
{
117-
columns << tr("Node/Service") << tr("User Agent") << tr("Ping Time");
119+
columns << tr("NodeId") << tr("Node/Service") << tr("User Agent") << tr("Ping Time");
118120
priv = new PeerTablePriv();
119121
// default to unsorted
120122
priv->sortColumn = -1;
@@ -160,6 +162,8 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
160162
if (role == Qt::DisplayRole) {
161163
switch(index.column())
162164
{
165+
case NetNodeId:
166+
return rec->nodeStats.nodeid;
163167
case Address:
164168
return QString::fromStdString(rec->nodeStats.addrName);
165169
case Subversion:

src/qt/peertablemodel.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ class PeerTableModel : public QAbstractTableModel
5252
void stopAutoRefresh();
5353

5454
enum ColumnIndex {
55-
Address = 0,
56-
Subversion = 1,
57-
Ping = 2
55+
NetNodeId = 0,
56+
Address = 1,
57+
Subversion = 2,
58+
Ping = 3
5859
};
5960

6061
/** @name Methods overridden from QAbstractTableModel

src/qt/rpcconsole.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ void RPCConsole::showBanTableContextMenu(const QPoint& point)
877877
void RPCConsole::disconnectSelectedNode()
878878
{
879879
// Get currently selected peer address
880-
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address);
880+
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address).toString();
881881
// Find the node, disconnect it and clear the selected node
882882
if (CNode *bannedNode = FindNode(strNode.toStdString())) {
883883
bannedNode->fDisconnect = true;
@@ -891,7 +891,7 @@ void RPCConsole::banSelectedNode(int bantime)
891891
return;
892892

893893
// Get currently selected peer address
894-
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address);
894+
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address).toString();
895895
// Find possible nodes, ban it and clear the selected node
896896
if (FindNode(strNode.toStdString())) {
897897
std::string nStr = strNode.toStdString();
@@ -915,7 +915,7 @@ void RPCConsole::unbanSelectedNode()
915915
return;
916916

917917
// Get currently selected ban address
918-
QString strNode = GUIUtil::getEntryData(ui->banlistWidget, 0, BanTableModel::Address);
918+
QString strNode = GUIUtil::getEntryData(ui->banlistWidget, 0, BanTableModel::Address).toString();
919919
CSubNet possibleSubnet;
920920

921921
LookupSubNet(strNode.toStdString().c_str(), possibleSubnet);

0 commit comments

Comments
 (0)