VirtualBox

Changeset 86629 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Oct 19, 2020 1:05:06 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Rework unregister cloud machine action to be updated with subsequent List Cloud Machine task; This is possible since r140984 where this task is used to determine [un]registered cloud machines.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r86611 r86629  
    708708    /* Prepare arrays: */
    709709    QMap<QUuid, bool> verdicts;
    710     QList<UIChooserItemMachine*> itemsToRemove;
     710    QList<UIChooserItemMachine*> localMachineItemsToRemove;
    711711    QList<CMachine> localMachinesToUnregister;
    712     QList<CCloudMachine> cloudMachinesToUnregister;
     712    QList<UIChooserItemMachine*> cloudMachineItemsToUnregister;
    713713
    714714    /* For each selected machine-item: */
     
    724724            /* To remove similar machine items? */
    725725            if (!verdicts.value(uId))
    726                 itemsToRemove << pMachineItem;
     726                localMachineItemsToRemove << pMachineItem;
    727727            continue;
    728728        }
     
    754754                localMachinesToUnregister.append(pMachineItem->cache()->toLocal()->machine());
    755755            else if (pMachineItem->cacheType() == UIVirtualMachineItemType_CloudReal)
    756                 cloudMachinesToUnregister.append(pMachineItem->cache()->toCloud()->machine());
     756                cloudMachineItemsToUnregister.append(pMachineItem);
    757757        }
    758758        else
    759             itemsToRemove << pMachineItem;
     759            localMachineItemsToRemove << pMachineItem;
    760760    }
    761761
    762762    /* If we have something to remove: */
    763     if (!itemsToRemove.isEmpty())
    764         removeItems(itemsToRemove);
     763    if (!localMachineItemsToRemove.isEmpty())
     764        removeLocalMachineItems(localMachineItemsToRemove);
    765765    /* If we have something local to unregister: */
    766766    if (!localMachinesToUnregister.isEmpty())
    767767        unregisterLocalMachines(localMachinesToUnregister);
    768768    /* If we have something cloud to unregister: */
    769     if (!cloudMachinesToUnregister.isEmpty())
    770         unregisterCloudMachines(cloudMachinesToUnregister);
     769    if (!cloudMachineItemsToUnregister.isEmpty())
     770        unregisterCloudMachineItems(cloudMachineItemsToUnregister);
    771771}
    772772
     
    16861686}
    16871687
    1688 void UIChooserModel::removeItems(const QList<UIChooserItemMachine*> &machineItems)
     1688void UIChooserModel::removeLocalMachineItems(const QList<UIChooserItemMachine*> &machineItems)
    16891689{
    16901690    /* Confirm machine-items removal: */
     
    17631763}
    17641764
    1765 void UIChooserModel::unregisterCloudMachines(const QList<CCloudMachine> &machines)
    1766 {
     1765void UIChooserModel::unregisterCloudMachineItems(const QList<UIChooserItemMachine*> &machineItems)
     1766{
     1767    /* Compose a list of machines: */
     1768    QList<CCloudMachine> machines;
     1769    foreach (UIChooserItemMachine *pMachineItem, machineItems)
     1770        machines << pMachineItem->cache()->toCloud()->machine();
     1771
    17671772    /* Confirm machine removal: */
    17681773    const int iResultCode = msgCenter().confirmCloudMachineRemoval(machines);
     
    17701775        return;
    17711776
    1772     /* For every selected machine: */
    1773     foreach (CCloudMachine comMachine, machines)
    1774     {
    1775         /* Remember machine ID: */
    1776         const QUuid uId = comMachine.GetId();
    1777         if (!comMachine.isOk())
    1778         {
    1779             msgCenter().cannotAcquireCloudMachineParameter(comMachine);
    1780             continue;
    1781         }
    1782 
     1777    /* For every selected machine-item: */
     1778    typedef QPair<QString, QString> UICloudAccount;
     1779    QSet<UICloudAccount> changedAccounts;
     1780    foreach (UIChooserItemMachine *pMachineItem, machineItems)
     1781    {
     1782        /* Acquire cloud machine: */
     1783        CCloudMachine comMachine = pMachineItem->cache()->toCloud()->machine();
    17831784        CProgress comProgress;
    17841785        /* Prepare remove progress: */
     
    17931794            continue;
    17941795        }
    1795 
    17961796        /* And show unregister progress finally: */
    17971797        msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_delete_90px.png", 0, 0);
     
    18011801            continue;
    18021802        }
    1803 
    1804         // WORKAROUND:
    1805         // Hehey! Now we have to remove deleted VM nodes and then update tree for the main root node
    1806         // ourselves cause there is no corresponding event yet. So we are calling actual handler to do that.
    1807         UIChooserItem *pItem = root()->searchForItem(uId.toString(),
    1808                                                      UIChooserItemSearchFlag_Machine |
    1809                                                      UIChooserItemSearchFlag_ExactId);
    1810         AssertPtrReturnVoid(pItem);
    1811         AssertReturnVoid(pItem->node()->toMachineNode()->cacheType() == UIVirtualMachineItemType_CloudReal);
    1812         AssertPtrReturnVoid(pItem->parentItem());
    1813         AssertPtrReturnVoid(pItem->parentItem()->parentItem());
    1814         const QString strProviderShortName = pItem->parentItem()->parentItem()->name();
    1815         const QString strProfileName = pItem->parentItem()->name();
    1816         sltCloudMachineUnregistered(strProviderShortName,
    1817                                     strProfileName,
    1818                                     uId /* machine ID */);
     1803        /* Compose cloud account to update: */
     1804        const QString strProviderShortName = pMachineItem->parentItem()->parentItem()->name();
     1805        const QString strProfileName = pMachineItem->parentItem()->name();
     1806        const UICloudAccount account = qMakePair(strProviderShortName, strProfileName);
     1807        if (!changedAccounts.contains(account))
     1808            changedAccounts.insert(account);
     1809    }
     1810
     1811    /* Restart list cloud machines task for required accounts: */
     1812    foreach (const UICloudAccount &account, changedAccounts)
     1813    {
     1814        UITaskCloudListMachines *pTask = new UITaskCloudListMachines(account.first /* short provider name */,
     1815                                                                     account.second /* profile name */,
     1816                                                                     false /* with refresh? */);
     1817        AssertPtrReturnVoid(pTask);
     1818        uiCommon().threadPoolCloud()->enqueueTask(pTask);
    18191819    }
    18201820}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r86611 r86629  
    379379        void updateTreeForMainRoot();
    380380
    381         /** Removes @a machineItems. */
    382         void removeItems(const QList<UIChooserItemMachine*> &machineItems);
     381        /** Removes a list of local virtual @a machineItems. */
     382        void removeLocalMachineItems(const QList<UIChooserItemMachine*> &machineItems);
    383383        /** Unregisters a list of local virtual @a machines. */
    384384        void unregisterLocalMachines(const QList<CMachine> &machines);
    385         /** Unregisters a list of cloud virtual @a machines. */
    386         void unregisterCloudMachines(const QList<CCloudMachine> &machines);
     385        /** Unregisters a list of cloud virtual @a machineItems. */
     386        void unregisterCloudMachineItems(const QList<UIChooserItemMachine*> &machineItems);
    387387
    388388        /** Processes drag move @a pEvent. */
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