儲存庫 vbox 的更動 43593
- 時間撮記:
- 2012-10-10 下午01:36:39 (12 年 以前)
- 位置:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
- 檔案:
-
- 修改 2 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r43592 r43593 693 693 } 694 694 695 void UIGChooserModel::sltEditGroupName() 696 { 697 /* Check if action is enabled: */ 698 if (!gActionPool->action(UIActionIndexSelector_Simple_Group_Rename)->isEnabled()) 699 return; 700 701 /* Only for single selected group: */ 702 if (!isSingleGroupSelected()) 703 return; 704 705 /* Start editing group name: */ 706 currentItem()->startEditing(); 707 } 708 709 void UIGChooserModel::sltSortGroup() 710 { 711 /* Check if action is enabled: */ 712 if (!gActionPool->action(UIActionIndexSelector_Simple_Group_Sort)->isEnabled()) 713 return; 714 715 /* Only for single selected group: */ 716 if (!isSingleGroupSelected()) 717 return; 718 719 /* Sorting group: */ 720 sortItems(currentItem()); 721 } 722 723 void UIGChooserModel::sltUngroupSelectedGroup() 724 { 725 /* Check if action is enabled: */ 726 if (!gActionPool->action(UIActionIndexSelector_Simple_Group_Remove)->isEnabled()) 727 return; 728 729 /* Make sure focus item is of group type! */ 730 AssertMsg(focusItem()->type() == UIGChooserItemType_Group, ("This is not group-item!")); 731 732 /* Check if we have collisions with our siblings: */ 733 UIGChooserItem *pFocusItem = focusItem(); 734 UIGChooserItem *pParentItem = pFocusItem->parentItem(); 735 QList<UIGChooserItem*> siblings = pParentItem->items(); 736 QList<UIGChooserItem*> toBeRenamed; 737 QList<UIGChooserItem*> toBeRemoved; 738 foreach (UIGChooserItem *pItem, pFocusItem->items()) 739 { 740 QString strItemName = pItem->name(); 741 UIGChooserItem *pCollisionSibling = 0; 742 foreach (UIGChooserItem *pSibling, siblings) 743 if (pSibling != pFocusItem && pSibling->name() == strItemName) 744 pCollisionSibling = pSibling; 745 if (pCollisionSibling) 746 { 747 if (pItem->type() == UIGChooserItemType_Machine) 748 { 749 if (pCollisionSibling->type() == UIGChooserItemType_Machine) 750 toBeRemoved << pItem; 751 else if (pCollisionSibling->type() == UIGChooserItemType_Group) 752 { 753 msgCenter().notifyAboutCollisionOnGroupRemovingCantBeResolved(strItemName, pParentItem->name()); 754 return; 755 } 756 } 757 else if (pItem->type() == UIGChooserItemType_Group) 758 { 759 if (msgCenter().askAboutCollisionOnGroupRemoving(strItemName, pParentItem->name()) == QIMessageBox::Ok) 760 toBeRenamed << pItem; 761 else 762 return; 763 } 764 } 765 } 766 767 /* Copy all the children into our parent: */ 768 foreach (UIGChooserItem *pItem, pFocusItem->items()) 769 { 770 if (toBeRemoved.contains(pItem)) 771 continue; 772 switch (pItem->type()) 773 { 774 case UIGChooserItemType_Group: 775 { 776 UIGChooserItemGroup *pGroupItem = new UIGChooserItemGroup(pParentItem, pItem->toGroupItem()); 777 if (toBeRenamed.contains(pItem)) 778 pGroupItem->setName(uniqueGroupName(pParentItem)); 779 break; 780 } 781 case UIGChooserItemType_Machine: 782 { 783 new UIGChooserItemMachine(pParentItem, pItem->toMachineItem()); 784 break; 785 } 786 } 787 } 788 789 /* Delete focus group: */ 790 delete focusItem(); 791 792 /* And update model: */ 793 updateNavigation(); 794 updateLayout(); 795 setCurrentItem(navigationList().first()); 796 saveGroupSettings(); 797 } 798 799 void UIGChooserModel::sltCreateNewMachine() 800 { 801 /* Check if action is enabled: */ 802 if (!gActionPool->action(UIActionIndexSelector_Simple_Machine_New)->isEnabled()) 803 return; 804 805 /* Choose the parent: */ 806 UIGChooserItem *pGroup = 0; 807 if (isSingleGroupSelected()) 808 pGroup = currentItem(); 809 else if (!currentItems().isEmpty()) 810 pGroup = currentItem()->parentItem(); 811 QString strGroupName; 812 if (pGroup) 813 strGroupName = fullName(pGroup); 814 815 /* Start the new vm wizard: */ 816 UISafePointerWizard pWizard = new UIWizardNewVM(&vboxGlobal().selectorWnd(), strGroupName); 817 pWizard->prepare(); 818 pWizard->exec(); 819 if (pWizard) 820 delete pWizard; 821 } 822 695 823 void UIGChooserModel::sltGroupSelectedMachines() 696 824 { 825 /* Check if action is enabled: */ 826 if (!gActionPool->action(UIActionIndexSelector_Simple_Machine_AddGroup)->isEnabled()) 827 return; 828 697 829 /* Create new group in the current root: */ 698 830 UIGChooserItemGroup *pNewGroupItem = new UIGChooserItemGroup(root(), uniqueGroupName(root()), true); … … 740 872 } 741 873 742 void UIGChooserModel::sltEditGroupName()743 {744 /* Check if action is enabled: */745 if (!gActionPool->action(UIActionIndexSelector_Simple_Group_Rename)->isEnabled())746 return;747 748 /* Only for single selected group: */749 if (!isSingleGroupSelected())750 return;751 752 /* Start editing group name: */753 currentItem()->startEditing();754 }755 756 void UIGChooserModel::sltSortGroup()757 {758 /* Only for single selected group: */759 if (!isSingleGroupSelected())760 return;761 762 /* Sorting group: */763 sortItems(currentItem());764 }765 766 void UIGChooserModel::sltUngroupSelectedGroup()767 {768 /* Make sure focus item is of group type! */769 AssertMsg(focusItem()->type() == UIGChooserItemType_Group, ("This is not group-item!"));770 771 /* Check if we have collisions with our siblings: */772 UIGChooserItem *pFocusItem = focusItem();773 UIGChooserItem *pParentItem = pFocusItem->parentItem();774 QList<UIGChooserItem*> siblings = pParentItem->items();775 QList<UIGChooserItem*> toBeRenamed;776 QList<UIGChooserItem*> toBeRemoved;777 foreach (UIGChooserItem *pItem, pFocusItem->items())778 {779 QString strItemName = pItem->name();780 UIGChooserItem *pCollisionSibling = 0;781 foreach (UIGChooserItem *pSibling, siblings)782 if (pSibling != pFocusItem && pSibling->name() == strItemName)783 pCollisionSibling = pSibling;784 if (pCollisionSibling)785 {786 if (pItem->type() == UIGChooserItemType_Machine)787 {788 if (pCollisionSibling->type() == UIGChooserItemType_Machine)789 toBeRemoved << pItem;790 else if (pCollisionSibling->type() == UIGChooserItemType_Group)791 {792 msgCenter().notifyAboutCollisionOnGroupRemovingCantBeResolved(strItemName, pParentItem->name());793 return;794 }795 }796 else if (pItem->type() == UIGChooserItemType_Group)797 {798 if (msgCenter().askAboutCollisionOnGroupRemoving(strItemName, pParentItem->name()) == QIMessageBox::Ok)799 toBeRenamed << pItem;800 else801 return;802 }803 }804 }805 806 /* Copy all the children into our parent: */807 foreach (UIGChooserItem *pItem, pFocusItem->items())808 {809 if (toBeRemoved.contains(pItem))810 continue;811 switch (pItem->type())812 {813 case UIGChooserItemType_Group:814 {815 UIGChooserItemGroup *pGroupItem = new UIGChooserItemGroup(pParentItem, pItem->toGroupItem());816 if (toBeRenamed.contains(pItem))817 pGroupItem->setName(uniqueGroupName(pParentItem));818 break;819 }820 case UIGChooserItemType_Machine:821 {822 new UIGChooserItemMachine(pParentItem, pItem->toMachineItem());823 break;824 }825 }826 }827 828 /* Delete focus group: */829 delete focusItem();830 831 /* And update model: */832 updateNavigation();833 updateLayout();834 setCurrentItem(navigationList().first());835 saveGroupSettings();836 }837 838 void UIGChooserModel::sltCreateNewMachine()839 {840 UIGChooserItem *pGroup = 0;841 if (isSingleGroupSelected())842 pGroup = currentItem();843 else if (!currentItems().isEmpty())844 pGroup = currentItem()->parentItem();845 QString strGroupName;846 if (pGroup)847 strGroupName = fullName(pGroup);848 UISafePointerWizard pWizard = new UIWizardNewVM(&vboxGlobal().selectorWnd(), strGroupName);849 pWizard->prepare();850 pWizard->exec();851 if (pWizard)852 delete pWizard;853 }854 855 874 void UIGChooserModel::sltReloadMachine(const QString &strId) 856 875 { … … 877 896 void UIGChooserModel::sltSortParentGroup() 878 897 { 898 /* Check if action is enabled: */ 899 if (!gActionPool->action(UIActionIndexSelector_Simple_Machine_SortParent)->isEnabled()) 900 return; 901 879 902 /* Only if some item selected: */ 880 903 if (!currentItem()) … … 887 910 void UIGChooserModel::sltPerformRefreshAction() 888 911 { 912 /* Check if action is enabled: */ 913 if (!gActionPool->action(UIActionIndexSelector_Simple_Common_Refresh)->isEnabled()) 914 return; 915 889 916 /* Gather list of chosen inaccessible VMs: */ 890 917 QList<UIGChooserItem*> inaccessibleItems; … … 920 947 void UIGChooserModel::sltRemoveSelectedMachine() 921 948 { 949 /* Check if action is enabled: */ 950 if (!gActionPool->action(UIActionIndexSelector_Simple_Machine_Remove)->isEnabled()) 951 return; 952 922 953 /* Enumerate all the selected machine-items: */ 923 954 QList<UIGChooserItem*> selectedMachineItemList = gatherMachineItems(currentItems()); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r43592 r43593 175 175 176 176 /* Handlers: Group-item stuff: */ 177 void sltGroupSelectedMachines();178 177 void sltEditGroupName(); 179 178 void sltSortGroup(); … … 182 181 /* Handlers: Machine-item stuff: */ 183 182 void sltCreateNewMachine(); 183 void sltGroupSelectedMachines(); 184 184 void sltReloadMachine(const QString &strId); 185 185 void sltSortParentGroup();
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器