Skip to content

Commit 1c46329

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

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/qt/peertablemodel.cpp

Lines changed: 7 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,10 @@ 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+
//: Connection direction. Also used in ConnectionTypeToQString() and CONNECTION_TYPE_DOC.
169+
return QString(rec->nodeStats.fInbound ? tr("Inbound") : tr("Outbound"));
166170
case ConnectionType:
167171
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
168172
case Network:
@@ -182,6 +186,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
182186
case NetNodeId:
183187
case Address:
184188
return {};
189+
case Direction:
185190
case ConnectionType:
186191
case Network:
187192
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)