Changeset 86665 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 21, 2020 2:21:40 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r86664 r86665 718 718 { 719 719 /* Search for profile node: */ 720 const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName); 721 QList<UIChooserNode*> profileNodes; 722 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 723 UIChooserNode *pProfileNode = profileNodes.value(0); 720 UIChooserNode *pProfileNode = searchProfileNode(strProviderShortName, strProfileName); 724 721 if (!pProfileNode) 725 722 return; … … 738 735 { 739 736 /* Search for profile node: */ 740 const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName); 741 QList<UIChooserNode*> profileNodes; 742 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 743 UIChooserNode *pProfileNode = profileNodes.value(0); 737 UIChooserNode *pProfileNode = searchProfileNode(strProviderShortName, strProfileName); 744 738 if (!pProfileNode) 745 739 return; … … 759 753 { 760 754 /* Search for profile node: */ 761 const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName); 762 QList<UIChooserNode*> profileNodes; 763 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 764 UIChooserNode *pProfileNode = profileNodes.value(0); 755 UIChooserNode *pProfileNode = searchProfileNode(strProviderShortName, strProfileName); 765 756 if (!pProfileNode) 766 757 return; 767 758 768 759 /* Add new machine-item: */ 769 addCloudMachineIntoTheTree(strProfileNodeName, comMachine, true /* make it visible? */); 770 771 /* Search for possible fake node: */ 772 QList<UIChooserNode*> fakeNodes; 773 pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes); 760 const QString strGroup = QString("/%1/%2").arg(strProviderShortName, strProfileName); 761 addCloudMachineIntoTheTree(strGroup, comMachine, true /* make it visible? */); 762 774 763 /* Delete fake node if present: */ 775 delete fakeNodes.value(0);764 delete searchFakeNode(pProfileNode); 776 765 } 777 766 … … 781 770 { 782 771 /* Search for profile node: */ 783 const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName); 784 QList<UIChooserNode*> profileNodes; 785 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 786 UIChooserNode *pProfileNode = profileNodes.value(0); 772 UIChooserNode *pProfileNode = searchProfileNode(strProviderShortName, strProfileName); 787 773 if (!pProfileNode) 788 774 return; 789 775 790 776 /* Add new machine-items: */ 777 const QString strGroup = QString("/%1/%2").arg(strProviderShortName, strProfileName); 791 778 foreach (const CCloudMachine &comMachine, machines) 792 addCloudMachineIntoTheTree(strProfileNodeName, comMachine, false /* make it visible? */); 793 794 /* Search for possible fake node: */ 795 QList<UIChooserNode*> fakeNodes; 796 pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes); 779 addCloudMachineIntoTheTree(strGroup, comMachine, false /* make it visible? */); 780 797 781 /* Delete fake node if present: */ 798 delete fakeNodes.value(0);782 delete searchFakeNode(pProfileNode); 799 783 } 800 784 … … 807 791 UITaskCloudListMachines *pAcquiringTask = qobject_cast<UITaskCloudListMachines*>(pTask); 808 792 AssertPtrReturnVoid(pAcquiringTask); 793 const QString strProviderShortName = pAcquiringTask->providerShortName(); 794 const QString strProfileName = pAcquiringTask->profileName(); 809 795 810 796 /* Search for profile node: */ 811 const QString strProfileNodeName = QString("/%1/%2").arg(pAcquiringTask->providerShortName(), pAcquiringTask->profileName()); 812 QList<UIChooserNode*> profileNodes; 813 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 814 UIChooserNode *pProfileNode = profileNodes.value(0); 797 UIChooserNode *pProfileNode = searchProfileNode(strProviderShortName, strProfileName); 815 798 if (!pProfileNode) 816 799 return; … … 847 830 /* Remove unregistered cloud VM nodes: */ 848 831 if (!unregisteredIDs.isEmpty()) 849 sltCloudMachinesUnregistered( pAcquiringTask->providerShortName(), pAcquiringTask->profileName(), unregisteredIDs.toList());832 sltCloudMachinesUnregistered(strProviderShortName, strProfileName, unregisteredIDs.toList()); 850 833 /* Add registered cloud VM nodes: */ 851 834 if (!registeredMachines.isEmpty()) 852 sltCloudMachinesRegistered( pAcquiringTask->providerShortName(), pAcquiringTask->profileName(), registeredMachines);835 sltCloudMachinesRegistered(strProviderShortName, strProfileName, registeredMachines); 853 836 854 837 /* Remove cloud account key from the list of keys currently being updated: */ 855 const UICloudAccountKey accountKey = qMakePair( pAcquiringTask->providerShortName(), pAcquiringTask->profileName());838 const UICloudAccountKey accountKey = qMakePair(strProviderShortName, strProfileName); 856 839 removeCloudAccountKey(accountKey); 857 840 } … … 1619 1602 } 1620 1603 1604 UIChooserNode *UIChooserAbstractModel::searchProfileNode(const QString &strProviderShortName, const QString &strProfileName) 1605 { 1606 /* Compose profile node ID: */ 1607 const QString strProfileNodeId = QString("/%1/%2").arg(strProviderShortName, strProfileName); 1608 1609 /* Search for a list of nodes matching required ID: */ 1610 QList<UIChooserNode*> profileNodes; 1611 invisibleRoot()->searchForNodes(strProfileNodeId, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes); 1612 1613 /* Return 1st node if any: */ 1614 return profileNodes.value(0); 1615 } 1616 1617 UIChooserNode *UIChooserAbstractModel::searchFakeNode(UIChooserNode *pProfileNode) 1618 { 1619 /* Search for a list of nodes matching null ID: */ 1620 QList<UIChooserNode*> fakeNodes; 1621 pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes); 1622 1623 /* Return 1st node if any: */ 1624 return fakeNodes.value(0); 1625 } 1626 1621 1627 1622 1628 #include "UIChooserAbstractModel.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r86664 r86665 308 308 /** @} */ 309 309 310 /** @name Cloud stuff. 311 * @{ */ 312 /** Searches for profile node with passed @a strProviderShortName and @a strProfileName. */ 313 UIChooserNode *searchProfileNode(const QString &strProviderShortName, const QString &strProfileName); 314 /** Searches for fake node under passed @a pProfileNode. */ 315 UIChooserNode *searchFakeNode(UIChooserNode *pProfileNode); 316 /** @} */ 317 310 318 /** @name General stuff. 311 319 * @{ */
Note:
See TracChangeset
for help on using the changeset viewer.