VirtualBox

Changeset 43595 in vbox


Ignore:
Timestamp:
Oct 10, 2012 2:05:06 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM group feature UI: Group/machine item handling cleanup (part 4).

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  
    13671367        if (pItem->type() == UIGChooserItemType_Machine)
    13681368        {
    1369             if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())
    1370                 return pMachineItem;
     1369            /* Just return it: */
     1370            return pItem->toMachineItem();
    13711371        }
    13721372        /* If that is group-item: */
     
    14331433{
    14341434    /* 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))
    14371441            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;
    14421442    /* Nothing found? */
    14431443    return 0;
    14441444}
    14451445
    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: */
     1446void 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: */
    14571458        else if (root() != mainRoot())
    14581459            unindentRoot();
     
    14631464{
    14641465    /* 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))
    14671472            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;
    14721473    /* Nothing found? */
    14731474    return 0;
    14741475}
    14751476
    1476 void UIGChooserModel::sortItems(UIGChooserItem *pParent, bool fRecursively /* = false */)
     1477void UIGChooserModel::sortItems(UIGChooserItem *pParent)
    14771478{
    14781479    /* Sort group-items: */
    14791480    QMap<QString, UIGChooserItem*> sorter;
    14801481    foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group))
    1481     {
    14821482        sorter.insert(pItem->name().toLower(), pItem);
    1483         if (fRecursively)
    1484             sortItems(pItem, fRecursively);
    1485     }
    14861483    pParent->setItems(sorter.values(), UIGChooserItemType_Group);
    14871484
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h

    r43594 r43595  
    253253    /* Helpers: Machine-item stuff: */
    254254    UIGChooserItem* findMachineItem(const QString &strName, UIGChooserItem *pParent);
    255     void sortItems(UIGChooserItem *pParent, bool fRecursively = false);
     255    void sortItems(UIGChooserItem *pParent);
    256256    void updateMachineItems(const QString &strId, UIGChooserItem *pParent);
    257257    void removeMachineItems(const QString &strId, UIGChooserItem *pParent);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette