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 | |
| 6 | #include <qlistview.h> |
| 7 | #if QT_VERSION >= 300 |
| 8 | #include <qsettings.h> |
| 9 | #else |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 10 | class QSettings { |
| 11 | public: |
| 12 | void beginGroup(const QString& group) { } |
| 13 | void endGroup(void) { } |
| 14 | bool readBoolEntry(const QString& key, bool def = FALSE, bool* ok = 0) const |
| 15 | { if (ok) *ok = FALSE; return def; } |
| 16 | int readNumEntry(const QString& key, int def = 0, bool* ok = 0) const |
| 17 | { if (ok) *ok = FALSE; return def; } |
| 18 | QString readEntry(const QString& key, const QString& def = QString::null, bool* ok = 0) const |
| 19 | { if (ok) *ok = FALSE; return def; } |
| 20 | QStringList readListEntry(const QString& key, bool* ok = 0) const |
| 21 | { if (ok) *ok = FALSE; return QStringList(); } |
| 22 | template <class t> |
| 23 | bool writeEntry(const QString& key, t value) |
| 24 | { return TRUE; } |
| 25 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #endif |
| 27 | |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 28 | class ConfigView; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | class ConfigList; |
| 30 | class ConfigItem; |
| 31 | class ConfigLineEdit; |
| 32 | class ConfigMainWindow; |
| 33 | |
| 34 | |
| 35 | class ConfigSettings : public QSettings { |
| 36 | public: |
Dave Jones | 19144d0 | 2006-01-08 01:05:02 -0800 | [diff] [blame] | 37 | QValueList<int> readSizes(const QString& key, bool *ok); |
| 38 | bool writeSizes(const QString& key, const QValueList<int>& value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | enum colIdx { |
| 42 | promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr |
| 43 | }; |
| 44 | enum listMode { |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 45 | singleMode, menuMode, symbolMode, fullMode, listMode |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | class ConfigList : public QListView { |
| 49 | Q_OBJECT |
| 50 | typedef class QListView Parent; |
| 51 | public: |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 52 | ConfigList(ConfigView* p, const char *name = 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | void reinit(void); |
| 54 | ConfigView* parent(void) const |
| 55 | { |
| 56 | return (ConfigView*)Parent::parent(); |
| 57 | } |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 58 | ConfigItem* findConfigItem(struct menu *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | protected: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | void keyPressEvent(QKeyEvent *e); |
| 62 | void contentsMousePressEvent(QMouseEvent *e); |
| 63 | void contentsMouseReleaseEvent(QMouseEvent *e); |
| 64 | void contentsMouseMoveEvent(QMouseEvent *e); |
| 65 | void contentsMouseDoubleClickEvent(QMouseEvent *e); |
| 66 | void focusInEvent(QFocusEvent *e); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 67 | void contextMenuEvent(QContextMenuEvent *e); |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | public slots: |
| 70 | void setRootMenu(struct menu *menu); |
| 71 | |
| 72 | void updateList(ConfigItem *item); |
| 73 | void setValue(ConfigItem* item, tristate val); |
| 74 | void changeValue(ConfigItem* item); |
| 75 | void updateSelection(void); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 76 | void saveSettings(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | signals: |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 78 | void menuChanged(struct menu *menu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | void menuSelected(struct menu *menu); |
| 80 | void parentSelected(void); |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 81 | void gotFocus(struct menu *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
| 83 | public: |
| 84 | void updateListAll(void) |
| 85 | { |
| 86 | updateAll = true; |
| 87 | updateList(NULL); |
| 88 | updateAll = false; |
| 89 | } |
| 90 | ConfigList* listView() |
| 91 | { |
| 92 | return this; |
| 93 | } |
| 94 | ConfigItem* firstChild() const |
| 95 | { |
| 96 | return (ConfigItem *)Parent::firstChild(); |
| 97 | } |
| 98 | int mapIdx(colIdx idx) |
| 99 | { |
| 100 | return colMap[idx]; |
| 101 | } |
| 102 | void addColumn(colIdx idx, const QString& label) |
| 103 | { |
| 104 | colMap[idx] = Parent::addColumn(label); |
| 105 | colRevMap[colMap[idx]] = idx; |
| 106 | } |
| 107 | void removeColumn(colIdx idx) |
| 108 | { |
| 109 | int col = colMap[idx]; |
| 110 | if (col >= 0) { |
| 111 | Parent::removeColumn(col); |
| 112 | colRevMap[col] = colMap[idx] = -1; |
| 113 | } |
| 114 | } |
| 115 | void setAllOpen(bool open); |
| 116 | void setParentMenu(void); |
| 117 | |
| 118 | template <class P> |
Dave Jones | 19144d0 | 2006-01-08 01:05:02 -0800 | [diff] [blame] | 119 | void updateMenuList(P*, struct menu*); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | bool updateAll; |
| 122 | |
| 123 | QPixmap symbolYesPix, symbolModPix, symbolNoPix; |
| 124 | QPixmap choiceYesPix, choiceNoPix; |
| 125 | QPixmap menuPix, menuInvPix, menuBackPix, voidPix; |
| 126 | |
| 127 | bool showAll, showName, showRange, showData; |
| 128 | enum listMode mode; |
| 129 | struct menu *rootEntry; |
| 130 | QColorGroup disabledColorGroup; |
| 131 | QColorGroup inactivedColorGroup; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 132 | QPopupMenu* headerPopup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
| 134 | private: |
| 135 | int colMap[colNr]; |
| 136 | int colRevMap[colNr]; |
| 137 | }; |
| 138 | |
| 139 | class ConfigItem : public QListViewItem { |
| 140 | typedef class QListViewItem Parent; |
| 141 | public: |
| 142 | ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v) |
| 143 | : Parent(parent, after), menu(m), visible(v), goParent(false) |
| 144 | { |
| 145 | init(); |
| 146 | } |
| 147 | ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) |
| 148 | : Parent(parent, after), menu(m), visible(v), goParent(false) |
| 149 | { |
| 150 | init(); |
| 151 | } |
| 152 | ConfigItem(QListView *parent, ConfigItem *after, bool v) |
| 153 | : Parent(parent, after), menu(0), visible(v), goParent(true) |
| 154 | { |
| 155 | init(); |
| 156 | } |
| 157 | ~ConfigItem(void); |
| 158 | void init(void); |
| 159 | #if QT_VERSION >= 300 |
| 160 | void okRename(int col); |
| 161 | #endif |
| 162 | void updateMenu(void); |
| 163 | void testUpdateMenu(bool v); |
| 164 | ConfigList* listView() const |
| 165 | { |
| 166 | return (ConfigList*)Parent::listView(); |
| 167 | } |
| 168 | ConfigItem* firstChild() const |
| 169 | { |
| 170 | return (ConfigItem *)Parent::firstChild(); |
| 171 | } |
| 172 | ConfigItem* nextSibling() const |
| 173 | { |
| 174 | return (ConfigItem *)Parent::nextSibling(); |
| 175 | } |
| 176 | void setText(colIdx idx, const QString& text) |
| 177 | { |
| 178 | Parent::setText(listView()->mapIdx(idx), text); |
| 179 | } |
| 180 | QString text(colIdx idx) const |
| 181 | { |
| 182 | return Parent::text(listView()->mapIdx(idx)); |
| 183 | } |
| 184 | void setPixmap(colIdx idx, const QPixmap& pm) |
| 185 | { |
| 186 | Parent::setPixmap(listView()->mapIdx(idx), pm); |
| 187 | } |
| 188 | const QPixmap* pixmap(colIdx idx) const |
| 189 | { |
| 190 | return Parent::pixmap(listView()->mapIdx(idx)); |
| 191 | } |
| 192 | void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); |
| 193 | |
| 194 | ConfigItem* nextItem; |
| 195 | struct menu *menu; |
| 196 | bool visible; |
| 197 | bool goParent; |
| 198 | }; |
| 199 | |
| 200 | class ConfigLineEdit : public QLineEdit { |
| 201 | Q_OBJECT |
| 202 | typedef class QLineEdit Parent; |
| 203 | public: |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 204 | ConfigLineEdit(ConfigView* parent); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | ConfigView* parent(void) const |
| 206 | { |
| 207 | return (ConfigView*)Parent::parent(); |
| 208 | } |
| 209 | void show(ConfigItem *i); |
| 210 | void keyPressEvent(QKeyEvent *e); |
| 211 | |
| 212 | public: |
| 213 | ConfigItem *item; |
| 214 | }; |
| 215 | |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 216 | class ConfigView : public QVBox { |
| 217 | Q_OBJECT |
| 218 | typedef class QVBox Parent; |
| 219 | public: |
| 220 | ConfigView(QWidget* parent, const char *name = 0); |
| 221 | ~ConfigView(void); |
| 222 | static void updateList(ConfigItem* item); |
| 223 | static void updateListAll(void); |
| 224 | |
| 225 | bool showAll(void) const { return list->showAll; } |
| 226 | bool showName(void) const { return list->showName; } |
| 227 | bool showRange(void) const { return list->showRange; } |
| 228 | bool showData(void) const { return list->showData; } |
| 229 | public slots: |
| 230 | void setShowAll(bool); |
| 231 | void setShowName(bool); |
| 232 | void setShowRange(bool); |
| 233 | void setShowData(bool); |
| 234 | signals: |
| 235 | void showAllChanged(bool); |
| 236 | void showNameChanged(bool); |
| 237 | void showRangeChanged(bool); |
| 238 | void showDataChanged(bool); |
| 239 | public: |
| 240 | ConfigList* list; |
| 241 | ConfigLineEdit* lineEdit; |
| 242 | |
| 243 | static ConfigView* viewList; |
| 244 | ConfigView* nextView; |
| 245 | }; |
| 246 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 247 | class ConfigInfoView : public QTextBrowser { |
| 248 | Q_OBJECT |
| 249 | typedef class QTextBrowser Parent; |
| 250 | public: |
| 251 | ConfigInfoView(QWidget* parent, const char *name = 0); |
| 252 | bool showDebug(void) const { return _showDebug; } |
| 253 | |
| 254 | public slots: |
| 255 | void setInfo(struct menu *menu); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 256 | void saveSettings(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 257 | void setSource(const QString& name); |
| 258 | void setShowDebug(bool); |
| 259 | |
| 260 | signals: |
| 261 | void showDebugChanged(bool); |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 262 | void menuSelected(struct menu *); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 263 | |
| 264 | protected: |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 265 | void symbolInfo(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 266 | void menuInfo(void); |
| 267 | QString debug_info(struct symbol *sym); |
| 268 | static QString print_filter(const QString &str); |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 269 | static void expr_print_help(void *data, struct symbol *sym, const char *str); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 270 | QPopupMenu* createPopupMenu(const QPoint& pos); |
| 271 | void contentsContextMenuEvent(QContextMenuEvent *e); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 272 | |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 273 | struct symbol *sym; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 274 | struct menu *menu; |
| 275 | bool _showDebug; |
| 276 | }; |
| 277 | |
| 278 | class ConfigSearchWindow : public QDialog { |
| 279 | Q_OBJECT |
| 280 | typedef class QDialog Parent; |
| 281 | public: |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 282 | ConfigSearchWindow(QWidget* parent, const char *name = 0); |
| 283 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 284 | public slots: |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 285 | void saveSettings(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 286 | void search(void); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 287 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 288 | protected: |
| 289 | QLineEdit* editField; |
| 290 | QPushButton* searchButton; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 291 | QSplitter* split; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 292 | ConfigView* list; |
| 293 | ConfigInfoView* info; |
| 294 | |
| 295 | struct symbol **result; |
| 296 | }; |
| 297 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | class ConfigMainWindow : public QMainWindow { |
| 299 | Q_OBJECT |
Karsten Wiese | 3b354c5 | 2006-12-13 00:34:08 -0800 | [diff] [blame^] | 300 | |
| 301 | static QAction *saveAction; |
| 302 | static void conf_changed(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | public: |
| 304 | ConfigMainWindow(void); |
| 305 | public slots: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | void changeMenu(struct menu *); |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 307 | void setMenuLink(struct menu *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | void listFocusChanged(void); |
| 309 | void goBack(void); |
| 310 | void loadConfig(void); |
| 311 | void saveConfig(void); |
| 312 | void saveConfigAs(void); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 313 | void searchConfig(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | void showSingleView(void); |
| 315 | void showSplitView(void); |
| 316 | void showFullView(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | void showIntro(void); |
| 318 | void showAbout(void); |
| 319 | void saveSettings(void); |
| 320 | |
| 321 | protected: |
| 322 | void closeEvent(QCloseEvent *e); |
| 323 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 324 | ConfigSearchWindow *searchWindow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | ConfigView *menuView; |
| 326 | ConfigList *menuList; |
| 327 | ConfigView *configView; |
| 328 | ConfigList *configList; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 329 | ConfigInfoView *helpText; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | QToolBar *toolBar; |
| 331 | QAction *backAction; |
| 332 | QSplitter* split1; |
| 333 | QSplitter* split2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | }; |