| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
|---|
| 3 | | - * Released under the terms of the GNU GPL v2.0. |
|---|
| 4 | 4 | */ |
|---|
| 5 | 5 | |
|---|
| 6 | | -#include <QTextBrowser> |
|---|
| 7 | | -#include <QTreeWidget> |
|---|
| 8 | | -#include <QMainWindow> |
|---|
| 9 | | -#include <QHeaderView> |
|---|
| 10 | | -#include <qsettings.h> |
|---|
| 11 | | -#include <QPushButton> |
|---|
| 12 | | -#include <QSettings> |
|---|
| 13 | | -#include <QLineEdit> |
|---|
| 14 | | -#include <QSplitter> |
|---|
| 15 | 6 | #include <QCheckBox> |
|---|
| 16 | 7 | #include <QDialog> |
|---|
| 8 | +#include <QHeaderView> |
|---|
| 9 | +#include <QLineEdit> |
|---|
| 10 | +#include <QMainWindow> |
|---|
| 11 | +#include <QPushButton> |
|---|
| 12 | +#include <QSettings> |
|---|
| 13 | +#include <QSplitter> |
|---|
| 14 | +#include <QStyledItemDelegate> |
|---|
| 15 | +#include <QTextBrowser> |
|---|
| 16 | +#include <QTreeWidget> |
|---|
| 17 | + |
|---|
| 17 | 18 | #include "expr.h" |
|---|
| 18 | 19 | |
|---|
| 19 | | -class ConfigView; |
|---|
| 20 | 20 | class ConfigList; |
|---|
| 21 | 21 | class ConfigItem; |
|---|
| 22 | | -class ConfigLineEdit; |
|---|
| 23 | 22 | class ConfigMainWindow; |
|---|
| 24 | 23 | |
|---|
| 25 | 24 | class ConfigSettings : public QSettings { |
|---|
| .. | .. |
|---|
| 30 | 29 | }; |
|---|
| 31 | 30 | |
|---|
| 32 | 31 | enum colIdx { |
|---|
| 33 | | - promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr |
|---|
| 32 | + promptColIdx, nameColIdx, dataColIdx |
|---|
| 34 | 33 | }; |
|---|
| 35 | 34 | enum listMode { |
|---|
| 36 | 35 | singleMode, menuMode, symbolMode, fullMode, listMode |
|---|
| .. | .. |
|---|
| 43 | 42 | Q_OBJECT |
|---|
| 44 | 43 | typedef class QTreeWidget Parent; |
|---|
| 45 | 44 | public: |
|---|
| 46 | | - ConfigList(ConfigView* p, const char *name = 0); |
|---|
| 45 | + ConfigList(QWidget *parent, const char *name = 0); |
|---|
| 46 | + ~ConfigList(); |
|---|
| 47 | 47 | void reinit(void); |
|---|
| 48 | | - ConfigView* parent(void) const |
|---|
| 49 | | - { |
|---|
| 50 | | - return (ConfigView*)Parent::parent(); |
|---|
| 51 | | - } |
|---|
| 52 | 48 | ConfigItem* findConfigItem(struct menu *); |
|---|
| 49 | + void setSelected(QTreeWidgetItem *item, bool enable) { |
|---|
| 50 | + for (int i = 0; i < selectedItems().size(); i++) |
|---|
| 51 | + selectedItems().at(i)->setSelected(false); |
|---|
| 52 | + |
|---|
| 53 | + item->setSelected(enable); |
|---|
| 54 | + } |
|---|
| 53 | 55 | |
|---|
| 54 | 56 | protected: |
|---|
| 55 | 57 | void keyPressEvent(QKeyEvent *e); |
|---|
| .. | .. |
|---|
| 63 | 65 | public slots: |
|---|
| 64 | 66 | void setRootMenu(struct menu *menu); |
|---|
| 65 | 67 | |
|---|
| 66 | | - void updateList(ConfigItem *item); |
|---|
| 68 | + void updateList(); |
|---|
| 67 | 69 | void setValue(ConfigItem* item, tristate val); |
|---|
| 68 | 70 | void changeValue(ConfigItem* item); |
|---|
| 69 | 71 | void updateSelection(void); |
|---|
| 70 | 72 | void saveSettings(void); |
|---|
| 73 | + void setOptionMode(QAction *action); |
|---|
| 74 | + void setShowName(bool on); |
|---|
| 75 | + |
|---|
| 71 | 76 | signals: |
|---|
| 72 | 77 | void menuChanged(struct menu *menu); |
|---|
| 73 | 78 | void menuSelected(struct menu *menu); |
|---|
| 79 | + void itemSelected(struct menu *menu); |
|---|
| 74 | 80 | void parentSelected(void); |
|---|
| 75 | 81 | void gotFocus(struct menu *); |
|---|
| 82 | + void showNameChanged(bool on); |
|---|
| 76 | 83 | |
|---|
| 77 | 84 | public: |
|---|
| 78 | 85 | void updateListAll(void) |
|---|
| 79 | 86 | { |
|---|
| 80 | 87 | updateAll = true; |
|---|
| 81 | | - updateList(NULL); |
|---|
| 88 | + updateList(); |
|---|
| 82 | 89 | updateAll = false; |
|---|
| 83 | | - } |
|---|
| 84 | | - ConfigList* listView() |
|---|
| 85 | | - { |
|---|
| 86 | | - return this; |
|---|
| 87 | | - } |
|---|
| 88 | | - ConfigItem* firstChild() const |
|---|
| 89 | | - { |
|---|
| 90 | | - return (ConfigItem *)children().first(); |
|---|
| 91 | | - } |
|---|
| 92 | | - void addColumn(colIdx idx) |
|---|
| 93 | | - { |
|---|
| 94 | | - showColumn(idx); |
|---|
| 95 | | - } |
|---|
| 96 | | - void removeColumn(colIdx idx) |
|---|
| 97 | | - { |
|---|
| 98 | | - hideColumn(idx); |
|---|
| 99 | 90 | } |
|---|
| 100 | 91 | void setAllOpen(bool open); |
|---|
| 101 | 92 | void setParentMenu(void); |
|---|
| .. | .. |
|---|
| 103 | 94 | bool menuSkip(struct menu *); |
|---|
| 104 | 95 | |
|---|
| 105 | 96 | void updateMenuList(ConfigItem *parent, struct menu*); |
|---|
| 106 | | - void updateMenuList(ConfigList *parent, struct menu*); |
|---|
| 97 | + void updateMenuList(struct menu *menu); |
|---|
| 107 | 98 | |
|---|
| 108 | 99 | bool updateAll; |
|---|
| 109 | 100 | |
|---|
| 110 | | - QPixmap symbolYesPix, symbolModPix, symbolNoPix; |
|---|
| 111 | | - QPixmap choiceYesPix, choiceNoPix; |
|---|
| 112 | | - QPixmap menuPix, menuInvPix, menuBackPix, voidPix; |
|---|
| 113 | | - |
|---|
| 114 | | - bool showName, showRange, showData; |
|---|
| 101 | + bool showName; |
|---|
| 115 | 102 | enum listMode mode; |
|---|
| 116 | 103 | enum optionMode optMode; |
|---|
| 117 | 104 | struct menu *rootEntry; |
|---|
| 118 | 105 | QPalette disabledColorGroup; |
|---|
| 119 | 106 | QPalette inactivedColorGroup; |
|---|
| 120 | 107 | QMenu* headerPopup; |
|---|
| 108 | + |
|---|
| 109 | + static QList<ConfigList *> allLists; |
|---|
| 110 | + static void updateListForAll(); |
|---|
| 111 | + static void updateListAllForAll(); |
|---|
| 112 | + |
|---|
| 113 | + static QAction *showNormalAction, *showAllAction, *showPromptAction; |
|---|
| 121 | 114 | }; |
|---|
| 122 | 115 | |
|---|
| 123 | 116 | class ConfigItem : public QTreeWidgetItem { |
|---|
| .. | .. |
|---|
| 140 | 133 | } |
|---|
| 141 | 134 | ~ConfigItem(void); |
|---|
| 142 | 135 | void init(void); |
|---|
| 143 | | - void okRename(int col); |
|---|
| 144 | 136 | void updateMenu(void); |
|---|
| 145 | 137 | void testUpdateMenu(bool v); |
|---|
| 146 | 138 | ConfigList* listView() const |
|---|
| .. | .. |
|---|
| 165 | 157 | |
|---|
| 166 | 158 | return ret; |
|---|
| 167 | 159 | } |
|---|
| 168 | | - void setText(colIdx idx, const QString& text) |
|---|
| 169 | | - { |
|---|
| 170 | | - Parent::setText(idx, text); |
|---|
| 171 | | - } |
|---|
| 172 | | - QString text(colIdx idx) const |
|---|
| 173 | | - { |
|---|
| 174 | | - return Parent::text(idx); |
|---|
| 175 | | - } |
|---|
| 176 | | - void setPixmap(colIdx idx, const QIcon &icon) |
|---|
| 177 | | - { |
|---|
| 178 | | - Parent::setIcon(idx, icon); |
|---|
| 179 | | - } |
|---|
| 180 | | - const QIcon pixmap(colIdx idx) const |
|---|
| 181 | | - { |
|---|
| 182 | | - return icon(idx); |
|---|
| 183 | | - } |
|---|
| 184 | 160 | // TODO: Implement paintCell |
|---|
| 185 | 161 | |
|---|
| 186 | 162 | ConfigItem* nextItem; |
|---|
| 187 | 163 | struct menu *menu; |
|---|
| 188 | 164 | bool visible; |
|---|
| 189 | 165 | bool goParent; |
|---|
| 166 | + |
|---|
| 167 | + static QIcon symbolYesIcon, symbolModIcon, symbolNoIcon; |
|---|
| 168 | + static QIcon choiceYesIcon, choiceNoIcon; |
|---|
| 169 | + static QIcon menuIcon, menubackIcon; |
|---|
| 190 | 170 | }; |
|---|
| 191 | 171 | |
|---|
| 192 | | -class ConfigLineEdit : public QLineEdit { |
|---|
| 193 | | - Q_OBJECT |
|---|
| 194 | | - typedef class QLineEdit Parent; |
|---|
| 172 | +class ConfigItemDelegate : public QStyledItemDelegate |
|---|
| 173 | +{ |
|---|
| 174 | +private: |
|---|
| 175 | + struct menu *menu; |
|---|
| 195 | 176 | public: |
|---|
| 196 | | - ConfigLineEdit(ConfigView* parent); |
|---|
| 197 | | - ConfigView* parent(void) const |
|---|
| 198 | | - { |
|---|
| 199 | | - return (ConfigView*)Parent::parent(); |
|---|
| 200 | | - } |
|---|
| 201 | | - void show(ConfigItem *i); |
|---|
| 202 | | - void keyPressEvent(QKeyEvent *e); |
|---|
| 203 | | - |
|---|
| 204 | | -public: |
|---|
| 205 | | - ConfigItem *item; |
|---|
| 206 | | -}; |
|---|
| 207 | | - |
|---|
| 208 | | -class ConfigView : public QWidget { |
|---|
| 209 | | - Q_OBJECT |
|---|
| 210 | | - typedef class QWidget Parent; |
|---|
| 211 | | -public: |
|---|
| 212 | | - ConfigView(QWidget* parent, const char *name = 0); |
|---|
| 213 | | - ~ConfigView(void); |
|---|
| 214 | | - static void updateList(ConfigItem* item); |
|---|
| 215 | | - static void updateListAll(void); |
|---|
| 216 | | - |
|---|
| 217 | | - bool showName(void) const { return list->showName; } |
|---|
| 218 | | - bool showRange(void) const { return list->showRange; } |
|---|
| 219 | | - bool showData(void) const { return list->showData; } |
|---|
| 220 | | -public slots: |
|---|
| 221 | | - void setShowName(bool); |
|---|
| 222 | | - void setShowRange(bool); |
|---|
| 223 | | - void setShowData(bool); |
|---|
| 224 | | - void setOptionMode(QAction *); |
|---|
| 225 | | -signals: |
|---|
| 226 | | - void showNameChanged(bool); |
|---|
| 227 | | - void showRangeChanged(bool); |
|---|
| 228 | | - void showDataChanged(bool); |
|---|
| 229 | | -public: |
|---|
| 230 | | - ConfigList* list; |
|---|
| 231 | | - ConfigLineEdit* lineEdit; |
|---|
| 232 | | - |
|---|
| 233 | | - static ConfigView* viewList; |
|---|
| 234 | | - ConfigView* nextView; |
|---|
| 235 | | - |
|---|
| 236 | | - static QAction *showNormalAction; |
|---|
| 237 | | - static QAction *showAllAction; |
|---|
| 238 | | - static QAction *showPromptAction; |
|---|
| 177 | + ConfigItemDelegate(QObject *parent = nullptr) |
|---|
| 178 | + : QStyledItemDelegate(parent) {} |
|---|
| 179 | + QWidget *createEditor(QWidget *parent, |
|---|
| 180 | + const QStyleOptionViewItem &option, |
|---|
| 181 | + const QModelIndex &index) const override; |
|---|
| 182 | + void setModelData(QWidget *editor, QAbstractItemModel *model, |
|---|
| 183 | + const QModelIndex &index) const override; |
|---|
| 239 | 184 | }; |
|---|
| 240 | 185 | |
|---|
| 241 | 186 | class ConfigInfoView : public QTextBrowser { |
|---|
| 242 | 187 | Q_OBJECT |
|---|
| 243 | 188 | typedef class QTextBrowser Parent; |
|---|
| 189 | + QMenu *contextMenu; |
|---|
| 244 | 190 | public: |
|---|
| 245 | 191 | ConfigInfoView(QWidget* parent, const char *name = 0); |
|---|
| 246 | 192 | bool showDebug(void) const { return _showDebug; } |
|---|
| .. | .. |
|---|
| 249 | 195 | void setInfo(struct menu *menu); |
|---|
| 250 | 196 | void saveSettings(void); |
|---|
| 251 | 197 | void setShowDebug(bool); |
|---|
| 198 | + void clicked (const QUrl &url); |
|---|
| 252 | 199 | |
|---|
| 253 | 200 | signals: |
|---|
| 254 | 201 | void showDebugChanged(bool); |
|---|
| .. | .. |
|---|
| 260 | 207 | QString debug_info(struct symbol *sym); |
|---|
| 261 | 208 | static QString print_filter(const QString &str); |
|---|
| 262 | 209 | static void expr_print_help(void *data, struct symbol *sym, const char *str); |
|---|
| 263 | | - QMenu *createStandardContextMenu(const QPoint & pos); |
|---|
| 264 | | - void contextMenuEvent(QContextMenuEvent *e); |
|---|
| 210 | + void contextMenuEvent(QContextMenuEvent *event); |
|---|
| 265 | 211 | |
|---|
| 266 | 212 | struct symbol *sym; |
|---|
| 267 | 213 | struct menu *_menu; |
|---|
| .. | .. |
|---|
| 272 | 218 | Q_OBJECT |
|---|
| 273 | 219 | typedef class QDialog Parent; |
|---|
| 274 | 220 | public: |
|---|
| 275 | | - ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0); |
|---|
| 221 | + ConfigSearchWindow(ConfigMainWindow *parent); |
|---|
| 276 | 222 | |
|---|
| 277 | 223 | public slots: |
|---|
| 278 | 224 | void saveSettings(void); |
|---|
| .. | .. |
|---|
| 282 | 228 | QLineEdit* editField; |
|---|
| 283 | 229 | QPushButton* searchButton; |
|---|
| 284 | 230 | QSplitter* split; |
|---|
| 285 | | - ConfigView* list; |
|---|
| 231 | + ConfigList *list; |
|---|
| 286 | 232 | ConfigInfoView* info; |
|---|
| 287 | 233 | |
|---|
| 288 | 234 | struct symbol **result; |
|---|
| .. | .. |
|---|
| 291 | 237 | class ConfigMainWindow : public QMainWindow { |
|---|
| 292 | 238 | Q_OBJECT |
|---|
| 293 | 239 | |
|---|
| 240 | + char *configname; |
|---|
| 294 | 241 | static QAction *saveAction; |
|---|
| 295 | 242 | static void conf_changed(void); |
|---|
| 296 | 243 | public: |
|---|
| 297 | 244 | ConfigMainWindow(void); |
|---|
| 298 | 245 | public slots: |
|---|
| 299 | 246 | void changeMenu(struct menu *); |
|---|
| 247 | + void changeItens(struct menu *); |
|---|
| 300 | 248 | void setMenuLink(struct menu *); |
|---|
| 301 | 249 | void listFocusChanged(void); |
|---|
| 302 | 250 | void goBack(void); |
|---|
| .. | .. |
|---|
| 315 | 263 | void closeEvent(QCloseEvent *e); |
|---|
| 316 | 264 | |
|---|
| 317 | 265 | ConfigSearchWindow *searchWindow; |
|---|
| 318 | | - ConfigView *menuView; |
|---|
| 319 | 266 | ConfigList *menuList; |
|---|
| 320 | | - ConfigView *configView; |
|---|
| 321 | 267 | ConfigList *configList; |
|---|
| 322 | 268 | ConfigInfoView *helpText; |
|---|
| 323 | | - QToolBar *toolBar; |
|---|
| 324 | 269 | QAction *backAction; |
|---|
| 325 | 270 | QAction *singleViewAction; |
|---|
| 326 | 271 | QAction *splitViewAction; |
|---|