Changeset 84598 in vbox
- Timestamp:
- May 28, 2020 4:39:06 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r84562 r84598 82 82 83 83 /** Contains a thread task to be executed. */ 84 v oid run();84 virtual void run() /* override */; 85 85 86 86 /** Holds the singleton instance. */ … … 339 339 /* For every particular group definition: */ 340 340 foreach (const QString &strId, m_lists.keys()) 341 gEDataManager->setSelectorWindowGroupsDefinitions(strId, m_lists [strId]);341 gEDataManager->setSelectorWindowGroupsDefinitions(strId, m_lists.value(strId)); 342 342 343 343 /* Notify listeners about completeness: */ … … 525 525 /* Search for all the machine nodes with passed ID: */ 526 526 QList<UIChooserNode*> machineNodes; 527 invisibleRoot()->searchForNodes( toOldStyleUuid(uId),527 invisibleRoot()->searchForNodes(uId.toString(), 528 528 UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, 529 529 machineNodes); … … 660 660 { 661 661 /* Global nodes: */ 662 case UIChooserNodeDataPrefixType_Global: 662 case UIChooserNodeDataPrefixType_Global: return "n"; 663 663 /* Machine nodes: */ 664 case UIChooserNodeDataPrefixType_Machine: 664 case UIChooserNodeDataPrefixType_Machine: return "m"; 665 665 /* Group nodes: */ 666 666 case UIChooserNodeDataPrefixType_Local: return "g"; … … 695 695 } 696 696 697 void UIChooserAbstractModel::sltHandleCloudMachineStateChange() 698 { 699 UIVirtualMachineItem *pCache = qobject_cast<UIVirtualMachineItem*>(sender()); 700 AssertPtrReturnVoid(pCache); 701 emit sigCloudMachineStateChange(pCache->id()); 702 } 703 704 void UIChooserAbstractModel::sltGroupSettingsSaveComplete() 705 { 706 makeSureGroupSettingsSaveIsFinished(); 707 emit sigGroupSavingStateChanged(); 708 } 709 710 void UIChooserAbstractModel::sltGroupDefinitionsSaveComplete() 711 { 712 makeSureGroupDefinitionsSaveIsFinished(); 713 emit sigGroupSavingStateChanged(); 714 } 715 697 716 void UIChooserAbstractModel::sltLocalMachineStateChanged(const QUuid &uMachineId, const KMachineState) 698 717 { … … 733 752 const QUuid &uMachineId, const bool fRegistered) 734 753 { 735 /* Compose full group name: */ 736 const QString strGroupName = QString("/%1/%2").arg(strProviderShortName, strProfileName); 737 /* Search for corresponding profile node: */ 754 /* Search for profile node: */ 755 const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName); 738 756 QList<UIChooserNode*> profileNodes; 739 invisibleRoot()->searchForNodes(strGroupName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 740 /* Acquire corresponding profile node: */ 757 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 741 758 AssertReturnVoid(!profileNodes.isEmpty()); 742 UIChooserNode Group *pProfileNode = profileNodes.first()->toGroupNode();759 UIChooserNode *pProfileNode = profileNodes.first(); 743 760 AssertPtrReturnVoid(pProfileNode); 744 761 … … 747 764 { 748 765 /* Remove machine-items with passed id: */ 749 invisibleRoot()->removeAllNodes(uMachineId);766 pProfileNode->removeAllNodes(uMachineId); 750 767 751 768 /* If there are no items left: */ … … 766 783 /* Add new machine-item: */ 767 784 const CCloudMachine comMachine = cloudMachineById(strProviderShortName, strProfileName, uMachineId); 768 addCloudMachineIntoTheTree(str GroupName, comMachine, true /* make it visible */);785 addCloudMachineIntoTheTree(strProfileNodeName, comMachine, true /* make it visible */); 769 786 770 787 /* Search for possible fake node: */ 771 788 QList<UIChooserNode*> fakeNodes; 772 pProfileNode->searchForNodes( toOldStyleUuid(QUuid()), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);789 pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes); 773 790 /* Delete fake node if present: */ 774 if (!fakeNodes.isEmpty()) 775 delete fakeNodes.first(); 791 delete fakeNodes.value(0); 776 792 } 777 793 } … … 824 840 QList<UIChooserNode*> profileNodes; 825 841 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 826 UIChooserNode *pProfileNode = profileNodes.value(0); 842 AssertReturnVoid(!profileNodes.isEmpty()); 843 UIChooserNode *pProfileNode = profileNodes.first(); 827 844 AssertPtrReturnVoid(pProfileNode); 828 845 829 846 /* Search for fake node: */ 830 847 QList<UIChooserNode*> fakeNodes; 831 pProfileNode->searchForNodes( toOldStyleUuid(QUuid()), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);848 pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes); 832 849 UIChooserNode *pFakeNode = fakeNodes.value(0); 833 850 AssertPtrReturnVoid(pFakeNode); 834 UIChooserNodeMachine *pFakeMachineNode = pFakeNode->toMachineNode();835 AssertPtrReturnVoid(pFakeMachineNode);836 AssertReturnVoid(pFakeMachineNode->cacheType() == UIVirtualMachineItemType_CloudFake);837 851 838 852 /* And if we have at least one cloud machine: */ … … 841 855 { 842 856 /* Remove fake node: */ 843 delete pFake MachineNode;857 delete pFakeNode; 844 858 845 859 /* Add real cloud VM nodes: */ … … 850 864 { 851 865 /* Otherwise toggle and update "Empty" node: */ 866 UIChooserNodeMachine *pFakeMachineNode = pFakeNode->toMachineNode(); 867 AssertReturnVoid(pFakeMachineNode && pFakeMachineNode->cacheType() == UIVirtualMachineItemType_CloudFake); 852 868 UIVirtualMachineItemCloud *pFakeCloudMachineItem = pFakeMachineNode->cache()->toCloud(); 853 869 AssertPtrReturnVoid(pFakeCloudMachineItem); … … 855 871 pFakeCloudMachineItem->setFakeCloudItemErrorMessage(pAcquiringTask->errorInfo()); 856 872 } 857 }858 859 void UIChooserAbstractModel::sltHandleCloudMachineStateChange()860 {861 UIVirtualMachineItem *pCache = qobject_cast<UIVirtualMachineItem*>(sender());862 AssertPtrReturnVoid(pCache);863 emit sigCloudMachineStateChange(pCache->id());864 }865 866 void UIChooserAbstractModel::sltGroupSettingsSaveComplete()867 {868 makeSureGroupSettingsSaveIsFinished();869 emit sigGroupSavingStateChanged();870 }871 872 void UIChooserAbstractModel::sltGroupDefinitionsSaveComplete()873 {874 makeSureGroupDefinitionsSaveIsFinished();875 emit sigGroupSavingStateChanged();876 873 } 877 874 … … 929 926 LogRelFlow(("UIChooserModel: Loading local VM with ID={%s}...\n", 930 927 toOldStyleUuid(uId).toUtf8().constData())); 928 931 929 /* Is that machine accessible? */ 932 930 if (comMachine.GetAccessible()) … … 978 976 LogRelFlow(("UIChooserModel: Loading cloud VM with ID={%s}...\n", 979 977 toOldStyleUuid(uId).toUtf8().constData())); 978 980 979 /* Acquire VM name: */ 981 980 QString strName = comMachine.GetName(); … … 1145 1144 void UIChooserAbstractModel::wipeOutEmptyGroupsStartingFrom(UIChooserNode *pParent) 1146 1145 { 1147 /* Cleanup all the group -itemsrecursively first: */1146 /* Cleanup all the group children recursively first: */ 1148 1147 foreach (UIChooserNode *pNode, pParent->nodes(UIChooserNodeType_Group)) 1149 1148 wipeOutEmptyGroupsStartingFrom(pNode); 1150 /* If parent has no nodes: */ 1151 if (!pParent->hasNodes()) 1152 { 1153 /* If that is non-root item: */ 1154 if (!pParent->isRoot()) 1155 { 1156 /* Delete parent node and item: */ 1157 delete pParent; 1158 } 1149 /* If parent isn't root and has no nodes: */ 1150 if (!pParent->isRoot() && !pParent->hasNodes()) 1151 { 1152 /* Delete parent node and item: */ 1153 delete pParent; 1159 1154 } 1160 1155 } … … 1169 1164 const int iNewNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmDataType, strName); 1170 1165 1171 /* If some position wanted: */1166 /* If some position defined: */ 1172 1167 if (iNewNodeDefinitionPosition != -1) 1173 1168 { … … 1219 1214 break; 1220 1215 } 1216 /* If some position defined: */ 1221 1217 const int iNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmNodeDataType, strDefinitionName); 1222 /* If some position wanted: */1223 1218 if (iNodeDefinitionPosition != -1) 1224 1219 { … … 1323 1318 if (!comMachine.GetAccessible()) 1324 1319 { 1325 AssertPtrReturnVoid(pNode); 1326 AssertReturnVoid(pNode->cacheType() == UIVirtualMachineItemType_CloudReal); 1320 AssertReturnVoid(pNode && pNode->cacheType() == UIVirtualMachineItemType_CloudReal); 1327 1321 pNode->cache()->toCloud()->updateInfoAsync(false /* delayed? */); 1328 1322 }
Note:
See TracChangeset
for help on using the changeset viewer.