From 05c08c696a1bc45ab28abe6f82bebbdbd6239c23 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Fri, 25 Dec 2020 14:46:03 +0100 Subject: gui: add network column in peers tab/window --- src/qt/peertablemodel.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/qt/peertablemodel.cpp') diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 5220f8e138..54c9291b9d 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -29,14 +29,16 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine return pLeft->nodeid < pRight->nodeid; case PeerTableModel::Address: return pLeft->addrName.compare(pRight->addrName) < 0; - case PeerTableModel::Subversion: - return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0; + case PeerTableModel::Network: + return pLeft->m_network < pRight->m_network; case PeerTableModel::Ping: return pLeft->m_min_ping_usec < pRight->m_min_ping_usec; case PeerTableModel::Sent: return pLeft->nSendBytes < pRight->nSendBytes; case PeerTableModel::Received: return pLeft->nRecvBytes < pRight->nRecvBytes; + case PeerTableModel::Subversion: + return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0; } return false; @@ -104,7 +106,7 @@ PeerTableModel::PeerTableModel(interfaces::Node& node, QObject* parent) : m_node(node), timer(nullptr) { - columns << tr("NodeId") << tr("Node/Service") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent"); + columns << tr("NodeId") << tr("Node/Service") << tr("Network") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent"); priv.reset(new PeerTablePriv()); // set up timer for auto refresh @@ -158,17 +160,21 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const case Address: // prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection return QString(rec->nodeStats.fInbound ? "↓ " : "↑ ") + QString::fromStdString(rec->nodeStats.addrName); - case Subversion: - return QString::fromStdString(rec->nodeStats.cleanSubVer); + case Network: + return GUIUtil::NetworkToQString(rec->nodeStats.m_network); case Ping: return GUIUtil::formatPingTime(rec->nodeStats.m_min_ping_usec); case Sent: return GUIUtil::formatBytes(rec->nodeStats.nSendBytes); case Received: return GUIUtil::formatBytes(rec->nodeStats.nRecvBytes); + case Subversion: + return QString::fromStdString(rec->nodeStats.cleanSubVer); } } else if (role == Qt::TextAlignmentRole) { switch (index.column()) { + case Network: + return QVariant(Qt::AlignCenter); case Ping: case Sent: case Received: -- cgit v1.2.3