Changeset 103107 in vbox
- Timestamp:
- Jan 29, 2024 2:50:20 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityOverviewWidget.cpp
r103105 r103107 286 286 virtual bool isRunning() const override; 287 287 virtual bool isCloudVM() const override; 288 289 KMachineState m_enmMachineState; 288 void setMachineState(KMachineState enmState); 289 290 290 quint64 m_uCPUVMMLoad; 291 291 … … 299 299 CSession m_comSession; 300 300 CGuest m_comGuest; 301 KMachineState m_enmMachineState; 301 302 }; 302 303 … … 376 377 QUuid itemUid(int iIndex); 377 378 int itemIndex(const QUuid &uid); 378 /* Return the state of the machine represented by the item at @rowIndex. */ 379 KMachineState machineState(int rowIndex) const; 379 bool isVMRunning(int rowIndex) const; 380 380 void setDefaultViewFont(const QFont &font); 381 381 void setDefaultViewFontColor(const QColor &color); … … 397 397 void getHostRAMStats(); 398 398 399 QVector<UIActivityOverviewItem Local> m_itemList;399 QVector<UIActivityOverviewItem*> m_itemList; 400 400 QMap<int, QString> m_columnTitles; 401 401 QTimer *m_pTimer; … … 982 982 } 983 983 984 void UIActivityOverviewItemLocal::setMachineState(KMachineState enmState) 985 { 986 m_enmMachineState = enmState; 987 } 988 984 989 985 990 /********************************************************************************************************************************* … … 1019 1024 if (pModel) 1020 1025 { 1021 KMachineState enmLeftState = pModel->machineState(sourceLeftIndex.row());1022 KMachineState enmRightState = pModel->machineState(sourceRightIndex.row());1023 if ( (enmLeftState == KMachineState_Running) && (enmRightState != KMachineState_Running))1026 bool fLeftRunning = pModel->isVMRunning(sourceLeftIndex.row()); 1027 bool fRightRunning = pModel->isVMRunning(sourceRightIndex.row()); 1028 if (fLeftRunning && fRightRunning) 1024 1029 { 1025 1030 if (sortOrder() == Qt::AscendingOrder) … … 1028 1033 return false; 1029 1034 } 1030 if ( (enmLeftState != KMachineState_Running) && (enmRightState == KMachineState_Running))1035 if (!fLeftRunning && fRightRunning) 1031 1036 { 1032 1037 if (sortOrder() == Qt::AscendingOrder) … … 1048 1053 if (!pModel) 1049 1054 return true; 1050 if ( pModel->machineState(iSourceRow) != KMachineState_Running)1055 if (!pModel->isVMRunning(iSourceRow)) 1051 1056 return false; 1052 1057 return true; … … 1111 1116 QUuid UIActivityOverviewModel::itemUid(int iIndex) 1112 1117 { 1113 if (iIndex >= m_itemList.size() )1118 if (iIndex >= m_itemList.size() || !m_itemList[iIndex]) 1114 1119 return QUuid(); 1115 return m_itemList[iIndex] .m_VMuid;1120 return m_itemList[iIndex]->m_VMuid; 1116 1121 } 1117 1122 … … 1120 1125 for (int i = 0; i < m_itemList.size(); ++i) 1121 1126 { 1122 if (m_itemList[i].m_VMuid == uid) 1127 if (!m_itemList[i]) 1128 continue; 1129 if (m_itemList[i]->m_VMuid == uid) 1123 1130 return i; 1124 1131 } … … 1126 1133 } 1127 1134 1128 KMachineState UIActivityOverviewModel::machineState(int rowIndex) const1129 { 1130 if (rowIndex >= m_itemList.size() || rowIndex < 0 )1131 return KMachineState_Null;1132 return m_itemList[rowIndex] .m_enmMachineState;1135 bool UIActivityOverviewModel::isVMRunning(int rowIndex) const 1136 { 1137 if (rowIndex >= m_itemList.size() || rowIndex < 0 || !m_itemList[rowIndex]) 1138 return false; 1139 return m_itemList[rowIndex]->isRunning(); 1133 1140 } 1134 1141 … … 1145 1152 QVariant UIActivityOverviewModel::data(const QModelIndex &index, int role) const 1146 1153 { 1154 Q_UNUSED(index); 1155 Q_UNUSED(role); 1156 return QVariant(); 1157 #if 0 1147 1158 if (machineState(index.row()) != KMachineState_Running) 1148 1159 { … … 1163 1174 return gpConverter->toString(m_itemList[index.row()].m_enmMachineState); 1164 1175 return m_itemList[index.row()].m_columnData[index.column()]; 1176 #endif 1165 1177 } 1166 1178 … … 1170 1182 * first of all we are removing all the items, 1171 1183 * this will detach COM wrappers implicitly: */ 1184 qDeleteAll(m_itemList); 1172 1185 m_itemList.clear(); 1173 1186 /* Detaching perf. collector finally, … … 1203 1216 if (iIndex != -1 && iIndex < m_itemList.size()) 1204 1217 { 1205 m_itemList[iIndex].m_enmMachineState = state; 1206 if (state == KMachineState_Running) 1207 m_itemList[iIndex].resetDebugger(); 1218 UIActivityOverviewItemLocal *pItem = dynamic_cast<UIActivityOverviewItemLocal*>(m_itemList[iIndex]); 1219 if (pItem) 1220 { 1221 pItem->setMachineState(state); 1222 if (state == KMachineState_Running) 1223 pItem->resetDebugger(); 1224 } 1208 1225 } 1209 1226 } … … 1231 1248 void UIActivityOverviewModel::sltTimeout() 1232 1249 { 1250 #if 0 1233 1251 ULONG aPctExecuting; 1234 1252 ULONG aPctHalted; … … 1349 1367 m_columnDataMaxLength[i] = m_itemList[j].m_columnData[i].length(); 1350 1368 } 1369 #endif 1351 1370 emit sigDataUpdate(); 1352 1371 emit sigHostStatsUpdate(m_hostStats); … … 1373 1392 void UIActivityOverviewModel::queryPerformanceCollector() 1374 1393 { 1394 #if 0 1375 1395 QVector<QString> aReturnNames; 1376 1396 QVector<CUnknown> aReturnObjects; … … 1456 1476 m_itemList[i].m_fRAMUsagePercentage = 100.f * (m_itemList[i].m_uUsedRAM / (float)m_itemList[i].m_uTotalRAM); 1457 1477 } 1478 #endif 1458 1479 } 1459 1480 1460 1481 void UIActivityOverviewModel::addItem(const QUuid& uMachineId, const QString& strMachineName, KMachineState enmState) 1461 1482 { 1462 UIActivityOverviewItemLocal newItem(uMachineId, strMachineName);1463 newItem.m_enmMachineState = enmState;1464 m_itemList.append( newItem);1483 UIActivityOverviewItemLocal *pItem = new UIActivityOverviewItemLocal(uMachineId, strMachineName); 1484 pItem->setMachineState(enmState); 1485 m_itemList.append(pItem); 1465 1486 } 1466 1487 … … 1470 1491 if (iIndex == -1) 1471 1492 return; 1493 delete m_itemList[iIndex]; 1472 1494 m_itemList.remove(iIndex); 1473 1495 } … … 1804 1826 } 1805 1827 int iMachineIndex = m_pProxyModel->mapToSource(selected.indexes()[0]).row(); 1806 if ( m_pModel->machineState(iMachineIndex) != KMachineState_Running)1828 if (!m_pModel->isVMRunning(iMachineIndex)) 1807 1829 { 1808 1830 m_pVMActivityMonitorAction->setEnabled(false);
Note:
See TracChangeset
for help on using the changeset viewer.