Skip to content

Commit

Permalink
gui: add Direction column to peers tab
Browse files Browse the repository at this point in the history
Co-authored-by: Jarol Rodriguez <jarolrod@tutanota.com>
  • Loading branch information
jonatack and jarolrod committed May 26, 2021
1 parent 790f006 commit 5d7463a
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 @@ -113,8 +113,13 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
case NetNodeId:
return (qint64)rec->nodeStats.nodeid;
case Address:
// prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection
return QString(rec->nodeStats.fInbound ? "" : "") + QString::fromStdString(rec->nodeStats.addrName);
return QString::fromStdString(rec->nodeStats.addrName);
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 @@ -134,6 +139,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
case NetNodeId:
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 @@ -47,6 +47,7 @@ class PeerTableModel : public QAbstractTableModel
enum ColumnIndex {
NetNodeId = 0,
Address,
Direction,
ConnectionType,
Network,
Ping,
Expand Down Expand Up @@ -81,6 +82,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 @@ -26,6 +26,8 @@ bool PeerTableSortProxy::lessThan(const QModelIndex& left_index, const QModelInd
return left_stats.nodeid < right_stats.nodeid;
case PeerTableModel::Address:
return left_stats.addrName.compare(right_stats.addrName) < 0;
case PeerTableModel::Direction:
return left_stats.fInbound > right_stats.fInbound;
case PeerTableModel::ConnectionType:
return left_stats.m_conn_type < right_stats.m_conn_type;
case PeerTableModel::Network:
Expand Down

0 comments on commit 5d7463a

Please sign in to comment.