Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
} else if (role == Qt::TextAlignmentRole) {
switch (column) {
case NetNodeId:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
case Address:
return {};
case ConnectionType:
Expand Down
20 changes: 19 additions & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@
#include <QDateTime>
#include <QFont>
#include <QKeyEvent>
#include <QLatin1String>
#include <QLocale>
#include <QMenu>
#include <QMessageBox>
#include <QScreen>
#include <QScrollBar>
#include <QSettings>
#include <QString>
#include <QStringList>
#include <QStyledItemDelegate>
#include <QTime>
#include <QTimer>

#include <QVariant>

const int CONSOLE_HISTORY = 50;
const int INITIAL_TRAFFIC_GRAPH_MINS = 30;
Expand Down Expand Up @@ -128,6 +131,20 @@ class QtRPCTimerInterface: public RPCTimerInterface
}
};

class PeerIdViewDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit PeerIdViewDelegate(QObject* parent = nullptr)
: QStyledItemDelegate(parent) {}

QString displayText(const QVariant& value, const QLocale& locale) const override
{
// Additional spaces should visually separate right-aligned content
// from the next column to the right.
return value.toString() + QLatin1String(" ");
}
};

#include <qt/rpcconsole.moc>

Expand Down Expand Up @@ -634,6 +651,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH);
ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
ui->peerWidget->setItemDelegateForColumn(PeerTableModel::NetNodeId, new PeerIdViewDelegate(this));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion on this. I think with and without the PeerIdViewDelegate both look fine:

With Delegate Without Delegate
Screen Shot 2021-05-12 at 9 46 31 PM Screen Shot 2021-05-12 at 10 09 38 PM

Copy link
Member

@jonatack jonatack May 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing this patch to my attention @jarolrod and for this helpful comparison. I prefer with the added separation between the right-aligned peer number and the left-aligned address as proposed here (which is why I originally proposed center-aligned to have the spacing as well and aligned under the header that is also center-aligned, but the version proposed in this PR seems good too).


// create peer table context menu
peersTableContextMenu = new QMenu(this);
Expand Down