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, colNr
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);
72 void updateList(ConfigItem *item);
73 void setValue(ConfigItem* item, tristate val);
74 void changeValue(ConfigItem* item);
75 void updateSelection(void);
76 void saveSettings(void);
78 void menuChanged(struct menu *menu);
79 void menuSelected(struct menu *menu);
80 void itemSelected(struct menu *menu);
81 void parentSelected(void);
82 void gotFocus(struct menu *);
85 void updateListAll(void)
91 ConfigList* listView()
95 void addColumn(colIdx idx)
99 void removeColumn(colIdx idx)
103 void setAllOpen(bool open);
104 void setParentMenu(void);
106 bool menuSkip(struct menu *);
108 void updateMenuList(ConfigItem *parent, struct menu*);
109 void updateMenuList(ConfigList *parent, struct menu*);
113 QPixmap symbolYesPix, symbolModPix, symbolNoPix;
114 QPixmap choiceYesPix, choiceNoPix;
115 QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
117 bool showName, showRange, showData;
119 enum optionMode optMode;
120 struct menu *rootEntry;
121 QPalette disabledColorGroup;
122 QPalette inactivedColorGroup;
126 class ConfigItem : public QTreeWidgetItem {
127 typedef class QTreeWidgetItem Parent;
129 ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
130 : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
134 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
135 : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
139 ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
140 : Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
146 void okRename(int col);
147 void updateMenu(void);
148 void testUpdateMenu(bool v);
149 ConfigList* listView() const
151 return (ConfigList*)Parent::treeWidget();
153 ConfigItem* firstChild() const
155 return (ConfigItem *)Parent::child(0);
157 ConfigItem* nextSibling()
159 ConfigItem *ret = NULL;
160 ConfigItem *_parent = (ConfigItem *)parent();
163 ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1);
165 QTreeWidget *_treeWidget = treeWidget();
166 ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1);
171 void setText(colIdx idx, const QString& text)
173 Parent::setText(idx, text);
175 QString text(colIdx idx) const
177 return Parent::text(idx);
179 void setPixmap(colIdx idx, const QIcon &icon)
181 Parent::setIcon(idx, icon);
183 const QIcon pixmap(colIdx idx) const
187 // TODO: Implement paintCell
189 ConfigItem* nextItem;
195 class ConfigLineEdit : public QLineEdit {
197 typedef class QLineEdit Parent;
199 ConfigLineEdit(ConfigView* parent);
200 ConfigView* parent(void) const
202 return (ConfigView*)Parent::parent();
204 void show(ConfigItem *i);
205 void keyPressEvent(QKeyEvent *e);
211 class ConfigView : public QWidget {
213 typedef class QWidget Parent;
215 ConfigView(QWidget* parent, const char *name = 0);
217 static void updateList(ConfigItem* item);
218 static void updateListAll(void);
220 bool showName(void) const { return list->showName; }
221 bool showRange(void) const { return list->showRange; }
222 bool showData(void) const { return list->showData; }
224 void setShowName(bool);
225 void setShowRange(bool);
226 void setShowData(bool);
227 void setOptionMode(QAction *);
229 void showNameChanged(bool);
230 void showRangeChanged(bool);
231 void showDataChanged(bool);
234 ConfigLineEdit* lineEdit;
236 static ConfigView* viewList;
237 ConfigView* nextView;
239 static QAction *showNormalAction;
240 static QAction *showAllAction;
241 static QAction *showPromptAction;
244 class ConfigInfoView : public QTextBrowser {
246 typedef class QTextBrowser Parent;
248 ConfigInfoView(QWidget* parent, const char *name = 0);
249 bool showDebug(void) const { return _showDebug; }
252 void setInfo(struct menu *menu);
253 void saveSettings(void);
254 void setShowDebug(bool);
255 void clicked (const QUrl &url);
258 void showDebugChanged(bool);
259 void menuSelected(struct menu *);
262 void symbolInfo(void);
264 QString debug_info(struct symbol *sym);
265 static QString print_filter(const QString &str);
266 static void expr_print_help(void *data, struct symbol *sym, const char *str);
267 QMenu *createStandardContextMenu(const QPoint & pos);
268 void contextMenuEvent(QContextMenuEvent *e);
275 class ConfigSearchWindow : public QDialog {
277 typedef class QDialog Parent;
279 ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0);
282 void saveSettings(void);
286 QLineEdit* editField;
287 QPushButton* searchButton;
290 ConfigInfoView* info;
292 struct symbol **result;
295 class ConfigMainWindow : public QMainWindow {
299 static QAction *saveAction;
300 static void conf_changed(void);
302 ConfigMainWindow(void);
304 void changeMenu(struct menu *);
305 void changeItens(struct menu *);
306 void setMenuLink(struct menu *);
307 void listFocusChanged(void);
309 void loadConfig(void);
310 bool saveConfig(void);
311 void saveConfigAs(void);
312 void searchConfig(void);
313 void showSingleView(void);
314 void showSplitView(void);
315 void showFullView(void);
316 void showIntro(void);
317 void showAbout(void);
318 void saveSettings(void);
321 void closeEvent(QCloseEvent *e);
323 ConfigSearchWindow *searchWindow;
324 ConfigView *menuView;
325 ConfigList *menuList;
326 ConfigView *configView;
327 ConfigList *configList;
328 ConfigInfoView *helpText;
330 QAction *singleViewAction;
331 QAction *splitViewAction;
332 QAction *fullViewAction;