Skip to content

Commit

Permalink
gui: add Direction column to peers tab
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatack committed Apr 24, 2021
1 parent 66fd3b2 commit 8c580ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
return pLeft->nodeid < pRight->nodeid;
case PeerTableModel::Address:
return pLeft->addrName.compare(pRight->addrName) < 0;
case PeerTableModel::Direction:
return pLeft->fInbound > pRight->fInbound; // default sort Inbound, then Outbound
case PeerTableModel::ConnectionType:
return pLeft->m_conn_type < pRight->m_conn_type;
case PeerTableModel::Network:
Expand Down Expand Up @@ -161,8 +163,12 @@ 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:
// Prepend a down-arrow for an inbound peer and an up-arrow for an outbound peer.
return QString(rec->nodeStats.fInbound ? "" : "")
//: This word refers to the peer connection direction.
+ QString(rec->nodeStats.fInbound ? tr("Inbound") : tr("Outbound"));
case ConnectionType:
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
case Network:
Expand All @@ -182,6 +188,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: 3 additions & 1 deletion src/qt/peertablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class PeerTableModel : public QAbstractTableModel
enum ColumnIndex {
NetNodeId = 0,
Address,
Direction,
ConnectionType,
Network,
Ping,
Expand Down Expand Up @@ -88,7 +89,8 @@ public Q_SLOTS:

private:
interfaces::Node& m_node;
const QStringList columns{tr("Peer Id"), tr("Address"), tr("Type"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
/*: Column titles of the Peers tab window. */
const QStringList columns{tr("Peer Id"), tr("Address"), tr("Direction"), tr("Type"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
std::unique_ptr<PeerTablePriv> priv;
QTimer *timer;
};
Expand Down

0 comments on commit 8c580ef

Please sign in to comment.