File Index
Files and directories
Sign in
FILE

qconf.h

File preview with syntax highlighting.

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