Browse Source

gui: add NodeID to the peer table

0.14
Cory Fields 8 years ago
parent
commit
531214fb10
  1. 8
      src/qt/guiutil.cpp
  2. 2
      src/qt/guiutil.h
  3. 6
      src/qt/peertablemodel.cpp
  4. 7
      src/qt/peertablemodel.h
  5. 6
      src/qt/rpcconsole.cpp

8
src/qt/guiutil.cpp

@ -291,17 +291,17 @@ void copyEntryData(QAbstractItemView *view, int column, int role)
} }
} }
QString getEntryData(QAbstractItemView *view, int column, int role) QVariant getEntryData(QAbstractItemView *view, int column, int role)
{ {
if(!view || !view->selectionModel()) if(!view || !view->selectionModel())
return QString(); return QVariant();
QModelIndexList selection = view->selectionModel()->selectedRows(column); QModelIndexList selection = view->selectionModel()->selectedRows(column);
if(!selection.isEmpty()) { if(!selection.isEmpty()) {
// Return first item // Return first item
return (selection.at(0).data(role).toString()); return (selection.at(0).data(role));
} }
return QString(); return QVariant();
} }
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir,

2
src/qt/guiutil.h

@ -70,7 +70,7 @@ namespace GUIUtil
@param[in] role Data role to extract from the model @param[in] role Data role to extract from the model
@see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress @see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress
*/ */
QString getEntryData(QAbstractItemView *view, int column, int role); QVariant getEntryData(QAbstractItemView *view, int column, int role);
void setClipboard(const QString& str); void setClipboard(const QString& str);

6
src/qt/peertablemodel.cpp

@ -24,6 +24,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
switch(column) switch(column)
{ {
case PeerTableModel::NetNodeId:
return pLeft->nodeid < pRight->nodeid;
case PeerTableModel::Address: case PeerTableModel::Address:
return pLeft->addrName.compare(pRight->addrName) < 0; return pLeft->addrName.compare(pRight->addrName) < 0;
case PeerTableModel::Subversion: case PeerTableModel::Subversion:
@ -114,7 +116,7 @@ PeerTableModel::PeerTableModel(ClientModel *parent) :
clientModel(parent), clientModel(parent),
timer(0) timer(0)
{ {
columns << tr("Node/Service") << tr("User Agent") << tr("Ping Time"); columns << tr("NodeId") << tr("Node/Service") << tr("User Agent") << tr("Ping Time");
priv = new PeerTablePriv(); priv = new PeerTablePriv();
// default to unsorted // default to unsorted
priv->sortColumn = -1; priv->sortColumn = -1;
@ -160,6 +162,8 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
switch(index.column()) switch(index.column())
{ {
case NetNodeId:
return rec->nodeStats.nodeid;
case Address: case Address:
return QString::fromStdString(rec->nodeStats.addrName); return QString::fromStdString(rec->nodeStats.addrName);
case Subversion: case Subversion:

7
src/qt/peertablemodel.h

@ -52,9 +52,10 @@ public:
void stopAutoRefresh(); void stopAutoRefresh();
enum ColumnIndex { enum ColumnIndex {
Address = 0, NetNodeId = 0,
Subversion = 1, Address = 1,
Ping = 2 Subversion = 2,
Ping = 3
}; };
/** @name Methods overridden from QAbstractTableModel /** @name Methods overridden from QAbstractTableModel

6
src/qt/rpcconsole.cpp

@ -877,7 +877,7 @@ void RPCConsole::showBanTableContextMenu(const QPoint& point)
void RPCConsole::disconnectSelectedNode() void RPCConsole::disconnectSelectedNode()
{ {
// Get currently selected peer address // Get currently selected peer address
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address); QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address).toString();
// Find the node, disconnect it and clear the selected node // Find the node, disconnect it and clear the selected node
if (CNode *bannedNode = FindNode(strNode.toStdString())) { if (CNode *bannedNode = FindNode(strNode.toStdString())) {
bannedNode->fDisconnect = true; bannedNode->fDisconnect = true;
@ -891,7 +891,7 @@ void RPCConsole::banSelectedNode(int bantime)
return; return;
// Get currently selected peer address // Get currently selected peer address
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address); QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address).toString();
// Find possible nodes, ban it and clear the selected node // Find possible nodes, ban it and clear the selected node
if (FindNode(strNode.toStdString())) { if (FindNode(strNode.toStdString())) {
std::string nStr = strNode.toStdString(); std::string nStr = strNode.toStdString();
@ -915,7 +915,7 @@ void RPCConsole::unbanSelectedNode()
return; return;
// Get currently selected ban address // Get currently selected ban address
QString strNode = GUIUtil::getEntryData(ui->banlistWidget, 0, BanTableModel::Address); QString strNode = GUIUtil::getEntryData(ui->banlistWidget, 0, BanTableModel::Address).toString();
CSubNet possibleSubnet; CSubNet possibleSubnet;
LookupSubNet(strNode.toStdString().c_str(), possibleSubnet); LookupSubNet(strNode.toStdString().c_str(), possibleSubnet);

Loading…
Cancel
Save