qconf.h 4.8 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5
/*
 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
 * Released under the terms of the GNU GPL v2.0.
 */

6 7
#include <QTextBrowser>
#include <QTreeWidget>
8
#include <QMainWindow>
9
#include <QHeaderView>
A
Alexander Stein 已提交
10
#include <qsettings.h>
11 12 13 14 15 16 17
#include <QPushButton>
#include <QSettings>
#include <QLineEdit>
#include <QSplitter>
#include <QCheckBox>
#include <QDialog>
#include "expr.h"
A
Alexander Stein 已提交
18

19
class ConfigView;
20 21
class ConfigList;
class ConfigItem;
L
Linus Torvalds 已提交
22 23 24 25 26
class ConfigLineEdit;
class ConfigMainWindow;

class ConfigSettings : public QSettings {
public:
27
	ConfigSettings();
28 29
	QList<int> readSizes(const QString& key, bool *ok);
	bool writeSizes(const QString& key, const QList<int>& value);
L
Linus Torvalds 已提交
30 31 32 33 34 35
};

enum colIdx {
	promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
};
enum listMode {
36
	singleMode, menuMode, symbolMode, fullMode, listMode
L
Linus Torvalds 已提交
37
};
38 39 40
enum optionMode {
	normalOpt = 0, allOpt, promptOpt
};
L
Linus Torvalds 已提交
41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
class ConfigList : public QTreeWidget {
	Q_OBJECT
	typedef class QTreeWidget Parent;
public:
	ConfigList(ConfigView* p, const char *name = 0);
};

class ConfigItem : public QTreeWidgetItem {
	typedef class QTreeWidgetItem Parent;
public:
	ConfigItem(QTreeWidgetItem *parent, ConfigItem *after, struct menu *m, bool v)
	: Parent(parent, after), menu(m), visible(v), goParent(false)
	{
		init();
	}
	ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
	: Parent(parent, after), menu(m), visible(v), goParent(false)
	{
		init();
	}
	ConfigItem(QTreeWidgetItem *parent, ConfigItem *after, bool v)
	: Parent(parent, after), menu(0), visible(v), goParent(true)
	{
		init();
	}
	~ConfigItem(void);
	void init(void);

	ConfigItem* nextItem;
	struct menu *menu;
	bool visible;
	bool goParent;
};

L
Linus Torvalds 已提交
76 77 78 79
class ConfigLineEdit : public QLineEdit {
	Q_OBJECT
	typedef class QLineEdit Parent;
public:
80
	ConfigLineEdit(ConfigView* parent);
L
Linus Torvalds 已提交
81 82 83 84
	ConfigView* parent(void) const
	{
		return (ConfigView*)Parent::parent();
	}
85
	void show(ConfigItem *i);
L
Linus Torvalds 已提交
86 87 88
	void keyPressEvent(QKeyEvent *e);

public:
89
	ConfigItem *item;
L
Linus Torvalds 已提交
90 91
};

92
class ConfigView : public QWidget {
93
	Q_OBJECT
94
	typedef class QWidget Parent;
95 96 97
public:
	ConfigView(QWidget* parent, const char *name = 0);
	~ConfigView(void);
98
	static void updateList(ConfigItem* item);
99 100
	static void updateListAll(void);

101 102 103
	bool showName(void) const { return false; } // TODO: Implement me.
	bool showRange(void) const { return false; } // TODO: Implement me.
	bool showData(void) const { return false; } // TODO: Implement me.
104 105 106 107
public slots:
	void setShowName(bool);
	void setShowRange(bool);
	void setShowData(bool);
108
	void setOptionMode(QAction *);
109 110 111 112 113
signals:
	void showNameChanged(bool);
	void showRangeChanged(bool);
	void showDataChanged(bool);
public:
114
	ConfigList* list;
115 116 117 118
	ConfigLineEdit* lineEdit;

	static ConfigView* viewList;
	ConfigView* nextView;
119 120 121 122

	static QAction *showNormalAction;
	static QAction *showAllAction;
	static QAction *showPromptAction;
123 124
};

125
class ConfigInfoView : public QTextBrowser {
126
	Q_OBJECT
127
	typedef class QTextBrowser Parent;
128 129 130 131 132 133
public:
	ConfigInfoView(QWidget* parent, const char *name = 0);
	bool showDebug(void) const { return _showDebug; }

public slots:
	void setInfo(struct menu *menu);
134
	void saveSettings(void);
135 136 137 138
	void setShowDebug(bool);

signals:
	void showDebugChanged(bool);
139
	void menuSelected(struct menu *);
140 141

protected:
142
	void symbolInfo(void);
143 144 145
	void menuInfo(void);
	QString debug_info(struct symbol *sym);
	static QString print_filter(const QString &str);
146
	static void expr_print_help(void *data, struct symbol *sym, const char *str);
147 148
	QMenu *createStandardContextMenu(const QPoint & pos);
	void contextMenuEvent(QContextMenuEvent *e);
149

150
	struct symbol *sym;
A
Alexander Stein 已提交
151
	struct menu *_menu;
152 153 154 155 156 157 158
	bool _showDebug;
};

class ConfigSearchWindow : public QDialog {
	Q_OBJECT
	typedef class QDialog Parent;
public:
159
	ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0);
160

161
public slots:
162
	void saveSettings(void);
163
	void search(void);
164

165 166 167
protected:
	QLineEdit* editField;
	QPushButton* searchButton;
168
	QSplitter* split;
169 170 171 172 173 174
	ConfigView* list;
	ConfigInfoView* info;

	struct symbol **result;
};

175
class ConfigMainWindow : public QMainWindow {
L
Linus Torvalds 已提交
176
	Q_OBJECT
177

178
	static QAction *saveAction;
179
	static void conf_changed(void);
L
Linus Torvalds 已提交
180 181 182 183
public:
	ConfigMainWindow(void);
public slots:
	void changeMenu(struct menu *);
184
	void setMenuLink(struct menu *);
L
Linus Torvalds 已提交
185 186 187
	void listFocusChanged(void);
	void goBack(void);
	void loadConfig(void);
188
	bool saveConfig(void);
L
Linus Torvalds 已提交
189
	void saveConfigAs(void);
190
	void searchConfig(void);
L
Linus Torvalds 已提交
191 192 193 194 195 196 197 198 199 200
	void showSingleView(void);
	void showSplitView(void);
	void showFullView(void);
	void showIntro(void);
	void showAbout(void);
	void saveSettings(void);

protected:
	void closeEvent(QCloseEvent *e);

201
	ConfigSearchWindow *searchWindow;
L
Linus Torvalds 已提交
202
	ConfigView *menuView;
203
	ConfigList *menuList;
L
Linus Torvalds 已提交
204
	ConfigView *configView;
205
	ConfigList *configList;
206
	ConfigInfoView *helpText;
207
	QToolBar *toolBar;
208
	QAction *backAction;
209 210 211
	QAction *singleViewAction;
	QAction *splitViewAction;
	QAction *fullViewAction;
212 213
	QSplitter *split1;
	QSplitter *split2;
L
Linus Torvalds 已提交
214
};