1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt4 GUI ("VirtualBox"):
|
---|
4 | * VBoxSettingsSelector class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2008 Oracle Corporation
|
---|
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 |
|
---|
19 | #ifndef __VBoxSettingsSelector_h__
|
---|
20 | #define __VBoxSettingsSelector_h__
|
---|
21 |
|
---|
22 | /* Qt includes */
|
---|
23 | #include <QObject>
|
---|
24 |
|
---|
25 | class QITreeWidget;
|
---|
26 | class UIToolBar;
|
---|
27 | class UISettingsPage;
|
---|
28 | class SelectorItem;
|
---|
29 | class SelectorActionItem;
|
---|
30 |
|
---|
31 | class QTreeWidget;
|
---|
32 | class QTreeWidgetItem;
|
---|
33 | class QIcon;
|
---|
34 | class QAction;
|
---|
35 | class QActionGroup;
|
---|
36 | template <class Key, class T> class QMap;
|
---|
37 | class QTabWidget;
|
---|
38 |
|
---|
39 | class VBoxSettingsSelector: public QObject
|
---|
40 | {
|
---|
41 | Q_OBJECT;
|
---|
42 |
|
---|
43 | public:
|
---|
44 |
|
---|
45 | VBoxSettingsSelector (QWidget *aParent = NULL);
|
---|
46 | ~VBoxSettingsSelector();
|
---|
47 |
|
---|
48 | virtual QWidget *widget() const = 0;
|
---|
49 |
|
---|
50 | virtual QWidget *addItem (const QString &aBigIcon, const QString &aBigIconDisabled, const QString &aSmallIcon, const QString &aSmallIconDisabled, int aId, const QString &aLink, UISettingsPage* aPage = NULL, int aParentId = -1) = 0;
|
---|
51 |
|
---|
52 | virtual void setItemText (int aId, const QString &aText);
|
---|
53 | virtual QString itemText (int aId) const = 0;
|
---|
54 | virtual QString itemTextByPage (UISettingsPage *aPage) const;
|
---|
55 |
|
---|
56 | virtual int currentId () const = 0;
|
---|
57 | virtual int linkToId (const QString &aLink) const = 0;
|
---|
58 |
|
---|
59 | virtual QWidget *idToPage (int aId) const;
|
---|
60 | virtual QWidget *rootPage (int aId) const { return idToPage (aId); }
|
---|
61 |
|
---|
62 | virtual void selectById (int aId) = 0;
|
---|
63 | virtual void selectByLink (const QString &aLink) { selectById (linkToId (aLink)); }
|
---|
64 |
|
---|
65 | virtual void setVisibleById (int aId, bool aShow) = 0;
|
---|
66 |
|
---|
67 | virtual QList<UISettingsPage*> settingPages() const;
|
---|
68 | virtual QList<QWidget*> rootPages() const;
|
---|
69 |
|
---|
70 | virtual void polish() {};
|
---|
71 |
|
---|
72 | virtual int minWidth () const { return 0; }
|
---|
73 |
|
---|
74 | signals:
|
---|
75 |
|
---|
76 | void categoryChanged (int);
|
---|
77 |
|
---|
78 | protected:
|
---|
79 |
|
---|
80 | virtual void clear() = 0;
|
---|
81 |
|
---|
82 | SelectorItem* findItem (int aId) const;
|
---|
83 | SelectorItem* findItemByLink (const QString &aLink) const;
|
---|
84 | SelectorItem* findItemByPage (UISettingsPage* aPage) const;
|
---|
85 |
|
---|
86 | QList<SelectorItem*> mItemList;
|
---|
87 | };
|
---|
88 |
|
---|
89 | class VBoxSettingsTreeViewSelector: public VBoxSettingsSelector
|
---|
90 | {
|
---|
91 | Q_OBJECT;
|
---|
92 |
|
---|
93 | public:
|
---|
94 |
|
---|
95 | VBoxSettingsTreeViewSelector (QWidget *aParent = NULL);
|
---|
96 |
|
---|
97 | virtual QWidget *widget() const;
|
---|
98 |
|
---|
99 | virtual QWidget *addItem (const QString &aBigIcon, const QString &aBigIconDisabled, const QString &aSmallIcon, const QString &aSmallIconDisabled, int aId, const QString &aLink, UISettingsPage* aPage = NULL, int aParentId = -1);
|
---|
100 | virtual void setItemText (int aId, const QString &aText);
|
---|
101 | virtual QString itemText (int aId) const;
|
---|
102 |
|
---|
103 | virtual int currentId() const;
|
---|
104 | virtual int linkToId (const QString &aLink) const;
|
---|
105 |
|
---|
106 | virtual void selectById (int aId);
|
---|
107 |
|
---|
108 | virtual void setVisibleById (int aId, bool aShow);
|
---|
109 |
|
---|
110 | virtual void polish();
|
---|
111 |
|
---|
112 | private slots:
|
---|
113 |
|
---|
114 | void settingsGroupChanged (QTreeWidgetItem *aItem, QTreeWidgetItem *aPrevItem);
|
---|
115 |
|
---|
116 | private:
|
---|
117 |
|
---|
118 | virtual void clear();
|
---|
119 |
|
---|
120 | QString pagePath (const QString &aMatch) const;
|
---|
121 | QTreeWidgetItem* findItem (QTreeWidget *aView, const QString &aMatch, int aColumn) const;
|
---|
122 | QString idToString (int aId) const;
|
---|
123 |
|
---|
124 | /* Private member vars */
|
---|
125 | QITreeWidget *mTwSelector;
|
---|
126 | };
|
---|
127 |
|
---|
128 | class VBoxSettingsToolBarSelector: public VBoxSettingsSelector
|
---|
129 | {
|
---|
130 | Q_OBJECT;
|
---|
131 |
|
---|
132 | public:
|
---|
133 |
|
---|
134 | VBoxSettingsToolBarSelector (QWidget *aParent = NULL);
|
---|
135 | ~VBoxSettingsToolBarSelector();
|
---|
136 |
|
---|
137 | virtual QWidget *widget() const;
|
---|
138 |
|
---|
139 | virtual QWidget *addItem (const QString &aBigIcon, const QString &aBigIconDisabled, const QString &aSmallIcon, const QString &aSmallIconDisabled, int aId, const QString &aLink, UISettingsPage* aPage = NULL, int aParentId = -1);
|
---|
140 | virtual void setItemText (int aId, const QString &aText);
|
---|
141 | virtual QString itemText (int aId) const;
|
---|
142 |
|
---|
143 | virtual int currentId() const;
|
---|
144 | virtual int linkToId (const QString &aLink) const;
|
---|
145 |
|
---|
146 | virtual QWidget *idToPage (int aId) const;
|
---|
147 | virtual QWidget *rootPage (int aId) const;
|
---|
148 |
|
---|
149 | virtual void selectById (int aId);
|
---|
150 |
|
---|
151 | virtual void setVisibleById (int aId, bool aShow);
|
---|
152 |
|
---|
153 | virtual int minWidth() const;
|
---|
154 |
|
---|
155 | virtual QList<QWidget*> rootPages() const;
|
---|
156 | private slots:
|
---|
157 |
|
---|
158 | void settingsGroupChanged (QAction *aAction);
|
---|
159 | void settingsGroupChanged (int aIndex);
|
---|
160 |
|
---|
161 | private:
|
---|
162 |
|
---|
163 | virtual void clear();
|
---|
164 |
|
---|
165 | SelectorActionItem *findActionItem (int aId) const;
|
---|
166 | SelectorActionItem *findActionItemByAction (QAction *aAction) const;
|
---|
167 | SelectorActionItem *findActionItemByTabWidget (QTabWidget* aTabWidget, int aIndex) const;
|
---|
168 |
|
---|
169 | /* Private member vars */
|
---|
170 | UIToolBar *mTbSelector;
|
---|
171 | QActionGroup *mActionGroup;
|
---|
172 | };
|
---|
173 |
|
---|
174 | #endif /* __VBoxSettingsSelector_h__ */
|
---|
175 |
|
---|