gui: add Age column to peers tab

Co-authored-by: Jon Atack <jon@atack.com>
This commit is contained in:
randymcmillan
2022-02-10 01:45:25 -05:00
parent 127de22c5f
commit 209301a442
3 changed files with 9 additions and 0 deletions

View File

@@ -71,6 +71,8 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
switch (column) { switch (column) {
case NetNodeId: case NetNodeId:
return (qint64)rec->nodeStats.nodeid; return (qint64)rec->nodeStats.nodeid;
case Age:
return GUIUtil::FormatPeerAge(rec->nodeStats.m_connected);
case Address: case Address:
return QString::fromStdString(rec->nodeStats.m_addr_name); return QString::fromStdString(rec->nodeStats.m_addr_name);
case Direction: case Direction:
@@ -96,6 +98,7 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
} else if (role == Qt::TextAlignmentRole) { } else if (role == Qt::TextAlignmentRole) {
switch (column) { switch (column) {
case NetNodeId: case NetNodeId:
case Age:
return QVariant(Qt::AlignRight | Qt::AlignVCenter); return QVariant(Qt::AlignRight | Qt::AlignVCenter);
case Address: case Address:
return {}; return {};

View File

@@ -47,6 +47,7 @@ public:
enum ColumnIndex { enum ColumnIndex {
NetNodeId = 0, NetNodeId = 0,
Age,
Address, Address,
Direction, Direction,
ConnectionType, ConnectionType,
@@ -82,6 +83,9 @@ private:
/*: Title of Peers Table column which contains a /*: Title of Peers Table column which contains a
unique number used to identify a connection. */ unique number used to identify a connection. */
tr("Peer"), tr("Peer"),
/*: Title of Peers Table column which indicates the duration (length of time)
since the peer connection started. */
tr("Age"),
/*: Title of Peers Table column which contains the /*: Title of Peers Table column which contains the
IP/Onion/I2P address of the connected peer. */ IP/Onion/I2P address of the connected peer. */
tr("Address"), tr("Address"),

View File

@@ -24,6 +24,8 @@ bool PeerTableSortProxy::lessThan(const QModelIndex& left_index, const QModelInd
switch (static_cast<PeerTableModel::ColumnIndex>(left_index.column())) { switch (static_cast<PeerTableModel::ColumnIndex>(left_index.column())) {
case PeerTableModel::NetNodeId: case PeerTableModel::NetNodeId:
return left_stats.nodeid < right_stats.nodeid; return left_stats.nodeid < right_stats.nodeid;
case PeerTableModel::Age:
return left_stats.m_connected > right_stats.m_connected;
case PeerTableModel::Address: case PeerTableModel::Address:
return left_stats.m_addr_name.compare(right_stats.m_addr_name) < 0; return left_stats.m_addr_name.compare(right_stats.m_addr_name) < 0;
case PeerTableModel::Direction: case PeerTableModel::Direction: