2018-12-18 12:13:35 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
|
|
|
|
*/
|
|
|
|
|
2020-06-30 06:26:35 +00:00
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QDialog>
|
2015-09-22 18:36:15 +00:00
|
|
|
#include <QHeaderView>
|
2020-06-30 06:26:35 +00:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QMainWindow>
|
2015-09-22 18:36:15 +00:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QSplitter>
|
2020-06-30 06:26:35 +00:00
|
|
|
#include <QTextBrowser>
|
|
|
|
#include <QTreeWidget>
|
|
|
|
|
2015-09-22 18:36:15 +00:00
|
|
|
#include "expr.h"
|
2010-08-31 15:34:37 +00:00
|
|
|
|
2006-06-09 05:12:46 +00:00
|
|
|
class ConfigView;
|
2015-09-22 18:36:17 +00:00
|
|
|
class ConfigList;
|
|
|
|
class ConfigItem;
|
2005-04-16 22:20:36 +00:00
|
|
|
class ConfigLineEdit;
|
|
|
|
class ConfigMainWindow;
|
|
|
|
|
|
|
|
class ConfigSettings : public QSettings {
|
|
|
|
public:
|
2013-10-06 18:21:31 +00:00
|
|
|
ConfigSettings();
|
2015-09-22 18:36:05 +00:00
|
|
|
QList<int> readSizes(const QString& key, bool *ok);
|
|
|
|
bool writeSizes(const QString& key, const QList<int>& value);
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum colIdx {
|
|
|
|
promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
|
|
|
|
};
|
|
|
|
enum listMode {
|
2006-06-09 05:12:45 +00:00
|
|
|
singleMode, menuMode, symbolMode, fullMode, listMode
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
2010-05-10 08:33:41 +00:00
|
|
|
enum optionMode {
|
|
|
|
normalOpt = 0, allOpt, promptOpt
|
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-09-22 18:36:17 +00:00
|
|
|
class ConfigList : public QTreeWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
typedef class QTreeWidget Parent;
|
|
|
|
public:
|
|
|
|
ConfigList(ConfigView* p, const char *name = 0);
|
2015-09-22 18:36:18 +00:00
|
|
|
void reinit(void);
|
2020-06-30 06:26:38 +00:00
|
|
|
ConfigItem* findConfigItem(struct menu *);
|
2015-09-22 18:36:18 +00:00
|
|
|
ConfigView* parent(void) const
|
|
|
|
{
|
|
|
|
return (ConfigView*)Parent::parent();
|
|
|
|
}
|
2020-06-30 06:26:38 +00:00
|
|
|
void setSelected(QTreeWidgetItem *item, bool enable) {
|
|
|
|
for (int i = 0; i < selectedItems().size(); i++)
|
|
|
|
selectedItems().at(i)->setSelected(false);
|
|
|
|
|
|
|
|
item->setSelected(enable);
|
|
|
|
}
|
2015-09-22 18:36:18 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void keyPressEvent(QKeyEvent *e);
|
2015-09-22 18:36:19 +00:00
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *e);
|
2015-09-22 18:36:18 +00:00
|
|
|
void focusInEvent(QFocusEvent *e);
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setRootMenu(struct menu *menu);
|
|
|
|
|
|
|
|
void updateList(ConfigItem *item);
|
|
|
|
void setValue(ConfigItem* item, tristate val);
|
|
|
|
void changeValue(ConfigItem* item);
|
|
|
|
void updateSelection(void);
|
|
|
|
void saveSettings(void);
|
|
|
|
signals:
|
|
|
|
void menuChanged(struct menu *menu);
|
|
|
|
void menuSelected(struct menu *menu);
|
2020-04-02 09:28:01 +00:00
|
|
|
void itemSelected(struct menu *menu);
|
2015-09-22 18:36:18 +00:00
|
|
|
void parentSelected(void);
|
|
|
|
void gotFocus(struct menu *);
|
|
|
|
|
|
|
|
public:
|
|
|
|
void updateListAll(void)
|
|
|
|
{
|
|
|
|
updateAll = true;
|
|
|
|
updateList(NULL);
|
|
|
|
updateAll = false;
|
|
|
|
}
|
2015-09-22 18:36:19 +00:00
|
|
|
void addColumn(colIdx idx)
|
2015-09-22 18:36:18 +00:00
|
|
|
{
|
2015-09-22 18:36:19 +00:00
|
|
|
showColumn(idx);
|
2015-09-22 18:36:18 +00:00
|
|
|
}
|
|
|
|
void removeColumn(colIdx idx)
|
|
|
|
{
|
2015-09-22 18:36:19 +00:00
|
|
|
hideColumn(idx);
|
2015-09-22 18:36:18 +00:00
|
|
|
}
|
|
|
|
void setAllOpen(bool open);
|
|
|
|
void setParentMenu(void);
|
|
|
|
|
|
|
|
bool menuSkip(struct menu *);
|
|
|
|
|
2015-09-22 18:36:27 +00:00
|
|
|
void updateMenuList(ConfigItem *parent, struct menu*);
|
|
|
|
void updateMenuList(ConfigList *parent, struct menu*);
|
2015-09-22 18:36:18 +00:00
|
|
|
|
|
|
|
bool updateAll;
|
|
|
|
|
|
|
|
QPixmap symbolYesPix, symbolModPix, symbolNoPix;
|
|
|
|
QPixmap choiceYesPix, choiceNoPix;
|
|
|
|
QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
|
|
|
|
|
|
|
|
bool showName, showRange, showData;
|
|
|
|
enum listMode mode;
|
|
|
|
enum optionMode optMode;
|
|
|
|
struct menu *rootEntry;
|
|
|
|
QPalette disabledColorGroup;
|
|
|
|
QPalette inactivedColorGroup;
|
|
|
|
QMenu* headerPopup;
|
2015-09-22 18:36:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ConfigItem : public QTreeWidgetItem {
|
|
|
|
typedef class QTreeWidgetItem Parent;
|
|
|
|
public:
|
2015-09-22 18:36:30 +00:00
|
|
|
ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
|
2015-09-22 18:36:25 +00:00
|
|
|
: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
|
2015-09-22 18:36:17 +00:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
|
2015-09-22 18:36:25 +00:00
|
|
|
: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
|
2015-09-22 18:36:17 +00:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
2015-09-22 18:36:30 +00:00
|
|
|
ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
|
2015-09-22 18:36:25 +00:00
|
|
|
: Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
|
2015-09-22 18:36:17 +00:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
~ConfigItem(void);
|
|
|
|
void init(void);
|
2015-09-22 18:36:18 +00:00
|
|
|
void okRename(int col);
|
|
|
|
void updateMenu(void);
|
|
|
|
void testUpdateMenu(bool v);
|
|
|
|
ConfigList* listView() const
|
|
|
|
{
|
|
|
|
return (ConfigList*)Parent::treeWidget();
|
|
|
|
}
|
|
|
|
ConfigItem* firstChild() const
|
|
|
|
{
|
|
|
|
return (ConfigItem *)Parent::child(0);
|
|
|
|
}
|
2015-09-22 18:36:19 +00:00
|
|
|
ConfigItem* nextSibling()
|
2015-09-22 18:36:18 +00:00
|
|
|
{
|
2015-09-22 18:36:19 +00:00
|
|
|
ConfigItem *ret = NULL;
|
|
|
|
ConfigItem *_parent = (ConfigItem *)parent();
|
|
|
|
|
|
|
|
if(_parent) {
|
2015-09-22 18:36:32 +00:00
|
|
|
ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1);
|
2015-09-22 18:36:19 +00:00
|
|
|
} else {
|
2015-09-22 18:36:32 +00:00
|
|
|
QTreeWidget *_treeWidget = treeWidget();
|
|
|
|
ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1);
|
2015-09-22 18:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2015-09-22 18:36:18 +00:00
|
|
|
}
|
|
|
|
void setText(colIdx idx, const QString& text)
|
|
|
|
{
|
|
|
|
Parent::setText(idx, text);
|
|
|
|
}
|
|
|
|
QString text(colIdx idx) const
|
|
|
|
{
|
|
|
|
return Parent::text(idx);
|
|
|
|
}
|
2015-09-22 18:36:19 +00:00
|
|
|
void setPixmap(colIdx idx, const QIcon &icon)
|
2015-09-22 18:36:18 +00:00
|
|
|
{
|
2015-09-22 18:36:19 +00:00
|
|
|
Parent::setIcon(idx, icon);
|
2015-09-22 18:36:18 +00:00
|
|
|
}
|
2015-09-22 18:36:19 +00:00
|
|
|
const QIcon pixmap(colIdx idx) const
|
2015-09-22 18:36:18 +00:00
|
|
|
{
|
2015-09-22 18:36:19 +00:00
|
|
|
return icon(idx);
|
2015-09-22 18:36:18 +00:00
|
|
|
}
|
2015-09-22 18:36:19 +00:00
|
|
|
// TODO: Implement paintCell
|
2015-09-22 18:36:17 +00:00
|
|
|
|
|
|
|
ConfigItem* nextItem;
|
|
|
|
struct menu *menu;
|
|
|
|
bool visible;
|
|
|
|
bool goParent;
|
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
class ConfigLineEdit : public QLineEdit {
|
|
|
|
Q_OBJECT
|
|
|
|
typedef class QLineEdit Parent;
|
|
|
|
public:
|
2006-06-09 05:12:45 +00:00
|
|
|
ConfigLineEdit(ConfigView* parent);
|
2005-04-16 22:20:36 +00:00
|
|
|
ConfigView* parent(void) const
|
|
|
|
{
|
|
|
|
return (ConfigView*)Parent::parent();
|
|
|
|
}
|
2015-09-22 18:36:17 +00:00
|
|
|
void show(ConfigItem *i);
|
2005-04-16 22:20:36 +00:00
|
|
|
void keyPressEvent(QKeyEvent *e);
|
|
|
|
|
|
|
|
public:
|
2015-09-22 18:36:17 +00:00
|
|
|
ConfigItem *item;
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2015-09-22 18:36:09 +00:00
|
|
|
class ConfigView : public QWidget {
|
2006-06-09 05:12:46 +00:00
|
|
|
Q_OBJECT
|
2015-09-22 18:36:09 +00:00
|
|
|
typedef class QWidget Parent;
|
2006-06-09 05:12:46 +00:00
|
|
|
public:
|
|
|
|
ConfigView(QWidget* parent, const char *name = 0);
|
|
|
|
~ConfigView(void);
|
2015-09-22 18:36:17 +00:00
|
|
|
static void updateList(ConfigItem* item);
|
2006-06-09 05:12:46 +00:00
|
|
|
static void updateListAll(void);
|
|
|
|
|
2015-09-22 18:36:18 +00:00
|
|
|
bool showName(void) const { return list->showName; }
|
|
|
|
bool showRange(void) const { return list->showRange; }
|
|
|
|
bool showData(void) const { return list->showData; }
|
2006-06-09 05:12:46 +00:00
|
|
|
public slots:
|
|
|
|
void setShowName(bool);
|
|
|
|
void setShowRange(bool);
|
|
|
|
void setShowData(bool);
|
2010-05-10 08:33:41 +00:00
|
|
|
void setOptionMode(QAction *);
|
2006-06-09 05:12:46 +00:00
|
|
|
signals:
|
|
|
|
void showNameChanged(bool);
|
|
|
|
void showRangeChanged(bool);
|
|
|
|
void showDataChanged(bool);
|
|
|
|
public:
|
2015-09-22 18:36:17 +00:00
|
|
|
ConfigList* list;
|
2006-06-09 05:12:46 +00:00
|
|
|
ConfigLineEdit* lineEdit;
|
|
|
|
|
|
|
|
static ConfigView* viewList;
|
|
|
|
ConfigView* nextView;
|
2010-05-10 08:33:41 +00:00
|
|
|
|
|
|
|
static QAction *showNormalAction;
|
|
|
|
static QAction *showAllAction;
|
|
|
|
static QAction *showPromptAction;
|
2006-06-09 05:12:46 +00:00
|
|
|
};
|
|
|
|
|
2015-09-22 18:36:06 +00:00
|
|
|
class ConfigInfoView : public QTextBrowser {
|
2006-06-09 05:12:45 +00:00
|
|
|
Q_OBJECT
|
2015-09-22 18:36:06 +00:00
|
|
|
typedef class QTextBrowser Parent;
|
2006-06-09 05:12:45 +00:00
|
|
|
public:
|
|
|
|
ConfigInfoView(QWidget* parent, const char *name = 0);
|
|
|
|
bool showDebug(void) const { return _showDebug; }
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setInfo(struct menu *menu);
|
2006-06-09 05:12:46 +00:00
|
|
|
void saveSettings(void);
|
2006-06-09 05:12:45 +00:00
|
|
|
void setShowDebug(bool);
|
2020-06-30 06:26:37 +00:00
|
|
|
void clicked (const QUrl &url);
|
2006-06-09 05:12:45 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void showDebugChanged(bool);
|
2006-06-09 05:12:47 +00:00
|
|
|
void menuSelected(struct menu *);
|
2006-06-09 05:12:45 +00:00
|
|
|
|
|
|
|
protected:
|
2006-06-09 05:12:47 +00:00
|
|
|
void symbolInfo(void);
|
2006-06-09 05:12:45 +00:00
|
|
|
void menuInfo(void);
|
|
|
|
QString debug_info(struct symbol *sym);
|
|
|
|
static QString print_filter(const QString &str);
|
2006-06-09 05:12:47 +00:00
|
|
|
static void expr_print_help(void *data, struct symbol *sym, const char *str);
|
2015-09-22 18:36:06 +00:00
|
|
|
QMenu *createStandardContextMenu(const QPoint & pos);
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e);
|
2006-06-09 05:12:45 +00:00
|
|
|
|
2006-06-09 05:12:47 +00:00
|
|
|
struct symbol *sym;
|
2010-08-31 15:34:37 +00:00
|
|
|
struct menu *_menu;
|
2006-06-09 05:12:45 +00:00
|
|
|
bool _showDebug;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ConfigSearchWindow : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
typedef class QDialog Parent;
|
|
|
|
public:
|
2006-10-05 17:12:59 +00:00
|
|
|
ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0);
|
2006-06-09 05:12:46 +00:00
|
|
|
|
2006-06-09 05:12:45 +00:00
|
|
|
public slots:
|
2006-06-09 05:12:46 +00:00
|
|
|
void saveSettings(void);
|
2006-06-09 05:12:45 +00:00
|
|
|
void search(void);
|
2006-06-09 05:12:46 +00:00
|
|
|
|
2006-06-09 05:12:45 +00:00
|
|
|
protected:
|
|
|
|
QLineEdit* editField;
|
|
|
|
QPushButton* searchButton;
|
2006-06-09 05:12:46 +00:00
|
|
|
QSplitter* split;
|
2006-06-09 05:12:45 +00:00
|
|
|
ConfigView* list;
|
|
|
|
ConfigInfoView* info;
|
|
|
|
|
|
|
|
struct symbol **result;
|
|
|
|
};
|
|
|
|
|
2015-09-22 18:36:02 +00:00
|
|
|
class ConfigMainWindow : public QMainWindow {
|
2005-04-16 22:20:36 +00:00
|
|
|
Q_OBJECT
|
2006-12-13 08:34:08 +00:00
|
|
|
|
2019-03-10 16:13:15 +00:00
|
|
|
char *configname;
|
2015-09-22 18:36:03 +00:00
|
|
|
static QAction *saveAction;
|
2006-12-13 08:34:08 +00:00
|
|
|
static void conf_changed(void);
|
2005-04-16 22:20:36 +00:00
|
|
|
public:
|
|
|
|
ConfigMainWindow(void);
|
|
|
|
public slots:
|
|
|
|
void changeMenu(struct menu *);
|
2020-04-02 09:28:01 +00:00
|
|
|
void changeItens(struct menu *);
|
2006-06-09 05:12:47 +00:00
|
|
|
void setMenuLink(struct menu *);
|
2005-04-16 22:20:36 +00:00
|
|
|
void listFocusChanged(void);
|
|
|
|
void goBack(void);
|
|
|
|
void loadConfig(void);
|
2011-05-25 13:10:25 +00:00
|
|
|
bool saveConfig(void);
|
2005-04-16 22:20:36 +00:00
|
|
|
void saveConfigAs(void);
|
2006-06-09 05:12:45 +00:00
|
|
|
void searchConfig(void);
|
2005-04-16 22:20:36 +00:00
|
|
|
void showSingleView(void);
|
|
|
|
void showSplitView(void);
|
|
|
|
void showFullView(void);
|
|
|
|
void showIntro(void);
|
|
|
|
void showAbout(void);
|
|
|
|
void saveSettings(void);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *e);
|
|
|
|
|
2006-06-09 05:12:45 +00:00
|
|
|
ConfigSearchWindow *searchWindow;
|
2005-04-16 22:20:36 +00:00
|
|
|
ConfigView *menuView;
|
2015-09-22 18:36:17 +00:00
|
|
|
ConfigList *menuList;
|
2005-04-16 22:20:36 +00:00
|
|
|
ConfigView *configView;
|
2015-09-22 18:36:17 +00:00
|
|
|
ConfigList *configList;
|
2006-06-09 05:12:45 +00:00
|
|
|
ConfigInfoView *helpText;
|
2015-09-22 18:36:03 +00:00
|
|
|
QAction *backAction;
|
2015-09-22 18:36:13 +00:00
|
|
|
QAction *singleViewAction;
|
|
|
|
QAction *splitViewAction;
|
|
|
|
QAction *fullViewAction;
|
2015-09-22 18:36:14 +00:00
|
|
|
QSplitter *split1;
|
|
|
|
QSplitter *split2;
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|