Changeset 43540 in vbox for trunk/src/VBox
- Timestamp:
- Oct 4, 2012 12:56:22 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooser.cpp
r43536 r43540 149 149 /* Prepare model: */ 150 150 m_pChooserModel->prepare(); 151 152 /* Load last selected item: */153 m_pChooserModel->setCurrentItemDefinition(vboxGlobal().virtualBox().GetExtraData(GUI_LastItemSelected));154 151 } 155 152 156 153 void UIGChooser::save() 157 154 { 158 /* Save last selected item: */159 vboxGlobal().virtualBox().SetExtraData(GUI_LastItemSelected, m_pChooserModel->currentItemDefinition());160 161 155 /* Cleanup model: */ 162 156 m_pChooserModel->cleanup(); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.h
r43447 r43540 81 81 virtual void startEditing() = 0; 82 82 virtual QString name() const = 0; 83 virtual QString definition() const = 0; 83 84 void setRoot(bool fRoot); 84 85 bool isRoot() const; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp
r43539 r43540 185 185 { 186 186 return m_strName; 187 } 188 189 QString UIGChooserItemGroup::definition() const 190 { 191 return QString("g=%1").arg(name()); 187 192 } 188 193 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h
r43505 r43540 68 68 /* API: Basic stuff: */ 69 69 QString name() const; 70 QString definition() const; 70 71 void setName(const QString &strName); 71 72 bool closed() const; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp
r43539 r43540 134 134 } 135 135 136 QString UIGChooserItemMachine::definition() const 137 { 138 return QString("m=%1").arg(name()); 139 } 140 136 141 bool UIGChooserItemMachine::isLockedMachine() const 137 142 { -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h
r43447 r43540 51 51 /* API: Basic stuff: */ 52 52 QString name() const; 53 QString definition() const; 53 54 bool isLockedMachine() const; 54 55 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r43539 r43540 192 192 } 193 193 194 QString UIGChooserModel::currentItemDefinition() const195 {196 /* Determine item type: */197 QString strItemType;198 QString strItemName;199 200 /* Get first selected item: */201 UIGChooserItem *pSelectedItem = currentItem();202 /* Item exists? */203 if (pSelectedItem)204 {205 /* Update item type: */206 if (pSelectedItem->type() == UIGChooserItemType_Group)207 strItemType = "g";208 else if (pSelectedItem->type() == UIGChooserItemType_Machine)209 strItemType = "m";210 211 /* Update item name: */212 strItemName = pSelectedItem->name();213 }214 215 /* Return result: */216 return pSelectedItem ? strItemType + "=" + strItemName : QString();217 }218 219 194 QList<UIVMItem*> UIGChooserModel::currentMachineItems() const 220 195 { … … 260 235 } 261 236 262 void UIGChooserModel::setCurrentItem Definition(const QString &strDefinition)263 { 264 /* Make sure something waspassed: */237 void UIGChooserModel::setCurrentItem(const QString &strDefinition) 238 { 239 /* Ignore if empty definition passed: */ 265 240 if (strDefinition.isEmpty()) 266 {267 if (mainRoot()->hasItems())268 setCurrentItem(0);269 else270 unsetCurrentItem();271 241 return; 272 } 273 274 /* Parse definitions: */242 243 /* Parse definition: */ 244 UIGChooserItem *pItem = 0; 275 245 QString strItemType = strDefinition.section('=', 0, 0); 276 QString strItemName = strDefinition.section('=', 1, -1); 277 UIGChooserItem *pItem = 0; 278 279 /* Its group item? */ 246 QString strItemDescriptor = strDefinition.section('=', 1, -1); 247 /* Its a group-item definition? */ 280 248 if (strItemType == "g") 281 249 { 282 /* Make sure group item with passed id exists: */283 pItem = findGroupItem(strItem Name, mainRoot());284 } 285 /* Its machine item? */250 /* Search for group-item with passed descriptor (name): */ 251 pItem = findGroupItem(strItemDescriptor, mainRoot()); 252 } 253 /* Its a machine-item definition? */ 286 254 else if (strItemType == "m") 287 255 { 288 /* Make sure machine with passed nameregistered: */289 CMachine machine = vboxGlobal().virtualBox().FindMachine(strItem Name);256 /* Check if machine-item with passed descriptor (name or id) registered: */ 257 CMachine machine = vboxGlobal().virtualBox().FindMachine(strItemDescriptor); 290 258 if (!machine.isNull()) 291 259 { 292 /* Make sure machine item with passed id exists: */260 /* Search for machine-item with required name: */ 293 261 pItem = findMachineItem(machine.GetName(), mainRoot()); 294 262 } 295 263 } 296 264 297 /* Found nothing? */ 298 if (!pItem) 299 { 300 setCurrentItem(0); 301 return; 302 } 303 304 /* Select desired item: */ 305 if (navigationList().contains(pItem)) 265 /* Some item found? */ 266 if (pItem) 267 { 268 /* This item should be in navigation list: */ 269 AssertMsg(navigationList().contains(pItem), 270 ("Passed item is NOT in navigation list!")); 271 /* Make this item current: */ 306 272 setCurrentItem(pItem); 307 else 308 setCurrentItem(0); 273 } 309 274 } 310 275 … … 345 310 /* Notify listeners about selection change: */ 346 311 emit sigSelectionChanged(); 347 }348 349 void UIGChooserModel::activate()350 {351 gActionPool->action(UIActionIndexSelector_State_Common_StartOrShow)->activate(QAction::Trigger);352 312 } 353 313 … … 553 513 { 554 514 updateGroupTree(mainRoot()); 515 } 516 517 void UIGChooserModel::activate() 518 { 519 gActionPool->action(UIActionIndexSelector_State_Common_StartOrShow)->activate(QAction::Trigger); 555 520 } 556 521 … … 1235 1200 updateNavigation(); 1236 1201 updateLayout(); 1237 if (mainRoot()->hasItems()) 1202 1203 /* Load last selected item (choose first if unable to load): */ 1204 setCurrentItem(vboxGlobal().virtualBox().GetExtraData(GUI_LastItemSelected)); 1205 if (!currentItem() && !navigationList().isEmpty()) 1238 1206 setCurrentItem(0); 1239 else1240 unsetCurrentItem();1241 1207 } 1242 1208 1243 1209 void UIGChooserModel::cleanupGroupTree() 1244 1210 { 1211 /* Save last selected item: */ 1212 vboxGlobal().virtualBox().SetExtraData(GUI_LastItemSelected, 1213 currentItem() ? currentItem()->definition() : QString()); 1214 1245 1215 /* Currently we are not saving group descriptors 1246 1216 * (which reflecting group toggle-state) on-the-fly -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r43539 r43540 111 111 /* API: Current-item stuff: */ 112 112 UIVMItem* currentMachineItem() const; 113 QString currentItemDefinition() const;114 113 QList<UIVMItem*> currentMachineItems() const; 115 114 UIGChooserItem* currentItem() const; … … 117 116 void setCurrentItem(int iItemIndex); 118 117 void setCurrentItem(UIGChooserItem *pItem); 119 void setCurrentItem Definition(const QString &strDefinition);118 void setCurrentItem(const QString &strDefinition); 120 119 void unsetCurrentItem(); 121 120 void addToCurrentItems(UIGChooserItem *pItem); … … 123 122 void clearSelectionList(); 124 123 void notifyCurrentItemChanged(); 125 void activate();126 124 bool isSingleGroupSelected() const; 127 125 bool isAllItemsOfOneGroupSelected() const; … … 142 140 void startEditing(); 143 141 void updateGroupTree(); 142 143 /* API: Machine-item stuff: */ 144 void activate(); 144 145 145 146 /* API: Drag&drop stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.