qconf.h 7.1 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
class ConfigList : public QTreeWidget {
	Q_OBJECT
	typedef class QTreeWidget Parent;
public:
	ConfigList(ConfigView* p, const char *name = 0);
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
	void reinit(void);
	ConfigView* parent(void) const
	{
		return (ConfigView*)Parent::parent();
	}
	ConfigItem* findConfigItem(struct menu *);

protected:
	void keyPressEvent(QKeyEvent *e);
	void contentsMousePressEvent(QMouseEvent *e);
	void contentsMouseReleaseEvent(QMouseEvent *e);
	void contentsMouseMoveEvent(QMouseEvent *e);
	void contentsMouseDoubleClickEvent(QMouseEvent *e);
	void focusInEvent(QFocusEvent *e);
	void contextMenuEvent(QContextMenuEvent *e);

public slots:
	void setRootMenu(struct menu *menu);

	void updateList(ConfigItem *item);
	void setValue(ConfigItem* item, tristate val);
	void changeValue(ConfigItem* item);
	void updateSelection(void);
	void saveSettings(void);
signals:
	void menuChanged(struct menu *menu);
	void menuSelected(struct menu *menu);
	void parentSelected(void);
	void gotFocus(struct menu *);

public:
	void updateListAll(void)
	{
		updateAll = true;
		updateList(NULL);
		updateAll = false;
	}
	ConfigList* listView()
	{
		return this;
	}
	ConfigItem* firstChild() const
	{
		// TODO: Implement me.
		return NULL;
	}
	void addColumn(colIdx idx, const QString& label)
	{
		// TODO: Implement me.
	}
	void removeColumn(colIdx idx)
	{
		// TODO: Implement me.
	}
	void setAllOpen(bool open);
	void setParentMenu(void);

	bool menuSkip(struct menu *);

	template <class P>
	void updateMenuList(P*, struct menu*);

	bool updateAll;

	QPixmap symbolYesPix, symbolModPix, symbolNoPix;
	QPixmap choiceYesPix, choiceNoPix;
	QPixmap menuPix, menuInvPix, menuBackPix, voidPix;

	bool showName, showRange, showData;
	enum listMode mode;
	enum optionMode optMode;
	struct menu *rootEntry;
	QPalette disabledColorGroup;
	QPalette inactivedColorGroup;
	QMenu* headerPopup;
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
};

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);
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
	void okRename(int col);
	void updateMenu(void);
	void testUpdateMenu(bool v);
	ConfigList* listView() const
	{
		return (ConfigList*)Parent::treeWidget();
	}
	ConfigItem* firstChild() const
	{
		return (ConfigItem *)Parent::child(0);
	}
	ConfigItem* nextSibling() const
	{
		return NULL; // TODO: Implement me
	}
	void setText(colIdx idx, const QString& text)
	{
		Parent::setText(idx, text);
	}
	QString text(colIdx idx) const
	{
		return Parent::text(idx);
	}
	void setPixmap(colIdx idx, const QPixmap& pm)
	{
		// TODO: Implement me
	}
	const QPixmap* pixmap(colIdx idx) const
	{
		return NULL; // TODO: Implement me
	}
	// Implement paintCell
176 177 178 179 180 181 182

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

L
Linus Torvalds 已提交
183 184 185 186
class ConfigLineEdit : public QLineEdit {
	Q_OBJECT
	typedef class QLineEdit Parent;
public:
187
	ConfigLineEdit(ConfigView* parent);
L
Linus Torvalds 已提交
188 189 190 191
	ConfigView* parent(void) const
	{
		return (ConfigView*)Parent::parent();
	}
192
	void show(ConfigItem *i);
L
Linus Torvalds 已提交
193 194 195
	void keyPressEvent(QKeyEvent *e);

public:
196
	ConfigItem *item;
L
Linus Torvalds 已提交
197 198
};

199
class ConfigView : public QWidget {
200
	Q_OBJECT
201
	typedef class QWidget Parent;
202 203 204
public:
	ConfigView(QWidget* parent, const char *name = 0);
	~ConfigView(void);
205
	static void updateList(ConfigItem* item);
206 207
	static void updateListAll(void);

208 209 210
	bool showName(void) const { return list->showName; }
	bool showRange(void) const { return list->showRange; }
	bool showData(void) const { return list->showData; }
211 212 213 214
public slots:
	void setShowName(bool);
	void setShowRange(bool);
	void setShowData(bool);
215
	void setOptionMode(QAction *);
216 217 218 219 220
signals:
	void showNameChanged(bool);
	void showRangeChanged(bool);
	void showDataChanged(bool);
public:
221
	ConfigList* list;
222 223 224 225
	ConfigLineEdit* lineEdit;

	static ConfigView* viewList;
	ConfigView* nextView;
226 227 228 229

	static QAction *showNormalAction;
	static QAction *showAllAction;
	static QAction *showPromptAction;
230 231
};

232
class ConfigInfoView : public QTextBrowser {
233
	Q_OBJECT
234
	typedef class QTextBrowser Parent;
235 236 237 238 239 240
public:
	ConfigInfoView(QWidget* parent, const char *name = 0);
	bool showDebug(void) const { return _showDebug; }

public slots:
	void setInfo(struct menu *menu);
241
	void saveSettings(void);
242 243 244 245
	void setShowDebug(bool);

signals:
	void showDebugChanged(bool);
246
	void menuSelected(struct menu *);
247 248

protected:
249
	void symbolInfo(void);
250 251 252
	void menuInfo(void);
	QString debug_info(struct symbol *sym);
	static QString print_filter(const QString &str);
253
	static void expr_print_help(void *data, struct symbol *sym, const char *str);
254 255
	QMenu *createStandardContextMenu(const QPoint & pos);
	void contextMenuEvent(QContextMenuEvent *e);
256

257
	struct symbol *sym;
A
Alexander Stein 已提交
258
	struct menu *_menu;
259 260 261 262 263 264 265
	bool _showDebug;
};

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

268
public slots:
269
	void saveSettings(void);
270
	void search(void);
271

272 273 274
protected:
	QLineEdit* editField;
	QPushButton* searchButton;
275
	QSplitter* split;
276 277 278 279 280 281
	ConfigView* list;
	ConfigInfoView* info;

	struct symbol **result;
};

282
class ConfigMainWindow : public QMainWindow {
L
Linus Torvalds 已提交
283
	Q_OBJECT
284

285
	static QAction *saveAction;
286
	static void conf_changed(void);
L
Linus Torvalds 已提交
287 288 289 290
public:
	ConfigMainWindow(void);
public slots:
	void changeMenu(struct menu *);
291
	void setMenuLink(struct menu *);
L
Linus Torvalds 已提交
292 293 294
	void listFocusChanged(void);
	void goBack(void);
	void loadConfig(void);
295
	bool saveConfig(void);
L
Linus Torvalds 已提交
296
	void saveConfigAs(void);
297
	void searchConfig(void);
L
Linus Torvalds 已提交
298 299 300 301 302 303 304 305 306 307
	void showSingleView(void);
	void showSplitView(void);
	void showFullView(void);
	void showIntro(void);
	void showAbout(void);
	void saveSettings(void);

protected:
	void closeEvent(QCloseEvent *e);

308
	ConfigSearchWindow *searchWindow;
L
Linus Torvalds 已提交
309
	ConfigView *menuView;
310
	ConfigList *menuList;
L
Linus Torvalds 已提交
311
	ConfigView *configView;
312
	ConfigList *configList;
313
	ConfigInfoView *helpText;
314
	QToolBar *toolBar;
315
	QAction *backAction;
316 317 318
	QAction *singleViewAction;
	QAction *splitViewAction;
	QAction *fullViewAction;
319 320
	QSplitter *split1;
	QSplitter *split2;
L
Linus Torvalds 已提交
321
};