diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 535e3374033..72d503258ee 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -649,7 +649,7 @@ void RPCConsole::setClientModel(ClientModel *model) connect(unbanAction, &QAction::triggered, this, &RPCConsole::unbanSelectedNode); // ban table signal handling - clear peer details when clicking a peer in the ban table - connect(ui->banlistWidget, &QTableView::clicked, this, &RPCConsole::clearSelectedNode); + connect(ui->banlistWidget, &QTableView::clicked, ui->peerWidget->selectionModel(), &QItemSelectionModel::clearSelection); // ban table signal handling - ensure ban table is shown or hidden (if empty) connect(model->getBanTableModel(), &BanTableModel::layoutChanged, this, &RPCConsole::showOrHideBanTableIfRequired); showOrHideBanTableIfRequired(); @@ -1118,8 +1118,9 @@ void RPCConsole::disconnectSelectedNode() // Get currently selected peer address NodeId id = nodes.at(i).data().toLongLong(); // Find the node, disconnect it and clear the selected node - if(m_node.disconnectById(id)) - clearSelectedNode(); + if (m_node.disconnectById(id)) { + clearSelectedNode(nodes.at(i)); + } } } @@ -1143,10 +1144,11 @@ void RPCConsole::banSelectedNode(int bantime) const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow); if (stats) { m_node.ban(stats->nodeStats.addr, BanReasonManuallyAdded, bantime); - m_node.disconnectByAddress(stats->nodeStats.addr); + if (m_node.disconnectByAddress(stats->nodeStats.addr)) { + clearSelectedNode(nodes.at(i)); + } } } - clearSelectedNode(); clientModel->getBanTableModel()->refresh(); } @@ -1171,11 +1173,10 @@ void RPCConsole::unbanSelectedNode() } } -void RPCConsole::clearSelectedNode() +void RPCConsole::clearSelectedNode(const QModelIndex& peer) { - ui->peerWidget->selectionModel()->clearSelection(); - cachedNodeids.clear(); - updateDetailWidget(); + auto selection = ui->peerWidget->selectionModel(); + selection->select(peer, QItemSelectionModel::Deselect | QItemSelectionModel::Rows); } void RPCConsole::showOrHideBanTableIfRequired() diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 6055233ee9c..651dc6b2ad0 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -93,7 +93,7 @@ private Q_SLOTS: /** Hides ban table if no bans are present */ void showOrHideBanTableIfRequired(); /** clear the selected node */ - void clearSelectedNode(); + void clearSelectedNode(const QModelIndex& peer); /** show detailed information on ui about selected node */ void updateDetailWidget();