blob: 7c55b1d97a1a6f839658fe8cf1e67dc1956cb451 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -07006#include <QTextBrowser>
7#include <QTreeWidget>
Boris Barbulovskib1f8a452015-09-22 11:36:02 -07008#include <QMainWindow>
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -07009#include <QHeaderView>
Alexander Stein133c5f72010-08-31 17:34:37 +020010#include <qsettings.h>
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -070011#include <QPushButton>
12#include <QSettings>
13#include <QLineEdit>
14#include <QSplitter>
15#include <QCheckBox>
16#include <QDialog>
17#include "expr.h"
Alexander Stein133c5f72010-08-31 17:34:37 +020018
Roman Zippel7fc925f2006-06-08 22:12:46 -070019class ConfigView;
Boris Barbulovski1019f1a2015-09-22 11:36:17 -070020class ConfigList;
21class ConfigItem;
Linus Torvalds1da177e2005-04-16 15:20:36 -070022class ConfigLineEdit;
23class ConfigMainWindow;
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025class ConfigSettings : public QSettings {
26public:
Ben Hutchings00d4f8f2013-10-06 19:21:31 +010027 ConfigSettings();
Boris Barbulovski041fbdc2015-09-22 11:36:05 -070028 QList<int> readSizes(const QString& key, bool *ok);
29 bool writeSizes(const QString& key, const QList<int>& value);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030};
31
32enum colIdx {
33 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
34};
35enum listMode {
Roman Zippel43bf6122006-06-08 22:12:45 -070036 singleMode, menuMode, symbolMode, fullMode, listMode
Linus Torvalds1da177e2005-04-16 15:20:36 -070037};
Li Zefan39a48972010-05-10 16:33:41 +080038enum optionMode {
39 normalOpt = 0, allOpt, promptOpt
40};
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Boris Barbulovski1019f1a2015-09-22 11:36:17 -070042class ConfigList : public QTreeWidget {
43 Q_OBJECT
44 typedef class QTreeWidget Parent;
45public:
46 ConfigList(ConfigView* p, const char *name = 0);
Boris Barbulovski59e56442015-09-22 11:36:18 -070047 void reinit(void);
48 ConfigView* parent(void) const
49 {
50 return (ConfigView*)Parent::parent();
51 }
52 ConfigItem* findConfigItem(struct menu *);
53
54protected:
55 void keyPressEvent(QKeyEvent *e);
56 void contentsMousePressEvent(QMouseEvent *e);
57 void contentsMouseReleaseEvent(QMouseEvent *e);
58 void contentsMouseMoveEvent(QMouseEvent *e);
59 void contentsMouseDoubleClickEvent(QMouseEvent *e);
60 void focusInEvent(QFocusEvent *e);
61 void contextMenuEvent(QContextMenuEvent *e);
62
63public slots:
64 void setRootMenu(struct menu *menu);
65
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);
71signals:
72 void menuChanged(struct menu *menu);
73 void menuSelected(struct menu *menu);
74 void parentSelected(void);
75 void gotFocus(struct menu *);
76
77public:
78 void updateListAll(void)
79 {
80 updateAll = true;
81 updateList(NULL);
82 updateAll = false;
83 }
84 ConfigList* listView()
85 {
86 return this;
87 }
88 ConfigItem* firstChild() const
89 {
90 // TODO: Implement me.
91 return NULL;
92 }
93 void addColumn(colIdx idx, const QString& label)
94 {
95 // TODO: Implement me.
96 }
97 void removeColumn(colIdx idx)
98 {
99 // TODO: Implement me.
100 }
101 void setAllOpen(bool open);
102 void setParentMenu(void);
103
104 bool menuSkip(struct menu *);
105
106 template <class P>
107 void updateMenuList(P*, struct menu*);
108
109 bool updateAll;
110
111 QPixmap symbolYesPix, symbolModPix, symbolNoPix;
112 QPixmap choiceYesPix, choiceNoPix;
113 QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
114
115 bool showName, showRange, showData;
116 enum listMode mode;
117 enum optionMode optMode;
118 struct menu *rootEntry;
119 QPalette disabledColorGroup;
120 QPalette inactivedColorGroup;
121 QMenu* headerPopup;
Boris Barbulovski1019f1a2015-09-22 11:36:17 -0700122};
123
124class ConfigItem : public QTreeWidgetItem {
125 typedef class QTreeWidgetItem Parent;
126public:
127 ConfigItem(QTreeWidgetItem *parent, ConfigItem *after, struct menu *m, bool v)
128 : Parent(parent, after), menu(m), visible(v), goParent(false)
129 {
130 init();
131 }
132 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
133 : Parent(parent, after), menu(m), visible(v), goParent(false)
134 {
135 init();
136 }
137 ConfigItem(QTreeWidgetItem *parent, ConfigItem *after, bool v)
138 : Parent(parent, after), menu(0), visible(v), goParent(true)
139 {
140 init();
141 }
142 ~ConfigItem(void);
143 void init(void);
Boris Barbulovski59e56442015-09-22 11:36:18 -0700144 void okRename(int col);
145 void updateMenu(void);
146 void testUpdateMenu(bool v);
147 ConfigList* listView() const
148 {
149 return (ConfigList*)Parent::treeWidget();
150 }
151 ConfigItem* firstChild() const
152 {
153 return (ConfigItem *)Parent::child(0);
154 }
155 ConfigItem* nextSibling() const
156 {
157 return NULL; // TODO: Implement me
158 }
159 void setText(colIdx idx, const QString& text)
160 {
161 Parent::setText(idx, text);
162 }
163 QString text(colIdx idx) const
164 {
165 return Parent::text(idx);
166 }
167 void setPixmap(colIdx idx, const QPixmap& pm)
168 {
169 // TODO: Implement me
170 }
171 const QPixmap* pixmap(colIdx idx) const
172 {
173 return NULL; // TODO: Implement me
174 }
175 // Implement paintCell
Boris Barbulovski1019f1a2015-09-22 11:36:17 -0700176
177 ConfigItem* nextItem;
178 struct menu *menu;
179 bool visible;
180 bool goParent;
181};
182
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183class ConfigLineEdit : public QLineEdit {
184 Q_OBJECT
185 typedef class QLineEdit Parent;
186public:
Roman Zippel43bf6122006-06-08 22:12:45 -0700187 ConfigLineEdit(ConfigView* parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 ConfigView* parent(void) const
189 {
190 return (ConfigView*)Parent::parent();
191 }
Boris Barbulovski1019f1a2015-09-22 11:36:17 -0700192 void show(ConfigItem *i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 void keyPressEvent(QKeyEvent *e);
194
195public:
Boris Barbulovski1019f1a2015-09-22 11:36:17 -0700196 ConfigItem *item;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197};
198
Boris Barbulovski34d63202015-09-22 11:36:09 -0700199class ConfigView : public QWidget {
Roman Zippel7fc925f2006-06-08 22:12:46 -0700200 Q_OBJECT
Boris Barbulovski34d63202015-09-22 11:36:09 -0700201 typedef class QWidget Parent;
Roman Zippel7fc925f2006-06-08 22:12:46 -0700202public:
203 ConfigView(QWidget* parent, const char *name = 0);
204 ~ConfigView(void);
Boris Barbulovski1019f1a2015-09-22 11:36:17 -0700205 static void updateList(ConfigItem* item);
Roman Zippel7fc925f2006-06-08 22:12:46 -0700206 static void updateListAll(void);
207
Boris Barbulovski59e56442015-09-22 11:36:18 -0700208 bool showName(void) const { return list->showName; }
209 bool showRange(void) const { return list->showRange; }
210 bool showData(void) const { return list->showData; }
Roman Zippel7fc925f2006-06-08 22:12:46 -0700211public slots:
Roman Zippel7fc925f2006-06-08 22:12:46 -0700212 void setShowName(bool);
213 void setShowRange(bool);
214 void setShowData(bool);
Li Zefan39a48972010-05-10 16:33:41 +0800215 void setOptionMode(QAction *);
Roman Zippel7fc925f2006-06-08 22:12:46 -0700216signals:
Roman Zippel7fc925f2006-06-08 22:12:46 -0700217 void showNameChanged(bool);
218 void showRangeChanged(bool);
219 void showDataChanged(bool);
220public:
Boris Barbulovski1019f1a2015-09-22 11:36:17 -0700221 ConfigList* list;
Roman Zippel7fc925f2006-06-08 22:12:46 -0700222 ConfigLineEdit* lineEdit;
223
224 static ConfigView* viewList;
225 ConfigView* nextView;
Li Zefan39a48972010-05-10 16:33:41 +0800226
227 static QAction *showNormalAction;
228 static QAction *showAllAction;
229 static QAction *showPromptAction;
Roman Zippel7fc925f2006-06-08 22:12:46 -0700230};
231
Boris Barbulovski924bbb52015-09-22 11:36:06 -0700232class ConfigInfoView : public QTextBrowser {
Roman Zippel43bf6122006-06-08 22:12:45 -0700233 Q_OBJECT
Boris Barbulovski924bbb52015-09-22 11:36:06 -0700234 typedef class QTextBrowser Parent;
Roman Zippel43bf6122006-06-08 22:12:45 -0700235public:
236 ConfigInfoView(QWidget* parent, const char *name = 0);
237 bool showDebug(void) const { return _showDebug; }
238
239public slots:
240 void setInfo(struct menu *menu);
Roman Zippel7fc925f2006-06-08 22:12:46 -0700241 void saveSettings(void);
Roman Zippel43bf6122006-06-08 22:12:45 -0700242 void setShowDebug(bool);
243
244signals:
245 void showDebugChanged(bool);
Roman Zippelb65a47e2006-06-08 22:12:47 -0700246 void menuSelected(struct menu *);
Roman Zippel43bf6122006-06-08 22:12:45 -0700247
248protected:
Roman Zippelab45d192006-06-08 22:12:47 -0700249 void symbolInfo(void);
Roman Zippel43bf6122006-06-08 22:12:45 -0700250 void menuInfo(void);
251 QString debug_info(struct symbol *sym);
252 static QString print_filter(const QString &str);
Roman Zippelab45d192006-06-08 22:12:47 -0700253 static void expr_print_help(void *data, struct symbol *sym, const char *str);
Boris Barbulovski924bbb52015-09-22 11:36:06 -0700254 QMenu *createStandardContextMenu(const QPoint & pos);
255 void contextMenuEvent(QContextMenuEvent *e);
Roman Zippel43bf6122006-06-08 22:12:45 -0700256
Roman Zippelab45d192006-06-08 22:12:47 -0700257 struct symbol *sym;
Alexander Stein133c5f72010-08-31 17:34:37 +0200258 struct menu *_menu;
Roman Zippel43bf6122006-06-08 22:12:45 -0700259 bool _showDebug;
260};
261
262class ConfigSearchWindow : public QDialog {
263 Q_OBJECT
264 typedef class QDialog Parent;
265public:
Marco Costalba63431e72006-10-05 19:12:59 +0200266 ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0);
Roman Zippel7fc925f2006-06-08 22:12:46 -0700267
Roman Zippel43bf6122006-06-08 22:12:45 -0700268public slots:
Roman Zippel7fc925f2006-06-08 22:12:46 -0700269 void saveSettings(void);
Roman Zippel43bf6122006-06-08 22:12:45 -0700270 void search(void);
Roman Zippel7fc925f2006-06-08 22:12:46 -0700271
Roman Zippel43bf6122006-06-08 22:12:45 -0700272protected:
273 QLineEdit* editField;
274 QPushButton* searchButton;
Roman Zippel7fc925f2006-06-08 22:12:46 -0700275 QSplitter* split;
Roman Zippel43bf6122006-06-08 22:12:45 -0700276 ConfigView* list;
277 ConfigInfoView* info;
278
279 struct symbol **result;
280};
281
Boris Barbulovskib1f8a452015-09-22 11:36:02 -0700282class ConfigMainWindow : public QMainWindow {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 Q_OBJECT
Karsten Wiese3b354c52006-12-13 00:34:08 -0800284
Boris Barbulovski85eaf282015-09-22 11:36:03 -0700285 static QAction *saveAction;
Karsten Wiese3b354c52006-12-13 00:34:08 -0800286 static void conf_changed(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287public:
288 ConfigMainWindow(void);
289public slots:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 void changeMenu(struct menu *);
Roman Zippelb65a47e2006-06-08 22:12:47 -0700291 void setMenuLink(struct menu *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 void listFocusChanged(void);
293 void goBack(void);
294 void loadConfig(void);
Michal Marekbac6aa82011-05-25 15:10:25 +0200295 bool saveConfig(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 void saveConfigAs(void);
Roman Zippel43bf6122006-06-08 22:12:45 -0700297 void searchConfig(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 void showSingleView(void);
299 void showSplitView(void);
300 void showFullView(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 void showIntro(void);
302 void showAbout(void);
303 void saveSettings(void);
304
305protected:
306 void closeEvent(QCloseEvent *e);
307
Roman Zippel43bf6122006-06-08 22:12:45 -0700308 ConfigSearchWindow *searchWindow;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 ConfigView *menuView;
Boris Barbulovski1019f1a2015-09-22 11:36:17 -0700310 ConfigList *menuList;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 ConfigView *configView;
Boris Barbulovski1019f1a2015-09-22 11:36:17 -0700312 ConfigList *configList;
Roman Zippel43bf6122006-06-08 22:12:45 -0700313 ConfigInfoView *helpText;
Boris Barbulovskib1f8a452015-09-22 11:36:02 -0700314 QToolBar *toolBar;
Boris Barbulovski85eaf282015-09-22 11:36:03 -0700315 QAction *backAction;
Boris Barbulovski780505e2015-09-22 11:36:13 -0700316 QAction *singleViewAction;
317 QAction *splitViewAction;
318 QAction *fullViewAction;
Boris Barbulovski76538662015-09-22 11:36:14 -0700319 QSplitter *split1;
320 QSplitter *split2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321};