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 SelectorAction;
|
---|
32 |
|
---|
33 | class QTreeWidget;
|
---|
34 | class QTreeWidgetItem;
|
---|
35 | class QIcon;
|
---|
36 | class QAction;
|
---|
37 | class QActionGroup;
|
---|
38 |
|
---|
39 | class VBoxSettingsSelector: public QObject
|
---|
40 | {
|
---|
41 | Q_OBJECT;
|
---|
42 |
|
---|
43 | public:
|
---|
44 |
|
---|
45 | VBoxSettingsSelector (QWidget *aParent = NULL);
|
---|
46 |
|
---|
47 | virtual QWidget *widget() const = 0;
|
---|
48 |
|
---|
49 | virtual void addItem (const QIcon &aIcon, const QString &aText, int aId, const QString &aLink) = 0;
|
---|
50 | virtual QString itemText (int aId) const = 0;
|
---|
51 | virtual QString itemTextByIndex (int aIndex) const { return itemText (indexToId (aIndex)); }
|
---|
52 |
|
---|
53 | virtual int currentId () const = 0;
|
---|
54 | virtual int idToIndex (int aId) const = 0;
|
---|
55 | virtual int indexToId (int aIndex) const = 0;
|
---|
56 | virtual int linkToId (const QString &aLink) const = 0;
|
---|
57 | virtual void selectById (int aId) = 0;
|
---|
58 | virtual void selectByLink (const QString &aLink) { selectById (linkToId (aLink)); }
|
---|
59 | virtual void setVisibleById (int aId, bool aShow) = 0;
|
---|
60 |
|
---|
61 | virtual void clear() = 0;
|
---|
62 |
|
---|
63 | virtual void polish() {};
|
---|
64 | virtual int minWidth () const { return 0; }
|
---|
65 |
|
---|
66 | signals:
|
---|
67 |
|
---|
68 | void categoryChanged (int);
|
---|
69 |
|
---|
70 | };
|
---|
71 |
|
---|
72 | class VBoxSettingsTreeViewSelector: public VBoxSettingsSelector
|
---|
73 | {
|
---|
74 | Q_OBJECT;
|
---|
75 |
|
---|
76 | public:
|
---|
77 |
|
---|
78 | VBoxSettingsTreeViewSelector (QWidget *aParent = NULL);
|
---|
79 |
|
---|
80 | virtual QWidget *widget() const;
|
---|
81 |
|
---|
82 | virtual void addItem (const QIcon &aIcon, const QString &aText, int aIndex, const QString &aLink);
|
---|
83 | virtual QString itemText (int aId) const;
|
---|
84 |
|
---|
85 | virtual int currentId() const;
|
---|
86 | virtual int idToIndex (int aId) const;
|
---|
87 | virtual int indexToId (int aIndex) const;
|
---|
88 | virtual int linkToId (const QString &aLink) const;
|
---|
89 | virtual void selectById (int aId);
|
---|
90 | virtual void setVisibleById (int aId, bool aShow);
|
---|
91 |
|
---|
92 | virtual void clear();
|
---|
93 |
|
---|
94 | virtual void polish();
|
---|
95 |
|
---|
96 | private slots:
|
---|
97 |
|
---|
98 | void settingsGroupChanged (QTreeWidgetItem *aItem, QTreeWidgetItem *aPrevItem);
|
---|
99 |
|
---|
100 | private:
|
---|
101 |
|
---|
102 | QString pagePath (const QString &aMatch) const;
|
---|
103 | QTreeWidgetItem* findItem (QTreeWidget *aView, const QString &aMatch, int aColumn) const;
|
---|
104 | QString idToString (int aId) const;
|
---|
105 |
|
---|
106 | /* Private member vars */
|
---|
107 | QITreeWidget *mTwSelector;
|
---|
108 | };
|
---|
109 |
|
---|
110 | class VBoxSettingsToolBarSelector: public VBoxSettingsSelector
|
---|
111 | {
|
---|
112 | Q_OBJECT;
|
---|
113 |
|
---|
114 | public:
|
---|
115 |
|
---|
116 | VBoxSettingsToolBarSelector (QWidget *aParent = NULL);
|
---|
117 |
|
---|
118 | virtual QWidget *widget() const;
|
---|
119 |
|
---|
120 | virtual void addItem (const QIcon &aIcon, const QString &aText, int aIndex, const QString &aLink);
|
---|
121 | virtual QString itemText (int aId) const;
|
---|
122 |
|
---|
123 | virtual int currentId() const;
|
---|
124 | virtual int idToIndex (int aId) const;
|
---|
125 | virtual int indexToId (int aIndex) const;
|
---|
126 | virtual int linkToId (const QString &aLink) const;
|
---|
127 | virtual void selectById (int aId);
|
---|
128 | virtual void setVisibleById (int aId, bool aShow);
|
---|
129 |
|
---|
130 | virtual void clear();
|
---|
131 |
|
---|
132 | virtual int minWidth() const;
|
---|
133 |
|
---|
134 | private slots:
|
---|
135 |
|
---|
136 | void settingsGroupChanged (QAction *aAction);
|
---|
137 |
|
---|
138 | private:
|
---|
139 |
|
---|
140 | SelectorAction* findAction (int aId) const;
|
---|
141 |
|
---|
142 | /* Private member vars */
|
---|
143 | VBoxToolBar *mTbSelector;
|
---|
144 | QActionGroup *mActionGroup;
|
---|
145 | };
|
---|
146 |
|
---|
147 | #endif /* __VBoxSettingsSelector_h__ */
|
---|