- Timestamp:
- May 19, 2020 5:57:56 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r84373 r84376 314 314 { 315 315 return uId.toString().remove(QRegExp("[{}]")); 316 } 317 318 /* static */ 319 QString UIChooserAbstractModel::definitionOption(NodeDef enmOption) 320 { 321 switch (enmOption) 322 { 323 /* Global nodes: */ 324 case NodeDef_GlobalPrefix: return "n"; 325 case NodeDef_GlobalOptionFavorite: return "f"; 326 case NodeDef_GlobalValueDefault: return "GLOBAL"; 327 /* Machine nodes: */ 328 case NodeDef_MachinePrefix: return "m"; 329 /* Group nodes: */ 330 case NodeDef_GroupPrefix: return "g"; 331 case NodeDef_GroupOptionOpened: return "o"; 332 } 333 return QString(); 316 334 } 317 335 … … 699 717 700 718 /* Prepare required group definition reg-exp: */ 701 const QString strDefinitionTemplate = QString("g(\\S)*=%1").arg(strName); 719 const QString strNodePrefix = definitionOption(NodeDef_GroupPrefix); 720 const QString strNodeOptionOpened = definitionOption(NodeDef_GroupOptionOpened); 721 const QString strDefinitionTemplate = QString("%1(\\S)*=%2").arg(strNodePrefix, strName); 702 722 const QRegExp definitionRegExp(strDefinitionTemplate); 703 723 /* For each the group definition: */ … … 709 729 /* Get group descriptor: */ 710 730 const QString strDescriptor(definitionRegExp.cap(1)); 711 if (strDescriptor.contains( 'o'))731 if (strDescriptor.contains(strNodeOptionOpened)) 712 732 return true; 713 733 } … … 744 764 745 765 /* Prepare required group definition reg-exp: */ 746 const QString strDefinitionTemplate = QString("n(\\S)*=GLOBAL"); 747 const QRegExp definitionRegExp = QRegExp(strDefinitionTemplate); 766 const QString strNodePrefix = definitionOption(NodeDef_GlobalPrefix); 767 const QString strNodeOptionFavorite = definitionOption(NodeDef_GlobalOptionFavorite); 768 const QString strNodeValueDefault = definitionOption(NodeDef_GlobalValueDefault); 769 const QString strDefinitionTemplate = QString("%1(\\S)*=%2").arg(strNodePrefix, strNodeValueDefault); 770 const QRegExp definitionRegExp(strDefinitionTemplate); 748 771 /* For each the group definition: */ 749 772 foreach (const QString &strDefinition, definitions) … … 754 777 /* Get group descriptor: */ 755 778 const QString strDescriptor(definitionRegExp.cap(1)); 756 if (strDescriptor.contains( 'f'))779 if (strDescriptor.contains(strNodeOptionFavorite)) 757 780 return true; 758 781 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r84186 r84376 65 65 public: 66 66 67 /** Extra-data node definition option types. */ 68 enum NodeDef 69 { 70 NodeDef_GlobalPrefix, 71 NodeDef_GlobalOptionFavorite, 72 NodeDef_GlobalValueDefault, 73 NodeDef_MachinePrefix, 74 NodeDef_GroupPrefix, 75 NodeDef_GroupOptionOpened, 76 }; 77 67 78 /** Constructs abstract Chooser-model passing @a pParent to the base-class. */ 68 79 UIChooserAbstractModel(UIChooser *pParent); … … 109 120 * @note Required for backward compatibility after QString=>QUuid change. */ 110 121 static QString toOldStyleUuid(const QUuid &uId); 122 123 /** Returns extra-data node definition option of certain @a enmType. */ 124 static QString definitionOption(NodeDef enmType); 111 125 /** @} */ 112 126 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r84371 r84376 222 222 const QString strItemDescriptor = strDefinition.section('=', 1, -1); 223 223 /* Its a group-item definition? */ 224 if (strItemType == "g")224 if (strItemType == definitionOption(NodeDef_GroupPrefix)) 225 225 { 226 226 /* Search for group-item with passed descriptor (name): */ … … 232 232 } 233 233 /* Its a global-item definition? */ 234 else if (strItemType == "n")234 else if (strItemType == definitionOption(NodeDef_GlobalPrefix)) 235 235 { 236 236 /* Search for global-item with required name: */ … … 240 240 } 241 241 /* Its a machine-item definition? */ 242 else if (strItemType == "m")242 else if (strItemType == definitionOption(NodeDef_MachinePrefix)) 243 243 { 244 244 /* Search for machine-item with required ID: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGlobal.cpp
r84373 r84376 17 17 18 18 /* GUI includes: */ 19 #include "UIChooserAbstractModel.h" 19 20 #include "UIChooserNodeGlobal.h" 20 21 … … 77 78 QString UIChooserNodeGlobal::definition(bool fFull /* = false */) const 78 79 { 80 const QString strNodePrefix = UIChooserAbstractModel::definitionOption(UIChooserAbstractModel::NodeDef_GlobalPrefix); 81 const QString strNodeOptionFavorite = UIChooserAbstractModel::definitionOption(UIChooserAbstractModel::NodeDef_GlobalOptionFavorite); 82 const QString strNodeValueDefault = UIChooserAbstractModel::definitionOption(UIChooserAbstractModel::NodeDef_GlobalValueDefault); 79 83 return fFull 80 ? QString(" n%1=%2").arg(isFavorite() ? "f" : "").arg("GLOBAL")81 : QString(" n=%1").arg("GLOBAL");84 ? QString("%1%2=%3").arg(strNodePrefix).arg(isFavorite() ? strNodeOptionFavorite : "").arg(strNodeValueDefault) 85 : QString("%1=%2").arg(strNodePrefix).arg(strNodeValueDefault); 82 86 } 83 87 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGroup.cpp
r84373 r84376 17 17 18 18 /* GUI includes: */ 19 #include "UIChooserAbstractModel.h" 19 20 #include "UIChooserNodeGroup.h" 20 21 #include "UIChooserNodeGlobal.h" … … 107 108 QString UIChooserNodeGroup::definition(bool fFull /* = false */) const 108 109 { 110 const QString strNodePrefix = UIChooserAbstractModel::definitionOption(UIChooserAbstractModel::NodeDef_GroupPrefix); 111 const QString strNodeOptionOpened = UIChooserAbstractModel::definitionOption(UIChooserAbstractModel::NodeDef_GroupOptionOpened); 109 112 return fFull 110 ? QString(" g%1=%2").arg(isOpened() ? "o": "").arg(name())111 : QString(" g=%1").arg(fullName());113 ? QString("%1%2=%3").arg(strNodePrefix).arg(isOpened() ? strNodeOptionOpened : "").arg(name()) 114 : QString("%1=%2").arg(strNodePrefix).arg(fullName()); 112 115 } 113 116 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeMachine.cpp
r84373 r84376 138 138 QString UIChooserNodeMachine::definition(bool) const 139 139 { 140 return QString("m=%1").arg(UIChooserAbstractModel::toOldStyleUuid(id())); 140 const QString strNodePrefix = UIChooserAbstractModel::definitionOption(UIChooserAbstractModel::NodeDef_MachinePrefix); 141 return QString("%1=%2").arg(strNodePrefix).arg(UIChooserAbstractModel::toOldStyleUuid(id())); 141 142 } 142 143
Note:
See TracChangeset
for help on using the changeset viewer.