1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
6 #include <QTextBrowser>
10 #include <qsettings.h>
11 #include <QPushButton>
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 ConfigView
* parent(void) const
50 return (ConfigView
*)Parent::parent();
52 ConfigItem
* findConfigItem(struct menu
*);
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
);
64 void setRootMenu(struct menu
*menu
);
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);
72 void menuChanged(struct menu
*menu
);
73 void menuSelected(struct menu
*menu
);
74 void parentSelected(void);
75 void gotFocus(struct menu
*);
78 void updateListAll(void)
84 ConfigList
* listView()
88 ConfigItem
* firstChild() const
90 return (ConfigItem
*)children().first();
92 void addColumn(colIdx idx
)
96 void removeColumn(colIdx idx
)
100 void setAllOpen(bool open
);
101 void setParentMenu(void);
103 bool menuSkip(struct menu
*);
105 void updateMenuList(ConfigItem
*parent
, struct menu
*);
106 void updateMenuList(ConfigList
*parent
, struct menu
*);
110 QPixmap symbolYesPix
, symbolModPix
, symbolNoPix
;
111 QPixmap choiceYesPix
, choiceNoPix
;
112 QPixmap menuPix
, menuInvPix
, menuBackPix
, voidPix
;
114 bool showName
, showRange
, showData
;
116 enum optionMode optMode
;
117 struct menu
*rootEntry
;
118 QPalette disabledColorGroup
;
119 QPalette inactivedColorGroup
;
123 class ConfigItem
: public QTreeWidgetItem
{
124 typedef class QTreeWidgetItem Parent
;
126 ConfigItem(ConfigList
*parent
, ConfigItem
*after
, struct menu
*m
, bool v
)
127 : Parent(parent
, after
), nextItem(0), menu(m
), visible(v
), goParent(false)
131 ConfigItem(ConfigItem
*parent
, ConfigItem
*after
, struct menu
*m
, bool v
)
132 : Parent(parent
, after
), nextItem(0), menu(m
), visible(v
), goParent(false)
136 ConfigItem(ConfigList
*parent
, ConfigItem
*after
, bool v
)
137 : Parent(parent
, after
), nextItem(0), menu(0), visible(v
), goParent(true)
143 void okRename(int col
);
144 void updateMenu(void);
145 void testUpdateMenu(bool v
);
146 ConfigList
* listView() const
148 return (ConfigList
*)Parent::treeWidget();
150 ConfigItem
* firstChild() const
152 return (ConfigItem
*)Parent::child(0);
154 ConfigItem
* nextSibling()
156 ConfigItem
*ret
= NULL
;
157 ConfigItem
*_parent
= (ConfigItem
*)parent();
160 ret
= (ConfigItem
*)_parent
->child(_parent
->indexOfChild(this)+1);
162 QTreeWidget
*_treeWidget
= treeWidget();
163 ret
= (ConfigItem
*)_treeWidget
->topLevelItem(_treeWidget
->indexOfTopLevelItem(this)+1);
168 void setText(colIdx idx
, const QString
& text
)
170 Parent::setText(idx
, text
);
172 QString
text(colIdx idx
) const
174 return Parent::text(idx
);
176 void setPixmap(colIdx idx
, const QIcon
&icon
)
178 Parent::setIcon(idx
, icon
);
180 const QIcon
pixmap(colIdx idx
) const
184 // TODO: Implement paintCell
186 ConfigItem
* nextItem
;
192 class ConfigLineEdit
: public QLineEdit
{
194 typedef class QLineEdit Parent
;
196 ConfigLineEdit(ConfigView
* parent
);
197 ConfigView
* parent(void) const
199 return (ConfigView
*)Parent::parent();
201 void show(ConfigItem
*i
);
202 void keyPressEvent(QKeyEvent
*e
);
208 class ConfigView
: public QWidget
{
210 typedef class QWidget Parent
;
212 ConfigView(QWidget
* parent
, const char *name
= 0);
214 static void updateList(ConfigItem
* item
);
215 static void updateListAll(void);
217 bool showName(void) const { return list
->showName
; }
218 bool showRange(void) const { return list
->showRange
; }
219 bool showData(void) const { return list
->showData
; }
221 void setShowName(bool);
222 void setShowRange(bool);
223 void setShowData(bool);
224 void setOptionMode(QAction
*);
226 void showNameChanged(bool);
227 void showRangeChanged(bool);
228 void showDataChanged(bool);
231 ConfigLineEdit
* lineEdit
;
233 static ConfigView
* viewList
;
234 ConfigView
* nextView
;
236 static QAction
*showNormalAction
;
237 static QAction
*showAllAction
;
238 static QAction
*showPromptAction
;
241 class ConfigInfoView
: public QTextBrowser
{
243 typedef class QTextBrowser Parent
;
245 ConfigInfoView(QWidget
* parent
, const char *name
= 0);
246 bool showDebug(void) const { return _showDebug
; }
249 void setInfo(struct menu
*menu
);
250 void saveSettings(void);
251 void setShowDebug(bool);
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
, const char *name
= 0);
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 setMenuLink(struct menu
*);
302 void listFocusChanged(void);
304 void loadConfig(void);
305 bool saveConfig(void);
306 void saveConfigAs(void);
307 void searchConfig(void);
308 void showSingleView(void);
309 void showSplitView(void);
310 void showFullView(void);
311 void showIntro(void);
312 void showAbout(void);
313 void saveSettings(void);
316 void closeEvent(QCloseEvent
*e
);
318 ConfigSearchWindow
*searchWindow
;
319 ConfigView
*menuView
;
320 ConfigList
*menuList
;
321 ConfigView
*configView
;
322 ConfigList
*configList
;
323 ConfigInfoView
*helpText
;
326 QAction
*singleViewAction
;
327 QAction
*splitViewAction
;
328 QAction
*fullViewAction
;