Changeset 43595 in vbox
- Timestamp:
- Oct 10, 2012 2:05:06 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r43594 r43595 1367 1367 if (pItem->type() == UIGChooserItemType_Machine) 1368 1368 { 1369 if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())1370 return pMachineItem;1369 /* Just return it: */ 1370 return pItem->toMachineItem(); 1371 1371 } 1372 1372 /* If that is group-item: */ … … 1433 1433 { 1434 1434 /* Search among all the group-items of passed parent: */ 1435 foreach (UIGChooserItem *pGroupItem, pParent->items(UIGChooserItemType_Group)) 1436 if (pGroupItem->name() == strName) 1435 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group)) 1436 if (pItem->name() == strName) 1437 return pItem; 1438 /* Recursively iterate into each the group-item of the passed parent: */ 1439 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group)) 1440 if (UIGChooserItem *pGroupItem = findGroupItem(strName, pItem)) 1437 1441 return pGroupItem; 1438 /* Recursively iterate into each the group-item of the passed parent: */1439 foreach (UIGChooserItem *pGroupItem, pParent->items(UIGChooserItemType_Group))1440 if (UIGChooserItem *pSubGroupItem = findGroupItem(strName, pGroupItem))1441 return pSubGroupItem;1442 1442 /* Nothing found? */ 1443 1443 return 0; 1444 1444 } 1445 1445 1446 void UIGChooserModel::cleanupGroupTree(UIGChooserItem *pGroupItem) 1447 { 1448 /* Cleanup all the group-items first: */ 1449 foreach (UIGChooserItem *pSubGroupItem, pGroupItem->items(UIGChooserItemType_Group)) 1450 cleanupGroupTree(pSubGroupItem); 1451 if (!pGroupItem->hasItems()) 1452 { 1453 /* Cleanup only non-root items: */ 1454 if (!pGroupItem->isRoot()) 1455 delete pGroupItem; 1456 /* Unindent root-items: */ 1446 void UIGChooserModel::cleanupGroupTree(UIGChooserItem *pParent) 1447 { 1448 /* Cleanup all the group-items recursively first: */ 1449 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group)) 1450 cleanupGroupTree(pItem); 1451 /* If parent has no items: */ 1452 if (!pParent->hasItems()) 1453 { 1454 /* Cleanup if that is non-root item: */ 1455 if (!pParent->isRoot()) 1456 delete pParent; 1457 /* Unindent if that is root item: */ 1457 1458 else if (root() != mainRoot()) 1458 1459 unindentRoot(); … … 1463 1464 { 1464 1465 /* Search among all the machine-items of passed parent: */ 1465 foreach (UIGChooserItem *pMachineItem, pParent->items(UIGChooserItemType_Machine)) 1466 if (pMachineItem->name() == strName) 1466 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine)) 1467 if (pItem->name() == strName) 1468 return pItem; 1469 /* Recursively iterate into each the group-item of the passed parent: */ 1470 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group)) 1471 if (UIGChooserItem *pMachineItem = findMachineItem(strName, pItem)) 1467 1472 return pMachineItem; 1468 /* Recursively iterate into each the group-item of the passed parent: */1469 foreach (UIGChooserItem *pGroupItem, pParent->items(UIGChooserItemType_Group))1470 if (UIGChooserItem *pSubMachineItem = findMachineItem(strName, pGroupItem))1471 return pSubMachineItem;1472 1473 /* Nothing found? */ 1473 1474 return 0; 1474 1475 } 1475 1476 1476 void UIGChooserModel::sortItems(UIGChooserItem *pParent , bool fRecursively /* = false */)1477 void UIGChooserModel::sortItems(UIGChooserItem *pParent) 1477 1478 { 1478 1479 /* Sort group-items: */ 1479 1480 QMap<QString, UIGChooserItem*> sorter; 1480 1481 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group)) 1481 {1482 1482 sorter.insert(pItem->name().toLower(), pItem); 1483 if (fRecursively)1484 sortItems(pItem, fRecursively);1485 }1486 1483 pParent->setItems(sorter.values(), UIGChooserItemType_Group); 1487 1484 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r43594 r43595 253 253 /* Helpers: Machine-item stuff: */ 254 254 UIGChooserItem* findMachineItem(const QString &strName, UIGChooserItem *pParent); 255 void sortItems(UIGChooserItem *pParent , bool fRecursively = false);255 void sortItems(UIGChooserItem *pParent); 256 256 void updateMachineItems(const QString &strId, UIGChooserItem *pParent); 257 257 void removeMachineItems(const QString &strId, UIGChooserItem *pParent);
Note:
See TracChangeset
for help on using the changeset viewer.