Skip to content

Commit

Permalink
Merge bitcoin-core/gui#179: Add Type column to peers window, update…
Browse files Browse the repository at this point in the history
… 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 bitcoin-core/gui@be4cf48  on Ubuntu 20.04 on VMWare.

Tree-SHA512: 6c6d1dbe7d6bdb616acff0aaf8f4223546f1d2524566e9cd6e5b1b3bed2be1e9b20b1bc52ed3b627df53ba1f2fe0bc76f036cf16ad934d8a446b515d9bece3b1
  • Loading branch information
MarcoFalke committed Feb 22, 2021
2 parents 5bb64ac + be4cf48 commit 02fda82
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/qt/forms/debugwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1079,10 +1079,10 @@
<item row="1" column="0">
<widget class="QLabel" name="peerConnectionTypeLabel">
<property name="toolTip">
<string>The type of peer connection: %1</string>
<string>The direction and type of peer connection: %1</string>
</property>
<property name="text">
<string>Connection Type</string>
<string>Direction/Type</string>
</property>
</widget>
</item>
Expand Down
18 changes: 11 additions & 7 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,15 +766,19 @@ QString NetworkToQString(Network net)
assert(false);
}

QString ConnectionTypeToQString(ConnectionType conn_type)
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction)
{
QString prefix;
if (prepend_direction) {
prefix = (conn_type == ConnectionType::INBOUND) ? QObject::tr("Inbound") : QObject::tr("Outbound") + " ";
}
switch (conn_type) {
case ConnectionType::INBOUND: return QObject::tr("Inbound");
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay");
case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay");
case ConnectionType::MANUAL: return QObject::tr("Outbound Manual");
case ConnectionType::FEELER: return QObject::tr("Outbound Feeler");
case ConnectionType::ADDR_FETCH: return QObject::tr("Outbound Address Fetch");
case ConnectionType::INBOUND: return prefix;
case ConnectionType::OUTBOUND_FULL_RELAY: return prefix + QObject::tr("Full Relay");
case ConnectionType::BLOCK_RELAY: return prefix + QObject::tr("Block Relay");
case ConnectionType::MANUAL: return prefix + QObject::tr("Manual");
case ConnectionType::FEELER: return prefix + QObject::tr("Feeler");
case ConnectionType::ADDR_FETCH: return prefix + QObject::tr("Address Fetch");
} // no default case, so the compiler can warn about missing cases
assert(false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ namespace GUIUtil
QString NetworkToQString(Network net);

/** Convert enum ConnectionType to QString */
QString ConnectionTypeToQString(ConnectionType conn_type);
QString ConnectionTypeToQString(ConnectionType conn_type, bool prepend_direction);

/** Convert seconds into a QString with days, hours, mins, secs */
QString formatDurationStr(int secs);
Expand Down
5 changes: 5 additions & 0 deletions src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
return pLeft->nodeid < pRight->nodeid;
case PeerTableModel::Address:
return pLeft->addrName.compare(pRight->addrName) < 0;
case PeerTableModel::ConnectionType:
return pLeft->m_conn_type < pRight->m_conn_type;
case PeerTableModel::Network:
return pLeft->m_network < pRight->m_network;
case PeerTableModel::Ping:
Expand Down Expand Up @@ -163,6 +165,8 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
case Address:
// 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);
case ConnectionType:
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
case Network:
return GUIUtil::NetworkToQString(rec->nodeStats.m_network);
case Ping:
Expand All @@ -176,6 +180,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
}
} else if (role == Qt::TextAlignmentRole) {
switch (index.column()) {
case ConnectionType:
case Network:
return QVariant(Qt::AlignCenter);
case Ping:
Expand Down
15 changes: 8 additions & 7 deletions src/qt/peertablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ class PeerTableModel : public QAbstractTableModel

enum ColumnIndex {
NetNodeId = 0,
Address = 1,
Network = 2,
Ping = 3,
Sent = 4,
Received = 5,
Subversion = 6
Address,
ConnectionType,
Network,
Ping,
Sent,
Received,
Subversion
};

enum {
Expand All @@ -87,7 +88,7 @@ public Q_SLOTS:

private:
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;
QTimer *timer;
};
Expand Down
2 changes: 1 addition & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ void RPCConsole::updateDetailWidget()
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion));
ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type));
ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type, /* prepend_direction */ true));
ui->peerNetwork->setText(GUIUtil::NetworkToQString(stats->nodeStats.m_network));
if (stats->nodeStats.m_permissionFlags == PF_NONE) {
ui->peerPermissions->setText(tr("N/A"));
Expand Down

0 comments on commit 02fda82

Please sign in to comment.