Skip to content

Commit 76277cc

Browse files
committed
qt: Hide peer detail view if multiple are selected
1 parent 4946400 commit 76277cc

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

src/qt/rpcconsole.cpp

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
492492
m_node.rpcSetTimerInterfaceIfUnset(rpcTimerInterface);
493493

494494
setTrafficGraphRange(INITIAL_TRAFFIC_GRAPH_MINS);
495-
496-
ui->detailWidget->hide();
497-
ui->peerHeading->setText(tr("Select a peer to view detailed information."));
495+
updateDetailWidget();
498496

499497
consoleFontSize = settings.value(fontSizeSettingsKey, QFont().pointSize()).toInt();
500498
clear();
@@ -625,7 +623,7 @@ void RPCConsole::setClientModel(ClientModel *model)
625623
connect(disconnectAction, &QAction::triggered, this, &RPCConsole::disconnectSelectedNode);
626624

627625
// peer table signal handling - update peer details when selecting new node
628-
connect(ui->peerWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RPCConsole::peerSelected);
626+
connect(ui->peerWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RPCConsole::updateDetailWidget);
629627
// peer table signal handling - update peer details when new nodes are added to the model
630628
connect(model->getPeerTableModel(), &PeerTableModel::layoutChanged, this, &RPCConsole::peerLayoutChanged);
631629
// peer table signal handling - cache selected node ids
@@ -1017,18 +1015,6 @@ void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
10171015
ui->lblBytesOut->setText(GUIUtil::formatBytes(totalBytesOut));
10181016
}
10191017

1020-
void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelection &deselected)
1021-
{
1022-
Q_UNUSED(deselected);
1023-
1024-
if (!clientModel || !clientModel->getPeerTableModel() || selected.indexes().isEmpty())
1025-
return;
1026-
1027-
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected.indexes().first().row());
1028-
if (stats)
1029-
updateNodeDetail(stats);
1030-
}
1031-
10321018
void RPCConsole::peerLayoutAboutToChange()
10331019
{
10341020
QModelIndexList selected = ui->peerWidget->selectionModel()->selectedIndexes();
@@ -1045,7 +1031,6 @@ void RPCConsole::peerLayoutChanged()
10451031
if (!clientModel || !clientModel->getPeerTableModel())
10461032
return;
10471033

1048-
const CNodeCombinedStats *stats = nullptr;
10491034
bool fUnselect = false;
10501035
bool fReselect = false;
10511036

@@ -1076,9 +1061,6 @@ void RPCConsole::peerLayoutChanged()
10761061
fUnselect = true;
10771062
fReselect = true;
10781063
}
1079-
1080-
// get fresh stats on the detail node.
1081-
stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
10821064
}
10831065

10841066
if (fUnselect && selectedRow >= 0) {
@@ -1093,12 +1075,20 @@ void RPCConsole::peerLayoutChanged()
10931075
}
10941076
}
10951077

1096-
if (stats)
1097-
updateNodeDetail(stats);
1078+
updateDetailWidget();
10981079
}
10991080

1100-
void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
1081+
void RPCConsole::updateDetailWidget()
11011082
{
1083+
QModelIndexList selected_rows;
1084+
auto selection_model = ui->peerWidget->selectionModel();
1085+
if (selection_model) selected_rows = selection_model->selectedRows();
1086+
if (!clientModel || !clientModel->getPeerTableModel() || selected_rows.size() != 1) {
1087+
ui->detailWidget->hide();
1088+
ui->peerHeading->setText(tr("Select a peer to view detailed information."));
1089+
return;
1090+
}
1091+
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected_rows.first().row());
11021092
// update the detail ui with latest node information
11031093
QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName) + " ");
11041094
peerAddrDetails += tr("(node id: %1)").arg(QString::number(stats->nodeStats.nodeid));
@@ -1251,8 +1241,7 @@ void RPCConsole::clearSelectedNode()
12511241
{
12521242
ui->peerWidget->selectionModel()->clearSelection();
12531243
cachedNodeids.clear();
1254-
ui->detailWidget->hide();
1255-
ui->peerHeading->setText(tr("Select a peer to view detailed information."));
1244+
updateDetailWidget();
12561245
}
12571246

12581247
void RPCConsole::showOrHideBanTableIfRequired()

src/qt/rpcconsole.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ private Q_SLOTS:
9494
void showOrHideBanTableIfRequired();
9595
/** clear the selected node */
9696
void clearSelectedNode();
97+
/** show detailed information on ui about selected node */
98+
void updateDetailWidget();
9799

98100
public Q_SLOTS:
99101
void clear(bool clearHistory = true);
@@ -115,8 +117,6 @@ public Q_SLOTS:
115117
void browseHistory(int offset);
116118
/** Scroll console view to end */
117119
void scrollToEnd();
118-
/** Handle selection of peer in peers list */
119-
void peerSelected(const QItemSelection &selected, const QItemSelection &deselected);
120120
/** Handle selection caching before update */
121121
void peerLayoutAboutToChange();
122122
/** Handle updated peer information */
@@ -137,8 +137,6 @@ public Q_SLOTS:
137137
private:
138138
void startExecutor();
139139
void setTrafficGraphRange(int mins);
140-
/** show detailed information on ui about selected node */
141-
void updateNodeDetail(const CNodeCombinedStats *stats);
142140

143141
enum ColumnWidths
144142
{

0 commit comments

Comments
 (0)