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 23, 2021
1 parent 66fd3b2 commit d508c3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 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,9 @@ 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 ? "Inbound" : "Outbound");
case ConnectionType:
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
case Network:
Expand All @@ -182,6 +185,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
3 changes: 2 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,7 @@ 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")};
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 d508c3f

Please sign in to comment.