Skip to content

Commit 209301a

Browse files
gui: add Age column to peers tab
Co-authored-by: Jon Atack <[email protected]>
1 parent 127de22 commit 209301a

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/qt/peertablemodel.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
7171
switch (column) {
7272
case NetNodeId:
7373
return (qint64)rec->nodeStats.nodeid;
74+
case Age:
75+
return GUIUtil::FormatPeerAge(rec->nodeStats.m_connected);
7476
case Address:
7577
return QString::fromStdString(rec->nodeStats.m_addr_name);
7678
case Direction:
@@ -96,6 +98,7 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
9698
} else if (role == Qt::TextAlignmentRole) {
9799
switch (column) {
98100
case NetNodeId:
101+
case Age:
99102
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
100103
case Address:
101104
return {};

src/qt/peertablemodel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class PeerTableModel : public QAbstractTableModel
4747

4848
enum ColumnIndex {
4949
NetNodeId = 0,
50+
Age,
5051
Address,
5152
Direction,
5253
ConnectionType,
@@ -82,6 +83,9 @@ public Q_SLOTS:
8283
/*: Title of Peers Table column which contains a
8384
unique number used to identify a connection. */
8485
tr("Peer"),
86+
/*: Title of Peers Table column which indicates the duration (length of time)
87+
since the peer connection started. */
88+
tr("Age"),
8589
/*: Title of Peers Table column which contains the
8690
IP/Onion/I2P address of the connected peer. */
8791
tr("Address"),

src/qt/peertablesortproxy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ bool PeerTableSortProxy::lessThan(const QModelIndex& left_index, const QModelInd
2424
switch (static_cast<PeerTableModel::ColumnIndex>(left_index.column())) {
2525
case PeerTableModel::NetNodeId:
2626
return left_stats.nodeid < right_stats.nodeid;
27+
case PeerTableModel::Age:
28+
return left_stats.m_connected > right_stats.m_connected;
2729
case PeerTableModel::Address:
2830
return left_stats.m_addr_name.compare(right_stats.m_addr_name) < 0;
2931
case PeerTableModel::Direction:

0 commit comments

Comments
 (0)