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

#include <qlistview.h>
#if QT_VERSION >= 300
#include <qsettings.h>
#else
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
class QSettings {
public:
	void beginGroup(const QString& group) { }
	void endGroup(void) { }
	bool readBoolEntry(const QString& key, bool def = FALSE, bool* ok = 0) const
	{ if (ok) *ok = FALSE; return def; }
	int readNumEntry(const QString& key, int def = 0, bool* ok = 0) const
	{ if (ok) *ok = FALSE; return def; }
	QString readEntry(const QString& key, const QString& def = QString::null, bool* ok = 0) const
	{ if (ok) *ok = FALSE; return def; }
	QStringList readListEntry(const QString& key, bool* ok = 0) const
	{ if (ok) *ok = FALSE; return QStringList(); }
	template <class t>
	bool writeEntry(const QString& key, t value)
	{ return TRUE; }
};
L
Linus Torvalds 已提交
26 27
#endif

28
class ConfigView;
L
Linus Torvalds 已提交
29 30 31 32 33 34 35 36
class ConfigList;
class ConfigItem;
class ConfigLineEdit;
class ConfigMainWindow;


class ConfigSettings : public QSettings {
public:
37 38
	QValueList<int> readSizes(const QString& key, bool *ok);
	bool writeSizes(const QString& key, const QValueList<int>& value);
L
Linus Torvalds 已提交
39 40 41 42 43 44
};

enum colIdx {
	promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
};
enum listMode {
45
	singleMode, menuMode, symbolMode, fullMode, listMode
L
Linus Torvalds 已提交
46
};
47 48 49
enum optionMode {
	normalOpt = 0, allOpt, promptOpt
};
L
Linus Torvalds 已提交
50 51 52 53 54

class ConfigList : public QListView {
	Q_OBJECT
	typedef class QListView Parent;
public:
55
	ConfigList(ConfigView* p, const char *name = 0);
L
Linus Torvalds 已提交
56 57 58 59 60
	void reinit(void);
	ConfigView* parent(void) const
	{
		return (ConfigView*)Parent::parent();
	}
61
	ConfigItem* findConfigItem(struct menu *);
L
Linus Torvalds 已提交
62 63 64 65 66 67 68 69

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

L
Linus Torvalds 已提交
72 73 74 75 76 77 78
public slots:
	void setRootMenu(struct menu *menu);

	void updateList(ConfigItem *item);
	void setValue(ConfigItem* item, tristate val);
	void changeValue(ConfigItem* item);
	void updateSelection(void);
79
	void saveSettings(void);
L
Linus Torvalds 已提交
80
signals:
81
	void menuChanged(struct menu *menu);
L
Linus Torvalds 已提交
82 83
	void menuSelected(struct menu *menu);
	void parentSelected(void);
84
	void gotFocus(struct menu *);
L
Linus Torvalds 已提交
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

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);

121 122
	bool menuSkip(struct menu *);

L
Linus Torvalds 已提交
123
	template <class P>
124
	void updateMenuList(P*, struct menu*);
L
Linus Torvalds 已提交
125 126 127 128 129 130 131

	bool updateAll;

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

132
	bool showName, showRange, showData;
L
Linus Torvalds 已提交
133
	enum listMode mode;
134
	enum optionMode optMode;
L
Linus Torvalds 已提交
135 136 137
	struct menu *rootEntry;
	QColorGroup disabledColorGroup;
	QColorGroup inactivedColorGroup;
138
	QPopupMenu* headerPopup;
L
Linus Torvalds 已提交
139 140 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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209

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

class ConfigItem : public QListViewItem {
	typedef class QListViewItem Parent;
public:
	ConfigItem(QListView *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(QListView *parent, ConfigItem *after, bool v)
	: Parent(parent, after), menu(0), visible(v), goParent(true)
	{
		init();
	}
	~ConfigItem(void);
	void init(void);
#if QT_VERSION >= 300
	void okRename(int col);
#endif
	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:
210
	ConfigLineEdit(ConfigView* parent);
L
Linus Torvalds 已提交
211 212 213 214 215 216 217 218 219 220 221
	ConfigView* parent(void) const
	{
		return (ConfigView*)Parent::parent();
	}
	void show(ConfigItem *i);
	void keyPressEvent(QKeyEvent *e);

public:
	ConfigItem *item;
};

222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
class ConfigView : public QVBox {
	Q_OBJECT
	typedef class QVBox Parent;
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);
238
	void setOptionMode(QAction *);
239 240 241 242 243 244 245 246 247 248
signals:
	void showNameChanged(bool);
	void showRangeChanged(bool);
	void showDataChanged(bool);
public:
	ConfigList* list;
	ConfigLineEdit* lineEdit;

	static ConfigView* viewList;
	ConfigView* nextView;
249 250 251 252

	static QAction *showNormalAction;
	static QAction *showAllAction;
	static QAction *showPromptAction;
253 254
};

255 256 257 258 259 260 261 262 263
class ConfigInfoView : public QTextBrowser {
	Q_OBJECT
	typedef class QTextBrowser Parent;
public:
	ConfigInfoView(QWidget* parent, const char *name = 0);
	bool showDebug(void) const { return _showDebug; }

public slots:
	void setInfo(struct menu *menu);
264
	void saveSettings(void);
265 266 267 268
	void setShowDebug(bool);

signals:
	void showDebugChanged(bool);
269
	void menuSelected(struct menu *);
270 271

protected:
272
	void symbolInfo(void);
273 274 275
	void menuInfo(void);
	QString debug_info(struct symbol *sym);
	static QString print_filter(const QString &str);
276
	static void expr_print_help(void *data, struct symbol *sym, const char *str);
277 278
	QPopupMenu* createPopupMenu(const QPoint& pos);
	void contentsContextMenuEvent(QContextMenuEvent *e);
279

280
	struct symbol *sym;
281 282 283 284 285 286 287 288
	struct menu *menu;
	bool _showDebug;
};

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

291
public slots:
292
	void saveSettings(void);
293
	void search(void);
294

295 296 297
protected:
	QLineEdit* editField;
	QPushButton* searchButton;
298
	QSplitter* split;
299 300 301 302 303 304
	ConfigView* list;
	ConfigInfoView* info;

	struct symbol **result;
};

L
Linus Torvalds 已提交
305 306
class ConfigMainWindow : public QMainWindow {
	Q_OBJECT
307 308 309

	static QAction *saveAction;
	static void conf_changed(void);
L
Linus Torvalds 已提交
310 311 312 313
public:
	ConfigMainWindow(void);
public slots:
	void changeMenu(struct menu *);
314
	void setMenuLink(struct menu *);
L
Linus Torvalds 已提交
315 316 317 318 319
	void listFocusChanged(void);
	void goBack(void);
	void loadConfig(void);
	void saveConfig(void);
	void saveConfigAs(void);
320
	void searchConfig(void);
L
Linus Torvalds 已提交
321 322 323 324 325 326 327 328 329 330
	void showSingleView(void);
	void showSplitView(void);
	void showFullView(void);
	void showIntro(void);
	void showAbout(void);
	void saveSettings(void);

protected:
	void closeEvent(QCloseEvent *e);

331
	ConfigSearchWindow *searchWindow;
L
Linus Torvalds 已提交
332 333 334 335
	ConfigView *menuView;
	ConfigList *menuList;
	ConfigView *configView;
	ConfigList *configList;
336
	ConfigInfoView *helpText;
L
Linus Torvalds 已提交
337 338 339 340 341
	QToolBar *toolBar;
	QAction *backAction;
	QSplitter* split1;
	QSplitter* split2;
};