- Timestamp:
- May 20, 2020 3:28:43 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
r84412 r84415 136 136 false /* favorite */, 137 137 getDesiredNodePosition(invisibleRoot(), 138 UIChooserNode Type_Group,138 UIChooserNodeDataPrefixType_Provider, 139 139 strProviderShortName), 140 140 strProviderShortName, … … 160 160 false /* favorite */, 161 161 getDesiredNodePosition(pProviderNode, 162 UIChooserNode Type_Group,162 UIChooserNodeDataPrefixType_Profile, 163 163 strProfileName), 164 164 strProfileName, … … 692 692 new UIChooserNodeGroup(pParentNode, 693 693 false /* favorite */, 694 getDesiredNodePosition(pParentNode, UIChooserNodeType_Group, strSecondSubName), 694 getDesiredNodePosition(pParentNode, 695 UIChooserNodeDataPrefixType_Local, 696 strSecondSubName), 695 697 strSecondSubName, 696 698 UIChooserNodeGroupType_Local, … … 821 823 } 822 824 823 int UIChooserAbstractModel::getDesiredNodePosition(UIChooserNode *pParentNode, UIChooserNodeType enmType, const QString &strName) 825 int UIChooserAbstractModel::getDesiredNodePosition(UIChooserNode *pParentNode, 826 UIChooserNodeDataPrefixType enmDataType, 827 const QString &strName) 824 828 { 825 829 /* End of list (by default)? */ 826 830 int iNewNodeDesiredPosition = -1; 827 831 /* Which position should be new node placed by definitions: */ 828 int iNewNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmType, strName);832 const int iNewNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmDataType, strName); 829 833 830 834 /* If some position wanted: */ … … 834 838 iNewNodeDesiredPosition = 0; 835 839 /* We have to check all the existing node positions: */ 836 QList<UIChooserNode*> nodes = pParentNode->nodes(enmType); 840 UIChooserNodeType enmType = UIChooserNodeType_Any; 841 switch (enmDataType) 842 { 843 case UIChooserNodeDataPrefixType_Global: enmType = UIChooserNodeType_Global; break; 844 case UIChooserNodeDataPrefixType_Machine: enmType = UIChooserNodeType_Machine; break; 845 case UIChooserNodeDataPrefixType_Local: 846 case UIChooserNodeDataPrefixType_Provider: 847 case UIChooserNodeDataPrefixType_Profile: enmType = UIChooserNodeType_Group; break; 848 } 849 const QList<UIChooserNode*> nodes = pParentNode->nodes(enmType); 837 850 for (int i = nodes.size() - 1; i >= 0; --i) 838 851 { … … 841 854 AssertPtrReturn(pNode, iNewNodeDesiredPosition); 842 855 /* Which position should be current node placed by definitions? */ 843 QString strDefinitionName = pNode->type() == UIChooserNodeType_Group ? pNode->name() 844 : pNode->type() == UIChooserNodeType_Machine ? toOldStyleUuid(pNode->toMachineNode()->id()) 845 : QString(); 846 AssertReturn(!strDefinitionName.isEmpty(), iNewNodeDesiredPosition); 847 int iNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmType, strDefinitionName); 856 UIChooserNodeDataPrefixType enmNodeDataType = UIChooserNodeDataPrefixType_Global; 857 QString strDefinitionName; 858 switch (pNode->type()) 859 { 860 case UIChooserNodeType_Machine: 861 { 862 enmNodeDataType = UIChooserNodeDataPrefixType_Machine; 863 strDefinitionName = toOldStyleUuid(pNode->toMachineNode()->id()); 864 break; 865 } 866 case UIChooserNodeType_Group: 867 { 868 /* Cast to group node: */ 869 UIChooserNodeGroup *pGroupNode = pNode->toGroupNode(); 870 AssertPtrReturn(pGroupNode, iNewNodeDesiredPosition); 871 switch (pGroupNode->groupType()) 872 { 873 case UIChooserNodeGroupType_Local: enmNodeDataType = UIChooserNodeDataPrefixType_Local; break; 874 case UIChooserNodeGroupType_Provider: enmNodeDataType = UIChooserNodeDataPrefixType_Provider; break; 875 case UIChooserNodeGroupType_Profile: enmNodeDataType = UIChooserNodeDataPrefixType_Profile; break; 876 default: break; 877 } 878 strDefinitionName = pNode->name(); 879 break; 880 } 881 default: 882 break; 883 } 884 const int iNodeDefinitionPosition = getDefinedNodePosition(pParentNode, enmNodeDataType, strDefinitionName); 848 885 /* If some position wanted: */ 849 886 if (iNodeDefinitionPosition != -1) … … 863 900 } 864 901 865 int UIChooserAbstractModel::getDefinedNodePosition(UIChooserNode *pParentNode, UIChooserNode Type enmType, const QString &strName)902 int UIChooserAbstractModel::getDefinedNodePosition(UIChooserNode *pParentNode, UIChooserNodeDataPrefixType enmDataType, const QString &strName) 866 903 { 867 904 /* Read group definitions: */ … … 874 911 QString strDefinitionTemplateShort; 875 912 QString strDefinitionTemplateFull; 876 switch (enmType) 877 { 878 case UIChooserNodeType_Group: 879 { 880 const QString strNodePrefixLocal = prefixToString(UIChooserNodeDataPrefixType_Local); 881 const QString strNodePrefixProvider = prefixToString(UIChooserNodeDataPrefixType_Provider); 882 const QString strNodePrefixProfile = prefixToString(UIChooserNodeDataPrefixType_Profile); 913 const QString strNodePrefixLocal = prefixToString(UIChooserNodeDataPrefixType_Local); 914 const QString strNodePrefixProvider = prefixToString(UIChooserNodeDataPrefixType_Provider); 915 const QString strNodePrefixProfile = prefixToString(UIChooserNodeDataPrefixType_Profile); 916 const QString strNodePrefixMachine = prefixToString(UIChooserNodeDataPrefixType_Machine); 917 switch (enmDataType) 918 { 919 case UIChooserNodeDataPrefixType_Local: 920 { 883 921 strDefinitionTemplateShort = QString("^[%1%2%3](\\S)*=").arg(strNodePrefixLocal, strNodePrefixProvider, strNodePrefixProfile); 884 strDefinitionTemplateFull = QString("^ [%1%2%3](\\S)*=%4$").arg(strNodePrefixLocal, strNodePrefixProvider, strNodePrefixProfile, strName);922 strDefinitionTemplateFull = QString("^%1(\\S)*=%2$").arg(strNodePrefixLocal, strName); 885 923 break; 886 924 } 887 case UIChooserNodeType_Machine: 888 { 889 const QString strNodePrefix = prefixToString(UIChooserNodeDataPrefixType_Machine); 890 strDefinitionTemplateShort = QString("^%1=").arg(strNodePrefix); 891 strDefinitionTemplateFull = QString("^%1=%2$").arg(strNodePrefix, strName); 925 case UIChooserNodeDataPrefixType_Provider: 926 { 927 strDefinitionTemplateShort = QString("^[%1%2%3](\\S)*=").arg(strNodePrefixLocal, strNodePrefixProvider, strNodePrefixProfile); 928 strDefinitionTemplateFull = QString("^%1(\\S)*=%2$").arg(strNodePrefixProvider, strName); 929 break; 930 } 931 case UIChooserNodeDataPrefixType_Profile: 932 { 933 strDefinitionTemplateShort = QString("^[%1%2%3](\\S)*=").arg(strNodePrefixLocal, strNodePrefixProvider, strNodePrefixProfile); 934 strDefinitionTemplateFull = QString("^%1(\\S)*=%2$").arg(strNodePrefixProfile, strName); 935 break; 936 } 937 case UIChooserNodeDataPrefixType_Machine: 938 { 939 strDefinitionTemplateShort = QString("^%1=").arg(strNodePrefixMachine); 940 strDefinitionTemplateFull = QString("^%1=%2$").arg(strNodePrefixMachine, strName); 892 941 break; 893 942 } … … 921 970 false /* favorite */, 922 971 getDesiredNodePosition(pParentNode, 923 UIChooserNode Type_Machine,972 UIChooserNodeDataPrefixType_Machine, 924 973 toOldStyleUuid(comMachine.GetId())), 925 974 comMachine); … … 931 980 false /* favorite */, 932 981 getDesiredNodePosition(pParentNode, 933 UIChooserNode Type_Machine,982 UIChooserNodeDataPrefixType_Machine, 934 983 toOldStyleUuid(comMachine.GetId())), 935 984 comMachine); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r84412 r84415 212 212 bool isGlobalNodeFavorite(UIChooserNode *pParentNode) const; 213 213 214 /** Acquires desired position for a child of @a pParentNode with specified @a enm Type and @a strName. */215 int getDesiredNodePosition(UIChooserNode *pParentNode, UIChooserNode Type enmType, const QString &strName);216 /** Acquires defined position for a child of @a pParentNode with specified @a enm Type and @a strName. */217 int getDefinedNodePosition(UIChooserNode *pParentNode, UIChooserNode Type enmType, const QString &strName);214 /** Acquires desired position for a child of @a pParentNode with specified @a enmDataType and @a strName. */ 215 int getDesiredNodePosition(UIChooserNode *pParentNode, UIChooserNodeDataPrefixType enmDataType, const QString &strName); 216 /** Acquires defined position for a child of @a pParentNode with specified @a enmDataType and @a strName. */ 217 int getDefinedNodePosition(UIChooserNode *pParentNode, UIChooserNodeDataPrefixType enmDataType, const QString &strName); 218 218 219 219 /** Creates local machine node based on certain @a comMachine as a child of specified @a pParentNode. */
Note:
See TracChangeset
for help on using the changeset viewer.