diff options
author | Philip Kaufmann <phil.kaufmann@t-online.de> | 2015-06-06 10:38:15 +0200 |
---|---|---|
committer | Philip Kaufmann <phil.kaufmann@t-online.de> | 2015-06-11 08:39:08 +0200 |
commit | e0597268116cf90d961abeba9d14aaad0ab682d2 (patch) | |
tree | ef2321c125402ea60b62f9f1af3386a041179b0e /src/qt | |
parent | 7211adad85275db24835bb877a29b28adcf06f62 (diff) |
[Qt] deselect peer when switching away from peers tab in RPC console
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/rpcconsole.cpp | 32 | ||||
-rw-r--r-- | src/qt/rpcconsole.h | 4 |
2 files changed, 20 insertions, 16 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 73ee33cbd8..681617bd81 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -485,10 +485,10 @@ void RPCConsole::startExecutor() void RPCConsole::on_tabWidget_currentChanged(int index) { - if(ui->tabWidget->widget(index) == ui->tab_console) - { + if (ui->tabWidget->widget(index) == ui->tab_console) ui->lineEdit->setFocus(); - } + else if (ui->tabWidget->widget(index) != ui->tab_peers) + clearSelectedNode(); } void RPCConsole::on_openDebugLogfileButton_clicked() @@ -558,12 +558,11 @@ void RPCConsole::peerLayoutChanged() return; // find the currently selected row - int selectedRow; + int selectedRow = -1; QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes(); - if (selectedModelIndex.isEmpty()) - selectedRow = -1; - else + if (!selectedModelIndex.isEmpty()) { selectedRow = selectedModelIndex.first().row(); + } // check if our detail node has a row in the table (it may not necessarily // be at selectedRow since its position can change after a layout change) @@ -573,9 +572,6 @@ void RPCConsole::peerLayoutChanged() { // detail node dissapeared from table (node disconnected) fUnselect = true; - cachedNodeid = -1; - ui->detailWidget->hide(); - ui->peerHeading->setText(tr("Select a peer to view detailed information.")); } else { @@ -590,10 +586,8 @@ void RPCConsole::peerLayoutChanged() stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow); } - if (fUnselect && selectedRow >= 0) - { - ui->peerWidget->selectionModel()->select(QItemSelection(selectedModelIndex.first(), selectedModelIndex.last()), - QItemSelectionModel::Deselect); + if (fUnselect && selectedRow >= 0) { + clearSelectedNode(); } if (fReselect) @@ -694,6 +688,14 @@ void RPCConsole::disconnectSelectedNode() // Find the node, disconnect it and clear the selected node if (CNode *bannedNode = FindNode(strNode.toStdString())) { bannedNode->CloseSocketDisconnect(); - ui->peerWidget->selectionModel()->clearSelection(); + clearSelectedNode(); } } + +void RPCConsole::clearSelectedNode() +{ + ui->peerWidget->selectionModel()->clearSelection(); + cachedNodeid = -1; + ui->detailWidget->hide(); + ui->peerHeading->setText(tr("Select a peer to view detailed information.")); +} diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 767e9aaeea..a309df7ba7 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -76,7 +76,7 @@ public slots: void peerSelected(const QItemSelection &selected, const QItemSelection &deselected); /** Handle updated peer information */ void peerLayoutChanged(); - /** Disconnect a selected node on the Peers tab */ + /** Disconnect a selected node on the Peers tab */ void disconnectSelectedNode(); signals: @@ -90,6 +90,8 @@ private: void setTrafficGraphRange(int mins); /** show detailed information on ui about selected node */ void updateNodeDetail(const CNodeCombinedStats *stats); + /** clear the selected node */ + void clearSelectedNode(); enum ColumnWidths { |