Changeset 86629 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 19, 2020 1:05:06 PM (4 years ago)
- 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 708 708 /* Prepare arrays: */ 709 709 QMap<QUuid, bool> verdicts; 710 QList<UIChooserItemMachine*> itemsToRemove;710 QList<UIChooserItemMachine*> localMachineItemsToRemove; 711 711 QList<CMachine> localMachinesToUnregister; 712 QList< CCloudMachine> cloudMachinesToUnregister;712 QList<UIChooserItemMachine*> cloudMachineItemsToUnregister; 713 713 714 714 /* For each selected machine-item: */ … … 724 724 /* To remove similar machine items? */ 725 725 if (!verdicts.value(uId)) 726 itemsToRemove << pMachineItem;726 localMachineItemsToRemove << pMachineItem; 727 727 continue; 728 728 } … … 754 754 localMachinesToUnregister.append(pMachineItem->cache()->toLocal()->machine()); 755 755 else if (pMachineItem->cacheType() == UIVirtualMachineItemType_CloudReal) 756 cloudMachine sToUnregister.append(pMachineItem->cache()->toCloud()->machine());756 cloudMachineItemsToUnregister.append(pMachineItem); 757 757 } 758 758 else 759 itemsToRemove << pMachineItem;759 localMachineItemsToRemove << pMachineItem; 760 760 } 761 761 762 762 /* If we have something to remove: */ 763 if (! itemsToRemove.isEmpty())764 remove Items(itemsToRemove);763 if (!localMachineItemsToRemove.isEmpty()) 764 removeLocalMachineItems(localMachineItemsToRemove); 765 765 /* If we have something local to unregister: */ 766 766 if (!localMachinesToUnregister.isEmpty()) 767 767 unregisterLocalMachines(localMachinesToUnregister); 768 768 /* If we have something cloud to unregister: */ 769 if (!cloudMachine sToUnregister.isEmpty())770 unregisterCloudMachine s(cloudMachinesToUnregister);769 if (!cloudMachineItemsToUnregister.isEmpty()) 770 unregisterCloudMachineItems(cloudMachineItemsToUnregister); 771 771 } 772 772 … … 1686 1686 } 1687 1687 1688 void UIChooserModel::remove Items(const QList<UIChooserItemMachine*> &machineItems)1688 void UIChooserModel::removeLocalMachineItems(const QList<UIChooserItemMachine*> &machineItems) 1689 1689 { 1690 1690 /* Confirm machine-items removal: */ … … 1763 1763 } 1764 1764 1765 void UIChooserModel::unregisterCloudMachines(const QList<CCloudMachine> &machines) 1766 { 1765 void 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 1767 1772 /* Confirm machine removal: */ 1768 1773 const int iResultCode = msgCenter().confirmCloudMachineRemoval(machines); … … 1770 1775 return; 1771 1776 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(); 1783 1784 CProgress comProgress; 1784 1785 /* Prepare remove progress: */ … … 1793 1794 continue; 1794 1795 } 1795 1796 1796 /* And show unregister progress finally: */ 1797 1797 msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_delete_90px.png", 0, 0); … … 1801 1801 continue; 1802 1802 } 1803 1804 // WORKAROUND:1805 // Hehey! Now we have to remove deleted VM nodes and then update tree for the main root node1806 // 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); 1819 1819 } 1820 1820 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r86611 r86629 379 379 void updateTreeForMainRoot(); 380 380 381 /** Removes @a machineItems. */382 void remove Items(const QList<UIChooserItemMachine*> &machineItems);381 /** Removes a list of local virtual @a machineItems. */ 382 void removeLocalMachineItems(const QList<UIChooserItemMachine*> &machineItems); 383 383 /** Unregisters a list of local virtual @a machines. */ 384 384 void unregisterLocalMachines(const QList<CMachine> &machines); 385 /** Unregisters a list of cloud virtual @a machine s. */386 void unregisterCloudMachine s(const QList<CCloudMachine> &machines);385 /** Unregisters a list of cloud virtual @a machineItems. */ 386 void unregisterCloudMachineItems(const QList<UIChooserItemMachine*> &machineItems); 387 387 388 388 /** Processes drag move @a pEvent. */
Note:
See TracChangeset
for help on using the changeset viewer.