Changeset 86605 in vbox
- Timestamp:
- Oct 16, 2020 1:40:05 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 4 edited
-
UIChooserAbstractModel.cpp (modified) (2 diffs)
-
UIChooserAbstractModel.h (modified) (2 diffs)
-
UIChooserModel.cpp (modified) (3 diffs)
-
UIChooserModel.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r86573 r86605 636 636 } 637 637 638 void UIChooserAbstractModel::sltCloudMachineRegistered(const QString &strProviderShortName, const QString &strProfileName,639 const CCloudMachine &comMachine, bool fSelect)640 {641 /* Search for profile node: */642 const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName);643 QList<UIChooserNode*> profileNodes;644 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);645 AssertReturnVoid(!profileNodes.isEmpty());646 UIChooserNode *pProfileNode = profileNodes.first();647 AssertPtrReturnVoid(pProfileNode);648 649 /* Add new machine-item: */650 addCloudMachineIntoTheTree(strProfileNodeName, comMachine, fSelect);651 652 /* Search for possible fake node: */653 QList<UIChooserNode*> fakeNodes;654 pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);655 /* Delete fake node if present: */656 delete fakeNodes.value(0);657 }658 659 void UIChooserAbstractModel::sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName,660 const QUuid &uMachineId, const bool fRegistered)661 {662 /* Search for profile node: */663 const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName);664 QList<UIChooserNode*> profileNodes;665 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);666 AssertReturnVoid(!profileNodes.isEmpty());667 UIChooserNode *pProfileNode = profileNodes.first();668 AssertPtrReturnVoid(pProfileNode);669 670 /* Existing VM unregistered? */671 if (!fRegistered)672 {673 /* Remove machine-items with passed id: */674 pProfileNode->removeAllNodes(uMachineId);675 676 /* If there are no items left: */677 if (pProfileNode->nodes(UIChooserNodeType_Machine).isEmpty())678 {679 /* Add fake cloud VM item: */680 new UIChooserNodeMachine(pProfileNode /* parent */,681 0 /* position */,682 UIFakeCloudVirtualMachineItemState_Done);683 }684 }685 /* New VM registered? */686 else687 {688 /* Add new machine-item: */689 const CCloudMachine comMachine = cloudMachineById(strProviderShortName, strProfileName, uMachineId);690 addCloudMachineIntoTheTree(strProfileNodeName, comMachine, true /* make it visible */);691 692 /* Search for possible fake node: */693 QList<UIChooserNode*> fakeNodes;694 pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);695 /* Delete fake node if present: */696 delete fakeNodes.value(0);697 }698 }699 700 638 void UIChooserAbstractModel::sltSessionStateChanged(const QUuid &uMachineId, const KSessionState) 701 639 { … … 751 689 saveGroupSettings(); 752 690 saveGroupDefinitions(); 691 } 692 693 void UIChooserAbstractModel::sltCloudMachineRegistered(const QString &strProviderShortName, const QString &strProfileName, 694 const CCloudMachine &comMachine, bool fSelect) 695 { 696 /* Search for profile node: */ 697 const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName); 698 QList<UIChooserNode*> profileNodes; 699 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 700 AssertReturnVoid(!profileNodes.isEmpty()); 701 UIChooserNode *pProfileNode = profileNodes.first(); 702 AssertPtrReturnVoid(pProfileNode); 703 704 /* Add new machine-item: */ 705 addCloudMachineIntoTheTree(strProfileNodeName, comMachine, fSelect); 706 707 /* Search for possible fake node: */ 708 QList<UIChooserNode*> fakeNodes; 709 pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes); 710 /* Delete fake node if present: */ 711 delete fakeNodes.value(0); 712 } 713 714 void UIChooserAbstractModel::sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName, 715 const QUuid &uMachineId, const bool fRegistered) 716 { 717 /* Search for profile node: */ 718 const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName); 719 QList<UIChooserNode*> profileNodes; 720 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 721 AssertReturnVoid(!profileNodes.isEmpty()); 722 UIChooserNode *pProfileNode = profileNodes.first(); 723 AssertPtrReturnVoid(pProfileNode); 724 725 /* Existing VM unregistered? */ 726 if (!fRegistered) 727 { 728 /* Remove machine-items with passed id: */ 729 pProfileNode->removeAllNodes(uMachineId); 730 731 /* If there are no items left: */ 732 if (pProfileNode->nodes(UIChooserNodeType_Machine).isEmpty()) 733 { 734 /* Add fake cloud VM item: */ 735 new UIChooserNodeMachine(pProfileNode /* parent */, 736 0 /* position */, 737 UIFakeCloudVirtualMachineItemState_Done); 738 } 739 } 740 /* New VM registered? */ 741 else 742 { 743 /* Add new machine-item: */ 744 const CCloudMachine comMachine = cloudMachineById(strProviderShortName, strProfileName, uMachineId); 745 addCloudMachineIntoTheTree(strProfileNodeName, comMachine, true /* make it visible */); 746 747 /* Search for possible fake node: */ 748 QList<UIChooserNode*> fakeNodes; 749 pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes); 750 /* Delete fake node if present: */ 751 delete fakeNodes.value(0); 752 } 753 753 } 754 754 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r86573 r86605 145 145 /** Handles local machine registering/unregistering for machine with certain @a uMachineId. */ 146 146 virtual void sltLocalMachineRegistrationChanged(const QUuid &uMachineId, const bool fRegistered); 147 148 /** Handles session @a enmState change for machine with certain @a uMachineId. */ 149 virtual void sltSessionStateChanged(const QUuid &uMachineId, const KSessionState enmState); 150 151 /** Handles snapshot change for machine/snapshot with certain @a uMachineId / @a uSnapshotId. */ 152 virtual void sltSnapshotChanged(const QUuid &uMachineId, const QUuid &uSnapshotId); 153 154 /** Handles event about cloud provider with @a uProviderId being uninstalled. */ 155 virtual void sltHandleCloudProviderUninstall(const QUuid &uProviderId); 156 /** @} */ 157 158 /** @name Children stuff. 159 * @{ */ 160 /** Handles reload machine with certain @a uMachineId request. */ 161 virtual void sltReloadMachine(const QUuid &uMachineId); 162 /** @} */ 163 164 /** @name Cloud stuff. 165 * @{ */ 147 166 /** Handles cloud machine registering for @a comMachine. 148 167 * @param strProviderShortName Brings provider short name. … … 156 175 virtual void sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName, 157 176 const QUuid &uMachineId, const bool fRegistered); 158 /** Handles session @a enmState change for machine with certain @a uMachineId. */ 159 virtual void sltSessionStateChanged(const QUuid &uMachineId, const KSessionState enmState); 160 /** Handles snapshot change for machine/snapshot with certain @a uMachineId / @a uSnapshotId. */ 161 virtual void sltSnapshotChanged(const QUuid &uMachineId, const QUuid &uSnapshotId); 162 /** Handles event about cloud provider with @a uProviderId being uninstalled. */ 163 virtual void sltHandleCloudProviderUninstall(const QUuid &uProviderId); 164 /** @} */ 165 166 /** @name Children stuff. 167 * @{ */ 168 /** Handles reload machine with certain @a uMachineId request. */ 169 virtual void sltReloadMachine(const QUuid &uMachineId); 170 /** @} */ 171 172 /** @name Cloud stuff. 173 * @{ */ 177 174 178 /** Handles list cloud machines task complete signal. */ 175 179 virtual void sltHandleCloudListMachinesTaskComplete(UITask *pTask); 180 176 181 /** Handles Cloud Profile Manager cumulative change. */ 177 182 virtual void sltHandleCloudProfileManagerCumulativeChange(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r86573 r86605 1111 1111 } 1112 1112 1113 void UIChooserModel::sltCloudMachineRegistered(const QString &strProviderShortName, const QString &strProfileName, 1114 const CCloudMachine &comMachine, bool fSelect) 1115 { 1113 void UIChooserModel::sltHandleCloudProviderUninstall(const QUuid &uProviderId) 1114 { 1115 /* Search for selected cloud machine items: */ 1116 foreach (UIVirtualMachineItem *pItem, selectedMachineItems()) 1117 { 1118 /* Skip unrelated nodes: */ 1119 AssertPtrReturnVoid(pItem); 1120 UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud(); 1121 if (!pCloudItem) 1122 continue; 1123 1124 /* Wait for cloud machine refresh task to complete: */ 1125 pCloudItem->waitForAsyncInfoUpdateFinished(); 1126 } 1127 1116 1128 /* Call to base-class: */ 1117 UIChooserAbstractModel::sltCloudMachineRegistered(strProviderShortName, strProfileName, comMachine, fSelect); 1118 1119 /* Rebuild tree for main root: */ 1120 buildTreeForMainRoot(false /* preserve selection */); 1121 1122 /* Select newly added item: */ 1123 if (fSelect) 1124 { 1125 QUuid uMachineId; 1126 if (cloudMachineId(comMachine, uMachineId)) 1127 setSelectedItem(root()->searchForItem(uMachineId.toString(), 1128 UIChooserItemSearchFlag_Machine | 1129 UIChooserItemSearchFlag_ExactId)); 1130 } 1131 } 1132 1133 void UIChooserModel::sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName, 1134 const QUuid &uMachineId, const bool fRegistered) 1135 { 1136 /* Existing VM unregistered => make sure no item with passed uMachineId is selected: */ 1137 if (!fRegistered) 1138 makeSureNoItemWithCertainIdSelected(uMachineId); 1139 1129 UIChooserAbstractModel::sltHandleCloudProviderUninstall(uProviderId); 1130 1131 /* Notify about selection invalidated: */ 1132 emit sigSelectionInvalidated(); 1133 } 1134 1135 void UIChooserModel::sltReloadMachine(const QUuid &uMachineId) 1136 { 1140 1137 /* Call to base-class: */ 1141 UIChooserAbstractModel::sltCloudMachineRegistrationChanged(strProviderShortName, strProfileName, uMachineId, fRegistered); 1142 1143 /* Existing VM unregistered? */ 1144 if (!fRegistered) 1145 { 1146 /* Rebuild tree for main root: */ 1147 buildTreeForMainRoot(true /* preserve selection */); 1148 } 1149 /* New VM registered? */ 1150 else 1138 UIChooserAbstractModel::sltReloadMachine(uMachineId); 1139 1140 /* Should we show this VM? */ 1141 if (gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineId)) 1151 1142 { 1152 1143 /* Rebuild tree for main root: */ … … 1157 1148 UIChooserItemSearchFlag_ExactId)); 1158 1149 } 1159 } 1160 1161 void UIChooserModel::sltHandleCloudProviderUninstall(const QUuid &uProviderId) 1162 { 1163 /* Search for selected cloud machine items: */ 1164 foreach (UIVirtualMachineItem *pItem, selectedMachineItems()) 1165 { 1166 /* Skip unrelated nodes: */ 1167 AssertPtrReturnVoid(pItem); 1168 UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud(); 1169 if (!pCloudItem) 1170 continue; 1171 1172 /* Wait for cloud machine refresh task to complete: */ 1173 pCloudItem->waitForAsyncInfoUpdateFinished(); 1174 } 1175 1150 makeSureAtLeastOneItemSelected(); 1151 1152 /* Notify listeners about selection change: */ 1153 emit sigSelectionChanged(); 1154 } 1155 1156 void UIChooserModel::sltCloudMachineRegistered(const QString &strProviderShortName, const QString &strProfileName, 1157 const CCloudMachine &comMachine, bool fSelect) 1158 { 1176 1159 /* Call to base-class: */ 1177 UIChooserAbstractModel::sltHandleCloudProviderUninstall(uProviderId); 1178 1179 /* Notify about selection invalidated: */ 1180 emit sigSelectionInvalidated(); 1181 } 1182 1183 void UIChooserModel::sltReloadMachine(const QUuid &uMachineId) 1184 { 1160 UIChooserAbstractModel::sltCloudMachineRegistered(strProviderShortName, strProfileName, comMachine, fSelect); 1161 1162 /* Rebuild tree for main root: */ 1163 buildTreeForMainRoot(false /* preserve selection */); 1164 1165 /* Select newly added item: */ 1166 if (fSelect) 1167 { 1168 QUuid uMachineId; 1169 if (cloudMachineId(comMachine, uMachineId)) 1170 setSelectedItem(root()->searchForItem(uMachineId.toString(), 1171 UIChooserItemSearchFlag_Machine | 1172 UIChooserItemSearchFlag_ExactId)); 1173 } 1174 } 1175 1176 void UIChooserModel::sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName, 1177 const QUuid &uMachineId, const bool fRegistered) 1178 { 1179 /* Existing VM unregistered => make sure no item with passed uMachineId is selected: */ 1180 if (!fRegistered) 1181 makeSureNoItemWithCertainIdSelected(uMachineId); 1182 1185 1183 /* Call to base-class: */ 1186 UIChooserAbstractModel::sltReloadMachine(uMachineId); 1187 1188 /* Should we show this VM? */ 1189 if (gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineId)) 1184 UIChooserAbstractModel::sltCloudMachineRegistrationChanged(strProviderShortName, strProfileName, uMachineId, fRegistered); 1185 1186 /* Existing VM unregistered? */ 1187 if (!fRegistered) 1188 { 1189 /* Rebuild tree for main root: */ 1190 buildTreeForMainRoot(true /* preserve selection */); 1191 } 1192 /* New VM registered? */ 1193 else 1190 1194 { 1191 1195 /* Rebuild tree for main root: */ … … 1196 1200 UIChooserItemSearchFlag_ExactId)); 1197 1201 } 1198 makeSureAtLeastOneItemSelected();1199 1200 /* Notify listeners about selection change: */1201 emit sigSelectionChanged();1202 1202 } 1203 1203 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r86573 r86605 263 263 /** Handles local machine registering/unregistering for machine with certain @a uMachineId. */ 264 264 virtual void sltLocalMachineRegistrationChanged(const QUuid &uMachineId, const bool fRegistered) /* override */; 265 266 /** Handles event about cloud provider with @a uProviderId being uninstalled. */ 267 virtual void sltHandleCloudProviderUninstall(const QUuid &uProviderId) /* override */; 268 /** @} */ 269 270 /** @name Children stuff. 271 * @{ */ 272 /** Handles reload machine with certain @a uMachineId request. */ 273 virtual void sltReloadMachine(const QUuid &uMachineId) /* override */; 274 /** @} */ 275 276 /** @name Cloud stuff. 277 * @{ */ 265 278 /** Handles cloud machine registering for @a comMachine. 266 279 * @param strProviderShortName Brings provider short name. … … 274 287 virtual void sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName, 275 288 const QUuid &uMachineId, const bool fRegistered) /* override */; 276 /** Handles event about cloud provider with @a uProviderId being uninstalled. */ 277 virtual void sltHandleCloudProviderUninstall(const QUuid &uProviderId) /* override */; 278 /** @} */ 279 280 /** @name Children stuff. 281 * @{ */ 282 /** Handles reload machine with certain @a uMachineId request. */ 283 virtual void sltReloadMachine(const QUuid &uMachineId) /* override */; 284 /** @} */ 285 286 /** @name Cloud stuff. 287 * @{ */ 289 288 290 /** Handles list cloud machines task complete signal. */ 289 291 virtual void sltHandleCloudListMachinesTaskComplete(UITask *pTask) /* override */; 292 290 293 /** Handles Cloud Profile Manager cumulative changes. */ 291 294 virtual void sltHandleCloudProfileManagerCumulativeChange() /* override */;
Note:
See TracChangeset
for help on using the changeset viewer.

