-rw-r--r-- | scripts/kconfig/qconf.cc | 16 | ||||
-rw-r--r-- | scripts/kconfig/qconf.h | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 52419ad..0459caf 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc | |||
@@ -1,1304 +1,1304 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
3 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include <qmainwindow.h> | 7 | #include <qmainwindow.h> |
8 | #include <qtoolbar.h> | 8 | #include <qtoolbar.h> |
9 | #include <qvbox.h> | 9 | #include <qvbox.h> |
10 | #include <qsplitter.h> | 10 | #include <qsplitter.h> |
11 | #include <qlistview.h> | 11 | #include <qlistview.h> |
12 | #include <qtextview.h> | 12 | #include <qtextview.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qmenubar.h> | 14 | #include <qmenubar.h> |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qaction.h> | 16 | #include <qaction.h> |
17 | #include <qheader.h> | 17 | #include <qheader.h> |
18 | #include <qfiledialog.h> | 18 | #include <qfiledialog.h> |
19 | #include <qregexp.h> | 19 | #include <qregexp.h> |
20 | #if QT_VERSION >= 300 | 20 | #if QT_VERSION >= 0x030000 |
21 | #include <qsettings.h> | 21 | #include <qsettings.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | 25 | ||
26 | #include "lkc.h" | 26 | #include "lkc.h" |
27 | #include "qconf.h" | 27 | #include "qconf.h" |
28 | 28 | ||
29 | #include "qconf.moc" | 29 | #include "qconf.moc" |
30 | #include "images.c" | 30 | #include "images.c" |
31 | 31 | ||
32 | static QApplication *configApp; | 32 | static QApplication *configApp; |
33 | #if QT_VERSION >= 300 | 33 | #if QT_VERSION >= 0x030000 |
34 | static QSettings *configSettings; | 34 | static QSettings *configSettings; |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | /* | 37 | /* |
38 | * update all the children of a menu entry | 38 | * update all the children of a menu entry |
39 | * removes/adds the entries from the parent widget as necessary | 39 | * removes/adds the entries from the parent widget as necessary |
40 | * | 40 | * |
41 | * parent: either the menu list widget or a menu entry widget | 41 | * parent: either the menu list widget or a menu entry widget |
42 | * menu: entry to be updated | 42 | * menu: entry to be updated |
43 | */ | 43 | */ |
44 | template <class P> | 44 | template <class P> |
45 | void ConfigList::updateMenuList(P* parent, struct menu* menu) | 45 | void ConfigList::updateMenuList(P* parent, struct menu* menu) |
46 | { | 46 | { |
47 | struct menu* child; | 47 | struct menu* child; |
48 | ConfigItem* item; | 48 | ConfigItem* item; |
49 | ConfigItem* last; | 49 | ConfigItem* last; |
50 | bool visible; | 50 | bool visible; |
51 | enum prop_type type; | 51 | enum prop_type type; |
52 | 52 | ||
53 | if (!menu) { | 53 | if (!menu) { |
54 | while ((item = parent->firstChild())) | 54 | while ((item = parent->firstChild())) |
55 | delete item; | 55 | delete item; |
56 | return; | 56 | return; |
57 | } | 57 | } |
58 | 58 | ||
59 | last = parent->firstChild(); | 59 | last = parent->firstChild(); |
60 | if (last && !last->goParent) | 60 | if (last && !last->goParent) |
61 | last = 0; | 61 | last = 0; |
62 | for (child = menu->list; child; child = child->next) { | 62 | for (child = menu->list; child; child = child->next) { |
63 | item = last ? last->nextSibling() : parent->firstChild(); | 63 | item = last ? last->nextSibling() : parent->firstChild(); |
64 | type = child->prompt ? child->prompt->type : P_UNKNOWN; | 64 | type = child->prompt ? child->prompt->type : P_UNKNOWN; |
65 | 65 | ||
66 | switch (mode) { | 66 | switch (mode) { |
67 | case menuMode: | 67 | case menuMode: |
68 | if (!(child->flags & MENU_ROOT)) | 68 | if (!(child->flags & MENU_ROOT)) |
69 | goto hide; | 69 | goto hide; |
70 | break; | 70 | break; |
71 | case symbolMode: | 71 | case symbolMode: |
72 | if (child->flags & MENU_ROOT) | 72 | if (child->flags & MENU_ROOT) |
73 | goto hide; | 73 | goto hide; |
74 | break; | 74 | break; |
75 | default: | 75 | default: |
76 | break; | 76 | break; |
77 | } | 77 | } |
78 | 78 | ||
79 | visible = menu_is_visible(child); | 79 | visible = menu_is_visible(child); |
80 | if (showAll || visible) { | 80 | if (showAll || visible) { |
81 | if (!item || item->menu != child) | 81 | if (!item || item->menu != child) |
82 | item = new ConfigItem(parent, last, child, visible); | 82 | item = new ConfigItem(parent, last, child, visible); |
83 | else | 83 | else |
84 | item->testUpdateMenu(visible); | 84 | item->testUpdateMenu(visible); |
85 | 85 | ||
86 | if (mode == fullMode || mode == menuMode || type != P_MENU) | 86 | if (mode == fullMode || mode == menuMode || type != P_MENU) |
87 | updateMenuList(item, child); | 87 | updateMenuList(item, child); |
88 | else | 88 | else |
89 | updateMenuList(item, 0); | 89 | updateMenuList(item, 0); |
90 | last = item; | 90 | last = item; |
91 | continue; | 91 | continue; |
92 | } | 92 | } |
93 | hide: | 93 | hide: |
94 | if (item && item->menu == child) { | 94 | if (item && item->menu == child) { |
95 | last = parent->firstChild(); | 95 | last = parent->firstChild(); |
96 | if (last == item) | 96 | if (last == item) |
97 | last = 0; | 97 | last = 0; |
98 | else while (last->nextSibling() != item) | 98 | else while (last->nextSibling() != item) |
99 | last = last->nextSibling(); | 99 | last = last->nextSibling(); |
100 | delete item; | 100 | delete item; |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | #if QT_VERSION >= 300 | 105 | #if QT_VERSION >= 0x030000 |
106 | /* | 106 | /* |
107 | * set the new data | 107 | * set the new data |
108 | * TODO check the value | 108 | * TODO check the value |
109 | */ | 109 | */ |
110 | void ConfigItem::okRename(int col) | 110 | void ConfigItem::okRename(int col) |
111 | { | 111 | { |
112 | Parent::okRename(col); | 112 | Parent::okRename(col); |
113 | sym_set_string_value(menu->sym, text(dataColIdx).latin1()); | 113 | sym_set_string_value(menu->sym, text(dataColIdx).latin1()); |
114 | } | 114 | } |
115 | #endif | 115 | #endif |
116 | 116 | ||
117 | /* | 117 | /* |
118 | * update the displayed of a menu entry | 118 | * update the displayed of a menu entry |
119 | */ | 119 | */ |
120 | void ConfigItem::updateMenu(void) | 120 | void ConfigItem::updateMenu(void) |
121 | { | 121 | { |
122 | ConfigList* list; | 122 | ConfigList* list; |
123 | struct symbol* sym; | 123 | struct symbol* sym; |
124 | struct property *prop; | 124 | struct property *prop; |
125 | QString prompt; | 125 | QString prompt; |
126 | int type; | 126 | int type; |
127 | tristate expr; | 127 | tristate expr; |
128 | 128 | ||
129 | list = listView(); | 129 | list = listView(); |
130 | if (goParent) { | 130 | if (goParent) { |
131 | setPixmap(promptColIdx, list->menuBackPix); | 131 | setPixmap(promptColIdx, list->menuBackPix); |
132 | prompt = ".."; | 132 | prompt = ".."; |
133 | goto set_prompt; | 133 | goto set_prompt; |
134 | } | 134 | } |
135 | 135 | ||
136 | sym = menu->sym; | 136 | sym = menu->sym; |
137 | prop = menu->prompt; | 137 | prop = menu->prompt; |
138 | prompt = menu_get_prompt(menu); | 138 | prompt = menu_get_prompt(menu); |
139 | 139 | ||
140 | if (prop) switch (prop->type) { | 140 | if (prop) switch (prop->type) { |
141 | case P_MENU: | 141 | case P_MENU: |
142 | if (list->mode == singleMode || list->mode == symbolMode) { | 142 | if (list->mode == singleMode || list->mode == symbolMode) { |
143 | /* a menuconfig entry is displayed differently | 143 | /* a menuconfig entry is displayed differently |
144 | * depending whether it's at the view root or a child. | 144 | * depending whether it's at the view root or a child. |
145 | */ | 145 | */ |
146 | if (sym && list->rootEntry == menu) | 146 | if (sym && list->rootEntry == menu) |
147 | break; | 147 | break; |
148 | setPixmap(promptColIdx, list->menuPix); | 148 | setPixmap(promptColIdx, list->menuPix); |
149 | } else { | 149 | } else { |
150 | if (sym) | 150 | if (sym) |
151 | break; | 151 | break; |
152 | setPixmap(promptColIdx, 0); | 152 | setPixmap(promptColIdx, 0); |
153 | } | 153 | } |
154 | goto set_prompt; | 154 | goto set_prompt; |
155 | case P_COMMENT: | 155 | case P_COMMENT: |
156 | setPixmap(promptColIdx, 0); | 156 | setPixmap(promptColIdx, 0); |
157 | goto set_prompt; | 157 | goto set_prompt; |
158 | default: | 158 | default: |
159 | ; | 159 | ; |
160 | } | 160 | } |
161 | if (!sym) | 161 | if (!sym) |
162 | goto set_prompt; | 162 | goto set_prompt; |
163 | 163 | ||
164 | setText(nameColIdx, sym->name); | 164 | setText(nameColIdx, sym->name); |
165 | 165 | ||
166 | type = sym_get_type(sym); | 166 | type = sym_get_type(sym); |
167 | switch (type) { | 167 | switch (type) { |
168 | case S_BOOLEAN: | 168 | case S_BOOLEAN: |
169 | case S_TRISTATE: | 169 | case S_TRISTATE: |
170 | char ch; | 170 | char ch; |
171 | 171 | ||
172 | if (!sym_is_changable(sym) && !list->showAll) { | 172 | if (!sym_is_changable(sym) && !list->showAll) { |
173 | setPixmap(promptColIdx, 0); | 173 | setPixmap(promptColIdx, 0); |
174 | setText(noColIdx, 0); | 174 | setText(noColIdx, 0); |
175 | setText(modColIdx, 0); | 175 | setText(modColIdx, 0); |
176 | setText(yesColIdx, 0); | 176 | setText(yesColIdx, 0); |
177 | break; | 177 | break; |
178 | } | 178 | } |
179 | expr = sym_get_tristate_value(sym); | 179 | expr = sym_get_tristate_value(sym); |
180 | switch (expr) { | 180 | switch (expr) { |
181 | case yes: | 181 | case yes: |
182 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) | 182 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) |
183 | setPixmap(promptColIdx, list->choiceYesPix); | 183 | setPixmap(promptColIdx, list->choiceYesPix); |
184 | else | 184 | else |
185 | setPixmap(promptColIdx, list->symbolYesPix); | 185 | setPixmap(promptColIdx, list->symbolYesPix); |
186 | setText(yesColIdx, "Y"); | 186 | setText(yesColIdx, "Y"); |
187 | ch = 'Y'; | 187 | ch = 'Y'; |
188 | break; | 188 | break; |
189 | case mod: | 189 | case mod: |
190 | setPixmap(promptColIdx, list->symbolModPix); | 190 | setPixmap(promptColIdx, list->symbolModPix); |
191 | setText(modColIdx, "M"); | 191 | setText(modColIdx, "M"); |
192 | ch = 'M'; | 192 | ch = 'M'; |
193 | break; | 193 | break; |
194 | default: | 194 | default: |
195 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) | 195 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) |
196 | setPixmap(promptColIdx, list->choiceNoPix); | 196 | setPixmap(promptColIdx, list->choiceNoPix); |
197 | else | 197 | else |
198 | setPixmap(promptColIdx, list->symbolNoPix); | 198 | setPixmap(promptColIdx, list->symbolNoPix); |
199 | setText(noColIdx, "N"); | 199 | setText(noColIdx, "N"); |
200 | ch = 'N'; | 200 | ch = 'N'; |
201 | break; | 201 | break; |
202 | } | 202 | } |
203 | if (expr != no) | 203 | if (expr != no) |
204 | setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); | 204 | setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); |
205 | if (expr != mod) | 205 | if (expr != mod) |
206 | setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); | 206 | setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); |
207 | if (expr != yes) | 207 | if (expr != yes) |
208 | setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); | 208 | setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); |
209 | 209 | ||
210 | setText(dataColIdx, QChar(ch)); | 210 | setText(dataColIdx, QChar(ch)); |
211 | break; | 211 | break; |
212 | case S_INT: | 212 | case S_INT: |
213 | case S_HEX: | 213 | case S_HEX: |
214 | case S_STRING: | 214 | case S_STRING: |
215 | const char* data; | 215 | const char* data; |
216 | 216 | ||
217 | data = sym_get_string_value(sym); | 217 | data = sym_get_string_value(sym); |
218 | #if QT_VERSION >= 300 | 218 | #if QT_VERSION >= 0x030000 |
219 | int i = list->mapIdx(dataColIdx); | 219 | int i = list->mapIdx(dataColIdx); |
220 | if (i >= 0) | 220 | if (i >= 0) |
221 | setRenameEnabled(i, TRUE); | 221 | setRenameEnabled(i, TRUE); |
222 | #endif | 222 | #endif |
223 | setText(dataColIdx, data); | 223 | setText(dataColIdx, data); |
224 | if (type == S_STRING) | 224 | if (type == S_STRING) |
225 | prompt.sprintf("%s: %s", prompt.latin1(), data); | 225 | prompt.sprintf("%s: %s", prompt.latin1(), data); |
226 | else | 226 | else |
227 | prompt.sprintf("(%s) %s", data, prompt.latin1()); | 227 | prompt.sprintf("(%s) %s", data, prompt.latin1()); |
228 | break; | 228 | break; |
229 | } | 229 | } |
230 | if (!sym_has_value(sym) && visible) | 230 | if (!sym_has_value(sym) && visible) |
231 | prompt += " (NEW)"; | 231 | prompt += " (NEW)"; |
232 | set_prompt: | 232 | set_prompt: |
233 | setText(promptColIdx, prompt); | 233 | setText(promptColIdx, prompt); |
234 | } | 234 | } |
235 | 235 | ||
236 | void ConfigItem::testUpdateMenu(bool v) | 236 | void ConfigItem::testUpdateMenu(bool v) |
237 | { | 237 | { |
238 | ConfigItem* i; | 238 | ConfigItem* i; |
239 | 239 | ||
240 | visible = v; | 240 | visible = v; |
241 | if (!menu) | 241 | if (!menu) |
242 | return; | 242 | return; |
243 | 243 | ||
244 | sym_calc_value(menu->sym); | 244 | sym_calc_value(menu->sym); |
245 | if (menu->flags & MENU_CHANGED) { | 245 | if (menu->flags & MENU_CHANGED) { |
246 | /* the menu entry changed, so update all list items */ | 246 | /* the menu entry changed, so update all list items */ |
247 | menu->flags &= ~MENU_CHANGED; | 247 | menu->flags &= ~MENU_CHANGED; |
248 | for (i = (ConfigItem*)menu->data; i; i = i->nextItem) | 248 | for (i = (ConfigItem*)menu->data; i; i = i->nextItem) |
249 | i->updateMenu(); | 249 | i->updateMenu(); |
250 | } else if (listView()->updateAll) | 250 | } else if (listView()->updateAll) |
251 | updateMenu(); | 251 | updateMenu(); |
252 | } | 252 | } |
253 | 253 | ||
254 | void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) | 254 | void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) |
255 | { | 255 | { |
256 | ConfigList* list = listView(); | 256 | ConfigList* list = listView(); |
257 | 257 | ||
258 | if (visible) { | 258 | if (visible) { |
259 | if (isSelected() && !list->hasFocus() && list->mode == menuMode) | 259 | if (isSelected() && !list->hasFocus() && list->mode == menuMode) |
260 | Parent::paintCell(p, list->inactivedColorGroup, column, width, align); | 260 | Parent::paintCell(p, list->inactivedColorGroup, column, width, align); |
261 | else | 261 | else |
262 | Parent::paintCell(p, cg, column, width, align); | 262 | Parent::paintCell(p, cg, column, width, align); |
263 | } else | 263 | } else |
264 | Parent::paintCell(p, list->disabledColorGroup, column, width, align); | 264 | Parent::paintCell(p, list->disabledColorGroup, column, width, align); |
265 | } | 265 | } |
266 | 266 | ||
267 | /* | 267 | /* |
268 | * construct a menu entry | 268 | * construct a menu entry |
269 | */ | 269 | */ |
270 | void ConfigItem::init(void) | 270 | void ConfigItem::init(void) |
271 | { | 271 | { |
272 | if (menu) { | 272 | if (menu) { |
273 | ConfigList* list = listView(); | 273 | ConfigList* list = listView(); |
274 | nextItem = (ConfigItem*)menu->data; | 274 | nextItem = (ConfigItem*)menu->data; |
275 | menu->data = this; | 275 | menu->data = this; |
276 | 276 | ||
277 | if (list->mode != fullMode) | 277 | if (list->mode != fullMode) |
278 | setOpen(TRUE); | 278 | setOpen(TRUE); |
279 | sym_calc_value(menu->sym); | 279 | sym_calc_value(menu->sym); |
280 | } | 280 | } |
281 | updateMenu(); | 281 | updateMenu(); |
282 | } | 282 | } |
283 | 283 | ||
284 | /* | 284 | /* |
285 | * destruct a menu entry | 285 | * destruct a menu entry |
286 | */ | 286 | */ |
287 | ConfigItem::~ConfigItem(void) | 287 | ConfigItem::~ConfigItem(void) |
288 | { | 288 | { |
289 | if (menu) { | 289 | if (menu) { |
290 | ConfigItem** ip = (ConfigItem**)&menu->data; | 290 | ConfigItem** ip = (ConfigItem**)&menu->data; |
291 | for (; *ip; ip = &(*ip)->nextItem) { | 291 | for (; *ip; ip = &(*ip)->nextItem) { |
292 | if (*ip == this) { | 292 | if (*ip == this) { |
293 | *ip = nextItem; | 293 | *ip = nextItem; |
294 | break; | 294 | break; |
295 | } | 295 | } |
296 | } | 296 | } |
297 | } | 297 | } |
298 | } | 298 | } |
299 | 299 | ||
300 | void ConfigLineEdit::show(ConfigItem* i) | 300 | void ConfigLineEdit::show(ConfigItem* i) |
301 | { | 301 | { |
302 | item = i; | 302 | item = i; |
303 | if (sym_get_string_value(item->menu->sym)) | 303 | if (sym_get_string_value(item->menu->sym)) |
304 | setText(sym_get_string_value(item->menu->sym)); | 304 | setText(sym_get_string_value(item->menu->sym)); |
305 | else | 305 | else |
306 | setText(0); | 306 | setText(0); |
307 | Parent::show(); | 307 | Parent::show(); |
308 | setFocus(); | 308 | setFocus(); |
309 | } | 309 | } |
310 | 310 | ||
311 | void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | 311 | void ConfigLineEdit::keyPressEvent(QKeyEvent* e) |
312 | { | 312 | { |
313 | switch (e->key()) { | 313 | switch (e->key()) { |
314 | case Key_Escape: | 314 | case Key_Escape: |
315 | break; | 315 | break; |
316 | case Key_Return: | 316 | case Key_Return: |
317 | case Key_Enter: | 317 | case Key_Enter: |
318 | sym_set_string_value(item->menu->sym, text().latin1()); | 318 | sym_set_string_value(item->menu->sym, text().latin1()); |
319 | parent()->updateList(item); | 319 | parent()->updateList(item); |
320 | break; | 320 | break; |
321 | default: | 321 | default: |
322 | Parent::keyPressEvent(e); | 322 | Parent::keyPressEvent(e); |
323 | return; | 323 | return; |
324 | } | 324 | } |
325 | e->accept(); | 325 | e->accept(); |
326 | parent()->list->setFocus(); | 326 | parent()->list->setFocus(); |
327 | hide(); | 327 | hide(); |
328 | } | 328 | } |
329 | 329 | ||
330 | ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv) | 330 | ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv) |
331 | : Parent(p), cview(cv), | 331 | : Parent(p), cview(cv), |
332 | updateAll(false), | 332 | updateAll(false), |
333 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), | 333 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), |
334 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), | 334 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), |
335 | menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), | 335 | menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), |
336 | showAll(false), showName(false), showRange(false), showData(false), | 336 | showAll(false), showName(false), showRange(false), showData(false), |
337 | rootEntry(0) | 337 | rootEntry(0) |
338 | { | 338 | { |
339 | int i; | 339 | int i; |
340 | 340 | ||
341 | setSorting(-1); | 341 | setSorting(-1); |
342 | setRootIsDecorated(TRUE); | 342 | setRootIsDecorated(TRUE); |
343 | disabledColorGroup = palette().active(); | 343 | disabledColorGroup = palette().active(); |
344 | disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text()); | 344 | disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text()); |
345 | inactivedColorGroup = palette().active(); | 345 | inactivedColorGroup = palette().active(); |
346 | inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight()); | 346 | inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight()); |
347 | 347 | ||
348 | connect(this, SIGNAL(selectionChanged(void)), | 348 | connect(this, SIGNAL(selectionChanged(void)), |
349 | SLOT(updateSelection(void))); | 349 | SLOT(updateSelection(void))); |
350 | 350 | ||
351 | for (i = 0; i < colNr; i++) | 351 | for (i = 0; i < colNr; i++) |
352 | colMap[i] = colRevMap[i] = -1; | 352 | colMap[i] = colRevMap[i] = -1; |
353 | addColumn(promptColIdx, "Option"); | 353 | addColumn(promptColIdx, "Option"); |
354 | 354 | ||
355 | reinit(); | 355 | reinit(); |
356 | } | 356 | } |
357 | 357 | ||
358 | void ConfigList::reinit(void) | 358 | void ConfigList::reinit(void) |
359 | { | 359 | { |
360 | removeColumn(dataColIdx); | 360 | removeColumn(dataColIdx); |
361 | removeColumn(yesColIdx); | 361 | removeColumn(yesColIdx); |
362 | removeColumn(modColIdx); | 362 | removeColumn(modColIdx); |
363 | removeColumn(noColIdx); | 363 | removeColumn(noColIdx); |
364 | removeColumn(nameColIdx); | 364 | removeColumn(nameColIdx); |
365 | 365 | ||
366 | if (showName) | 366 | if (showName) |
367 | addColumn(nameColIdx, "Name"); | 367 | addColumn(nameColIdx, "Name"); |
368 | if (showRange) { | 368 | if (showRange) { |
369 | addColumn(noColIdx, "N"); | 369 | addColumn(noColIdx, "N"); |
370 | addColumn(modColIdx, "M"); | 370 | addColumn(modColIdx, "M"); |
371 | addColumn(yesColIdx, "Y"); | 371 | addColumn(yesColIdx, "Y"); |
372 | } | 372 | } |
373 | if (showData) | 373 | if (showData) |
374 | addColumn(dataColIdx, "Value"); | 374 | addColumn(dataColIdx, "Value"); |
375 | 375 | ||
376 | updateListAll(); | 376 | updateListAll(); |
377 | } | 377 | } |
378 | 378 | ||
379 | void ConfigList::updateSelection(void) | 379 | void ConfigList::updateSelection(void) |
380 | { | 380 | { |
381 | struct menu *menu; | 381 | struct menu *menu; |
382 | enum prop_type type; | 382 | enum prop_type type; |
383 | 383 | ||
384 | ConfigItem* item = (ConfigItem*)selectedItem(); | 384 | ConfigItem* item = (ConfigItem*)selectedItem(); |
385 | if (!item) | 385 | if (!item) |
386 | return; | 386 | return; |
387 | 387 | ||
388 | cview->setHelp(item); | 388 | cview->setHelp(item); |
389 | 389 | ||
390 | menu = item->menu; | 390 | menu = item->menu; |
391 | if (!menu) | 391 | if (!menu) |
392 | return; | 392 | return; |
393 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 393 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
394 | if (mode == menuMode && type == P_MENU) | 394 | if (mode == menuMode && type == P_MENU) |
395 | emit menuSelected(menu); | 395 | emit menuSelected(menu); |
396 | } | 396 | } |
397 | 397 | ||
398 | void ConfigList::updateList(ConfigItem* item) | 398 | void ConfigList::updateList(ConfigItem* item) |
399 | { | 399 | { |
400 | ConfigItem* last = 0; | 400 | ConfigItem* last = 0; |
401 | 401 | ||
402 | if (!rootEntry) | 402 | if (!rootEntry) |
403 | goto update; | 403 | goto update; |
404 | 404 | ||
405 | if (rootEntry != &rootmenu && (mode == singleMode || | 405 | if (rootEntry != &rootmenu && (mode == singleMode || |
406 | (mode == symbolMode && rootEntry->parent != &rootmenu))) { | 406 | (mode == symbolMode && rootEntry->parent != &rootmenu))) { |
407 | item = firstChild(); | 407 | item = firstChild(); |
408 | if (!item) | 408 | if (!item) |
409 | item = new ConfigItem(this, 0, true); | 409 | item = new ConfigItem(this, 0, true); |
410 | last = item; | 410 | last = item; |
411 | } | 411 | } |
412 | if (mode == singleMode && rootEntry->sym && rootEntry->prompt) { | 412 | if (mode == singleMode && rootEntry->sym && rootEntry->prompt) { |
413 | item = last ? last->nextSibling() : firstChild(); | 413 | item = last ? last->nextSibling() : firstChild(); |
414 | if (!item) | 414 | if (!item) |
415 | item = new ConfigItem(this, last, rootEntry, true); | 415 | item = new ConfigItem(this, last, rootEntry, true); |
416 | 416 | ||
417 | updateMenuList(item, rootEntry); | 417 | updateMenuList(item, rootEntry); |
418 | triggerUpdate(); | 418 | triggerUpdate(); |
419 | return; | 419 | return; |
420 | } | 420 | } |
421 | update: | 421 | update: |
422 | updateMenuList(this, rootEntry); | 422 | updateMenuList(this, rootEntry); |
423 | triggerUpdate(); | 423 | triggerUpdate(); |
424 | } | 424 | } |
425 | 425 | ||
426 | void ConfigList::setAllOpen(bool open) | 426 | void ConfigList::setAllOpen(bool open) |
427 | { | 427 | { |
428 | QListViewItemIterator it(this); | 428 | QListViewItemIterator it(this); |
429 | 429 | ||
430 | for (; it.current(); it++) | 430 | for (; it.current(); it++) |
431 | it.current()->setOpen(open); | 431 | it.current()->setOpen(open); |
432 | } | 432 | } |
433 | 433 | ||
434 | void ConfigList::setValue(ConfigItem* item, tristate val) | 434 | void ConfigList::setValue(ConfigItem* item, tristate val) |
435 | { | 435 | { |
436 | struct symbol* sym; | 436 | struct symbol* sym; |
437 | int type; | 437 | int type; |
438 | tristate oldval; | 438 | tristate oldval; |
439 | 439 | ||
440 | sym = item->menu ? item->menu->sym : 0; | 440 | sym = item->menu ? item->menu->sym : 0; |
441 | if (!sym) | 441 | if (!sym) |
442 | return; | 442 | return; |
443 | 443 | ||
444 | type = sym_get_type(sym); | 444 | type = sym_get_type(sym); |
445 | switch (type) { | 445 | switch (type) { |
446 | case S_BOOLEAN: | 446 | case S_BOOLEAN: |
447 | case S_TRISTATE: | 447 | case S_TRISTATE: |
448 | oldval = sym_get_tristate_value(sym); | 448 | oldval = sym_get_tristate_value(sym); |
449 | 449 | ||
450 | if (!sym_set_tristate_value(sym, val)) | 450 | if (!sym_set_tristate_value(sym, val)) |
451 | return; | 451 | return; |
452 | if (oldval == no && item->menu->list) | 452 | if (oldval == no && item->menu->list) |
453 | item->setOpen(TRUE); | 453 | item->setOpen(TRUE); |
454 | parent()->updateList(item); | 454 | parent()->updateList(item); |
455 | break; | 455 | break; |
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | void ConfigList::changeValue(ConfigItem* item) | 459 | void ConfigList::changeValue(ConfigItem* item) |
460 | { | 460 | { |
461 | struct symbol* sym; | 461 | struct symbol* sym; |
462 | struct menu* menu; | 462 | struct menu* menu; |
463 | int type, oldexpr, newexpr; | 463 | int type, oldexpr, newexpr; |
464 | 464 | ||
465 | menu = item->menu; | 465 | menu = item->menu; |
466 | if (!menu) | 466 | if (!menu) |
467 | return; | 467 | return; |
468 | sym = menu->sym; | 468 | sym = menu->sym; |
469 | if (!sym) { | 469 | if (!sym) { |
470 | if (item->menu->list) | 470 | if (item->menu->list) |
471 | item->setOpen(!item->isOpen()); | 471 | item->setOpen(!item->isOpen()); |
472 | return; | 472 | return; |
473 | } | 473 | } |
474 | 474 | ||
475 | type = sym_get_type(sym); | 475 | type = sym_get_type(sym); |
476 | switch (type) { | 476 | switch (type) { |
477 | case S_BOOLEAN: | 477 | case S_BOOLEAN: |
478 | case S_TRISTATE: | 478 | case S_TRISTATE: |
479 | oldexpr = sym_get_tristate_value(sym); | 479 | oldexpr = sym_get_tristate_value(sym); |
480 | newexpr = sym_toggle_tristate_value(sym); | 480 | newexpr = sym_toggle_tristate_value(sym); |
481 | if (item->menu->list) { | 481 | if (item->menu->list) { |
482 | if (oldexpr == newexpr) | 482 | if (oldexpr == newexpr) |
483 | item->setOpen(!item->isOpen()); | 483 | item->setOpen(!item->isOpen()); |
484 | else if (oldexpr == no) | 484 | else if (oldexpr == no) |
485 | item->setOpen(TRUE); | 485 | item->setOpen(TRUE); |
486 | } | 486 | } |
487 | if (oldexpr != newexpr) | 487 | if (oldexpr != newexpr) |
488 | parent()->updateList(item); | 488 | parent()->updateList(item); |
489 | break; | 489 | break; |
490 | case S_INT: | 490 | case S_INT: |
491 | case S_HEX: | 491 | case S_HEX: |
492 | case S_STRING: | 492 | case S_STRING: |
493 | #if QT_VERSION >= 300 | 493 | #if QT_VERSION >= 0x030000 |
494 | if (colMap[dataColIdx] >= 0) | 494 | if (colMap[dataColIdx] >= 0) |
495 | item->startRename(colMap[dataColIdx]); | 495 | item->startRename(colMap[dataColIdx]); |
496 | else | 496 | else |
497 | #endif | 497 | #endif |
498 | parent()->lineEdit->show(item); | 498 | parent()->lineEdit->show(item); |
499 | break; | 499 | break; |
500 | } | 500 | } |
501 | } | 501 | } |
502 | 502 | ||
503 | void ConfigList::setRootMenu(struct menu *menu) | 503 | void ConfigList::setRootMenu(struct menu *menu) |
504 | { | 504 | { |
505 | enum prop_type type; | 505 | enum prop_type type; |
506 | 506 | ||
507 | if (rootEntry == menu) | 507 | if (rootEntry == menu) |
508 | return; | 508 | return; |
509 | type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; | 509 | type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; |
510 | if (type != P_MENU) | 510 | if (type != P_MENU) |
511 | return; | 511 | return; |
512 | updateMenuList(this, 0); | 512 | updateMenuList(this, 0); |
513 | rootEntry = menu; | 513 | rootEntry = menu; |
514 | updateListAll(); | 514 | updateListAll(); |
515 | setSelected(currentItem(), hasFocus()); | 515 | setSelected(currentItem(), hasFocus()); |
516 | } | 516 | } |
517 | 517 | ||
518 | void ConfigList::setParentMenu(void) | 518 | void ConfigList::setParentMenu(void) |
519 | { | 519 | { |
520 | ConfigItem* item; | 520 | ConfigItem* item; |
521 | struct menu *oldroot; | 521 | struct menu *oldroot; |
522 | 522 | ||
523 | oldroot = rootEntry; | 523 | oldroot = rootEntry; |
524 | if (rootEntry == &rootmenu) | 524 | if (rootEntry == &rootmenu) |
525 | return; | 525 | return; |
526 | setRootMenu(menu_get_parent_menu(rootEntry->parent)); | 526 | setRootMenu(menu_get_parent_menu(rootEntry->parent)); |
527 | 527 | ||
528 | QListViewItemIterator it(this); | 528 | QListViewItemIterator it(this); |
529 | for (; (item = (ConfigItem*)it.current()); it++) { | 529 | for (; (item = (ConfigItem*)it.current()); it++) { |
530 | if (item->menu == oldroot) { | 530 | if (item->menu == oldroot) { |
531 | setCurrentItem(item); | 531 | setCurrentItem(item); |
532 | ensureItemVisible(item); | 532 | ensureItemVisible(item); |
533 | break; | 533 | break; |
534 | } | 534 | } |
535 | } | 535 | } |
536 | } | 536 | } |
537 | 537 | ||
538 | void ConfigList::keyPressEvent(QKeyEvent* ev) | 538 | void ConfigList::keyPressEvent(QKeyEvent* ev) |
539 | { | 539 | { |
540 | QListViewItem* i = currentItem(); | 540 | QListViewItem* i = currentItem(); |
541 | ConfigItem* item; | 541 | ConfigItem* item; |
542 | struct menu *menu; | 542 | struct menu *menu; |
543 | enum prop_type type; | 543 | enum prop_type type; |
544 | 544 | ||
545 | if (ev->key() == Key_Escape && mode != fullMode) { | 545 | if (ev->key() == Key_Escape && mode != fullMode) { |
546 | emit parentSelected(); | 546 | emit parentSelected(); |
547 | ev->accept(); | 547 | ev->accept(); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | 550 | ||
551 | if (!i) { | 551 | if (!i) { |
552 | Parent::keyPressEvent(ev); | 552 | Parent::keyPressEvent(ev); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | item = (ConfigItem*)i; | 555 | item = (ConfigItem*)i; |
556 | 556 | ||
557 | switch (ev->key()) { | 557 | switch (ev->key()) { |
558 | case Key_Return: | 558 | case Key_Return: |
559 | case Key_Enter: | 559 | case Key_Enter: |
560 | if (item->goParent) { | 560 | if (item->goParent) { |
561 | emit parentSelected(); | 561 | emit parentSelected(); |
562 | break; | 562 | break; |
563 | } | 563 | } |
564 | menu = item->menu; | 564 | menu = item->menu; |
565 | if (!menu) | 565 | if (!menu) |
566 | break; | 566 | break; |
567 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 567 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
568 | if (type == P_MENU && rootEntry != menu && | 568 | if (type == P_MENU && rootEntry != menu && |
569 | mode != fullMode && mode != menuMode) { | 569 | mode != fullMode && mode != menuMode) { |
570 | emit menuSelected(menu); | 570 | emit menuSelected(menu); |
571 | break; | 571 | break; |
572 | } | 572 | } |
573 | case Key_Space: | 573 | case Key_Space: |
574 | changeValue(item); | 574 | changeValue(item); |
575 | break; | 575 | break; |
576 | case Key_N: | 576 | case Key_N: |
577 | setValue(item, no); | 577 | setValue(item, no); |
578 | break; | 578 | break; |
579 | case Key_M: | 579 | case Key_M: |
580 | setValue(item, mod); | 580 | setValue(item, mod); |
581 | break; | 581 | break; |
582 | case Key_Y: | 582 | case Key_Y: |
583 | setValue(item, yes); | 583 | setValue(item, yes); |
584 | break; | 584 | break; |
585 | default: | 585 | default: |
586 | Parent::keyPressEvent(ev); | 586 | Parent::keyPressEvent(ev); |
587 | return; | 587 | return; |
588 | } | 588 | } |
589 | ev->accept(); | 589 | ev->accept(); |
590 | } | 590 | } |
591 | 591 | ||
592 | void ConfigList::contentsMousePressEvent(QMouseEvent* e) | 592 | void ConfigList::contentsMousePressEvent(QMouseEvent* e) |
593 | { | 593 | { |
594 | //QPoint p(contentsToViewport(e->pos())); | 594 | //QPoint p(contentsToViewport(e->pos())); |
595 | //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); | 595 | //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); |
596 | Parent::contentsMousePressEvent(e); | 596 | Parent::contentsMousePressEvent(e); |
597 | } | 597 | } |
598 | 598 | ||
599 | void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) | 599 | void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) |
600 | { | 600 | { |
601 | QPoint p(contentsToViewport(e->pos())); | 601 | QPoint p(contentsToViewport(e->pos())); |
602 | ConfigItem* item = (ConfigItem*)itemAt(p); | 602 | ConfigItem* item = (ConfigItem*)itemAt(p); |
603 | struct menu *menu; | 603 | struct menu *menu; |
604 | enum prop_type ptype; | 604 | enum prop_type ptype; |
605 | const QPixmap* pm; | 605 | const QPixmap* pm; |
606 | int idx, x; | 606 | int idx, x; |
607 | 607 | ||
608 | if (!item) | 608 | if (!item) |
609 | goto skip; | 609 | goto skip; |
610 | 610 | ||
611 | menu = item->menu; | 611 | menu = item->menu; |
612 | x = header()->offset() + p.x(); | 612 | x = header()->offset() + p.x(); |
613 | idx = colRevMap[header()->sectionAt(x)]; | 613 | idx = colRevMap[header()->sectionAt(x)]; |
614 | switch (idx) { | 614 | switch (idx) { |
615 | case promptColIdx: | 615 | case promptColIdx: |
616 | pm = item->pixmap(promptColIdx); | 616 | pm = item->pixmap(promptColIdx); |
617 | if (pm) { | 617 | if (pm) { |
618 | int off = header()->sectionPos(0) + itemMargin() + | 618 | int off = header()->sectionPos(0) + itemMargin() + |
619 | treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); | 619 | treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); |
620 | if (x >= off && x < off + pm->width()) { | 620 | if (x >= off && x < off + pm->width()) { |
621 | if (item->goParent) { | 621 | if (item->goParent) { |
622 | emit parentSelected(); | 622 | emit parentSelected(); |
623 | break; | 623 | break; |
624 | } else if (!menu) | 624 | } else if (!menu) |
625 | break; | 625 | break; |
626 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 626 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
627 | if (ptype == P_MENU && rootEntry != menu && | 627 | if (ptype == P_MENU && rootEntry != menu && |
628 | mode != fullMode && mode != menuMode) | 628 | mode != fullMode && mode != menuMode) |
629 | emit menuSelected(menu); | 629 | emit menuSelected(menu); |
630 | else | 630 | else |
631 | changeValue(item); | 631 | changeValue(item); |
632 | } | 632 | } |
633 | } | 633 | } |
634 | break; | 634 | break; |
635 | case noColIdx: | 635 | case noColIdx: |
636 | setValue(item, no); | 636 | setValue(item, no); |
637 | break; | 637 | break; |
638 | case modColIdx: | 638 | case modColIdx: |
639 | setValue(item, mod); | 639 | setValue(item, mod); |
640 | break; | 640 | break; |
641 | case yesColIdx: | 641 | case yesColIdx: |
642 | setValue(item, yes); | 642 | setValue(item, yes); |
643 | break; | 643 | break; |
644 | case dataColIdx: | 644 | case dataColIdx: |
645 | changeValue(item); | 645 | changeValue(item); |
646 | break; | 646 | break; |
647 | } | 647 | } |
648 | 648 | ||
649 | skip: | 649 | skip: |
650 | //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); | 650 | //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); |
651 | Parent::contentsMouseReleaseEvent(e); | 651 | Parent::contentsMouseReleaseEvent(e); |
652 | } | 652 | } |
653 | 653 | ||
654 | void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) | 654 | void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) |
655 | { | 655 | { |
656 | //QPoint p(contentsToViewport(e->pos())); | 656 | //QPoint p(contentsToViewport(e->pos())); |
657 | //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); | 657 | //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); |
658 | Parent::contentsMouseMoveEvent(e); | 658 | Parent::contentsMouseMoveEvent(e); |
659 | } | 659 | } |
660 | 660 | ||
661 | void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) | 661 | void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) |
662 | { | 662 | { |
663 | QPoint p(contentsToViewport(e->pos())); | 663 | QPoint p(contentsToViewport(e->pos())); |
664 | ConfigItem* item = (ConfigItem*)itemAt(p); | 664 | ConfigItem* item = (ConfigItem*)itemAt(p); |
665 | struct menu *menu; | 665 | struct menu *menu; |
666 | enum prop_type ptype; | 666 | enum prop_type ptype; |
667 | 667 | ||
668 | if (!item) | 668 | if (!item) |
669 | goto skip; | 669 | goto skip; |
670 | if (item->goParent) { | 670 | if (item->goParent) { |
671 | emit parentSelected(); | 671 | emit parentSelected(); |
672 | goto skip; | 672 | goto skip; |
673 | } | 673 | } |
674 | menu = item->menu; | 674 | menu = item->menu; |
675 | if (!menu) | 675 | if (!menu) |
676 | goto skip; | 676 | goto skip; |
677 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 677 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
678 | if (ptype == P_MENU && (mode == singleMode || mode == symbolMode)) | 678 | if (ptype == P_MENU && (mode == singleMode || mode == symbolMode)) |
679 | emit menuSelected(menu); | 679 | emit menuSelected(menu); |
680 | else if (menu->sym) | 680 | else if (menu->sym) |
681 | changeValue(item); | 681 | changeValue(item); |
682 | 682 | ||
683 | skip: | 683 | skip: |
684 | //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); | 684 | //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); |
685 | Parent::contentsMouseDoubleClickEvent(e); | 685 | Parent::contentsMouseDoubleClickEvent(e); |
686 | } | 686 | } |
687 | 687 | ||
688 | void ConfigList::focusInEvent(QFocusEvent *e) | 688 | void ConfigList::focusInEvent(QFocusEvent *e) |
689 | { | 689 | { |
690 | Parent::focusInEvent(e); | 690 | Parent::focusInEvent(e); |
691 | 691 | ||
692 | QListViewItem* item = currentItem(); | 692 | QListViewItem* item = currentItem(); |
693 | if (!item) | 693 | if (!item) |
694 | return; | 694 | return; |
695 | 695 | ||
696 | setSelected(item, TRUE); | 696 | setSelected(item, TRUE); |
697 | emit gotFocus(); | 697 | emit gotFocus(); |
698 | } | 698 | } |
699 | 699 | ||
700 | ConfigView* ConfigView::viewList; | 700 | ConfigView* ConfigView::viewList; |
701 | 701 | ||
702 | ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview) | 702 | ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview) |
703 | : Parent(parent) | 703 | : Parent(parent) |
704 | { | 704 | { |
705 | list = new ConfigList(this, cview); | 705 | list = new ConfigList(this, cview); |
706 | lineEdit = new ConfigLineEdit(this); | 706 | lineEdit = new ConfigLineEdit(this); |
707 | lineEdit->hide(); | 707 | lineEdit->hide(); |
708 | 708 | ||
709 | this->nextView = viewList; | 709 | this->nextView = viewList; |
710 | viewList = this; | 710 | viewList = this; |
711 | } | 711 | } |
712 | 712 | ||
713 | ConfigView::~ConfigView(void) | 713 | ConfigView::~ConfigView(void) |
714 | { | 714 | { |
715 | ConfigView** vp; | 715 | ConfigView** vp; |
716 | 716 | ||
717 | for (vp = &viewList; *vp; vp = &(*vp)->nextView) { | 717 | for (vp = &viewList; *vp; vp = &(*vp)->nextView) { |
718 | if (*vp == this) { | 718 | if (*vp == this) { |
719 | *vp = nextView; | 719 | *vp = nextView; |
720 | break; | 720 | break; |
721 | } | 721 | } |
722 | } | 722 | } |
723 | } | 723 | } |
724 | 724 | ||
725 | void ConfigView::updateList(ConfigItem* item) | 725 | void ConfigView::updateList(ConfigItem* item) |
726 | { | 726 | { |
727 | ConfigView* v; | 727 | ConfigView* v; |
728 | 728 | ||
729 | for (v = viewList; v; v = v->nextView) | 729 | for (v = viewList; v; v = v->nextView) |
730 | v->list->updateList(item); | 730 | v->list->updateList(item); |
731 | } | 731 | } |
732 | 732 | ||
733 | void ConfigView::updateListAll(void) | 733 | void ConfigView::updateListAll(void) |
734 | { | 734 | { |
735 | ConfigView* v; | 735 | ConfigView* v; |
736 | 736 | ||
737 | for (v = viewList; v; v = v->nextView) | 737 | for (v = viewList; v; v = v->nextView) |
738 | v->list->updateListAll(); | 738 | v->list->updateListAll(); |
739 | } | 739 | } |
740 | 740 | ||
741 | /* | 741 | /* |
742 | * Construct the complete config widget | 742 | * Construct the complete config widget |
743 | */ | 743 | */ |
744 | ConfigMainWindow::ConfigMainWindow(void) | 744 | ConfigMainWindow::ConfigMainWindow(void) |
745 | { | 745 | { |
746 | QMenuBar* menu; | 746 | QMenuBar* menu; |
747 | QSplitter* split1; | 747 | QSplitter* split1; |
748 | QSplitter* split2; | 748 | QSplitter* split2; |
749 | bool ok; | 749 | bool ok; |
750 | int x, y, width, height; | 750 | int x, y, width, height; |
751 | 751 | ||
752 | QWidget *d = configApp->desktop(); | 752 | QWidget *d = configApp->desktop(); |
753 | 753 | ||
754 | #if QT_VERSION >= 300 | 754 | #if QT_VERSION >= 0x030000 |
755 | width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64); | 755 | width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64); |
756 | height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64); | 756 | height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64); |
757 | resize(width, height); | 757 | resize(width, height); |
758 | x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok); | 758 | x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok); |
759 | if (ok) | 759 | if (ok) |
760 | y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok); | 760 | y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok); |
761 | if (ok) | 761 | if (ok) |
762 | move(x, y); | 762 | move(x, y); |
763 | #else | 763 | #else |
764 | width = d->width() - 64; | 764 | width = d->width() - 64; |
765 | height = d->height() - 64; | 765 | height = d->height() - 64; |
766 | resize(width, height); | 766 | resize(width, height); |
767 | #endif | 767 | #endif |
768 | 768 | ||
769 | showDebug = false; | 769 | showDebug = false; |
770 | 770 | ||
771 | split1 = new QSplitter(this); | 771 | split1 = new QSplitter(this); |
772 | split1->setOrientation(QSplitter::Horizontal); | 772 | split1->setOrientation(QSplitter::Horizontal); |
773 | setCentralWidget(split1); | 773 | setCentralWidget(split1); |
774 | 774 | ||
775 | menuView = new ConfigView(split1, this); | 775 | menuView = new ConfigView(split1, this); |
776 | menuList = menuView->list; | 776 | menuList = menuView->list; |
777 | 777 | ||
778 | split2 = new QSplitter(split1); | 778 | split2 = new QSplitter(split1); |
779 | split2->setOrientation(QSplitter::Vertical); | 779 | split2->setOrientation(QSplitter::Vertical); |
780 | 780 | ||
781 | // create config tree | 781 | // create config tree |
782 | configView = new ConfigView(split2, this); | 782 | configView = new ConfigView(split2, this); |
783 | configList = configView->list; | 783 | configList = configView->list; |
784 | 784 | ||
785 | helpText = new QTextView(split2); | 785 | helpText = new QTextView(split2); |
786 | helpText->setTextFormat(Qt::RichText); | 786 | helpText->setTextFormat(Qt::RichText); |
787 | 787 | ||
788 | setTabOrder(configList, helpText); | 788 | setTabOrder(configList, helpText); |
789 | configList->setFocus(); | 789 | configList->setFocus(); |
790 | 790 | ||
791 | menu = menuBar(); | 791 | menu = menuBar(); |
792 | toolBar = new QToolBar("Tools", this); | 792 | toolBar = new QToolBar("Tools", this); |
793 | 793 | ||
794 | backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this); | 794 | backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this); |
795 | connect(backAction, SIGNAL(activated()), SLOT(goBack())); | 795 | connect(backAction, SIGNAL(activated()), SLOT(goBack())); |
796 | backAction->setEnabled(FALSE); | 796 | backAction->setEnabled(FALSE); |
797 | QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this); | 797 | QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this); |
798 | connect(quitAction, SIGNAL(activated()), SLOT(close())); | 798 | connect(quitAction, SIGNAL(activated()), SLOT(close())); |
799 | QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); | 799 | QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); |
800 | connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); | 800 | connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); |
801 | QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); | 801 | QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); |
802 | connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); | 802 | connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); |
803 | QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); | 803 | QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); |
804 | connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); | 804 | connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); |
805 | QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); | 805 | QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); |
806 | connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); | 806 | connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); |
807 | QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); | 807 | QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); |
808 | connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); | 808 | connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); |
809 | QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this); | 809 | QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this); |
810 | connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); | 810 | connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); |
811 | 811 | ||
812 | QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); | 812 | QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); |
813 | showNameAction->setToggleAction(TRUE); | 813 | showNameAction->setToggleAction(TRUE); |
814 | showNameAction->setOn(configList->showName); | 814 | showNameAction->setOn(configList->showName); |
815 | connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool))); | 815 | connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool))); |
816 | QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); | 816 | QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); |
817 | showRangeAction->setToggleAction(TRUE); | 817 | showRangeAction->setToggleAction(TRUE); |
818 | showRangeAction->setOn(configList->showRange); | 818 | showRangeAction->setOn(configList->showRange); |
819 | connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool))); | 819 | connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool))); |
820 | QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); | 820 | QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); |
821 | showDataAction->setToggleAction(TRUE); | 821 | showDataAction->setToggleAction(TRUE); |
822 | showDataAction->setOn(configList->showData); | 822 | showDataAction->setOn(configList->showData); |
823 | connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool))); | 823 | connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool))); |
824 | QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); | 824 | QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); |
825 | showAllAction->setToggleAction(TRUE); | 825 | showAllAction->setToggleAction(TRUE); |
826 | showAllAction->setOn(configList->showAll); | 826 | showAllAction->setOn(configList->showAll); |
827 | connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool))); | 827 | connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool))); |
828 | QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); | 828 | QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); |
829 | showDebugAction->setToggleAction(TRUE); | 829 | showDebugAction->setToggleAction(TRUE); |
830 | showDebugAction->setOn(showDebug); | 830 | showDebugAction->setOn(showDebug); |
831 | connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); | 831 | connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); |
832 | 832 | ||
833 | QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this); | 833 | QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this); |
834 | connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); | 834 | connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); |
835 | QAction *showAboutAction = new QAction(NULL, "About", 0, this); | 835 | QAction *showAboutAction = new QAction(NULL, "About", 0, this); |
836 | connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); | 836 | connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); |
837 | 837 | ||
838 | // init tool bar | 838 | // init tool bar |
839 | backAction->addTo(toolBar); | 839 | backAction->addTo(toolBar); |
840 | toolBar->addSeparator(); | 840 | toolBar->addSeparator(); |
841 | loadAction->addTo(toolBar); | 841 | loadAction->addTo(toolBar); |
842 | saveAction->addTo(toolBar); | 842 | saveAction->addTo(toolBar); |
843 | toolBar->addSeparator(); | 843 | toolBar->addSeparator(); |
844 | singleViewAction->addTo(toolBar); | 844 | singleViewAction->addTo(toolBar); |
845 | splitViewAction->addTo(toolBar); | 845 | splitViewAction->addTo(toolBar); |
846 | fullViewAction->addTo(toolBar); | 846 | fullViewAction->addTo(toolBar); |
847 | 847 | ||
848 | // create config menu | 848 | // create config menu |
849 | QPopupMenu* config = new QPopupMenu(this); | 849 | QPopupMenu* config = new QPopupMenu(this); |
850 | menu->insertItem("&File", config); | 850 | menu->insertItem("&File", config); |
851 | loadAction->addTo(config); | 851 | loadAction->addTo(config); |
852 | saveAction->addTo(config); | 852 | saveAction->addTo(config); |
853 | saveAsAction->addTo(config); | 853 | saveAsAction->addTo(config); |
854 | config->insertSeparator(); | 854 | config->insertSeparator(); |
855 | quitAction->addTo(config); | 855 | quitAction->addTo(config); |
856 | 856 | ||
857 | // create options menu | 857 | // create options menu |
858 | QPopupMenu* optionMenu = new QPopupMenu(this); | 858 | QPopupMenu* optionMenu = new QPopupMenu(this); |
859 | menu->insertItem("&Option", optionMenu); | 859 | menu->insertItem("&Option", optionMenu); |
860 | showNameAction->addTo(optionMenu); | 860 | showNameAction->addTo(optionMenu); |
861 | showRangeAction->addTo(optionMenu); | 861 | showRangeAction->addTo(optionMenu); |
862 | showDataAction->addTo(optionMenu); | 862 | showDataAction->addTo(optionMenu); |
863 | optionMenu->insertSeparator(); | 863 | optionMenu->insertSeparator(); |
864 | showAllAction->addTo(optionMenu); | 864 | showAllAction->addTo(optionMenu); |
865 | showDebugAction->addTo(optionMenu); | 865 | showDebugAction->addTo(optionMenu); |
866 | 866 | ||
867 | // create help menu | 867 | // create help menu |
868 | QPopupMenu* helpMenu = new QPopupMenu(this); | 868 | QPopupMenu* helpMenu = new QPopupMenu(this); |
869 | menu->insertSeparator(); | 869 | menu->insertSeparator(); |
870 | menu->insertItem("&Help", helpMenu); | 870 | menu->insertItem("&Help", helpMenu); |
871 | showIntroAction->addTo(helpMenu); | 871 | showIntroAction->addTo(helpMenu); |
872 | showAboutAction->addTo(helpMenu); | 872 | showAboutAction->addTo(helpMenu); |
873 | 873 | ||
874 | connect(configList, SIGNAL(menuSelected(struct menu *)), | 874 | connect(configList, SIGNAL(menuSelected(struct menu *)), |
875 | SLOT(changeMenu(struct menu *))); | 875 | SLOT(changeMenu(struct menu *))); |
876 | connect(configList, SIGNAL(parentSelected()), | 876 | connect(configList, SIGNAL(parentSelected()), |
877 | SLOT(goBack())); | 877 | SLOT(goBack())); |
878 | connect(menuList, SIGNAL(menuSelected(struct menu *)), | 878 | connect(menuList, SIGNAL(menuSelected(struct menu *)), |
879 | SLOT(changeMenu(struct menu *))); | 879 | SLOT(changeMenu(struct menu *))); |
880 | 880 | ||
881 | connect(configList, SIGNAL(gotFocus(void)), | 881 | connect(configList, SIGNAL(gotFocus(void)), |
882 | SLOT(listFocusChanged(void))); | 882 | SLOT(listFocusChanged(void))); |
883 | connect(menuList, SIGNAL(gotFocus(void)), | 883 | connect(menuList, SIGNAL(gotFocus(void)), |
884 | SLOT(listFocusChanged(void))); | 884 | SLOT(listFocusChanged(void))); |
885 | 885 | ||
886 | showSplitView(); | 886 | showSplitView(); |
887 | } | 887 | } |
888 | 888 | ||
889 | static QString print_filter(const char *str) | 889 | static QString print_filter(const char *str) |
890 | { | 890 | { |
891 | QRegExp re("[<>&\"\\n]"); | 891 | QRegExp re("[<>&\"\\n]"); |
892 | QString res = str; | 892 | QString res = str; |
893 | for (int i = 0; (i = res.find(re, i)) >= 0;) { | 893 | for (int i = 0; (i = res.find(re, i)) >= 0;) { |
894 | switch (res[i].latin1()) { | 894 | switch (res[i].latin1()) { |
895 | case '<': | 895 | case '<': |
896 | res.replace(i, 1, "<"); | 896 | res.replace(i, 1, "<"); |
897 | i += 4; | 897 | i += 4; |
898 | break; | 898 | break; |
899 | case '>': | 899 | case '>': |
900 | res.replace(i, 1, ">"); | 900 | res.replace(i, 1, ">"); |
901 | i += 4; | 901 | i += 4; |
902 | break; | 902 | break; |
903 | case '&': | 903 | case '&': |
904 | res.replace(i, 1, "&"); | 904 | res.replace(i, 1, "&"); |
905 | i += 5; | 905 | i += 5; |
906 | break; | 906 | break; |
907 | case '"': | 907 | case '"': |
908 | res.replace(i, 1, """); | 908 | res.replace(i, 1, """); |
909 | i += 6; | 909 | i += 6; |
910 | break; | 910 | break; |
911 | case '\n': | 911 | case '\n': |
912 | res.replace(i, 1, "<br>"); | 912 | res.replace(i, 1, "<br>"); |
913 | i += 4; | 913 | i += 4; |
914 | break; | 914 | break; |
915 | } | 915 | } |
916 | } | 916 | } |
917 | return res; | 917 | return res; |
918 | } | 918 | } |
919 | 919 | ||
920 | static void expr_print_help(void *data, const char *str) | 920 | static void expr_print_help(void *data, const char *str) |
921 | { | 921 | { |
922 | ((QString*)data)->append(print_filter(str)); | 922 | ((QString*)data)->append(print_filter(str)); |
923 | } | 923 | } |
924 | 924 | ||
925 | /* | 925 | /* |
926 | * display a new help entry as soon as a new menu entry is selected | 926 | * display a new help entry as soon as a new menu entry is selected |
927 | */ | 927 | */ |
928 | void ConfigMainWindow::setHelp(QListViewItem* item) | 928 | void ConfigMainWindow::setHelp(QListViewItem* item) |
929 | { | 929 | { |
930 | struct symbol* sym; | 930 | struct symbol* sym; |
931 | struct menu* menu = 0; | 931 | struct menu* menu = 0; |
932 | 932 | ||
933 | configList->parent()->lineEdit->hide(); | 933 | configList->parent()->lineEdit->hide(); |
934 | if (item) | 934 | if (item) |
935 | menu = ((ConfigItem*)item)->menu; | 935 | menu = ((ConfigItem*)item)->menu; |
936 | if (!menu) { | 936 | if (!menu) { |
937 | helpText->setText(NULL); | 937 | helpText->setText(NULL); |
938 | return; | 938 | return; |
939 | } | 939 | } |
940 | 940 | ||
941 | QString head, debug, help; | 941 | QString head, debug, help; |
942 | menu = ((ConfigItem*)item)->menu; | 942 | menu = ((ConfigItem*)item)->menu; |
943 | sym = menu->sym; | 943 | sym = menu->sym; |
944 | if (sym) { | 944 | if (sym) { |
945 | if (menu->prompt) { | 945 | if (menu->prompt) { |
946 | head += "<big><b>"; | 946 | head += "<big><b>"; |
947 | head += print_filter(menu->prompt->text); | 947 | head += print_filter(menu->prompt->text); |
948 | head += "</b></big>"; | 948 | head += "</b></big>"; |
949 | if (sym->name) { | 949 | if (sym->name) { |
950 | head += " ("; | 950 | head += " ("; |
951 | head += print_filter(sym->name); | 951 | head += print_filter(sym->name); |
952 | head += ")"; | 952 | head += ")"; |
953 | } | 953 | } |
954 | } else if (sym->name) { | 954 | } else if (sym->name) { |
955 | head += "<big><b>"; | 955 | head += "<big><b>"; |
956 | head += print_filter(sym->name); | 956 | head += print_filter(sym->name); |
957 | head += "</b></big>"; | 957 | head += "</b></big>"; |
958 | } | 958 | } |
959 | head += "<br><br>"; | 959 | head += "<br><br>"; |
960 | 960 | ||
961 | if (showDebug) { | 961 | if (showDebug) { |
962 | debug += "type: "; | 962 | debug += "type: "; |
963 | debug += print_filter(sym_type_name(sym->type)); | 963 | debug += print_filter(sym_type_name(sym->type)); |
964 | if (sym_is_choice(sym)) | 964 | if (sym_is_choice(sym)) |
965 | debug += " (choice)"; | 965 | debug += " (choice)"; |
966 | debug += "<br>"; | 966 | debug += "<br>"; |
967 | if (sym->rev_dep.expr) { | 967 | if (sym->rev_dep.expr) { |
968 | debug += "reverse dep: "; | 968 | debug += "reverse dep: "; |
969 | expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); | 969 | expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); |
970 | debug += "<br>"; | 970 | debug += "<br>"; |
971 | } | 971 | } |
972 | for (struct property *prop = sym->prop; prop; prop = prop->next) { | 972 | for (struct property *prop = sym->prop; prop; prop = prop->next) { |
973 | switch (prop->type) { | 973 | switch (prop->type) { |
974 | case P_PROMPT: | 974 | case P_PROMPT: |
975 | case P_MENU: | 975 | case P_MENU: |
976 | debug += "prompt: "; | 976 | debug += "prompt: "; |
977 | debug += print_filter(prop->text); | 977 | debug += print_filter(prop->text); |
978 | debug += "<br>"; | 978 | debug += "<br>"; |
979 | break; | 979 | break; |
980 | case P_DEFAULT: | 980 | case P_DEFAULT: |
981 | debug += "default: "; | 981 | debug += "default: "; |
982 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | 982 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); |
983 | debug += "<br>"; | 983 | debug += "<br>"; |
984 | break; | 984 | break; |
985 | case P_CHOICE: | 985 | case P_CHOICE: |
986 | if (sym_is_choice(sym)) { | 986 | if (sym_is_choice(sym)) { |
987 | debug += "choice: "; | 987 | debug += "choice: "; |
988 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | 988 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); |
989 | debug += "<br>"; | 989 | debug += "<br>"; |
990 | } | 990 | } |
991 | break; | 991 | break; |
992 | case P_SELECT: | 992 | case P_SELECT: |
993 | debug += "select: "; | 993 | debug += "select: "; |
994 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | 994 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); |
995 | debug += "<br>"; | 995 | debug += "<br>"; |
996 | break; | 996 | break; |
997 | case P_RANGE: | 997 | case P_RANGE: |
998 | debug += "range: "; | 998 | debug += "range: "; |
999 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | 999 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); |
1000 | debug += "<br>"; | 1000 | debug += "<br>"; |
1001 | break; | 1001 | break; |
1002 | default: | 1002 | default: |
1003 | debug += "unknown property: "; | 1003 | debug += "unknown property: "; |
1004 | debug += prop_get_type_name(prop->type); | 1004 | debug += prop_get_type_name(prop->type); |
1005 | debug += "<br>"; | 1005 | debug += "<br>"; |
1006 | } | 1006 | } |
1007 | if (prop->visible.expr) { | 1007 | if (prop->visible.expr) { |
1008 | debug += " dep: "; | 1008 | debug += " dep: "; |
1009 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); | 1009 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); |
1010 | debug += "<br>"; | 1010 | debug += "<br>"; |
1011 | } | 1011 | } |
1012 | } | 1012 | } |
1013 | debug += "<br>"; | 1013 | debug += "<br>"; |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | help = print_filter(sym->help); | 1016 | help = print_filter(sym->help); |
1017 | } else if (menu->prompt) { | 1017 | } else if (menu->prompt) { |
1018 | head += "<big><b>"; | 1018 | head += "<big><b>"; |
1019 | head += print_filter(menu->prompt->text); | 1019 | head += print_filter(menu->prompt->text); |
1020 | head += "</b></big><br><br>"; | 1020 | head += "</b></big><br><br>"; |
1021 | if (showDebug) { | 1021 | if (showDebug) { |
1022 | if (menu->prompt->visible.expr) { | 1022 | if (menu->prompt->visible.expr) { |
1023 | debug += " dep: "; | 1023 | debug += " dep: "; |
1024 | expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); | 1024 | expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); |
1025 | debug += "<br><br>"; | 1025 | debug += "<br><br>"; |
1026 | } | 1026 | } |
1027 | } | 1027 | } |
1028 | } | 1028 | } |
1029 | if (showDebug) | 1029 | if (showDebug) |
1030 | debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno); | 1030 | debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno); |
1031 | helpText->setText(head + debug + help); | 1031 | helpText->setText(head + debug + help); |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | void ConfigMainWindow::loadConfig(void) | 1034 | void ConfigMainWindow::loadConfig(void) |
1035 | { | 1035 | { |
1036 | QString s = QFileDialog::getOpenFileName(".config", NULL, this); | 1036 | QString s = QFileDialog::getOpenFileName(".config", NULL, this); |
1037 | if (s.isNull()) | 1037 | if (s.isNull()) |
1038 | return; | 1038 | return; |
1039 | if (conf_read(s.latin1())) | 1039 | if (conf_read(s.latin1())) |
1040 | QMessageBox::information(this, "qconf", "Unable to load configuration!"); | 1040 | QMessageBox::information(this, "qconf", "Unable to load configuration!"); |
1041 | ConfigView::updateListAll(); | 1041 | ConfigView::updateListAll(); |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | void ConfigMainWindow::saveConfig(void) | 1044 | void ConfigMainWindow::saveConfig(void) |
1045 | { | 1045 | { |
1046 | if (conf_write(NULL)) | 1046 | if (conf_write(NULL)) |
1047 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); | 1047 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | void ConfigMainWindow::saveConfigAs(void) | 1050 | void ConfigMainWindow::saveConfigAs(void) |
1051 | { | 1051 | { |
1052 | QString s = QFileDialog::getSaveFileName(".config", NULL, this); | 1052 | QString s = QFileDialog::getSaveFileName(".config", NULL, this); |
1053 | if (s.isNull()) | 1053 | if (s.isNull()) |
1054 | return; | 1054 | return; |
1055 | if (conf_write(s.latin1())) | 1055 | if (conf_write(s.latin1())) |
1056 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); | 1056 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | void ConfigMainWindow::changeMenu(struct menu *menu) | 1059 | void ConfigMainWindow::changeMenu(struct menu *menu) |
1060 | { | 1060 | { |
1061 | configList->setRootMenu(menu); | 1061 | configList->setRootMenu(menu); |
1062 | backAction->setEnabled(TRUE); | 1062 | backAction->setEnabled(TRUE); |
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | void ConfigMainWindow::listFocusChanged(void) | 1065 | void ConfigMainWindow::listFocusChanged(void) |
1066 | { | 1066 | { |
1067 | if (menuList->hasFocus()) { | 1067 | if (menuList->hasFocus()) { |
1068 | if (menuList->mode == menuMode) | 1068 | if (menuList->mode == menuMode) |
1069 | configList->clearSelection(); | 1069 | configList->clearSelection(); |
1070 | setHelp(menuList->selectedItem()); | 1070 | setHelp(menuList->selectedItem()); |
1071 | } else if (configList->hasFocus()) { | 1071 | } else if (configList->hasFocus()) { |
1072 | setHelp(configList->selectedItem()); | 1072 | setHelp(configList->selectedItem()); |
1073 | } | 1073 | } |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | void ConfigMainWindow::goBack(void) | 1076 | void ConfigMainWindow::goBack(void) |
1077 | { | 1077 | { |
1078 | ConfigItem* item; | 1078 | ConfigItem* item; |
1079 | 1079 | ||
1080 | configList->setParentMenu(); | 1080 | configList->setParentMenu(); |
1081 | if (configList->rootEntry == &rootmenu) | 1081 | if (configList->rootEntry == &rootmenu) |
1082 | backAction->setEnabled(FALSE); | 1082 | backAction->setEnabled(FALSE); |
1083 | item = (ConfigItem*)menuList->selectedItem(); | 1083 | item = (ConfigItem*)menuList->selectedItem(); |
1084 | while (item) { | 1084 | while (item) { |
1085 | if (item->menu == configList->rootEntry) { | 1085 | if (item->menu == configList->rootEntry) { |
1086 | menuList->setSelected(item, TRUE); | 1086 | menuList->setSelected(item, TRUE); |
1087 | break; | 1087 | break; |
1088 | } | 1088 | } |
1089 | item = (ConfigItem*)item->parent(); | 1089 | item = (ConfigItem*)item->parent(); |
1090 | } | 1090 | } |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | void ConfigMainWindow::showSingleView(void) | 1093 | void ConfigMainWindow::showSingleView(void) |
1094 | { | 1094 | { |
1095 | menuView->hide(); | 1095 | menuView->hide(); |
1096 | menuList->setRootMenu(0); | 1096 | menuList->setRootMenu(0); |
1097 | configList->mode = singleMode; | 1097 | configList->mode = singleMode; |
1098 | if (configList->rootEntry == &rootmenu) | 1098 | if (configList->rootEntry == &rootmenu) |
1099 | configList->updateListAll(); | 1099 | configList->updateListAll(); |
1100 | else | 1100 | else |
1101 | configList->setRootMenu(&rootmenu); | 1101 | configList->setRootMenu(&rootmenu); |
1102 | configList->setAllOpen(TRUE); | 1102 | configList->setAllOpen(TRUE); |
1103 | configList->setFocus(); | 1103 | configList->setFocus(); |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | void ConfigMainWindow::showSplitView(void) | 1106 | void ConfigMainWindow::showSplitView(void) |
1107 | { | 1107 | { |
1108 | configList->mode = symbolMode; | 1108 | configList->mode = symbolMode; |
1109 | if (configList->rootEntry == &rootmenu) | 1109 | if (configList->rootEntry == &rootmenu) |
1110 | configList->updateListAll(); | 1110 | configList->updateListAll(); |
1111 | else | 1111 | else |
1112 | configList->setRootMenu(&rootmenu); | 1112 | configList->setRootMenu(&rootmenu); |
1113 | configList->setAllOpen(TRUE); | 1113 | configList->setAllOpen(TRUE); |
1114 | configApp->processEvents(); | 1114 | configApp->processEvents(); |
1115 | menuList->mode = menuMode; | 1115 | menuList->mode = menuMode; |
1116 | menuList->setRootMenu(&rootmenu); | 1116 | menuList->setRootMenu(&rootmenu); |
1117 | menuList->setAllOpen(TRUE); | 1117 | menuList->setAllOpen(TRUE); |
1118 | menuView->show(); | 1118 | menuView->show(); |
1119 | menuList->setFocus(); | 1119 | menuList->setFocus(); |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | void ConfigMainWindow::showFullView(void) | 1122 | void ConfigMainWindow::showFullView(void) |
1123 | { | 1123 | { |
1124 | menuView->hide(); | 1124 | menuView->hide(); |
1125 | menuList->setRootMenu(0); | 1125 | menuList->setRootMenu(0); |
1126 | configList->mode = fullMode; | 1126 | configList->mode = fullMode; |
1127 | if (configList->rootEntry == &rootmenu) | 1127 | if (configList->rootEntry == &rootmenu) |
1128 | configList->updateListAll(); | 1128 | configList->updateListAll(); |
1129 | else | 1129 | else |
1130 | configList->setRootMenu(&rootmenu); | 1130 | configList->setRootMenu(&rootmenu); |
1131 | configList->setAllOpen(FALSE); | 1131 | configList->setAllOpen(FALSE); |
1132 | configList->setFocus(); | 1132 | configList->setFocus(); |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | void ConfigMainWindow::setShowAll(bool b) | 1135 | void ConfigMainWindow::setShowAll(bool b) |
1136 | { | 1136 | { |
1137 | if (configList->showAll == b) | 1137 | if (configList->showAll == b) |
1138 | return; | 1138 | return; |
1139 | configList->showAll = b; | 1139 | configList->showAll = b; |
1140 | configList->updateListAll(); | 1140 | configList->updateListAll(); |
1141 | menuList->showAll = b; | 1141 | menuList->showAll = b; |
1142 | menuList->updateListAll(); | 1142 | menuList->updateListAll(); |
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | void ConfigMainWindow::setShowDebug(bool b) | 1145 | void ConfigMainWindow::setShowDebug(bool b) |
1146 | { | 1146 | { |
1147 | if (showDebug == b) | 1147 | if (showDebug == b) |
1148 | return; | 1148 | return; |
1149 | showDebug = b; | 1149 | showDebug = b; |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | void ConfigMainWindow::setShowName(bool b) | 1152 | void ConfigMainWindow::setShowName(bool b) |
1153 | { | 1153 | { |
1154 | if (configList->showName == b) | 1154 | if (configList->showName == b) |
1155 | return; | 1155 | return; |
1156 | configList->showName = b; | 1156 | configList->showName = b; |
1157 | configList->reinit(); | 1157 | configList->reinit(); |
1158 | menuList->showName = b; | 1158 | menuList->showName = b; |
1159 | menuList->reinit(); | 1159 | menuList->reinit(); |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | void ConfigMainWindow::setShowRange(bool b) | 1162 | void ConfigMainWindow::setShowRange(bool b) |
1163 | { | 1163 | { |
1164 | if (configList->showRange == b) | 1164 | if (configList->showRange == b) |
1165 | return; | 1165 | return; |
1166 | configList->showRange = b; | 1166 | configList->showRange = b; |
1167 | configList->reinit(); | 1167 | configList->reinit(); |
1168 | menuList->showRange = b; | 1168 | menuList->showRange = b; |
1169 | menuList->reinit(); | 1169 | menuList->reinit(); |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | void ConfigMainWindow::setShowData(bool b) | 1172 | void ConfigMainWindow::setShowData(bool b) |
1173 | { | 1173 | { |
1174 | if (configList->showData == b) | 1174 | if (configList->showData == b) |
1175 | return; | 1175 | return; |
1176 | configList->showData = b; | 1176 | configList->showData = b; |
1177 | configList->reinit(); | 1177 | configList->reinit(); |
1178 | menuList->showData = b; | 1178 | menuList->showData = b; |
1179 | menuList->reinit(); | 1179 | menuList->reinit(); |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | /* | 1182 | /* |
1183 | * ask for saving configuration before quitting | 1183 | * ask for saving configuration before quitting |
1184 | * TODO ask only when something changed | 1184 | * TODO ask only when something changed |
1185 | */ | 1185 | */ |
1186 | void ConfigMainWindow::closeEvent(QCloseEvent* e) | 1186 | void ConfigMainWindow::closeEvent(QCloseEvent* e) |
1187 | { | 1187 | { |
1188 | if (!sym_change_count) { | 1188 | if (!sym_change_count) { |
1189 | e->accept(); | 1189 | e->accept(); |
1190 | return; | 1190 | return; |
1191 | } | 1191 | } |
1192 | QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, | 1192 | QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, |
1193 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); | 1193 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); |
1194 | mb.setButtonText(QMessageBox::Yes, "&Save Changes"); | 1194 | mb.setButtonText(QMessageBox::Yes, "&Save Changes"); |
1195 | mb.setButtonText(QMessageBox::No, "&Discard Changes"); | 1195 | mb.setButtonText(QMessageBox::No, "&Discard Changes"); |
1196 | mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); | 1196 | mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); |
1197 | switch (mb.exec()) { | 1197 | switch (mb.exec()) { |
1198 | case QMessageBox::Yes: | 1198 | case QMessageBox::Yes: |
1199 | conf_write(NULL); | 1199 | conf_write(NULL); |
1200 | case QMessageBox::No: | 1200 | case QMessageBox::No: |
1201 | e->accept(); | 1201 | e->accept(); |
1202 | break; | 1202 | break; |
1203 | case QMessageBox::Cancel: | 1203 | case QMessageBox::Cancel: |
1204 | e->ignore(); | 1204 | e->ignore(); |
1205 | break; | 1205 | break; |
1206 | } | 1206 | } |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | void ConfigMainWindow::showIntro(void) | 1209 | void ConfigMainWindow::showIntro(void) |
1210 | { | 1210 | { |
1211 | static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" | 1211 | static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" |
1212 | "For each option, a blank box indicates the feature is disabled, a check\n" | 1212 | "For each option, a blank box indicates the feature is disabled, a check\n" |
1213 | "indicates it is enabled, and a dot indicates that it is to be compiled\n" | 1213 | "indicates it is enabled, and a dot indicates that it is to be compiled\n" |
1214 | "as a module. Clicking on the box will cycle through the three states.\n\n" | 1214 | "as a module. Clicking on the box will cycle through the three states.\n\n" |
1215 | "If you do not see an option (e.g., a device driver) that you believe\n" | 1215 | "If you do not see an option (e.g., a device driver) that you believe\n" |
1216 | "should be present, try turning on Show All Options under the Options menu.\n" | 1216 | "should be present, try turning on Show All Options under the Options menu.\n" |
1217 | "Although there is no cross reference yet to help you figure out what other\n" | 1217 | "Although there is no cross reference yet to help you figure out what other\n" |
1218 | "options must be enabled to support the option you are interested in, you can\n" | 1218 | "options must be enabled to support the option you are interested in, you can\n" |
1219 | "still view the help of a grayed-out option.\n\n" | 1219 | "still view the help of a grayed-out option.\n\n" |
1220 | "Toggling Show Debug Info under the Options menu will show the dependencies,\n" | 1220 | "Toggling Show Debug Info under the Options menu will show the dependencies,\n" |
1221 | "which you can then match by examining other options.\n\n"; | 1221 | "which you can then match by examining other options.\n\n"; |
1222 | 1222 | ||
1223 | QMessageBox::information(this, "qconf", str); | 1223 | QMessageBox::information(this, "qconf", str); |
1224 | } | 1224 | } |
1225 | 1225 | ||
1226 | void ConfigMainWindow::showAbout(void) | 1226 | void ConfigMainWindow::showAbout(void) |
1227 | { | 1227 | { |
1228 | static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n" | 1228 | static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n" |
1229 | "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; | 1229 | "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; |
1230 | 1230 | ||
1231 | QMessageBox::information(this, "qconf", str); | 1231 | QMessageBox::information(this, "qconf", str); |
1232 | } | 1232 | } |
1233 | 1233 | ||
1234 | void fixup_rootmenu(struct menu *menu) | 1234 | void fixup_rootmenu(struct menu *menu) |
1235 | { | 1235 | { |
1236 | struct menu *child; | 1236 | struct menu *child; |
1237 | static int menu_cnt = 0; | 1237 | static int menu_cnt = 0; |
1238 | 1238 | ||
1239 | menu->flags |= MENU_ROOT; | 1239 | menu->flags |= MENU_ROOT; |
1240 | for (child = menu->list; child; child = child->next) { | 1240 | for (child = menu->list; child; child = child->next) { |
1241 | if (child->prompt && child->prompt->type == P_MENU) { | 1241 | if (child->prompt && child->prompt->type == P_MENU) { |
1242 | menu_cnt++; | 1242 | menu_cnt++; |
1243 | fixup_rootmenu(child); | 1243 | fixup_rootmenu(child); |
1244 | menu_cnt--; | 1244 | menu_cnt--; |
1245 | } else if (!menu_cnt) | 1245 | } else if (!menu_cnt) |
1246 | fixup_rootmenu(child); | 1246 | fixup_rootmenu(child); |
1247 | } | 1247 | } |
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | static const char *progname; | 1250 | static const char *progname; |
1251 | 1251 | ||
1252 | static void usage(void) | 1252 | static void usage(void) |
1253 | { | 1253 | { |
1254 | printf("%s <config>\n", progname); | 1254 | printf("%s <config>\n", progname); |
1255 | exit(0); | 1255 | exit(0); |
1256 | } | 1256 | } |
1257 | 1257 | ||
1258 | int main(int ac, char** av) | 1258 | int main(int ac, char** av) |
1259 | { | 1259 | { |
1260 | ConfigMainWindow* v; | 1260 | ConfigMainWindow* v; |
1261 | const char *name; | 1261 | const char *name; |
1262 | 1262 | ||
1263 | #ifndef LKC_DIRECT_LINK | 1263 | #ifndef LKC_DIRECT_LINK |
1264 | kconfig_load(); | 1264 | kconfig_load(); |
1265 | #endif | 1265 | #endif |
1266 | 1266 | ||
1267 | progname = av[0]; | 1267 | progname = av[0]; |
1268 | configApp = new QApplication(ac, av); | 1268 | configApp = new QApplication(ac, av); |
1269 | #if QT_VERSION >= 300 | 1269 | #if QT_VERSION >= 0x030000 |
1270 | configSettings = new QSettings; | 1270 | configSettings = new QSettings; |
1271 | #endif | 1271 | #endif |
1272 | if (ac > 1 && av[1][0] == '-') { | 1272 | if (ac > 1 && av[1][0] == '-') { |
1273 | switch (av[1][1]) { | 1273 | switch (av[1][1]) { |
1274 | case 'h': | 1274 | case 'h': |
1275 | case '?': | 1275 | case '?': |
1276 | usage(); | 1276 | usage(); |
1277 | } | 1277 | } |
1278 | name = av[2]; | 1278 | name = av[2]; |
1279 | } else | 1279 | } else |
1280 | name = av[1]; | 1280 | name = av[1]; |
1281 | if (!name) | 1281 | if (!name) |
1282 | usage(); | 1282 | usage(); |
1283 | 1283 | ||
1284 | conf_parse(name); | 1284 | conf_parse(name); |
1285 | fixup_rootmenu(&rootmenu); | 1285 | fixup_rootmenu(&rootmenu); |
1286 | conf_read(NULL); | 1286 | conf_read(NULL); |
1287 | //zconfdump(stdout); | 1287 | //zconfdump(stdout); |
1288 | 1288 | ||
1289 | v = new ConfigMainWindow(); | 1289 | v = new ConfigMainWindow(); |
1290 | 1290 | ||
1291 | //zconfdump(stdout); | 1291 | //zconfdump(stdout); |
1292 | v->show(); | 1292 | v->show(); |
1293 | configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); | 1293 | configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); |
1294 | configApp->exec(); | 1294 | configApp->exec(); |
1295 | 1295 | ||
1296 | #if QT_VERSION >= 300 | 1296 | #if QT_VERSION >= 0x030000 |
1297 | configSettings->writeEntry("/kconfig/qconf/window x", v->pos().x()); | 1297 | configSettings->writeEntry("/kconfig/qconf/window x", v->pos().x()); |
1298 | configSettings->writeEntry("/kconfig/qconf/window y", v->pos().y()); | 1298 | configSettings->writeEntry("/kconfig/qconf/window y", v->pos().y()); |
1299 | configSettings->writeEntry("/kconfig/qconf/window width", v->size().width()); | 1299 | configSettings->writeEntry("/kconfig/qconf/window width", v->size().width()); |
1300 | configSettings->writeEntry("/kconfig/qconf/window height", v->size().height()); | 1300 | configSettings->writeEntry("/kconfig/qconf/window height", v->size().height()); |
1301 | delete configSettings; | 1301 | delete configSettings; |
1302 | #endif | 1302 | #endif |
1303 | return 0; | 1303 | return 0; |
1304 | } | 1304 | } |
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index c548884..dee5254 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h | |||
@@ -1,238 +1,238 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
3 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <qlistview.h> | 6 | #include <qlistview.h> |
7 | 7 | ||
8 | class ConfigList; | 8 | class ConfigList; |
9 | class ConfigItem; | 9 | class ConfigItem; |
10 | class ConfigLineEdit; | 10 | class ConfigLineEdit; |
11 | class ConfigMainWindow; | 11 | class ConfigMainWindow; |
12 | 12 | ||
13 | class ConfigView : public QVBox { | 13 | class ConfigView : public QVBox { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | typedef class QVBox Parent; | 15 | typedef class QVBox Parent; |
16 | public: | 16 | public: |
17 | ConfigView(QWidget* parent, ConfigMainWindow* cview); | 17 | ConfigView(QWidget* parent, ConfigMainWindow* cview); |
18 | ~ConfigView(void); | 18 | ~ConfigView(void); |
19 | static void updateList(ConfigItem* item); | 19 | static void updateList(ConfigItem* item); |
20 | static void updateListAll(void); | 20 | static void updateListAll(void); |
21 | 21 | ||
22 | public: | 22 | public: |
23 | ConfigList* list; | 23 | ConfigList* list; |
24 | ConfigLineEdit* lineEdit; | 24 | ConfigLineEdit* lineEdit; |
25 | 25 | ||
26 | static ConfigView* viewList; | 26 | static ConfigView* viewList; |
27 | ConfigView* nextView; | 27 | ConfigView* nextView; |
28 | }; | 28 | }; |
29 | 29 | ||
30 | enum colIdx { | 30 | enum colIdx { |
31 | promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr | 31 | promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr |
32 | }; | 32 | }; |
33 | enum listMode { | 33 | enum listMode { |
34 | singleMode, menuMode, symbolMode, fullMode | 34 | singleMode, menuMode, symbolMode, fullMode |
35 | }; | 35 | }; |
36 | 36 | ||
37 | class ConfigList : public QListView { | 37 | class ConfigList : public QListView { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | typedef class QListView Parent; | 39 | typedef class QListView Parent; |
40 | public: | 40 | public: |
41 | ConfigList(ConfigView* p, ConfigMainWindow* cview); | 41 | ConfigList(ConfigView* p, ConfigMainWindow* cview); |
42 | void reinit(void); | 42 | void reinit(void); |
43 | ConfigView* parent(void) const | 43 | ConfigView* parent(void) const |
44 | { | 44 | { |
45 | return (ConfigView*)Parent::parent(); | 45 | return (ConfigView*)Parent::parent(); |
46 | } | 46 | } |
47 | 47 | ||
48 | protected: | 48 | protected: |
49 | ConfigMainWindow* cview; | 49 | ConfigMainWindow* cview; |
50 | 50 | ||
51 | void keyPressEvent(QKeyEvent *e); | 51 | void keyPressEvent(QKeyEvent *e); |
52 | void contentsMousePressEvent(QMouseEvent *e); | 52 | void contentsMousePressEvent(QMouseEvent *e); |
53 | void contentsMouseReleaseEvent(QMouseEvent *e); | 53 | void contentsMouseReleaseEvent(QMouseEvent *e); |
54 | void contentsMouseMoveEvent(QMouseEvent *e); | 54 | void contentsMouseMoveEvent(QMouseEvent *e); |
55 | void contentsMouseDoubleClickEvent(QMouseEvent *e); | 55 | void contentsMouseDoubleClickEvent(QMouseEvent *e); |
56 | void focusInEvent(QFocusEvent *e); | 56 | void focusInEvent(QFocusEvent *e); |
57 | public slots: | 57 | public slots: |
58 | void setRootMenu(struct menu *menu); | 58 | void setRootMenu(struct menu *menu); |
59 | 59 | ||
60 | void updateList(ConfigItem *item); | 60 | void updateList(ConfigItem *item); |
61 | void setValue(ConfigItem* item, tristate val); | 61 | void setValue(ConfigItem* item, tristate val); |
62 | void changeValue(ConfigItem* item); | 62 | void changeValue(ConfigItem* item); |
63 | void updateSelection(void); | 63 | void updateSelection(void); |
64 | signals: | 64 | signals: |
65 | void menuSelected(struct menu *menu); | 65 | void menuSelected(struct menu *menu); |
66 | void parentSelected(void); | 66 | void parentSelected(void); |
67 | void gotFocus(void); | 67 | void gotFocus(void); |
68 | 68 | ||
69 | public: | 69 | public: |
70 | void updateListAll(void) | 70 | void updateListAll(void) |
71 | { | 71 | { |
72 | updateAll = true; | 72 | updateAll = true; |
73 | updateList(NULL); | 73 | updateList(NULL); |
74 | updateAll = false; | 74 | updateAll = false; |
75 | } | 75 | } |
76 | ConfigList* listView() | 76 | ConfigList* listView() |
77 | { | 77 | { |
78 | return this; | 78 | return this; |
79 | } | 79 | } |
80 | ConfigItem* firstChild() const | 80 | ConfigItem* firstChild() const |
81 | { | 81 | { |
82 | return (ConfigItem *)Parent::firstChild(); | 82 | return (ConfigItem *)Parent::firstChild(); |
83 | } | 83 | } |
84 | int mapIdx(colIdx idx) | 84 | int mapIdx(colIdx idx) |
85 | { | 85 | { |
86 | return colMap[idx]; | 86 | return colMap[idx]; |
87 | } | 87 | } |
88 | void addColumn(colIdx idx, const QString& label) | 88 | void addColumn(colIdx idx, const QString& label) |
89 | { | 89 | { |
90 | colMap[idx] = Parent::addColumn(label); | 90 | colMap[idx] = Parent::addColumn(label); |
91 | colRevMap[colMap[idx]] = idx; | 91 | colRevMap[colMap[idx]] = idx; |
92 | } | 92 | } |
93 | void removeColumn(colIdx idx) | 93 | void removeColumn(colIdx idx) |
94 | { | 94 | { |
95 | int col = colMap[idx]; | 95 | int col = colMap[idx]; |
96 | if (col >= 0) { | 96 | if (col >= 0) { |
97 | Parent::removeColumn(col); | 97 | Parent::removeColumn(col); |
98 | colRevMap[col] = colMap[idx] = -1; | 98 | colRevMap[col] = colMap[idx] = -1; |
99 | } | 99 | } |
100 | } | 100 | } |
101 | void setAllOpen(bool open); | 101 | void setAllOpen(bool open); |
102 | void setParentMenu(void); | 102 | void setParentMenu(void); |
103 | 103 | ||
104 | template <class P> | 104 | template <class P> |
105 | void ConfigList::updateMenuList(P*, struct menu*); | 105 | void ConfigList::updateMenuList(P*, struct menu*); |
106 | 106 | ||
107 | bool updateAll; | 107 | bool updateAll; |
108 | 108 | ||
109 | QPixmap symbolYesPix, symbolModPix, symbolNoPix; | 109 | QPixmap symbolYesPix, symbolModPix, symbolNoPix; |
110 | QPixmap choiceYesPix, choiceNoPix; | 110 | QPixmap choiceYesPix, choiceNoPix; |
111 | QPixmap menuPix, menuInvPix, menuBackPix, voidPix; | 111 | QPixmap menuPix, menuInvPix, menuBackPix, voidPix; |
112 | 112 | ||
113 | bool showAll, showName, showRange, showData; | 113 | bool showAll, showName, showRange, showData; |
114 | enum listMode mode; | 114 | enum listMode mode; |
115 | struct menu *rootEntry; | 115 | struct menu *rootEntry; |
116 | QColorGroup disabledColorGroup; | 116 | QColorGroup disabledColorGroup; |
117 | QColorGroup inactivedColorGroup; | 117 | QColorGroup inactivedColorGroup; |
118 | 118 | ||
119 | private: | 119 | private: |
120 | int colMap[colNr]; | 120 | int colMap[colNr]; |
121 | int colRevMap[colNr]; | 121 | int colRevMap[colNr]; |
122 | }; | 122 | }; |
123 | 123 | ||
124 | class ConfigItem : public QListViewItem { | 124 | class ConfigItem : public QListViewItem { |
125 | typedef class QListViewItem Parent; | 125 | typedef class QListViewItem Parent; |
126 | public: | 126 | public: |
127 | ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v) | 127 | ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v) |
128 | : Parent(parent, after), menu(m), visible(v), goParent(false) | 128 | : Parent(parent, after), menu(m), visible(v), goParent(false) |
129 | { | 129 | { |
130 | init(); | 130 | init(); |
131 | } | 131 | } |
132 | ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) | 132 | ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) |
133 | : Parent(parent, after), menu(m), visible(v), goParent(false) | 133 | : Parent(parent, after), menu(m), visible(v), goParent(false) |
134 | { | 134 | { |
135 | init(); | 135 | init(); |
136 | } | 136 | } |
137 | ConfigItem(QListView *parent, ConfigItem *after, bool v) | 137 | ConfigItem(QListView *parent, ConfigItem *after, bool v) |
138 | : Parent(parent, after), menu(0), visible(v), goParent(true) | 138 | : Parent(parent, after), menu(0), visible(v), goParent(true) |
139 | { | 139 | { |
140 | init(); | 140 | init(); |
141 | } | 141 | } |
142 | ~ConfigItem(void); | 142 | ~ConfigItem(void); |
143 | void init(void); | 143 | void init(void); |
144 | #if QT_VERSION >= 300 | 144 | #if QT_VERSION >= 0x030000 |
145 | void okRename(int col); | 145 | void okRename(int col); |
146 | #endif | 146 | #endif |
147 | void updateMenu(void); | 147 | void updateMenu(void); |
148 | void testUpdateMenu(bool v); | 148 | void testUpdateMenu(bool v); |
149 | ConfigList* listView() const | 149 | ConfigList* listView() const |
150 | { | 150 | { |
151 | return (ConfigList*)Parent::listView(); | 151 | return (ConfigList*)Parent::listView(); |
152 | } | 152 | } |
153 | ConfigItem* firstChild() const | 153 | ConfigItem* firstChild() const |
154 | { | 154 | { |
155 | return (ConfigItem *)Parent::firstChild(); | 155 | return (ConfigItem *)Parent::firstChild(); |
156 | } | 156 | } |
157 | ConfigItem* nextSibling() const | 157 | ConfigItem* nextSibling() const |
158 | { | 158 | { |
159 | return (ConfigItem *)Parent::nextSibling(); | 159 | return (ConfigItem *)Parent::nextSibling(); |
160 | } | 160 | } |
161 | void setText(colIdx idx, const QString& text) | 161 | void setText(colIdx idx, const QString& text) |
162 | { | 162 | { |
163 | Parent::setText(listView()->mapIdx(idx), text); | 163 | Parent::setText(listView()->mapIdx(idx), text); |
164 | } | 164 | } |
165 | QString text(colIdx idx) const | 165 | QString text(colIdx idx) const |
166 | { | 166 | { |
167 | return Parent::text(listView()->mapIdx(idx)); | 167 | return Parent::text(listView()->mapIdx(idx)); |
168 | } | 168 | } |
169 | void setPixmap(colIdx idx, const QPixmap& pm) | 169 | void setPixmap(colIdx idx, const QPixmap& pm) |
170 | { | 170 | { |
171 | Parent::setPixmap(listView()->mapIdx(idx), pm); | 171 | Parent::setPixmap(listView()->mapIdx(idx), pm); |
172 | } | 172 | } |
173 | const QPixmap* pixmap(colIdx idx) const | 173 | const QPixmap* pixmap(colIdx idx) const |
174 | { | 174 | { |
175 | return Parent::pixmap(listView()->mapIdx(idx)); | 175 | return Parent::pixmap(listView()->mapIdx(idx)); |
176 | } | 176 | } |
177 | void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); | 177 | void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); |
178 | 178 | ||
179 | ConfigItem* nextItem; | 179 | ConfigItem* nextItem; |
180 | struct menu *menu; | 180 | struct menu *menu; |
181 | bool visible; | 181 | bool visible; |
182 | bool goParent; | 182 | bool goParent; |
183 | }; | 183 | }; |
184 | 184 | ||
185 | class ConfigLineEdit : public QLineEdit { | 185 | class ConfigLineEdit : public QLineEdit { |
186 | Q_OBJECT | 186 | Q_OBJECT |
187 | typedef class QLineEdit Parent; | 187 | typedef class QLineEdit Parent; |
188 | public: | 188 | public: |
189 | ConfigLineEdit(ConfigView* parent) | 189 | ConfigLineEdit(ConfigView* parent) |
190 | : Parent(parent) | 190 | : Parent(parent) |
191 | { } | 191 | { } |
192 | ConfigView* parent(void) const | 192 | ConfigView* parent(void) const |
193 | { | 193 | { |
194 | return (ConfigView*)Parent::parent(); | 194 | return (ConfigView*)Parent::parent(); |
195 | } | 195 | } |
196 | void show(ConfigItem *i); | 196 | void show(ConfigItem *i); |
197 | void keyPressEvent(QKeyEvent *e); | 197 | void keyPressEvent(QKeyEvent *e); |
198 | 198 | ||
199 | public: | 199 | public: |
200 | ConfigItem *item; | 200 | ConfigItem *item; |
201 | }; | 201 | }; |
202 | 202 | ||
203 | class ConfigMainWindow : public QMainWindow { | 203 | class ConfigMainWindow : public QMainWindow { |
204 | Q_OBJECT | 204 | Q_OBJECT |
205 | public: | 205 | public: |
206 | ConfigMainWindow(void); | 206 | ConfigMainWindow(void); |
207 | public slots: | 207 | public slots: |
208 | void setHelp(QListViewItem* item); | 208 | void setHelp(QListViewItem* item); |
209 | void changeMenu(struct menu *); | 209 | void changeMenu(struct menu *); |
210 | void listFocusChanged(void); | 210 | void listFocusChanged(void); |
211 | void goBack(void); | 211 | void goBack(void); |
212 | void loadConfig(void); | 212 | void loadConfig(void); |
213 | void saveConfig(void); | 213 | void saveConfig(void); |
214 | void saveConfigAs(void); | 214 | void saveConfigAs(void); |
215 | void showSingleView(void); | 215 | void showSingleView(void); |
216 | void showSplitView(void); | 216 | void showSplitView(void); |
217 | void showFullView(void); | 217 | void showFullView(void); |
218 | void setShowAll(bool); | 218 | void setShowAll(bool); |
219 | void setShowDebug(bool); | 219 | void setShowDebug(bool); |
220 | void setShowRange(bool); | 220 | void setShowRange(bool); |
221 | void setShowName(bool); | 221 | void setShowName(bool); |
222 | void setShowData(bool); | 222 | void setShowData(bool); |
223 | void showIntro(void); | 223 | void showIntro(void); |
224 | void showAbout(void); | 224 | void showAbout(void); |
225 | 225 | ||
226 | protected: | 226 | protected: |
227 | void closeEvent(QCloseEvent *e); | 227 | void closeEvent(QCloseEvent *e); |
228 | 228 | ||
229 | ConfigView *menuView; | 229 | ConfigView *menuView; |
230 | ConfigList *menuList; | 230 | ConfigList *menuList; |
231 | ConfigView *configView; | 231 | ConfigView *configView; |
232 | ConfigList *configList; | 232 | ConfigList *configList; |
233 | QTextView *helpText; | 233 | QTextView *helpText; |
234 | QToolBar *toolBar; | 234 | QToolBar *toolBar; |
235 | QAction *backAction; | 235 | QAction *backAction; |
236 | 236 | ||
237 | bool showDebug; | 237 | bool showDebug; |
238 | }; | 238 | }; |