Linux-2.6.12-rc2
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / scripts / kconfig / qconf.h
1 /*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6 #include <qlistview.h>
7 #if QT_VERSION >= 300
8 #include <qsettings.h>
9 #else
10 class QSettings { };
11 #endif
12
13 class ConfigList;
14 class ConfigItem;
15 class ConfigLineEdit;
16 class ConfigMainWindow;
17
18
19 class ConfigSettings : public QSettings {
20 public:
21 ConfigSettings();
22
23 #if QT_VERSION >= 300
24 void readListSettings();
25 QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok);
26 bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value);
27 #endif
28
29 bool showAll;
30 bool showName;
31 bool showRange;
32 bool showData;
33 };
34
35 class ConfigView : public QVBox {
36 Q_OBJECT
37 typedef class QVBox Parent;
38 public:
39 ConfigView(QWidget* parent, ConfigMainWindow* cview, ConfigSettings* configSettings);
40 ~ConfigView(void);
41 static void updateList(ConfigItem* item);
42 static void updateListAll(void);
43
44 public:
45 ConfigList* list;
46 ConfigLineEdit* lineEdit;
47
48 static ConfigView* viewList;
49 ConfigView* nextView;
50 };
51
52 enum colIdx {
53 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
54 };
55 enum listMode {
56 singleMode, menuMode, symbolMode, fullMode
57 };
58
59 class ConfigList : public QListView {
60 Q_OBJECT
61 typedef class QListView Parent;
62 public:
63 ConfigList(ConfigView* p, ConfigMainWindow* cview, ConfigSettings *configSettings);
64 void reinit(void);
65 ConfigView* parent(void) const
66 {
67 return (ConfigView*)Parent::parent();
68 }
69
70 protected:
71 ConfigMainWindow* cview;
72
73 void keyPressEvent(QKeyEvent *e);
74 void contentsMousePressEvent(QMouseEvent *e);
75 void contentsMouseReleaseEvent(QMouseEvent *e);
76 void contentsMouseMoveEvent(QMouseEvent *e);
77 void contentsMouseDoubleClickEvent(QMouseEvent *e);
78 void focusInEvent(QFocusEvent *e);
79 public slots:
80 void setRootMenu(struct menu *menu);
81
82 void updateList(ConfigItem *item);
83 void setValue(ConfigItem* item, tristate val);
84 void changeValue(ConfigItem* item);
85 void updateSelection(void);
86 signals:
87 void menuSelected(struct menu *menu);
88 void parentSelected(void);
89 void gotFocus(void);
90
91 public:
92 void updateListAll(void)
93 {
94 updateAll = true;
95 updateList(NULL);
96 updateAll = false;
97 }
98 ConfigList* listView()
99 {
100 return this;
101 }
102 ConfigItem* firstChild() const
103 {
104 return (ConfigItem *)Parent::firstChild();
105 }
106 int mapIdx(colIdx idx)
107 {
108 return colMap[idx];
109 }
110 void addColumn(colIdx idx, const QString& label)
111 {
112 colMap[idx] = Parent::addColumn(label);
113 colRevMap[colMap[idx]] = idx;
114 }
115 void removeColumn(colIdx idx)
116 {
117 int col = colMap[idx];
118 if (col >= 0) {
119 Parent::removeColumn(col);
120 colRevMap[col] = colMap[idx] = -1;
121 }
122 }
123 void setAllOpen(bool open);
124 void setParentMenu(void);
125
126 template <class P>
127 void ConfigList::updateMenuList(P*, struct menu*);
128
129 bool updateAll;
130
131 QPixmap symbolYesPix, symbolModPix, symbolNoPix;
132 QPixmap choiceYesPix, choiceNoPix;
133 QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
134
135 bool showAll, showName, showRange, showData;
136 enum listMode mode;
137 struct menu *rootEntry;
138 QColorGroup disabledColorGroup;
139 QColorGroup inactivedColorGroup;
140
141 private:
142 int colMap[colNr];
143 int colRevMap[colNr];
144 };
145
146 class ConfigItem : public QListViewItem {
147 typedef class QListViewItem Parent;
148 public:
149 ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v)
150 : Parent(parent, after), menu(m), visible(v), goParent(false)
151 {
152 init();
153 }
154 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
155 : Parent(parent, after), menu(m), visible(v), goParent(false)
156 {
157 init();
158 }
159 ConfigItem(QListView *parent, ConfigItem *after, bool v)
160 : Parent(parent, after), menu(0), visible(v), goParent(true)
161 {
162 init();
163 }
164 ~ConfigItem(void);
165 void init(void);
166 #if QT_VERSION >= 300
167 void okRename(int col);
168 #endif
169 void updateMenu(void);
170 void testUpdateMenu(bool v);
171 ConfigList* listView() const
172 {
173 return (ConfigList*)Parent::listView();
174 }
175 ConfigItem* firstChild() const
176 {
177 return (ConfigItem *)Parent::firstChild();
178 }
179 ConfigItem* nextSibling() const
180 {
181 return (ConfigItem *)Parent::nextSibling();
182 }
183 void setText(colIdx idx, const QString& text)
184 {
185 Parent::setText(listView()->mapIdx(idx), text);
186 }
187 QString text(colIdx idx) const
188 {
189 return Parent::text(listView()->mapIdx(idx));
190 }
191 void setPixmap(colIdx idx, const QPixmap& pm)
192 {
193 Parent::setPixmap(listView()->mapIdx(idx), pm);
194 }
195 const QPixmap* pixmap(colIdx idx) const
196 {
197 return Parent::pixmap(listView()->mapIdx(idx));
198 }
199 void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align);
200
201 ConfigItem* nextItem;
202 struct menu *menu;
203 bool visible;
204 bool goParent;
205 };
206
207 class ConfigLineEdit : public QLineEdit {
208 Q_OBJECT
209 typedef class QLineEdit Parent;
210 public:
211 ConfigLineEdit(ConfigView* parent)
212 : Parent(parent)
213 { }
214 ConfigView* parent(void) const
215 {
216 return (ConfigView*)Parent::parent();
217 }
218 void show(ConfigItem *i);
219 void keyPressEvent(QKeyEvent *e);
220
221 public:
222 ConfigItem *item;
223 };
224
225 class ConfigMainWindow : public QMainWindow {
226 Q_OBJECT
227 public:
228 ConfigMainWindow(void);
229 public slots:
230 void setHelp(QListViewItem* item);
231 void changeMenu(struct menu *);
232 void listFocusChanged(void);
233 void goBack(void);
234 void loadConfig(void);
235 void saveConfig(void);
236 void saveConfigAs(void);
237 void showSingleView(void);
238 void showSplitView(void);
239 void showFullView(void);
240 void setShowAll(bool);
241 void setShowDebug(bool);
242 void setShowRange(bool);
243 void setShowName(bool);
244 void setShowData(bool);
245 void showIntro(void);
246 void showAbout(void);
247 void saveSettings(void);
248
249 protected:
250 void closeEvent(QCloseEvent *e);
251
252 ConfigView *menuView;
253 ConfigList *menuList;
254 ConfigView *configView;
255 ConfigList *configList;
256 QTextView *helpText;
257 QToolBar *toolBar;
258 QAction *backAction;
259 QSplitter* split1;
260 QSplitter* split2;
261
262 bool showDebug;
263 };