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 itemSelected(struct menu
*menu
);
75 void parentSelected(void);
76 void gotFocus(struct menu
*);
79 void updateListAll(void)
85 ConfigList
* listView()
89 ConfigItem
* firstChild() const
91 return (ConfigItem
*)children().first();
93 void addColumn(colIdx idx
)
97 void removeColumn(colIdx idx
)
101 void setAllOpen(bool open
);
102 void setParentMenu(void);
104 bool menuSkip(struct menu
*);
106 void updateMenuList(ConfigItem
*parent
, struct menu
*);
107 void updateMenuList(ConfigList
*parent
, struct menu
*);
111 QPixmap symbolYesPix
, symbolModPix
, symbolNoPix
;
112 QPixmap choiceYesPix
, choiceNoPix
;
113 QPixmap menuPix
, menuInvPix
, menuBackPix
, voidPix
;
115 bool showName
, showRange
, showData
;
117 enum optionMode optMode
;
118 struct menu
*rootEntry
;
119 QPalette disabledColorGroup
;
120 QPalette inactivedColorGroup
;
124 class ConfigItem
: public QTreeWidgetItem
{
125 typedef class QTreeWidgetItem Parent
;
127 ConfigItem(ConfigList
*parent
, ConfigItem
*after
, struct menu
*m
, bool v
)
128 : Parent(parent
, after
), nextItem(0), menu(m
), visible(v
), goParent(false)
132 ConfigItem(ConfigItem
*parent
, ConfigItem
*after
, struct menu
*m
, bool v
)
133 : Parent(parent
, after
), nextItem(0), menu(m
), visible(v
), goParent(false)
137 ConfigItem(ConfigList
*parent
, ConfigItem
*after
, bool v
)
138 : Parent(parent
, after
), nextItem(0), menu(0), visible(v
), goParent(true)
144 void okRename(int col
);
145 void updateMenu(void);
146 void testUpdateMenu(bool v
);
147 ConfigList
* listView() const
149 return (ConfigList
*)Parent::treeWidget();
151 ConfigItem
* firstChild() const
153 return (ConfigItem
*)Parent::child(0);
155 ConfigItem
* nextSibling()
157 ConfigItem
*ret
= NULL
;
158 ConfigItem
*_parent
= (ConfigItem
*)parent();
161 ret
= (ConfigItem
*)_parent
->child(_parent
->indexOfChild(this)+1);
163 QTreeWidget
*_treeWidget
= treeWidget();
164 ret
= (ConfigItem
*)_treeWidget
->topLevelItem(_treeWidget
->indexOfTopLevelItem(this)+1);
169 void setText(colIdx idx
, const QString
& text
)
171 Parent::setText(idx
, text
);
173 QString
text(colIdx idx
) const
175 return Parent::text(idx
);
177 void setPixmap(colIdx idx
, const QIcon
&icon
)
179 Parent::setIcon(idx
, icon
);
181 const QIcon
pixmap(colIdx idx
) const
185 // TODO: Implement paintCell
187 ConfigItem
* nextItem
;
193 class ConfigLineEdit
: public QLineEdit
{
195 typedef class QLineEdit Parent
;
197 ConfigLineEdit(ConfigView
* parent
);
198 ConfigView
* parent(void) const
200 return (ConfigView
*)Parent::parent();
202 void show(ConfigItem
*i
);
203 void keyPressEvent(QKeyEvent
*e
);
209 class ConfigView
: public QWidget
{
211 typedef class QWidget Parent
;
213 ConfigView(QWidget
* parent
, const char *name
= 0);
215 static void updateList(ConfigItem
* item
);
216 static void updateListAll(void);
218 bool showName(void) const { return list
->showName
; }
219 bool showRange(void) const { return list
->showRange
; }
220 bool showData(void) const { return list
->showData
; }
222 void setShowName(bool);
223 void setShowRange(bool);
224 void setShowData(bool);
225 void setOptionMode(QAction
*);
227 void showNameChanged(bool);
228 void showRangeChanged(bool);
229 void showDataChanged(bool);
232 ConfigLineEdit
* lineEdit
;
234 static ConfigView
* viewList
;
235 ConfigView
* nextView
;
237 static QAction
*showNormalAction
;
238 static QAction
*showAllAction
;
239 static QAction
*showPromptAction
;
242 class ConfigInfoView
: public QTextBrowser
{
244 typedef class QTextBrowser Parent
;
246 ConfigInfoView(QWidget
* parent
, const char *name
= 0);
247 bool showDebug(void) const { return _showDebug
; }
250 void setInfo(struct menu
*menu
);
251 void saveSettings(void);
252 void setShowDebug(bool);
255 void showDebugChanged(bool);
256 void menuSelected(struct menu
*);
259 void symbolInfo(void);
261 QString
debug_info(struct symbol
*sym
);
262 static QString
print_filter(const QString
&str
);
263 static void expr_print_help(void *data
, struct symbol
*sym
, const char *str
);
264 QMenu
*createStandardContextMenu(const QPoint
& pos
);
265 void contextMenuEvent(QContextMenuEvent
*e
);
272 class ConfigSearchWindow
: public QDialog
{
274 typedef class QDialog Parent
;
276 ConfigSearchWindow(ConfigMainWindow
* parent
, const char *name
= 0);
279 void saveSettings(void);
283 QLineEdit
* editField
;
284 QPushButton
* searchButton
;
287 ConfigInfoView
* info
;
289 struct symbol
**result
;
292 class ConfigMainWindow
: public QMainWindow
{
296 static QAction
*saveAction
;
297 static void conf_changed(void);
299 ConfigMainWindow(void);
301 void changeMenu(struct menu
*);
302 void changeItens(struct menu
*);
303 void setMenuLink(struct menu
*);
304 void listFocusChanged(void);
306 void loadConfig(void);
307 bool saveConfig(void);
308 void saveConfigAs(void);
309 void searchConfig(void);
310 void showSingleView(void);
311 void showSplitView(void);
312 void showFullView(void);
313 void showIntro(void);
314 void showAbout(void);
315 void saveSettings(void);
318 void closeEvent(QCloseEvent
*e
);
320 ConfigSearchWindow
*searchWindow
;
321 ConfigView
*menuView
;
322 ConfigList
*menuList
;
323 ConfigView
*configView
;
324 ConfigList
*configList
;
325 ConfigInfoView
*helpText
;
328 QAction
*singleViewAction
;
329 QAction
*splitViewAction
;
330 QAction
*fullViewAction
;