Loading...
1/*
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 <QTextBrowser>
7#include <QTreeWidget>
8#include <QMainWindow>
9#include <QHeaderView>
10#include <qsettings.h>
11#include <QPushButton>
12#include <QSettings>
13#include <QLineEdit>
14#include <QSplitter>
15#include <QCheckBox>
16#include <QDialog>
17#include "expr.h"
18
19class ConfigView;
20class ConfigList;
21class ConfigItem;
22class ConfigLineEdit;
23class ConfigMainWindow;
24
25class ConfigSettings : public QSettings {
26public:
27 ConfigSettings();
28 QList<int> readSizes(const QString& key, bool *ok);
29 bool writeSizes(const QString& key, const QList<int>& value);
30};
31
32enum colIdx {
33 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
34};
35enum listMode {
36 singleMode, menuMode, symbolMode, fullMode, listMode
37};
38enum optionMode {
39 normalOpt = 0, allOpt, promptOpt
40};
41
42class ConfigList : public QTreeWidget {
43 Q_OBJECT
44 typedef class QTreeWidget Parent;
45public:
46 ConfigList(ConfigView* p, const char *name = 0);
47 void reinit(void);
48 ConfigView* parent(void) const
49 {
50 return (ConfigView*)Parent::parent();
51 }
52 ConfigItem* findConfigItem(struct menu *);
53
54protected:
55 void keyPressEvent(QKeyEvent *e);
56 void mousePressEvent(QMouseEvent *e);
57 void mouseReleaseEvent(QMouseEvent *e);
58 void mouseMoveEvent(QMouseEvent *e);
59 void mouseDoubleClickEvent(QMouseEvent *e);
60 void focusInEvent(QFocusEvent *e);
61 void contextMenuEvent(QContextMenuEvent *e);
62
63public slots:
64 void setRootMenu(struct menu *menu);
65
66 void updateList(ConfigItem *item);
67 void setValue(ConfigItem* item, tristate val);
68 void changeValue(ConfigItem* item);
69 void updateSelection(void);
70 void saveSettings(void);
71signals:
72 void menuChanged(struct menu *menu);
73 void menuSelected(struct menu *menu);
74 void parentSelected(void);
75 void gotFocus(struct menu *);
76
77public:
78 void updateListAll(void)
79 {
80 updateAll = true;
81 updateList(NULL);
82 updateAll = false;
83 }
84 ConfigList* listView()
85 {
86 return this;
87 }
88 ConfigItem* firstChild() const
89 {
90 return (ConfigItem *)children().first();
91 }
92 void addColumn(colIdx idx)
93 {
94 showColumn(idx);
95 }
96 void removeColumn(colIdx idx)
97 {
98 hideColumn(idx);
99 }
100 void setAllOpen(bool open);
101 void setParentMenu(void);
102
103 bool menuSkip(struct menu *);
104
105 void updateMenuList(ConfigItem *parent, struct menu*);
106 void updateMenuList(ConfigList *parent, struct menu*);
107
108 bool updateAll;
109
110 QPixmap symbolYesPix, symbolModPix, symbolNoPix;
111 QPixmap choiceYesPix, choiceNoPix;
112 QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
113
114 bool showName, showRange, showData;
115 enum listMode mode;
116 enum optionMode optMode;
117 struct menu *rootEntry;
118 QPalette disabledColorGroup;
119 QPalette inactivedColorGroup;
120 QMenu* headerPopup;
121};
122
123class ConfigItem : public QTreeWidgetItem {
124 typedef class QTreeWidgetItem Parent;
125public:
126 ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
127 : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
128 {
129 init();
130 }
131 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
132 : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
133 {
134 init();
135 }
136 ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
137 : Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
138 {
139 init();
140 }
141 ~ConfigItem(void);
142 void init(void);
143 void okRename(int col);
144 void updateMenu(void);
145 void testUpdateMenu(bool v);
146 ConfigList* listView() const
147 {
148 return (ConfigList*)Parent::treeWidget();
149 }
150 ConfigItem* firstChild() const
151 {
152 return (ConfigItem *)Parent::child(0);
153 }
154 ConfigItem* nextSibling()
155 {
156 ConfigItem *ret = NULL;
157 ConfigItem *_parent = (ConfigItem *)parent();
158
159 if(_parent) {
160 ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1);
161 } else {
162 QTreeWidget *_treeWidget = treeWidget();
163 ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1);
164 }
165
166 return ret;
167 }
168 void setText(colIdx idx, const QString& text)
169 {
170 Parent::setText(idx, text);
171 }
172 QString text(colIdx idx) const
173 {
174 return Parent::text(idx);
175 }
176 void setPixmap(colIdx idx, const QIcon &icon)
177 {
178 Parent::setIcon(idx, icon);
179 }
180 const QIcon pixmap(colIdx idx) const
181 {
182 return icon(idx);
183 }
184 // TODO: Implement paintCell
185
186 ConfigItem* nextItem;
187 struct menu *menu;
188 bool visible;
189 bool goParent;
190};
191
192class ConfigLineEdit : public QLineEdit {
193 Q_OBJECT
194 typedef class QLineEdit Parent;
195public:
196 ConfigLineEdit(ConfigView* parent);
197 ConfigView* parent(void) const
198 {
199 return (ConfigView*)Parent::parent();
200 }
201 void show(ConfigItem *i);
202 void keyPressEvent(QKeyEvent *e);
203
204public:
205 ConfigItem *item;
206};
207
208class ConfigView : public QWidget {
209 Q_OBJECT
210 typedef class QWidget Parent;
211public:
212 ConfigView(QWidget* parent, const char *name = 0);
213 ~ConfigView(void);
214 static void updateList(ConfigItem* item);
215 static void updateListAll(void);
216
217 bool showName(void) const { return list->showName; }
218 bool showRange(void) const { return list->showRange; }
219 bool showData(void) const { return list->showData; }
220public slots:
221 void setShowName(bool);
222 void setShowRange(bool);
223 void setShowData(bool);
224 void setOptionMode(QAction *);
225signals:
226 void showNameChanged(bool);
227 void showRangeChanged(bool);
228 void showDataChanged(bool);
229public:
230 ConfigList* list;
231 ConfigLineEdit* lineEdit;
232
233 static ConfigView* viewList;
234 ConfigView* nextView;
235
236 static QAction *showNormalAction;
237 static QAction *showAllAction;
238 static QAction *showPromptAction;
239};
240
241class ConfigInfoView : public QTextBrowser {
242 Q_OBJECT
243 typedef class QTextBrowser Parent;
244public:
245 ConfigInfoView(QWidget* parent, const char *name = 0);
246 bool showDebug(void) const { return _showDebug; }
247
248public slots:
249 void setInfo(struct menu *menu);
250 void saveSettings(void);
251 void setShowDebug(bool);
252
253signals:
254 void showDebugChanged(bool);
255 void menuSelected(struct menu *);
256
257protected:
258 void symbolInfo(void);
259 void menuInfo(void);
260 QString debug_info(struct symbol *sym);
261 static QString print_filter(const QString &str);
262 static void expr_print_help(void *data, struct symbol *sym, const char *str);
263 QMenu *createStandardContextMenu(const QPoint & pos);
264 void contextMenuEvent(QContextMenuEvent *e);
265
266 struct symbol *sym;
267 struct menu *_menu;
268 bool _showDebug;
269};
270
271class ConfigSearchWindow : public QDialog {
272 Q_OBJECT
273 typedef class QDialog Parent;
274public:
275 ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0);
276
277public slots:
278 void saveSettings(void);
279 void search(void);
280
281protected:
282 QLineEdit* editField;
283 QPushButton* searchButton;
284 QSplitter* split;
285 ConfigView* list;
286 ConfigInfoView* info;
287
288 struct symbol **result;
289};
290
291class ConfigMainWindow : public QMainWindow {
292 Q_OBJECT
293
294 static QAction *saveAction;
295 static void conf_changed(void);
296public:
297 ConfigMainWindow(void);
298public slots:
299 void changeMenu(struct menu *);
300 void setMenuLink(struct menu *);
301 void listFocusChanged(void);
302 void goBack(void);
303 void loadConfig(void);
304 bool saveConfig(void);
305 void saveConfigAs(void);
306 void searchConfig(void);
307 void showSingleView(void);
308 void showSplitView(void);
309 void showFullView(void);
310 void showIntro(void);
311 void showAbout(void);
312 void saveSettings(void);
313
314protected:
315 void closeEvent(QCloseEvent *e);
316
317 ConfigSearchWindow *searchWindow;
318 ConfigView *menuView;
319 ConfigList *menuList;
320 ConfigView *configView;
321 ConfigList *configList;
322 ConfigInfoView *helpText;
323 QToolBar *toolBar;
324 QAction *backAction;
325 QAction *singleViewAction;
326 QAction *splitViewAction;
327 QAction *fullViewAction;
328 QSplitter *split1;
329 QSplitter *split2;
330};
1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#if QT_VERSION < 0x040000
7#include <qlistview.h>
8#else
9#include <q3listview.h>
10#endif
11#include <qsettings.h>
12
13#if QT_VERSION < 0x040000
14#define Q3ValueList QValueList
15#define Q3PopupMenu QPopupMenu
16#define Q3ListView QListView
17#define Q3ListViewItem QListViewItem
18#define Q3VBox QVBox
19#define Q3TextBrowser QTextBrowser
20#define Q3MainWindow QMainWindow
21#define Q3Action QAction
22#define Q3ToolBar QToolBar
23#define Q3ListViewItemIterator QListViewItemIterator
24#define Q3FileDialog QFileDialog
25#endif
26
27class ConfigView;
28class ConfigList;
29class ConfigItem;
30class ConfigLineEdit;
31class ConfigMainWindow;
32
33class ConfigSettings : public QSettings {
34public:
35 Q3ValueList<int> readSizes(const QString& key, bool *ok);
36 bool writeSizes(const QString& key, const Q3ValueList<int>& value);
37};
38
39enum colIdx {
40 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
41};
42enum listMode {
43 singleMode, menuMode, symbolMode, fullMode, listMode
44};
45enum optionMode {
46 normalOpt = 0, allOpt, promptOpt
47};
48
49class ConfigList : public Q3ListView {
50 Q_OBJECT
51 typedef class Q3ListView Parent;
52public:
53 ConfigList(ConfigView* p, const char *name = 0);
54 void reinit(void);
55 ConfigView* parent(void) const
56 {
57 return (ConfigView*)Parent::parent();
58 }
59 ConfigItem* findConfigItem(struct menu *);
60
61protected:
62 void keyPressEvent(QKeyEvent *e);
63 void contentsMousePressEvent(QMouseEvent *e);
64 void contentsMouseReleaseEvent(QMouseEvent *e);
65 void contentsMouseMoveEvent(QMouseEvent *e);
66 void contentsMouseDoubleClickEvent(QMouseEvent *e);
67 void focusInEvent(QFocusEvent *e);
68 void contextMenuEvent(QContextMenuEvent *e);
69
70public slots:
71 void setRootMenu(struct menu *menu);
72
73 void updateList(ConfigItem *item);
74 void setValue(ConfigItem* item, tristate val);
75 void changeValue(ConfigItem* item);
76 void updateSelection(void);
77 void saveSettings(void);
78signals:
79 void menuChanged(struct menu *menu);
80 void menuSelected(struct menu *menu);
81 void parentSelected(void);
82 void gotFocus(struct menu *);
83
84public:
85 void updateListAll(void)
86 {
87 updateAll = true;
88 updateList(NULL);
89 updateAll = false;
90 }
91 ConfigList* listView()
92 {
93 return this;
94 }
95 ConfigItem* firstChild() const
96 {
97 return (ConfigItem *)Parent::firstChild();
98 }
99 int mapIdx(colIdx idx)
100 {
101 return colMap[idx];
102 }
103 void addColumn(colIdx idx, const QString& label)
104 {
105 colMap[idx] = Parent::addColumn(label);
106 colRevMap[colMap[idx]] = idx;
107 }
108 void removeColumn(colIdx idx)
109 {
110 int col = colMap[idx];
111 if (col >= 0) {
112 Parent::removeColumn(col);
113 colRevMap[col] = colMap[idx] = -1;
114 }
115 }
116 void setAllOpen(bool open);
117 void setParentMenu(void);
118
119 bool menuSkip(struct menu *);
120
121 template <class P>
122 void updateMenuList(P*, struct menu*);
123
124 bool updateAll;
125
126 QPixmap symbolYesPix, symbolModPix, symbolNoPix;
127 QPixmap choiceYesPix, choiceNoPix;
128 QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
129
130 bool showName, showRange, showData;
131 enum listMode mode;
132 enum optionMode optMode;
133 struct menu *rootEntry;
134 QColorGroup disabledColorGroup;
135 QColorGroup inactivedColorGroup;
136 Q3PopupMenu* headerPopup;
137
138private:
139 int colMap[colNr];
140 int colRevMap[colNr];
141};
142
143class ConfigItem : public Q3ListViewItem {
144 typedef class Q3ListViewItem Parent;
145public:
146 ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v)
147 : Parent(parent, after), menu(m), visible(v), goParent(false)
148 {
149 init();
150 }
151 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
152 : Parent(parent, after), menu(m), visible(v), goParent(false)
153 {
154 init();
155 }
156 ConfigItem(Q3ListView *parent, ConfigItem *after, bool v)
157 : Parent(parent, after), menu(0), visible(v), goParent(true)
158 {
159 init();
160 }
161 ~ConfigItem(void);
162 void init(void);
163 void okRename(int col);
164 void updateMenu(void);
165 void testUpdateMenu(bool v);
166 ConfigList* listView() const
167 {
168 return (ConfigList*)Parent::listView();
169 }
170 ConfigItem* firstChild() const
171 {
172 return (ConfigItem *)Parent::firstChild();
173 }
174 ConfigItem* nextSibling() const
175 {
176 return (ConfigItem *)Parent::nextSibling();
177 }
178 void setText(colIdx idx, const QString& text)
179 {
180 Parent::setText(listView()->mapIdx(idx), text);
181 }
182 QString text(colIdx idx) const
183 {
184 return Parent::text(listView()->mapIdx(idx));
185 }
186 void setPixmap(colIdx idx, const QPixmap& pm)
187 {
188 Parent::setPixmap(listView()->mapIdx(idx), pm);
189 }
190 const QPixmap* pixmap(colIdx idx) const
191 {
192 return Parent::pixmap(listView()->mapIdx(idx));
193 }
194 void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align);
195
196 ConfigItem* nextItem;
197 struct menu *menu;
198 bool visible;
199 bool goParent;
200};
201
202class ConfigLineEdit : public QLineEdit {
203 Q_OBJECT
204 typedef class QLineEdit Parent;
205public:
206 ConfigLineEdit(ConfigView* parent);
207 ConfigView* parent(void) const
208 {
209 return (ConfigView*)Parent::parent();
210 }
211 void show(ConfigItem *i);
212 void keyPressEvent(QKeyEvent *e);
213
214public:
215 ConfigItem *item;
216};
217
218class ConfigView : public Q3VBox {
219 Q_OBJECT
220 typedef class Q3VBox Parent;
221public:
222 ConfigView(QWidget* parent, const char *name = 0);
223 ~ConfigView(void);
224 static void updateList(ConfigItem* item);
225 static void updateListAll(void);
226
227 bool showName(void) const { return list->showName; }
228 bool showRange(void) const { return list->showRange; }
229 bool showData(void) const { return list->showData; }
230public slots:
231 void setShowName(bool);
232 void setShowRange(bool);
233 void setShowData(bool);
234 void setOptionMode(QAction *);
235signals:
236 void showNameChanged(bool);
237 void showRangeChanged(bool);
238 void showDataChanged(bool);
239public:
240 ConfigList* list;
241 ConfigLineEdit* lineEdit;
242
243 static ConfigView* viewList;
244 ConfigView* nextView;
245
246 static QAction *showNormalAction;
247 static QAction *showAllAction;
248 static QAction *showPromptAction;
249};
250
251class ConfigInfoView : public Q3TextBrowser {
252 Q_OBJECT
253 typedef class Q3TextBrowser Parent;
254public:
255 ConfigInfoView(QWidget* parent, const char *name = 0);
256 bool showDebug(void) const { return _showDebug; }
257
258public slots:
259 void setInfo(struct menu *menu);
260 void saveSettings(void);
261 void setShowDebug(bool);
262
263signals:
264 void showDebugChanged(bool);
265 void menuSelected(struct menu *);
266
267protected:
268 void symbolInfo(void);
269 void menuInfo(void);
270 QString debug_info(struct symbol *sym);
271 static QString print_filter(const QString &str);
272 static void expr_print_help(void *data, struct symbol *sym, const char *str);
273 Q3PopupMenu* createPopupMenu(const QPoint& pos);
274 void contentsContextMenuEvent(QContextMenuEvent *e);
275
276 struct symbol *sym;
277 struct menu *_menu;
278 bool _showDebug;
279};
280
281class ConfigSearchWindow : public QDialog {
282 Q_OBJECT
283 typedef class QDialog Parent;
284public:
285 ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0);
286
287public slots:
288 void saveSettings(void);
289 void search(void);
290
291protected:
292 QLineEdit* editField;
293 QPushButton* searchButton;
294 QSplitter* split;
295 ConfigView* list;
296 ConfigInfoView* info;
297
298 struct symbol **result;
299};
300
301class ConfigMainWindow : public Q3MainWindow {
302 Q_OBJECT
303
304 static Q3Action *saveAction;
305 static void conf_changed(void);
306public:
307 ConfigMainWindow(void);
308public slots:
309 void changeMenu(struct menu *);
310 void setMenuLink(struct menu *);
311 void listFocusChanged(void);
312 void goBack(void);
313 void loadConfig(void);
314 bool saveConfig(void);
315 void saveConfigAs(void);
316 void searchConfig(void);
317 void showSingleView(void);
318 void showSplitView(void);
319 void showFullView(void);
320 void showIntro(void);
321 void showAbout(void);
322 void saveSettings(void);
323
324protected:
325 void closeEvent(QCloseEvent *e);
326
327 ConfigSearchWindow *searchWindow;
328 ConfigView *menuView;
329 ConfigList *menuList;
330 ConfigView *configView;
331 ConfigList *configList;
332 ConfigInfoView *helpText;
333 Q3ToolBar *toolBar;
334 Q3Action *backAction;
335 QSplitter* split1;
336 QSplitter* split2;
337};