Changeset 84434 in vbox
- Timestamp:
- May 21, 2020 2:44:56 PM (5 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
r84424 r84434 70 70 /* Create global node: */ 71 71 new UIChooserNodeGlobal(invisibleRoot() /* parent */, 72 isGlobalNodeFavorite(invisibleRoot()),72 shouldGlobalNodeBeFavorite(invisibleRoot()), 73 73 0 /* position */, 74 74 QString() /* tip */); … … 141 141 UIChooserNodeGroupType_Provider, 142 142 shouldGroupNodeBeOpened(invisibleRoot(), 143 UIChooserNodeDataPrefixType_Provider, 143 144 strProviderShortName)); 144 145 … … 165 166 UIChooserNodeGroupType_Profile, 166 167 shouldGroupNodeBeOpened(pProviderNode, 168 UIChooserNodeDataPrefixType_Profile, 167 169 strProfileName)); 168 170 … … 697 699 strSecondSubName, 698 700 UIChooserNodeGroupType_Local, 699 fAllGroupsOpened || shouldGroupNodeBeOpened(pParentNode, strSecondSubName)); 701 fAllGroupsOpened || shouldGroupNodeBeOpened(pParentNode, 702 UIChooserNodeDataPrefixType_Local, 703 strSecondSubName)); 700 704 return strSecondSuffix.isEmpty() ? pNewGroupNode : getLocalGroupNode(strFirstSuffix, pNewGroupNode, fAllGroupsOpened); 701 705 } … … 740 744 } 741 745 742 bool UIChooserAbstractModel::shouldGroupNodeBeOpened(UIChooserNode *pParentNode, const QString &strName) 746 bool UIChooserAbstractModel::shouldGroupNodeBeOpened(UIChooserNode *pParentNode, 747 UIChooserNodeDataPrefixType enmDataType, 748 const QString &strName) const 743 749 { 744 750 /* Read group definitions: */ … … 749 755 750 756 /* Prepare required group definition reg-exp: */ 751 const QString strNodePrefixLocal = prefixToString(UIChooserNodeDataPrefixType_Local); 752 const QString strNodePrefixProvider = prefixToString(UIChooserNodeDataPrefixType_Provider); 753 const QString strNodePrefixProfile = prefixToString(UIChooserNodeDataPrefixType_Profile); 757 const QString strNodePrefix = prefixToString(enmDataType); 754 758 const QString strNodeOptionOpened = optionToString(UIChooserNodeDataOptionType_GroupOpened); 755 const QString strDefinitionTemplate = QString("[%1%2%3](\\S)*=%4").arg(strNodePrefixLocal, 756 strNodePrefixProvider, 757 strNodePrefixProfile, 758 strName); 759 const QString strDefinitionTemplate = QString("%1(\\S)*=%2").arg(strNodePrefix, strName); 759 760 const QRegExp definitionRegExp(strDefinitionTemplate); 760 761 /* For each the group definition: */ … … 775 776 } 776 777 777 void UIChooserAbstractModel::wipeOutEmptyGroupsStartingFrom(UIChooserNode *pParent) 778 { 779 /* Cleanup all the group-items recursively first: */ 780 foreach (UIChooserNode *pNode, pParent->nodes(UIChooserNodeType_Group)) 781 wipeOutEmptyGroupsStartingFrom(pNode); 782 /* If parent has no nodes: */ 783 if (!pParent->hasNodes()) 784 { 785 /* If that is non-root item: */ 786 if (!pParent->isRoot()) 787 { 788 /* Delete parent node and item: */ 789 delete pParent; 790 } 791 } 792 } 793 794 bool UIChooserAbstractModel::isGlobalNodeFavorite(UIChooserNode *pParentNode) const 778 bool UIChooserAbstractModel::shouldGlobalNodeBeFavorite(UIChooserNode *pParentNode) const 795 779 { 796 780 /* Read group definitions: */ … … 821 805 /* Return 'false' by default: */ 822 806 return false; 807 } 808 809 void UIChooserAbstractModel::wipeOutEmptyGroupsStartingFrom(UIChooserNode *pParent) 810 { 811 /* Cleanup all the group-items recursively first: */ 812 foreach (UIChooserNode *pNode, pParent->nodes(UIChooserNodeType_Group)) 813 wipeOutEmptyGroupsStartingFrom(pNode); 814 /* If parent has no nodes: */ 815 if (!pParent->hasNodes()) 816 { 817 /* If that is non-root item: */ 818 if (!pParent->isRoot()) 819 { 820 /* Delete parent node and item: */ 821 delete pParent; 822 } 823 } 823 824 } 824 825 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r84424 r84434 203 203 UIChooserNode *getCloudGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened); 204 204 205 /** Returns whether group node with certain @a strName should be opened, searching starting from the passed @a pParentItem. */ 206 bool shouldGroupNodeBeOpened(UIChooserNode *pParentNode, const QString &strName); 205 /** Returns whether group node * with specified @a enmDataType and @a strName should be opened, 206 * searching starting from the passed @a pParentNode. */ 207 bool shouldGroupNodeBeOpened(UIChooserNode *pParentNode, 208 UIChooserNodeDataPrefixType enmDataType, 209 const QString &strName) const; 210 /** Returns whether global node should be favorite, 211 * searching starting from the passed @a pParentNode. */ 212 bool shouldGlobalNodeBeFavorite(UIChooserNode *pParentNode) const; 207 213 208 214 /** Wipes out empty groups starting from @a pParentItem. */ 209 215 void wipeOutEmptyGroupsStartingFrom(UIChooserNode *pParentNode); 210 211 /** Returns whether global node within the @a pParentNode is favorite. */212 bool isGlobalNodeFavorite(UIChooserNode *pParentNode) const;213 216 214 217 /** Acquires desired position for a child of @a pParentNode with specified @a enmDataType and @a strName. */
Note:
See TracChangeset
for help on using the changeset viewer.