Skip to content

Commit 8c580ef

Browse files
committed
gui: add Direction column to peers tab
1 parent 66fd3b2 commit 8c580ef

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/qt/peertablemodel.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
2828
return pLeft->nodeid < pRight->nodeid;
2929
case PeerTableModel::Address:
3030
return pLeft->addrName.compare(pRight->addrName) < 0;
31+
case PeerTableModel::Direction:
32+
return pLeft->fInbound > pRight->fInbound; // default sort Inbound, then Outbound
3133
case PeerTableModel::ConnectionType:
3234
return pLeft->m_conn_type < pRight->m_conn_type;
3335
case PeerTableModel::Network:
@@ -161,8 +163,12 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
161163
case NetNodeId:
162164
return (qint64)rec->nodeStats.nodeid;
163165
case Address:
164-
// prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection
165-
return QString(rec->nodeStats.fInbound ? "" : "") + QString::fromStdString(rec->nodeStats.addrName);
166+
return QString::fromStdString(rec->nodeStats.addrName);
167+
case Direction:
168+
// Prepend a down-arrow for an inbound peer and an up-arrow for an outbound peer.
169+
return QString(rec->nodeStats.fInbound ? "" : "")
170+
//: This word refers to the peer connection direction.
171+
+ QString(rec->nodeStats.fInbound ? tr("Inbound") : tr("Outbound"));
166172
case ConnectionType:
167173
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
168174
case Network:
@@ -182,6 +188,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
182188
case NetNodeId:
183189
case Address:
184190
return {};
191+
case Direction:
185192
case ConnectionType:
186193
case Network:
187194
return QVariant(Qt::AlignCenter);

src/qt/peertablemodel.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class PeerTableModel : public QAbstractTableModel
6060
enum ColumnIndex {
6161
NetNodeId = 0,
6262
Address,
63+
Direction,
6364
ConnectionType,
6465
Network,
6566
Ping,
@@ -88,7 +89,8 @@ public Q_SLOTS:
8889

8990
private:
9091
interfaces::Node& m_node;
91-
const QStringList columns{tr("Peer Id"), tr("Address"), tr("Type"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
92+
/*: Column titles of the Peers tab window. */
93+
const QStringList columns{tr("Peer Id"), tr("Address"), tr("Direction"), tr("Type"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
9294
std::unique_ptr<PeerTablePriv> priv;
9395
QTimer *timer;
9496
};

0 commit comments

Comments
 (0)