@@ -343,7 +343,6 @@ RPCConsole::RPCConsole(const PlatformStyle *_platformStyle, QWidget *parent) :
343
343
ui(new Ui::RPCConsole),
344
344
clientModel(0 ),
345
345
historyPtr(0 ),
346
- cachedNodeid(-1 ),
347
346
platformStyle(_platformStyle),
348
347
peersTableContextMenu(0 ),
349
348
banTableContextMenu(0 ),
@@ -514,7 +513,9 @@ void RPCConsole::setClientModel(ClientModel *model)
514
513
this , SLOT (peerSelected (const QItemSelection &, const QItemSelection &)));
515
514
// peer table signal handling - update peer details when new nodes are added to the model
516
515
connect (model->getPeerTableModel (), SIGNAL (layoutChanged ()), this , SLOT (peerLayoutChanged ()));
517
-
516
+ // peer table signal handling - cache selected node ids
517
+ connect (model->getPeerTableModel (), SIGNAL (layoutAboutToChange ()), this , SLOT (peerLayoutAboutToChange ()));
518
+
518
519
// set up ban table
519
520
ui->banlistWidget ->setModel (model->getBanTableModel ());
520
521
ui->banlistWidget ->verticalHeader ()->hide ();
@@ -825,6 +826,17 @@ void RPCConsole::peerSelected(const QItemSelection &selected, const QItemSelecti
825
826
updateNodeDetail (stats);
826
827
}
827
828
829
+ void RPCConsole::peerLayoutAboutToChange ()
830
+ {
831
+ QModelIndexList selected = ui->peerWidget ->selectionModel ()->selectedIndexes ();
832
+ cachedNodeids.clear ();
833
+ for (int i = 0 ; i < selected.size (); i++)
834
+ {
835
+ const CNodeCombinedStats *stats = clientModel->getPeerTableModel ()->getNodeStats (selected.at (i).row ());
836
+ cachedNodeids.append (stats->nodeStats .nodeid );
837
+ }
838
+ }
839
+
828
840
void RPCConsole::peerLayoutChanged ()
829
841
{
830
842
if (!clientModel || !clientModel->getPeerTableModel ())
@@ -834,7 +846,7 @@ void RPCConsole::peerLayoutChanged()
834
846
bool fUnselect = false ;
835
847
bool fReselect = false ;
836
848
837
- if (cachedNodeid == - 1 ) // no node selected yet
849
+ if (cachedNodeids. empty () ) // no node selected yet
838
850
return ;
839
851
840
852
// find the currently selected row
@@ -846,7 +858,7 @@ void RPCConsole::peerLayoutChanged()
846
858
847
859
// check if our detail node has a row in the table (it may not necessarily
848
860
// be at selectedRow since its position can change after a layout change)
849
- int detailNodeRow = clientModel->getPeerTableModel ()->getRowByNodeId (cachedNodeid );
861
+ int detailNodeRow = clientModel->getPeerTableModel ()->getRowByNodeId (cachedNodeids. first () );
850
862
851
863
if (detailNodeRow < 0 )
852
864
{
@@ -872,7 +884,10 @@ void RPCConsole::peerLayoutChanged()
872
884
873
885
if (fReselect )
874
886
{
875
- ui->peerWidget ->selectRow (detailNodeRow);
887
+ for (int i = 0 ; i < cachedNodeids.size (); i++)
888
+ {
889
+ ui->peerWidget ->selectRow (clientModel->getPeerTableModel ()->getRowByNodeId (cachedNodeids.at (i)));
890
+ }
876
891
}
877
892
878
893
if (stats)
@@ -881,9 +896,6 @@ void RPCConsole::peerLayoutChanged()
881
896
882
897
void RPCConsole::updateNodeDetail (const CNodeCombinedStats *stats)
883
898
{
884
- // Update cached nodeid
885
- cachedNodeid = stats->nodeStats .nodeid ;
886
-
887
899
// update the detail ui with latest node information
888
900
QString peerAddrDetails (QString::fromStdString (stats->nodeStats .addrName ) + " " );
889
901
peerAddrDetails += tr (" (node id: %1)" ).arg (QString::number (stats->nodeStats .nodeid ));
@@ -1038,7 +1050,7 @@ void RPCConsole::unbanSelectedNode()
1038
1050
void RPCConsole::clearSelectedNode ()
1039
1051
{
1040
1052
ui->peerWidget ->selectionModel ()->clearSelection ();
1041
- cachedNodeid = - 1 ;
1053
+ cachedNodeids. clear () ;
1042
1054
ui->detailWidget ->hide ();
1043
1055
ui->peerHeading ->setText (tr (" Select a peer to view detailed information." ));
1044
1056
}
0 commit comments