2007-06-28 12:46:19 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
|
|
|
|
* Released under the terms of the GNU GPL v2.0.
|
|
|
|
*/
|
|
|
|
|
2018-09-19 13:36:15 +02:00
|
|
|
#include <QTextBrowser>
|
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QHeaderView>
|
2011-02-02 11:48:58 +01:00
|
|
|
#include <qsettings.h>
|
2018-09-19 13:36:15 +02:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QSplitter>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QDialog>
|
|
|
|
#include "expr.h"
|
2007-06-28 12:46:19 +02:00
|
|
|
|
|
|
|
class ConfigView;
|
|
|
|
class ConfigList;
|
|
|
|
class ConfigItem;
|
|
|
|
class ConfigLineEdit;
|
|
|
|
class ConfigMainWindow;
|
|
|
|
|
|
|
|
class ConfigSettings : public QSettings {
|
|
|
|
public:
|
2013-12-27 22:18:28 +01:00
|
|
|
ConfigSettings();
|
2018-09-19 13:36:15 +02:00
|
|
|
QList<int> readSizes(const QString& key, bool *ok);
|
|
|
|
bool writeSizes(const QString& key, const QList<int>& value);
|
2007-06-28 12:46:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum colIdx {
|
|
|
|
promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
|
|
|
|
};
|
|
|
|
enum listMode {
|
|
|
|
singleMode, menuMode, symbolMode, fullMode, listMode
|
|
|
|
};
|
2010-08-21 17:00:49 +02:00
|
|
|
enum optionMode {
|
|
|
|
normalOpt = 0, allOpt, promptOpt
|
|
|
|
};
|
2007-06-28 12:46:19 +02:00
|
|
|
|
2018-09-19 13:36:15 +02:00
|
|
|
class ConfigList : public QTreeWidget {
|
2007-06-28 12:46:19 +02:00
|
|
|
Q_OBJECT
|
2018-09-19 13:36:15 +02:00
|
|
|
typedef class QTreeWidget Parent;
|
2007-06-28 12:46:19 +02:00
|
|
|
public:
|
|
|
|
ConfigList(ConfigView* p, const char *name = 0);
|
|
|
|
void reinit(void);
|
|
|
|
ConfigView* parent(void) const
|
|
|
|
{
|
|
|
|
return (ConfigView*)Parent::parent();
|
|
|
|
}
|
|
|
|
ConfigItem* findConfigItem(struct menu *);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void keyPressEvent(QKeyEvent *e);
|
2018-09-19 13:36:15 +02:00
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *e);
|
2007-06-28 12:46:19 +02: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);
|
|
|
|
void parentSelected(void);
|
|
|
|
void gotFocus(struct menu *);
|
|
|
|
|
|
|
|
public:
|
|
|
|
void updateListAll(void)
|
|
|
|
{
|
|
|
|
updateAll = true;
|
|
|
|
updateList(NULL);
|
|
|
|
updateAll = false;
|
|
|
|
}
|
|
|
|
ConfigList* listView()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
ConfigItem* firstChild() const
|
|
|
|
{
|
2018-09-19 13:36:15 +02:00
|
|
|
return (ConfigItem *)children().first();
|
2007-06-28 12:46:19 +02:00
|
|
|
}
|
2018-09-19 13:36:15 +02:00
|
|
|
void addColumn(colIdx idx)
|
2007-06-28 12:46:19 +02:00
|
|
|
{
|
2018-09-19 13:36:15 +02:00
|
|
|
showColumn(idx);
|
2007-06-28 12:46:19 +02:00
|
|
|
}
|
|
|
|
void removeColumn(colIdx idx)
|
|
|
|
{
|
2018-09-19 13:36:15 +02:00
|
|
|
hideColumn(idx);
|
2007-06-28 12:46:19 +02:00
|
|
|
}
|
|
|
|
void setAllOpen(bool open);
|
|
|
|
void setParentMenu(void);
|
|
|
|
|
2010-08-21 17:00:49 +02:00
|
|
|
bool menuSkip(struct menu *);
|
|
|
|
|
2018-09-19 13:36:15 +02:00
|
|
|
void updateMenuList(ConfigItem *parent, struct menu*);
|
|
|
|
void updateMenuList(ConfigList *parent, struct menu*);
|
2007-06-28 12:46:19 +02:00
|
|
|
|
|
|
|
bool updateAll;
|
|
|
|
|
|
|
|
QPixmap symbolYesPix, symbolModPix, symbolNoPix;
|
|
|
|
QPixmap choiceYesPix, choiceNoPix;
|
|
|
|
QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
|
|
|
|
|
2010-08-21 17:00:49 +02:00
|
|
|
bool showName, showRange, showData;
|
2007-06-28 12:46:19 +02:00
|
|
|
enum listMode mode;
|
2010-08-21 17:00:49 +02:00
|
|
|
enum optionMode optMode;
|
2007-06-28 12:46:19 +02:00
|
|
|
struct menu *rootEntry;
|
2018-09-19 13:36:15 +02:00
|
|
|
QPalette disabledColorGroup;
|
|
|
|
QPalette inactivedColorGroup;
|
|
|
|
QMenu* headerPopup;
|
2007-06-28 12:46:19 +02:00
|
|
|
};
|
|
|
|
|
2018-09-19 13:36:15 +02:00
|
|
|
class ConfigItem : public QTreeWidgetItem {
|
|
|
|
typedef class QTreeWidgetItem Parent;
|
2007-06-28 12:46:19 +02:00
|
|
|
public:
|
2018-09-19 13:36:15 +02:00
|
|
|
ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
|
|
|
|
: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
|
2007-06-28 12:46:19 +02:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
|
2018-09-19 13:36:15 +02:00
|
|
|
: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
|
2007-06-28 12:46:19 +02:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
2018-09-19 13:36:15 +02:00
|
|
|
ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
|
|
|
|
: Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
|
2007-06-28 12:46:19 +02:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
~ConfigItem(void);
|
|
|
|
void init(void);
|
|
|
|
void okRename(int col);
|
|
|
|
void updateMenu(void);
|
|
|
|
void testUpdateMenu(bool v);
|
|
|
|
ConfigList* listView() const
|
|
|
|
{
|
2018-09-19 13:36:15 +02:00
|
|
|
return (ConfigList*)Parent::treeWidget();
|
2007-06-28 12:46:19 +02:00
|
|
|
}
|
|
|
|
ConfigItem* firstChild() const
|
|
|
|
{
|
2018-09-19 13:36:15 +02:00
|
|
|
return (ConfigItem *)Parent::child(0);
|
2007-06-28 12:46:19 +02:00
|
|
|
}
|
2018-09-19 13:36:15 +02:00
|
|
|
ConfigItem* nextSibling()
|
2007-06-28 12:46:19 +02:00
|
|
|
{
|
2018-09-19 13:36:15 +02: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;
|
2007-06-28 12:46:19 +02:00
|
|
|
}
|
|
|
|
void setText(colIdx idx, const QString& text)
|
|
|
|
{
|
2018-09-19 13:36:15 +02:00
|
|
|
Parent::setText(idx, text);
|
2007-06-28 12:46:19 +02:00
|
|
|
}
|
|
|
|
QString text(colIdx idx) const
|
|
|
|
{
|
2018-09-19 13:36:15 +02:00
|
|
|
return Parent::text(idx);
|
2007-06-28 12:46:19 +02:00
|
|
|
}
|
2018-09-19 13:36:15 +02:00
|
|
|
void setPixmap(colIdx idx, const QIcon &icon)
|
2007-06-28 12:46:19 +02:00
|
|
|
{
|
2018-09-19 13:36:15 +02:00
|
|
|
Parent::setIcon(idx, icon);
|
2007-06-28 12:46:19 +02:00
|
|
|
}
|
2018-09-19 13:36:15 +02:00
|
|
|
const QIcon pixmap(colIdx idx) const
|
2007-06-28 12:46:19 +02:00
|
|
|
{
|
2018-09-19 13:36:15 +02:00
|
|
|
return icon(idx);
|
2007-06-28 12:46:19 +02:00
|
|
|
}
|
2018-09-19 13:36:15 +02:00
|
|
|
// TODO: Implement paintCell
|
2007-06-28 12:46:19 +02:00
|
|
|
|
|
|
|
ConfigItem* nextItem;
|
|
|
|
struct menu *menu;
|
|
|
|
bool visible;
|
|
|
|
bool goParent;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ConfigLineEdit : public QLineEdit {
|
|
|
|
Q_OBJECT
|
|
|
|
typedef class QLineEdit Parent;
|
|
|
|
public:
|
|
|
|
ConfigLineEdit(ConfigView* parent);
|
|
|
|
ConfigView* parent(void) const
|
|
|
|
{
|
|
|
|
return (ConfigView*)Parent::parent();
|
|
|
|
}
|
|
|
|
void show(ConfigItem *i);
|
|
|
|
void keyPressEvent(QKeyEvent *e);
|
|
|
|
|
|
|
|
public:
|
|
|
|
ConfigItem *item;
|
|
|
|
};
|
|
|
|
|
2018-09-19 13:36:15 +02:00
|
|
|
class ConfigView : public QWidget {
|
2007-06-28 12:46:19 +02:00
|
|
|
Q_OBJECT
|
2018-09-19 13:36:15 +02:00
|
|
|
typedef class QWidget Parent;
|
2007-06-28 12:46:19 +02:00
|
|
|
public:
|
|
|
|
ConfigView(QWidget* parent, const char *name = 0);
|
|
|
|
~ConfigView(void);
|
|
|
|
static void updateList(ConfigItem* item);
|
|
|
|
static void updateListAll(void);
|
|
|
|
|
|
|
|
bool showName(void) const { return list->showName; }
|
|
|
|
bool showRange(void) const { return list->showRange; }
|
|
|
|
bool showData(void) const { return list->showData; }
|
|
|
|
public slots:
|
|
|
|
void setShowName(bool);
|
|
|
|
void setShowRange(bool);
|
|
|
|
void setShowData(bool);
|
2010-08-21 17:00:49 +02:00
|
|
|
void setOptionMode(QAction *);
|
2007-06-28 12:46:19 +02:00
|
|
|
signals:
|
|
|
|
void showNameChanged(bool);
|
|
|
|
void showRangeChanged(bool);
|
|
|
|
void showDataChanged(bool);
|
|
|
|
public:
|
|
|
|
ConfigList* list;
|
|
|
|
ConfigLineEdit* lineEdit;
|
|
|
|
|
|
|
|
static ConfigView* viewList;
|
|
|
|
ConfigView* nextView;
|
2010-08-21 17:00:49 +02:00
|
|
|
|
|
|
|
static QAction *showNormalAction;
|
|
|
|
static QAction *showAllAction;
|
|
|
|
static QAction *showPromptAction;
|
2007-06-28 12:46:19 +02:00
|
|
|
};
|
|
|
|
|
2018-09-19 13:36:15 +02:00
|
|
|
class ConfigInfoView : public QTextBrowser {
|
2007-06-28 12:46:19 +02:00
|
|
|
Q_OBJECT
|
2018-09-19 13:36:15 +02:00
|
|
|
typedef class QTextBrowser Parent;
|
2007-06-28 12:46:19 +02:00
|
|
|
public:
|
|
|
|
ConfigInfoView(QWidget* parent, const char *name = 0);
|
|
|
|
bool showDebug(void) const { return _showDebug; }
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setInfo(struct menu *menu);
|
|
|
|
void saveSettings(void);
|
|
|
|
void setShowDebug(bool);
|
|
|
|
|
|
|
|
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);
|
2018-09-19 13:36:15 +02:00
|
|
|
QMenu *createStandardContextMenu(const QPoint & pos);
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e);
|
2007-06-28 12:46:19 +02:00
|
|
|
|
|
|
|
struct symbol *sym;
|
2011-02-02 11:48:58 +01:00
|
|
|
struct menu *_menu;
|
2007-06-28 12:46:19 +02:00
|
|
|
bool _showDebug;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ConfigSearchWindow : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
typedef class QDialog Parent;
|
|
|
|
public:
|
2007-09-23 16:06:59 +02:00
|
|
|
ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0);
|
2007-06-28 12:46:19 +02:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void saveSettings(void);
|
|
|
|
void search(void);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QLineEdit* editField;
|
|
|
|
QPushButton* searchButton;
|
|
|
|
QSplitter* split;
|
|
|
|
ConfigView* list;
|
|
|
|
ConfigInfoView* info;
|
|
|
|
|
|
|
|
struct symbol **result;
|
|
|
|
};
|
|
|
|
|
2018-09-19 13:36:15 +02:00
|
|
|
class ConfigMainWindow : public QMainWindow {
|
2007-06-28 12:46:19 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2018-09-19 13:36:15 +02:00
|
|
|
static QAction *saveAction;
|
2007-06-28 12:46:19 +02:00
|
|
|
static void conf_changed(void);
|
|
|
|
public:
|
|
|
|
ConfigMainWindow(void);
|
|
|
|
public slots:
|
|
|
|
void changeMenu(struct menu *);
|
|
|
|
void setMenuLink(struct menu *);
|
|
|
|
void listFocusChanged(void);
|
|
|
|
void goBack(void);
|
|
|
|
void loadConfig(void);
|
2013-04-04 13:24:24 +02:00
|
|
|
bool saveConfig(void);
|
2007-06-28 12:46:19 +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;
|
|
|
|
ConfigView *menuView;
|
|
|
|
ConfigList *menuList;
|
|
|
|
ConfigView *configView;
|
|
|
|
ConfigList *configList;
|
|
|
|
ConfigInfoView *helpText;
|
2018-09-19 13:36:15 +02:00
|
|
|
QToolBar *toolBar;
|
|
|
|
QAction *backAction;
|
|
|
|
QAction *singleViewAction;
|
|
|
|
QAction *splitViewAction;
|
|
|
|
QAction *fullViewAction;
|
|
|
|
QSplitter *split1;
|
|
|
|
QSplitter *split2;
|
2007-06-28 12:46:19 +02:00
|
|
|
};
|