- Timestamp:
- May 25, 2020 4:23:21 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r84516 r84517 777 777 } 778 778 779 void UIVirtualBoxManager::sltPerformMachineRemove() 780 { 781 m_pWidget->removeMachine(); 782 } 783 779 784 void UIVirtualBoxManager::sltPerformMachineMoveToNewGroup() 780 785 { … … 1612 1617 connect(actionPool()->action(UIActionIndexST_M_Machine_S_ExportToOCI), &UIAction::triggered, 1613 1618 this, &UIVirtualBoxManager::sltOpenExportApplianceWizard); 1619 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Remove), &UIAction::triggered, 1620 this, &UIVirtualBoxManager::sltPerformMachineRemove); 1614 1621 connect(actionPool()->action(UIActionIndexST_M_Machine_M_MoveToGroup_S_New), &UIAction::triggered, 1615 1622 this, &UIVirtualBoxManager::sltPerformMachineMoveToNewGroup); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r84516 r84517 210 210 /** Handles call to move machine. */ 211 211 void sltPerformMachineMove(); 212 213 /** Handles call to remove machine. */ 214 void sltPerformMachineRemove(); 212 215 213 216 /** Handles call to move machine to a new group. */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r84516 r84517 124 124 { 125 125 m_pPaneChooser->disbandGroup(); 126 } 127 128 void UIVirtualBoxManagerWidget::removeMachine() 129 { 130 m_pPaneChooser->removeMachine(); 126 131 } 127 132 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h
r84516 r84517 142 142 /** Disbands group. */ 143 143 void disbandGroup(); 144 /** Removes machine. */ 145 void removeMachine(); 144 146 /** Moves machine to a new group. */ 145 147 void moveMachineToNewGroup(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp
r84516 r84517 123 123 AssertPtrReturnVoid(model()); 124 124 model()->disbandSelectedGroupItem(); 125 } 126 127 void UIChooser::removeMachine() 128 { 129 AssertPtrReturnVoid(model()); 130 model()->removeSelectedMachineItems(); 125 131 } 126 132 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h
r84516 r84517 136 136 /** Disbands group. */ 137 137 void disbandGroup(); 138 /** Removes machine. */ 139 void removeMachine(); 138 140 /** Moves machine to a new group. */ 139 141 void moveMachineToNewGroup(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r84516 r84517 48 48 #include "UIVirtualMachineItemCloud.h" 49 49 #include "UIVirtualMachineItemLocal.h" 50 #include "UIWizardNewCloudVM.h"51 #include "UIWizardNewVM.h"52 50 53 51 /* COM includes: */ … … 661 659 } 662 660 saveGroups(); 661 } 662 663 void UIChooserModel::removeSelectedMachineItems() 664 { 665 /* Enumerate all the selected machine-items: */ 666 QList<UIChooserItemMachine*> selectedMachineItemList; 667 UIChooserItemMachine::enumerateMachineItems(selectedItems(), selectedMachineItemList); 668 /* Enumerate all the existing machine-items: */ 669 QList<UIChooserItemMachine*> existingMachineItemList; 670 UIChooserItemMachine::enumerateMachineItems(root()->items(), existingMachineItemList); 671 672 /* Prepare arrays: */ 673 QMap<QUuid, bool> verdicts; 674 QList<UIChooserItemMachine*> itemsToRemove; 675 QList<CMachine> localMachinesToUnregister; 676 QList<CCloudMachine> cloudMachinesToUnregister; 677 678 /* For each selected machine-item: */ 679 foreach (UIChooserItemMachine *pMachineItem, selectedMachineItemList) 680 { 681 /* Get machine-item id: */ 682 AssertPtrReturnVoid(pMachineItem); 683 const QUuid uId = pMachineItem->id(); 684 685 /* We already decided for that machine? */ 686 if (verdicts.contains(uId)) 687 { 688 /* To remove similar machine items? */ 689 if (!verdicts.value(uId)) 690 itemsToRemove << pMachineItem; 691 continue; 692 } 693 694 /* Selected copy count: */ 695 int iSelectedCopyCount = 0; 696 foreach (UIChooserItemMachine *pSelectedItem, selectedMachineItemList) 697 { 698 AssertPtrReturnVoid(pSelectedItem); 699 if (pSelectedItem->id() == uId) 700 ++iSelectedCopyCount; 701 } 702 /* Existing copy count: */ 703 int iExistingCopyCount = 0; 704 foreach (UIChooserItemMachine *pExistingItem, existingMachineItemList) 705 { 706 AssertPtrReturnVoid(pExistingItem); 707 if (pExistingItem->id() == uId) 708 ++iExistingCopyCount; 709 } 710 /* If selected copy count equal to existing copy count, 711 * we will propose ro unregister machine fully else 712 * we will just propose to remove selected-items: */ 713 const bool fVerdict = iSelectedCopyCount == iExistingCopyCount; 714 verdicts.insert(uId, fVerdict); 715 if (fVerdict) 716 { 717 if (pMachineItem->cacheType() == UIVirtualMachineItemType_Local) 718 localMachinesToUnregister.append(pMachineItem->cache()->toLocal()->machine()); 719 else if (pMachineItem->cacheType() == UIVirtualMachineItemType_CloudReal) 720 cloudMachinesToUnregister.append(pMachineItem->cache()->toCloud()->machine()); 721 } 722 else 723 itemsToRemove << pMachineItem; 724 } 725 726 /* If we have something to remove: */ 727 if (!itemsToRemove.isEmpty()) 728 removeItems(itemsToRemove); 729 /* If we have something local to unregister: */ 730 if (!localMachinesToUnregister.isEmpty()) 731 unregisterLocalMachines(localMachinesToUnregister); 732 /* If we have something cloud to unregister: */ 733 if (!cloudMachinesToUnregister.isEmpty()) 734 unregisterCloudMachines(cloudMachinesToUnregister); 663 735 } 664 736 … … 1048 1120 } 1049 1121 1050 void UIChooserModel::sltRemoveSelectedMachine()1051 {1052 /* Check if action is enabled: */1053 if (!actionPool()->action(UIActionIndexST_M_Machine_S_Remove)->isEnabled())1054 return;1055 1056 /* Enumerate all the selected machine-items: */1057 QList<UIChooserItemMachine*> selectedMachineItemList;1058 UIChooserItemMachine::enumerateMachineItems(selectedItems(), selectedMachineItemList);1059 /* Enumerate all the existing machine-items: */1060 QList<UIChooserItemMachine*> existingMachineItemList;1061 UIChooserItemMachine::enumerateMachineItems(root()->items(), existingMachineItemList);1062 1063 /* Prepare arrays: */1064 QMap<QUuid, bool> verdicts;1065 QList<UIChooserItemMachine*> itemsToRemove;1066 QList<CMachine> localMachinesToUnregister;1067 QList<CCloudMachine> cloudMachinesToUnregister;1068 1069 /* For each selected machine-item: */1070 foreach (UIChooserItemMachine *pMachineItem, selectedMachineItemList)1071 {1072 /* Get machine-item id: */1073 AssertPtrReturnVoid(pMachineItem);1074 const QUuid uId = pMachineItem->id();1075 1076 /* We already decided for that machine? */1077 if (verdicts.contains(uId))1078 {1079 /* To remove similar machine items? */1080 if (!verdicts.value(uId))1081 itemsToRemove << pMachineItem;1082 continue;1083 }1084 1085 /* Selected copy count: */1086 int iSelectedCopyCount = 0;1087 foreach (UIChooserItemMachine *pSelectedItem, selectedMachineItemList)1088 {1089 AssertPtrReturnVoid(pSelectedItem);1090 if (pSelectedItem->id() == uId)1091 ++iSelectedCopyCount;1092 }1093 /* Existing copy count: */1094 int iExistingCopyCount = 0;1095 foreach (UIChooserItemMachine *pExistingItem, existingMachineItemList)1096 {1097 AssertPtrReturnVoid(pExistingItem);1098 if (pExistingItem->id() == uId)1099 ++iExistingCopyCount;1100 }1101 /* If selected copy count equal to existing copy count,1102 * we will propose ro unregister machine fully else1103 * we will just propose to remove selected-items: */1104 const bool fVerdict = iSelectedCopyCount == iExistingCopyCount;1105 verdicts.insert(uId, fVerdict);1106 if (fVerdict)1107 {1108 if (pMachineItem->cacheType() == UIVirtualMachineItemType_Local)1109 localMachinesToUnregister.append(pMachineItem->cache()->toLocal()->machine());1110 else if (pMachineItem->cacheType() == UIVirtualMachineItemType_CloudReal)1111 cloudMachinesToUnregister.append(pMachineItem->cache()->toCloud()->machine());1112 }1113 else1114 itemsToRemove << pMachineItem;1115 }1116 1117 /* If we have something to remove: */1118 if (!itemsToRemove.isEmpty())1119 removeItems(itemsToRemove);1120 /* If we have something local to unregister: */1121 if (!localMachinesToUnregister.isEmpty())1122 unregisterLocalMachines(localMachinesToUnregister);1123 /* If we have something cloud to unregister: */1124 if (!cloudMachinesToUnregister.isEmpty())1125 unregisterCloudMachines(cloudMachinesToUnregister);1126 }1127 1128 1122 void UIChooserModel::sltStartScrolling() 1129 1123 { … … 1303 1297 { 1304 1298 /* Setup action connections: */ 1305 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Remove), &UIAction::triggered,1306 this, &UIChooserModel::sltRemoveSelectedMachine);1307 1299 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Search), &UIAction::triggered, 1308 1300 this, &UIChooserModel::sltShowHideSearchWidget); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r84516 r84517 220 220 /** Disbands selected group item. */ 221 221 void disbandSelectedGroupItem(); 222 /** Removes selected machine items. */ 223 void removeSelectedMachineItems(); 222 224 /** Moves selected machine items to new group item. */ 223 225 void moveSelectedMachineItemsToNewGroupItem(); … … 299 301 /** @name Children stuff. 300 302 * @{ */ 301 /** Handles remove selected machine request. */302 void sltRemoveSelectedMachine();303 304 303 /** Handles D&D scrolling. */ 305 304 void sltStartScrolling();
Note:
See TracChangeset
for help on using the changeset viewer.