]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | |
3 | * Released under the terms of the GNU GPL v2.0. | |
4 | */ | |
5 | ||
6 | #include <qlistview.h> | |
7 | #if QT_VERSION >= 300 | |
8 | #include <qsettings.h> | |
9 | #else | |
10 | class QSettings { }; | |
11 | #endif | |
12 | ||
13 | class ConfigList; | |
14 | class ConfigItem; | |
15 | class ConfigLineEdit; | |
16 | class ConfigMainWindow; | |
17 | ||
18 | ||
19 | class ConfigSettings : public QSettings { | |
20 | public: | |
21 | ConfigSettings(); | |
22 | ||
23 | #if QT_VERSION >= 300 | |
24 | void readListSettings(); | |
19144d0b DJ |
25 | QValueList<int> readSizes(const QString& key, bool *ok); |
26 | bool writeSizes(const QString& key, const QValueList<int>& value); | |
1da177e4 LT |
27 | #endif |
28 | ||
29 | bool showAll; | |
30 | bool showName; | |
31 | bool showRange; | |
32 | bool showData; | |
33 | }; | |
34 | ||
35 | class ConfigView : public QVBox { | |
36 | Q_OBJECT | |
37 | typedef class QVBox Parent; | |
38 | public: | |
43bf612a | 39 | ConfigView(QWidget* parent, ConfigSettings* configSettings); |
1da177e4 LT |
40 | ~ConfigView(void); |
41 | static void updateList(ConfigItem* item); | |
42 | static void updateListAll(void); | |
43 | ||
44 | public: | |
45 | ConfigList* list; | |
46 | ConfigLineEdit* lineEdit; | |
47 | ||
48 | static ConfigView* viewList; | |
49 | ConfigView* nextView; | |
50 | }; | |
51 | ||
52 | enum colIdx { | |
53 | promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr | |
54 | }; | |
55 | enum listMode { | |
43bf612a | 56 | singleMode, menuMode, symbolMode, fullMode, listMode |
1da177e4 LT |
57 | }; |
58 | ||
59 | class ConfigList : public QListView { | |
60 | Q_OBJECT | |
61 | typedef class QListView Parent; | |
62 | public: | |
43bf612a | 63 | ConfigList(ConfigView* p, ConfigSettings *configSettings); |
1da177e4 LT |
64 | void reinit(void); |
65 | ConfigView* parent(void) const | |
66 | { | |
67 | return (ConfigView*)Parent::parent(); | |
68 | } | |
69 | ||
70 | protected: | |
1da177e4 LT |
71 | void keyPressEvent(QKeyEvent *e); |
72 | void contentsMousePressEvent(QMouseEvent *e); | |
73 | void contentsMouseReleaseEvent(QMouseEvent *e); | |
74 | void contentsMouseMoveEvent(QMouseEvent *e); | |
75 | void contentsMouseDoubleClickEvent(QMouseEvent *e); | |
76 | void focusInEvent(QFocusEvent *e); | |
77 | public slots: | |
78 | void setRootMenu(struct menu *menu); | |
79 | ||
80 | void updateList(ConfigItem *item); | |
81 | void setValue(ConfigItem* item, tristate val); | |
82 | void changeValue(ConfigItem* item); | |
83 | void updateSelection(void); | |
84 | signals: | |
43bf612a | 85 | void menuChanged(struct menu *menu); |
1da177e4 LT |
86 | void menuSelected(struct menu *menu); |
87 | void parentSelected(void); | |
88 | void gotFocus(void); | |
89 | ||
90 | public: | |
91 | void updateListAll(void) | |
92 | { | |
93 | updateAll = true; | |
94 | updateList(NULL); | |
95 | updateAll = false; | |
96 | } | |
97 | ConfigList* listView() | |
98 | { | |
99 | return this; | |
100 | } | |
101 | ConfigItem* firstChild() const | |
102 | { | |
103 | return (ConfigItem *)Parent::firstChild(); | |
104 | } | |
105 | int mapIdx(colIdx idx) | |
106 | { | |
107 | return colMap[idx]; | |
108 | } | |
109 | void addColumn(colIdx idx, const QString& label) | |
110 | { | |
111 | colMap[idx] = Parent::addColumn(label); | |
112 | colRevMap[colMap[idx]] = idx; | |
113 | } | |
114 | void removeColumn(colIdx idx) | |
115 | { | |
116 | int col = colMap[idx]; | |
117 | if (col >= 0) { | |
118 | Parent::removeColumn(col); | |
119 | colRevMap[col] = colMap[idx] = -1; | |
120 | } | |
121 | } | |
122 | void setAllOpen(bool open); | |
123 | void setParentMenu(void); | |
124 | ||
125 | template <class P> | |
19144d0b | 126 | void updateMenuList(P*, struct menu*); |
1da177e4 LT |
127 | |
128 | bool updateAll; | |
129 | ||
130 | QPixmap symbolYesPix, symbolModPix, symbolNoPix; | |
131 | QPixmap choiceYesPix, choiceNoPix; | |
132 | QPixmap menuPix, menuInvPix, menuBackPix, voidPix; | |
133 | ||
134 | bool showAll, showName, showRange, showData; | |
135 | enum listMode mode; | |
136 | struct menu *rootEntry; | |
137 | QColorGroup disabledColorGroup; | |
138 | QColorGroup inactivedColorGroup; | |
139 | ||
140 | private: | |
141 | int colMap[colNr]; | |
142 | int colRevMap[colNr]; | |
143 | }; | |
144 | ||
145 | class ConfigItem : public QListViewItem { | |
146 | typedef class QListViewItem Parent; | |
147 | public: | |
148 | ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v) | |
149 | : Parent(parent, after), menu(m), visible(v), goParent(false) | |
150 | { | |
151 | init(); | |
152 | } | |
153 | ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) | |
154 | : Parent(parent, after), menu(m), visible(v), goParent(false) | |
155 | { | |
156 | init(); | |
157 | } | |
158 | ConfigItem(QListView *parent, ConfigItem *after, bool v) | |
159 | : Parent(parent, after), menu(0), visible(v), goParent(true) | |
160 | { | |
161 | init(); | |
162 | } | |
163 | ~ConfigItem(void); | |
164 | void init(void); | |
165 | #if QT_VERSION >= 300 | |
166 | void okRename(int col); | |
167 | #endif | |
168 | void updateMenu(void); | |
169 | void testUpdateMenu(bool v); | |
170 | ConfigList* listView() const | |
171 | { | |
172 | return (ConfigList*)Parent::listView(); | |
173 | } | |
174 | ConfigItem* firstChild() const | |
175 | { | |
176 | return (ConfigItem *)Parent::firstChild(); | |
177 | } | |
178 | ConfigItem* nextSibling() const | |
179 | { | |
180 | return (ConfigItem *)Parent::nextSibling(); | |
181 | } | |
182 | void setText(colIdx idx, const QString& text) | |
183 | { | |
184 | Parent::setText(listView()->mapIdx(idx), text); | |
185 | } | |
186 | QString text(colIdx idx) const | |
187 | { | |
188 | return Parent::text(listView()->mapIdx(idx)); | |
189 | } | |
190 | void setPixmap(colIdx idx, const QPixmap& pm) | |
191 | { | |
192 | Parent::setPixmap(listView()->mapIdx(idx), pm); | |
193 | } | |
194 | const QPixmap* pixmap(colIdx idx) const | |
195 | { | |
196 | return Parent::pixmap(listView()->mapIdx(idx)); | |
197 | } | |
198 | void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); | |
199 | ||
200 | ConfigItem* nextItem; | |
201 | struct menu *menu; | |
202 | bool visible; | |
203 | bool goParent; | |
204 | }; | |
205 | ||
206 | class ConfigLineEdit : public QLineEdit { | |
207 | Q_OBJECT | |
208 | typedef class QLineEdit Parent; | |
209 | public: | |
43bf612a | 210 | ConfigLineEdit(ConfigView* parent); |
1da177e4 LT |
211 | ConfigView* parent(void) const |
212 | { | |
213 | return (ConfigView*)Parent::parent(); | |
214 | } | |
215 | void show(ConfigItem *i); | |
216 | void keyPressEvent(QKeyEvent *e); | |
217 | ||
218 | public: | |
219 | ConfigItem *item; | |
220 | }; | |
221 | ||
43bf612a RZ |
222 | class ConfigInfoView : public QTextBrowser { |
223 | Q_OBJECT | |
224 | typedef class QTextBrowser Parent; | |
225 | public: | |
226 | ConfigInfoView(QWidget* parent, const char *name = 0); | |
227 | bool showDebug(void) const { return _showDebug; } | |
228 | ||
229 | public slots: | |
230 | void setInfo(struct menu *menu); | |
231 | void setSource(const QString& name); | |
232 | void setShowDebug(bool); | |
233 | ||
234 | signals: | |
235 | void showDebugChanged(bool); | |
236 | ||
237 | protected: | |
238 | void menuInfo(void); | |
239 | QString debug_info(struct symbol *sym); | |
240 | static QString print_filter(const QString &str); | |
241 | static void expr_print_help(void *data, const char *str); | |
242 | ||
243 | struct menu *menu; | |
244 | bool _showDebug; | |
245 | }; | |
246 | ||
247 | class ConfigSearchWindow : public QDialog { | |
248 | Q_OBJECT | |
249 | typedef class QDialog Parent; | |
250 | public: | |
251 | ConfigSearchWindow(QWidget* parent); | |
252 | public slots: | |
253 | void search(void); | |
254 | protected: | |
255 | QLineEdit* editField; | |
256 | QPushButton* searchButton; | |
257 | ConfigView* list; | |
258 | ConfigInfoView* info; | |
259 | ||
260 | struct symbol **result; | |
261 | }; | |
262 | ||
1da177e4 LT |
263 | class ConfigMainWindow : public QMainWindow { |
264 | Q_OBJECT | |
265 | public: | |
266 | ConfigMainWindow(void); | |
267 | public slots: | |
268 | void setHelp(QListViewItem* item); | |
269 | void changeMenu(struct menu *); | |
270 | void listFocusChanged(void); | |
271 | void goBack(void); | |
272 | void loadConfig(void); | |
273 | void saveConfig(void); | |
274 | void saveConfigAs(void); | |
43bf612a | 275 | void searchConfig(void); |
1da177e4 LT |
276 | void showSingleView(void); |
277 | void showSplitView(void); | |
278 | void showFullView(void); | |
279 | void setShowAll(bool); | |
1da177e4 LT |
280 | void setShowRange(bool); |
281 | void setShowName(bool); | |
282 | void setShowData(bool); | |
283 | void showIntro(void); | |
284 | void showAbout(void); | |
285 | void saveSettings(void); | |
286 | ||
287 | protected: | |
288 | void closeEvent(QCloseEvent *e); | |
289 | ||
43bf612a | 290 | ConfigSearchWindow *searchWindow; |
1da177e4 LT |
291 | ConfigView *menuView; |
292 | ConfigList *menuList; | |
293 | ConfigView *configView; | |
294 | ConfigList *configList; | |
43bf612a | 295 | ConfigInfoView *helpText; |
1da177e4 LT |
296 | QToolBar *toolBar; |
297 | QAction *backAction; | |
298 | QSplitter* split1; | |
299 | QSplitter* split2; | |
1da177e4 | 300 | }; |