1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt4 GUI ("VirtualBox"):
|
---|
4 | * VBoxSettingsSelector class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2008 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | * additional information or have any questions.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef __VBoxSettingsSelector_h__
|
---|
24 | #define __VBoxSettingsSelector_h__
|
---|
25 |
|
---|
26 | /* Qt includes */
|
---|
27 | #include <QObject>
|
---|
28 |
|
---|
29 | class QITreeWidget;
|
---|
30 | class VBoxToolBar;
|
---|
31 | class VBoxSettingsPage;
|
---|
32 | class SelectorItem;
|
---|
33 | class SelectorActionItem;
|
---|
34 |
|
---|
35 | class QTreeWidget;
|
---|
36 | class QTreeWidgetItem;
|
---|
37 | class QIcon;
|
---|
38 | class QAction;
|
---|
39 | class QActionGroup;
|
---|
40 | template <class Key, class T> class QMap;
|
---|
41 | class QTabWidget;
|
---|
42 |
|
---|
43 | class VBoxSettingsSelector: public QObject
|
---|
44 | {
|
---|
45 | Q_OBJECT;
|
---|
46 |
|
---|
47 | public:
|
---|
48 |
|
---|
49 | VBoxSettingsSelector (QWidget *aParent = NULL);
|
---|
50 |
|
---|
51 | virtual QWidget *widget() const = 0;
|
---|
52 |
|
---|
53 | virtual QWidget *addItem (const QIcon &aIcon, int aId, const QString &aLink, VBoxSettingsPage* aPage = NULL, int aParentId = -1) = 0;
|
---|
54 |
|
---|
55 | virtual void setItemText (int aId, const QString &aText);
|
---|
56 | virtual QString itemText (int aId) const = 0;
|
---|
57 | virtual QString itemTextByPage (VBoxSettingsPage *aPage) const;
|
---|
58 |
|
---|
59 | virtual int currentId () const = 0;
|
---|
60 | virtual int linkToId (const QString &aLink) const = 0;
|
---|
61 |
|
---|
62 | virtual QWidget *idToPage (int aId) const;
|
---|
63 | virtual QWidget *rootPage (int aId) const { return idToPage (aId); }
|
---|
64 |
|
---|
65 | virtual void selectById (int aId) = 0;
|
---|
66 | virtual void selectByLink (const QString &aLink) { selectById (linkToId (aLink)); }
|
---|
67 |
|
---|
68 | virtual void setVisibleById (int aId, bool aShow) = 0;
|
---|
69 |
|
---|
70 | virtual QList<VBoxSettingsPage*> settingPages() const;
|
---|
71 | virtual QList<QWidget*> rootPages() const;
|
---|
72 |
|
---|
73 | virtual void polish() {};
|
---|
74 |
|
---|
75 | virtual int minWidth () const { return 0; }
|
---|
76 |
|
---|
77 | signals:
|
---|
78 |
|
---|
79 | void categoryChanged (int);
|
---|
80 |
|
---|
81 | protected:
|
---|
82 |
|
---|
83 | virtual void clear() = 0;
|
---|
84 |
|
---|
85 | SelectorItem* findItem (int aId) const;
|
---|
86 | SelectorItem* findItemByLink (const QString &aLink) const;
|
---|
87 | SelectorItem* findItemByPage (VBoxSettingsPage* aPage) const;
|
---|
88 |
|
---|
89 | QList<SelectorItem*> mItemList;
|
---|
90 | };
|
---|
91 |
|
---|
92 | class VBoxSettingsTreeViewSelector: public VBoxSettingsSelector
|
---|
93 | {
|
---|
94 | Q_OBJECT;
|
---|
95 |
|
---|
96 | public:
|
---|
97 |
|
---|
98 | VBoxSettingsTreeViewSelector (QWidget *aParent = NULL);
|
---|
99 |
|
---|
100 | virtual QWidget *widget() const;
|
---|
101 |
|
---|
102 | virtual QWidget *addItem (const QIcon &aIcon, int aId, const QString &aLink, VBoxSettingsPage* aPage = NULL, int aParentId = -1);
|
---|
103 | virtual void setItemText (int aId, const QString &aText);
|
---|
104 | virtual QString itemText (int aId) const;
|
---|
105 |
|
---|
106 | virtual int currentId() const;
|
---|
107 | virtual int linkToId (const QString &aLink) const;
|
---|
108 |
|
---|
109 | virtual void selectById (int aId);
|
---|
110 |
|
---|
111 | virtual void setVisibleById (int aId, bool aShow);
|
---|
112 |
|
---|
113 | virtual void polish();
|
---|
114 |
|
---|
115 | private slots:
|
---|
116 |
|
---|
117 | void settingsGroupChanged (QTreeWidgetItem *aItem, QTreeWidgetItem *aPrevItem);
|
---|
118 |
|
---|
119 | private:
|
---|
120 |
|
---|
121 | virtual void clear();
|
---|
122 |
|
---|
123 | QString pagePath (const QString &aMatch) const;
|
---|
124 | QTreeWidgetItem* findItem (QTreeWidget *aView, const QString &aMatch, int aColumn) const;
|
---|
125 | QString idToString (int aId) const;
|
---|
126 |
|
---|
127 | /* Private member vars */
|
---|
128 | QITreeWidget *mTwSelector;
|
---|
129 | };
|
---|
130 |
|
---|
131 | class VBoxSettingsToolBarSelector: public VBoxSettingsSelector
|
---|
132 | {
|
---|
133 | Q_OBJECT;
|
---|
134 |
|
---|
135 | public:
|
---|
136 |
|
---|
137 | VBoxSettingsToolBarSelector (QWidget *aParent = NULL);
|
---|
138 | ~VBoxSettingsToolBarSelector();
|
---|
139 |
|
---|
140 | virtual QWidget *widget() const;
|
---|
141 |
|
---|
142 | virtual QWidget *addItem (const QIcon &aIcon, int aId, const QString &aLink, VBoxSettingsPage* aPage = NULL, int aParentId = -1);
|
---|
143 | virtual void setItemText (int aId, const QString &aText);
|
---|
144 | virtual QString itemText (int aId) const;
|
---|
145 |
|
---|
146 | virtual int currentId() const;
|
---|
147 | virtual int linkToId (const QString &aLink) const;
|
---|
148 |
|
---|
149 | virtual QWidget *idToPage (int aId) const;
|
---|
150 | virtual QWidget *rootPage (int aId) const;
|
---|
151 |
|
---|
152 | virtual void selectById (int aId);
|
---|
153 |
|
---|
154 | virtual void setVisibleById (int aId, bool aShow);
|
---|
155 |
|
---|
156 | virtual int minWidth() const;
|
---|
157 |
|
---|
158 | virtual QList<QWidget*> rootPages() const;
|
---|
159 | private slots:
|
---|
160 |
|
---|
161 | void settingsGroupChanged (QAction *aAction);
|
---|
162 | void settingsGroupChanged (int aIndex);
|
---|
163 |
|
---|
164 | private:
|
---|
165 |
|
---|
166 | virtual void clear();
|
---|
167 |
|
---|
168 | SelectorActionItem *findActionItem (int aId) const;
|
---|
169 | SelectorActionItem *findActionItemByAction (QAction *aAction) const;
|
---|
170 | SelectorActionItem *findActionItemByTabWidget (QTabWidget* aTabWidget, int aIndex) const;
|
---|
171 |
|
---|
172 | /* Private member vars */
|
---|
173 | VBoxToolBar *mTbSelector;
|
---|
174 | QActionGroup *mActionGroup;
|
---|
175 | };
|
---|
176 |
|
---|
177 | #endif /* __VBoxSettingsSelector_h__ */
|
---|