Skip to content

Commit fe1e52f

Browse files
committed
Merge 02fda82 into merged_master (Bitcoin PR bitcoin-core/gui#179)
2 parents e353185 + 02fda82 commit fe1e52f

File tree

6 files changed

+28
-18
lines changed

6 files changed

+28
-18
lines changed

src/qt/forms/debugwindow.ui

Lines changed: 2 additions & 2 deletions
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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -779,15 +779,19 @@ QString NetworkToQString(Network net)
779779
assert(false);
780780
}
781781

782-
QString ConnectionTypeToQString(ConnectionType conn_type)
782+
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction)
783783
{
784+
QString prefix;
785+
if (prepend_direction) {
786+
prefix = (conn_type == ConnectionType::INBOUND) ? QObject::tr("Inbound") : QObject::tr("Outbound") + " ";
787+
}
784788
switch (conn_type) {
785-
case ConnectionType::INBOUND: return QObject::tr("Inbound");
786-
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay");
787-
case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay");
788-
case ConnectionType::MANUAL: return QObject::tr("Outbound Manual");
789-
case ConnectionType::FEELER: return QObject::tr("Outbound Feeler");
790-
case ConnectionType::ADDR_FETCH: return QObject::tr("Outbound Address Fetch");
789+
case ConnectionType::INBOUND: return prefix;
790+
case ConnectionType::OUTBOUND_FULL_RELAY: return prefix + QObject::tr("Full Relay");
791+
case ConnectionType::BLOCK_RELAY: return prefix + QObject::tr("Block Relay");
792+
case ConnectionType::MANUAL: return prefix + QObject::tr("Manual");
793+
case ConnectionType::FEELER: return prefix + QObject::tr("Feeler");
794+
case ConnectionType::ADDR_FETCH: return prefix + QObject::tr("Address Fetch");
791795
} // no default case, so the compiler can warn about missing cases
792796
assert(false);
793797
}

src/qt/guiutil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ namespace GUIUtil
244244
QString NetworkToQString(Network net);
245245

246246
/** Convert enum ConnectionType to QString */
247-
QString ConnectionTypeToQString(ConnectionType conn_type);
247+
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction);
248248

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

src/qt/peertablemodel.cpp

Lines changed: 5 additions & 0 deletions
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

Lines changed: 8 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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)