1 | /* $Id: UISettingsSelector.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UISettingsSelector class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2008-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_settings_UISettingsSelector_h
|
---|
29 | #define FEQT_INCLUDED_SRC_settings_UISettingsSelector_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QObject>
|
---|
36 |
|
---|
37 | /* GUI includes: */
|
---|
38 | #include "UILibraryDefs.h"
|
---|
39 |
|
---|
40 | /* Forward declarations: */
|
---|
41 | class QSortFilterProxyModel;
|
---|
42 | class UISelectorItem;
|
---|
43 | class UISelectorModel;
|
---|
44 | class UISelectorTreeView;
|
---|
45 | class UISettingsPage;
|
---|
46 |
|
---|
47 |
|
---|
48 | /** QObject subclass providing settings dialog
|
---|
49 | * with the means to switch between settings pages. */
|
---|
50 | class SHARED_LIBRARY_STUFF UISettingsSelector : public QObject
|
---|
51 | {
|
---|
52 | Q_OBJECT;
|
---|
53 |
|
---|
54 | signals:
|
---|
55 |
|
---|
56 | /** Notifies listeners about selector @a iCategory changed. */
|
---|
57 | void sigCategoryChanged(int iCategory);
|
---|
58 |
|
---|
59 | public:
|
---|
60 |
|
---|
61 | /** Constructs settings selector passing @a pParent to the base-class. */
|
---|
62 | UISettingsSelector(QWidget *pParent = 0);
|
---|
63 | /** Destructs settings selector. */
|
---|
64 | virtual ~UISettingsSelector() RT_OVERRIDE;
|
---|
65 |
|
---|
66 | /** Returns the widget selector operates on. */
|
---|
67 | virtual QWidget *widget() const = 0;
|
---|
68 |
|
---|
69 | /** Adds a new selector item.
|
---|
70 | * @param strBigIcon Brings the big icon reference.
|
---|
71 | * @param strMediumIcon Brings the medium icon reference.
|
---|
72 | * @param strSmallIcon Brings the small icon reference.
|
---|
73 | * @param iID Brings the selector section ID.
|
---|
74 | * @param strLink Brings the selector section link.
|
---|
75 | * @param pPage Brings the selector section page reference.
|
---|
76 | * @param iParentID Brings the parent section ID or -1 if there is no parent. */
|
---|
77 | virtual QWidget *addItem(const QString &strBigIcon, const QString &strMediumIcon, const QString &strSmallIcon,
|
---|
78 | int iID, const QString &strLink, UISettingsPage *pPage = 0, int iParentID = -1) = 0;
|
---|
79 |
|
---|
80 | /** Defines whether section with @a iID is @a fVisible. */
|
---|
81 | virtual void setItemVisible(int iID, bool fVisible) { Q_UNUSED(iID); Q_UNUSED(fVisible); }
|
---|
82 |
|
---|
83 | /** Defines the @a strText for section with @a iID. */
|
---|
84 | virtual void setItemText(int iID, const QString &strText);
|
---|
85 | /** Returns the text for section with @a iID. */
|
---|
86 | virtual QString itemText(int iID) const = 0;
|
---|
87 | /** Returns the text for section with @a pPage. */
|
---|
88 | virtual QString itemTextByPage(UISettingsPage *pPage) const;
|
---|
89 |
|
---|
90 | /** Returns the current selector ID. */
|
---|
91 | virtual int currentId() const = 0;
|
---|
92 |
|
---|
93 | /** Returns the section ID for passed @a strLink. */
|
---|
94 | virtual int linkToId(const QString &strLink) const = 0;
|
---|
95 |
|
---|
96 | /** Returns the section page for passed @a iID. */
|
---|
97 | virtual QWidget *idToPage(int iID) const;
|
---|
98 |
|
---|
99 | /** Make the section with @a iID current. */
|
---|
100 | virtual void selectById(int iID, bool fSilently = false) = 0;
|
---|
101 | /** Make the section with @a strLink current. */
|
---|
102 | virtual void selectByLink(const QString &strLink) { selectById(linkToId(strLink)); }
|
---|
103 |
|
---|
104 | /** Returns the list of all selector pages. */
|
---|
105 | virtual QList<UISettingsPage*> settingPages() const;
|
---|
106 |
|
---|
107 | /** Performs selector polishing. */
|
---|
108 | virtual void polish() {}
|
---|
109 |
|
---|
110 | /** Returns minimum selector width. */
|
---|
111 | virtual int minWidth() const { return 0; }
|
---|
112 |
|
---|
113 | protected:
|
---|
114 |
|
---|
115 | /** Searches for item with passed @a iID. */
|
---|
116 | UISelectorItem *findItem(int iID) const;
|
---|
117 | /** Searches for item with passed @a strLink. */
|
---|
118 | UISelectorItem *findItemByLink(const QString &strLink) const;
|
---|
119 | /** Searches for item with passed @a pPage. */
|
---|
120 | UISelectorItem *findItemByPage(UISettingsPage *pPage) const;
|
---|
121 |
|
---|
122 | /** Holds the selector item instances. */
|
---|
123 | QList<UISelectorItem*> m_list;
|
---|
124 | };
|
---|
125 |
|
---|
126 |
|
---|
127 | /** UISettingsSelector subclass providing settings dialog
|
---|
128 | * with the means to switch between settings pages.
|
---|
129 | * This one represented as tree-view. */
|
---|
130 | class SHARED_LIBRARY_STUFF UISettingsSelectorTreeView : public UISettingsSelector
|
---|
131 | {
|
---|
132 | Q_OBJECT;
|
---|
133 |
|
---|
134 | public:
|
---|
135 |
|
---|
136 | /** Constructs settings selector passing @a pParent to the base-class. */
|
---|
137 | UISettingsSelectorTreeView(QWidget *pParent);
|
---|
138 | /** Destructs settings selector. */
|
---|
139 | virtual ~UISettingsSelectorTreeView() RT_OVERRIDE;
|
---|
140 |
|
---|
141 | /** Returns the widget selector operates on. */
|
---|
142 | virtual QWidget *widget() const RT_OVERRIDE;
|
---|
143 |
|
---|
144 | /** Adds a new selector item.
|
---|
145 | * @param strBigIcon Brings the big icon reference.
|
---|
146 | * @param strMediumIcon Brings the medium icon reference.
|
---|
147 | * @param strSmallIcon Brings the small icon reference.
|
---|
148 | * @param iID Brings the selector section ID.
|
---|
149 | * @param strLink Brings the selector section link.
|
---|
150 | * @param pPage Brings the selector section page reference.
|
---|
151 | * @param iParentID Brings the parent section ID or -1 if there is no parent. */
|
---|
152 | virtual QWidget *addItem(const QString &strBigIcon, const QString &strMediumIcon, const QString &strSmallIcon,
|
---|
153 | int iID, const QString &strLink, UISettingsPage *pPage = 0, int iParentID = -1) RT_OVERRIDE;
|
---|
154 |
|
---|
155 | /** Defines whether section with @a iID is @a fVisible. */
|
---|
156 | virtual void setItemVisible(int iID, bool fVisible) RT_OVERRIDE;
|
---|
157 |
|
---|
158 | /** Defines the @a strText for section with @a iID. */
|
---|
159 | virtual void setItemText(int iID, const QString &strText) RT_OVERRIDE;
|
---|
160 | /** Returns the text for section with @a iID. */
|
---|
161 | virtual QString itemText(int iID) const RT_OVERRIDE;
|
---|
162 |
|
---|
163 | /** Returns the current selector ID. */
|
---|
164 | virtual int currentId() const RT_OVERRIDE;
|
---|
165 |
|
---|
166 | /** Returns the section ID for passed @a strLink. */
|
---|
167 | virtual int linkToId(const QString &strLink) const RT_OVERRIDE;
|
---|
168 |
|
---|
169 | /** Make the section with @a iID current. */
|
---|
170 | virtual void selectById(int iID, bool fSilently) RT_OVERRIDE;
|
---|
171 |
|
---|
172 | private slots:
|
---|
173 |
|
---|
174 | /** Handles selector section change from @a pPrevItem to @a pItem. */
|
---|
175 | void sltHandleCurrentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
---|
176 |
|
---|
177 | private:
|
---|
178 |
|
---|
179 | /** Prepares all. */
|
---|
180 | void prepare();
|
---|
181 | /** Cleanups all. */
|
---|
182 | void cleanup();
|
---|
183 |
|
---|
184 | /** Holds the tree-view instance. */
|
---|
185 | UISelectorTreeView *m_pTreeView;
|
---|
186 | /** Holds the model instance. */
|
---|
187 | UISelectorModel *m_pModel;
|
---|
188 | /** Holds the proxy-model instance. */
|
---|
189 | QSortFilterProxyModel *m_pModelProxy;
|
---|
190 | };
|
---|
191 |
|
---|
192 |
|
---|
193 | #endif /* !FEQT_INCLUDED_SRC_settings_UISettingsSelector_h */
|
---|