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