VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.h

Last change on this file was 106061, checked in by vboxsync, 3 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.9 KB
RevLine 
[55401]1/* $Id: UISettingsSelector.h 106061 2024-09-16 14:03:52Z vboxsync $ */
[25177]2/** @file
[63978]3 * VBox Qt GUI - UISettingsSelector class declaration.
[25177]4 */
5
6/*
[106061]7 * Copyright (C) 2008-2024 Oracle and/or its affiliates.
[25177]8 *
[96407]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
[25177]26 */
27
[76581]28#ifndef FEQT_INCLUDED_SRC_settings_UISettingsSelector_h
29#define FEQT_INCLUDED_SRC_settings_UISettingsSelector_h
[76532]30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
[25177]33
[64058]34/* Qt includes: */
[25177]35#include <QObject>
36
[72102]37/* GUI includes: */
38#include "UILibraryDefs.h"
39
[64058]40/* Forward declarations: */
[101692]41class QSortFilterProxyModel;
[64081]42class UISelectorItem;
[101417]43class UISelectorModel;
44class UISelectorTreeView;
[64081]45class UISettingsPage;
[25177]46
[64058]47
48/** QObject subclass providing settings dialog
49 * with the means to switch between settings pages. */
[72102]50class SHARED_LIBRARY_STUFF UISettingsSelector : public QObject
[25177]51{
52 Q_OBJECT;
53
[64084]54signals:
55
56 /** Notifies listeners about selector @a iCategory changed. */
57 void sigCategoryChanged(int iCategory);
58
[25177]59public:
60
[64081]61 /** Constructs settings selector passing @a pParent to the base-class. */
62 UISettingsSelector(QWidget *pParent = 0);
[64058]63 /** Destructs settings selector. */
[93990]64 virtual ~UISettingsSelector() RT_OVERRIDE;
[25177]65
[64058]66 /** Returns the widget selector operates on. */
[25177]67 virtual QWidget *widget() const = 0;
68
[64058]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.
[64081]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;
[25177]79
[101693]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
[64081]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;
[25177]89
[64058]90 /** Returns the current selector ID. */
[64081]91 virtual int currentId() const = 0;
[64058]92
[64081]93 /** Returns the section ID for passed @a strLink. */
94 virtual int linkToId(const QString &strLink) const = 0;
[25177]95
[64081]96 /** Returns the section page for passed @a iID. */
97 virtual QWidget *idToPage(int iID) const;
[25177]98
[64081]99 /** Make the section with @a iID current. */
[102261]100 virtual void selectById(int iID, bool fSilently = false) = 0;
[64081]101 /** Make the section with @a strLink current. */
102 virtual void selectByLink(const QString &strLink) { selectById(linkToId(strLink)); }
[25177]103
[64058]104 /** Returns the list of all selector pages. */
[32814]105 virtual QList<UISettingsPage*> settingPages() const;
[25177]106
[64058]107 /** Performs selector polishing. */
[64081]108 virtual void polish() {}
[25177]109
[64058]110 /** Returns minimum selector width. */
[64081]111 virtual int minWidth() const { return 0; }
[25177]112
113protected:
114
[64081]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;
[25177]121
[64058]122 /** Holds the selector item instances. */
[64081]123 QList<UISelectorItem*> m_list;
[25177]124};
125
[64058]126
127/** UISettingsSelector subclass providing settings dialog
128 * with the means to switch between settings pages.
[101417]129 * This one represented as tree-view. */
130class SHARED_LIBRARY_STUFF UISettingsSelectorTreeView : public UISettingsSelector
131{
132 Q_OBJECT;
133
134public:
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
[101693]155 /** Defines whether section with @a iID is @a fVisible. */
156 virtual void setItemVisible(int iID, bool fVisible) RT_OVERRIDE;
157
[101417]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. */
[102261]170 virtual void selectById(int iID, bool fSilently) RT_OVERRIDE;
[101417]171
172private slots:
173
174 /** Handles selector section change from @a pPrevItem to @a pItem. */
175 void sltHandleCurrentChanged(const QModelIndex &current, const QModelIndex &previous);
176
177private:
178
179 /** Prepares all. */
180 void prepare();
181 /** Cleanups all. */
182 void cleanup();
183
184 /** Holds the tree-view instance. */
[101692]185 UISelectorTreeView *m_pTreeView;
[101691]186 /** Holds the model instance. */
[101692]187 UISelectorModel *m_pModel;
188 /** Holds the proxy-model instance. */
189 QSortFilterProxyModel *m_pModelProxy;
[101417]190};
191
192
[76581]193#endif /* !FEQT_INCLUDED_SRC_settings_UISettingsSelector_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette