VirtualBox

Changeset 84517 in vbox for trunk/src


Ignore:
Timestamp:
May 25, 2020 4:23:21 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane cleanup: Move remove VMs action trigger handling to proper place in UIVirtualBoxManager class.

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  
    777777}
    778778
     779void UIVirtualBoxManager::sltPerformMachineRemove()
     780{
     781    m_pWidget->removeMachine();
     782}
     783
    779784void UIVirtualBoxManager::sltPerformMachineMoveToNewGroup()
    780785{
     
    16121617    connect(actionPool()->action(UIActionIndexST_M_Machine_S_ExportToOCI), &UIAction::triggered,
    16131618            this, &UIVirtualBoxManager::sltOpenExportApplianceWizard);
     1619    connect(actionPool()->action(UIActionIndexST_M_Machine_S_Remove), &UIAction::triggered,
     1620            this, &UIVirtualBoxManager::sltPerformMachineRemove);
    16141621    connect(actionPool()->action(UIActionIndexST_M_Machine_M_MoveToGroup_S_New), &UIAction::triggered,
    16151622            this, &UIVirtualBoxManager::sltPerformMachineMoveToNewGroup);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r84516 r84517  
    210210        /** Handles call to move machine. */
    211211        void sltPerformMachineMove();
     212
     213        /** Handles call to remove machine. */
     214        void sltPerformMachineRemove();
    212215
    213216        /** Handles call to move machine to a new group. */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r84516 r84517  
    124124{
    125125    m_pPaneChooser->disbandGroup();
     126}
     127
     128void UIVirtualBoxManagerWidget::removeMachine()
     129{
     130    m_pPaneChooser->removeMachine();
    126131}
    127132
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h

    r84516 r84517  
    142142        /** Disbands group. */
    143143        void disbandGroup();
     144        /** Removes machine. */
     145        void removeMachine();
    144146        /** Moves machine to a new group. */
    145147        void moveMachineToNewGroup();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp

    r84516 r84517  
    123123    AssertPtrReturnVoid(model());
    124124    model()->disbandSelectedGroupItem();
     125}
     126
     127void UIChooser::removeMachine()
     128{
     129    AssertPtrReturnVoid(model());
     130    model()->removeSelectedMachineItems();
    125131}
    126132
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h

    r84516 r84517  
    136136        /** Disbands group. */
    137137        void disbandGroup();
     138        /** Removes machine. */
     139        void removeMachine();
    138140        /** Moves machine to a new group. */
    139141        void moveMachineToNewGroup();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r84516 r84517  
    4848#include "UIVirtualMachineItemCloud.h"
    4949#include "UIVirtualMachineItemLocal.h"
    50 #include "UIWizardNewCloudVM.h"
    51 #include "UIWizardNewVM.h"
    5250
    5351/* COM includes: */
     
    661659    }
    662660    saveGroups();
     661}
     662
     663void 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);
    663735}
    664736
     
    10481120}
    10491121
    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 else
    1103          * 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         else
    1114             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 
    11281122void UIChooserModel::sltStartScrolling()
    11291123{
     
    13031297{
    13041298    /* Setup action connections: */
    1305     connect(actionPool()->action(UIActionIndexST_M_Machine_S_Remove), &UIAction::triggered,
    1306             this, &UIChooserModel::sltRemoveSelectedMachine);
    13071299    connect(actionPool()->action(UIActionIndexST_M_Machine_S_Search), &UIAction::triggered,
    13081300            this, &UIChooserModel::sltShowHideSearchWidget);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r84516 r84517  
    220220        /** Disbands selected group item. */
    221221        void disbandSelectedGroupItem();
     222        /** Removes selected machine items. */
     223        void removeSelectedMachineItems();
    222224        /** Moves selected machine items to new group item. */
    223225        void moveSelectedMachineItemsToNewGroupItem();
     
    299301    /** @name Children stuff.
    300302      * @{ */
    301         /** Handles remove selected machine request. */
    302         void sltRemoveSelectedMachine();
    303 
    304303        /** Handles D&D scrolling. */
    305304        void sltStartScrolling();
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