qconf.h 7.2 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.
 */

A
Alexander Stein 已提交
6
#include <q3listview.h>
7
#include <QMainWindow>
A
Alexander Stein 已提交
8 9
#include <qsettings.h>

10
class ConfigView;
L
Linus Torvalds 已提交
11 12 13 14 15 16 17
class ConfigList;
class ConfigItem;
class ConfigLineEdit;
class ConfigMainWindow;

class ConfigSettings : public QSettings {
public:
18
	ConfigSettings();
19 20
	QList<int> readSizes(const QString& key, bool *ok);
	bool writeSizes(const QString& key, const QList<int>& value);
L
Linus Torvalds 已提交
21 22 23 24 25 26
};

enum colIdx {
	promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
};
enum listMode {
27
	singleMode, menuMode, symbolMode, fullMode, listMode
L
Linus Torvalds 已提交
28
};
29 30 31
enum optionMode {
	normalOpt = 0, allOpt, promptOpt
};
L
Linus Torvalds 已提交
32

A
Alexander Stein 已提交
33
class ConfigList : public Q3ListView {
L
Linus Torvalds 已提交
34
	Q_OBJECT
A
Alexander Stein 已提交
35
	typedef class Q3ListView Parent;
L
Linus Torvalds 已提交
36
public:
37
	ConfigList(ConfigView* p, const char *name = 0);
L
Linus Torvalds 已提交
38 39 40 41 42
	void reinit(void);
	ConfigView* parent(void) const
	{
		return (ConfigView*)Parent::parent();
	}
43
	ConfigItem* findConfigItem(struct menu *);
L
Linus Torvalds 已提交
44 45 46 47 48 49 50 51

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);
52 53
	void contextMenuEvent(QContextMenuEvent *e);

L
Linus Torvalds 已提交
54 55 56 57 58 59 60
public slots:
	void setRootMenu(struct menu *menu);

	void updateList(ConfigItem *item);
	void setValue(ConfigItem* item, tristate val);
	void changeValue(ConfigItem* item);
	void updateSelection(void);
61
	void saveSettings(void);
L
Linus Torvalds 已提交
62
signals:
63
	void menuChanged(struct menu *menu);
L
Linus Torvalds 已提交
64 65
	void menuSelected(struct menu *menu);
	void parentSelected(void);
66
	void gotFocus(struct menu *);
L
Linus Torvalds 已提交
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

public:
	void updateListAll(void)
	{
		updateAll = true;
		updateList(NULL);
		updateAll = false;
	}
	ConfigList* listView()
	{
		return this;
	}
	ConfigItem* firstChild() const
	{
		return (ConfigItem *)Parent::firstChild();
	}
	int mapIdx(colIdx idx)
	{
		return colMap[idx];
	}
	void addColumn(colIdx idx, const QString& label)
	{
		colMap[idx] = Parent::addColumn(label);
		colRevMap[colMap[idx]] = idx;
	}
	void removeColumn(colIdx idx)
	{
		int col = colMap[idx];
		if (col >= 0) {
			Parent::removeColumn(col);
			colRevMap[col] = colMap[idx] = -1;
		}
	}
	void setAllOpen(bool open);
	void setParentMenu(void);

103 104
	bool menuSkip(struct menu *);

L
Linus Torvalds 已提交
105
	template <class P>
106
	void updateMenuList(P*, struct menu*);
L
Linus Torvalds 已提交
107 108 109 110 111 112 113

	bool updateAll;

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

114
	bool showName, showRange, showData;
L
Linus Torvalds 已提交
115
	enum listMode mode;
116
	enum optionMode optMode;
L
Linus Torvalds 已提交
117 118 119
	struct menu *rootEntry;
	QColorGroup disabledColorGroup;
	QColorGroup inactivedColorGroup;
120
	QMenu* headerPopup;
L
Linus Torvalds 已提交
121 122 123 124 125 126

private:
	int colMap[colNr];
	int colRevMap[colNr];
};

A
Alexander Stein 已提交
127 128
class ConfigItem : public Q3ListViewItem {
	typedef class Q3ListViewItem Parent;
L
Linus Torvalds 已提交
129
public:
A
Alexander Stein 已提交
130
	ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v)
L
Linus Torvalds 已提交
131 132 133 134 135 136 137 138 139
	: 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();
	}
A
Alexander Stein 已提交
140
	ConfigItem(Q3ListView *parent, ConfigItem *after, bool v)
L
Linus Torvalds 已提交
141 142 143 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 176 177 178 179 180 181 182 183 184 185 186 187 188 189
	: Parent(parent, after), menu(0), visible(v), goParent(true)
	{
		init();
	}
	~ConfigItem(void);
	void init(void);
	void okRename(int col);
	void updateMenu(void);
	void testUpdateMenu(bool v);
	ConfigList* listView() const
	{
		return (ConfigList*)Parent::listView();
	}
	ConfigItem* firstChild() const
	{
		return (ConfigItem *)Parent::firstChild();
	}
	ConfigItem* nextSibling() const
	{
		return (ConfigItem *)Parent::nextSibling();
	}
	void setText(colIdx idx, const QString& text)
	{
		Parent::setText(listView()->mapIdx(idx), text);
	}
	QString text(colIdx idx) const
	{
		return Parent::text(listView()->mapIdx(idx));
	}
	void setPixmap(colIdx idx, const QPixmap& pm)
	{
		Parent::setPixmap(listView()->mapIdx(idx), pm);
	}
	const QPixmap* pixmap(colIdx idx) const
	{
		return Parent::pixmap(listView()->mapIdx(idx));
	}
	void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align);

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

class ConfigLineEdit : public QLineEdit {
	Q_OBJECT
	typedef class QLineEdit Parent;
public:
190
	ConfigLineEdit(ConfigView* parent);
L
Linus Torvalds 已提交
191 192 193 194 195 196 197 198 199 200 201
	ConfigView* parent(void) const
	{
		return (ConfigView*)Parent::parent();
	}
	void show(ConfigItem *i);
	void keyPressEvent(QKeyEvent *e);

public:
	ConfigItem *item;
};

202
class ConfigView : public QWidget {
203
	Q_OBJECT
204
	typedef class QWidget Parent;
205 206 207 208 209 210 211 212 213 214 215 216 217
public:
	ConfigView(QWidget* parent, const char *name = 0);
	~ConfigView(void);
	static void updateList(ConfigItem* item);
	static void updateListAll(void);

	bool showName(void) const { return list->showName; }
	bool showRange(void) const { return list->showRange; }
	bool showData(void) const { return list->showData; }
public slots:
	void setShowName(bool);
	void setShowRange(bool);
	void setShowData(bool);
218
	void setOptionMode(QAction *);
219 220 221 222 223 224 225 226 227 228
signals:
	void showNameChanged(bool);
	void showRangeChanged(bool);
	void showDataChanged(bool);
public:
	ConfigList* list;
	ConfigLineEdit* lineEdit;

	static ConfigView* viewList;
	ConfigView* nextView;
229 230 231 232

	static QAction *showNormalAction;
	static QAction *showAllAction;
	static QAction *showPromptAction;
233 234
};

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

public slots:
	void setInfo(struct menu *menu);
244
	void saveSettings(void);
245 246 247 248
	void setShowDebug(bool);

signals:
	void showDebugChanged(bool);
249
	void menuSelected(struct menu *);
250 251

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

260
	struct symbol *sym;
A
Alexander Stein 已提交
261
	struct menu *_menu;
262 263 264 265 266 267 268
	bool _showDebug;
};

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

271
public slots:
272
	void saveSettings(void);
273
	void search(void);
274

275 276 277
protected:
	QLineEdit* editField;
	QPushButton* searchButton;
278
	QSplitter* split;
279 280 281 282 283 284
	ConfigView* list;
	ConfigInfoView* info;

	struct symbol **result;
};

285
class ConfigMainWindow : public QMainWindow {
L
Linus Torvalds 已提交
286
	Q_OBJECT
287

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

protected:
	void closeEvent(QCloseEvent *e);

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