Skip to content

Commit 69b8b5d

Browse files
committed
qt: Align numbers in the "Peer Id" column to the right
1 parent 6b49d88 commit 69b8b5d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/qt/peertablemodel.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
132132
} else if (role == Qt::TextAlignmentRole) {
133133
switch (column) {
134134
case NetNodeId:
135+
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
135136
case Address:
136137
return {};
137138
case ConnectionType:

src/qt/rpcconsole.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,19 @@
3737
#include <QDateTime>
3838
#include <QFont>
3939
#include <QKeyEvent>
40+
#include <QLatin1String>
41+
#include <QLocale>
4042
#include <QMenu>
4143
#include <QMessageBox>
4244
#include <QScreen>
4345
#include <QScrollBar>
4446
#include <QSettings>
4547
#include <QString>
4648
#include <QStringList>
49+
#include <QStyledItemDelegate>
4750
#include <QTime>
4851
#include <QTimer>
49-
52+
#include <QVariant>
5053

5154
const int CONSOLE_HISTORY = 50;
5255
const int INITIAL_TRAFFIC_GRAPH_MINS = 30;
@@ -128,6 +131,20 @@ class QtRPCTimerInterface: public RPCTimerInterface
128131
}
129132
};
130133

134+
class PeerIdViewDelegate : public QStyledItemDelegate
135+
{
136+
Q_OBJECT
137+
public:
138+
explicit PeerIdViewDelegate(QObject* parent = nullptr)
139+
: QStyledItemDelegate(parent) {}
140+
141+
QString displayText(const QVariant& value, const QLocale& locale) const override
142+
{
143+
// Additional spaces should visually separate right-aligned content
144+
// from the next column to the right.
145+
return value.toString() + QLatin1String(" ");
146+
}
147+
};
131148

132149
#include <qt/rpcconsole.moc>
133150

@@ -634,6 +651,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
634651
ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
635652
ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH);
636653
ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
654+
ui->peerWidget->setItemDelegateForColumn(PeerTableModel::NetNodeId, new PeerIdViewDelegate(this));
637655

638656
// create peer table context menu
639657
peersTableContextMenu = new QMenu(this);

0 commit comments

Comments
 (0)