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