VirtualBox

Changeset 42851 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 16, 2012 5:06:40 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: 6234: Support for VM groups: Fixing bugs in machine (item) remove procedure.

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

    r42850 r42851  
    716716    QList<UIGChooserItem*> existingMachineItemList = gatherMachineItems(mainRoot()->items());
    717717
    718     /* Prepare removing map: */
    719     QMap<QString, bool> removingMap;
     718    /* Prepare maps: */
     719    QMap<QString, bool> verdictMap;
     720    QMap<QString, QString> namesMap;
    720721
    721722    /* For each selected machine item: */
    722723    foreach (UIGChooserItem *pItem, selectedMachineItemList)
    723724    {
    724         /* Get item name: */
     725        /* Get item name/id: */
    725726        QString strName = pItem->name();
     727        QString strId = pItem->toMachineItem()->id();
    726728
    727729        /* Check if we already decided for that machine: */
    728         if (removingMap.contains(strName))
     730        if (verdictMap.contains(strId))
    729731            continue;
    730732
     
    732734        int iSelectedCopyCount = 0;
    733735        foreach (UIGChooserItem *pSelectedItem, selectedMachineItemList)
    734             if (pSelectedItem->name() == strName)
     736            if (pSelectedItem->toMachineItem()->id() == strId)
    735737                ++iSelectedCopyCount;
    736738
     
    738740        int iExistingCopyCount = 0;
    739741        foreach (UIGChooserItem *pExistingItem, existingMachineItemList)
    740             if (pExistingItem->name() == strName)
     742            if (pExistingItem->toMachineItem()->id() == strId)
    741743                ++iExistingCopyCount;
    742744
     
    744746         * we will propose ro unregister machine fully else
    745747         * we will just propose to remove selected items: */
    746         removingMap.insert(strName, iSelectedCopyCount == iExistingCopyCount);
     748        verdictMap.insert(strId, iSelectedCopyCount == iExistingCopyCount);
     749        namesMap.insert(strId, strName);
    747750    }
    748751
    749752    /* If we have something to remove: */
    750     if (removingMap.values().contains(false))
     753    if (verdictMap.values().contains(false))
    751754    {
    752755        /* Gather names: */
    753756        QStringList names;
    754         foreach (const QString &strName, removingMap.keys())
    755             if (!removingMap[strName])
    756                 names << strName;
     757        foreach (const QString &strId, verdictMap.keys())
     758            if (!verdictMap[strId])
     759                names << namesMap[strId];
    757760        removeMachineItems(names, selectedMachineItemList);
    758761    }
    759762    /* If we have something to unregister: */
    760     if (removingMap.values().contains(true))
    761     {
    762         /* Gather names: */
    763         QStringList names;
    764         foreach (const QString &strName, removingMap.keys())
    765             if (removingMap[strName])
    766                 names << strName;
    767         unregisterMachines(names);
     763    if (verdictMap.values().contains(true))
     764    {
     765        /* Gather ids: */
     766        QStringList ids;
     767        foreach (const QString &strId, verdictMap.keys())
     768            if (verdictMap[strId])
     769                ids << strId;
     770        unregisterMachines(ids);
    768771    }
    769772}
     
    17491752    else
    17501753        unsetCurrentItem();
    1751 }
    1752 
    1753 void UIGChooserModel::unregisterMachines(const QStringList &names)
     1754    saveGroupSettings();
     1755}
     1756
     1757void UIGChooserModel::unregisterMachines(const QStringList &ids)
    17541758{
    17551759    /* Populate machine list: */
    17561760    QList<CMachine> machines;
    17571761    CVirtualBox vbox = vboxGlobal().virtualBox();
    1758     foreach (const QString &strName, names)
    1759     {
    1760         CMachine machine = vbox.FindMachine(strName);
     1762    foreach (const QString &strId, ids)
     1763    {
     1764        CMachine machine = vbox.FindMachine(strId);
    17611765        if (!machine.isNull())
    17621766            machines << machine;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h

    r42832 r42851  
    296296    /* Helpers: Remove stuff: */
    297297    void removeMachineItems(const QStringList &names, QList<UIGChooserItem*> &selectedItems);
    298     void unregisterMachines(const QStringList &names);
     298    void unregisterMachines(const QStringList &ids);
    299299
    300300    /* Helper: Sorting stuff: */
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