qconf.h 4.0 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;
L
Linus Torvalds 已提交
20 21 22 23 24
class ConfigLineEdit;
class ConfigMainWindow;

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

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

class ConfigLineEdit : public QLineEdit {
	Q_OBJECT
	typedef class QLineEdit Parent;
public:
44
	ConfigLineEdit(ConfigView* parent);
L
Linus Torvalds 已提交
45 46 47 48
	ConfigView* parent(void) const
	{
		return (ConfigView*)Parent::parent();
	}
49
	void show(QTreeWidgetItem *i);
L
Linus Torvalds 已提交
50 51 52
	void keyPressEvent(QKeyEvent *e);

public:
53
	QTreeWidgetItem *item;
L
Linus Torvalds 已提交
54 55
};

56
class ConfigView : public QWidget {
57
	Q_OBJECT
58
	typedef class QWidget Parent;
59 60 61
public:
	ConfigView(QWidget* parent, const char *name = 0);
	~ConfigView(void);
62
	static void updateList(QTreeWidgetItem* item);
63 64
	static void updateListAll(void);

65 66 67
	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.
68 69 70 71
public slots:
	void setShowName(bool);
	void setShowRange(bool);
	void setShowData(bool);
72
	void setOptionMode(QAction *);
73 74 75 76 77
signals:
	void showNameChanged(bool);
	void showRangeChanged(bool);
	void showDataChanged(bool);
public:
78
	QTreeWidget* list;
79 80 81 82
	ConfigLineEdit* lineEdit;

	static ConfigView* viewList;
	ConfigView* nextView;
83 84 85 86

	static QAction *showNormalAction;
	static QAction *showAllAction;
	static QAction *showPromptAction;
87 88
};

89
class ConfigInfoView : public QTextBrowser {
90
	Q_OBJECT
91
	typedef class QTextBrowser Parent;
92 93 94 95 96 97
public:
	ConfigInfoView(QWidget* parent, const char *name = 0);
	bool showDebug(void) const { return _showDebug; }

public slots:
	void setInfo(struct menu *menu);
98
	void saveSettings(void);
99 100 101 102
	void setShowDebug(bool);

signals:
	void showDebugChanged(bool);
103
	void menuSelected(struct menu *);
104 105

protected:
106
	void symbolInfo(void);
107 108 109
	void menuInfo(void);
	QString debug_info(struct symbol *sym);
	static QString print_filter(const QString &str);
110
	static void expr_print_help(void *data, struct symbol *sym, const char *str);
111 112
	QMenu *createStandardContextMenu(const QPoint & pos);
	void contextMenuEvent(QContextMenuEvent *e);
113

114
	struct symbol *sym;
A
Alexander Stein 已提交
115
	struct menu *_menu;
116 117 118 119 120 121 122
	bool _showDebug;
};

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

125
public slots:
126
	void saveSettings(void);
127
	void search(void);
128

129 130 131
protected:
	QLineEdit* editField;
	QPushButton* searchButton;
132
	QSplitter* split;
133 134 135 136 137 138
	ConfigView* list;
	ConfigInfoView* info;

	struct symbol **result;
};

139
class ConfigMainWindow : public QMainWindow {
L
Linus Torvalds 已提交
140
	Q_OBJECT
141

142
	static QAction *saveAction;
143
	static void conf_changed(void);
L
Linus Torvalds 已提交
144 145 146 147
public:
	ConfigMainWindow(void);
public slots:
	void changeMenu(struct menu *);
148
	void setMenuLink(struct menu *);
L
Linus Torvalds 已提交
149 150 151
	void listFocusChanged(void);
	void goBack(void);
	void loadConfig(void);
152
	bool saveConfig(void);
L
Linus Torvalds 已提交
153
	void saveConfigAs(void);
154
	void searchConfig(void);
L
Linus Torvalds 已提交
155 156 157 158 159 160 161 162 163 164
	void showSingleView(void);
	void showSplitView(void);
	void showFullView(void);
	void showIntro(void);
	void showAbout(void);
	void saveSettings(void);

protected:
	void closeEvent(QCloseEvent *e);

165
	ConfigSearchWindow *searchWindow;
L
Linus Torvalds 已提交
166
	ConfigView *menuView;
167
	QTreeWidget *menuList;
L
Linus Torvalds 已提交
168
	ConfigView *configView;
169
	QTreeWidget *configList;
170
	ConfigInfoView *helpText;
171
	QToolBar *toolBar;
172
	QAction *backAction;
173 174 175
	QAction *singleViewAction;
	QAction *splitViewAction;
	QAction *fullViewAction;
176 177
	QSplitter *split1;
	QSplitter *split2;
L
Linus Torvalds 已提交
178
};