xref: /openbmc/u-boot/scripts/kconfig/qconf.h (revision bf7ab1e70fd7621fea5dea07b6975c576119b86e)
10a9064fbSMasahiro Yamada /*
20a9064fbSMasahiro Yamada  * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
30a9064fbSMasahiro Yamada  * Released under the terms of the GNU GPL v2.0.
40a9064fbSMasahiro Yamada  */
50a9064fbSMasahiro Yamada 
6*bf7ab1e7SMasahiro Yamada #include <QTextBrowser>
7*bf7ab1e7SMasahiro Yamada #include <QTreeWidget>
8*bf7ab1e7SMasahiro Yamada #include <QMainWindow>
9*bf7ab1e7SMasahiro Yamada #include <QHeaderView>
100a9064fbSMasahiro Yamada #include <qsettings.h>
11*bf7ab1e7SMasahiro Yamada #include <QPushButton>
12*bf7ab1e7SMasahiro Yamada #include <QSettings>
13*bf7ab1e7SMasahiro Yamada #include <QLineEdit>
14*bf7ab1e7SMasahiro Yamada #include <QSplitter>
15*bf7ab1e7SMasahiro Yamada #include <QCheckBox>
16*bf7ab1e7SMasahiro Yamada #include <QDialog>
17*bf7ab1e7SMasahiro Yamada #include "expr.h"
180a9064fbSMasahiro Yamada 
190a9064fbSMasahiro Yamada class ConfigView;
200a9064fbSMasahiro Yamada class ConfigList;
210a9064fbSMasahiro Yamada class ConfigItem;
220a9064fbSMasahiro Yamada class ConfigLineEdit;
230a9064fbSMasahiro Yamada class ConfigMainWindow;
240a9064fbSMasahiro Yamada 
250a9064fbSMasahiro Yamada class ConfigSettings : public QSettings {
260a9064fbSMasahiro Yamada public:
270a9064fbSMasahiro Yamada 	ConfigSettings();
28*bf7ab1e7SMasahiro Yamada 	QList<int> readSizes(const QString& key, bool *ok);
29*bf7ab1e7SMasahiro Yamada 	bool writeSizes(const QString& key, const QList<int>& value);
300a9064fbSMasahiro Yamada };
310a9064fbSMasahiro Yamada 
320a9064fbSMasahiro Yamada enum colIdx {
330a9064fbSMasahiro Yamada 	promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
340a9064fbSMasahiro Yamada };
350a9064fbSMasahiro Yamada enum listMode {
360a9064fbSMasahiro Yamada 	singleMode, menuMode, symbolMode, fullMode, listMode
370a9064fbSMasahiro Yamada };
380a9064fbSMasahiro Yamada enum optionMode {
390a9064fbSMasahiro Yamada 	normalOpt = 0, allOpt, promptOpt
400a9064fbSMasahiro Yamada };
410a9064fbSMasahiro Yamada 
42*bf7ab1e7SMasahiro Yamada class ConfigList : public QTreeWidget {
430a9064fbSMasahiro Yamada 	Q_OBJECT
44*bf7ab1e7SMasahiro Yamada 	typedef class QTreeWidget Parent;
450a9064fbSMasahiro Yamada public:
460a9064fbSMasahiro Yamada 	ConfigList(ConfigView* p, const char *name = 0);
470a9064fbSMasahiro Yamada 	void reinit(void);
parent(void)480a9064fbSMasahiro Yamada 	ConfigView* parent(void) const
490a9064fbSMasahiro Yamada 	{
500a9064fbSMasahiro Yamada 		return (ConfigView*)Parent::parent();
510a9064fbSMasahiro Yamada 	}
520a9064fbSMasahiro Yamada 	ConfigItem* findConfigItem(struct menu *);
530a9064fbSMasahiro Yamada 
540a9064fbSMasahiro Yamada protected:
550a9064fbSMasahiro Yamada 	void keyPressEvent(QKeyEvent *e);
56*bf7ab1e7SMasahiro Yamada 	void mousePressEvent(QMouseEvent *e);
57*bf7ab1e7SMasahiro Yamada 	void mouseReleaseEvent(QMouseEvent *e);
58*bf7ab1e7SMasahiro Yamada 	void mouseMoveEvent(QMouseEvent *e);
59*bf7ab1e7SMasahiro Yamada 	void mouseDoubleClickEvent(QMouseEvent *e);
600a9064fbSMasahiro Yamada 	void focusInEvent(QFocusEvent *e);
610a9064fbSMasahiro Yamada 	void contextMenuEvent(QContextMenuEvent *e);
620a9064fbSMasahiro Yamada 
630a9064fbSMasahiro Yamada public slots:
640a9064fbSMasahiro Yamada 	void setRootMenu(struct menu *menu);
650a9064fbSMasahiro Yamada 
660a9064fbSMasahiro Yamada 	void updateList(ConfigItem *item);
670a9064fbSMasahiro Yamada 	void setValue(ConfigItem* item, tristate val);
680a9064fbSMasahiro Yamada 	void changeValue(ConfigItem* item);
690a9064fbSMasahiro Yamada 	void updateSelection(void);
700a9064fbSMasahiro Yamada 	void saveSettings(void);
710a9064fbSMasahiro Yamada signals:
720a9064fbSMasahiro Yamada 	void menuChanged(struct menu *menu);
730a9064fbSMasahiro Yamada 	void menuSelected(struct menu *menu);
740a9064fbSMasahiro Yamada 	void parentSelected(void);
750a9064fbSMasahiro Yamada 	void gotFocus(struct menu *);
760a9064fbSMasahiro Yamada 
770a9064fbSMasahiro Yamada public:
updateListAll(void)780a9064fbSMasahiro Yamada 	void updateListAll(void)
790a9064fbSMasahiro Yamada 	{
800a9064fbSMasahiro Yamada 		updateAll = true;
810a9064fbSMasahiro Yamada 		updateList(NULL);
820a9064fbSMasahiro Yamada 		updateAll = false;
830a9064fbSMasahiro Yamada 	}
listView()840a9064fbSMasahiro Yamada 	ConfigList* listView()
850a9064fbSMasahiro Yamada 	{
860a9064fbSMasahiro Yamada 		return this;
870a9064fbSMasahiro Yamada 	}
firstChild()880a9064fbSMasahiro Yamada 	ConfigItem* firstChild() const
890a9064fbSMasahiro Yamada 	{
90*bf7ab1e7SMasahiro Yamada 		return (ConfigItem *)children().first();
910a9064fbSMasahiro Yamada 	}
addColumn(colIdx idx)92*bf7ab1e7SMasahiro Yamada 	void addColumn(colIdx idx)
930a9064fbSMasahiro Yamada 	{
94*bf7ab1e7SMasahiro Yamada 		showColumn(idx);
950a9064fbSMasahiro Yamada 	}
removeColumn(colIdx idx)960a9064fbSMasahiro Yamada 	void removeColumn(colIdx idx)
970a9064fbSMasahiro Yamada 	{
98*bf7ab1e7SMasahiro Yamada 		hideColumn(idx);
990a9064fbSMasahiro Yamada 	}
1000a9064fbSMasahiro Yamada 	void setAllOpen(bool open);
1010a9064fbSMasahiro Yamada 	void setParentMenu(void);
1020a9064fbSMasahiro Yamada 
1030a9064fbSMasahiro Yamada 	bool menuSkip(struct menu *);
1040a9064fbSMasahiro Yamada 
105*bf7ab1e7SMasahiro Yamada 	void updateMenuList(ConfigItem *parent, struct menu*);
106*bf7ab1e7SMasahiro Yamada 	void updateMenuList(ConfigList *parent, struct menu*);
1070a9064fbSMasahiro Yamada 
1080a9064fbSMasahiro Yamada 	bool updateAll;
1090a9064fbSMasahiro Yamada 
1100a9064fbSMasahiro Yamada 	QPixmap symbolYesPix, symbolModPix, symbolNoPix;
1110a9064fbSMasahiro Yamada 	QPixmap choiceYesPix, choiceNoPix;
1120a9064fbSMasahiro Yamada 	QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
1130a9064fbSMasahiro Yamada 
1140a9064fbSMasahiro Yamada 	bool showName, showRange, showData;
1150a9064fbSMasahiro Yamada 	enum listMode mode;
1160a9064fbSMasahiro Yamada 	enum optionMode optMode;
1170a9064fbSMasahiro Yamada 	struct menu *rootEntry;
118*bf7ab1e7SMasahiro Yamada 	QPalette disabledColorGroup;
119*bf7ab1e7SMasahiro Yamada 	QPalette inactivedColorGroup;
120*bf7ab1e7SMasahiro Yamada 	QMenu* headerPopup;
1210a9064fbSMasahiro Yamada };
1220a9064fbSMasahiro Yamada 
123*bf7ab1e7SMasahiro Yamada class ConfigItem : public QTreeWidgetItem {
124*bf7ab1e7SMasahiro Yamada 	typedef class QTreeWidgetItem Parent;
1250a9064fbSMasahiro Yamada public:
ConfigItem(ConfigList * parent,ConfigItem * after,struct menu * m,bool v)126*bf7ab1e7SMasahiro Yamada 	ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
127*bf7ab1e7SMasahiro Yamada 	: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
1280a9064fbSMasahiro Yamada 	{
1290a9064fbSMasahiro Yamada 		init();
1300a9064fbSMasahiro Yamada 	}
ConfigItem(ConfigItem * parent,ConfigItem * after,struct menu * m,bool v)1310a9064fbSMasahiro Yamada 	ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
132*bf7ab1e7SMasahiro Yamada 	: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
1330a9064fbSMasahiro Yamada 	{
1340a9064fbSMasahiro Yamada 		init();
1350a9064fbSMasahiro Yamada 	}
ConfigItem(ConfigList * parent,ConfigItem * after,bool v)136*bf7ab1e7SMasahiro Yamada 	ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
137*bf7ab1e7SMasahiro Yamada 	: Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
1380a9064fbSMasahiro Yamada 	{
1390a9064fbSMasahiro Yamada 		init();
1400a9064fbSMasahiro Yamada 	}
1410a9064fbSMasahiro Yamada 	~ConfigItem(void);
1420a9064fbSMasahiro Yamada 	void init(void);
1430a9064fbSMasahiro Yamada 	void okRename(int col);
1440a9064fbSMasahiro Yamada 	void updateMenu(void);
1450a9064fbSMasahiro Yamada 	void testUpdateMenu(bool v);
listView()1460a9064fbSMasahiro Yamada 	ConfigList* listView() const
1470a9064fbSMasahiro Yamada 	{
148*bf7ab1e7SMasahiro Yamada 		return (ConfigList*)Parent::treeWidget();
1490a9064fbSMasahiro Yamada 	}
firstChild()1500a9064fbSMasahiro Yamada 	ConfigItem* firstChild() const
1510a9064fbSMasahiro Yamada 	{
152*bf7ab1e7SMasahiro Yamada 		return (ConfigItem *)Parent::child(0);
1530a9064fbSMasahiro Yamada 	}
nextSibling()154*bf7ab1e7SMasahiro Yamada 	ConfigItem* nextSibling()
1550a9064fbSMasahiro Yamada 	{
156*bf7ab1e7SMasahiro Yamada 		ConfigItem *ret = NULL;
157*bf7ab1e7SMasahiro Yamada 		ConfigItem *_parent = (ConfigItem *)parent();
158*bf7ab1e7SMasahiro Yamada 
159*bf7ab1e7SMasahiro Yamada 		if(_parent) {
160*bf7ab1e7SMasahiro Yamada 			ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1);
161*bf7ab1e7SMasahiro Yamada 		} else {
162*bf7ab1e7SMasahiro Yamada 			QTreeWidget *_treeWidget = treeWidget();
163*bf7ab1e7SMasahiro Yamada 			ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1);
164*bf7ab1e7SMasahiro Yamada 		}
165*bf7ab1e7SMasahiro Yamada 
166*bf7ab1e7SMasahiro Yamada 		return ret;
1670a9064fbSMasahiro Yamada 	}
setText(colIdx idx,const QString & text)1680a9064fbSMasahiro Yamada 	void setText(colIdx idx, const QString& text)
1690a9064fbSMasahiro Yamada 	{
170*bf7ab1e7SMasahiro Yamada 		Parent::setText(idx, text);
1710a9064fbSMasahiro Yamada 	}
text(colIdx idx)1720a9064fbSMasahiro Yamada 	QString text(colIdx idx) const
1730a9064fbSMasahiro Yamada 	{
174*bf7ab1e7SMasahiro Yamada 		return Parent::text(idx);
1750a9064fbSMasahiro Yamada 	}
setPixmap(colIdx idx,const QIcon & icon)176*bf7ab1e7SMasahiro Yamada 	void setPixmap(colIdx idx, const QIcon &icon)
1770a9064fbSMasahiro Yamada 	{
178*bf7ab1e7SMasahiro Yamada 		Parent::setIcon(idx, icon);
1790a9064fbSMasahiro Yamada 	}
pixmap(colIdx idx)180*bf7ab1e7SMasahiro Yamada 	const QIcon pixmap(colIdx idx) const
1810a9064fbSMasahiro Yamada 	{
182*bf7ab1e7SMasahiro Yamada 		return icon(idx);
1830a9064fbSMasahiro Yamada 	}
184*bf7ab1e7SMasahiro Yamada 	// TODO: Implement paintCell
1850a9064fbSMasahiro Yamada 
1860a9064fbSMasahiro Yamada 	ConfigItem* nextItem;
1870a9064fbSMasahiro Yamada 	struct menu *menu;
1880a9064fbSMasahiro Yamada 	bool visible;
1890a9064fbSMasahiro Yamada 	bool goParent;
1900a9064fbSMasahiro Yamada };
1910a9064fbSMasahiro Yamada 
1920a9064fbSMasahiro Yamada class ConfigLineEdit : public QLineEdit {
1930a9064fbSMasahiro Yamada 	Q_OBJECT
1940a9064fbSMasahiro Yamada 	typedef class QLineEdit Parent;
1950a9064fbSMasahiro Yamada public:
1960a9064fbSMasahiro Yamada 	ConfigLineEdit(ConfigView* parent);
parent(void)1970a9064fbSMasahiro Yamada 	ConfigView* parent(void) const
1980a9064fbSMasahiro Yamada 	{
1990a9064fbSMasahiro Yamada 		return (ConfigView*)Parent::parent();
2000a9064fbSMasahiro Yamada 	}
2010a9064fbSMasahiro Yamada 	void show(ConfigItem *i);
2020a9064fbSMasahiro Yamada 	void keyPressEvent(QKeyEvent *e);
2030a9064fbSMasahiro Yamada 
2040a9064fbSMasahiro Yamada public:
2050a9064fbSMasahiro Yamada 	ConfigItem *item;
2060a9064fbSMasahiro Yamada };
2070a9064fbSMasahiro Yamada 
208*bf7ab1e7SMasahiro Yamada class ConfigView : public QWidget {
2090a9064fbSMasahiro Yamada 	Q_OBJECT
210*bf7ab1e7SMasahiro Yamada 	typedef class QWidget Parent;
2110a9064fbSMasahiro Yamada public:
2120a9064fbSMasahiro Yamada 	ConfigView(QWidget* parent, const char *name = 0);
2130a9064fbSMasahiro Yamada 	~ConfigView(void);
2140a9064fbSMasahiro Yamada 	static void updateList(ConfigItem* item);
2150a9064fbSMasahiro Yamada 	static void updateListAll(void);
2160a9064fbSMasahiro Yamada 
showName(void)2170a9064fbSMasahiro Yamada 	bool showName(void) const { return list->showName; }
showRange(void)2180a9064fbSMasahiro Yamada 	bool showRange(void) const { return list->showRange; }
showData(void)2190a9064fbSMasahiro Yamada 	bool showData(void) const { return list->showData; }
2200a9064fbSMasahiro Yamada public slots:
2210a9064fbSMasahiro Yamada 	void setShowName(bool);
2220a9064fbSMasahiro Yamada 	void setShowRange(bool);
2230a9064fbSMasahiro Yamada 	void setShowData(bool);
2240a9064fbSMasahiro Yamada 	void setOptionMode(QAction *);
2250a9064fbSMasahiro Yamada signals:
2260a9064fbSMasahiro Yamada 	void showNameChanged(bool);
2270a9064fbSMasahiro Yamada 	void showRangeChanged(bool);
2280a9064fbSMasahiro Yamada 	void showDataChanged(bool);
2290a9064fbSMasahiro Yamada public:
2300a9064fbSMasahiro Yamada 	ConfigList* list;
2310a9064fbSMasahiro Yamada 	ConfigLineEdit* lineEdit;
2320a9064fbSMasahiro Yamada 
2330a9064fbSMasahiro Yamada 	static ConfigView* viewList;
2340a9064fbSMasahiro Yamada 	ConfigView* nextView;
2350a9064fbSMasahiro Yamada 
2360a9064fbSMasahiro Yamada 	static QAction *showNormalAction;
2370a9064fbSMasahiro Yamada 	static QAction *showAllAction;
2380a9064fbSMasahiro Yamada 	static QAction *showPromptAction;
2390a9064fbSMasahiro Yamada };
2400a9064fbSMasahiro Yamada 
241*bf7ab1e7SMasahiro Yamada class ConfigInfoView : public QTextBrowser {
2420a9064fbSMasahiro Yamada 	Q_OBJECT
243*bf7ab1e7SMasahiro Yamada 	typedef class QTextBrowser Parent;
2440a9064fbSMasahiro Yamada public:
2450a9064fbSMasahiro Yamada 	ConfigInfoView(QWidget* parent, const char *name = 0);
showDebug(void)2460a9064fbSMasahiro Yamada 	bool showDebug(void) const { return _showDebug; }
2470a9064fbSMasahiro Yamada 
2480a9064fbSMasahiro Yamada public slots:
2490a9064fbSMasahiro Yamada 	void setInfo(struct menu *menu);
2500a9064fbSMasahiro Yamada 	void saveSettings(void);
2510a9064fbSMasahiro Yamada 	void setShowDebug(bool);
2520a9064fbSMasahiro Yamada 
2530a9064fbSMasahiro Yamada signals:
2540a9064fbSMasahiro Yamada 	void showDebugChanged(bool);
2550a9064fbSMasahiro Yamada 	void menuSelected(struct menu *);
2560a9064fbSMasahiro Yamada 
2570a9064fbSMasahiro Yamada protected:
2580a9064fbSMasahiro Yamada 	void symbolInfo(void);
2590a9064fbSMasahiro Yamada 	void menuInfo(void);
2600a9064fbSMasahiro Yamada 	QString debug_info(struct symbol *sym);
2610a9064fbSMasahiro Yamada 	static QString print_filter(const QString &str);
2620a9064fbSMasahiro Yamada 	static void expr_print_help(void *data, struct symbol *sym, const char *str);
263*bf7ab1e7SMasahiro Yamada 	QMenu *createStandardContextMenu(const QPoint & pos);
264*bf7ab1e7SMasahiro Yamada 	void contextMenuEvent(QContextMenuEvent *e);
2650a9064fbSMasahiro Yamada 
2660a9064fbSMasahiro Yamada 	struct symbol *sym;
2670a9064fbSMasahiro Yamada 	struct menu *_menu;
2680a9064fbSMasahiro Yamada 	bool _showDebug;
2690a9064fbSMasahiro Yamada };
2700a9064fbSMasahiro Yamada 
2710a9064fbSMasahiro Yamada class ConfigSearchWindow : public QDialog {
2720a9064fbSMasahiro Yamada 	Q_OBJECT
2730a9064fbSMasahiro Yamada 	typedef class QDialog Parent;
2740a9064fbSMasahiro Yamada public:
2750a9064fbSMasahiro Yamada 	ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0);
2760a9064fbSMasahiro Yamada 
2770a9064fbSMasahiro Yamada public slots:
2780a9064fbSMasahiro Yamada 	void saveSettings(void);
2790a9064fbSMasahiro Yamada 	void search(void);
2800a9064fbSMasahiro Yamada 
2810a9064fbSMasahiro Yamada protected:
2820a9064fbSMasahiro Yamada 	QLineEdit* editField;
2830a9064fbSMasahiro Yamada 	QPushButton* searchButton;
2840a9064fbSMasahiro Yamada 	QSplitter* split;
2850a9064fbSMasahiro Yamada 	ConfigView* list;
2860a9064fbSMasahiro Yamada 	ConfigInfoView* info;
2870a9064fbSMasahiro Yamada 
2880a9064fbSMasahiro Yamada 	struct symbol **result;
2890a9064fbSMasahiro Yamada };
2900a9064fbSMasahiro Yamada 
291*bf7ab1e7SMasahiro Yamada class ConfigMainWindow : public QMainWindow {
2920a9064fbSMasahiro Yamada 	Q_OBJECT
2930a9064fbSMasahiro Yamada 
294*bf7ab1e7SMasahiro Yamada 	static QAction *saveAction;
2950a9064fbSMasahiro Yamada 	static void conf_changed(void);
2960a9064fbSMasahiro Yamada public:
2970a9064fbSMasahiro Yamada 	ConfigMainWindow(void);
2980a9064fbSMasahiro Yamada public slots:
2990a9064fbSMasahiro Yamada 	void changeMenu(struct menu *);
3000a9064fbSMasahiro Yamada 	void setMenuLink(struct menu *);
3010a9064fbSMasahiro Yamada 	void listFocusChanged(void);
3020a9064fbSMasahiro Yamada 	void goBack(void);
3030a9064fbSMasahiro Yamada 	void loadConfig(void);
3040a9064fbSMasahiro Yamada 	bool saveConfig(void);
3050a9064fbSMasahiro Yamada 	void saveConfigAs(void);
3060a9064fbSMasahiro Yamada 	void searchConfig(void);
3070a9064fbSMasahiro Yamada 	void showSingleView(void);
3080a9064fbSMasahiro Yamada 	void showSplitView(void);
3090a9064fbSMasahiro Yamada 	void showFullView(void);
3100a9064fbSMasahiro Yamada 	void showIntro(void);
3110a9064fbSMasahiro Yamada 	void showAbout(void);
3120a9064fbSMasahiro Yamada 	void saveSettings(void);
3130a9064fbSMasahiro Yamada 
3140a9064fbSMasahiro Yamada protected:
3150a9064fbSMasahiro Yamada 	void closeEvent(QCloseEvent *e);
3160a9064fbSMasahiro Yamada 
3170a9064fbSMasahiro Yamada 	ConfigSearchWindow *searchWindow;
3180a9064fbSMasahiro Yamada 	ConfigView *menuView;
3190a9064fbSMasahiro Yamada 	ConfigList *menuList;
3200a9064fbSMasahiro Yamada 	ConfigView *configView;
3210a9064fbSMasahiro Yamada 	ConfigList *configList;
3220a9064fbSMasahiro Yamada 	ConfigInfoView *helpText;
323*bf7ab1e7SMasahiro Yamada 	QToolBar *toolBar;
324*bf7ab1e7SMasahiro Yamada 	QAction *backAction;
325*bf7ab1e7SMasahiro Yamada 	QAction *singleViewAction;
326*bf7ab1e7SMasahiro Yamada 	QAction *splitViewAction;
327*bf7ab1e7SMasahiro Yamada 	QAction *fullViewAction;
3280a9064fbSMasahiro Yamada 	QSplitter *split1;
3290a9064fbSMasahiro Yamada 	QSplitter *split2;
3300a9064fbSMasahiro Yamada };
331