MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / peerLayoutChanged

Method peerLayoutChanged

src/qt/rpcconsole.cpp:1051–1106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1049}
1050
1051void RPCConsole::peerLayoutChanged()
1052{
1053 if (!clientModel || !clientModel->getPeerTableModel())
1054 return;
1055
1056 const CNodeCombinedStats *stats = nullptr;
1057 bool fUnselect = false;
1058 bool fReselect = false;
1059
1060 if (cachedNodeids.empty()) // no node selected yet
1061 return;
1062
1063 // find the currently selected row
1064 int selectedRow = -1;
1065 QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes();
1066 if (!selectedModelIndex.isEmpty()) {
1067 selectedRow = selectedModelIndex.first().row();
1068 }
1069
1070 // check if our detail node has a row in the table (it may not necessarily
1071 // be at selectedRow since its position can change after a layout change)
1072 int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeids.first());
1073
1074 if (detailNodeRow < 0)
1075 {
1076 // detail node disappeared from table (node disconnected)
1077 fUnselect = true;
1078 }
1079 else
1080 {
1081 if (detailNodeRow != selectedRow)
1082 {
1083 // detail node moved position
1084 fUnselect = true;
1085 fReselect = true;
1086 }
1087
1088 // get fresh stats on the detail node.
1089 stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
1090 }
1091
1092 if (fUnselect && selectedRow >= 0) {
1093 clearSelectedNode();
1094 }
1095
1096 if (fReselect)
1097 {
1098 for(int i = 0; i < cachedNodeids.size(); i++)
1099 {
1100 ui->peerWidget->selectRow(clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeids.at(i)));
1101 }
1102 }
1103
1104 if (stats)
1105 updateNodeDetail(stats);
1106}
1107
1108void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)

Callers

nothing calls this directly

Calls 6

getPeerTableModelMethod · 0.80
firstMethod · 0.80
getRowByNodeIdMethod · 0.80
getNodeStatsMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected