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