2019-11-22 16:55:58 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2009-08-12 17:00:51 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
|
|
|
|
*/
|
|
|
|
|
2019-11-22 16:55:58 +01:00
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QDialog>
|
2016-01-22 11:54:22 +01:00
|
|
|
#include <QHeaderView>
|
2019-11-22 16:55:58 +01:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QMainWindow>
|
2016-01-22 11:54:22 +01:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QSplitter>
|
2019-11-22 16:55:58 +01:00
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
#include <QTextBrowser>
|
|
|
|
#include <QTreeWidget>
|
|
|
|
|
2016-01-22 11:54:22 +01:00
|
|
|
#include "expr.h"
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
class ConfigList;
|
|
|
|
class ConfigItem;
|
|
|
|
class ConfigMainWindow;
|
|
|
|
|
|
|
|
class ConfigSettings : public QSettings {
|
|
|
|
public:
|
2014-04-11 20:24:06 +02:00
|
|
|
ConfigSettings();
|
2016-01-22 11:54:22 +01:00
|
|
|
QList<int> readSizes(const QString& key, bool *ok);
|
|
|
|
bool writeSizes(const QString& key, const QList<int>& value);
|
2009-08-12 17:00:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum colIdx {
|
2019-11-22 16:55:58 +01:00
|
|
|
promptColIdx, nameColIdx, dataColIdx
|
2009-08-12 17:00:51 +02:00
|
|
|
};
|
|
|
|
enum listMode {
|
|
|
|
singleMode, menuMode, symbolMode, fullMode, listMode
|
|
|
|
};
|
2014-04-11 20:24:06 +02:00
|
|
|
enum optionMode {
|
|
|
|
normalOpt = 0, allOpt, promptOpt
|
|
|
|
};
|
2009-08-12 17:00:51 +02:00
|
|
|
|
2016-01-22 11:54:22 +01:00
|
|
|
class ConfigList : public QTreeWidget {
|
2009-08-12 17:00:51 +02:00
|
|
|
Q_OBJECT
|
2016-01-22 11:54:22 +01:00
|
|
|
typedef class QTreeWidget Parent;
|
2009-08-12 17:00:51 +02:00
|
|
|
public:
|
2019-11-22 16:55:58 +01:00
|
|
|
ConfigList(QWidget *parent, const char *name = NULL);
|
|
|
|
~ConfigList();
|
2009-08-12 17:00:51 +02:00
|
|
|
void reinit(void);
|
|
|
|
ConfigItem* findConfigItem(struct menu *);
|
2019-11-22 16:55:58 +01:00
|
|
|
void setSelected(QTreeWidgetItem *item, bool enable) {
|
|
|
|
for (int i = 0; i < selectedItems().size(); i++)
|
|
|
|
selectedItems().at(i)->setSelected(false);
|
|
|
|
|
|
|
|
item->setSelected(enable);
|
|
|
|
}
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void keyPressEvent(QKeyEvent *e);
|
2016-01-22 11:54:22 +01:00
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *e);
|
2009-08-12 17:00:51 +02:00
|
|
|
void focusInEvent(QFocusEvent *e);
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setRootMenu(struct menu *menu);
|
|
|
|
|
2019-11-22 16:55:58 +01:00
|
|
|
void updateList();
|
2009-08-12 17:00:51 +02:00
|
|
|
void setValue(ConfigItem* item, tristate val);
|
|
|
|
void changeValue(ConfigItem* item);
|
|
|
|
void updateSelection(void);
|
|
|
|
void saveSettings(void);
|
2019-11-22 16:55:58 +01:00
|
|
|
void setOptionMode(QAction *action);
|
|
|
|
void setShowName(bool on);
|
|
|
|
|
2009-08-12 17:00:51 +02:00
|
|
|
signals:
|
|
|
|
void menuChanged(struct menu *menu);
|
|
|
|
void menuSelected(struct menu *menu);
|
2019-11-22 16:55:58 +01:00
|
|
|
void itemSelected(struct menu *menu);
|
2009-08-12 17:00:51 +02:00
|
|
|
void parentSelected(void);
|
|
|
|
void gotFocus(struct menu *);
|
2019-11-22 16:55:58 +01:00
|
|
|
void showNameChanged(bool on);
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
void updateListAll(void)
|
|
|
|
{
|
|
|
|
updateAll = true;
|
2019-11-22 16:55:58 +01:00
|
|
|
updateList();
|
2009-08-12 17:00:51 +02:00
|
|
|
updateAll = false;
|
|
|
|
}
|
|
|
|
void setAllOpen(bool open);
|
|
|
|
void setParentMenu(void);
|
|
|
|
|
2014-04-11 20:24:06 +02:00
|
|
|
bool menuSkip(struct menu *);
|
|
|
|
|
2016-01-22 11:54:22 +01:00
|
|
|
void updateMenuList(ConfigItem *parent, struct menu*);
|
2019-11-22 16:55:58 +01:00
|
|
|
void updateMenuList(struct menu *menu);
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
bool updateAll;
|
|
|
|
|
2019-11-22 16:55:58 +01:00
|
|
|
bool showName;
|
2009-08-12 17:00:51 +02:00
|
|
|
enum listMode mode;
|
2014-04-11 20:24:06 +02:00
|
|
|
enum optionMode optMode;
|
2009-08-12 17:00:51 +02:00
|
|
|
struct menu *rootEntry;
|
2016-01-22 11:54:22 +01:00
|
|
|
QPalette disabledColorGroup;
|
|
|
|
QPalette inactivedColorGroup;
|
|
|
|
QMenu* headerPopup;
|
2019-11-22 16:55:58 +01:00
|
|
|
|
|
|
|
static QList<ConfigList *> allLists;
|
|
|
|
static void updateListForAll();
|
|
|
|
static void updateListAllForAll();
|
|
|
|
|
|
|
|
static QAction *showNormalAction, *showAllAction, *showPromptAction;
|
2009-08-12 17:00:51 +02:00
|
|
|
};
|
|
|
|
|
2016-01-22 11:54:22 +01:00
|
|
|
class ConfigItem : public QTreeWidgetItem {
|
|
|
|
typedef class QTreeWidgetItem Parent;
|
2009-08-12 17:00:51 +02:00
|
|
|
public:
|
2016-01-22 11:54:22 +01:00
|
|
|
ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
|
|
|
|
: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
|
2009-08-12 17:00:51 +02:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
|
2016-01-22 11:54:22 +01:00
|
|
|
: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
|
2009-08-12 17:00:51 +02:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
2016-01-22 11:54:22 +01:00
|
|
|
ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
|
|
|
|
: Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
|
2009-08-12 17:00:51 +02:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
~ConfigItem(void);
|
|
|
|
void init(void);
|
|
|
|
void updateMenu(void);
|
|
|
|
void testUpdateMenu(bool v);
|
|
|
|
ConfigList* listView() const
|
|
|
|
{
|
2016-01-22 11:54:22 +01:00
|
|
|
return (ConfigList*)Parent::treeWidget();
|
2009-08-12 17:00:51 +02:00
|
|
|
}
|
|
|
|
ConfigItem* firstChild() const
|
|
|
|
{
|
2016-01-22 11:54:22 +01:00
|
|
|
return (ConfigItem *)Parent::child(0);
|
2009-08-12 17:00:51 +02:00
|
|
|
}
|
2016-01-22 11:54:22 +01:00
|
|
|
ConfigItem* nextSibling()
|
2009-08-12 17:00:51 +02:00
|
|
|
{
|
2016-01-22 11:54:22 +01:00
|
|
|
ConfigItem *ret = NULL;
|
|
|
|
ConfigItem *_parent = (ConfigItem *)parent();
|
|
|
|
|
|
|
|
if(_parent) {
|
|
|
|
ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1);
|
|
|
|
} else {
|
|
|
|
QTreeWidget *_treeWidget = treeWidget();
|
|
|
|
ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2009-08-12 17:00:51 +02:00
|
|
|
}
|
2016-01-22 11:54:22 +01:00
|
|
|
// TODO: Implement paintCell
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
ConfigItem* nextItem;
|
|
|
|
struct menu *menu;
|
|
|
|
bool visible;
|
|
|
|
bool goParent;
|
|
|
|
|
2019-11-22 16:55:58 +01:00
|
|
|
static QIcon symbolYesIcon, symbolModIcon, symbolNoIcon;
|
|
|
|
static QIcon choiceYesIcon, choiceNoIcon;
|
|
|
|
static QIcon menuIcon, menubackIcon;
|
2009-08-12 17:00:51 +02:00
|
|
|
};
|
|
|
|
|
2019-11-22 16:55:58 +01:00
|
|
|
class ConfigItemDelegate : public QStyledItemDelegate
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
struct menu *menu;
|
2009-08-12 17:00:51 +02:00
|
|
|
public:
|
2019-11-22 16:55:58 +01:00
|
|
|
ConfigItemDelegate(QObject *parent = nullptr)
|
|
|
|
: QStyledItemDelegate(parent) {}
|
|
|
|
QWidget *createEditor(QWidget *parent,
|
|
|
|
const QStyleOptionViewItem &option,
|
|
|
|
const QModelIndex &index) const override;
|
|
|
|
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
|
|
|
const QModelIndex &index) const override;
|
2009-08-12 17:00:51 +02:00
|
|
|
};
|
|
|
|
|
2016-01-22 11:54:22 +01:00
|
|
|
class ConfigInfoView : public QTextBrowser {
|
2009-08-12 17:00:51 +02:00
|
|
|
Q_OBJECT
|
2016-01-22 11:54:22 +01:00
|
|
|
typedef class QTextBrowser Parent;
|
2019-11-22 16:55:58 +01:00
|
|
|
QMenu *contextMenu;
|
2009-08-12 17:00:51 +02:00
|
|
|
public:
|
2018-06-05 08:41:29 +02:00
|
|
|
ConfigInfoView(QWidget* parent, const char *name = NULL);
|
2009-08-12 17:00:51 +02:00
|
|
|
bool showDebug(void) const { return _showDebug; }
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setInfo(struct menu *menu);
|
|
|
|
void saveSettings(void);
|
|
|
|
void setShowDebug(bool);
|
2019-11-22 16:55:58 +01:00
|
|
|
void clicked (const QUrl &url);
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void showDebugChanged(bool);
|
|
|
|
void menuSelected(struct menu *);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void symbolInfo(void);
|
|
|
|
void menuInfo(void);
|
|
|
|
QString debug_info(struct symbol *sym);
|
|
|
|
static QString print_filter(const QString &str);
|
|
|
|
static void expr_print_help(void *data, struct symbol *sym, const char *str);
|
2019-11-22 16:55:58 +01:00
|
|
|
void contextMenuEvent(QContextMenuEvent *event);
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
struct symbol *sym;
|
2014-04-11 20:24:06 +02:00
|
|
|
struct menu *_menu;
|
2009-08-12 17:00:51 +02:00
|
|
|
bool _showDebug;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ConfigSearchWindow : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
typedef class QDialog Parent;
|
|
|
|
public:
|
2019-11-22 16:55:58 +01:00
|
|
|
ConfigSearchWindow(ConfigMainWindow *parent);
|
2009-08-12 17:00:51 +02:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void saveSettings(void);
|
|
|
|
void search(void);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QLineEdit* editField;
|
|
|
|
QPushButton* searchButton;
|
|
|
|
QSplitter* split;
|
2019-11-22 16:55:58 +01:00
|
|
|
ConfigList *list;
|
2009-08-12 17:00:51 +02:00
|
|
|
ConfigInfoView* info;
|
|
|
|
|
|
|
|
struct symbol **result;
|
|
|
|
};
|
|
|
|
|
2016-01-22 11:54:22 +01:00
|
|
|
class ConfigMainWindow : public QMainWindow {
|
2009-08-12 17:00:51 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2019-11-22 16:55:58 +01:00
|
|
|
char *configname;
|
2016-01-22 11:54:22 +01:00
|
|
|
static QAction *saveAction;
|
2009-08-12 17:00:51 +02:00
|
|
|
static void conf_changed(void);
|
|
|
|
public:
|
|
|
|
ConfigMainWindow(void);
|
|
|
|
public slots:
|
|
|
|
void changeMenu(struct menu *);
|
2019-11-22 16:55:58 +01:00
|
|
|
void changeItens(struct menu *);
|
2009-08-12 17:00:51 +02:00
|
|
|
void setMenuLink(struct menu *);
|
|
|
|
void listFocusChanged(void);
|
|
|
|
void goBack(void);
|
|
|
|
void loadConfig(void);
|
2014-04-11 20:24:06 +02:00
|
|
|
bool saveConfig(void);
|
2009-08-12 17:00:51 +02:00
|
|
|
void saveConfigAs(void);
|
|
|
|
void searchConfig(void);
|
|
|
|
void showSingleView(void);
|
|
|
|
void showSplitView(void);
|
|
|
|
void showFullView(void);
|
|
|
|
void showIntro(void);
|
|
|
|
void showAbout(void);
|
|
|
|
void saveSettings(void);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *e);
|
|
|
|
|
|
|
|
ConfigSearchWindow *searchWindow;
|
|
|
|
ConfigList *menuList;
|
|
|
|
ConfigList *configList;
|
|
|
|
ConfigInfoView *helpText;
|
2016-01-22 11:54:22 +01:00
|
|
|
QAction *backAction;
|
|
|
|
QAction *singleViewAction;
|
|
|
|
QAction *splitViewAction;
|
|
|
|
QAction *fullViewAction;
|
|
|
|
QSplitter *split1;
|
|
|
|
QSplitter *split2;
|
2009-08-12 17:00:51 +02:00
|
|
|
};
|