@@ -487,9 +487,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
487
487
m_node.rpcSetTimerInterfaceIfUnset (rpcTimerInterface);
488
488
489
489
setTrafficGraphRange (INITIAL_TRAFFIC_GRAPH_MINS);
490
-
491
- ui->detailWidget ->hide ();
492
- ui->peerHeading ->setText (tr (" Select a peer to view detailed information." ));
490
+ updateDetailWidget ();
493
491
494
492
consoleFontSize = settings.value (fontSizeSettingsKey, QFont ().pointSize ()).toInt ();
495
493
clear ();
@@ -620,7 +618,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
620
618
connect (disconnectAction, &QAction::triggered, this , &RPCConsole::disconnectSelectedNode);
621
619
622
620
// peer table signal handling - update peer details when selecting new node
623
- connect (ui->peerWidget ->selectionModel (), &QItemSelectionModel::selectionChanged, this , &RPCConsole::peerSelected );
621
+ connect (ui->peerWidget ->selectionModel (), &QItemSelectionModel::selectionChanged, this , &RPCConsole::updateDetailWidget );
624
622
// peer table signal handling - update peer details when new nodes are added to the model
625
623
connect (model->getPeerTableModel (), &PeerTableModel::layoutChanged, this , &RPCConsole::peerLayoutChanged);
626
624
// peer table signal handling - cache selected node ids
@@ -1015,18 +1013,6 @@ void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut)
1015
1013
ui->lblBytesOut ->setText (GUIUtil::formatBytes (totalBytesOut));
1016
1014
}
1017
1015
1018
- void RPCConsole::peerSelected (const QItemSelection &selected, const QItemSelection &deselected)
1019
- {
1020
- Q_UNUSED (deselected);
1021
-
1022
- if (!clientModel || !clientModel->getPeerTableModel () || selected.indexes ().isEmpty ())
1023
- return ;
1024
-
1025
- const CNodeCombinedStats *stats = clientModel->getPeerTableModel ()->getNodeStats (selected.indexes ().first ().row ());
1026
- if (stats)
1027
- updateNodeDetail (stats);
1028
- }
1029
-
1030
1016
void RPCConsole::peerLayoutAboutToChange ()
1031
1017
{
1032
1018
QModelIndexList selected = ui->peerWidget ->selectionModel ()->selectedIndexes ();
@@ -1043,7 +1029,6 @@ void RPCConsole::peerLayoutChanged()
1043
1029
if (!clientModel || !clientModel->getPeerTableModel ())
1044
1030
return ;
1045
1031
1046
- const CNodeCombinedStats *stats = nullptr ;
1047
1032
bool fUnselect = false ;
1048
1033
bool fReselect = false ;
1049
1034
@@ -1074,9 +1059,6 @@ void RPCConsole::peerLayoutChanged()
1074
1059
fUnselect = true ;
1075
1060
fReselect = true ;
1076
1061
}
1077
-
1078
- // get fresh stats on the detail node.
1079
- stats = clientModel->getPeerTableModel ()->getNodeStats (detailNodeRow);
1080
1062
}
1081
1063
1082
1064
if (fUnselect && selectedRow >= 0 ) {
@@ -1091,12 +1073,20 @@ void RPCConsole::peerLayoutChanged()
1091
1073
}
1092
1074
}
1093
1075
1094
- if (stats)
1095
- updateNodeDetail (stats);
1076
+ updateDetailWidget ();
1096
1077
}
1097
1078
1098
- void RPCConsole::updateNodeDetail ( const CNodeCombinedStats *stats )
1079
+ void RPCConsole::updateDetailWidget ( )
1099
1080
{
1081
+ QModelIndexList selected_rows;
1082
+ auto selection_model = ui->peerWidget ->selectionModel ();
1083
+ if (selection_model) selected_rows = selection_model->selectedRows ();
1084
+ if (!clientModel || !clientModel->getPeerTableModel () || selected_rows.size () != 1 ) {
1085
+ ui->detailWidget ->hide ();
1086
+ ui->peerHeading ->setText (tr (" Select a peer to view detailed information." ));
1087
+ return ;
1088
+ }
1089
+ const CNodeCombinedStats *stats = clientModel->getPeerTableModel ()->getNodeStats (selected_rows.first ().row ());
1100
1090
// update the detail ui with latest node information
1101
1091
QString peerAddrDetails (QString::fromStdString (stats->nodeStats .addrName ) + " " );
1102
1092
peerAddrDetails += tr (" (node id: %1)" ).arg (QString::number (stats->nodeStats .nodeid ));
@@ -1254,8 +1244,7 @@ void RPCConsole::clearSelectedNode()
1254
1244
{
1255
1245
ui->peerWidget ->selectionModel ()->clearSelection ();
1256
1246
cachedNodeids.clear ();
1257
- ui->detailWidget ->hide ();
1258
- ui->peerHeading ->setText (tr (" Select a peer to view detailed information." ));
1247
+ updateDetailWidget ();
1259
1248
}
1260
1249
1261
1250
void RPCConsole::showOrHideBanTableIfRequired ()
0 commit comments