Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs into...
[linux-2.6-microblaze.git] / scripts / kconfig / qconf.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4  */
5
6 #include <QCheckBox>
7 #include <QDialog>
8 #include <QHeaderView>
9 #include <QLineEdit>
10 #include <QMainWindow>
11 #include <QPushButton>
12 #include <QSettings>
13 #include <QSplitter>
14 #include <QTextBrowser>
15 #include <QTreeWidget>
16
17 #include "expr.h"
18
19 class ConfigView;
20 class ConfigList;
21 class ConfigItem;
22 class ConfigLineEdit;
23 class ConfigMainWindow;
24
25 class ConfigSettings : public QSettings {
26 public:
27         ConfigSettings();
28         QList<int> readSizes(const QString& key, bool *ok);
29         bool writeSizes(const QString& key, const QList<int>& value);
30 };
31
32 enum colIdx {
33         promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
34 };
35 enum listMode {
36         singleMode, menuMode, symbolMode, fullMode, listMode
37 };
38 enum optionMode {
39         normalOpt = 0, allOpt, promptOpt
40 };
41
42 class ConfigList : public QTreeWidget {
43         Q_OBJECT
44         typedef class QTreeWidget Parent;
45 public:
46         ConfigList(ConfigView* p, const char *name = 0);
47         void reinit(void);
48         ConfigItem* findConfigItem(struct menu *);
49         ConfigView* parent(void) const
50         {
51                 return (ConfigView*)Parent::parent();
52         }
53         void setSelected(QTreeWidgetItem *item, bool enable) {
54                 for (int i = 0; i < selectedItems().size(); i++)
55                         selectedItems().at(i)->setSelected(false);
56
57                 item->setSelected(enable);
58         }
59
60 protected:
61         void keyPressEvent(QKeyEvent *e);
62         void mousePressEvent(QMouseEvent *e);
63         void mouseReleaseEvent(QMouseEvent *e);
64         void mouseMoveEvent(QMouseEvent *e);
65         void mouseDoubleClickEvent(QMouseEvent *e);
66         void focusInEvent(QFocusEvent *e);
67         void contextMenuEvent(QContextMenuEvent *e);
68
69 public slots:
70         void setRootMenu(struct menu *menu);
71
72         void updateList(ConfigItem *item);
73         void setValue(ConfigItem* item, tristate val);
74         void changeValue(ConfigItem* item);
75         void updateSelection(void);
76         void saveSettings(void);
77 signals:
78         void menuChanged(struct menu *menu);
79         void menuSelected(struct menu *menu);
80         void itemSelected(struct menu *menu);
81         void parentSelected(void);
82         void gotFocus(struct menu *);
83
84 public:
85         void updateListAll(void)
86         {
87                 updateAll = true;
88                 updateList(NULL);
89                 updateAll = false;
90         }
91         ConfigList* listView()
92         {
93                 return this;
94         }
95         ConfigItem* firstChild() const
96         {
97                 return (ConfigItem *)children().first();
98         }
99         void addColumn(colIdx idx)
100         {
101                 showColumn(idx);
102         }
103         void removeColumn(colIdx idx)
104         {
105                 hideColumn(idx);
106         }
107         void setAllOpen(bool open);
108         void setParentMenu(void);
109
110         bool menuSkip(struct menu *);
111
112         void updateMenuList(ConfigItem *parent, struct menu*);
113         void updateMenuList(ConfigList *parent, struct menu*);
114
115         bool updateAll;
116
117         QPixmap symbolYesPix, symbolModPix, symbolNoPix;
118         QPixmap choiceYesPix, choiceNoPix;
119         QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
120
121         bool showName, showRange, showData;
122         enum listMode mode;
123         enum optionMode optMode;
124         struct menu *rootEntry;
125         QPalette disabledColorGroup;
126         QPalette inactivedColorGroup;
127         QMenu* headerPopup;
128 };
129
130 class ConfigItem : public QTreeWidgetItem {
131         typedef class QTreeWidgetItem Parent;
132 public:
133         ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
134         : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
135         {
136                 init();
137         }
138         ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
139         : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
140         {
141                 init();
142         }
143         ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
144         : Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
145         {
146                 init();
147         }
148         ~ConfigItem(void);
149         void init(void);
150         void okRename(int col);
151         void updateMenu(void);
152         void testUpdateMenu(bool v);
153         ConfigList* listView() const
154         {
155                 return (ConfigList*)Parent::treeWidget();
156         }
157         ConfigItem* firstChild() const
158         {
159                 return (ConfigItem *)Parent::child(0);
160         }
161         ConfigItem* nextSibling()
162         {
163                 ConfigItem *ret = NULL;
164                 ConfigItem *_parent = (ConfigItem *)parent();
165
166                 if(_parent) {
167                         ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1);
168                 } else {
169                         QTreeWidget *_treeWidget = treeWidget();
170                         ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1);
171                 }
172
173                 return ret;
174         }
175         void setText(colIdx idx, const QString& text)
176         {
177                 Parent::setText(idx, text);
178         }
179         QString text(colIdx idx) const
180         {
181                 return Parent::text(idx);
182         }
183         void setPixmap(colIdx idx, const QIcon &icon)
184         {
185                 Parent::setIcon(idx, icon);
186         }
187         const QIcon pixmap(colIdx idx) const
188         {
189                 return icon(idx);
190         }
191         // TODO: Implement paintCell
192
193         ConfigItem* nextItem;
194         struct menu *menu;
195         bool visible;
196         bool goParent;
197 };
198
199 class ConfigLineEdit : public QLineEdit {
200         Q_OBJECT
201         typedef class QLineEdit Parent;
202 public:
203         ConfigLineEdit(ConfigView* parent);
204         ConfigView* parent(void) const
205         {
206                 return (ConfigView*)Parent::parent();
207         }
208         void show(ConfigItem *i);
209         void keyPressEvent(QKeyEvent *e);
210
211 public:
212         ConfigItem *item;
213 };
214
215 class ConfigView : public QWidget {
216         Q_OBJECT
217         typedef class QWidget Parent;
218 public:
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 showName(void) const { return list->showName; }
225         bool showRange(void) const { return list->showRange; }
226         bool showData(void) const { return list->showData; }
227 public slots:
228         void setShowName(bool);
229         void setShowRange(bool);
230         void setShowData(bool);
231         void setOptionMode(QAction *);
232 signals:
233         void showNameChanged(bool);
234         void showRangeChanged(bool);
235         void showDataChanged(bool);
236 public:
237         ConfigList* list;
238         ConfigLineEdit* lineEdit;
239
240         static ConfigView* viewList;
241         ConfigView* nextView;
242
243         static QAction *showNormalAction;
244         static QAction *showAllAction;
245         static QAction *showPromptAction;
246 };
247
248 class ConfigInfoView : public QTextBrowser {
249         Q_OBJECT
250         typedef class QTextBrowser Parent;
251 public:
252         ConfigInfoView(QWidget* parent, const char *name = 0);
253         bool showDebug(void) const { return _showDebug; }
254
255 public slots:
256         void setInfo(struct menu *menu);
257         void saveSettings(void);
258         void setShowDebug(bool);
259         void clicked (const QUrl &url);
260
261 signals:
262         void showDebugChanged(bool);
263         void menuSelected(struct menu *);
264
265 protected:
266         void symbolInfo(void);
267         void menuInfo(void);
268         QString debug_info(struct symbol *sym);
269         static QString print_filter(const QString &str);
270         static void expr_print_help(void *data, struct symbol *sym, const char *str);
271         QMenu *createStandardContextMenu(const QPoint & pos);
272         void contextMenuEvent(QContextMenuEvent *e);
273
274         struct symbol *sym;
275         struct menu *_menu;
276         bool _showDebug;
277 };
278
279 class ConfigSearchWindow : public QDialog {
280         Q_OBJECT
281         typedef class QDialog Parent;
282 public:
283         ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0);
284
285 public slots:
286         void saveSettings(void);
287         void search(void);
288
289 protected:
290         QLineEdit* editField;
291         QPushButton* searchButton;
292         QSplitter* split;
293         ConfigView* list;
294         ConfigInfoView* info;
295
296         struct symbol **result;
297 };
298
299 class ConfigMainWindow : public QMainWindow {
300         Q_OBJECT
301
302         char *configname;
303         static QAction *saveAction;
304         static void conf_changed(void);
305 public:
306         ConfigMainWindow(void);
307 public slots:
308         void changeMenu(struct menu *);
309         void changeItens(struct menu *);
310         void setMenuLink(struct menu *);
311         void listFocusChanged(void);
312         void goBack(void);
313         void loadConfig(void);
314         bool saveConfig(void);
315         void saveConfigAs(void);
316         void searchConfig(void);
317         void showSingleView(void);
318         void showSplitView(void);
319         void showFullView(void);
320         void showIntro(void);
321         void showAbout(void);
322         void saveSettings(void);
323
324 protected:
325         void closeEvent(QCloseEvent *e);
326
327         ConfigSearchWindow *searchWindow;
328         ConfigView *menuView;
329         ConfigList *menuList;
330         ConfigView *configView;
331         ConfigList *configList;
332         ConfigInfoView *helpText;
333         QToolBar *toolBar;
334         QAction *backAction;
335         QAction *singleViewAction;
336         QAction *splitViewAction;
337         QAction *fullViewAction;
338         QSplitter *split1;
339         QSplitter *split2;
340 };