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; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | class ConfigLineEdit; |
| 21 | class ConfigMainWindow; |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | class ConfigSettings : public QSettings { |
| 24 | public: |
Ben Hutchings | 00d4f8f | 2013-10-06 19:21:31 +0100 | [diff] [blame] | 25 | ConfigSettings(); |
Boris Barbulovski | 041fbdc | 2015-09-22 11:36:05 -0700 | [diff] [blame] | 26 | QList<int> readSizes(const QString& key, bool *ok); |
| 27 | bool writeSizes(const QString& key, const QList<int>& value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | enum colIdx { |
| 31 | promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr |
| 32 | }; |
| 33 | enum listMode { |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 34 | singleMode, menuMode, symbolMode, fullMode, listMode |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | }; |
Li Zefan | 39a4897 | 2010-05-10 16:33:41 +0800 | [diff] [blame] | 36 | enum optionMode { |
| 37 | normalOpt = 0, allOpt, promptOpt |
| 38 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | class ConfigLineEdit : public QLineEdit { |
| 41 | Q_OBJECT |
| 42 | typedef class QLineEdit Parent; |
| 43 | public: |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 44 | ConfigLineEdit(ConfigView* parent); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | ConfigView* parent(void) const |
| 46 | { |
| 47 | return (ConfigView*)Parent::parent(); |
| 48 | } |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame] | 49 | void show(QTreeWidgetItem *i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | void keyPressEvent(QKeyEvent *e); |
| 51 | |
| 52 | public: |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame] | 53 | QTreeWidgetItem *item; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
Boris Barbulovski | 34d6320 | 2015-09-22 11:36:09 -0700 | [diff] [blame] | 56 | class ConfigView : public QWidget { |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 57 | Q_OBJECT |
Boris Barbulovski | 34d6320 | 2015-09-22 11:36:09 -0700 | [diff] [blame] | 58 | typedef class QWidget Parent; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 59 | public: |
| 60 | ConfigView(QWidget* parent, const char *name = 0); |
| 61 | ~ConfigView(void); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame] | 62 | static void updateList(QTreeWidgetItem* item); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 63 | static void updateListAll(void); |
| 64 | |
Boris Barbulovski | 7653866 | 2015-09-22 11:36:14 -0700 | [diff] [blame] | 65 | bool showName(void) const { return false; } // TODO: Implement me. |
| 66 | bool showRange(void) const { return false; } // TODO: Implement me. |
| 67 | bool showData(void) const { return false; } // TODO: Implement me. |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 68 | public slots: |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 69 | void setShowName(bool); |
| 70 | void setShowRange(bool); |
| 71 | void setShowData(bool); |
Li Zefan | 39a4897 | 2010-05-10 16:33:41 +0800 | [diff] [blame] | 72 | void setOptionMode(QAction *); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 73 | signals: |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 74 | void showNameChanged(bool); |
| 75 | void showRangeChanged(bool); |
| 76 | void showDataChanged(bool); |
| 77 | public: |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame] | 78 | QTreeWidget* list; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 79 | ConfigLineEdit* lineEdit; |
| 80 | |
| 81 | static ConfigView* viewList; |
| 82 | ConfigView* nextView; |
Li Zefan | 39a4897 | 2010-05-10 16:33:41 +0800 | [diff] [blame] | 83 | |
| 84 | static QAction *showNormalAction; |
| 85 | static QAction *showAllAction; |
| 86 | static QAction *showPromptAction; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
Boris Barbulovski | 924bbb5 | 2015-09-22 11:36:06 -0700 | [diff] [blame] | 89 | class ConfigInfoView : public QTextBrowser { |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 90 | Q_OBJECT |
Boris Barbulovski | 924bbb5 | 2015-09-22 11:36:06 -0700 | [diff] [blame] | 91 | typedef class QTextBrowser Parent; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 92 | public: |
| 93 | ConfigInfoView(QWidget* parent, const char *name = 0); |
| 94 | bool showDebug(void) const { return _showDebug; } |
| 95 | |
| 96 | public slots: |
| 97 | void setInfo(struct menu *menu); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 98 | void saveSettings(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 99 | void setShowDebug(bool); |
| 100 | |
| 101 | signals: |
| 102 | void showDebugChanged(bool); |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 103 | void menuSelected(struct menu *); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 104 | |
| 105 | protected: |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 106 | void symbolInfo(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 107 | void menuInfo(void); |
| 108 | QString debug_info(struct symbol *sym); |
| 109 | static QString print_filter(const QString &str); |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 110 | 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] | 111 | QMenu *createStandardContextMenu(const QPoint & pos); |
| 112 | void contextMenuEvent(QContextMenuEvent *e); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 113 | |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 114 | struct symbol *sym; |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 115 | struct menu *_menu; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 116 | bool _showDebug; |
| 117 | }; |
| 118 | |
| 119 | class ConfigSearchWindow : public QDialog { |
| 120 | Q_OBJECT |
| 121 | typedef class QDialog Parent; |
| 122 | public: |
Marco Costalba | 63431e7 | 2006-10-05 19:12:59 +0200 | [diff] [blame] | 123 | ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 124 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 125 | public slots: |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 126 | void saveSettings(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 127 | void search(void); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 128 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 129 | protected: |
| 130 | QLineEdit* editField; |
| 131 | QPushButton* searchButton; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 132 | QSplitter* split; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 133 | ConfigView* list; |
| 134 | ConfigInfoView* info; |
| 135 | |
| 136 | struct symbol **result; |
| 137 | }; |
| 138 | |
Boris Barbulovski | b1f8a45 | 2015-09-22 11:36:02 -0700 | [diff] [blame] | 139 | class ConfigMainWindow : public QMainWindow { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | Q_OBJECT |
Karsten Wiese | 3b354c55 | 2006-12-13 00:34:08 -0800 | [diff] [blame] | 141 | |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 142 | static QAction *saveAction; |
Karsten Wiese | 3b354c55 | 2006-12-13 00:34:08 -0800 | [diff] [blame] | 143 | static void conf_changed(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | public: |
| 145 | ConfigMainWindow(void); |
| 146 | public slots: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | void changeMenu(struct menu *); |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 148 | void setMenuLink(struct menu *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | void listFocusChanged(void); |
| 150 | void goBack(void); |
| 151 | void loadConfig(void); |
Michal Marek | bac6aa8 | 2011-05-25 15:10:25 +0200 | [diff] [blame] | 152 | bool saveConfig(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | void saveConfigAs(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 154 | void searchConfig(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | void showSingleView(void); |
| 156 | void showSplitView(void); |
| 157 | void showFullView(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | void showIntro(void); |
| 159 | void showAbout(void); |
| 160 | void saveSettings(void); |
| 161 | |
| 162 | protected: |
| 163 | void closeEvent(QCloseEvent *e); |
| 164 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 165 | ConfigSearchWindow *searchWindow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | ConfigView *menuView; |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame] | 167 | QTreeWidget *menuList; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | ConfigView *configView; |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame] | 169 | QTreeWidget *configList; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 170 | ConfigInfoView *helpText; |
Boris Barbulovski | b1f8a45 | 2015-09-22 11:36:02 -0700 | [diff] [blame] | 171 | QToolBar *toolBar; |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 172 | QAction *backAction; |
Boris Barbulovski | 780505e | 2015-09-22 11:36:13 -0700 | [diff] [blame] | 173 | QAction *singleViewAction; |
| 174 | QAction *splitViewAction; |
| 175 | QAction *fullViewAction; |
Boris Barbulovski | 7653866 | 2015-09-22 11:36:14 -0700 | [diff] [blame] | 176 | QSplitter *split1; |
| 177 | QSplitter *split2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | }; |