[Qt] deselect peer when switching away from peers tab in RPC console
This commit is contained in:
parent
7211adad85
commit
e059726811
2 changed files with 20 additions and 16 deletions
|
@ -485,10 +485,10 @@ void RPCConsole::startExecutor()
|
||||||
|
|
||||||
void RPCConsole::on_tabWidget_currentChanged(int index)
|
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();
|
ui->lineEdit->setFocus();
|
||||||
}
|
else if (ui->tabWidget->widget(index) != ui->tab_peers)
|
||||||
|
clearSelectedNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPCConsole::on_openDebugLogfileButton_clicked()
|
void RPCConsole::on_openDebugLogfileButton_clicked()
|
||||||
|
@ -558,12 +558,11 @@ void RPCConsole::peerLayoutChanged()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// find the currently selected row
|
// find the currently selected row
|
||||||
int selectedRow;
|
int selectedRow = -1;
|
||||||
QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes();
|
QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes();
|
||||||
if (selectedModelIndex.isEmpty())
|
if (!selectedModelIndex.isEmpty()) {
|
||||||
selectedRow = -1;
|
|
||||||
else
|
|
||||||
selectedRow = selectedModelIndex.first().row();
|
selectedRow = selectedModelIndex.first().row();
|
||||||
|
}
|
||||||
|
|
||||||
// check if our detail node has a row in the table (it may not necessarily
|
// 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)
|
// 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)
|
// detail node dissapeared from table (node disconnected)
|
||||||
fUnselect = true;
|
fUnselect = true;
|
||||||
cachedNodeid = -1;
|
|
||||||
ui->detailWidget->hide();
|
|
||||||
ui->peerHeading->setText(tr("Select a peer to view detailed information."));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -590,10 +586,8 @@ void RPCConsole::peerLayoutChanged()
|
||||||
stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
|
stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fUnselect && selectedRow >= 0)
|
if (fUnselect && selectedRow >= 0) {
|
||||||
{
|
clearSelectedNode();
|
||||||
ui->peerWidget->selectionModel()->select(QItemSelection(selectedModelIndex.first(), selectedModelIndex.last()),
|
|
||||||
QItemSelectionModel::Deselect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fReselect)
|
if (fReselect)
|
||||||
|
@ -694,6 +688,14 @@ void RPCConsole::disconnectSelectedNode()
|
||||||
// Find the node, disconnect it and clear the selected node
|
// Find the node, disconnect it and clear the selected node
|
||||||
if (CNode *bannedNode = FindNode(strNode.toStdString())) {
|
if (CNode *bannedNode = FindNode(strNode.toStdString())) {
|
||||||
bannedNode->CloseSocketDisconnect();
|
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."));
|
||||||
|
}
|
||||||
|
|
|
@ -90,6 +90,8 @@ private:
|
||||||
void setTrafficGraphRange(int mins);
|
void setTrafficGraphRange(int mins);
|
||||||
/** show detailed information on ui about selected node */
|
/** show detailed information on ui about selected node */
|
||||||
void updateNodeDetail(const CNodeCombinedStats *stats);
|
void updateNodeDetail(const CNodeCombinedStats *stats);
|
||||||
|
/** clear the selected node */
|
||||||
|
void clearSelectedNode();
|
||||||
|
|
||||||
enum ColumnWidths
|
enum ColumnWidths
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue