Merge tag 'nfs-for-6.4-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
[linux-block.git] / scripts / kconfig / qconf.h
CommitLineData
0c874100 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
1da177e4
LT
4 */
5
cf81dfa4
MCC
6#include <QCheckBox>
7#include <QDialog>
68ccb7ef 8#include <QHeaderView>
cf81dfa4
MCC
9#include <QLineEdit>
10#include <QMainWindow>
68ccb7ef
BB
11#include <QPushButton>
12#include <QSettings>
68ccb7ef 13#include <QSplitter>
37162a68 14#include <QStyledItemDelegate>
cf81dfa4
MCC
15#include <QTextBrowser>
16#include <QTreeWidget>
17
68ccb7ef 18#include "expr.h"
133c5f7c 19
1019f1a5
BB
20class ConfigList;
21class ConfigItem;
1da177e4
LT
22class ConfigMainWindow;
23
1da177e4
LT
24class ConfigSettings : public QSettings {
25public:
00d4f8fc 26 ConfigSettings();
041fbdc2
BB
27 QList<int> readSizes(const QString& key, bool *ok);
28 bool writeSizes(const QString& key, const QList<int>& value);
1da177e4
LT
29};
30
31enum colIdx {
a0fce283 32 promptColIdx, nameColIdx, dataColIdx
1da177e4
LT
33};
34enum listMode {
43bf612a 35 singleMode, menuMode, symbolMode, fullMode, listMode
1da177e4 36};
39a4897c
LZ
37enum optionMode {
38 normalOpt = 0, allOpt, promptOpt
39};
1da177e4 40
1019f1a5
BB
41class ConfigList : public QTreeWidget {
42 Q_OBJECT
43 typedef class QTreeWidget Parent;
44public:
62ed1656 45 ConfigList(QWidget *parent, const char *name = 0);
f9b918fa 46 ~ConfigList();
59e56440 47 void reinit(void);
b06c3ec3 48 ConfigItem* findConfigItem(struct menu *);
b06c3ec3
MCC
49 void setSelected(QTreeWidgetItem *item, bool enable) {
50 for (int i = 0; i < selectedItems().size(); i++)
51 selectedItems().at(i)->setSelected(false);
52
53 item->setSelected(enable);
54 }
59e56440
BB
55
56protected:
57 void keyPressEvent(QKeyEvent *e);
d5d973c3
BB
58 void mousePressEvent(QMouseEvent *e);
59 void mouseReleaseEvent(QMouseEvent *e);
60 void mouseMoveEvent(QMouseEvent *e);
61 void mouseDoubleClickEvent(QMouseEvent *e);
59e56440
BB
62 void focusInEvent(QFocusEvent *e);
63 void contextMenuEvent(QContextMenuEvent *e);
64
65public slots:
66 void setRootMenu(struct menu *menu);
67
cb77043f 68 void updateList();
59e56440
BB
69 void setValue(ConfigItem* item, tristate val);
70 void changeValue(ConfigItem* item);
71 void updateSelection(void);
72 void saveSettings(void);
d4bbe8a1 73 void setOptionMode(QAction *action);
7930dd91 74 void setShowName(bool on);
d4bbe8a1 75
59e56440
BB
76signals:
77 void menuChanged(struct menu *menu);
78 void menuSelected(struct menu *menu);
b311142f 79 void itemSelected(struct menu *menu);
59e56440
BB
80 void parentSelected(void);
81 void gotFocus(struct menu *);
7930dd91 82 void showNameChanged(bool on);
59e56440
BB
83
84public:
85 void updateListAll(void)
86 {
87 updateAll = true;
cb77043f 88 updateList();
59e56440
BB
89 updateAll = false;
90 }
59e56440
BB
91 void setAllOpen(bool open);
92 void setParentMenu(void);
93
94 bool menuSkip(struct menu *);
95
5c6f1554 96 void updateMenuList(ConfigItem *parent, struct menu*);
5b75a6c8 97 void updateMenuList(struct menu *menu);
59e56440
BB
98
99 bool updateAll;
100
a0fce283 101 bool showName;
59e56440
BB
102 enum listMode mode;
103 enum optionMode optMode;
104 struct menu *rootEntry;
105 QPalette disabledColorGroup;
106 QPalette inactivedColorGroup;
107 QMenu* headerPopup;
d4bbe8a1 108
f9b918fa
MY
109 static QList<ConfigList *> allLists;
110 static void updateListForAll();
111 static void updateListAllForAll();
112
d4bbe8a1 113 static QAction *showNormalAction, *showAllAction, *showPromptAction;
1019f1a5
BB
114};
115
116class ConfigItem : public QTreeWidgetItem {
117 typedef class QTreeWidgetItem Parent;
118public:
d960b988 119 ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
86c05282 120 : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
1019f1a5
BB
121 {
122 init();
123 }
124 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
86c05282 125 : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
1019f1a5
BB
126 {
127 init();
128 }
d960b988 129 ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
86c05282 130 : Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
1019f1a5
BB
131 {
132 init();
133 }
134 ~ConfigItem(void);
135 void init(void);
59e56440
BB
136 void updateMenu(void);
137 void testUpdateMenu(bool v);
138 ConfigList* listView() const
139 {
140 return (ConfigList*)Parent::treeWidget();
141 }
142 ConfigItem* firstChild() const
143 {
144 return (ConfigItem *)Parent::child(0);
145 }
d5d973c3 146 ConfigItem* nextSibling()
59e56440 147 {
d5d973c3
BB
148 ConfigItem *ret = NULL;
149 ConfigItem *_parent = (ConfigItem *)parent();
150
151 if(_parent) {
b3c48f96 152 ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1);
d5d973c3 153 } else {
b3c48f96
BB
154 QTreeWidget *_treeWidget = treeWidget();
155 ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1);
d5d973c3
BB
156 }
157
158 return ret;
59e56440 159 }
d5d973c3 160 // TODO: Implement paintCell
1019f1a5
BB
161
162 ConfigItem* nextItem;
163 struct menu *menu;
164 bool visible;
165 bool goParent;
5cb255ff
MY
166
167 static QIcon symbolYesIcon, symbolModIcon, symbolNoIcon;
168 static QIcon choiceYesIcon, choiceNoIcon;
169 static QIcon menuIcon, menubackIcon;
1019f1a5
BB
170};
171
37162a68
MY
172class ConfigItemDelegate : public QStyledItemDelegate
173{
174private:
175 struct menu *menu;
176public:
177 ConfigItemDelegate(QObject *parent = nullptr)
178 : QStyledItemDelegate(parent) {}
179 QWidget *createEditor(QWidget *parent,
180 const QStyleOptionViewItem &option,
181 const QModelIndex &index) const override;
182 void setModelData(QWidget *editor, QAbstractItemModel *model,
183 const QModelIndex &index) const override;
184};
185
924bbb53 186class ConfigInfoView : public QTextBrowser {
43bf612a 187 Q_OBJECT
924bbb53 188 typedef class QTextBrowser Parent;
7d1300e6 189 QMenu *contextMenu;
43bf612a
RZ
190public:
191 ConfigInfoView(QWidget* parent, const char *name = 0);
192 bool showDebug(void) const { return _showDebug; }
193
194public slots:
195 void setInfo(struct menu *menu);
7fc925fd 196 void saveSettings(void);
43bf612a 197 void setShowDebug(bool);
c4f7398b 198 void clicked (const QUrl &url);
43bf612a
RZ
199
200signals:
201 void showDebugChanged(bool);
b65a47e1 202 void menuSelected(struct menu *);
43bf612a
RZ
203
204protected:
ab45d190 205 void symbolInfo(void);
43bf612a
RZ
206 void menuInfo(void);
207 QString debug_info(struct symbol *sym);
208 static QString print_filter(const QString &str);
ab45d190 209 static void expr_print_help(void *data, struct symbol *sym, const char *str);
7d1300e6 210 void contextMenuEvent(QContextMenuEvent *event);
43bf612a 211
ab45d190 212 struct symbol *sym;
133c5f7c 213 struct menu *_menu;
43bf612a
RZ
214 bool _showDebug;
215};
216
217class ConfigSearchWindow : public QDialog {
218 Q_OBJECT
219 typedef class QDialog Parent;
220public:
740fdef8 221 ConfigSearchWindow(ConfigMainWindow *parent);
7fc925fd 222
43bf612a 223public slots:
7fc925fd 224 void saveSettings(void);
43bf612a 225 void search(void);
7fc925fd 226
43bf612a
RZ
227protected:
228 QLineEdit* editField;
229 QPushButton* searchButton;
7fc925fd 230 QSplitter* split;
62ed1656 231 ConfigList *list;
43bf612a
RZ
232 ConfigInfoView* info;
233
234 struct symbol **result;
235};
236
b1f8a45b 237class ConfigMainWindow : public QMainWindow {
1da177e4 238 Q_OBJECT
3b354c55 239
8741908b 240 char *configname;
85eaf28a 241 static QAction *saveAction;
3b354c55 242 static void conf_changed(void);
1da177e4
LT
243public:
244 ConfigMainWindow(void);
245public slots:
1da177e4 246 void changeMenu(struct menu *);
b311142f 247 void changeItens(struct menu *);
b65a47e1 248 void setMenuLink(struct menu *);
1da177e4
LT
249 void listFocusChanged(void);
250 void goBack(void);
251 void loadConfig(void);
bac6aa86 252 bool saveConfig(void);
1da177e4 253 void saveConfigAs(void);
43bf612a 254 void searchConfig(void);
1da177e4
LT
255 void showSingleView(void);
256 void showSplitView(void);
257 void showFullView(void);
1da177e4
LT
258 void showIntro(void);
259 void showAbout(void);
260 void saveSettings(void);
261
262protected:
263 void closeEvent(QCloseEvent *e);
264
43bf612a 265 ConfigSearchWindow *searchWindow;
1019f1a5 266 ConfigList *menuList;
1019f1a5 267 ConfigList *configList;
43bf612a 268 ConfigInfoView *helpText;
85eaf28a 269 QAction *backAction;
780505e3
BB
270 QAction *singleViewAction;
271 QAction *splitViewAction;
272 QAction *fullViewAction;
76538660
BB
273 QSplitter *split1;
274 QSplitter *split2;
1da177e4 275};