VirtualBox

Changeset 84545 in vbox for trunk/src


Ignore:
Timestamp:
May 26, 2020 4:17:40 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9743: VirtualBox Manager: Chooser pane: A possibility to move items to existing group with certain name using corresponding menu, based on r138272.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp

    r84518 r84545  
    653653    /** Constructs action passing @a pParent to the base-class. */
    654654    UIActionSimpleSelectorMachineMoveToGroupNew(UIActionPool *pParent)
    655         : UIActionSimple(pParent, ":/vm_group_create_16px.png", ":/vm_group_create_disabled_16px.png")
     655        : UIActionSimple(pParent)
    656656    {}
    657657
     
    667667    virtual void retranslateUi() /* override */
    668668    {
    669         setName(QApplication::translate("UIActionPool", "&New"));
     669        setName(QApplication::translate("UIActionPool", "[New]"));
    670670        setStatusTip(QApplication::translate("UIActionPool", "Add new group based on selected virtual machines"));
    671671    }
     
    33693369    pMenu->addAction(action(UIActionIndexST_M_Machine_M_MoveToGroup_S_New));
    33703370
    3371     /* Mark menu as valid (for now): */
    3372     m_invalidations.remove(UIActionIndexST_M_Machine_M_MoveToGroup);
     3371    /* This menu always remains invalid.. */
    33733372}
    33743373
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r84542 r84545  
    794794}
    795795
     796void UIVirtualBoxManager::sltPerformMachineMoveToSpecificGroup()
     797{
     798    AssertPtrReturnVoid(sender());
     799    QAction *pAction = qobject_cast<QAction*>(sender());
     800    AssertPtrReturnVoid(pAction);
     801    m_pWidget->moveMachineToGroup(pAction->text());
     802}
     803
    796804void UIVirtualBoxManager::sltPerformStartOrShowMachine()
    797805{
     
    14691477    /* Prepare menu update-handlers: */
    14701478    m_menuUpdateHandlers[UIActionIndexST_M_Group_M_Close] = &UIVirtualBoxManager::updateMenuGroupClose;
     1479    m_menuUpdateHandlers[UIActionIndexST_M_Machine_M_MoveToGroup] = &UIVirtualBoxManager::updateMenuMachineMoveToGroup;
    14711480    m_menuUpdateHandlers[UIActionIndexST_M_Machine_M_Close] = &UIVirtualBoxManager::updateMenuMachineClose;
    14721481
     
    19081917}
    19091918
     1919void UIVirtualBoxManager::updateMenuMachineMoveToGroup(QMenu *pMenu)
     1920{
     1921    /* Get current item: */
     1922    UIVirtualMachineItem *pItem = currentItem();
     1923    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
     1924
     1925    const QStringList groups = m_pWidget->possibleGroupsForMachineToMove(pItem->id());
     1926    if (!groups.isEmpty())
     1927        pMenu->addSeparator();
     1928    foreach (const QString &strGroupName, groups)
     1929        pMenu->addAction(strGroupName, this, &UIVirtualBoxManager::sltPerformMachineMoveToSpecificGroup);
     1930}
     1931
    19101932void UIVirtualBoxManager::updateMenuMachineClose(QMenu *)
    19111933{
     
    22182240        {
    22192241            return !isGroupSavingInProgress() &&
    2220                    !isAllItemsOfOneGroupSelected() &&
    22212242                   isItemsLocal(items) &&
    22222243                   isItemsPoweredOff(items);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r84537 r84545  
    225225        /** Handles call to move machine to a new group. */
    226226        void sltPerformMachineMoveToNewGroup();
     227        /** Handles call to move machine to a specific group. */
     228        void sltPerformMachineMoveToSpecificGroup();
    227229
    228230        /** Handles call to start or show machine. */
     
    345347        /** Updates 'Group' : 'Close' menu. */
    346348        void updateMenuGroupClose(QMenu *pMenu);
     349        /** Updates 'Machine' : 'Move to Group' menu. */
     350        void updateMenuMachineMoveToGroup(QMenu *pMenu);
    347351        /** Updates 'Machine' : 'Close' menu. */
    348352        void updateMenuMachineClose(QMenu *pMenu);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r84542 r84545  
    134134{
    135135    m_pPaneChooser->moveMachineToGroup(strName);
     136}
     137
     138QStringList UIVirtualBoxManagerWidget::possibleGroupsForMachineToMove(const QUuid &uId)
     139{
     140    return m_pPaneChooser->possibleGroupsForMachineToMove(uId);
    136141}
    137142
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h

    r84542 r84545  
    148148        /** Moves machine to a group with certain @a strName. */
    149149        void moveMachineToGroup(const QString &strName = QString());
     150        /** Returns possible groups for VM with passed @a uId to move to. */
     151        QStringList possibleGroupsForMachineToMove(const QUuid &uId);
    150152        /** Refreshes machine. */
    151153        void refreshMachine();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp

    r84542 r84545  
    135135    AssertPtrReturnVoid(model());
    136136    model()->moveSelectedMachineItemsToGroupItem(strName);
     137}
     138
     139QStringList UIChooser::possibleGroupsForMachineToMove(const QUuid &uId)
     140{
     141    AssertPtrReturn(model(), QStringList());
     142    return model()->possibleGroupNodeNamesForMachineNodeToMove(uId);
    137143}
    138144
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h

    r84542 r84545  
    142142        /** Moves machine to a group with certain @a strName. */
    143143        void moveMachineToGroup(const QString &strName);
     144        /** Returns possible groups for VM with passed @a uId to move to. */
     145        QStringList possibleGroupsForMachineToMove(const QUuid &uId);
    144146        /** Refreshes machine. */
    145147        void refreshMachine();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp

    r84436 r84545  
    514514{
    515515    wipeOutEmptyGroupsStartingFrom(invisibleRoot());
     516}
     517
     518QStringList UIChooserAbstractModel::possibleGroupNodeNamesForMachineNodeToMove(const QUuid &uId)
     519{
     520    /* Search for all the machine nodes with passed ID: */
     521    QList<UIChooserNode*> machineNodes;
     522    invisibleRoot()->searchForNodes(toOldStyleUuid(uId),
     523                                    UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId,
     524                                    machineNodes);
     525
     526    /* Return group nodes starting from root one: */
     527    return gatherPossibleGroupNodeNames(invisibleRoot(), machineNodes);
    516528}
    517529
     
    13001312}
    13011313
     1314QStringList UIChooserAbstractModel::gatherPossibleGroupNodeNames(UIChooserNode *pCurrentNode, QList<UIChooserNode*> exceptions) const
     1315{
     1316    /* Prepare result: */
     1317    QStringList result;
     1318
     1319    /* Walk through all the children and make sure there are no exceptions: */
     1320    bool fAddCurrent = true;
     1321    foreach (UIChooserNode *pChild, pCurrentNode->nodes(UIChooserNodeType_Any))
     1322    {
     1323        AssertPtrReturn(pChild, result);
     1324        if (exceptions.contains(pChild))
     1325            fAddCurrent = false;
     1326        else
     1327        {
     1328            if (pChild->type() == UIChooserNodeType_Group)
     1329            {
     1330                UIChooserNodeGroup *pChildGroup = pChild->toGroupNode();
     1331                AssertPtrReturn(pChildGroup, result);
     1332                if (pChildGroup->groupType() == UIChooserNodeGroupType_Local)
     1333                    result << gatherPossibleGroupNodeNames(pChild, exceptions);
     1334            }
     1335        }
     1336    }
     1337
     1338    /* Add current item if not overridden: */
     1339    if (fAddCurrent)
     1340        result.prepend(pCurrentNode->fullName());
     1341
     1342    /* Return result: */
     1343    return result;
     1344}
     1345
    13021346void UIChooserAbstractModel::saveGroupSettings()
    13031347{
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h

    r84436 r84545  
    7979        /** Wipes out empty groups. */
    8080        void wipeOutEmptyGroups();
     81
     82        /** Returns possible group node names for VM node with passed @a uId to move to. */
     83        QStringList possibleGroupNodeNamesForMachineNodeToMove(const QUuid &uId);
    8184
    8285        /** Generates unique group name traversing recursively starting from @a pRoot. */
     
    220223        /** Creates cloud machine node based on certain @a comMachine as a child of specified @a pParentNode. */
    221224        void createCloudMachineNode(UIChooserNode *pParentNode, const CCloudMachine &comMachine);
     225
     226        /** Gathers a list of possible group node names for machine nodes listed in @a exceptions, starting from @a pCurrentNode. */
     227        QStringList gatherPossibleGroupNodeNames(UIChooserNode *pCurrentNode, QList<UIChooserNode*> exceptions) const;
    222228    /** @} */
    223229
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