Skip to content

Commit cdf53b8

Browse files
committed
gui: add Direction column to peers window
1 parent 0944024 commit cdf53b8

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/qt/peertablemodel.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
2929
return pLeft->nodeid < pRight->nodeid;
3030
case PeerTableModel::Address:
3131
return pLeft->addrName.compare(pRight->addrName) < 0;
32+
case PeerTableModel::Direction:
33+
return pLeft->fInbound > pRight->fInbound;
3234
case PeerTableModel::Network:
3335
return pLeft->m_network < pRight->m_network;
3436
case PeerTableModel::Ping:
@@ -161,8 +163,9 @@ 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+
return QString(rec->nodeStats.fInbound ? "Inbound" : "Outbound");
166169
case Network:
167170
return GUIUtil::NetworkToQString(rec->nodeStats.m_network);
168171
case Ping:
@@ -176,6 +179,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
176179
}
177180
} else if (role == Qt::TextAlignmentRole) {
178181
switch (index.column()) {
182+
case Direction:
179183
case Network:
180184
return QVariant(Qt::AlignCenter);
181185
case Ping:

src/qt/peertablemodel.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ class PeerTableModel : public QAbstractTableModel
5959

6060
enum ColumnIndex {
6161
NetNodeId = 0,
62-
Address = 1,
63-
Network = 2,
64-
Ping = 3,
65-
Sent = 4,
66-
Received = 5,
67-
Subversion = 6
62+
Address,
63+
Direction,
64+
Network,
65+
Ping,
66+
Sent,
67+
Received,
68+
Subversion
6869
};
6970

7071
/** @name Methods overridden from QAbstractTableModel
@@ -83,7 +84,7 @@ public Q_SLOTS:
8384

8485
private:
8586
interfaces::Node& m_node;
86-
const QStringList columns{tr("Peer Id"), tr("Address"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
87+
const QStringList columns{tr("Peer Id"), tr("Address"), tr("Direction"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
8788
std::unique_ptr<PeerTablePriv> priv;
8889
QTimer *timer;
8990
};

0 commit comments

Comments
 (0)