Changeset 103101 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jan 29, 2024 9:08:47 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityOverviewWidget.cpp
r103019 r103101 232 232 public: 233 233 234 UIActivityOverviewItem(const QUuid &uid, const QString &strVMName , bool fIsCloudVM = false);234 UIActivityOverviewItem(const QUuid &uid, const QString &strVMName); 235 235 236 236 UIActivityOverviewItem(); 237 237 ~UIActivityOverviewItem(); 238 238 bool operator==(const UIActivityOverviewItem& other) const; 239 bool isWithGuestAdditions();240 void resetDebugger();241 239 242 240 QUuid m_VMuid; 243 241 QString m_strVMName; 244 bool m_fIsCloudVM;245 246 KMachineState m_enmMachineState;247 242 248 243 quint64 m_uCPUGuestLoad; 249 quint64 m_uCPUVMMLoad;250 251 244 quint64 m_uTotalRAM; 252 245 quint64 m_uFreeRAM; 253 246 quint64 m_uUsedRAM; 254 247 float m_fRAMUsagePercentage; 255 256 quint64 m_uNetworkDownRate; 257 quint64 m_uNetworkUpRate; 258 quint64 m_uNetworkDownTotal; 259 quint64 m_uNetworkUpTotal; 248 quint64 m_uNetworkDownRate; 249 quint64 m_uNetworkUpRate; 250 quint64 m_uNetworkDownTotal; 251 quint64 m_uNetworkUpTotal; 260 252 261 253 quint64 m_uDiskWriteRate; … … 264 256 quint64 m_uDiskReadTotal; 265 257 258 259 /** The strings of each column for the item. We update this during performance query 260 * instead of model's data function to know the string length earlier. */ 261 QMap<int, QString> m_columnData; 262 263 private: 264 265 void setupPerformanceCollector(); 266 }; 267 268 Q_DECLARE_METATYPE(UIActivityOverviewItem); 269 270 /** Each instance of UIVMActivityOverviewItem corresponds to a running vm whose stats are displayed. 271 * they are owned my the model. */ 272 /********************************************************************************************************************************* 273 * Class UIVMActivityOverviewItem definition. * 274 *********************************************************************************************************************************/ 275 class UIActivityOverviewItemLocal : public UIActivityOverviewItem 276 { 277 278 public: 279 280 UIActivityOverviewItemLocal(const QUuid &uid, const QString &strVMName); 281 282 UIActivityOverviewItemLocal(); 283 ~UIActivityOverviewItemLocal(); 284 285 bool isWithGuestAdditions(); 286 void resetDebugger(); 287 288 KMachineState m_enmMachineState; 289 quint64 m_uCPUVMMLoad; 290 266 291 quint64 m_uVMExitRate; 267 292 quint64 m_uVMExitTotal; … … 270 295 CMachineDebugger m_comDebugger; 271 296 CGuest m_comGuest; 272 /** The strings of each column for the item. We update this during performance query273 * instead of model's data function to know the string length earlier. */274 QMap<int, QString> m_columnData;275 276 private:277 278 void setupPerformanceCollector();279 297 }; 280 298 281 Q_DECLARE_METATYPE(UIActivityOverviewItem); 299 300 /********************************************************************************************************************************* 301 * Class UIVMActivityOverviewItem implementation. * 302 *********************************************************************************************************************************/ 303 UIActivityOverviewItemLocal::UIActivityOverviewItemLocal(const QUuid &uid, const QString &strVMName) 304 : UIActivityOverviewItem(uid, strVMName) 305 , m_uCPUVMMLoad(0) 306 , m_uVMExitRate(0) 307 , m_uVMExitTotal(0) 308 { 309 if (m_enmMachineState == KMachineState_Running) 310 resetDebugger(); 311 } 312 313 UIActivityOverviewItemLocal::UIActivityOverviewItemLocal() 314 : m_uCPUVMMLoad(0) 315 , m_uVMExitRate(0) 316 , m_uVMExitTotal(0) 317 { 318 } 319 320 UIActivityOverviewItemLocal::~UIActivityOverviewItemLocal() 321 { 322 if (!m_comSession.isNull()) 323 m_comSession.UnlockMachine(); 324 } 325 326 bool UIActivityOverviewItemLocal::isWithGuestAdditions() 327 { 328 if (m_comGuest.isNull()) 329 return false; 330 return m_comGuest.GetAdditionsStatus(m_comGuest.GetAdditionsRunLevel()); 331 } 332 333 void UIActivityOverviewItemLocal::resetDebugger() 334 { 335 m_comSession = uiCommon().openSession(m_VMuid, KLockType_Shared); 336 if (!m_comSession.isNull()) 337 { 338 CConsole comConsole = m_comSession.GetConsole(); 339 if (!comConsole.isNull()) 340 { 341 m_comGuest = comConsole.GetGuest(); 342 m_comDebugger = comConsole.GetDebugger(); 343 } 344 } 345 } 282 346 283 347 … … 346 410 void sltMachineRegistered(const QUuid &uId, bool fRegistered); 347 411 void sltTimeout(); 348 void sltCloudUpdateTimeout();349 412 350 413 private: … … 357 420 void removeItem(const QUuid& uMachineId); 358 421 void getHostRAMStats(); 359 QVector<CCloudClient> obtainCloudClientList(); 360 QVector<CCloudMachine> obtainCloudMachineList(); 361 362 QVector<UIActivityOverviewItem> m_itemList; 422 423 QVector<UIActivityOverviewItemLocal> m_itemList; 363 424 QMap<int, QString> m_columnTitles; 364 425 QTimer *m_pTimer; 365 QTimer *m_pCloudUpdateTimer;366 426 /** @name The following are used during UIPerformanceCollector::QueryMetricsData(..) 367 427 * @{ */ … … 793 853 * Class UIVMActivityOverviewItem implementation. * 794 854 *********************************************************************************************************************************/ 795 UIActivityOverviewItem::UIActivityOverviewItem(const QUuid &uid, const QString &strVMName , bool fIsCloudVM /* = false */)855 UIActivityOverviewItem::UIActivityOverviewItem(const QUuid &uid, const QString &strVMName) 796 856 : m_VMuid(uid) 797 857 , m_strVMName(strVMName) 798 , m_fIsCloudVM(fIsCloudVM)799 858 , m_uCPUGuestLoad(0) 800 , m_uCPUVMMLoad(0)801 859 , m_uTotalRAM(0) 802 860 , m_uFreeRAM(0) … … 811 869 , m_uDiskWriteTotal(0) 812 870 , m_uDiskReadTotal(0) 813 , m_uVMExitRate(0) 814 , m_uVMExitTotal(0) 815 { 816 if (m_enmMachineState == KMachineState_Running) 817 resetDebugger(); 871 { 818 872 } 819 873 820 874 UIActivityOverviewItem::UIActivityOverviewItem() 821 875 : m_VMuid(QUuid()) 822 , m_fIsCloudVM(false)823 876 , m_uCPUGuestLoad(0) 824 , m_uCPUVMMLoad(0)825 877 , m_uTotalRAM(0) 826 878 , m_uUsedRAM(0) … … 834 886 , m_uDiskWriteTotal(0) 835 887 , m_uDiskReadTotal(0) 836 , m_uVMExitRate(0) 837 , m_uVMExitTotal(0) 838 { 839 } 840 841 void UIActivityOverviewItem::resetDebugger() 842 { 843 m_comSession = uiCommon().openSession(m_VMuid, KLockType_Shared); 844 if (!m_comSession.isNull()) 845 { 846 CConsole comConsole = m_comSession.GetConsole(); 847 if (!comConsole.isNull()) 848 { 849 m_comGuest = comConsole.GetGuest(); 850 m_comDebugger = comConsole.GetDebugger(); 851 } 852 } 853 } 888 { 889 } 890 854 891 855 892 UIActivityOverviewItem::~UIActivityOverviewItem() 856 893 { 857 if (!m_comSession.isNull())858 m_comSession.UnlockMachine();859 894 } 860 895 … … 864 899 return true; 865 900 return false; 866 }867 868 bool UIActivityOverviewItem::isWithGuestAdditions()869 {870 if (m_comGuest.isNull())871 return false;872 return m_comGuest.GetAdditionsStatus(m_comGuest.GetAdditionsRunLevel());873 901 } 874 902 … … 967 995 :QAbstractTableModel(parent) 968 996 , m_pTimer(new QTimer(this)) 969 , m_pCloudUpdateTimer(new QTimer(this))970 997 { 971 998 initialize(); … … 987 1014 m_pTimer->start(1000); 988 1015 } 989 990 if (m_pCloudUpdateTimer)991 {992 connect(m_pCloudUpdateTimer, &QTimer::timeout, this, &UIActivityOverviewModel::sltCloudUpdateTimeout);993 m_pCloudUpdateTimer->start(10 * 1000);994 }995 1016 } 996 1017 … … 1015 1036 else 1016 1037 m_pTimer->stop(); 1017 }1018 if (m_pCloudUpdateTimer)1019 {1020 if (fShouldUpdate)1021 m_pCloudUpdateTimer->start();1022 else1023 m_pCloudUpdateTimer->stop();1024 1038 } 1025 1039 } … … 1272 1286 emit sigDataUpdate(); 1273 1287 emit sigHostStatsUpdate(m_hostStats); 1274 }1275 1276 QVector<CCloudMachine> UIActivityOverviewModel::obtainCloudMachineList()1277 {1278 QVector<CCloudMachine> cloudMachineList;1279 QVector<CCloudClient> cloudClientList = obtainCloudClientList();1280 foreach (const CCloudClient &comClient, cloudClientList)1281 {1282 cloudMachineList << comClient.GetCloudMachineList();1283 }1284 return cloudMachineList;1285 }1286 1287 QVector<CCloudClient> UIActivityOverviewModel::obtainCloudClientList()1288 {1289 QVector<CCloudClient> comCloudClients;1290 /* Acquire Cloud Profile Manager restrictions: */1291 const QStringList restrictions = gEDataManager->cloudProfileManagerRestrictions();1292 1293 foreach (CCloudProvider comCloudProvider, listCloudProviders())1294 {1295 /* Skip if we have nothing to populate: */1296 if (comCloudProvider.isNull())1297 continue;1298 1299 /* Acquire provider id: */1300 QUuid uProviderId;1301 if (!cloudProviderId(comCloudProvider, uProviderId))1302 continue;1303 1304 /* Acquire provider short name: */1305 QString strProviderShortName;1306 if (!cloudProviderShortName(comCloudProvider, strProviderShortName))1307 continue;1308 1309 /* Make sure this provider isn't restricted: */1310 const QString strProviderPath = QString("/%1").arg(strProviderShortName);1311 if (restrictions.contains(strProviderPath))1312 continue;1313 1314 /* Acquire list of profiles: */1315 const QVector<CCloudProfile> profiles = listCloudProfiles(comCloudProvider);1316 if (profiles.isEmpty())1317 continue;1318 1319 foreach (CCloudProfile comCloudProfile, profiles)1320 {1321 /* Skip if we have nothing to populate: */1322 if (comCloudProfile.isNull())1323 continue;1324 1325 /* Acquire profile name: */1326 QString strProfileName;1327 if (!cloudProfileName(comCloudProfile, strProfileName))1328 continue;1329 1330 /* Make sure this profile isn't restricted: */1331 const QString strProfilePath = QString("/%1/%2").arg(strProviderShortName, strProfileName);1332 if (restrictions.contains(strProfilePath))1333 continue;1334 1335 1336 QString strErrorMessage;1337 /* Create read cloud machine list task: */1338 const UICloudEntityKey cloudProfileKey = UICloudEntityKey(strProviderShortName, strProfileName);1339 CCloudClient comCloudClient = cloudClientByName(cloudProfileKey.m_strProviderShortName,1340 cloudProfileKey.m_strProfileName,1341 strErrorMessage);1342 if (strErrorMessage.isEmpty() && comCloudClient.isOk())1343 comCloudClients << comCloudClient;1344 }1345 }1346 return comCloudClients;1347 }1348 1349 void UIActivityOverviewModel::sltCloudUpdateTimeout()1350 {1351 /* Update the m_items list: This is necessary as we dont have add/remove/change events for cloud machines: */1352 QVector<CCloudMachine> cloudMachines = obtainCloudMachineList();1353 foreach (const CCloudMachine &comMachine, cloudMachines)1354 {1355 if (!comMachine.isOk())1356 continue;1357 UIActivityOverviewItem cloudVMItem(comMachine.GetId(), comMachine.GetName(), true /* cloud vm*/);1358 if (m_itemList.contains(cloudVMItem))1359 continue;1360 m_itemList << cloudVMItem;1361 }1362 1288 } 1363 1289 … … 1469 1395 void UIActivityOverviewModel::addItem(const QUuid& uMachineId, const QString& strMachineName, KMachineState enmState) 1470 1396 { 1471 UIActivityOverviewItem newItem(uMachineId, strMachineName);1397 UIActivityOverviewItemLocal newItem(uMachineId, strMachineName); 1472 1398 newItem.m_enmMachineState = enmState; 1473 1399 m_itemList.append(newItem);
Note:
See TracChangeset
for help on using the changeset viewer.