Skip to content

Commit 77e23ca

Browse files
committed
Merge bitcoin-core#317: Add Direction column to Peers Tab
6971e79 gui: add Direction column to peers tab (Jon Atack) Pull request description: Picking up bitcoin-core#289 This adds a `Direction column`, making the peers tab the same as the `Direction/Type` row in the peer details and the direction and type columns in our other user-facing peer connections table in `-netinfo`. Users can now sort the peers table by direction. The default sort is set to inbound, then outbound. | Master | PR | | ----------- | ----------- | | ![Screen Shot 2021-05-05 at 3 51 09 AM](https://user-images.githubusercontent.com/23396902/117111864-38ff9a00-ad56-11eb-889d-f1c838c845e6.png) | ![Screen Shot 2021-05-05 at 3 35 40 AM](https://user-images.githubusercontent.com/23396902/117111892-4157d500-ad56-11eb-82b1-5bd3e88a4cff.png) | ACKs for top commit: jonatack: Tested ACK 6971e79 ShaMan239: tACK 6971e79 hebasto: ACK 6971e79, tested on Linux Mint 20.2 (Qt 5.12.8). Tree-SHA512: 9716cdedd435f88245a097fed6d4b2b486104d0dd09df739bdb4f2bfad709cbd9c9a231168cc3326e94fa5fddc77dd68f992f20417d04d94930db9fccdbb7de1
2 parents 3d9cdb1 + 6971e79 commit 77e23ca

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/qt/peertablemodel.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
7272
case NetNodeId:
7373
return (qint64)rec->nodeStats.nodeid;
7474
case Address:
75-
// prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection
76-
return QString::fromStdString((rec->nodeStats.fInbound ? "" : "") + rec->nodeStats.addrName);
75+
return QString::fromStdString(rec->nodeStats.addrName);
76+
case Direction:
77+
return QString(rec->nodeStats.fInbound ?
78+
//: An Inbound Connection from a Peer.
79+
tr("Inbound") :
80+
//: An Outbound Connection to a Peer.
81+
tr("Outbound"));
7782
case ConnectionType:
7883
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
7984
case Network:
@@ -94,6 +99,7 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
9499
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
95100
case Address:
96101
return {};
102+
case Direction:
97103
case ConnectionType:
98104
case Network:
99105
return QVariant(Qt::AlignCenter);

src/qt/peertablemodel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class PeerTableModel : public QAbstractTableModel
4848
enum ColumnIndex {
4949
NetNodeId = 0,
5050
Address,
51+
Direction,
5152
ConnectionType,
5253
Network,
5354
Ping,
@@ -84,6 +85,9 @@ public Q_SLOTS:
8485
/*: Title of Peers Table column which contains the
8586
IP/Onion/I2P address of the connected peer. */
8687
tr("Address"),
88+
/*: Title of Peers Table column which indicates the direction
89+
the peer connection was initiated from. */
90+
tr("Direction"),
8791
/*: Title of Peers Table column which describes the type of
8892
peer connection. The "type" describes why the connection exists. */
8993
tr("Type"),

src/qt/peertablesortproxy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ bool PeerTableSortProxy::lessThan(const QModelIndex& left_index, const QModelInd
2626
return left_stats.nodeid < right_stats.nodeid;
2727
case PeerTableModel::Address:
2828
return left_stats.addrName.compare(right_stats.addrName) < 0;
29+
case PeerTableModel::Direction:
30+
return left_stats.fInbound > right_stats.fInbound; // default sort Inbound, then Outbound
2931
case PeerTableModel::ConnectionType:
3032
return left_stats.m_conn_type < right_stats.m_conn_type;
3133
case PeerTableModel::Network:

0 commit comments

Comments
 (0)