Blame view

scripts/kconfig/qconf.h 6.4 KB
0c8741001   Masahiro Yamada   kconfig: convert ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
  /*
   * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
   */
cf81dfa47   Mauro Carvalho Chehab   kconfig: qconf: c...
5
6
  #include <QCheckBox>
  #include <QDialog>
68ccb7ef4   Boris Barbulovski   Port xconfig to Q...
7
  #include <QHeaderView>
cf81dfa47   Mauro Carvalho Chehab   kconfig: qconf: c...
8
9
  #include <QLineEdit>
  #include <QMainWindow>
68ccb7ef4   Boris Barbulovski   Port xconfig to Q...
10
11
  #include <QPushButton>
  #include <QSettings>
68ccb7ef4   Boris Barbulovski   Port xconfig to Q...
12
  #include <QSplitter>
37162a68b   Masahiro Yamada   kconfig: qconf: a...
13
  #include <QStyledItemDelegate>
cf81dfa47   Mauro Carvalho Chehab   kconfig: qconf: c...
14
15
  #include <QTextBrowser>
  #include <QTreeWidget>
68ccb7ef4   Boris Barbulovski   Port xconfig to Q...
16
  #include "expr.h"
133c5f7c1   Alexander Stein   kconfig qconf: po...
17

1019f1a58   Boris Barbulovski   Port xconfig to Q...
18
19
  class ConfigList;
  class ConfigItem;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
20
  class ConfigMainWindow;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
22
  class ConfigSettings : public QSettings {
  public:
00d4f8fc2   Ben Hutchings   xconfig: Fix the ...
23
  	ConfigSettings();
041fbdc21   Boris Barbulovski   Port xconfig to Q...
24
25
  	QList<int> readSizes(const QString& key, bool *ok);
  	bool writeSizes(const QString& key, const QList<int>& value);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
27
28
  };
  
  enum colIdx {
a0fce2833   Masahiro Yamada   kconfig: qconf: r...
29
  	promptColIdx, nameColIdx, dataColIdx
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30
31
  };
  enum listMode {
43bf612af   Roman Zippel   kconfig: Add sear...
32
  	singleMode, menuMode, symbolMode, fullMode, listMode
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33
  };
39a4897c1   Li Zefan   xconfig: add supp...
34
35
36
  enum optionMode {
  	normalOpt = 0, allOpt, promptOpt
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37

1019f1a58   Boris Barbulovski   Port xconfig to Q...
38
39
40
41
  class ConfigList : public QTreeWidget {
  	Q_OBJECT
  	typedef class QTreeWidget Parent;
  public:
62ed16565   Masahiro Yamada   kconfig: qconf: r...
42
  	ConfigList(QWidget *parent, const char *name = 0);
f9b918fae   Masahiro Yamada   kconfig: qconf: m...
43
  	~ConfigList();
59e564408   Boris Barbulovski   Port xconfig to Q...
44
  	void reinit(void);
b06c3ec3b   Mauro Carvalho Chehab   kconfig: qconf: r...
45
  	ConfigItem* findConfigItem(struct menu *);
b06c3ec3b   Mauro Carvalho Chehab   kconfig: qconf: r...
46
47
48
49
50
51
  	void setSelected(QTreeWidgetItem *item, bool enable) {
  		for (int i = 0; i < selectedItems().size(); i++)
  			selectedItems().at(i)->setSelected(false);
  
  		item->setSelected(enable);
  	}
59e564408   Boris Barbulovski   Port xconfig to Q...
52
53
54
  
  protected:
  	void keyPressEvent(QKeyEvent *e);
d5d973c3f   Boris Barbulovski   Port xconfig to Q...
55
56
57
58
  	void mousePressEvent(QMouseEvent *e);
  	void mouseReleaseEvent(QMouseEvent *e);
  	void mouseMoveEvent(QMouseEvent *e);
  	void mouseDoubleClickEvent(QMouseEvent *e);
59e564408   Boris Barbulovski   Port xconfig to Q...
59
60
61
62
63
  	void focusInEvent(QFocusEvent *e);
  	void contextMenuEvent(QContextMenuEvent *e);
  
  public slots:
  	void setRootMenu(struct menu *menu);
cb77043f0   Masahiro Yamada   kconfig: qconf: r...
64
  	void updateList();
59e564408   Boris Barbulovski   Port xconfig to Q...
65
66
67
68
  	void setValue(ConfigItem* item, tristate val);
  	void changeValue(ConfigItem* item);
  	void updateSelection(void);
  	void saveSettings(void);
d4bbe8a1b   Masahiro Yamada   kconfig: qconf: m...
69
  	void setOptionMode(QAction *action);
7930dd91a   Masahiro Yamada   kconfig: qconf: m...
70
  	void setShowName(bool on);
d4bbe8a1b   Masahiro Yamada   kconfig: qconf: m...
71

59e564408   Boris Barbulovski   Port xconfig to Q...
72
73
74
  signals:
  	void menuChanged(struct menu *menu);
  	void menuSelected(struct menu *menu);
b311142fc   Mauro Carvalho Chehab   kconfig: qconf: f...
75
  	void itemSelected(struct menu *menu);
59e564408   Boris Barbulovski   Port xconfig to Q...
76
77
  	void parentSelected(void);
  	void gotFocus(struct menu *);
7930dd91a   Masahiro Yamada   kconfig: qconf: m...
78
  	void showNameChanged(bool on);
59e564408   Boris Barbulovski   Port xconfig to Q...
79
80
81
82
83
  
  public:
  	void updateListAll(void)
  	{
  		updateAll = true;
cb77043f0   Masahiro Yamada   kconfig: qconf: r...
84
  		updateList();
59e564408   Boris Barbulovski   Port xconfig to Q...
85
86
  		updateAll = false;
  	}
59e564408   Boris Barbulovski   Port xconfig to Q...
87
88
89
90
  	void setAllOpen(bool open);
  	void setParentMenu(void);
  
  	bool menuSkip(struct menu *);
5c6f1554b   Boris Barbulovski   Port xconfig to Q...
91
  	void updateMenuList(ConfigItem *parent, struct menu*);
5b75a6c89   Masahiro Yamada   kconfig: qconf: r...
92
  	void updateMenuList(struct menu *menu);
59e564408   Boris Barbulovski   Port xconfig to Q...
93
94
  
  	bool updateAll;
a0fce2833   Masahiro Yamada   kconfig: qconf: r...
95
  	bool showName;
59e564408   Boris Barbulovski   Port xconfig to Q...
96
97
98
99
100
101
  	enum listMode mode;
  	enum optionMode optMode;
  	struct menu *rootEntry;
  	QPalette disabledColorGroup;
  	QPalette inactivedColorGroup;
  	QMenu* headerPopup;
d4bbe8a1b   Masahiro Yamada   kconfig: qconf: m...
102

f9b918fae   Masahiro Yamada   kconfig: qconf: m...
103
104
105
  	static QList<ConfigList *> allLists;
  	static void updateListForAll();
  	static void updateListAllForAll();
d4bbe8a1b   Masahiro Yamada   kconfig: qconf: m...
106
  	static QAction *showNormalAction, *showAllAction, *showPromptAction;
1019f1a58   Boris Barbulovski   Port xconfig to Q...
107
108
109
110
111
  };
  
  class ConfigItem : public QTreeWidgetItem {
  	typedef class QTreeWidgetItem Parent;
  public:
d960b9889   Boris Barbulovski   Port xconfig to Q...
112
  	ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
86c052827   Boris Barbulovski   Port xconfig to Q...
113
  	: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
1019f1a58   Boris Barbulovski   Port xconfig to Q...
114
115
116
117
  	{
  		init();
  	}
  	ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
86c052827   Boris Barbulovski   Port xconfig to Q...
118
  	: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
1019f1a58   Boris Barbulovski   Port xconfig to Q...
119
120
121
  	{
  		init();
  	}
d960b9889   Boris Barbulovski   Port xconfig to Q...
122
  	ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
86c052827   Boris Barbulovski   Port xconfig to Q...
123
  	: Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
1019f1a58   Boris Barbulovski   Port xconfig to Q...
124
125
126
127
128
  	{
  		init();
  	}
  	~ConfigItem(void);
  	void init(void);
59e564408   Boris Barbulovski   Port xconfig to Q...
129
130
131
132
133
134
135
136
137
138
  	void updateMenu(void);
  	void testUpdateMenu(bool v);
  	ConfigList* listView() const
  	{
  		return (ConfigList*)Parent::treeWidget();
  	}
  	ConfigItem* firstChild() const
  	{
  		return (ConfigItem *)Parent::child(0);
  	}
d5d973c3f   Boris Barbulovski   Port xconfig to Q...
139
  	ConfigItem* nextSibling()
59e564408   Boris Barbulovski   Port xconfig to Q...
140
  	{
d5d973c3f   Boris Barbulovski   Port xconfig to Q...
141
142
143
144
  		ConfigItem *ret = NULL;
  		ConfigItem *_parent = (ConfigItem *)parent();
  
  		if(_parent) {
b3c48f964   Boris Barbulovski   Port xconfig to Q...
145
  			ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1);
d5d973c3f   Boris Barbulovski   Port xconfig to Q...
146
  		} else {
b3c48f964   Boris Barbulovski   Port xconfig to Q...
147
148
  			QTreeWidget *_treeWidget = treeWidget();
  			ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1);
d5d973c3f   Boris Barbulovski   Port xconfig to Q...
149
150
151
  		}
  
  		return ret;
59e564408   Boris Barbulovski   Port xconfig to Q...
152
  	}
d5d973c3f   Boris Barbulovski   Port xconfig to Q...
153
  	// TODO: Implement paintCell
1019f1a58   Boris Barbulovski   Port xconfig to Q...
154
155
156
157
158
  
  	ConfigItem* nextItem;
  	struct menu *menu;
  	bool visible;
  	bool goParent;
5cb255ffa   Masahiro Yamada   kconfig: qconf: r...
159
160
161
162
  
  	static QIcon symbolYesIcon, symbolModIcon, symbolNoIcon;
  	static QIcon choiceYesIcon, choiceNoIcon;
  	static QIcon menuIcon, menubackIcon;
1019f1a58   Boris Barbulovski   Port xconfig to Q...
163
  };
37162a68b   Masahiro Yamada   kconfig: qconf: a...
164
165
166
167
168
169
170
171
172
173
174
175
176
  class ConfigItemDelegate : public QStyledItemDelegate
  {
  private:
  	struct menu *menu;
  public:
  	ConfigItemDelegate(QObject *parent = nullptr)
  		: QStyledItemDelegate(parent) {}
  	QWidget *createEditor(QWidget *parent,
  			      const QStyleOptionViewItem &option,
  			      const QModelIndex &index) const override;
  	void setModelData(QWidget *editor, QAbstractItemModel *model,
  			  const QModelIndex &index) const override;
  };
924bbb53d   Boris Barbulovski   Port xconfig to Q...
177
  class ConfigInfoView : public QTextBrowser {
43bf612af   Roman Zippel   kconfig: Add sear...
178
  	Q_OBJECT
924bbb53d   Boris Barbulovski   Port xconfig to Q...
179
  	typedef class QTextBrowser Parent;
7d1300e63   Masahiro Yamada   kconfig: qconf: f...
180
  	QMenu *contextMenu;
43bf612af   Roman Zippel   kconfig: Add sear...
181
182
183
184
185
186
  public:
  	ConfigInfoView(QWidget* parent, const char *name = 0);
  	bool showDebug(void) const { return _showDebug; }
  
  public slots:
  	void setInfo(struct menu *menu);
7fc925fd6   Roman Zippel   kconfig: finer cu...
187
  	void saveSettings(void);
43bf612af   Roman Zippel   kconfig: Add sear...
188
  	void setShowDebug(bool);
c4f7398be   Mauro Carvalho Chehab   kconfig: qconf: m...
189
  	void clicked (const QUrl &url);
43bf612af   Roman Zippel   kconfig: Add sear...
190
191
192
  
  signals:
  	void showDebugChanged(bool);
b65a47e1a   Roman Zippel   kconfig: jump to ...
193
  	void menuSelected(struct menu *);
43bf612af   Roman Zippel   kconfig: Add sear...
194
195
  
  protected:
ab45d190f   Roman Zippel   kconfig: create l...
196
  	void symbolInfo(void);
43bf612af   Roman Zippel   kconfig: Add sear...
197
198
199
  	void menuInfo(void);
  	QString debug_info(struct symbol *sym);
  	static QString print_filter(const QString &str);
ab45d190f   Roman Zippel   kconfig: create l...
200
  	static void expr_print_help(void *data, struct symbol *sym, const char *str);
7d1300e63   Masahiro Yamada   kconfig: qconf: f...
201
  	void contextMenuEvent(QContextMenuEvent *event);
43bf612af   Roman Zippel   kconfig: Add sear...
202

ab45d190f   Roman Zippel   kconfig: create l...
203
  	struct symbol *sym;
133c5f7c1   Alexander Stein   kconfig qconf: po...
204
  	struct menu *_menu;
43bf612af   Roman Zippel   kconfig: Add sear...
205
206
207
208
209
210
211
  	bool _showDebug;
  };
  
  class ConfigSearchWindow : public QDialog {
  	Q_OBJECT
  	typedef class QDialog Parent;
  public:
740fdef85   Masahiro Yamada   kconfig: qconf: r...
212
  	ConfigSearchWindow(ConfigMainWindow *parent);
7fc925fd6   Roman Zippel   kconfig: finer cu...
213

43bf612af   Roman Zippel   kconfig: Add sear...
214
  public slots:
7fc925fd6   Roman Zippel   kconfig: finer cu...
215
  	void saveSettings(void);
43bf612af   Roman Zippel   kconfig: Add sear...
216
  	void search(void);
7fc925fd6   Roman Zippel   kconfig: finer cu...
217

43bf612af   Roman Zippel   kconfig: Add sear...
218
219
220
  protected:
  	QLineEdit* editField;
  	QPushButton* searchButton;
7fc925fd6   Roman Zippel   kconfig: finer cu...
221
  	QSplitter* split;
62ed16565   Masahiro Yamada   kconfig: qconf: r...
222
  	ConfigList *list;
43bf612af   Roman Zippel   kconfig: Add sear...
223
224
225
226
  	ConfigInfoView* info;
  
  	struct symbol **result;
  };
b1f8a45bf   Boris Barbulovski   Port xconfig to Q...
227
  class ConfigMainWindow : public QMainWindow {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
228
  	Q_OBJECT
3b354c557   Karsten Wiese   [PATCH] kconfig: ...
229

8741908b3   Masahiro Yamada   kconfig: fix 'Sav...
230
  	char *configname;
85eaf28a2   Boris Barbulovski   Port xconfig to Q...
231
  	static QAction *saveAction;
3b354c557   Karsten Wiese   [PATCH] kconfig: ...
232
  	static void conf_changed(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
233
234
235
  public:
  	ConfigMainWindow(void);
  public slots:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
236
  	void changeMenu(struct menu *);
b311142fc   Mauro Carvalho Chehab   kconfig: qconf: f...
237
  	void changeItens(struct menu *);
b65a47e1a   Roman Zippel   kconfig: jump to ...
238
  	void setMenuLink(struct menu *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
239
240
241
  	void listFocusChanged(void);
  	void goBack(void);
  	void loadConfig(void);
bac6aa865   Michal Marek   xconfig: Abort cl...
242
  	bool saveConfig(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
243
  	void saveConfigAs(void);
43bf612af   Roman Zippel   kconfig: Add sear...
244
  	void searchConfig(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
245
246
247
  	void showSingleView(void);
  	void showSplitView(void);
  	void showFullView(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
248
249
250
251
252
253
  	void showIntro(void);
  	void showAbout(void);
  	void saveSettings(void);
  
  protected:
  	void closeEvent(QCloseEvent *e);
43bf612af   Roman Zippel   kconfig: Add sear...
254
  	ConfigSearchWindow *searchWindow;
1019f1a58   Boris Barbulovski   Port xconfig to Q...
255
  	ConfigList *menuList;
1019f1a58   Boris Barbulovski   Port xconfig to Q...
256
  	ConfigList *configList;
43bf612af   Roman Zippel   kconfig: Add sear...
257
  	ConfigInfoView *helpText;
85eaf28a2   Boris Barbulovski   Port xconfig to Q...
258
  	QAction *backAction;
780505e33   Boris Barbulovski   Port xconfig to Q...
259
260
261
  	QAction *singleViewAction;
  	QAction *splitViewAction;
  	QAction *fullViewAction;
76538660f   Boris Barbulovski   Port xconfig to Q...
262
263
  	QSplitter *split1;
  	QSplitter *split2;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
264
  };