Skip to content

Commit ab070cf

Browse files
committed
qt: Rework RPCConsole::clearSelectedNode()
Only successfully disconnected peers are deselected from the selection.
1 parent fe0026a commit ab070cf

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/qt/rpcconsole.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
647647
connect(unbanAction, &QAction::triggered, this, &RPCConsole::unbanSelectedNode);
648648

649649
// ban table signal handling - clear peer details when clicking a peer in the ban table
650-
connect(ui->banlistWidget, &QTableView::clicked, this, &RPCConsole::clearSelectedNode);
650+
connect(ui->banlistWidget, &QTableView::clicked, ui->peerWidget->selectionModel(), &QItemSelectionModel::clearSelection);
651651
// ban table signal handling - ensure ban table is shown or hidden (if empty)
652652
connect(model->getBanTableModel(), &BanTableModel::layoutChanged, this, &RPCConsole::showOrHideBanTableIfRequired);
653653
showOrHideBanTableIfRequired();
@@ -1124,8 +1124,9 @@ void RPCConsole::disconnectSelectedNode()
11241124
// Get currently selected peer address
11251125
NodeId id = nodes.at(i).data().toLongLong();
11261126
// Find the node, disconnect it and clear the selected node
1127-
if(m_node.disconnectById(id))
1128-
clearSelectedNode();
1127+
if (m_node.disconnectById(id)) {
1128+
clearSelectedNode(nodes.at(i));
1129+
}
11291130
}
11301131
}
11311132

@@ -1149,10 +1150,11 @@ void RPCConsole::banSelectedNode(int bantime)
11491150
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
11501151
if (stats) {
11511152
m_node.ban(stats->nodeStats.addr, bantime);
1152-
m_node.disconnectByAddress(stats->nodeStats.addr);
1153+
if (m_node.disconnectByAddress(stats->nodeStats.addr)) {
1154+
clearSelectedNode(nodes.at(i));
1155+
}
11531156
}
11541157
}
1155-
clearSelectedNode();
11561158
clientModel->getBanTableModel()->refresh();
11571159
}
11581160

@@ -1177,11 +1179,10 @@ void RPCConsole::unbanSelectedNode()
11771179
}
11781180
}
11791181

1180-
void RPCConsole::clearSelectedNode()
1182+
void RPCConsole::clearSelectedNode(const QModelIndex& peer)
11811183
{
1182-
ui->peerWidget->selectionModel()->clearSelection();
1183-
cachedNodeids.clear();
1184-
updateDetailWidget();
1184+
auto selection = ui->peerWidget->selectionModel();
1185+
selection->select(peer, QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
11851186
}
11861187

11871188
void RPCConsole::showOrHideBanTableIfRequired()

src/qt/rpcconsole.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private Q_SLOTS:
9494
/** Hides ban table if no bans are present */
9595
void showOrHideBanTableIfRequired();
9696
/** clear the selected node */
97-
void clearSelectedNode();
97+
void clearSelectedNode(const QModelIndex& peer);
9898
/** show detailed information on ui about selected node */
9999
void updateDetailWidget();
100100

0 commit comments

Comments
 (0)