VirtualBox

Changeset 43616 in vbox


Ignore:
Timestamp:
Oct 11, 2012 12:29:00 PM (12 years ago)
Author:
vboxsync
Message:

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

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

    r43615 r43616  
    972972    UIGChooserItemMachine::enumerateMachineItems(mainRoot()->items(), existingMachineItemList);
    973973
    974     /* Prepare maps: */
    975     QMap<QString, bool> verdictMap;
    976     QMap<QString, QString> namesMap;
     974    /* Prepare arrays: */
     975    QMap<QString, bool> verdicts;
     976    QList<UIGChooserItem*> itemsToRemove;
     977    QStringList machinesToUnregister;
    977978
    978979    /* For each selected machine-item: */
    979980    foreach (UIGChooserItem *pItem, selectedMachineItemList)
    980981    {
    981         /* Get item name/id: */
    982         QString strName = pItem->name();
     982        /* Get machine-item id: */
    983983        QString strId = pItem->toMachineItem()->id();
    984984
    985         /* Check if we already decided for that machine: */
    986         if (verdictMap.contains(strId))
     985        /* We already decided for that machine? */
     986        if (verdicts.contains(strId))
     987        {
     988            /* To remove similar machine items? */
     989            if (!verdicts[strId])
     990                itemsToRemove << pItem;
    987991            continue;
     992        }
    988993
    989994        /* Selected copy count: */
     
    992997            if (pSelectedItem->toMachineItem()->id() == strId)
    993998                ++iSelectedCopyCount;
    994 
    995999        /* Existing copy count: */
    9961000        int iExistingCopyCount = 0;
     
    9981002            if (pExistingItem->toMachineItem()->id() == strId)
    9991003                ++iExistingCopyCount;
    1000 
    10011004        /* If selected copy count equal to existing copy count,
    10021005         * we will propose ro unregister machine fully else
    10031006         * we will just propose to remove selected items: */
    1004         verdictMap.insert(strId, iSelectedCopyCount == iExistingCopyCount);
    1005         namesMap.insert(strId, strName);
     1007        bool fVerdict = iSelectedCopyCount == iExistingCopyCount;
     1008        verdicts.insert(strId, fVerdict);
     1009        if (fVerdict)
     1010            machinesToUnregister << strId;
     1011        else
     1012            itemsToRemove << pItem;
    10061013    }
    10071014
    10081015    /* If we have something to remove: */
    1009     if (verdictMap.values().contains(false))
    1010     {
    1011         /* Gather names: */
    1012         QStringList names;
    1013         foreach (const QString &strId, verdictMap.keys())
    1014             if (!verdictMap[strId])
    1015                 names << namesMap[strId];
    1016         removeMachineItems(names, selectedMachineItemList);
    1017     }
     1016    if (!itemsToRemove.isEmpty())
     1017        removeItems(itemsToRemove);
    10181018    /* If we have something to unregister: */
    1019     if (verdictMap.values().contains(true))
    1020     {
    1021         /* Gather ids: */
    1022         QStringList ids;
    1023         foreach (const QString &strId, verdictMap.keys())
    1024             if (verdictMap[strId])
    1025                 ids << strId;
    1026         unregisterMachines(ids);
    1027     }
     1019    if (!machinesToUnregister.isEmpty())
     1020        unregisterMachines(machinesToUnregister);
    10281021}
    10291022
     
    14591452}
    14601453
    1461 void UIGChooserModel::removeMachineItems(const QStringList &names, QList<UIGChooserItemMachine*> &items)
     1454void UIGChooserModel::removeItems(const QList<UIGChooserItem*> &itemsToRemove)
    14621455{
    14631456    /* Show machine-items remove dialog: */
     1457    QStringList names;
     1458    foreach (UIGChooserItem *pItem, itemsToRemove)
     1459        names << pItem->name();
    14641460    int rc = msgCenter().confirmMachineItemRemoval(names);
    14651461    if (rc == QIMessageBox::Cancel)
    14661462        return;
    14671463
    1468     /* Remove all the required items: */
    1469     foreach (UIGChooserItem *pItem, items)
    1470         if (names.contains(pItem->name()))
    1471             delete pItem;
     1464    /* Remove all the passed items: */
     1465    foreach (UIGChooserItem *pItem, itemsToRemove)
     1466        delete pItem;
    14721467
    14731468    /* And update model: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h

    r43615 r43616  
    249249    void updateMachineItems(const QString &strId, UIGChooserItem *pParent);
    250250    void removeMachineItems(const QString &strId, UIGChooserItem *pParent);
    251     void removeMachineItems(const QStringList &names, QList<UIGChooserItemMachine*> &selectedItems);
     251    void removeItems(const QList<UIGChooserItem*> &itemsToRemove);
    252252    void unregisterMachines(const QStringList &ids);
    253253
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