blob: 1cd02192f1724531146f4541e0e608ec1ee2e0e0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -07006#include <QTextBrowser>
7#include <QTreeWidget>
Boris Barbulovskib1f8a452015-09-22 11:36:02 -07008#include <QMainWindow>
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -07009#include <QHeaderView>
Alexander Stein133c5f72010-08-31 17:34:37 +020010#include <qsettings.h>
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -070011#include <QPushButton>
12#include <QSettings>
13#include <QLineEdit>
14#include <QSplitter>
15#include <QCheckBox>
16#include <QDialog>
17#include "expr.h"
Alexander Stein133c5f72010-08-31 17:34:37 +020018
Roman Zippel7fc925f2006-06-08 22:12:46 -070019class ConfigView;
Linus Torvalds1da177e2005-04-16 15:20:36 -070020class ConfigLineEdit;
21class ConfigMainWindow;
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023class ConfigSettings : public QSettings {
24public:
Ben Hutchings00d4f8f2013-10-06 19:21:31 +010025 ConfigSettings();
Boris Barbulovski041fbdc2015-09-22 11:36:05 -070026 QList<int> readSizes(const QString& key, bool *ok);
27 bool writeSizes(const QString& key, const QList<int>& value);
Linus Torvalds1da177e2005-04-16 15:20:36 -070028};
29
30enum colIdx {
31 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
32};
33enum listMode {
Roman Zippel43bf6122006-06-08 22:12:45 -070034 singleMode, menuMode, symbolMode, fullMode, listMode
Linus Torvalds1da177e2005-04-16 15:20:36 -070035};
Li Zefan39a48972010-05-10 16:33:41 +080036enum optionMode {
37 normalOpt = 0, allOpt, promptOpt
38};
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Linus Torvalds1da177e2005-04-16 15:20:36 -070040class ConfigLineEdit : public QLineEdit {
41 Q_OBJECT
42 typedef class QLineEdit Parent;
43public:
Roman Zippel43bf6122006-06-08 22:12:45 -070044 ConfigLineEdit(ConfigView* parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 ConfigView* parent(void) const
46 {
47 return (ConfigView*)Parent::parent();
48 }
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -070049 void show(QTreeWidgetItem *i);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 void keyPressEvent(QKeyEvent *e);
51
52public:
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -070053 QTreeWidgetItem *item;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054};
55
Boris Barbulovski34d63202015-09-22 11:36:09 -070056class ConfigView : public QWidget {
Roman Zippel7fc925f2006-06-08 22:12:46 -070057 Q_OBJECT
Boris Barbulovski34d63202015-09-22 11:36:09 -070058 typedef class QWidget Parent;
Roman Zippel7fc925f2006-06-08 22:12:46 -070059public:
60 ConfigView(QWidget* parent, const char *name = 0);
61 ~ConfigView(void);
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -070062 static void updateList(QTreeWidgetItem* item);
Roman Zippel7fc925f2006-06-08 22:12:46 -070063 static void updateListAll(void);
64
Boris Barbulovski76538662015-09-22 11:36:14 -070065 bool showName(void) const { return false; } // TODO: Implement me.
66 bool showRange(void) const { return false; } // TODO: Implement me.
67 bool showData(void) const { return false; } // TODO: Implement me.
Roman Zippel7fc925f2006-06-08 22:12:46 -070068public slots:
Roman Zippel7fc925f2006-06-08 22:12:46 -070069 void setShowName(bool);
70 void setShowRange(bool);
71 void setShowData(bool);
Li Zefan39a48972010-05-10 16:33:41 +080072 void setOptionMode(QAction *);
Roman Zippel7fc925f2006-06-08 22:12:46 -070073signals:
Roman Zippel7fc925f2006-06-08 22:12:46 -070074 void showNameChanged(bool);
75 void showRangeChanged(bool);
76 void showDataChanged(bool);
77public:
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -070078 QTreeWidget* list;
Roman Zippel7fc925f2006-06-08 22:12:46 -070079 ConfigLineEdit* lineEdit;
80
81 static ConfigView* viewList;
82 ConfigView* nextView;
Li Zefan39a48972010-05-10 16:33:41 +080083
84 static QAction *showNormalAction;
85 static QAction *showAllAction;
86 static QAction *showPromptAction;
Roman Zippel7fc925f2006-06-08 22:12:46 -070087};
88
Boris Barbulovski924bbb52015-09-22 11:36:06 -070089class ConfigInfoView : public QTextBrowser {
Roman Zippel43bf6122006-06-08 22:12:45 -070090 Q_OBJECT
Boris Barbulovski924bbb52015-09-22 11:36:06 -070091 typedef class QTextBrowser Parent;
Roman Zippel43bf6122006-06-08 22:12:45 -070092public:
93 ConfigInfoView(QWidget* parent, const char *name = 0);
94 bool showDebug(void) const { return _showDebug; }
95
96public slots:
97 void setInfo(struct menu *menu);
Roman Zippel7fc925f2006-06-08 22:12:46 -070098 void saveSettings(void);
Roman Zippel43bf6122006-06-08 22:12:45 -070099 void setShowDebug(bool);
100
101signals:
102 void showDebugChanged(bool);
Roman Zippelb65a47e2006-06-08 22:12:47 -0700103 void menuSelected(struct menu *);
Roman Zippel43bf6122006-06-08 22:12:45 -0700104
105protected:
Roman Zippelab45d192006-06-08 22:12:47 -0700106 void symbolInfo(void);
Roman Zippel43bf6122006-06-08 22:12:45 -0700107 void menuInfo(void);
108 QString debug_info(struct symbol *sym);
109 static QString print_filter(const QString &str);
Roman Zippelab45d192006-06-08 22:12:47 -0700110 static void expr_print_help(void *data, struct symbol *sym, const char *str);
Boris Barbulovski924bbb52015-09-22 11:36:06 -0700111 QMenu *createStandardContextMenu(const QPoint & pos);
112 void contextMenuEvent(QContextMenuEvent *e);
Roman Zippel43bf6122006-06-08 22:12:45 -0700113
Roman Zippelab45d192006-06-08 22:12:47 -0700114 struct symbol *sym;
Alexander Stein133c5f72010-08-31 17:34:37 +0200115 struct menu *_menu;
Roman Zippel43bf6122006-06-08 22:12:45 -0700116 bool _showDebug;
117};
118
119class ConfigSearchWindow : public QDialog {
120 Q_OBJECT
121 typedef class QDialog Parent;
122public:
Marco Costalba63431e72006-10-05 19:12:59 +0200123 ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0);
Roman Zippel7fc925f2006-06-08 22:12:46 -0700124
Roman Zippel43bf6122006-06-08 22:12:45 -0700125public slots:
Roman Zippel7fc925f2006-06-08 22:12:46 -0700126 void saveSettings(void);
Roman Zippel43bf6122006-06-08 22:12:45 -0700127 void search(void);
Roman Zippel7fc925f2006-06-08 22:12:46 -0700128
Roman Zippel43bf6122006-06-08 22:12:45 -0700129protected:
130 QLineEdit* editField;
131 QPushButton* searchButton;
Roman Zippel7fc925f2006-06-08 22:12:46 -0700132 QSplitter* split;
Roman Zippel43bf6122006-06-08 22:12:45 -0700133 ConfigView* list;
134 ConfigInfoView* info;
135
136 struct symbol **result;
137};
138
Boris Barbulovskib1f8a452015-09-22 11:36:02 -0700139class ConfigMainWindow : public QMainWindow {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 Q_OBJECT
Karsten Wiese3b354c552006-12-13 00:34:08 -0800141
Boris Barbulovski85eaf282015-09-22 11:36:03 -0700142 static QAction *saveAction;
Karsten Wiese3b354c552006-12-13 00:34:08 -0800143 static void conf_changed(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144public:
145 ConfigMainWindow(void);
146public slots:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 void changeMenu(struct menu *);
Roman Zippelb65a47e2006-06-08 22:12:47 -0700148 void setMenuLink(struct menu *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 void listFocusChanged(void);
150 void goBack(void);
151 void loadConfig(void);
Michal Marekbac6aa82011-05-25 15:10:25 +0200152 bool saveConfig(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 void saveConfigAs(void);
Roman Zippel43bf6122006-06-08 22:12:45 -0700154 void searchConfig(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 void showSingleView(void);
156 void showSplitView(void);
157 void showFullView(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 void showIntro(void);
159 void showAbout(void);
160 void saveSettings(void);
161
162protected:
163 void closeEvent(QCloseEvent *e);
164
Roman Zippel43bf6122006-06-08 22:12:45 -0700165 ConfigSearchWindow *searchWindow;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 ConfigView *menuView;
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -0700167 QTreeWidget *menuList;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 ConfigView *configView;
Boris Barbulovski68ccb7e2015-09-22 11:36:15 -0700169 QTreeWidget *configList;
Roman Zippel43bf6122006-06-08 22:12:45 -0700170 ConfigInfoView *helpText;
Boris Barbulovskib1f8a452015-09-22 11:36:02 -0700171 QToolBar *toolBar;
Boris Barbulovski85eaf282015-09-22 11:36:03 -0700172 QAction *backAction;
Boris Barbulovski780505e2015-09-22 11:36:13 -0700173 QAction *singleViewAction;
174 QAction *splitViewAction;
175 QAction *fullViewAction;
Boris Barbulovski76538662015-09-22 11:36:14 -0700176 QSplitter *split1;
177 QSplitter *split2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178};