- Timestamp:
- May 22, 2020 1:31:42 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/UIMessageCenter.cpp
r84217 r84461 630 630 { 631 631 alert(0, MessageType_Error, 632 tr("<p>You are trying to move machine <nobr><b>%1</b></nobr> "633 " to group <nobr><b>%2</b></nobr> which already have sub-group <nobr><b>%1</b></nobr>.</p>"634 "<p>Please resolve this name -conflict and try again.</p>")632 tr("<p>You are trying to move machine <nobr><b>%1</b></nobr> to group " 633 "<nobr><b>%2</b></nobr> which already have another item with the same name.</p>" 634 "<p>Please resolve this name conflict and try again.</p>") 635 635 .arg(strCollisionName, strGroupName)); 636 636 } … … 639 639 { 640 640 return questionBinary(0, MessageType_Question, 641 tr("<p>You are trying to move group <nobr><b>%1</b></nobr> "642 " to group<nobr><b>%2</b></nobr> which already have another item with the same name.</p>"641 tr("<p>You are trying to move group <nobr><b>%1</b></nobr> to group " 642 "<nobr><b>%2</b></nobr> which already have another item with the same name.</p>" 643 643 "<p>Would you like to automatically rename it?</p>") 644 644 .arg(strName, strGroupName), -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r84456 r84461 605 605 } 606 606 607 void UIVirtualBoxManager::sltDisbandGroup() 608 { 609 m_pWidget->disbandGroup(); 610 } 611 607 612 void UIVirtualBoxManager::sltOpenMachineSettingsDialog(QString strCategory /* = QString() */, 608 613 QString strControl /* = QString() */, … … 1515 1520 connect(actionPool()->action(UIActionIndexST_M_Group_S_Rename), &UIAction::triggered, 1516 1521 this, &UIVirtualBoxManager::sltOpenGroupNameEditor); 1522 connect(actionPool()->action(UIActionIndexST_M_Group_S_Remove), &UIAction::triggered, 1523 this, &UIVirtualBoxManager::sltDisbandGroup); 1517 1524 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow), &UIAction::triggered, 1518 1525 this, &UIVirtualBoxManager::sltPerformStartOrShowMachine); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r84456 r84461 190 190 /** Handles call to open group name editor. */ 191 191 void sltOpenGroupNameEditor(); 192 /** Handles call to disband group. */ 193 void sltDisbandGroup(); 192 194 193 195 /** Handles call to open Machine Settings dialog. -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r84456 r84461 114 114 { 115 115 m_pPaneChooser->openGroupNameEditor(); 116 } 117 118 void UIVirtualBoxManagerWidget::disbandGroup() 119 { 120 m_pPaneChooser->disbandGroup(); 116 121 } 117 122 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h
r84456 r84461 137 137 /** Opens group name editor. */ 138 138 void openGroupNameEditor(); 139 /** Disbands group. */ 140 void disbandGroup(); 139 141 /** Performs group sorting. */ 140 142 void performGroupSorting(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp
r84456 r84461 111 111 AssertPtrReturnVoid(model()); 112 112 model()->startEditingSelectedGroupItemName(); 113 } 114 115 void UIChooser::disbandGroup() 116 { 117 AssertPtrReturnVoid(model()); 118 model()->disbandSelectedGroupItem(); 113 119 } 114 120 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h
r84456 r84461 131 131 /** Opens group name editor. */ 132 132 void openGroupNameEditor(); 133 /** Disbands group. */ 134 void disbandGroup(); 133 135 /** Performs group sorting. */ 134 136 void performGroupSorting(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r84456 r84461 565 565 } 566 566 567 void UIChooserModel::disbandSelectedGroupItem() 568 { 569 /* Only for single selected group: */ 570 if (!isSingleGroupSelected()) 571 return; 572 573 /* Check if we have collisions with our potential siblings: */ 574 UIChooserItem *pCurrentItem = currentItem(); 575 UIChooserNode *pCurrentNode = pCurrentItem->node(); 576 UIChooserItem *pParentItem = pCurrentItem->parentItem(); 577 UIChooserNode *pParentNode = pParentItem->node(); 578 QList<UIChooserNode*> childrenToBeRenamed; 579 foreach (UIChooserNode *pChildNode, pCurrentNode->nodes()) 580 { 581 const QString strChildName = pChildNode->name(); 582 UIChooserNode *pCollisionSibling = 0; 583 foreach (UIChooserNode *pSiblingNode, pParentNode->nodes()) 584 if (pSiblingNode != pCurrentNode && pSiblingNode->name() == strChildName) 585 { 586 pCollisionSibling = pSiblingNode; 587 break; 588 } 589 if (pCollisionSibling) 590 { 591 switch (pChildNode->type()) 592 { 593 case UIChooserNodeType_Machine: 594 { 595 msgCenter().cannotResolveCollisionAutomatically(strChildName, pParentNode->name()); 596 return; 597 } 598 case UIChooserNodeType_Group: 599 { 600 if (!msgCenter().confirmAutomaticCollisionResolve(strChildName, pParentNode->name())) 601 return; 602 childrenToBeRenamed << pChildNode; 603 break; 604 } 605 default: 606 break; 607 } 608 } 609 } 610 611 /* Copy all the children into our parent: */ 612 QList<UIChooserItem*> ungroupedItems; 613 foreach (UIChooserNode *pNode, pCurrentNode->nodes()) 614 { 615 switch (pNode->type()) 616 { 617 case UIChooserNodeType_Group: 618 { 619 UIChooserNodeGroup *pGroupNode = new UIChooserNodeGroup(pParentNode, 620 pNode->toGroupNode(), 621 pParentNode->nodes().size()); 622 UIChooserItemGroup *pGroupItem = new UIChooserItemGroup(pParentItem, pGroupNode); 623 if (childrenToBeRenamed.contains(pNode)) 624 pGroupNode->setName(uniqueGroupName(pParentNode)); 625 ungroupedItems << pGroupItem; 626 break; 627 } 628 case UIChooserNodeType_Machine: 629 { 630 UIChooserNodeMachine *pMachineNode = new UIChooserNodeMachine(pParentNode, 631 pNode->toMachineNode(), 632 pParentNode->nodes().size()); 633 UIChooserItemMachine *pMachineItem = new UIChooserItemMachine(pParentItem, pMachineNode); 634 ungroupedItems << pMachineItem; 635 break; 636 } 637 default: 638 break; 639 } 640 } 641 642 /* Delete current group: */ 643 delete pCurrentNode; 644 645 /* And update model: */ 646 updateTreeForMainRoot(); 647 if (!ungroupedItems.isEmpty()) 648 { 649 setSelectedItems(ungroupedItems); 650 setCurrentItem(firstSelectedItem()); 651 } 652 else 653 { 654 setSelectedItem(navigationItems().first()); 655 emit sigSelectionInvalidated(); 656 } 657 saveGroups(); 658 } 659 567 660 void UIChooserModel::startOrShowSelectedItems() 568 661 { … … 819 912 } 820 913 821 void UIChooserModel::sltUngroupSelectedGroup()822 {823 /* Check if action is enabled: */824 if (!actionPool()->action(UIActionIndexST_M_Group_S_Remove)->isEnabled())825 return;826 827 /* Make sure current-item is of group type! */828 AssertMsg(currentItem()->type() == UIChooserNodeType_Group, ("This is not group-item!"));829 830 /* Check if we have collisions with our siblings: */831 UIChooserItem *pCurrentItem = currentItem();832 UIChooserNode *pCurrentNode = pCurrentItem->node();833 UIChooserItem *pParentItem = pCurrentItem->parentItem();834 UIChooserNode *pParentNode = pParentItem->node();835 QList<UIChooserNode*> siblings = pParentNode->nodes();836 QList<UIChooserNode*> toBeRenamed;837 QList<UIChooserNode*> toBeRemoved;838 foreach (UIChooserNode *pNode, pCurrentNode->nodes())839 {840 QString strItemName = pNode->name();841 UIChooserNode *pCollisionSibling = 0;842 foreach (UIChooserNode *pSibling, siblings)843 if (pSibling != pCurrentNode && pSibling->name() == strItemName)844 pCollisionSibling = pSibling;845 if (pCollisionSibling)846 {847 if (pNode->type() == UIChooserNodeType_Machine)848 {849 if (pCollisionSibling->type() == UIChooserNodeType_Machine)850 toBeRemoved << pNode;851 else if (pCollisionSibling->type() == UIChooserNodeType_Group)852 {853 msgCenter().cannotResolveCollisionAutomatically(strItemName, pParentNode->name());854 return;855 }856 }857 else if (pNode->type() == UIChooserNodeType_Group)858 {859 if (msgCenter().confirmAutomaticCollisionResolve(strItemName, pParentNode->name()))860 toBeRenamed << pNode;861 else862 return;863 }864 }865 }866 867 /* Copy all the children into our parent: */868 QList<UIChooserItem*> copiedItems;869 foreach (UIChooserNode *pNode, pCurrentNode->nodes())870 {871 if (toBeRemoved.contains(pNode))872 continue;873 switch (pNode->type())874 {875 case UIChooserNodeType_Group:876 {877 UIChooserNodeGroup *pGroupNode = new UIChooserNodeGroup(pParentNode,878 pNode->toGroupNode(),879 pParentNode->nodes().size());880 UIChooserItemGroup *pGroupItem = new UIChooserItemGroup(pParentItem, pGroupNode);881 if (toBeRenamed.contains(pNode))882 pGroupNode->setName(uniqueGroupName(pParentNode));883 copiedItems << pGroupItem;884 break;885 }886 case UIChooserNodeType_Machine:887 {888 UIChooserNodeMachine *pMachineNode = new UIChooserNodeMachine(pParentNode,889 pNode->toMachineNode(),890 pParentNode->nodes().size());891 UIChooserItemMachine *pMachineItem = new UIChooserItemMachine(pParentItem, pMachineNode);892 copiedItems << pMachineItem;893 break;894 }895 default:896 break;897 }898 }899 900 /* Delete current group: */901 delete pCurrentNode;902 903 /* And update model: */904 updateTreeForMainRoot();905 if (!copiedItems.isEmpty())906 {907 setSelectedItems(copiedItems);908 setCurrentItem(firstSelectedItem());909 }910 else911 {912 setSelectedItem(navigationItems().first());913 emit sigSelectionInvalidated();914 }915 saveGroups();916 }917 918 914 void UIChooserModel::sltCreateNewMachine() 919 915 { … … 1372 1368 connect(actionPool()->action(UIActionIndexST_M_Machine_S_New), &UIAction::triggered, 1373 1369 this, &UIChooserModel::sltCreateNewMachine); 1374 connect(actionPool()->action(UIActionIndexST_M_Group_S_Remove), &UIAction::triggered,1375 this, &UIChooserModel::sltUngroupSelectedGroup);1376 1370 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Remove), &UIAction::triggered, 1377 1371 this, &UIChooserModel::sltRemoveSelectedMachine); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r84456 r84461 215 215 /** Starts editing selected group item name. */ 216 216 void startEditingSelectedGroupItemName(); 217 /** Disbands selected group item. */ 218 void disbandSelectedGroupItem(); 217 219 /** Starts or shows selected items. */ 218 220 void startOrShowSelectedItems(); … … 290 292 /** @name Children stuff. 291 293 * @{ */ 292 /** Handles group destroy request. */293 void sltUngroupSelectedGroup();294 295 294 /** Handles create new machine request. */ 296 295 void sltCreateNewMachine();
Note:
See TracChangeset
for help on using the changeset viewer.