kconfig: finer customization via popup menus
[deliverable/linux.git] / scripts / kconfig / qconf.h
CommitLineData
1da177e4
LT
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
7fc925fd
RZ
10class QSettings {
11public:
12 void beginGroup(const QString& group) { }
13 void endGroup(void) { }
14 bool readBoolEntry(const QString& key, bool def = FALSE, bool* ok = 0) const
15 { if (ok) *ok = FALSE; return def; }
16 int readNumEntry(const QString& key, int def = 0, bool* ok = 0) const
17 { if (ok) *ok = FALSE; return def; }
18 QString readEntry(const QString& key, const QString& def = QString::null, bool* ok = 0) const
19 { if (ok) *ok = FALSE; return def; }
20 QStringList readListEntry(const QString& key, bool* ok = 0) const
21 { if (ok) *ok = FALSE; return QStringList(); }
22 template <class t>
23 bool writeEntry(const QString& key, t value)
24 { return TRUE; }
25};
1da177e4
LT
26#endif
27
7fc925fd 28class ConfigView;
1da177e4
LT
29class ConfigList;
30class ConfigItem;
31class ConfigLineEdit;
32class ConfigMainWindow;
33
34
35class ConfigSettings : public QSettings {
36public:
19144d0b
DJ
37 QValueList<int> readSizes(const QString& key, bool *ok);
38 bool writeSizes(const QString& key, const QValueList<int>& value);
1da177e4
LT
39};
40
41enum colIdx {
42 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
43};
44enum listMode {
43bf612a 45 singleMode, menuMode, symbolMode, fullMode, listMode
1da177e4
LT
46};
47
48class ConfigList : public QListView {
49 Q_OBJECT
50 typedef class QListView Parent;
51public:
7fc925fd 52 ConfigList(ConfigView* p, const char *name = 0);
1da177e4
LT
53 void reinit(void);
54 ConfigView* parent(void) const
55 {
56 return (ConfigView*)Parent::parent();
57 }
58
59protected:
1da177e4
LT
60 void keyPressEvent(QKeyEvent *e);
61 void contentsMousePressEvent(QMouseEvent *e);
62 void contentsMouseReleaseEvent(QMouseEvent *e);
63 void contentsMouseMoveEvent(QMouseEvent *e);
64 void contentsMouseDoubleClickEvent(QMouseEvent *e);
65 void focusInEvent(QFocusEvent *e);
7fc925fd
RZ
66 void contextMenuEvent(QContextMenuEvent *e);
67
1da177e4
LT
68public slots:
69 void setRootMenu(struct menu *menu);
70
71 void updateList(ConfigItem *item);
72 void setValue(ConfigItem* item, tristate val);
73 void changeValue(ConfigItem* item);
74 void updateSelection(void);
7fc925fd 75 void saveSettings(void);
1da177e4 76signals:
43bf612a 77 void menuChanged(struct menu *menu);
1da177e4
LT
78 void menuSelected(struct menu *menu);
79 void parentSelected(void);
80 void gotFocus(void);
81
82public:
83 void updateListAll(void)
84 {
85 updateAll = true;
86 updateList(NULL);
87 updateAll = false;
88 }
89 ConfigList* listView()
90 {
91 return this;
92 }
93 ConfigItem* firstChild() const
94 {
95 return (ConfigItem *)Parent::firstChild();
96 }
97 int mapIdx(colIdx idx)
98 {
99 return colMap[idx];
100 }
101 void addColumn(colIdx idx, const QString& label)
102 {
103 colMap[idx] = Parent::addColumn(label);
104 colRevMap[colMap[idx]] = idx;
105 }
106 void removeColumn(colIdx idx)
107 {
108 int col = colMap[idx];
109 if (col >= 0) {
110 Parent::removeColumn(col);
111 colRevMap[col] = colMap[idx] = -1;
112 }
113 }
114 void setAllOpen(bool open);
115 void setParentMenu(void);
116
117 template <class P>
19144d0b 118 void updateMenuList(P*, struct menu*);
1da177e4
LT
119
120 bool updateAll;
121
122 QPixmap symbolYesPix, symbolModPix, symbolNoPix;
123 QPixmap choiceYesPix, choiceNoPix;
124 QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
125
126 bool showAll, showName, showRange, showData;
127 enum listMode mode;
128 struct menu *rootEntry;
129 QColorGroup disabledColorGroup;
130 QColorGroup inactivedColorGroup;
7fc925fd 131 QPopupMenu* headerPopup;
1da177e4
LT
132
133private:
134 int colMap[colNr];
135 int colRevMap[colNr];
136};
137
138class ConfigItem : public QListViewItem {
139 typedef class QListViewItem Parent;
140public:
141 ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v)
142 : Parent(parent, after), menu(m), visible(v), goParent(false)
143 {
144 init();
145 }
146 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
147 : Parent(parent, after), menu(m), visible(v), goParent(false)
148 {
149 init();
150 }
151 ConfigItem(QListView *parent, ConfigItem *after, bool v)
152 : Parent(parent, after), menu(0), visible(v), goParent(true)
153 {
154 init();
155 }
156 ~ConfigItem(void);
157 void init(void);
158#if QT_VERSION >= 300
159 void okRename(int col);
160#endif
161 void updateMenu(void);
162 void testUpdateMenu(bool v);
163 ConfigList* listView() const
164 {
165 return (ConfigList*)Parent::listView();
166 }
167 ConfigItem* firstChild() const
168 {
169 return (ConfigItem *)Parent::firstChild();
170 }
171 ConfigItem* nextSibling() const
172 {
173 return (ConfigItem *)Parent::nextSibling();
174 }
175 void setText(colIdx idx, const QString& text)
176 {
177 Parent::setText(listView()->mapIdx(idx), text);
178 }
179 QString text(colIdx idx) const
180 {
181 return Parent::text(listView()->mapIdx(idx));
182 }
183 void setPixmap(colIdx idx, const QPixmap& pm)
184 {
185 Parent::setPixmap(listView()->mapIdx(idx), pm);
186 }
187 const QPixmap* pixmap(colIdx idx) const
188 {
189 return Parent::pixmap(listView()->mapIdx(idx));
190 }
191 void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align);
192
193 ConfigItem* nextItem;
194 struct menu *menu;
195 bool visible;
196 bool goParent;
197};
198
199class ConfigLineEdit : public QLineEdit {
200 Q_OBJECT
201 typedef class QLineEdit Parent;
202public:
43bf612a 203 ConfigLineEdit(ConfigView* parent);
1da177e4
LT
204 ConfigView* parent(void) const
205 {
206 return (ConfigView*)Parent::parent();
207 }
208 void show(ConfigItem *i);
209 void keyPressEvent(QKeyEvent *e);
210
211public:
212 ConfigItem *item;
213};
214
7fc925fd
RZ
215class ConfigView : public QVBox {
216 Q_OBJECT
217 typedef class QVBox Parent;
218public:
219 ConfigView(QWidget* parent, const char *name = 0);
220 ~ConfigView(void);
221 static void updateList(ConfigItem* item);
222 static void updateListAll(void);
223
224 bool showAll(void) const { return list->showAll; }
225 bool showName(void) const { return list->showName; }
226 bool showRange(void) const { return list->showRange; }
227 bool showData(void) const { return list->showData; }
228public slots:
229 void setShowAll(bool);
230 void setShowName(bool);
231 void setShowRange(bool);
232 void setShowData(bool);
233signals:
234 void showAllChanged(bool);
235 void showNameChanged(bool);
236 void showRangeChanged(bool);
237 void showDataChanged(bool);
238public:
239 ConfigList* list;
240 ConfigLineEdit* lineEdit;
241
242 static ConfigView* viewList;
243 ConfigView* nextView;
244};
245
43bf612a
RZ
246class ConfigInfoView : public QTextBrowser {
247 Q_OBJECT
248 typedef class QTextBrowser Parent;
249public:
250 ConfigInfoView(QWidget* parent, const char *name = 0);
251 bool showDebug(void) const { return _showDebug; }
252
253public slots:
254 void setInfo(struct menu *menu);
7fc925fd 255 void saveSettings(void);
43bf612a
RZ
256 void setSource(const QString& name);
257 void setShowDebug(bool);
258
259signals:
260 void showDebugChanged(bool);
261
262protected:
263 void menuInfo(void);
264 QString debug_info(struct symbol *sym);
265 static QString print_filter(const QString &str);
266 static void expr_print_help(void *data, const char *str);
7fc925fd
RZ
267 QPopupMenu* createPopupMenu(const QPoint& pos);
268 void contentsContextMenuEvent(QContextMenuEvent *e);
43bf612a
RZ
269
270 struct menu *menu;
271 bool _showDebug;
272};
273
274class ConfigSearchWindow : public QDialog {
275 Q_OBJECT
276 typedef class QDialog Parent;
277public:
7fc925fd
RZ
278 ConfigSearchWindow(QWidget* parent, const char *name = 0);
279
43bf612a 280public slots:
7fc925fd 281 void saveSettings(void);
43bf612a 282 void search(void);
7fc925fd 283
43bf612a
RZ
284protected:
285 QLineEdit* editField;
286 QPushButton* searchButton;
7fc925fd 287 QSplitter* split;
43bf612a
RZ
288 ConfigView* list;
289 ConfigInfoView* info;
290
291 struct symbol **result;
292};
293
1da177e4
LT
294class ConfigMainWindow : public QMainWindow {
295 Q_OBJECT
296public:
297 ConfigMainWindow(void);
298public slots:
299 void setHelp(QListViewItem* item);
300 void changeMenu(struct menu *);
301 void listFocusChanged(void);
302 void goBack(void);
303 void loadConfig(void);
304 void saveConfig(void);
305 void saveConfigAs(void);
43bf612a 306 void searchConfig(void);
1da177e4
LT
307 void showSingleView(void);
308 void showSplitView(void);
309 void showFullView(void);
1da177e4
LT
310 void showIntro(void);
311 void showAbout(void);
312 void saveSettings(void);
313
314protected:
315 void closeEvent(QCloseEvent *e);
316
43bf612a 317 ConfigSearchWindow *searchWindow;
1da177e4
LT
318 ConfigView *menuView;
319 ConfigList *menuList;
320 ConfigView *configView;
321 ConfigList *configList;
43bf612a 322 ConfigInfoView *helpText;
1da177e4
LT
323 QToolBar *toolBar;
324 QAction *backAction;
325 QSplitter* split1;
326 QSplitter* split2;
1da177e4 327};
This page took 0.138428 seconds and 5 git commands to generate.