1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
10 #include <QMainWindow>
11 #include <QPushButton>
14 #include <QTextBrowser>
15 #include <QTreeWidget>
23 class ConfigMainWindow;
25 class ConfigSettings : public QSettings {
28 QList<int> readSizes(const QString& key, bool *ok);
29 bool writeSizes(const QString& key, const QList<int>& value);
33 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx
36 singleMode, menuMode, symbolMode, fullMode, listMode
39 normalOpt = 0, allOpt, promptOpt
42 class ConfigList : public QTreeWidget {
44 typedef class QTreeWidget Parent;
46 ConfigList(ConfigView* p, const char *name = 0);
48 ConfigItem* findConfigItem(struct menu *);
49 ConfigView* parent(void) const
51 return (ConfigView*)Parent::parent();
53 void setSelected(QTreeWidgetItem *item, bool enable) {
54 for (int i = 0; i < selectedItems().size(); i++)
55 selectedItems().at(i)->setSelected(false);
57 item->setSelected(enable);
61 void keyPressEvent(QKeyEvent *e);
62 void mousePressEvent(QMouseEvent *e);
63 void mouseReleaseEvent(QMouseEvent *e);
64 void mouseMoveEvent(QMouseEvent *e);
65 void mouseDoubleClickEvent(QMouseEvent *e);
66 void focusInEvent(QFocusEvent *e);
67 void contextMenuEvent(QContextMenuEvent *e);
70 void setRootMenu(struct menu *menu);
73 void setValue(ConfigItem* item, tristate val);
74 void changeValue(ConfigItem* item);
75 void updateSelection(void);
76 void saveSettings(void);
77 void setOptionMode(QAction *action);
80 void menuChanged(struct menu *menu);
81 void menuSelected(struct menu *menu);
82 void itemSelected(struct menu *menu);
83 void parentSelected(void);
84 void gotFocus(struct menu *);
87 void updateListAll(void)
93 void setAllOpen(bool open);
94 void setParentMenu(void);
96 bool menuSkip(struct menu *);
98 void updateMenuList(ConfigItem *parent, struct menu*);
99 void updateMenuList(struct menu *menu);
103 bool showName, showRange, showData;
105 enum optionMode optMode;
106 struct menu *rootEntry;
107 QPalette disabledColorGroup;
108 QPalette inactivedColorGroup;
111 static QAction *showNormalAction, *showAllAction, *showPromptAction;
114 class ConfigItem : public QTreeWidgetItem {
115 typedef class QTreeWidgetItem Parent;
117 ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
118 : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
122 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
123 : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
127 ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
128 : Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
134 void okRename(int col);
135 void updateMenu(void);
136 void testUpdateMenu(bool v);
137 ConfigList* listView() const
139 return (ConfigList*)Parent::treeWidget();
141 ConfigItem* firstChild() const
143 return (ConfigItem *)Parent::child(0);
145 ConfigItem* nextSibling()
147 ConfigItem *ret = NULL;
148 ConfigItem *_parent = (ConfigItem *)parent();
151 ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1);
153 QTreeWidget *_treeWidget = treeWidget();
154 ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1);
159 // TODO: Implement paintCell
161 ConfigItem* nextItem;
166 static QIcon symbolYesIcon, symbolModIcon, symbolNoIcon;
167 static QIcon choiceYesIcon, choiceNoIcon;
168 static QIcon menuIcon, menubackIcon;
171 class ConfigLineEdit : public QLineEdit {
173 typedef class QLineEdit Parent;
175 ConfigLineEdit(ConfigView* parent);
176 ConfigView* parent(void) const
178 return (ConfigView*)Parent::parent();
180 void show(ConfigItem *i);
181 void keyPressEvent(QKeyEvent *e);
187 class ConfigView : public QWidget {
189 typedef class QWidget Parent;
191 ConfigView(QWidget* parent, const char *name = 0);
193 static void updateList();
194 static void updateListAll(void);
196 bool showName(void) const { return list->showName; }
197 bool showRange(void) const { return list->showRange; }
198 bool showData(void) const { return list->showData; }
200 void setShowName(bool);
201 void setShowRange(bool);
202 void setShowData(bool);
204 void showNameChanged(bool);
205 void showRangeChanged(bool);
206 void showDataChanged(bool);
209 ConfigLineEdit* lineEdit;
211 static ConfigView* viewList;
212 ConfigView* nextView;
215 class ConfigInfoView : public QTextBrowser {
217 typedef class QTextBrowser Parent;
220 ConfigInfoView(QWidget* parent, const char *name = 0);
221 bool showDebug(void) const { return _showDebug; }
224 void setInfo(struct menu *menu);
225 void saveSettings(void);
226 void setShowDebug(bool);
227 void clicked (const QUrl &url);
230 void showDebugChanged(bool);
231 void menuSelected(struct menu *);
234 void symbolInfo(void);
236 QString debug_info(struct symbol *sym);
237 static QString print_filter(const QString &str);
238 static void expr_print_help(void *data, struct symbol *sym, const char *str);
239 void contextMenuEvent(QContextMenuEvent *event);
246 class ConfigSearchWindow : public QDialog {
248 typedef class QDialog Parent;
250 ConfigSearchWindow(ConfigMainWindow *parent);
253 void saveSettings(void);
257 QLineEdit* editField;
258 QPushButton* searchButton;
261 ConfigInfoView* info;
263 struct symbol **result;
266 class ConfigMainWindow : public QMainWindow {
270 static QAction *saveAction;
271 static void conf_changed(void);
273 ConfigMainWindow(void);
275 void changeMenu(struct menu *);
276 void changeItens(struct menu *);
277 void setMenuLink(struct menu *);
278 void listFocusChanged(void);
280 void loadConfig(void);
281 bool saveConfig(void);
282 void saveConfigAs(void);
283 void searchConfig(void);
284 void showSingleView(void);
285 void showSplitView(void);
286 void showFullView(void);
287 void showIntro(void);
288 void showAbout(void);
289 void saveSettings(void);
292 void closeEvent(QCloseEvent *e);
294 ConfigSearchWindow *searchWindow;
295 ConfigView *menuView;
296 ConfigList *menuList;
297 ConfigView *configView;
298 ConfigList *configList;
299 ConfigInfoView *helpText;
301 QAction *singleViewAction;
302 QAction *splitViewAction;
303 QAction *fullViewAction;