Changeset 86611 in vbox
- Timestamp:
- Oct 16, 2020 2:47:32 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 4 edited
-
UIChooserAbstractModel.cpp (modified) (3 diffs)
-
UIChooserAbstractModel.h (modified) (2 diffs)
-
UIChooserModel.cpp (modified) (2 diffs)
-
UIChooserModel.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r86609 r86611 713 713 } 714 714 715 void UIChooserAbstractModel::sltCloudMachine Registered(const QString &strProviderShortName,716 const QString &strProfileName,717 const CCloudMachine &comMachine)715 void UIChooserAbstractModel::sltCloudMachinesUnregistered(const QString &strProviderShortName, 716 const QString &strProfileName, 717 const QList<QUuid> &ids) 718 718 { 719 719 /* Search for profile node: */ … … 725 725 return; 726 726 727 /* Remove machine-items with passed id: */ 728 foreach (const QUuid &uId, ids) 729 pProfileNode->removeAllNodes(uId); 730 731 /* If there are no items left => add fake cloud VM node: */ 732 if (pProfileNode->nodes(UIChooserNodeType_Machine).isEmpty()) 733 new UIChooserNodeMachine(pProfileNode /* parent */, 734 0 /* position */, 735 UIFakeCloudVirtualMachineItemState_Done); 736 } 737 738 void UIChooserAbstractModel::sltCloudMachineRegistered(const QString &strProviderShortName, 739 const QString &strProfileName, 740 const CCloudMachine &comMachine) 741 { 742 /* Search for profile node: */ 743 const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName); 744 QList<UIChooserNode*> profileNodes; 745 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 746 UIChooserNode *pProfileNode = profileNodes.value(0); 747 if (!pProfileNode) 748 return; 749 727 750 /* Add new machine-item: */ 728 751 addCloudMachineIntoTheTree(strProfileNodeName, comMachine, true /* make it visible? */); 752 753 /* Search for possible fake node: */ 754 QList<UIChooserNode*> fakeNodes; 755 pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes); 756 /* Delete fake node if present: */ 757 delete fakeNodes.value(0); 758 } 759 760 void UIChooserAbstractModel::sltCloudMachinesRegistered(const QString &strProviderShortName, 761 const QString &strProfileName, 762 const QVector<CCloudMachine> &machines) 763 { 764 /* Search for profile node: */ 765 const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName); 766 QList<UIChooserNode*> profileNodes; 767 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 768 UIChooserNode *pProfileNode = profileNodes.value(0); 769 if (!pProfileNode) 770 return; 771 772 /* Add new machine-items: */ 773 foreach (const CCloudMachine &comMachine, machines) 774 addCloudMachineIntoTheTree(strProfileNodeName, comMachine, false /* make it visible? */); 729 775 730 776 /* Search for possible fake node: */ … … 752 798 return; 753 799 754 /* Search for fake node: */ 755 QList<UIChooserNode*> fakeNodes; 756 pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes); 757 UIChooserNode *pFakeNode = fakeNodes.value(0); 758 if (!pFakeNode) 759 return; 760 761 /* And if we have at least one cloud machine: */ 762 const QVector<CCloudMachine> machines = pAcquiringTask->result(); 763 if (!machines.isEmpty()) 764 { 765 /* Remove fake node: */ 766 delete pFakeNode; 767 768 /* Add real cloud VM nodes: */ 769 foreach (const CCloudMachine &comCloudMachine, machines) 770 createCloudMachineNode(pProfileNode, comCloudMachine); 771 } 772 else 773 { 774 /* Otherwise toggle and update "Empty" node: */ 775 UIChooserNodeMachine *pFakeMachineNode = pFakeNode->toMachineNode(); 776 AssertReturnVoid(pFakeMachineNode && pFakeMachineNode->cacheType() == UIVirtualMachineItemType_CloudFake); 777 UIVirtualMachineItemCloud *pFakeCloudMachineItem = pFakeMachineNode->cache()->toCloud(); 778 AssertPtrReturnVoid(pFakeCloudMachineItem); 779 pFakeCloudMachineItem->setFakeCloudItemState(UIFakeCloudVirtualMachineItemState_Done); 780 pFakeCloudMachineItem->setFakeCloudItemErrorMessage(pAcquiringTask->errorInfo()); 781 } 800 /* Compose old set of machine IDs: */ 801 QSet<QUuid> oldIDs; 802 foreach (UIChooserNode *pNode, pProfileNode->nodes(UIChooserNodeType_Machine)) 803 { 804 AssertPtrReturnVoid(pNode); 805 UIChooserNodeMachine *pNodeMachine = pNode->toMachineNode(); 806 AssertPtrReturnVoid(pNodeMachine); 807 if (pNodeMachine->cacheType() != UIVirtualMachineItemType_CloudReal) 808 continue; 809 oldIDs << pNodeMachine->id(); 810 } 811 /* Compose new set of machine IDs and map of machines: */ 812 QSet<QUuid> newIDs; 813 QMap<QUuid, CCloudMachine> newMachines; 814 foreach (const CCloudMachine &comMachine, pAcquiringTask->result()) 815 { 816 QUuid uId; 817 AssertReturnVoid(cloudMachineId(comMachine, uId)); 818 newMachines[uId] = comMachine; 819 newIDs << uId; 820 } 821 822 /* Calculate set of unregistered/registered IDs: */ 823 const QSet<QUuid> unregisteredIDs = oldIDs - newIDs; 824 const QSet<QUuid> registeredIDs = newIDs - oldIDs; 825 QVector<CCloudMachine> registeredMachines; 826 foreach (const QUuid &uId, registeredIDs) 827 registeredMachines << newMachines.value(uId); 828 829 /* Remove unregistered cloud VM nodes: */ 830 if (!unregisteredIDs.isEmpty()) 831 sltCloudMachinesUnregistered(pAcquiringTask->providerShortName(), pAcquiringTask->profileName(), unregisteredIDs.toList()); 832 /* Add registered cloud VM nodes: */ 833 if (!registeredMachines.isEmpty()) 834 sltCloudMachinesRegistered(pAcquiringTask->providerShortName(), pAcquiringTask->profileName(), registeredMachines); 782 835 } 783 836 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r86608 r86611 172 172 const QString &strProfileName, 173 173 const QUuid &uId); 174 /** Handles cloud machine unregistering for a list of @a ids. 175 * @param strProviderShortName Brings provider short name. 176 * @param strProfileName Brings profile name. */ 177 virtual void sltCloudMachinesUnregistered(const QString &strProviderShortName, 178 const QString &strProfileName, 179 const QList<QUuid> &ids); 174 180 /** Handles cloud machine registering for @a comMachine. 175 181 * @param strProviderShortName Brings provider short name. … … 178 184 const QString &strProfileName, 179 185 const CCloudMachine &comMachine); 186 /** Handles cloud machine registering for a list of @a machines. 187 * @param strProviderShortName Brings provider short name. 188 * @param strProfileName Brings profile name. */ 189 virtual void sltCloudMachinesRegistered(const QString &strProviderShortName, 190 const QString &strProfileName, 191 const QVector<CCloudMachine> &machines); 180 192 181 193 /** Handles list cloud machines task complete signal. */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r86609 r86611 1169 1169 } 1170 1170 1171 void UIChooserModel::sltCloudMachinesUnregistered(const QString &strProviderShortName, 1172 const QString &strProfileName, 1173 const QList<QUuid> &ids) 1174 { 1175 /* Make sure no item with one of passed ids is selected: */ 1176 foreach (const QUuid &uId, ids) 1177 makeSureNoItemWithCertainIdSelected(uId); 1178 1179 /* Call to base-class: */ 1180 UIChooserAbstractModel::sltCloudMachinesUnregistered(strProviderShortName, strProfileName, ids); 1181 1182 /* Rebuild tree for main root: */ 1183 buildTreeForMainRoot(true /* preserve selection */); 1184 } 1185 1171 1186 void UIChooserModel::sltCloudMachineRegistered(const QString &strProviderShortName, 1172 1187 const QString &strProfileName, … … 1185 1200 UIChooserItemSearchFlag_Machine | 1186 1201 UIChooserItemSearchFlag_ExactId)); 1202 } 1203 1204 void UIChooserModel::sltCloudMachinesRegistered(const QString &strProviderShortName, 1205 const QString &strProfileName, 1206 const QVector<CCloudMachine> &machines) 1207 { 1208 /* Call to base-class: */ 1209 UIChooserAbstractModel::sltCloudMachinesRegistered(strProviderShortName, strProfileName, machines); 1210 1211 /* Rebuild tree for main root: */ 1212 buildTreeForMainRoot(true /* preserve selection */); 1187 1213 } 1188 1214 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r86608 r86611 282 282 const QString &strProfileName, 283 283 const QUuid &uId) /* override */; 284 /** Handles cloud machine unregistering for a list of @a ids. 285 * @param strProviderShortName Brings provider short name. 286 * @param strProfileName Brings profile name. */ 287 virtual void sltCloudMachinesUnregistered(const QString &strProviderShortName, 288 const QString &strProfileName, 289 const QList<QUuid> &ids) /* override */; 284 290 /** Handles cloud machine registering for @a comMachine. 285 291 * @param strProviderShortName Brings provider short name. … … 288 294 const QString &strProfileName, 289 295 const CCloudMachine &comMachine) /* override */; 296 /** Handles cloud machine registering for a list of @a machines. 297 * @param strProviderShortName Brings provider short name. 298 * @param strProfileName Brings profile name. */ 299 virtual void sltCloudMachinesRegistered(const QString &strProviderShortName, 300 const QString &strProfileName, 301 const QVector<CCloudMachine> &machines) /* override */; 290 302 291 303 /** Handles list cloud machines task complete signal. */
Note:
See TracChangeset
for help on using the changeset viewer.

