- Timestamp:
- May 26, 2020 4:17:40 PM (5 years ago)
- 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 653 653 /** Constructs action passing @a pParent to the base-class. */ 654 654 UIActionSimpleSelectorMachineMoveToGroupNew(UIActionPool *pParent) 655 : UIActionSimple(pParent , ":/vm_group_create_16px.png", ":/vm_group_create_disabled_16px.png")655 : UIActionSimple(pParent) 656 656 {} 657 657 … … 667 667 virtual void retranslateUi() /* override */ 668 668 { 669 setName(QApplication::translate("UIActionPool", " &New"));669 setName(QApplication::translate("UIActionPool", "[New]")); 670 670 setStatusTip(QApplication::translate("UIActionPool", "Add new group based on selected virtual machines")); 671 671 } … … 3369 3369 pMenu->addAction(action(UIActionIndexST_M_Machine_M_MoveToGroup_S_New)); 3370 3370 3371 /* Mark menu as valid (for now): */ 3372 m_invalidations.remove(UIActionIndexST_M_Machine_M_MoveToGroup); 3371 /* This menu always remains invalid.. */ 3373 3372 } 3374 3373 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r84542 r84545 794 794 } 795 795 796 void UIVirtualBoxManager::sltPerformMachineMoveToSpecificGroup() 797 { 798 AssertPtrReturnVoid(sender()); 799 QAction *pAction = qobject_cast<QAction*>(sender()); 800 AssertPtrReturnVoid(pAction); 801 m_pWidget->moveMachineToGroup(pAction->text()); 802 } 803 796 804 void UIVirtualBoxManager::sltPerformStartOrShowMachine() 797 805 { … … 1469 1477 /* Prepare menu update-handlers: */ 1470 1478 m_menuUpdateHandlers[UIActionIndexST_M_Group_M_Close] = &UIVirtualBoxManager::updateMenuGroupClose; 1479 m_menuUpdateHandlers[UIActionIndexST_M_Machine_M_MoveToGroup] = &UIVirtualBoxManager::updateMenuMachineMoveToGroup; 1471 1480 m_menuUpdateHandlers[UIActionIndexST_M_Machine_M_Close] = &UIVirtualBoxManager::updateMenuMachineClose; 1472 1481 … … 1908 1917 } 1909 1918 1919 void 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 1910 1932 void UIVirtualBoxManager::updateMenuMachineClose(QMenu *) 1911 1933 { … … 2218 2240 { 2219 2241 return !isGroupSavingInProgress() && 2220 !isAllItemsOfOneGroupSelected() &&2221 2242 isItemsLocal(items) && 2222 2243 isItemsPoweredOff(items); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r84537 r84545 225 225 /** Handles call to move machine to a new group. */ 226 226 void sltPerformMachineMoveToNewGroup(); 227 /** Handles call to move machine to a specific group. */ 228 void sltPerformMachineMoveToSpecificGroup(); 227 229 228 230 /** Handles call to start or show machine. */ … … 345 347 /** Updates 'Group' : 'Close' menu. */ 346 348 void updateMenuGroupClose(QMenu *pMenu); 349 /** Updates 'Machine' : 'Move to Group' menu. */ 350 void updateMenuMachineMoveToGroup(QMenu *pMenu); 347 351 /** Updates 'Machine' : 'Close' menu. */ 348 352 void updateMenuMachineClose(QMenu *pMenu); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r84542 r84545 134 134 { 135 135 m_pPaneChooser->moveMachineToGroup(strName); 136 } 137 138 QStringList UIVirtualBoxManagerWidget::possibleGroupsForMachineToMove(const QUuid &uId) 139 { 140 return m_pPaneChooser->possibleGroupsForMachineToMove(uId); 136 141 } 137 142 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h
r84542 r84545 148 148 /** Moves machine to a group with certain @a strName. */ 149 149 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); 150 152 /** Refreshes machine. */ 151 153 void refreshMachine(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp
r84542 r84545 135 135 AssertPtrReturnVoid(model()); 136 136 model()->moveSelectedMachineItemsToGroupItem(strName); 137 } 138 139 QStringList UIChooser::possibleGroupsForMachineToMove(const QUuid &uId) 140 { 141 AssertPtrReturn(model(), QStringList()); 142 return model()->possibleGroupNodeNamesForMachineNodeToMove(uId); 137 143 } 138 144 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h
r84542 r84545 142 142 /** Moves machine to a group with certain @a strName. */ 143 143 void moveMachineToGroup(const QString &strName); 144 /** Returns possible groups for VM with passed @a uId to move to. */ 145 QStringList possibleGroupsForMachineToMove(const QUuid &uId); 144 146 /** Refreshes machine. */ 145 147 void refreshMachine(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r84436 r84545 514 514 { 515 515 wipeOutEmptyGroupsStartingFrom(invisibleRoot()); 516 } 517 518 QStringList 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); 516 528 } 517 529 … … 1300 1312 } 1301 1313 1314 QStringList 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 1302 1346 void UIChooserAbstractModel::saveGroupSettings() 1303 1347 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r84436 r84545 79 79 /** Wipes out empty groups. */ 80 80 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); 81 84 82 85 /** Generates unique group name traversing recursively starting from @a pRoot. */ … … 220 223 /** Creates cloud machine node based on certain @a comMachine as a child of specified @a pParentNode. */ 221 224 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; 222 228 /** @} */ 223 229
Note:
See TracChangeset
for help on using the changeset viewer.