Changeset 42563 in vbox
- Timestamp:
- Aug 3, 2012 1:42:21 AM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 13 edited
-
UIActionPoolSelector.cpp (modified) (5 diffs)
-
UIActionPoolSelector.h (modified) (1 diff)
-
UISelectorShortcuts.cpp (modified) (1 diff)
-
UISelectorShortcuts.h (modified) (1 diff)
-
UISelectorWindow.cpp (modified) (7 diffs)
-
UISelectorWindow.h (modified) (2 diffs)
-
graphics/chooser/UIGChooserItem.h (modified) (1 diff)
-
graphics/chooser/UIGChooserItemGroup.cpp (modified) (2 diffs)
-
graphics/chooser/UIGChooserItemGroup.h (modified) (1 diff)
-
graphics/chooser/UIGChooserItemMachine.cpp (modified) (1 diff)
-
graphics/chooser/UIGChooserItemMachine.h (modified) (1 diff)
-
graphics/chooser/UIGChooserModel.cpp (modified) (5 diffs)
-
graphics/chooser/UIGChooserModel.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.cpp
r42542 r42563 432 432 { 433 433 #if defined(Q_WS_MAC) 434 setText(QApplication::translate("UIActionPool", "Create Alias on Desktop"));435 setStatusTip(QApplication::translate("UIActionPool", "Creates an Alias file to the VirtualBox Machine Definition file on your Desktop."));434 setText(QApplication::translate("UIActionPool", "Create alias on desktop")); 435 setStatusTip(QApplication::translate("UIActionPool", "Creates an alias file to the VirtualBox Machine Definition file on your desktop.")); 436 436 #else 437 setText(QApplication::translate("UIActionPool", "Create Shortcut on Desktop"));438 setStatusTip(QApplication::translate("UIActionPool", "Creates an Shortcut file to the VirtualBox Machine Definition file on your Desktop."));437 setText(QApplication::translate("UIActionPool", "Create shortcut on desktop")); 438 setStatusTip(QApplication::translate("UIActionPool", "Creates an shortcut file to the VirtualBox Machine Definition file on your desktop.")); 439 439 #endif 440 440 setShortcut(gSS->keySequence(UISelectorShortcuts::CreateVMAliasShortcut)); … … 458 458 void retranslateUi() 459 459 { 460 setText(QApplication::translate("UIActionPool", "Sort List"));461 setStatusTip(QApplication::translate("UIActionPool", "Sort the VM list alphabetically (Shift for descending order)"));462 setShortcut(gSS->keySequence(UISelectorShortcuts:: ResortVMList));460 setText(QApplication::translate("UIActionPool", "Sort group")); 461 setStatusTip(QApplication::translate("UIActionPool", "Sort the items of the selected group alphabetically")); 462 setShortcut(gSS->keySequence(UISelectorShortcuts::SortGroup)); 463 463 } 464 464 }; … … 823 823 }; 824 824 825 class UIActionSimple MachineSort : public UIActionSimple826 { 827 Q_OBJECT; 828 829 public: 830 831 UIActionSimple MachineSort(QObject *pParent)825 class UIActionSimpleCommonSortParent : public UIActionSimple 826 { 827 Q_OBJECT; 828 829 public: 830 831 UIActionSimpleCommonSortParent(QObject *pParent) 832 832 : UIActionSimple(pParent/*, ":/settings_16px.png", ":/settings_dis_16px.png"*/) 833 833 { … … 839 839 void retranslateUi() 840 840 { 841 setText(QApplication::translate("UIActionPool", "Sort List"));842 setStatusTip(QApplication::translate("UIActionPool", "Sort the VM list alphabetically (Shift for descending order)"));843 setShortcut(gSS->keySequence(UISelectorShortcuts:: ResortVMList));841 setText(QApplication::translate("UIActionPool", "Sort parent group")); 842 setStatusTip(QApplication::translate("UIActionPool", "Sort the parent group of the first selected item alphabetically")); 843 setShortcut(gSS->keySequence(UISelectorShortcuts::SortParentGroup)); 844 844 } 845 845 }; … … 977 977 m_pool[UIActionIndexSelector_Simple_Machine_ShowInFileManager] = new UIActionSimpleMachineShowInFileManager(this); 978 978 m_pool[UIActionIndexSelector_Simple_Machine_CreateShortcut] = new UIActionSimpleMachineCreateShortcut(this); 979 m_pool[UIActionIndexSelector_Simple_Machine_Sort] = new UIActionSimpleMachineSort(this); 979 980 /* Common actions: */ 981 m_pool[UIActionIndexSelector_Simple_Common_SortParent] = new UIActionSimpleCommonSortParent(this); 980 982 981 983 /* 'Machine/Close' actions: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.h
r42542 r42563 63 63 UIActionIndexSelector_Simple_Machine_ShowInFileManager, 64 64 UIActionIndexSelector_Simple_Machine_CreateShortcut, 65 UIActionIndexSelector_Simple_Machine_Sort, 65 66 /* Common menu action: */ 67 UIActionIndexSelector_Simple_Common_SortParent, 66 68 67 69 /* 'Machine/Close' menu actions: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorShortcuts.cpp
r42542 r42563 49 49 m_Shortcuts[ShowVMInFileManagerShortcut] = UIKeySequence("ShowVMInFileManager"); 50 50 m_Shortcuts[CreateVMAliasShortcut] = UIKeySequence("CreateVMAlias"); 51 m_Shortcuts[ResortVMList] = UIKeySequence("ResortVMList"); 51 m_Shortcuts[SortParentGroup] = UIKeySequence("SortParentGroup"); 52 m_Shortcuts[SortGroup] = UIKeySequence("SortGroup"); 52 53 m_Shortcuts[HelpShortcut] = UIKeySequence("Help", QKeySequence::HelpContents); 53 54 m_Shortcuts[WebShortcut] = UIKeySequence("Web"); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorShortcuts.h
r42542 r42563 51 51 ShowVMInFileManagerShortcut, 52 52 CreateVMAliasShortcut, 53 ResortVMList, 53 SortParentGroup, 54 SortGroup, 54 55 HelpShortcut, 55 56 WebShortcut, -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r42560 r42563 1116 1116 pMenu->addAction(m_pActionGroupCreateShortcut); 1117 1117 pMenu->addSeparator(); 1118 // m_pActionGroupSort = gActionPool->action(UIActionIndexSelector_Simple_Group_Sort); 1119 // pMenu->addAction(m_pActionGroupSort); 1118 m_pActionGroupSortParent = gActionPool->action(UIActionIndexSelector_Simple_Common_SortParent); 1119 pMenu->addAction(m_pActionGroupSortParent); 1120 m_pActionGroupSort = gActionPool->action(UIActionIndexSelector_Simple_Group_Sort); 1121 pMenu->addAction(m_pActionGroupSort); 1120 1122 1121 1123 /* Remember action list: */ … … 1125 1127 << m_pActionGroupReset << m_pActionGroupRefresh 1126 1128 << m_pActionGroupLogDialog << m_pActionGroupShowInFileManager 1127 << m_pActionGroupCreateShortcut /* << m_pActionGroupSort */;1129 << m_pActionGroupCreateShortcut << m_pActionGroupSort; 1128 1130 } 1129 1131 … … 1168 1170 pMenu->addAction(m_pActionMachineCreateShortcut); 1169 1171 pMenu->addSeparator(); 1170 // m_pActionMachineSort = gActionPool->action(UIActionIndexSelector_Simple_Machine_Sort);1171 // pMenu->addAction(m_pActionMachineSort);1172 m_pActionMachineSortParent = gActionPool->action(UIActionIndexSelector_Simple_Common_SortParent); 1173 pMenu->addAction(m_pActionMachineSortParent); 1172 1174 1173 1175 /* Remember action list: */ … … 1179 1181 << m_pActionMachineReset << m_pActionMachineRefresh 1180 1182 << m_pActionMachineLogDialog << m_pActionMachineShowInFileManager 1181 << m_pActionMachineCreateShortcut /* << m_pActionMachineSort */;1183 << m_pActionMachineCreateShortcut; 1182 1184 } 1183 1185 … … 1522 1524 m_pActionGroupShowInFileManager->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_ShowInFileManager, items)); 1523 1525 m_pActionGroupCreateShortcut->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_CreateShortcut, items)); 1524 // m_pActionGroupSort->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_Sort, items)); 1526 m_pActionGroupSortParent->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Common_SortParent, items)); 1527 m_pActionGroupSort->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Group_Sort, items)); 1525 1528 1526 1529 /* Enable/disable machine actions: */ … … 1537 1540 m_pActionMachineShowInFileManager->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_ShowInFileManager, items)); 1538 1541 m_pActionMachineCreateShortcut->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CreateShortcut, items)); 1539 // m_pActionMachineSort->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Sort, items));1542 m_pActionMachineSortParent->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Common_SortParent, items)); 1540 1543 1541 1544 /* Enable/disable machine-close actions: */ … … 1758 1761 case UIActionIndexSelector_Simple_Group_ShowInFileManager: 1759 1762 case UIActionIndexSelector_Simple_Machine_ShowInFileManager: 1760 // case UIActionIndexSelector_Simple_Group_Sort:1761 // case UIActionIndexSelector_Simple_Machine_Sort:1762 //{1763 ///* Make sure all items are accessible: */1764 // returnisItemsAccessible(items);1765 //}1763 case UIActionIndexSelector_Simple_Common_SortParent: 1764 case UIActionIndexSelector_Simple_Group_Sort: 1765 { 1766 /* Make sure all items are accessible: */ 1767 return items.size() > 0 && isItemsAccessible(items); 1768 } 1766 1769 case UIActionIndexSelector_Simple_Group_CreateShortcut: 1767 1770 case UIActionIndexSelector_Simple_Machine_CreateShortcut: -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h
r42560 r42563 190 190 UIAction *m_pActionGroupShowInFileManager; 191 191 UIAction *m_pActionGroupCreateShortcut; 192 // UIAction *m_pActionGroupSort; 192 UIAction *m_pActionGroupSortParent; 193 UIAction *m_pActionGroupSort; 193 194 194 195 /* 'Machine' menu action pointers: */ … … 210 211 UIAction *m_pActionMachineShowInFileManager; 211 212 UIAction *m_pActionMachineCreateShortcut; 212 // UIAction *m_pActionMachineSort;213 UIAction *m_pActionMachineSortParent; 213 214 214 215 /* 'Machine / Close' menu action pointers: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.h
r42558 r42563 86 86 virtual void addItem(UIGChooserItem *pItem, int iPosition) = 0; 87 87 virtual void removeItem(UIGChooserItem *pItem) = 0; 88 virtual void setItems(const QList<UIGChooserItem*> &items, UIGChooserItemType type) = 0; 88 89 virtual QList<UIGChooserItem*> items(UIGChooserItemType type = UIGChooserItemType_Any) const = 0; 89 90 virtual bool hasItems(UIGChooserItemType type = UIGChooserItemType_Any) const = 0; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp
r42558 r42563 475 475 } 476 476 477 void UIGChooserItemGroup::setItems(const QList<UIGChooserItem*> &items, UIGChooserItemType type) 478 { 479 /* Check item type: */ 480 switch (type) 481 { 482 case UIGChooserItemType_Group: m_groupItems = items; break; 483 case UIGChooserItemType_Machine: m_machineItems = items; break; 484 default: AssertMsgFailed(("Invalid item type!")); break; 485 } 486 } 487 477 488 QList<UIGChooserItem*> UIGChooserItemGroup::items(UIGChooserItemType type /* = UIGChooserItemType_Any */) const 478 489 { … … 513 524 case UIGChooserItemType_Group: 514 525 { 515 while (!m_groupItems.isEmpty()) { delete m_groupItems.last(); } 526 while (!m_groupItems.isEmpty()) { delete m_groupItems.takeLast(); } 527 AssertMsg(m_groupItems.isEmpty(), ("Group items cleanup failed!")); 516 528 break; 517 529 } 518 530 case UIGChooserItemType_Machine: 519 531 { 520 while (!m_machineItems.isEmpty()) { delete m_machineItems.last(); } 532 while (!m_machineItems.isEmpty()) { delete m_machineItems.takeLast(); } 533 AssertMsg(m_machineItems.isEmpty(), ("Machine items cleanup failed!")); 521 534 break; 522 535 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h
r42558 r42563 117 117 void addItem(UIGChooserItem *pItem, int iPosition); 118 118 void removeItem(UIGChooserItem *pItem); 119 void setItems(const QList<UIGChooserItem*> &items, UIGChooserItemType type); 119 120 QList<UIGChooserItem*> items(UIGChooserItemType type = UIGChooserItemType_Any) const; 120 121 bool hasItems(UIGChooserItemType type = UIGChooserItemType_Any) const; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp
r42559 r42563 233 233 234 234 void UIGChooserItemMachine::removeItem(UIGChooserItem*) 235 { 236 AssertMsgFailed(("Machine graphics item do NOT support children!")); 237 } 238 239 void UIGChooserItemMachine::setItems(const QList<UIGChooserItem*>&, UIGChooserItemType) 235 240 { 236 241 AssertMsgFailed(("Machine graphics item do NOT support children!")); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h
r42558 r42563 98 98 void addItem(UIGChooserItem *pItem, int iPosition); 99 99 void removeItem(UIGChooserItem *pItem); 100 void setItems(const QList<UIGChooserItem*> &items, UIGChooserItemType type); 100 101 QList<UIGChooserItem*> items(UIGChooserItemType type) const; 101 102 bool hasItems(UIGChooserItemType type) const; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r42547 r42563 769 769 } 770 770 771 void UIGChooserModel::sltSortParentGroup() 772 { 773 if (!selectionList().isEmpty()) 774 sortItems(selectionList().first()->parentItem()); 775 } 776 777 void UIGChooserModel::sltSortGroup() 778 { 779 if (singleGroupSelected()) 780 sortItems(selectionList().first()); 781 } 782 771 783 QVariant UIGChooserModel::data(int iKey) const 772 784 { … … 814 826 m_pContextMenuGroup->addAction(gActionPool->action(UIActionIndexSelector_Simple_Group_ShowInFileManager)); 815 827 m_pContextMenuGroup->addAction(gActionPool->action(UIActionIndexSelector_Simple_Group_CreateShortcut)); 816 // m_pContextMenuGroup->addSeparator(); 817 // m_pContextMenuGroup->addAction(gActionPool->action(UIActionIndexSelector_Simple_Group_Sort)); 828 m_pContextMenuGroup->addSeparator(); 829 m_pContextMenuGroup->addAction(gActionPool->action(UIActionIndexSelector_Simple_Common_SortParent)); 830 m_pContextMenuGroup->addAction(gActionPool->action(UIActionIndexSelector_Simple_Group_Sort)); 818 831 819 832 /* Context menu for machine(s): */ … … 835 848 m_pContextMenuMachine->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_ShowInFileManager)); 836 849 m_pContextMenuMachine->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_CreateShortcut)); 837 //m_pContextMenuMachine->addSeparator();838 // m_pContextMenuMachine->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_Sort));850 m_pContextMenuMachine->addSeparator(); 851 m_pContextMenuMachine->addAction(gActionPool->action(UIActionIndexSelector_Simple_Common_SortParent)); 839 852 840 853 connect(m_pContextMenuRoot, SIGNAL(hovered(QAction*)), this, SLOT(sltActionHovered(QAction*))); … … 850 863 connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog), SIGNAL(triggered()), 851 864 this, SLOT(sltRemoveCurrentlySelectedMachine())); 865 connect(gActionPool->action(UIActionIndexSelector_Simple_Common_SortParent), SIGNAL(triggered()), 866 this, SLOT(sltSortParentGroup())); 867 connect(gActionPool->action(UIActionIndexSelector_Simple_Group_Sort), SIGNAL(triggered()), 868 this, SLOT(sltSortGroup())); 852 869 } 853 870 … … 1606 1623 } 1607 1624 1625 void UIGChooserModel::sortItems(UIGChooserItem *pParent, bool fRecursively /* = false */) 1626 { 1627 /* Sort group items: */ 1628 QMap<QString, UIGChooserItem*> sorter; 1629 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group)) 1630 { 1631 sorter.insert(pItem->name().toLower(), pItem); 1632 if (fRecursively) 1633 sortItems(pItem, fRecursively); 1634 } 1635 pParent->setItems(sorter.values(), UIGChooserItemType_Group); 1636 1637 /* Sort machine items: */ 1638 sorter.clear(); 1639 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine)) 1640 sorter.insert(pItem->name().toLower(), pItem); 1641 pParent->setItems(sorter.values(), UIGChooserItemType_Machine); 1642 1643 /* Update model: */ 1644 updateNavigation(); 1645 updateLayout(); 1646 } 1647 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r42547 r42563 177 177 void sltSlidingComplete(); 178 178 179 /* Handlers: Sorting stuff: */ 180 void sltSortParentGroup(); 181 void sltSortGroup(); 182 179 183 private: 180 184 … … 257 261 void removeMachineItems(const QStringList &names, QList<UIGChooserItem*> &selectedItems); 258 262 void unregisterMachines(const QStringList &names); 263 264 /* Helper: Sorting stuff: */ 265 void sortItems(UIGChooserItem *pParent, bool fRecursively = false); 259 266 260 267 /* Variables: */
Note:
See TracChangeset
for help on using the changeset viewer.

