blob: a548d13149b343a21e09f3b2255cfb0a080263f8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <qlistview.h>
7#if QT_VERSION >= 300
8#include <qsettings.h>
9#else
10class QSettings { };
11#endif
12
13class ConfigList;
14class ConfigItem;
15class ConfigLineEdit;
16class ConfigMainWindow;
17
18
19class ConfigSettings : public QSettings {
20public:
21 ConfigSettings();
22
23#if QT_VERSION >= 300
24 void readListSettings();
Dave Jones19144d02006-01-08 01:05:02 -080025 QValueList<int> readSizes(const QString& key, bool *ok);
26 bool writeSizes(const QString& key, const QValueList<int>& value);
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#endif
28
29 bool showAll;
30 bool showName;
31 bool showRange;
32 bool showData;
33};
34
35class ConfigView : public QVBox {
36 Q_OBJECT
37 typedef class QVBox Parent;
38public:
Roman Zippel43bf6122006-06-08 22:12:45 -070039 ConfigView(QWidget* parent, ConfigSettings* configSettings);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 ~ConfigView(void);
41 static void updateList(ConfigItem* item);
42 static void updateListAll(void);
43
44public:
45 ConfigList* list;
46 ConfigLineEdit* lineEdit;
47
48 static ConfigView* viewList;
49 ConfigView* nextView;
50};
51
52enum colIdx {
53 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
54};
55enum listMode {
Roman Zippel43bf6122006-06-08 22:12:45 -070056 singleMode, menuMode, symbolMode, fullMode, listMode
Linus Torvalds1da177e2005-04-16 15:20:36 -070057};
58
59class ConfigList : public QListView {
60 Q_OBJECT
61 typedef class QListView Parent;
62public:
Roman Zippel43bf6122006-06-08 22:12:45 -070063 ConfigList(ConfigView* p, ConfigSettings *configSettings);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 void reinit(void);
65 ConfigView* parent(void) const
66 {
67 return (ConfigView*)Parent::parent();
68 }
69
70protected:
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 void keyPressEvent(QKeyEvent *e);
72 void contentsMousePressEvent(QMouseEvent *e);
73 void contentsMouseReleaseEvent(QMouseEvent *e);
74 void contentsMouseMoveEvent(QMouseEvent *e);
75 void contentsMouseDoubleClickEvent(QMouseEvent *e);
76 void focusInEvent(QFocusEvent *e);
77public slots:
78 void setRootMenu(struct menu *menu);
79
80 void updateList(ConfigItem *item);
81 void setValue(ConfigItem* item, tristate val);
82 void changeValue(ConfigItem* item);
83 void updateSelection(void);
84signals:
Roman Zippel43bf6122006-06-08 22:12:45 -070085 void menuChanged(struct menu *menu);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 void menuSelected(struct menu *menu);
87 void parentSelected(void);
88 void gotFocus(void);
89
90public:
91 void updateListAll(void)
92 {
93 updateAll = true;
94 updateList(NULL);
95 updateAll = false;
96 }
97 ConfigList* listView()
98 {
99 return this;
100 }
101 ConfigItem* firstChild() const
102 {
103 return (ConfigItem *)Parent::firstChild();
104 }
105 int mapIdx(colIdx idx)
106 {
107 return colMap[idx];
108 }
109 void addColumn(colIdx idx, const QString& label)
110 {
111 colMap[idx] = Parent::addColumn(label);
112 colRevMap[colMap[idx]] = idx;
113 }
114 void removeColumn(colIdx idx)
115 {
116 int col = colMap[idx];
117 if (col >= 0) {
118 Parent::removeColumn(col);
119 colRevMap[col] = colMap[idx] = -1;
120 }
121 }
122 void setAllOpen(bool open);
123 void setParentMenu(void);
124
125 template <class P>
Dave Jones19144d02006-01-08 01:05:02 -0800126 void updateMenuList(P*, struct menu*);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128 bool updateAll;
129
130 QPixmap symbolYesPix, symbolModPix, symbolNoPix;
131 QPixmap choiceYesPix, choiceNoPix;
132 QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
133
134 bool showAll, showName, showRange, showData;
135 enum listMode mode;
136 struct menu *rootEntry;
137 QColorGroup disabledColorGroup;
138 QColorGroup inactivedColorGroup;
139
140private:
141 int colMap[colNr];
142 int colRevMap[colNr];
143};
144
145class ConfigItem : public QListViewItem {
146 typedef class QListViewItem Parent;
147public:
148 ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v)
149 : Parent(parent, after), menu(m), visible(v), goParent(false)
150 {
151 init();
152 }
153 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
154 : Parent(parent, after), menu(m), visible(v), goParent(false)
155 {
156 init();
157 }
158 ConfigItem(QListView *parent, ConfigItem *after, bool v)
159 : Parent(parent, after), menu(0), visible(v), goParent(true)
160 {
161 init();
162 }
163 ~ConfigItem(void);
164 void init(void);
165#if QT_VERSION >= 300
166 void okRename(int col);
167#endif
168 void updateMenu(void);
169 void testUpdateMenu(bool v);
170 ConfigList* listView() const
171 {
172 return (ConfigList*)Parent::listView();
173 }
174 ConfigItem* firstChild() const
175 {
176 return (ConfigItem *)Parent::firstChild();
177 }
178 ConfigItem* nextSibling() const
179 {
180 return (ConfigItem *)Parent::nextSibling();
181 }
182 void setText(colIdx idx, const QString& text)
183 {
184 Parent::setText(listView()->mapIdx(idx), text);
185 }
186 QString text(colIdx idx) const
187 {
188 return Parent::text(listView()->mapIdx(idx));
189 }
190 void setPixmap(colIdx idx, const QPixmap& pm)
191 {
192 Parent::setPixmap(listView()->mapIdx(idx), pm);
193 }
194 const QPixmap* pixmap(colIdx idx) const
195 {
196 return Parent::pixmap(listView()->mapIdx(idx));
197 }
198 void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align);
199
200 ConfigItem* nextItem;
201 struct menu *menu;
202 bool visible;
203 bool goParent;
204};
205
206class ConfigLineEdit : public QLineEdit {
207 Q_OBJECT
208 typedef class QLineEdit Parent;
209public:
Roman Zippel43bf6122006-06-08 22:12:45 -0700210 ConfigLineEdit(ConfigView* parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 ConfigView* parent(void) const
212 {
213 return (ConfigView*)Parent::parent();
214 }
215 void show(ConfigItem *i);
216 void keyPressEvent(QKeyEvent *e);
217
218public:
219 ConfigItem *item;
220};
221
Roman Zippel43bf6122006-06-08 22:12:45 -0700222class ConfigInfoView : public QTextBrowser {
223 Q_OBJECT
224 typedef class QTextBrowser Parent;
225public:
226 ConfigInfoView(QWidget* parent, const char *name = 0);
227 bool showDebug(void) const { return _showDebug; }
228
229public slots:
230 void setInfo(struct menu *menu);
231 void setSource(const QString& name);
232 void setShowDebug(bool);
233
234signals:
235 void showDebugChanged(bool);
236
237protected:
238 void menuInfo(void);
239 QString debug_info(struct symbol *sym);
240 static QString print_filter(const QString &str);
241 static void expr_print_help(void *data, const char *str);
242
243 struct menu *menu;
244 bool _showDebug;
245};
246
247class ConfigSearchWindow : public QDialog {
248 Q_OBJECT
249 typedef class QDialog Parent;
250public:
251 ConfigSearchWindow(QWidget* parent);
252public slots:
253 void search(void);
254protected:
255 QLineEdit* editField;
256 QPushButton* searchButton;
257 ConfigView* list;
258 ConfigInfoView* info;
259
260 struct symbol **result;
261};
262
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263class ConfigMainWindow : public QMainWindow {
264 Q_OBJECT
265public:
266 ConfigMainWindow(void);
267public slots:
268 void setHelp(QListViewItem* item);
269 void changeMenu(struct menu *);
270 void listFocusChanged(void);
271 void goBack(void);
272 void loadConfig(void);
273 void saveConfig(void);
274 void saveConfigAs(void);
Roman Zippel43bf6122006-06-08 22:12:45 -0700275 void searchConfig(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 void showSingleView(void);
277 void showSplitView(void);
278 void showFullView(void);
279 void setShowAll(bool);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 void setShowRange(bool);
281 void setShowName(bool);
282 void setShowData(bool);
283 void showIntro(void);
284 void showAbout(void);
285 void saveSettings(void);
286
287protected:
288 void closeEvent(QCloseEvent *e);
289
Roman Zippel43bf6122006-06-08 22:12:45 -0700290 ConfigSearchWindow *searchWindow;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 ConfigView *menuView;
292 ConfigList *menuList;
293 ConfigView *configView;
294 ConfigList *configList;
Roman Zippel43bf6122006-06-08 22:12:45 -0700295 ConfigInfoView *helpText;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 QToolBar *toolBar;
297 QAction *backAction;
298 QSplitter* split1;
299 QSplitter* split2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300};