@@ -485,10 +485,10 @@ void RPCConsole::startExecutor()
485
485
486
486
void RPCConsole::on_tabWidget_currentChanged (int index)
487
487
{
488
- if (ui->tabWidget ->widget (index) == ui->tab_console )
489
- {
488
+ if (ui->tabWidget ->widget (index) == ui->tab_console )
490
489
ui->lineEdit ->setFocus ();
491
- }
490
+ else if (ui->tabWidget ->widget (index) != ui->tab_peers )
491
+ clearSelectedNode ();
492
492
}
493
493
494
494
void RPCConsole::on_openDebugLogfileButton_clicked ()
@@ -558,12 +558,11 @@ void RPCConsole::peerLayoutChanged()
558
558
return ;
559
559
560
560
// find the currently selected row
561
- int selectedRow;
561
+ int selectedRow = - 1 ;
562
562
QModelIndexList selectedModelIndex = ui->peerWidget ->selectionModel ()->selectedIndexes ();
563
- if (selectedModelIndex.isEmpty ())
564
- selectedRow = -1 ;
565
- else
563
+ if (!selectedModelIndex.isEmpty ()) {
566
564
selectedRow = selectedModelIndex.first ().row ();
565
+ }
567
566
568
567
// check if our detail node has a row in the table (it may not necessarily
569
568
// be at selectedRow since its position can change after a layout change)
@@ -573,9 +572,6 @@ void RPCConsole::peerLayoutChanged()
573
572
{
574
573
// detail node dissapeared from table (node disconnected)
575
574
fUnselect = true ;
576
- cachedNodeid = -1 ;
577
- ui->detailWidget ->hide ();
578
- ui->peerHeading ->setText (tr (" Select a peer to view detailed information." ));
579
575
}
580
576
else
581
577
{
@@ -590,10 +586,8 @@ void RPCConsole::peerLayoutChanged()
590
586
stats = clientModel->getPeerTableModel ()->getNodeStats (detailNodeRow);
591
587
}
592
588
593
- if (fUnselect && selectedRow >= 0 )
594
- {
595
- ui->peerWidget ->selectionModel ()->select (QItemSelection (selectedModelIndex.first (), selectedModelIndex.last ()),
596
- QItemSelectionModel::Deselect);
589
+ if (fUnselect && selectedRow >= 0 ) {
590
+ clearSelectedNode ();
597
591
}
598
592
599
593
if (fReselect )
@@ -694,6 +688,14 @@ void RPCConsole::disconnectSelectedNode()
694
688
// Find the node, disconnect it and clear the selected node
695
689
if (CNode *bannedNode = FindNode (strNode.toStdString ())) {
696
690
bannedNode->CloseSocketDisconnect ();
697
- ui-> peerWidget -> selectionModel ()-> clearSelection ();
691
+ clearSelectedNode ();
698
692
}
699
693
}
694
+
695
+ void RPCConsole::clearSelectedNode ()
696
+ {
697
+ ui->peerWidget ->selectionModel ()->clearSelection ();
698
+ cachedNodeid = -1 ;
699
+ ui->detailWidget ->hide ();
700
+ ui->peerHeading ->setText (tr (" Select a peer to view detailed information." ));
701
+ }
0 commit comments