Skip to content

Commit d508c3f

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

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/qt/peertablemodel.cpp

Lines changed: 6 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,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 ConnectionType:
167170
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
168171
case Network:
@@ -182,6 +185,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
182185
case NetNodeId:
183186
case Address:
184187
return {};
188+
case Direction:
185189
case ConnectionType:
186190
case Network:
187191
return QVariant(Qt::AlignCenter);

src/qt/peertablemodel.h

Lines changed: 2 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,7 @@ 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+
const QStringList columns{tr("Peer Id"), tr("Address"), tr("Direction"), tr("Type"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
9293
std::unique_ptr<PeerTablePriv> priv;
9394
QTimer *timer;
9495
};

0 commit comments

Comments
 (0)