Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
| 3 | * Released under the terms of the GNU GPL v2.0. |
| 4 | */ |
| 5 | |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame] | 6 | #include <QTextBrowser> |
| 7 | #include <QTreeWidget> |
Boris Barbulovski | b1f8a45 | 2015-09-22 11:36:02 -0700 | [diff] [blame] | 8 | #include <QMainWindow> |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame] | 9 | #include <QHeaderView> |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 10 | #include <qsettings.h> |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame] | 11 | #include <QPushButton> |
| 12 | #include <QSettings> |
| 13 | #include <QLineEdit> |
| 14 | #include <QSplitter> |
| 15 | #include <QCheckBox> |
| 16 | #include <QDialog> |
| 17 | #include "expr.h" |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 18 | |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 19 | class ConfigView; |
Boris Barbulovski | 1019f1a | 2015-09-22 11:36:17 -0700 | [diff] [blame] | 20 | class ConfigList; |
| 21 | class ConfigItem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | class ConfigLineEdit; |
| 23 | class ConfigMainWindow; |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | class ConfigSettings : public QSettings { |
| 26 | public: |
Ben Hutchings | 00d4f8f | 2013-10-06 19:21:31 +0100 | [diff] [blame] | 27 | ConfigSettings(); |
Boris Barbulovski | 041fbdc | 2015-09-22 11:36:05 -0700 | [diff] [blame] | 28 | QList<int> readSizes(const QString& key, bool *ok); |
| 29 | bool writeSizes(const QString& key, const QList<int>& value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | enum colIdx { |
| 33 | promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr |
| 34 | }; |
| 35 | enum listMode { |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 36 | singleMode, menuMode, symbolMode, fullMode, listMode |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | }; |
Li Zefan | 39a4897 | 2010-05-10 16:33:41 +0800 | [diff] [blame] | 38 | enum optionMode { |
| 39 | normalOpt = 0, allOpt, promptOpt |
| 40 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Boris Barbulovski | 1019f1a | 2015-09-22 11:36:17 -0700 | [diff] [blame] | 42 | class ConfigList : public QTreeWidget { |
| 43 | Q_OBJECT |
| 44 | typedef class QTreeWidget Parent; |
| 45 | public: |
| 46 | ConfigList(ConfigView* p, const char *name = 0); |
Boris Barbulovski | 59e5644 | 2015-09-22 11:36:18 -0700 | [diff] [blame^] | 47 | void reinit(void); |
| 48 | ConfigView* parent(void) const |
| 49 | { |
| 50 | return (ConfigView*)Parent::parent(); |
| 51 | } |
| 52 | ConfigItem* findConfigItem(struct menu *); |
| 53 | |
| 54 | protected: |
| 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 | |
| 63 | public 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); |
| 71 | signals: |
| 72 | void menuChanged(struct menu *menu); |
| 73 | void menuSelected(struct menu *menu); |
| 74 | void parentSelected(void); |
| 75 | void gotFocus(struct menu *); |
| 76 | |
| 77 | public: |
| 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 Barbulovski | 1019f1a | 2015-09-22 11:36:17 -0700 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | class ConfigItem : public QTreeWidgetItem { |
| 125 | typedef class QTreeWidgetItem Parent; |
| 126 | public: |
| 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 Barbulovski | 59e5644 | 2015-09-22 11:36:18 -0700 | [diff] [blame^] | 144 | 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 Barbulovski | 1019f1a | 2015-09-22 11:36:17 -0700 | [diff] [blame] | 176 | |
| 177 | ConfigItem* nextItem; |
| 178 | struct menu *menu; |
| 179 | bool visible; |
| 180 | bool goParent; |
| 181 | }; |
| 182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | class ConfigLineEdit : public QLineEdit { |
| 184 | Q_OBJECT |
| 185 | typedef class QLineEdit Parent; |
| 186 | public: |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 187 | ConfigLineEdit(ConfigView* parent); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | ConfigView* parent(void) const |
| 189 | { |
| 190 | return (ConfigView*)Parent::parent(); |
| 191 | } |
Boris Barbulovski | 1019f1a | 2015-09-22 11:36:17 -0700 | [diff] [blame] | 192 | void show(ConfigItem *i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | void keyPressEvent(QKeyEvent *e); |
| 194 | |
| 195 | public: |
Boris Barbulovski | 1019f1a | 2015-09-22 11:36:17 -0700 | [diff] [blame] | 196 | ConfigItem *item; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | }; |
| 198 | |
Boris Barbulovski | 34d6320 | 2015-09-22 11:36:09 -0700 | [diff] [blame] | 199 | class ConfigView : public QWidget { |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 200 | Q_OBJECT |
Boris Barbulovski | 34d6320 | 2015-09-22 11:36:09 -0700 | [diff] [blame] | 201 | typedef class QWidget Parent; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 202 | public: |
| 203 | ConfigView(QWidget* parent, const char *name = 0); |
| 204 | ~ConfigView(void); |
Boris Barbulovski | 1019f1a | 2015-09-22 11:36:17 -0700 | [diff] [blame] | 205 | static void updateList(ConfigItem* item); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 206 | static void updateListAll(void); |
| 207 | |
Boris Barbulovski | 59e5644 | 2015-09-22 11:36:18 -0700 | [diff] [blame^] | 208 | bool showName(void) const { return list->showName; } |
| 209 | bool showRange(void) const { return list->showRange; } |
| 210 | bool showData(void) const { return list->showData; } |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 211 | public slots: |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 212 | void setShowName(bool); |
| 213 | void setShowRange(bool); |
| 214 | void setShowData(bool); |
Li Zefan | 39a4897 | 2010-05-10 16:33:41 +0800 | [diff] [blame] | 215 | void setOptionMode(QAction *); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 216 | signals: |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 217 | void showNameChanged(bool); |
| 218 | void showRangeChanged(bool); |
| 219 | void showDataChanged(bool); |
| 220 | public: |
Boris Barbulovski | 1019f1a | 2015-09-22 11:36:17 -0700 | [diff] [blame] | 221 | ConfigList* list; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 222 | ConfigLineEdit* lineEdit; |
| 223 | |
| 224 | static ConfigView* viewList; |
| 225 | ConfigView* nextView; |
Li Zefan | 39a4897 | 2010-05-10 16:33:41 +0800 | [diff] [blame] | 226 | |
| 227 | static QAction *showNormalAction; |
| 228 | static QAction *showAllAction; |
| 229 | static QAction *showPromptAction; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 230 | }; |
| 231 | |
Boris Barbulovski | 924bbb5 | 2015-09-22 11:36:06 -0700 | [diff] [blame] | 232 | class ConfigInfoView : public QTextBrowser { |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 233 | Q_OBJECT |
Boris Barbulovski | 924bbb5 | 2015-09-22 11:36:06 -0700 | [diff] [blame] | 234 | typedef class QTextBrowser Parent; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 235 | public: |
| 236 | ConfigInfoView(QWidget* parent, const char *name = 0); |
| 237 | bool showDebug(void) const { return _showDebug; } |
| 238 | |
| 239 | public slots: |
| 240 | void setInfo(struct menu *menu); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 241 | void saveSettings(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 242 | void setShowDebug(bool); |
| 243 | |
| 244 | signals: |
| 245 | void showDebugChanged(bool); |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 246 | void menuSelected(struct menu *); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 247 | |
| 248 | protected: |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 249 | void symbolInfo(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 250 | void menuInfo(void); |
| 251 | QString debug_info(struct symbol *sym); |
| 252 | static QString print_filter(const QString &str); |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 253 | static void expr_print_help(void *data, struct symbol *sym, const char *str); |
Boris Barbulovski | 924bbb5 | 2015-09-22 11:36:06 -0700 | [diff] [blame] | 254 | QMenu *createStandardContextMenu(const QPoint & pos); |
| 255 | void contextMenuEvent(QContextMenuEvent *e); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 256 | |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 257 | struct symbol *sym; |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 258 | struct menu *_menu; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 259 | bool _showDebug; |
| 260 | }; |
| 261 | |
| 262 | class ConfigSearchWindow : public QDialog { |
| 263 | Q_OBJECT |
| 264 | typedef class QDialog Parent; |
| 265 | public: |
Marco Costalba | 63431e7 | 2006-10-05 19:12:59 +0200 | [diff] [blame] | 266 | ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 267 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 268 | public slots: |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 269 | void saveSettings(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 270 | void search(void); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 271 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 272 | protected: |
| 273 | QLineEdit* editField; |
| 274 | QPushButton* searchButton; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 275 | QSplitter* split; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 276 | ConfigView* list; |
| 277 | ConfigInfoView* info; |
| 278 | |
| 279 | struct symbol **result; |
| 280 | }; |
| 281 | |
Boris Barbulovski | b1f8a45 | 2015-09-22 11:36:02 -0700 | [diff] [blame] | 282 | class ConfigMainWindow : public QMainWindow { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | Q_OBJECT |
Karsten Wiese | 3b354c5 | 2006-12-13 00:34:08 -0800 | [diff] [blame] | 284 | |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 285 | static QAction *saveAction; |
Karsten Wiese | 3b354c5 | 2006-12-13 00:34:08 -0800 | [diff] [blame] | 286 | static void conf_changed(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | public: |
| 288 | ConfigMainWindow(void); |
| 289 | public slots: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | void changeMenu(struct menu *); |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 291 | void setMenuLink(struct menu *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | void listFocusChanged(void); |
| 293 | void goBack(void); |
| 294 | void loadConfig(void); |
Michal Marek | bac6aa8 | 2011-05-25 15:10:25 +0200 | [diff] [blame] | 295 | bool saveConfig(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | void saveConfigAs(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 297 | void searchConfig(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | void showSingleView(void); |
| 299 | void showSplitView(void); |
| 300 | void showFullView(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | void showIntro(void); |
| 302 | void showAbout(void); |
| 303 | void saveSettings(void); |
| 304 | |
| 305 | protected: |
| 306 | void closeEvent(QCloseEvent *e); |
| 307 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 308 | ConfigSearchWindow *searchWindow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | ConfigView *menuView; |
Boris Barbulovski | 1019f1a | 2015-09-22 11:36:17 -0700 | [diff] [blame] | 310 | ConfigList *menuList; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | ConfigView *configView; |
Boris Barbulovski | 1019f1a | 2015-09-22 11:36:17 -0700 | [diff] [blame] | 312 | ConfigList *configList; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 313 | ConfigInfoView *helpText; |
Boris Barbulovski | b1f8a45 | 2015-09-22 11:36:02 -0700 | [diff] [blame] | 314 | QToolBar *toolBar; |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 315 | QAction *backAction; |
Boris Barbulovski | 780505e | 2015-09-22 11:36:13 -0700 | [diff] [blame] | 316 | QAction *singleViewAction; |
| 317 | QAction *splitViewAction; |
| 318 | QAction *fullViewAction; |
Boris Barbulovski | 7653866 | 2015-09-22 11:36:14 -0700 | [diff] [blame] | 319 | QSplitter *split1; |
| 320 | QSplitter *split2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | }; |