gui: add "Type" column to Peers main window

This commit is contained in:
Jon Atack
2021-01-09 20:10:12 +01:00
parent 6fc72bd6f0
commit 151888383a
2 changed files with 13 additions and 7 deletions

View File

@@ -29,6 +29,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
return pLeft->nodeid < pRight->nodeid; return pLeft->nodeid < pRight->nodeid;
case PeerTableModel::Address: case PeerTableModel::Address:
return pLeft->addrName.compare(pRight->addrName) < 0; return pLeft->addrName.compare(pRight->addrName) < 0;
case PeerTableModel::ConnectionType:
return pLeft->m_conn_type < pRight->m_conn_type;
case PeerTableModel::Network: case PeerTableModel::Network:
return pLeft->m_network < pRight->m_network; return pLeft->m_network < pRight->m_network;
case PeerTableModel::Ping: case PeerTableModel::Ping:
@@ -163,6 +165,8 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
case Address: case Address:
// prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection // 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(rec->nodeStats.fInbound ? "" : "") + QString::fromStdString(rec->nodeStats.addrName);
case ConnectionType:
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
case Network: case Network:
return GUIUtil::NetworkToQString(rec->nodeStats.m_network); return GUIUtil::NetworkToQString(rec->nodeStats.m_network);
case Ping: case Ping:
@@ -176,6 +180,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
} }
} else if (role == Qt::TextAlignmentRole) { } else if (role == Qt::TextAlignmentRole) {
switch (index.column()) { switch (index.column()) {
case ConnectionType:
case Network: case Network:
return QVariant(Qt::AlignCenter); return QVariant(Qt::AlignCenter);
case Ping: case Ping:

View File

@@ -59,12 +59,13 @@ public:
enum ColumnIndex { enum ColumnIndex {
NetNodeId = 0, NetNodeId = 0,
Address = 1, Address,
Network = 2, ConnectionType,
Ping = 3, Network,
Sent = 4, Ping,
Received = 5, Sent,
Subversion = 6 Received,
Subversion
}; };
enum { enum {
@@ -87,7 +88,7 @@ public Q_SLOTS:
private: private:
interfaces::Node& m_node; interfaces::Node& m_node;
const QStringList columns{tr("Peer Id"), tr("Address"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")}; const QStringList columns{tr("Peer Id"), tr("Address"), tr("Type"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
std::unique_ptr<PeerTablePriv> priv; std::unique_ptr<PeerTablePriv> priv;
QTimer *timer; QTimer *timer;
}; };