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