1 | /* $Id: UISettingsSelector.h 76581 2019-01-01 06:24:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UISettingsSelector class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2008-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef FEQT_INCLUDED_SRC_settings_UISettingsSelector_h
|
---|
19 | #define FEQT_INCLUDED_SRC_settings_UISettingsSelector_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QObject>
|
---|
26 |
|
---|
27 | /* GUI includes: */
|
---|
28 | #include "UILibraryDefs.h"
|
---|
29 |
|
---|
30 | /* Forward declarations: */
|
---|
31 | class QAction;
|
---|
32 | class QActionGroup;
|
---|
33 | class QTabWidget;
|
---|
34 | class QTreeWidget;
|
---|
35 | class QTreeWidgetItem;
|
---|
36 | class QITreeWidget;
|
---|
37 | class UISelectorActionItem;
|
---|
38 | class UISelectorItem;
|
---|
39 | class UISettingsPage;
|
---|
40 | class UIToolBar;
|
---|
41 |
|
---|
42 |
|
---|
43 | /** QObject subclass providing settings dialog
|
---|
44 | * with the means to switch between settings pages. */
|
---|
45 | class SHARED_LIBRARY_STUFF UISettingsSelector : public QObject
|
---|
46 | {
|
---|
47 | Q_OBJECT;
|
---|
48 |
|
---|
49 | signals:
|
---|
50 |
|
---|
51 | /** Notifies listeners about selector @a iCategory changed. */
|
---|
52 | void sigCategoryChanged(int iCategory);
|
---|
53 |
|
---|
54 | public:
|
---|
55 |
|
---|
56 | /** Constructs settings selector passing @a pParent to the base-class. */
|
---|
57 | UISettingsSelector(QWidget *pParent = 0);
|
---|
58 | /** Destructs settings selector. */
|
---|
59 | virtual ~UISettingsSelector() /* override */;
|
---|
60 |
|
---|
61 | /** Returns the widget selector operates on. */
|
---|
62 | virtual QWidget *widget() const = 0;
|
---|
63 |
|
---|
64 | /** Adds a new selector item.
|
---|
65 | * @param strBigIcon Brings the big icon reference.
|
---|
66 | * @param strMediumIcon Brings the medium icon reference.
|
---|
67 | * @param strSmallIcon Brings the small icon reference.
|
---|
68 | * @param iID Brings the selector section ID.
|
---|
69 | * @param strLink Brings the selector section link.
|
---|
70 | * @param pPage Brings the selector section page reference.
|
---|
71 | * @param iParentID Brings the parent section ID or -1 if there is no parent. */
|
---|
72 | virtual QWidget *addItem(const QString &strBigIcon, const QString &strMediumIcon, const QString &strSmallIcon,
|
---|
73 | int iID, const QString &strLink, UISettingsPage *pPage = 0, int iParentID = -1) = 0;
|
---|
74 |
|
---|
75 | /** Defines the @a strText for section with @a iID. */
|
---|
76 | virtual void setItemText(int iID, const QString &strText);
|
---|
77 | /** Returns the text for section with @a iID. */
|
---|
78 | virtual QString itemText(int iID) const = 0;
|
---|
79 | /** Returns the text for section with @a pPage. */
|
---|
80 | virtual QString itemTextByPage(UISettingsPage *pPage) const;
|
---|
81 |
|
---|
82 | /** Returns the current selector ID. */
|
---|
83 | virtual int currentId() const = 0;
|
---|
84 |
|
---|
85 | /** Returns the section ID for passed @a strLink. */
|
---|
86 | virtual int linkToId(const QString &strLink) const = 0;
|
---|
87 |
|
---|
88 | /** Returns the section page for passed @a iID. */
|
---|
89 | virtual QWidget *idToPage(int iID) const;
|
---|
90 | /** Returns the section root-page for passed @a iID. */
|
---|
91 | virtual QWidget *rootPage(int iID) const { return idToPage(iID); }
|
---|
92 |
|
---|
93 | /** Make the section with @a iID current. */
|
---|
94 | virtual void selectById(int iID) = 0;
|
---|
95 | /** Make the section with @a strLink current. */
|
---|
96 | virtual void selectByLink(const QString &strLink) { selectById(linkToId(strLink)); }
|
---|
97 |
|
---|
98 | /** Make the section with @a iID @a fVisible. */
|
---|
99 | virtual void setVisibleById(int iID, bool fVisible) = 0;
|
---|
100 |
|
---|
101 | /** Returns the list of all selector pages. */
|
---|
102 | virtual QList<UISettingsPage*> settingPages() const;
|
---|
103 | /** Returns the list of all root pages. */
|
---|
104 | virtual QList<QWidget*> rootPages() const;
|
---|
105 |
|
---|
106 | /** Performs selector polishing. */
|
---|
107 | virtual void polish() {}
|
---|
108 |
|
---|
109 | /** Returns minimum selector width. */
|
---|
110 | virtual int minWidth() const { return 0; }
|
---|
111 |
|
---|
112 | protected:
|
---|
113 |
|
---|
114 | /** Clears selector of all the items. */
|
---|
115 | virtual void clear() = 0;
|
---|
116 |
|
---|
117 | /** Searches for item with passed @a iID. */
|
---|
118 | UISelectorItem *findItem(int iID) const;
|
---|
119 | /** Searches for item with passed @a strLink. */
|
---|
120 | UISelectorItem *findItemByLink(const QString &strLink) const;
|
---|
121 | /** Searches for item with passed @a pPage. */
|
---|
122 | UISelectorItem *findItemByPage(UISettingsPage *pPage) const;
|
---|
123 |
|
---|
124 | /** Holds the selector item instances. */
|
---|
125 | QList<UISelectorItem*> m_list;
|
---|
126 | };
|
---|
127 |
|
---|
128 |
|
---|
129 | /** UISettingsSelector subclass providing settings dialog
|
---|
130 | * with the means to switch between settings pages.
|
---|
131 | * This one represented as tree-widget. */
|
---|
132 | class SHARED_LIBRARY_STUFF UISettingsSelectorTreeView : public UISettingsSelector
|
---|
133 | {
|
---|
134 | Q_OBJECT;
|
---|
135 |
|
---|
136 | public:
|
---|
137 |
|
---|
138 | /** Constructs settings selector passing @a pParent to the base-class. */
|
---|
139 | UISettingsSelectorTreeView(QWidget *pParent = 0);
|
---|
140 | /** Destructs settings selector. */
|
---|
141 | virtual ~UISettingsSelectorTreeView() /* override */;
|
---|
142 |
|
---|
143 | /** Returns the widget selector operates on. */
|
---|
144 | virtual QWidget *widget() const /* override */;
|
---|
145 |
|
---|
146 | /** Adds a new selector item.
|
---|
147 | * @param strBigIcon Brings the big icon reference.
|
---|
148 | * @param strMediumIcon Brings the medium icon reference.
|
---|
149 | * @param strSmallIcon Brings the small icon reference.
|
---|
150 | * @param iID Brings the selector section ID.
|
---|
151 | * @param strLink Brings the selector section link.
|
---|
152 | * @param pPage Brings the selector section page reference.
|
---|
153 | * @param iParentID Brings the parent section ID or -1 if there is no parent. */
|
---|
154 | virtual QWidget *addItem(const QString &strBigIcon, const QString &strMediumIcon, const QString &strSmallIcon,
|
---|
155 | int iID, const QString &strLink, UISettingsPage *pPage = 0, int iParentID = -1) /* override */;
|
---|
156 |
|
---|
157 | /** Defines the @a strText for section with @a iID. */
|
---|
158 | virtual void setItemText(int iID, const QString &strText) /* override */;
|
---|
159 | /** Returns the text for section with @a iID. */
|
---|
160 | virtual QString itemText(int iID) const /* override */;
|
---|
161 |
|
---|
162 | /** Returns the current selector ID. */
|
---|
163 | virtual int currentId() const /* override */;
|
---|
164 |
|
---|
165 | /** Returns the section ID for passed @a strLink. */
|
---|
166 | virtual int linkToId(const QString &strLink) const /* override */;
|
---|
167 |
|
---|
168 | /** Make the section with @a iID current. */
|
---|
169 | virtual void selectById(int iID) /* override */;
|
---|
170 |
|
---|
171 | /** Make the section with @a iID @a fVisible. */
|
---|
172 | virtual void setVisibleById(int iID, bool fVisible) /* override */;
|
---|
173 |
|
---|
174 | /** Performs selector polishing. */
|
---|
175 | virtual void polish() /* override */;
|
---|
176 |
|
---|
177 | private slots:
|
---|
178 |
|
---|
179 | /** Handles selector section change from @a pPrevItem to @a pItem. */
|
---|
180 | void sltSettingsGroupChanged(QTreeWidgetItem *pItem, QTreeWidgetItem *pPrevItem);
|
---|
181 |
|
---|
182 | private:
|
---|
183 |
|
---|
184 | /** Clears selector of all the items. */
|
---|
185 | virtual void clear() /* override */;
|
---|
186 |
|
---|
187 | /** Returns page path for passed @a strMatch. */
|
---|
188 | QString pagePath(const QString &strMatch) const;
|
---|
189 | /** Find item within the passed @a pView and @a iColumn matching @a strMatch. */
|
---|
190 | QTreeWidgetItem *findItem(QTreeWidget *pView, const QString &strMatch, int iColumn) const;
|
---|
191 | /** Performs @a iID to QString serialization. */
|
---|
192 | QString idToString(int iID) const;
|
---|
193 |
|
---|
194 | /** Forges the full path for passed @a pItem. */
|
---|
195 | static QString path(const QTreeWidgetItem *pItem);
|
---|
196 |
|
---|
197 | /** Holds the tree-widget instance. */
|
---|
198 | QITreeWidget *m_pTreeWidget;
|
---|
199 | };
|
---|
200 |
|
---|
201 |
|
---|
202 | /** UISettingsSelector subclass providing settings dialog
|
---|
203 | * with the means to switch between settings pages.
|
---|
204 | * This one represented as tab-widget. */
|
---|
205 | class SHARED_LIBRARY_STUFF UISettingsSelectorToolBar : public UISettingsSelector
|
---|
206 | {
|
---|
207 | Q_OBJECT;
|
---|
208 |
|
---|
209 | public:
|
---|
210 |
|
---|
211 | /** Constructs settings selector passing @a pParent to the base-class. */
|
---|
212 | UISettingsSelectorToolBar(QWidget *pParent = 0);
|
---|
213 | /** Destructs settings selector. */
|
---|
214 | virtual ~UISettingsSelectorToolBar() /* override */;
|
---|
215 |
|
---|
216 | /** Returns the widget selector operates on. */
|
---|
217 | virtual QWidget *widget() const /* override */;
|
---|
218 |
|
---|
219 | /** Adds a new selector item.
|
---|
220 | * @param strBigIcon Brings the big icon reference.
|
---|
221 | * @param strMediumIcon Brings the medium icon reference.
|
---|
222 | * @param strSmallIcon Brings the small icon reference.
|
---|
223 | * @param iID Brings the selector section ID.
|
---|
224 | * @param strLink Brings the selector section link.
|
---|
225 | * @param pPage Brings the selector section page reference.
|
---|
226 | * @param iParentID Brings the parent section ID or -1 if there is no parent. */
|
---|
227 | virtual QWidget *addItem(const QString &strBigIcon, const QString &strMediumIcon, const QString &strSmallIcon,
|
---|
228 | int iID, const QString &strLink, UISettingsPage *pPage = 0, int iParentID = -1) /* override */;
|
---|
229 |
|
---|
230 | /** Defines the @a strText for section with @a iID. */
|
---|
231 | virtual void setItemText(int iID, const QString &strText) /* override */;
|
---|
232 | /** Returns the text for section with @a iID. */
|
---|
233 | virtual QString itemText(int iID) const /* override */;
|
---|
234 |
|
---|
235 | /** Returns the current selector ID. */
|
---|
236 | virtual int currentId() const /* override */;
|
---|
237 |
|
---|
238 | /** Returns the section ID for passed @a strLink. */
|
---|
239 | virtual int linkToId(const QString &strLink) const /* override */;
|
---|
240 |
|
---|
241 | /** Returns the section page for passed @a iID. */
|
---|
242 | virtual QWidget *idToPage(int iID) const /* override */;
|
---|
243 | /** Returns the section root-page for passed @a iID. */
|
---|
244 | virtual QWidget *rootPage(int iID) const /* override */;
|
---|
245 |
|
---|
246 | /** Make the section with @a iID current. */
|
---|
247 | virtual void selectById(int iID) /* override */;
|
---|
248 |
|
---|
249 | /** Make the section with @a iID @a fVisible. */
|
---|
250 | virtual void setVisibleById(int iID, bool fVisible) /* override */;
|
---|
251 |
|
---|
252 | /** Returns the list of all root pages. */
|
---|
253 | virtual QList<QWidget*> rootPages() const /* override */;
|
---|
254 |
|
---|
255 | /** Returns minimum selector width. */
|
---|
256 | virtual int minWidth() const /* override */;
|
---|
257 |
|
---|
258 | private slots:
|
---|
259 |
|
---|
260 | /** Handles selector section change to @a pAction. */
|
---|
261 | void sltSettingsGroupChanged(QAction *pAction);
|
---|
262 | /** Handles selector section change to @a iIndex. */
|
---|
263 | void sltSettingsGroupChanged(int iIndex);
|
---|
264 |
|
---|
265 | private:
|
---|
266 |
|
---|
267 | /** Clears selector of all the items. */
|
---|
268 | virtual void clear() /* override */;
|
---|
269 |
|
---|
270 | /** Searches for action item with passed @a iID. */
|
---|
271 | UISelectorActionItem *findActionItem(int iID) const;
|
---|
272 | /** Searches for action item with passed @a pAction. */
|
---|
273 | UISelectorActionItem *findActionItemByAction(QAction *pAction) const;
|
---|
274 | /** Searches for action item with passed @a pTabWidget and @a iIndex. */
|
---|
275 | UISelectorActionItem *findActionItemByTabWidget(QTabWidget *pTabWidget, int iIndex) const;
|
---|
276 |
|
---|
277 | /** Holds the toolbar instance. */
|
---|
278 | UIToolBar *m_pToolBar;
|
---|
279 | /** Holds the action group instance. */
|
---|
280 | QActionGroup *m_pActionGroup;
|
---|
281 | };
|
---|
282 |
|
---|
283 |
|
---|
284 | #endif /* !FEQT_INCLUDED_SRC_settings_UISettingsSelector_h */
|
---|