From 8c580ef03e34ada1413f0541f73a6ba5b6d75514 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Fri, 23 Apr 2021 14:57:05 +0200 Subject: [PATCH] gui: add Direction column to peers tab --- src/qt/peertablemodel.cpp | 11 +++++++++-- src/qt/peertablemodel.h | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 3459bf4cf8e..16af5825056 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -28,6 +28,8 @@ 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::Direction: + return pLeft->fInbound > pRight->fInbound; // default sort Inbound, then Outbound case PeerTableModel::ConnectionType: return pLeft->m_conn_type < pRight->m_conn_type; case PeerTableModel::Network: @@ -161,8 +163,12 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const case NetNodeId: return (qint64)rec->nodeStats.nodeid; 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); + return QString::fromStdString(rec->nodeStats.addrName); + case Direction: + // Prepend a down-arrow for an inbound peer and an up-arrow for an outbound peer. + return QString(rec->nodeStats.fInbound ? "↓ " : "↑ ") + //: This word refers to the peer connection direction. + + QString(rec->nodeStats.fInbound ? tr("Inbound") : tr("Outbound")); case ConnectionType: return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false); case Network: @@ -182,6 +188,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const case NetNodeId: case Address: return {}; + case Direction: case ConnectionType: case Network: return QVariant(Qt::AlignCenter); diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h index 0823235ec09..ef76792c4e2 100644 --- a/src/qt/peertablemodel.h +++ b/src/qt/peertablemodel.h @@ -60,6 +60,7 @@ class PeerTableModel : public QAbstractTableModel enum ColumnIndex { NetNodeId = 0, Address, + Direction, ConnectionType, Network, Ping, @@ -88,7 +89,8 @@ public Q_SLOTS: private: interfaces::Node& m_node; - const QStringList columns{tr("Peer Id"), tr("Address"), tr("Type"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")}; + /*: Column titles of the Peers tab window. */ + const QStringList columns{tr("Peer Id"), tr("Address"), tr("Direction"), tr("Type"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")}; std::unique_ptr priv; QTimer *timer; };