Changeset 86731 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 28, 2020 10:52:12 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r86708 r86731 350 350 351 351 /********************************************************************************************************************************* 352 * Class UICloudEntityKey implementation. * 353 *********************************************************************************************************************************/ 354 355 UICloudEntityKey::UICloudEntityKey(const QString &strProviderShortName /* = QString() */, 356 const QString &strProfileName /* = QString() */, 357 const QString &strMachineName /* = QString() */) 358 : m_strProviderShortName(strProviderShortName) 359 , m_strProfileName(strProfileName) 360 , m_strMachineName(strMachineName) 361 { 362 } 363 364 UICloudEntityKey::UICloudEntityKey(const UICloudEntityKey &another) 365 : m_strProviderShortName(another.m_strProviderShortName) 366 , m_strProfileName(another.m_strProfileName) 367 , m_strMachineName(another.m_strMachineName) 368 { 369 } 370 371 bool UICloudEntityKey::operator==(const UICloudEntityKey &another) const 372 { 373 return true 374 && m_strProviderShortName == another.m_strProviderShortName 375 && m_strProfileName == another.m_strProfileName 376 && m_strProfileName == another.m_strProfileName 377 ; 378 } 379 380 QString UICloudEntityKey::toString() const 381 { 382 QString strResult; 383 if (m_strProviderShortName.isEmpty()) 384 return strResult; 385 strResult += QString("/%1").arg(m_strProviderShortName); 386 if (m_strProfileName.isEmpty()) 387 return strResult; 388 strResult += QString("/%1").arg(m_strProfileName); 389 if (m_strMachineName.isEmpty()) 390 return strResult; 391 strResult += QString("/%1").arg(m_strMachineName); 392 return strResult; 393 } 394 395 396 /********************************************************************************************************************************* 352 397 * Class UIChooserAbstractModel implementation. * 353 398 *********************************************************************************************************************************/ … … 582 627 } 583 628 584 void UIChooserAbstractModel::insertCloudAccountKey(const UICloudAccountKey &key) 585 { 586 m_cloudAccountKeysBeingUpdated.insert(key); 629 void UIChooserAbstractModel::insertCloudEntityKey(const UICloudEntityKey &key) 630 { 631 // printf("Cloud entity with key %s being updated..\n", key.toString().toUtf8().constData()); 632 m_cloudEntityKeysBeingUpdated.insert(key); 587 633 emit sigCloudUpdateStateChanged(); 588 634 } 589 635 590 void UIChooserAbstractModel::removeCloudAccountKey(const UICloudAccountKey &key) 591 { 592 m_cloudAccountKeysBeingUpdated.remove(key); 636 void UIChooserAbstractModel::removeCloudEntityKey(const UICloudEntityKey &key) 637 { 638 // printf("Cloud entity with key %s is updated!\n", key.toString().toUtf8().constData()); 639 m_cloudEntityKeysBeingUpdated.remove(key); 593 640 emit sigCloudUpdateStateChanged(); 594 641 } 595 642 596 bool UIChooserAbstractModel::containsCloud AccountKey(const UICloudAccountKey &key) const597 { 598 return m_cloud AccountKeysBeingUpdated.contains(key);643 bool UIChooserAbstractModel::containsCloudEntityKey(const UICloudEntityKey &key) const 644 { 645 return m_cloudEntityKeysBeingUpdated.contains(key); 599 646 } 600 647 601 648 bool UIChooserAbstractModel::isCloudUpdateInProgress() const 602 649 { 603 return !m_cloud AccountKeysBeingUpdated.isEmpty();650 return !m_cloudEntityKeysBeingUpdated.isEmpty(); 604 651 } 605 652 … … 860 907 } 861 908 862 /* Remove cloud accountkey from the list of keys currently being updated: */863 const UICloud AccountKey accountKey = qMakePair(strProviderShortName, strProfileName);864 removeCloud AccountKey(accountKey);909 /* Remove cloud entity key from the list of keys currently being updated: */ 910 const UICloudEntityKey cloudEntityKey = UICloudEntityKey(strProviderShortName, strProfileName); 911 removeCloudEntityKey(cloudEntityKey); 865 912 } 866 913 … … 1060 1107 createCloudMachineNode(pProfileNode, UIFakeCloudVirtualMachineItemState_Loading); 1061 1108 1062 /* Insert cloud accountkey into a list of keys currently being updated: */1063 const UICloud AccountKey cloudAccountKey = qMakePair(strProviderShortName, strProfileName);1064 insertCloud AccountKey(cloudAccountKey);1109 /* Insert cloud entity key into a list of keys currently being updated: */ 1110 const UICloudEntityKey cloudEntityKey = UICloudEntityKey(strProviderShortName, strProfileName); 1111 insertCloudEntityKey(cloudEntityKey); 1065 1112 1066 1113 /* Create list cloud machines task: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r86678 r86731 33 33 #include "COMEnums.h" 34 34 35 /* Typedefs: */36 typedef QPair<QString, QString> UICloudAccountKey;37 38 35 /* Forward declaration: */ 39 36 class UIChooser; … … 42 39 class CCloudMachine; 43 40 class CMachine; 41 42 43 /** Cloud entity key definition. */ 44 struct UICloudEntityKey 45 { 46 /** Constructs cloud entity key on the basis of passed parameters. 47 * @param strProviderShortName Brings provider short name. 48 * @param strProfileName Brings profile name. 49 * @param strMachineName Brings machine name. */ 50 UICloudEntityKey(const QString &strProviderShortName = QString(), 51 const QString &strProfileName = QString(), 52 const QString &strMachineName = QString()); 53 /** Constructs cloud entity key on the basis of @a another one. */ 54 UICloudEntityKey(const UICloudEntityKey &another); 55 56 /** Returns whether this one key equals to @a another one. */ 57 bool operator==(const UICloudEntityKey &another) const; 58 59 /** Returns string key representation. */ 60 QString toString() const; 61 62 /** Holds provider short name. */ 63 QString m_strProviderShortName; 64 /** Holds profile name. */ 65 QString m_strProfileName; 66 /** Holds machine name. */ 67 QString m_strMachineName; 68 }; 69 70 inline uint qHash(const UICloudEntityKey &key, uint uSeed) 71 { 72 return qHash(key.toString(), uSeed); 73 } 74 44 75 45 76 /** QObject extension used as VM Chooser-pane abstract model. … … 134 165 /** @name Cloud update stuff. 135 166 * @{ */ 136 /** Inserts cloud account@a key into a set of keys currently being updated. */137 void insertCloud AccountKey(const UICloudAccountKey &key);138 /** Removes cloud account@a key from a set of keys currently being updated. */139 void removeCloud AccountKey(const UICloudAccountKey &key);140 /** Returns whether cloud account@a key is a part of key set currently being updated. */141 bool containsCloud AccountKey(const UICloudAccountKey &key) const;142 /** Returns whether at least one cloud accountupdate is in progress. */167 /** Inserts cloud entity @a key into a set of keys currently being updated. */ 168 void insertCloudEntityKey(const UICloudEntityKey &key); 169 /** Removes cloud entity @a key from a set of keys currently being updated. */ 170 void removeCloudEntityKey(const UICloudEntityKey &key); 171 /** Returns whether cloud entity @a key is a part of key set currently being updated. */ 172 bool containsCloudEntityKey(const UICloudEntityKey &key) const; 173 /** Returns whether at least one cloud entity update is in progress. */ 143 174 bool isCloudUpdateInProgress() const; 144 175 /** @} */ … … 345 376 /** @name Cloud update stuff. 346 377 * @{ */ 347 /** Holds the set of cloud accountkeys currently being updated. */348 QSet<UICloud AccountKey> m_cloudAccountKeysBeingUpdated;378 /** Holds the set of cloud entity keys currently being updated. */ 379 QSet<UICloudEntityKey> m_cloudEntityKeysBeingUpdated; 349 380 /** @} */ 350 381 }; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r86706 r86731 927 927 case UIVirtualMachineItemType_CloudFake: 928 928 { 929 /* Compose cloud accountkey: */929 /* Compose cloud entity key: */ 930 930 UIChooserItem *pParent = pItem->parentItem(); 931 931 AssertPtrReturnVoid(pParent); … … 933 933 AssertPtrReturnVoid(pParentOfParent); 934 934 935 /* Insert cloud accountkey into a list of keys currently being updated: */936 const UICloud AccountKey cloudAccountKey = qMakePair(pParentOfParent->name(), pParent->name());937 insertCloud AccountKey(cloudAccountKey);935 /* Insert cloud entity key into a list of keys currently being updated: */ 936 const UICloudEntityKey cloudEntityKey = UICloudEntityKey(pParentOfParent->name(), pParent->name()); 937 insertCloudEntityKey(cloudEntityKey); 938 938 939 939 /* Create list cloud machines task: */ 940 UITaskCloudListMachines *pTask = new UITaskCloudListMachines(cloud AccountKey.first /* short provider name */,941 cloud AccountKey.second /* profile name */,940 UITaskCloudListMachines *pTask = new UITaskCloudListMachines(cloudEntityKey.m_strProviderShortName, 941 cloudEntityKey.m_strProfileName, 942 942 true /* with refresh? */); 943 943 AssertPtrReturnVoid(pTask); … … 1309 1309 { 1310 1310 /* For every selected item: */ 1311 QSet<UICloud AccountKey> selectedCloudAccountKeys;1311 QSet<UICloudEntityKey> selectedCloudAccountKeys; 1312 1312 foreach (UIChooserItem *pSelectedItem, selectedItems()) 1313 1313 { 1314 /* Enumerate cloud accountkeys to update: */1314 /* Enumerate cloud entity keys to update: */ 1315 1315 switch (pSelectedItem->type()) 1316 1316 { … … 1327 1327 { 1328 1328 const QString strProfileName = pChildItem->name(); 1329 const UICloud AccountKey cloudAccountKey = qMakePair(strProviderShortName, strProfileName);1330 if (!selectedCloudAccountKeys.contains(cloud AccountKey))1331 selectedCloudAccountKeys.insert(cloud AccountKey);1329 const UICloudEntityKey cloudEntityKey = UICloudEntityKey(strProviderShortName, strProfileName); 1330 if (!selectedCloudAccountKeys.contains(cloudEntityKey)) 1331 selectedCloudAccountKeys.insert(cloudEntityKey); 1332 1332 } 1333 1333 break; … … 1337 1337 const QString strProviderShortName = pSelectedItem->parentItem()->name(); 1338 1338 const QString strProfileName = pSelectedItem->name(); 1339 const UICloud AccountKey cloudAccountKey = qMakePair(strProviderShortName, strProfileName);1340 if (!selectedCloudAccountKeys.contains(cloud AccountKey))1341 selectedCloudAccountKeys.insert(cloud AccountKey);1339 const UICloudEntityKey cloudEntityKey = UICloudEntityKey(strProviderShortName, strProfileName); 1340 if (!selectedCloudAccountKeys.contains(cloudEntityKey)) 1341 selectedCloudAccountKeys.insert(cloudEntityKey); 1342 1342 break; 1343 1343 } … … 1356 1356 const QString strProviderShortName = pMachineItem->parentItem()->parentItem()->name(); 1357 1357 const QString strProfileName = pMachineItem->parentItem()->name(); 1358 const UICloud AccountKey cloudAccountKey = qMakePair(strProviderShortName, strProfileName);1359 if (!selectedCloudAccountKeys.contains(cloud AccountKey))1360 selectedCloudAccountKeys.insert(cloud AccountKey);1358 const UICloudEntityKey cloudEntityKey = UICloudEntityKey(strProviderShortName, strProfileName); 1359 if (!selectedCloudAccountKeys.contains(cloudEntityKey)) 1360 selectedCloudAccountKeys.insert(cloudEntityKey); 1361 1361 } 1362 1362 break; … … 1366 1366 1367 1367 /* Restart List Cloud Machines task for selected account keys: */ 1368 foreach (const UICloud AccountKey &cloudAccountKey, selectedCloudAccountKeys)1369 { 1370 /* Skip cloud accountkeys already being updated: */1371 if (containsCloud AccountKey(cloudAccountKey))1368 foreach (const UICloudEntityKey &cloudEntityKey, selectedCloudAccountKeys) 1369 { 1370 /* Skip cloud entity keys already being updated: */ 1371 if (containsCloudEntityKey(cloudEntityKey)) 1372 1372 continue; 1373 insertCloud AccountKey(cloudAccountKey);1374 1375 /* Create a task for particular cloud accountkey: */1376 UITaskCloudListMachines *pTask = new UITaskCloudListMachines(cloud AccountKey.first /* short provider name */,1377 cloud AccountKey.second /* profile name */,1373 insertCloudEntityKey(cloudEntityKey); 1374 1375 /* Create a task for particular cloud entity key: */ 1376 UITaskCloudListMachines *pTask = new UITaskCloudListMachines(cloudEntityKey.m_strProviderShortName, 1377 cloudEntityKey.m_strProfileName, 1378 1378 false /* with refresh? */); 1379 1379 AssertPtrReturnVoid(pTask); … … 1923 1923 1924 1924 /* For every selected machine-item: */ 1925 QSet<UICloud AccountKey> changedCloudAccountKeys;1925 QSet<UICloudEntityKey> changedCloudAccountKeys; 1926 1926 foreach (UIChooserItemMachine *pMachineItem, machineItems) 1927 1927 { … … 1947 1947 continue; 1948 1948 } 1949 /* Compose cloud accountkey to update: */1949 /* Compose cloud entity key to update: */ 1950 1950 const QString strProviderShortName = pMachineItem->parentItem()->parentItem()->name(); 1951 1951 const QString strProfileName = pMachineItem->parentItem()->name(); 1952 const UICloud AccountKey cloudAccountKey = qMakePair(strProviderShortName, strProfileName);1953 if (!changedCloudAccountKeys.contains(cloud AccountKey))1954 changedCloudAccountKeys.insert(cloud AccountKey);1952 const UICloudEntityKey cloudEntityKey = UICloudEntityKey(strProviderShortName, strProfileName); 1953 if (!changedCloudAccountKeys.contains(cloudEntityKey)) 1954 changedCloudAccountKeys.insert(cloudEntityKey); 1955 1955 } 1956 1956 1957 1957 /* Restart List Cloud Machines task for required account keys: */ 1958 foreach (const UICloud AccountKey &cloudAccountKey, changedCloudAccountKeys)1959 { 1960 /* Skip cloud accountkeys already being updated: */1961 if (containsCloud AccountKey(cloudAccountKey))1958 foreach (const UICloudEntityKey &cloudEntityKey, changedCloudAccountKeys) 1959 { 1960 /* Skip cloud entity keys already being updated: */ 1961 if (containsCloudEntityKey(cloudEntityKey)) 1962 1962 continue; 1963 insertCloud AccountKey(cloudAccountKey);1964 1965 /* Create a task for particular cloud accountkey: */1966 UITaskCloudListMachines *pTask = new UITaskCloudListMachines(cloud AccountKey.first /* short provider name */,1967 cloud AccountKey.second /* profile name */,1963 insertCloudEntityKey(cloudEntityKey); 1964 1965 /* Create a task for particular cloud entity key: */ 1966 UITaskCloudListMachines *pTask = new UITaskCloudListMachines(cloudEntityKey.m_strProviderShortName, 1967 cloudEntityKey.m_strProfileName, 1968 1968 false /* with refresh? */); 1969 1969 AssertPtrReturnVoid(pTask);
Note:
See TracChangeset
for help on using the changeset viewer.