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);
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 void addColumn(colIdx idx)
95 void removeColumn(colIdx idx)
99 void setAllOpen(bool open);
100 void setParentMenu(void);
102 bool menuSkip(struct menu *);
104 void updateMenuList(ConfigItem *parent, struct menu*);
105 void updateMenuList(ConfigList *parent, struct menu*);
109 QPixmap symbolYesPix, symbolModPix, symbolNoPix;
110 QPixmap choiceYesPix, choiceNoPix;
111 QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
113 bool showName, showRange, showData;
115 enum optionMode optMode;
116 struct menu *rootEntry;
117 QPalette disabledColorGroup;
118 QPalette inactivedColorGroup;
122 class ConfigItem : public QTreeWidgetItem {
123 typedef class QTreeWidgetItem Parent;
125 ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
126 : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
130 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
131 : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
135 ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
136 : Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
142 void okRename(int col);
143 void updateMenu(void);
144 void testUpdateMenu(bool v);
145 ConfigList* listView() const
147 return (ConfigList*)Parent::treeWidget();
149 ConfigItem* firstChild() const
151 return (ConfigItem *)Parent::child(0);
153 ConfigItem* nextSibling()
155 ConfigItem *ret = NULL;
156 ConfigItem *_parent = (ConfigItem *)parent();
159 ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1);
161 QTreeWidget *_treeWidget = treeWidget();
162 ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1);
167 void setText(colIdx idx, const QString& text)
169 Parent::setText(idx, text);
171 QString text(colIdx idx) const
173 return Parent::text(idx);
175 void setPixmap(colIdx idx, const QIcon &icon)
177 Parent::setIcon(idx, icon);
179 const QIcon pixmap(colIdx idx) const
183 // TODO: Implement paintCell
185 ConfigItem* nextItem;
191 class ConfigLineEdit : public QLineEdit {
193 typedef class QLineEdit Parent;
195 ConfigLineEdit(ConfigView* parent);
196 ConfigView* parent(void) const
198 return (ConfigView*)Parent::parent();
200 void show(ConfigItem *i);
201 void keyPressEvent(QKeyEvent *e);
207 class ConfigView : public QWidget {
209 typedef class QWidget Parent;
211 ConfigView(QWidget* parent, const char *name = 0);
213 static void updateList();
214 static void updateListAll(void);
216 bool showName(void) const { return list->showName; }
217 bool showRange(void) const { return list->showRange; }
218 bool showData(void) const { return list->showData; }
220 void setShowName(bool);
221 void setShowRange(bool);
222 void setShowData(bool);
223 void setOptionMode(QAction *);
225 void showNameChanged(bool);
226 void showRangeChanged(bool);
227 void showDataChanged(bool);
230 ConfigLineEdit* lineEdit;
232 static ConfigView* viewList;
233 ConfigView* nextView;
235 static QAction *showNormalAction;
236 static QAction *showAllAction;
237 static QAction *showPromptAction;
240 class ConfigInfoView : public QTextBrowser {
242 typedef class QTextBrowser Parent;
244 ConfigInfoView(QWidget* parent, const char *name = 0);
245 bool showDebug(void) const { return _showDebug; }
248 void setInfo(struct menu *menu);
249 void saveSettings(void);
250 void setShowDebug(bool);
251 void clicked (const QUrl &url);
254 void showDebugChanged(bool);
255 void menuSelected(struct menu *);
258 void symbolInfo(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);
271 class ConfigSearchWindow : public QDialog {
273 typedef class QDialog Parent;
275 ConfigSearchWindow(ConfigMainWindow *parent);
278 void saveSettings(void);
282 QLineEdit* editField;
283 QPushButton* searchButton;
286 ConfigInfoView* info;
288 struct symbol **result;
291 class ConfigMainWindow : public QMainWindow {
295 static QAction *saveAction;
296 static void conf_changed(void);
298 ConfigMainWindow(void);
300 void changeMenu(struct menu *);
301 void changeItens(struct menu *);
302 void setMenuLink(struct menu *);
303 void listFocusChanged(void);
305 void loadConfig(void);
306 bool saveConfig(void);
307 void saveConfigAs(void);
308 void searchConfig(void);
309 void showSingleView(void);
310 void showSplitView(void);
311 void showFullView(void);
312 void showIntro(void);
313 void showAbout(void);
314 void saveSettings(void);
317 void closeEvent(QCloseEvent *e);
319 ConfigSearchWindow *searchWindow;
320 ConfigView *menuView;
321 ConfigList *menuList;
322 ConfigView *configView;
323 ConfigList *configList;
324 ConfigInfoView *helpText;
326 QAction *singleViewAction;
327 QAction *splitViewAction;
328 QAction *fullViewAction;