Changeset 83683 in vbox for trunk/src/VBox
- Timestamp:
- Apr 13, 2020 6:34:08 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 137178
- 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
r83682 r83683 46 46 #include "UIVirtualBoxManagerWidget.h" 47 47 #include "UIVirtualMachineItemCloud.h" 48 #include "UIVirtualMachineItemLocal.h" 48 49 #include "UIWizardAddCloudVM.h" 49 50 #include "UIWizardNewVM.h" … … 1123 1124 QMap<QUuid, bool> verdicts; 1124 1125 QList<UIChooserItem*> itemsToRemove; 1125 QList< QUuid> machinesToUnregister;1126 QList<CMachine> localMachinesToUnregister; 1126 1127 1127 1128 /* For each selected machine-item: */ … … 1129 1130 { 1130 1131 /* Get machine-item id: */ 1131 QUuid uId = pItem->toMachineItem()->id();1132 const QUuid uId = pItem->toMachineItem()->id(); 1132 1133 1133 1134 /* We already decided for that machine? */ … … 1135 1136 { 1136 1137 /* To remove similar machine items? */ 1137 if (!verdicts [uId])1138 if (!verdicts.value(uId)) 1138 1139 itemsToRemove << pItem; 1139 1140 continue; … … 1153 1154 * we will propose ro unregister machine fully else 1154 1155 * we will just propose to remove selected-items: */ 1155 bool fVerdict = iSelectedCopyCount == iExistingCopyCount;1156 const bool fVerdict = iSelectedCopyCount == iExistingCopyCount; 1156 1157 verdicts.insert(uId, fVerdict); 1157 1158 if (fVerdict) 1158 machinesToUnregister.append(uId);1159 localMachinesToUnregister.append(pItem->node()->toMachineNode()->cache()->toLocal()->machine()); 1159 1160 else 1160 1161 itemsToRemove << pItem; … … 1164 1165 if (!itemsToRemove.isEmpty()) 1165 1166 removeItems(itemsToRemove); 1166 /* If we have something to unregister: */1167 if (! machinesToUnregister.isEmpty())1168 unregisterMachines( machinesToUnregister);1167 /* If we have something local to unregister: */ 1168 if (!localMachinesToUnregister.isEmpty()) 1169 unregisterMachines(localMachinesToUnregister); 1169 1170 } 1170 1171 … … 1633 1634 } 1634 1635 1635 void UIChooserModel::unregisterMachines(const QList<QUuid> &ids) 1636 { 1637 /* Populate machine list: */ 1638 QList<CMachine> machines; 1639 CVirtualBox vbox = uiCommon().virtualBox(); 1640 foreach (const QUuid &uId, ids) 1641 { 1642 CMachine machine = vbox.FindMachine(uId.toString()); 1643 if (!machine.isNull()) 1644 machines << machine; 1645 } 1646 1636 void UIChooserModel::unregisterMachines(const QList<CMachine> &machines) 1637 { 1647 1638 /* Confirm machine removal: */ 1648 1639 int iResultCode = msgCenter().confirmMachineRemoval(machines); … … 1653 1644 setSelectedItem(findClosestUnselectedItem()); 1654 1645 1655 /* For every selected-item: */ 1656 for (int iMachineIndex = 0; iMachineIndex < machines.size(); ++iMachineIndex) 1657 { 1658 /* Get iterated machine: */ 1659 CMachine &machine = machines[iMachineIndex]; 1646 /* For every selected machine: */ 1647 foreach (CMachine comMachine, machines) 1648 { 1660 1649 if (iResultCode == AlertButton_Choice1) 1661 1650 { 1662 1651 /* Unregister machine first: */ 1663 CMediumVector media = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly);1664 if (! machine.isOk())1652 CMediumVector comMedia = comMachine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly); 1653 if (!comMachine.isOk()) 1665 1654 { 1666 msgCenter().cannotRemoveMachine( machine);1655 msgCenter().cannotRemoveMachine(comMachine); 1667 1656 continue; 1668 1657 } 1669 1658 /* Prepare cleanup progress: */ 1670 CProgress progress = machine.DeleteConfig(media);1671 if (! machine.isOk())1659 CProgress comProgress = comMachine.DeleteConfig(comMedia); 1660 if (!comMachine.isOk()) 1672 1661 { 1673 msgCenter().cannotRemoveMachine( machine);1662 msgCenter().cannotRemoveMachine(comMachine); 1674 1663 continue; 1675 1664 } 1676 1665 /* And show cleanup progress finally: */ 1677 msgCenter().showModalProgressDialog( progress, machine.GetName(), ":/progress_delete_90px.png");1678 if (! progress.isOk() || progress.GetResultCode() != 0)1666 msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_delete_90px.png"); 1667 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1679 1668 { 1680 msgCenter().cannotRemoveMachine( machine, progress);1669 msgCenter().cannotRemoveMachine(comMachine, comProgress); 1681 1670 continue; 1682 1671 } … … 1685 1674 { 1686 1675 /* Unregister machine first: */ 1687 CMediumVector media = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly);1688 if (! machine.isOk())1676 CMediumVector comMedia = comMachine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly); 1677 if (!comMachine.isOk()) 1689 1678 { 1690 msgCenter().cannotRemoveMachine( machine);1679 msgCenter().cannotRemoveMachine(comMachine); 1691 1680 continue; 1692 1681 } 1693 1682 /* Finally close all media, deliberately ignoring errors: */ 1694 foreach (CMedium medium, media)1683 foreach (CMedium comMedium, comMedia) 1695 1684 { 1696 if (! medium.isNull())1697 medium.Close();1685 if (!comMedium.isNull()) 1686 comMedium.Close(); 1698 1687 } 1699 1688 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r83674 r83683 28 28 #include "UIChooserAbstractModel.h" 29 29 #include "UIExtraDataDefs.h" 30 31 /* COM includes: */ 32 #include "COMEnums.h" 33 #include "CMachine.h" 30 34 31 35 /* Forward declaration: */ … … 359 363 /** Removes machine @a items. */ 360 364 void removeItems(const QList<UIChooserItem*> &items); 361 /** Unregisters virtual machines using list of @a ids. */362 void unregisterMachines(const QList< QUuid> &ids);365 /** Unregisters a list of virtual @a machines. */ 366 void unregisterMachines(const QList<CMachine> &machines); 363 367 364 368 /** Processes drag move @a pEvent. */
Note:
See TracChangeset
for help on using the changeset viewer.