Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peers-tab: sortable directions column #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
switch (column) {
case NetNodeId:
return (qint64)rec->nodeStats.nodeid;
case Direction:
return QString::fromStdString((rec->nodeStats.fInbound ? "↓" : "↑"));
case Address:
// prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection
return QString::fromStdString((rec->nodeStats.fInbound ? "↓ " : "↑ ") + rec->nodeStats.addrName);
return QString::fromStdString(rec->nodeStats.addrName);
case ConnectionType:
return GUIUtil::ConnectionTypeToQString(rec->nodeStats.m_conn_type, /* prepend_direction */ false);
case Network:
Expand All @@ -92,6 +94,8 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
switch (column) {
case NetNodeId:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
case Direction:
return QVariant(Qt::AlignCenter);
case Address:
return {};
case ConnectionType:
Expand Down
2 changes: 2 additions & 0 deletions src/qt/peertablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class PeerTableModel : public QAbstractTableModel

enum ColumnIndex {
NetNodeId = 0,
Direction,
Address,
ConnectionType,
Network,
Expand Down Expand Up @@ -81,6 +82,7 @@ public Q_SLOTS:
/*: Title of Peers Table column which contains a
unique number used to identify a connection. */
tr("Peer"),
tr(""),
/*: Title of Peers Table column which contains the
IP/Onion/I2P address of the connected peer. */
tr("Address"),
Expand Down
2 changes: 2 additions & 0 deletions src/qt/peertablesortproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ bool PeerTableSortProxy::lessThan(const QModelIndex& left_index, const QModelInd
switch (static_cast<PeerTableModel::ColumnIndex>(left_index.column())) {
case PeerTableModel::NetNodeId:
return left_stats.nodeid < right_stats.nodeid;
case PeerTableModel::Direction:
return left_stats.fInbound < right_stats.fInbound;
case PeerTableModel::Address:
return left_stats.addrName.compare(right_stats.addrName) < 0;
case PeerTableModel::ConnectionType:
Expand Down
1 change: 1 addition & 0 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_

if (!ui->peerWidget->horizontalHeader()->restoreState(m_peer_widget_header_state)) {
ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH);
ui->peerWidget->setColumnWidth(PeerTableModel::Direction, DIRECTION_COLUMN_WIDTH);
ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH);
}
Expand Down
1 change: 1 addition & 0 deletions src/qt/rpcconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public Q_SLOTS:
enum ColumnWidths
{
ADDRESS_COLUMN_WIDTH = 200,
DIRECTION_COLUMN_WIDTH = 30,
SUBVERSION_COLUMN_WIDTH = 150,
PING_COLUMN_WIDTH = 80,
BANSUBNET_COLUMN_WIDTH = 200,
Expand Down