Skip to content

Commit

Permalink
Merge bitcoin-core/gui#317: Add Direction column to Peers Tab
Browse files Browse the repository at this point in the history
6971e79 gui: add Direction column to peers tab (Jon Atack)

Pull request description:

  Picking up dashpay#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
  • Loading branch information
hebasto authored and knst committed Oct 24, 2024
1 parent c0cafa3 commit f6c788f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
case Age:
return GUIUtil::FormatPeerAge(rec->nodeStats.m_connected);
case Address:
// prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection
return QString::fromStdString((rec->nodeStats.fInbound ? "" : "") + rec->nodeStats.m_addr_name);
return QString::fromStdString(rec->nodeStats.m_addr_name);
case Direction:
return QString(rec->nodeStats.fInbound ?
//: An Inbound Connection from a Peer.
tr("Inbound") :
//: An Outbound Connection to a Peer.
tr("Outbound"));
case ConnectionType:
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
case Network:
Expand All @@ -97,6 +102,7 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
case Address:
return {};
case Direction:
case ConnectionType:
case Network:
return QVariant(Qt::AlignCenter);
Expand Down
4 changes: 4 additions & 0 deletions src/qt/peertablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class PeerTableModel : public QAbstractTableModel
NetNodeId = 0,
Age,
Address,
Direction,
ConnectionType,
Network,
Ping,
Expand Down Expand Up @@ -88,6 +89,9 @@ public Q_SLOTS:
/*: Title of Peers Table column which contains the
IP/Onion/I2P address of the connected peer. */
tr("Address"),
/*: Title of Peers Table column which indicates the direction
the peer connection was initiated from. */
tr("Direction"),
/*: Title of Peers Table column which describes the type of
peer connection. The "type" describes why the connection exists. */
tr("Type"),
Expand Down
2 changes: 2 additions & 0 deletions src/qt/peertablesortproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ bool PeerTableSortProxy::lessThan(const QModelIndex& left_index, const QModelInd
return left_stats.m_connected > right_stats.m_connected;
case PeerTableModel::Address:
return left_stats.m_addr_name.compare(right_stats.m_addr_name) < 0;
case PeerTableModel::Direction:
return left_stats.fInbound > right_stats.fInbound; // default sort Inbound, then Outbound
case PeerTableModel::ConnectionType:
return left_stats.m_conn_type < right_stats.m_conn_type;
case PeerTableModel::Network:
Expand Down

0 comments on commit f6c788f

Please sign in to comment.