Changeset 64058 in vbox for trunk/src/VBox
- Timestamp:
- Sep 27, 2016 5:56:30 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 110986
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.cpp
r63978 r64058 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 21 22 /* Global includes*/22 /* Qt includes: */ 23 23 # include <QHeaderView> 24 24 # include <QTabWidget> … … 26 26 # include <QAction> 27 27 28 /* Local includes*/28 /* GUI includes: */ 29 29 # include "UISettingsSelector.h" 30 30 # include "UISettingsPage.h" … … 37 37 38 38 39 /** Tree-widget column categories. */ 39 40 enum 40 41 { 41 /* mTwSelector column numbers */42 42 treeWidget_Category = 0, 43 43 treeWidget_Id, … … 45 45 }; 46 46 47 48 /** Simple container of all the selector item data. */ 47 49 class SelectorItem 48 50 { 49 51 public: 52 50 53 SelectorItem (const QIcon &aIcon, const QString &aText, int aId, const QString &aLink, UISettingsPage* aPage, int aParentId) 51 54 : mIcon (aIcon) … … 75 78 }; 76 79 80 81 /********************************************************************************************************************************* 82 * Class UISettingsSelector implementation. * 83 *********************************************************************************************************************************/ 84 77 85 UISettingsSelector::UISettingsSelector (QWidget *aParent /* = NULL */) 78 86 :QObject (aParent) … … 126 134 } 127 135 128 129 136 SelectorItem *UISettingsSelector::findItem (int aId) const 130 137 { … … 163 170 } 164 171 165 /* UISettingsSelectorTreeView */ 166 167 /* Returns the path to the item in the form of 'grandparent > parent > item' 168 * using the text of the first column of every item. */ 172 173 /********************************************************************************************************************************* 174 * Class UISettingsSelectorTreeView implementation. * 175 *********************************************************************************************************************************/ 176 169 177 static QString path (QTreeWidgetItem *aItem) 170 178 { … … 275 283 } 276 284 277 278 285 void UISettingsSelectorTreeView::selectById (int aId) 279 286 { … … 331 338 } 332 339 333 /**334 * Returns a path to the given page of this settings window. See ::path() for335 * details.336 */337 340 QString UISettingsSelectorTreeView::pagePath (const QString &aMatch) const 338 341 { … … 344 347 } 345 348 346 /* Returns first item of 'aView' matching required 'aMatch' value347 * searching the 'aColumn' column. */348 349 QTreeWidgetItem* UISettingsSelectorTreeView::findItem (QTreeWidget *aView, 349 350 const QString &aMatch, … … 361 362 } 362 363 363 /* UISettingsSelectorToolBar */ 364 365 364 365 /********************************************************************************************************************************* 366 * Class UISettingsSelectorToolBar implementation. * 367 *********************************************************************************************************************************/ 368 369 /** SelectorItem subclass providing GUI 370 * with the tab-widget selector item. */ 366 371 class SelectorActionItem: public SelectorItem 367 372 { 368 373 public: 374 369 375 SelectorActionItem (const QIcon &aIcon, const QString &aText, int aId, const QString &aLink, UISettingsPage* aPage, int aParentId, QObject *aParent) 370 376 : SelectorItem (aIcon, aText, aId, aLink, aPage, aParentId) … … 385 391 QTabWidget *mTabWidget; 386 392 }; 393 387 394 388 395 UISettingsSelectorToolBar::UISettingsSelectorToolBar (QWidget *aParent /* = NULL */) … … 556 563 } 557 564 } 558 559 565 560 566 void UISettingsSelectorToolBar::setVisibleById (int aId, bool aShow) -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.h
r63978 r64058 16 16 */ 17 17 18 #ifndef __ UISettingsSelector_h__19 #define __ UISettingsSelector_h__20 21 /* Qt includes */18 #ifndef ___UISettingsSelector_h___ 19 #define ___UISettingsSelector_h___ 20 21 /* Qt includes: */ 22 22 #include <QObject> 23 23 24 /* Forward declarations: */ 24 25 class QITreeWidget; 25 26 class UIToolBar; … … 27 28 class SelectorItem; 28 29 class SelectorActionItem; 29 30 30 class QTreeWidget; 31 31 class QTreeWidgetItem; … … 36 36 class QTabWidget; 37 37 38 39 /** QObject subclass providing settings dialog 40 * with the means to switch between settings pages. */ 38 41 class UISettingsSelector: public QObject 39 42 { … … 42 45 public: 43 46 47 /** Constructs settings selector passing @a aParent to the base-class. */ 44 48 UISettingsSelector (QWidget *aParent = NULL); 49 /** Destructs settings selector. */ 45 50 ~UISettingsSelector(); 46 51 52 /** Returns the widget selector operates on. */ 47 53 virtual QWidget *widget() const = 0; 48 54 55 /** Adds a new selector item. 56 * @param strBigIcon Brings the big icon reference. 57 * @param strMediumIcon Brings the medium icon reference. 58 * @param strSmallIcon Brings the small icon reference. 59 * @param aId Brings the selector section ID. 60 * @param aLink Brings the selector section link. 61 * @param aPage Brings the selector section page reference. 62 * @param aParentId Brings the parent section ID or -1 if there is no parent. */ 49 63 virtual QWidget *addItem (const QString &strBigIcon, const QString &strMediumIcon, const QString &strSmallIcon, 50 64 int aId, const QString &aLink, UISettingsPage* aPage = NULL, int aParentId = -1) = 0; 51 65 66 /** Defines the @a aText for section with @a aId. */ 52 67 virtual void setItemText (int aId, const QString &aText); 68 /** Returns the text for section with @a aId. */ 53 69 virtual QString itemText (int aId) const = 0; 70 /** Returns the text for section with @a aPage. */ 54 71 virtual QString itemTextByPage (UISettingsPage *aPage) const; 55 72 73 /** Returns the current selector ID. */ 56 74 virtual int currentId () const = 0; 75 76 /** Returns the section ID for passed @a aLink. */ 57 77 virtual int linkToId (const QString &aLink) const = 0; 58 78 79 /** Returns the section page for passed @a aId. */ 59 80 virtual QWidget *idToPage (int aId) const; 81 /** Returns the section root-page for passed @a aId. */ 60 82 virtual QWidget *rootPage (int aId) const { return idToPage (aId); } 61 83 84 /** Make the section with @a aId current. */ 62 85 virtual void selectById (int aId) = 0; 86 /** Make the section with @a aLink current. */ 63 87 virtual void selectByLink (const QString &aLink) { selectById (linkToId (aLink)); } 64 88 89 /** Make the section with @a aId @a aShow. */ 65 90 virtual void setVisibleById (int aId, bool aShow) = 0; 66 91 92 /** Returns the list of all selector pages. */ 67 93 virtual QList<UISettingsPage*> settingPages() const; 94 /** Returns the list of all root pages. */ 68 95 virtual QList<QWidget*> rootPages() const; 69 96 97 /** Performs selector polishing. */ 70 98 virtual void polish() {}; 71 99 100 /** Returns minimum selector width. */ 72 101 virtual int minWidth () const { return 0; } 73 102 74 103 signals: 75 104 105 /** Notifies listeners about selector section changed. */ 76 106 void categoryChanged (int); 77 107 78 108 protected: 79 109 110 /** Clears selector of all the items. */ 80 111 virtual void clear() = 0; 81 112 113 /** Searches for item with passed @a aId. */ 82 114 SelectorItem* findItem (int aId) const; 115 /** Searches for item with passed @a aLink. */ 83 116 SelectorItem* findItemByLink (const QString &aLink) const; 117 /** Searches for item with passed @a aPage. */ 84 118 SelectorItem* findItemByPage (UISettingsPage* aPage) const; 85 119 120 /** Holds the selector item instances. */ 86 121 QList<SelectorItem*> mItemList; 87 122 }; 88 123 124 125 /** UISettingsSelector subclass providing settings dialog 126 * with the means to switch between settings pages. 127 * This one represented as tree-widget. */ 89 128 class UISettingsSelectorTreeView: public UISettingsSelector 90 129 { … … 93 132 public: 94 133 134 /** Constructs settings selector passing @a aParent to the base-class. */ 95 135 UISettingsSelectorTreeView (QWidget *aParent = NULL); 96 136 137 /** Returns the widget selector operates on. */ 97 138 virtual QWidget *widget() const; 98 139 140 /** Adds a new selector item. 141 * @param strBigIcon Brings the big icon reference. 142 * @param strMediumIcon Brings the medium icon reference. 143 * @param strSmallIcon Brings the small icon reference. 144 * @param aId Brings the selector section ID. 145 * @param aLink Brings the selector section link. 146 * @param aPage Brings the selector section page reference. 147 * @param aParentId Brings the parent section ID or -1 if there is no parent. */ 99 148 virtual QWidget *addItem (const QString &strBigIcon, const QString &strMediumIcon, const QString &strSmallIcon, 100 149 int aId, const QString &aLink, UISettingsPage* aPage = NULL, int aParentId = -1); 150 151 /** Defines the @a aText for section with @a aId. */ 101 152 virtual void setItemText (int aId, const QString &aText); 153 /** Returns the text for section with @a aId. */ 102 154 virtual QString itemText (int aId) const; 103 155 156 /** Returns the current selector ID. */ 104 157 virtual int currentId() const; 158 159 /** Returns the section ID for passed @a aLink. */ 105 160 virtual int linkToId (const QString &aLink) const; 106 161 162 /** Make the section with @a aId current. */ 107 163 virtual void selectById (int aId); 108 164 165 /** Make the section with @a aId @a aShow. */ 109 166 virtual void setVisibleById (int aId, bool aShow); 110 167 168 /** Performs selector polishing. */ 111 169 virtual void polish(); 112 170 113 171 private slots: 114 172 173 /** Handles selector section change from @a aPrevItem to @a aItem. */ 115 174 void settingsGroupChanged (QTreeWidgetItem *aItem, QTreeWidgetItem *aPrevItem); 116 175 117 176 private: 118 177 178 /** Clears selector of all the items. */ 119 179 virtual void clear(); 120 180 181 /** Returns page path for passed @a aMatch. */ 121 182 QString pagePath (const QString &aMatch) const; 183 /** Find item within the passed @a aView and @a aColumn matching @a aMatch. */ 122 184 QTreeWidgetItem* findItem (QTreeWidget *aView, const QString &aMatch, int aColumn) const; 185 /** Performs @a aId to QString serialization. */ 123 186 QString idToString (int aId) const; 124 187 125 /* Private member vars*/188 /** Holds the tree-widget selector instance. */ 126 189 QITreeWidget *mTwSelector; 127 190 }; 128 191 192 193 /** UISettingsSelector subclass providing settings dialog 194 * with the means to switch between settings pages. 195 * This one represented as tab-widget. */ 129 196 class UISettingsSelectorToolBar: public UISettingsSelector 130 197 { … … 133 200 public: 134 201 202 /** Constructs settings selector passing @a aParent to the base-class. */ 135 203 UISettingsSelectorToolBar (QWidget *aParent = NULL); 136 204 ~UISettingsSelectorToolBar(); 137 205 206 /** Returns the widget selector operates on. */ 138 207 virtual QWidget *widget() const; 139 208 209 /** Adds a new selector item. 210 * @param strBigIcon Brings the big icon reference. 211 * @param strMediumIcon Brings the medium icon reference. 212 * @param strSmallIcon Brings the small icon reference. 213 * @param aId Brings the selector section ID. 214 * @param aLink Brings the selector section link. 215 * @param aPage Brings the selector section page reference. 216 * @param aParentId Brings the parent section ID or -1 if there is no parent. */ 140 217 virtual QWidget *addItem (const QString &strBigIcon, const QString &strMediumIcon, const QString &strSmallIcon, 141 218 int aId, const QString &aLink, UISettingsPage* aPage = NULL, int aParentId = -1); 219 220 /** Defines the @a aText for section with @a aId. */ 142 221 virtual void setItemText (int aId, const QString &aText); 222 /** Returns the text for section with @a aId. */ 143 223 virtual QString itemText (int aId) const; 144 224 225 /** Returns the current selector ID. */ 145 226 virtual int currentId() const; 227 228 /** Returns the section ID for passed @a aLink. */ 146 229 virtual int linkToId (const QString &aLink) const; 147 230 231 /** Returns the section page for passed @a aId. */ 148 232 virtual QWidget *idToPage (int aId) const; 233 /** Returns the section root-page for passed @a aId. */ 149 234 virtual QWidget *rootPage (int aId) const; 150 235 236 /** Make the section with @a aId current. */ 151 237 virtual void selectById (int aId); 152 238 239 /** Make the section with @a aId @a aShow. */ 153 240 virtual void setVisibleById (int aId, bool aShow); 154 241 242 /** Returns minimum selector width. */ 155 243 virtual int minWidth() const; 156 244 245 /** Returns the list of all root pages. */ 157 246 virtual QList<QWidget*> rootPages() const; 247 158 248 private slots: 159 249 250 /** Handles selector section change to @a aAction . */ 160 251 void settingsGroupChanged (QAction *aAction); 252 /** Handles selector section change to @a aIndex . */ 161 253 void settingsGroupChanged (int aIndex); 162 254 163 255 private: 164 256 257 /** Clears selector of all the items. */ 165 258 virtual void clear(); 166 259 260 /** Searches for action item with passed @a aId. */ 167 261 SelectorActionItem *findActionItem (int aId) const; 262 /** Searches for action item with passed @a aAction. */ 168 263 SelectorActionItem *findActionItemByAction (QAction *aAction) const; 264 /** Searches for action item with passed @a aTabWidget and @a aIndex. */ 169 265 SelectorActionItem *findActionItemByTabWidget (QTabWidget* aTabWidget, int aIndex) const; 170 266 171 /* Private member vars*/267 /** Holds the toolbar instance. */ 172 268 UIToolBar *mTbSelector; 269 /** Holds the action group instance. */ 173 270 QActionGroup *mActionGroup; 174 271 }; 175 272 176 #endif /* __UISettingsSelector_h__ */177 273 #endif /* !___UISettingsSelector_h___ */ 274
Note:
See TracChangeset
for help on using the changeset viewer.