and rename peers window column headers from NodeId and Node/Service to Peer Id and Address.

and rename peers window column headers from NodeId and Node/Service to Peer Id and Address.

tACK b1704ead912ed813eaa08e80af5e14a2c087574e
Especially handy because IPv6 addresses are turned into ellipses until you expand it:
This column might be a more natural place for the inbound/outbound arrow.
In this PR the direction has its own column. This makes the direction sortable. Having the network type and the direction individually sortable would be great.
Note: I found that offsetting the arrow (based on direction) is a useful visual cue. And this makes seeing the direction (at a glance) easier.
1099@@ -1100,13 +1100,39 @@
1100 </widget>
1101 </item>
1102 <item row="2" column="0">
1103+ <widget class="QLabel" name="peerNetworkLabel">
1104+ <property name="toolTip">
1105+ <string>The network protocol this peer is connected through.</string>
1106+ </property>
b1704ead912ed813eaa08e80af5e14a2c087574e
It is inconsistent to have a tooltip only for this label among others.
754+ if (network == "ipv4") return "IPv4";
755+ if (network == "ipv6") return "IPv6";
756+ if (network == "onion") return "Onion";
757+ return "";
758+}
759+
105@@ -104,7 +106,7 @@ PeerTableModel::PeerTableModel(interfaces::Node& node, QObject* parent) :
106 m_node(node),
107 timer(nullptr)
108 {
109- columns << tr("NodeId") << tr("Node/Service") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent");
110+ columns << tr("Node Id") << tr("Node/Service") << tr("Network") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent");
c772533ce5f471b5aa968ac864cf8a2173900fac As you touching the headers, mind considering the following patch
0--- a/src/qt/peertablemodel.cpp
1+++ b/src/qt/peertablemodel.cpp
2@@ -106,7 +106,6 @@ PeerTableModel::PeerTableModel(interfaces::Node& node, QObject* parent) :
3 m_node(node),
4 timer(nullptr)
5 {
6- columns << tr("Node Id") << tr("Node/Service") << tr("Network") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent");
7 priv.reset(new PeerTablePriv());
8
9 // set up timer for auto refresh
10diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h
11index 39cbe16df..61a0132e0 100644
12--- a/src/qt/peertablemodel.h
13+++ b/src/qt/peertablemodel.h
14@@ -83,7 +83,7 @@ public Q_SLOTS:
15
16 private:
17 interfaces::Node& m_node;
18- QStringList columns;
19+ const QStringList columns{tr("Peer Id"), tr("Address"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
20 std::unique_ptr<PeerTablePriv> priv;
21 QTimer *timer;
22 };
?
I have reviewed the code (79e997e826b93595896839fd513a052b7a4d001d), and tested it.
UX notes.
Disclaimer: I’m not a design expert, and my opinions are based exclusively on my experience.
In this PR the direction has its own column. This makes the direction sortable. Having the network type and the direction individually sortable would be great.
I’ve been waiting for this feature for many years :)
This column might be a more natural place for the inbound/outbound arrow.
Thanks @Sjors. Good idea, done.
I don’t think this change is valuable. It is not possible to sort out all connections through a particular network.
44 case PeerTableModel::Received:
45 return pLeft->nRecvBytes < pRight->nRecvBytes;
46- }
47+ case PeerTableModel::Subversion:
48+ return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0;
49+ } // no default case, so the compiler can warn about missing cases
switch parameter is an int, not a enum.
748@@ -749,6 +749,21 @@ QString boostPathToQString(const fs::path &path)
749 return QString::fromStdString(path.string());
750 }
751
752+QString NetworkToQString(Network net)
753+{
754+ switch (net) {
755+ case NET_UNROUTABLE: return "Unroutable";
0 case NET_UNROUTABLE: return tr("Unroutable");
QObject::tr("Unroutable")
756+ case NET_IPV4: return "IPv4";
757+ case NET_IPV6: return "IPv6";
758+ case NET_ONION: return "Onion";
759+ case NET_I2P: return "I2P";
760+ case NET_CJDNS: return "CJDNS";
761+ case NET_INTERNAL: return "Internal";
0 case NET_INTERNAL: return tr("Internal");
@jonatack Could this patch make things look better
0--- a/src/qt/peertablemodel.cpp
1+++ b/src/qt/peertablemodel.cpp
2@@ -168,6 +168,8 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
3 }
4 } else if (role == Qt::TextAlignmentRole) {
5 switch (index.column()) {
6+ case Network:
7+ return QVariant(Qt::AlignCenter);
8 case Ping:
9 case Sent:
10 case Received:
?
Due to the header titles are changed this patch seems required:
0--- a/src/qt/rpcconsole.cpp
1+++ b/src/qt/rpcconsole.cpp
2@@ -1092,7 +1092,7 @@ void RPCConsole::updateDetailWidget()
3 const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected_rows.first().row());
4 // update the detail ui with latest node information
5 QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName) + " ");
6- peerAddrDetails += tr("(node id: %1)").arg(QString::number(stats->nodeStats.nodeid));
7+ peerAddrDetails += tr("(peer id: %1)").arg(QString::number(stats->nodeStats.nodeid));
8 if (!stats->nodeStats.addrLocal.empty())
9 peerAddrDetails += "<br />" + tr("via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal));
10 ui->peerHeading->setText(peerAddrDetails);
columns in the .h, fixed the broken doxygen formatting, dropped the clang formatting, and improved the network tooltip. Updated the PR description and screenshot.
ACK 12212e2b30b87110f81787d6e10259d02d807279, tested on Linux Mint 20 (x86_64) + Qt 5.12.8.
Looks great:

Also I’ve verified that the “network” field in the getpeerinfo RPC has not changed behavior.
With this patch
0--- a/src/net.cpp
1+++ b/src/net.cpp
2@@ -566,7 +566,7 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
3 X(nServices);
4 X(addr);
5 X(addrBind);
6- stats.m_network = ConnectedThroughNetwork();
7+ stats.m_network = static_cast<enum Network>(stats.nodeid % NET_MAX);
8 stats.m_network_name = GetNetworkName(stats.m_network);
9 stats.m_mapped_as = addr.GetMappedAS(m_asmap);
10 if (m_tx_relay != nullptr) {
I’ve verified that items in the “Network” column are sorted in lexicographical order:

TBH, I don’t like it, but it could be changed in a followup.
Updated the first commit to remove the now-redundant network string (same idea as @promag’s suggestion in the connection type pull) and updated the network column ordering by enum id rather than by network name (@hebasto I agree it’s better, though maybe more surprising to some users, see screenshot with your patch to show all the Network enum members). Will open this in the main repo as it now touches RPC code.

1099@@ -1100,13 +1100,39 @@
1100 </widget>
1101 </item>
1102 <item row="2" column="0">
1103+ <widget class="QLabel" name="peerNetworkLabel">
1104+ <property name="toolTip">
1105+ <string>The network protocol this peer is connected through: IPv4, IPv6, Onion, I2P, or CJDNS.</string>