Skip to content

Commit 02fda82

Browse files
author
MarcoFalke
committed
Merge #179: Add Type column to peers window, update peer details name/tooltip
be4cf48 gui: update to "Direction/Type" peer details name/tooltip (Jon Atack) 1518883 gui: add "Type" column to Peers main window (Jon Atack) 6fc72bd gui: allow ConnectionTypeToQString to prepend direction optionally (Jon Atack) Pull request description: This pull: - adds a sortable `Type` column to the GUI Peers tab window - updates the peer details row to `Direction/Type`, so the `Type` column without a direction makes sense (the tooltip is also updated) ![Screenshot from 2021-02-06 22-53-11](https://user-images.githubusercontent.com/2415484/107130646-973bee80-68c7-11eb-9025-b18394ac5c93.png) ACKs for top commit: jarolrod: ACK be4cf48 leonardojobim: Tested ACK be4cf48 on Ubuntu 20.04 on VMWare. Tree-SHA512: 6c6d1dbe7d6bdb616acff0aaf8f4223546f1d2524566e9cd6e5b1b3bed2be1e9b20b1bc52ed3b627df53ba1f2fe0bc76f036cf16ad934d8a446b515d9bece3b1
2 parents 5bb64ac + be4cf48 commit 02fda82

6 files changed

+28
-18
lines changed

src/qt/forms/debugwindow.ui

+2-2
Original file line numberDiff line numberDiff line change
@@ -1079,10 +1079,10 @@
10791079
<item row="1" column="0">
10801080
<widget class="QLabel" name="peerConnectionTypeLabel">
10811081
<property name="toolTip">
1082-
<string>The type of peer connection: %1</string>
1082+
<string>The direction and type of peer connection: %1</string>
10831083
</property>
10841084
<property name="text">
1085-
<string>Connection Type</string>
1085+
<string>Direction/Type</string>
10861086
</property>
10871087
</widget>
10881088
</item>

src/qt/guiutil.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -766,15 +766,19 @@ QString NetworkToQString(Network net)
766766
assert(false);
767767
}
768768

769-
QString ConnectionTypeToQString(ConnectionType conn_type)
769+
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction)
770770
{
771+
QString prefix;
772+
if (prepend_direction) {
773+
prefix = (conn_type == ConnectionType::INBOUND) ? QObject::tr("Inbound") : QObject::tr("Outbound") + " ";
774+
}
771775
switch (conn_type) {
772-
case ConnectionType::INBOUND: return QObject::tr("Inbound");
773-
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay");
774-
case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay");
775-
case ConnectionType::MANUAL: return QObject::tr("Outbound Manual");
776-
case ConnectionType::FEELER: return QObject::tr("Outbound Feeler");
777-
case ConnectionType::ADDR_FETCH: return QObject::tr("Outbound Address Fetch");
776+
case ConnectionType::INBOUND: return prefix;
777+
case ConnectionType::OUTBOUND_FULL_RELAY: return prefix + QObject::tr("Full Relay");
778+
case ConnectionType::BLOCK_RELAY: return prefix + QObject::tr("Block Relay");
779+
case ConnectionType::MANUAL: return prefix + QObject::tr("Manual");
780+
case ConnectionType::FEELER: return prefix + QObject::tr("Feeler");
781+
case ConnectionType::ADDR_FETCH: return prefix + QObject::tr("Address Fetch");
778782
} // no default case, so the compiler can warn about missing cases
779783
assert(false);
780784
}

src/qt/guiutil.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ namespace GUIUtil
233233
QString NetworkToQString(Network net);
234234

235235
/** Convert enum ConnectionType to QString */
236-
QString ConnectionTypeToQString(ConnectionType conn_type);
236+
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction);
237237

238238
/** Convert seconds into a QString with days, hours, mins, secs */
239239
QString formatDurationStr(int secs);

src/qt/peertablemodel.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
2929
return pLeft->nodeid < pRight->nodeid;
3030
case PeerTableModel::Address:
3131
return pLeft->addrName.compare(pRight->addrName) < 0;
32+
case PeerTableModel::ConnectionType:
33+
return pLeft->m_conn_type < pRight->m_conn_type;
3234
case PeerTableModel::Network:
3335
return pLeft->m_network < pRight->m_network;
3436
case PeerTableModel::Ping:
@@ -163,6 +165,8 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
163165
case Address:
164166
// prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection
165167
return QString(rec->nodeStats.fInbound ? "" : "") + QString::fromStdString(rec->nodeStats.addrName);
168+
case ConnectionType:
169+
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
166170
case Network:
167171
return GUIUtil::NetworkToQString(rec->nodeStats.m_network);
168172
case Ping:
@@ -176,6 +180,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
176180
}
177181
} else if (role == Qt::TextAlignmentRole) {
178182
switch (index.column()) {
183+
case ConnectionType:
179184
case Network:
180185
return QVariant(Qt::AlignCenter);
181186
case Ping:

src/qt/peertablemodel.h

+8-7
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ class PeerTableModel : public QAbstractTableModel
5959

6060
enum ColumnIndex {
6161
NetNodeId = 0,
62-
Address = 1,
63-
Network = 2,
64-
Ping = 3,
65-
Sent = 4,
66-
Received = 5,
67-
Subversion = 6
62+
Address,
63+
ConnectionType,
64+
Network,
65+
Ping,
66+
Sent,
67+
Received,
68+
Subversion
6869
};
6970

7071
enum {
@@ -87,7 +88,7 @@ public Q_SLOTS:
8788

8889
private:
8990
interfaces::Node& m_node;
90-
const QStringList columns{tr("Peer Id"), tr("Address"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
91+
const QStringList columns{tr("Peer Id"), tr("Address"), tr("Type"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")};
9192
std::unique_ptr<PeerTablePriv> priv;
9293
QTimer *timer;
9394
};

src/qt/rpcconsole.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ void RPCConsole::updateDetailWidget()
11191119
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
11201120
ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion));
11211121
ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
1122-
ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type));
1122+
ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type, /* prepend_direction */ true));
11231123
ui->peerNetwork->setText(GUIUtil::NetworkToQString(stats->nodeStats.m_network));
11241124
if (stats->nodeStats.m_permissionFlags == PF_NONE) {
11251125
ui->peerPermissions->setText(tr("N/A"));

0 commit comments

Comments
 (0)