Skip to content

Commit afd0648

Browse files
committed
merge bitcoin-core/gui#179: Add Type column to peers window, update peer details name/tooltip
1 parent 57597df commit afd0648

6 files changed

+30
-17
lines changed

src/qt/forms/debugwindow.ui

+2-2
Original file line numberDiff line numberDiff line change
@@ -1028,10 +1028,10 @@
10281028
<item row="4" column="0">
10291029
<widget class="QLabel" name="peerConnectionTypeLabel">
10301030
<property name="toolTip">
1031-
<string>The type of peer connection: %1</string>
1031+
<string>The direction and type of peer connection: %1</string>
10321032
</property>
10331033
<property name="text">
1034-
<string>Connection Type</string>
1034+
<string>Direction/Type</string>
10351035
</property>
10361036
</widget>
10371037
</item>

src/qt/guiutil.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -1661,15 +1661,19 @@ QString NetworkToQString(Network net)
16611661
assert(false);
16621662
}
16631663

1664-
QString ConnectionTypeToQString(ConnectionType conn_type)
1664+
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction)
16651665
{
1666+
QString prefix;
1667+
if (prepend_direction) {
1668+
prefix = (conn_type == ConnectionType::INBOUND) ? QObject::tr("Inbound") : QObject::tr("Outbound") + " ";
1669+
}
16661670
switch (conn_type) {
1667-
case ConnectionType::INBOUND: return QObject::tr("Inbound");
1668-
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay");
1669-
case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay");
1670-
case ConnectionType::MANUAL: return QObject::tr("Outbound Manual");
1671-
case ConnectionType::FEELER: return QObject::tr("Outbound Feeler");
1672-
case ConnectionType::ADDR_FETCH: return QObject::tr("Outbound Address Fetch");
1671+
case ConnectionType::INBOUND: return prefix;
1672+
case ConnectionType::OUTBOUND_FULL_RELAY: return prefix + QObject::tr("Full Relay");
1673+
case ConnectionType::BLOCK_RELAY: return prefix + QObject::tr("Block Relay");
1674+
case ConnectionType::MANUAL: return prefix + QObject::tr("Manual");
1675+
case ConnectionType::FEELER: return prefix + QObject::tr("Feeler");
1676+
case ConnectionType::ADDR_FETCH: return prefix + QObject::tr("Address Fetch");
16731677
} // no default case, so the compiler can warn about missing cases
16741678
assert(false);
16751679
}

src/qt/guiutil.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ namespace GUIUtil
398398
QString NetworkToQString(Network net);
399399

400400
/** Convert enum ConnectionType to QString */
401-
QString ConnectionTypeToQString(ConnectionType conn_type);
401+
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction);
402402

403403
/** Convert seconds into a QString with days, hours, mins, secs */
404404
QString formatDurationStr(std::chrono::seconds dur);

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->m_addr_name.compare(pRight->m_addr_name) < 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:
@@ -164,6 +166,8 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
164166
case Address:
165167
// prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection
166168
return QString(rec->nodeStats.fInbound ? "" : "") + QString::fromStdString(rec->nodeStats.m_addr_name);
169+
case ConnectionType:
170+
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
167171
case Network:
168172
return GUIUtil::NetworkToQString(rec->nodeStats.m_network);
169173
case Ping:
@@ -177,6 +181,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
177181
}
178182
} else if (role == Qt::TextAlignmentRole) {
179183
switch (index.column()) {
184+
case ConnectionType:
180185
case Network:
181186
return QVariant(Qt::AlignCenter);
182187
case Ping:

src/qt/peertablemodel.h

+10-6
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 {
@@ -94,6 +95,9 @@ public Q_SLOTS:
9495
/*: Title of Peers Table column which contains the
9596
IP/Onion/I2P address of the connected peer. */
9697
tr("Address"),
98+
/*: Title of Peers Table column which describes the type of
99+
peer connection. The "type" describes why the connection exists. */
100+
tr("Type"),
97101
/*: Title of Peers Table column which states the network the peer
98102
connected through. */
99103
tr("Network"),

src/qt/rpcconsole.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ void RPCConsole::updateDetailWidget()
12531253
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
12541254
ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion));
12551255
ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
1256-
ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type));
1256+
ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type, /* prepend_direction */ true));
12571257
ui->peerNetwork->setText(GUIUtil::NetworkToQString(stats->nodeStats.m_network));
12581258
if (stats->nodeStats.m_permissionFlags == NetPermissionFlags::None) {
12591259
ui->peerPermissions->setText(tr("N/A"));

0 commit comments

Comments
 (0)