aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/qconf.cc
diff options
context:
space:
mode:
authorBoris Barbulovski <bbarbulovski@gmail.com>2015-09-22 14:36:19 -0400
committerMichal Marek <mmarek@suse.com>2015-10-14 08:59:02 -0400
commitd5d973c3f8a956411fafc997738ff03f213200b6 (patch)
tree60c5a764d9fe585f861a1306e9d2daeaf271d59f /scripts/kconfig/qconf.cc
parent59e564408f88ee14395dd96f713eae2474edb591 (diff)
Port xconfig to Qt5 - Put back some of the old implementation(part 2).
Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Thiago Macieira <thiago.macieira@intel.com> Signed-off-by: Michal Marek <mmarek@suse.com>
Diffstat (limited to 'scripts/kconfig/qconf.cc')
-rw-r--r--scripts/kconfig/qconf.cc788
1 files changed, 780 insertions, 8 deletions
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 0987a751d740..e0518cab500e 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -102,10 +102,135 @@ void ConfigItem::okRename(int col)
102 */ 102 */
103void ConfigItem::updateMenu(void) 103void ConfigItem::updateMenu(void)
104{ 104{
105 ConfigList* list;
106 struct symbol* sym;
107 struct property *prop;
108 QString prompt;
109 int type;
110 tristate expr;
111
112 list = listView();
113 if (goParent) {
114 setPixmap(promptColIdx, list->menuBackPix);
115 prompt = "..";
116 goto set_prompt;
117 }
118
119 sym = menu->sym;
120 prop = menu->prompt;
121 prompt = _(menu_get_prompt(menu));
122
123 if (prop) switch (prop->type) {
124 case P_MENU:
125 if (list->mode == singleMode || list->mode == symbolMode) {
126 /* a menuconfig entry is displayed differently
127 * depending whether it's at the view root or a child.
128 */
129 if (sym && list->rootEntry == menu)
130 break;
131 setPixmap(promptColIdx, list->menuPix);
132 } else {
133 if (sym)
134 break;
135 setPixmap(promptColIdx, QIcon());
136 }
137 goto set_prompt;
138 case P_COMMENT:
139 setPixmap(promptColIdx, QIcon());
140 goto set_prompt;
141 default:
142 ;
143 }
144 if (!sym)
145 goto set_prompt;
146
147 setText(nameColIdx, QString::fromLocal8Bit(sym->name));
148
149 type = sym_get_type(sym);
150 switch (type) {
151 case S_BOOLEAN:
152 case S_TRISTATE:
153 char ch;
154
155 if (!sym_is_changable(sym) && list->optMode == normalOpt) {
156 setPixmap(promptColIdx, QIcon());
157 setText(noColIdx, QString::null);
158 setText(modColIdx, QString::null);
159 setText(yesColIdx, QString::null);
160 break;
161 }
162 expr = sym_get_tristate_value(sym);
163 switch (expr) {
164 case yes:
165 if (sym_is_choice_value(sym) && type == S_BOOLEAN)
166 setPixmap(promptColIdx, list->choiceYesPix);
167 else
168 setPixmap(promptColIdx, list->symbolYesPix);
169 setText(yesColIdx, "Y");
170 ch = 'Y';
171 break;
172 case mod:
173 setPixmap(promptColIdx, list->symbolModPix);
174 setText(modColIdx, "M");
175 ch = 'M';
176 break;
177 default:
178 if (sym_is_choice_value(sym) && type == S_BOOLEAN)
179 setPixmap(promptColIdx, list->choiceNoPix);
180 else
181 setPixmap(promptColIdx, list->symbolNoPix);
182 setText(noColIdx, "N");
183 ch = 'N';
184 break;
185 }
186 if (expr != no)
187 setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0);
188 if (expr != mod)
189 setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0);
190 if (expr != yes)
191 setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0);
192
193 setText(dataColIdx, QChar(ch));
194 break;
195 case S_INT:
196 case S_HEX:
197 case S_STRING:
198 const char* data;
199
200 data = sym_get_string_value(sym);
201
202 //int i = list->mapIdx(dataColIdx);
203 //if (i >= 0)
204 // setRenameEnabled(i, true);
205 setText(dataColIdx, data);
206 if (type == S_STRING)
207 prompt = QString("%1: %2").arg(prompt).arg(data);
208 else
209 prompt = QString("(%2) %1").arg(prompt).arg(data);
210 break;
211 }
212 if (!sym_has_value(sym) && visible)
213 prompt += _(" (NEW)");
214set_prompt:
215 setText(promptColIdx, prompt);
105} 216}
106 217
107void ConfigItem::testUpdateMenu(bool v) 218void ConfigItem::testUpdateMenu(bool v)
108{ 219{
220 ConfigItem* i;
221
222 visible = v;
223 if (!menu)
224 return;
225
226 sym_calc_value(menu->sym);
227 if (menu->flags & MENU_CHANGED) {
228 /* the menu entry changed, so update all list items */
229 menu->flags &= ~MENU_CHANGED;
230 for (i = (ConfigItem*)menu->data; i; i = i->nextItem)
231 i->updateMenu();
232 } else if (listView()->updateAll)
233 updateMenu();
109} 234}
110 235
111 236
@@ -114,6 +239,16 @@ void ConfigItem::testUpdateMenu(bool v)
114 */ 239 */
115void ConfigItem::init(void) 240void ConfigItem::init(void)
116{ 241{
242 if (menu) {
243 ConfigList* list = listView();
244 nextItem = (ConfigItem*)menu->data;
245 menu->data = this;
246
247 if (list->mode != fullMode)
248 setExpanded(true);
249 sym_calc_value(menu->sym);
250 }
251 updateMenu();
117} 252}
118 253
119/* 254/*
@@ -121,17 +256,30 @@ void ConfigItem::init(void)
121 */ 256 */
122ConfigItem::~ConfigItem(void) 257ConfigItem::~ConfigItem(void)
123{ 258{
259 if (menu) {
260 ConfigItem** ip = (ConfigItem**)&menu->data;
261 for (; *ip; ip = &(*ip)->nextItem) {
262 if (*ip == this) {
263 *ip = nextItem;
264 break;
265 }
266 }
267 }
124} 268}
125 269
126ConfigLineEdit::ConfigLineEdit(ConfigView* parent) 270ConfigLineEdit::ConfigLineEdit(ConfigView* parent)
127 : Parent(parent) 271 : Parent(parent)
128{ 272{
129 connect(this, SIGNAL(editingFinished()), SLOT(hide())); 273 connect(this, SIGNAL(lostFocus()), SLOT(hide()));
130} 274}
131 275
132void ConfigLineEdit::show(ConfigItem* i) 276void ConfigLineEdit::show(ConfigItem* i)
133{ 277{
134 item = i; 278 item = i;
279 if (sym_get_string_value(item->menu->sym))
280 setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym)));
281 else
282 setText(QString::null);
135 Parent::show(); 283 Parent::show();
136 setFocus(); 284 setFocus();
137} 285}
@@ -143,6 +291,7 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
143 break; 291 break;
144 case Qt::Key_Return: 292 case Qt::Key_Return:
145 case Qt::Key_Enter: 293 case Qt::Key_Enter:
294 sym_set_string_value(item->menu->sym, text().toLatin1());
146 parent()->updateList(item); 295 parent()->updateList(item);
147 break; 296 break;
148 default: 297 default:
@@ -163,42 +312,251 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
163 showName(false), showRange(false), showData(false), optMode(normalOpt), 312 showName(false), showRange(false), showData(false), optMode(normalOpt),
164 rootEntry(0), headerPopup(0) 313 rootEntry(0), headerPopup(0)
165{ 314{
315 int i;
316
317 setObjectName(name);
318 setSortingEnabled(-1);
319 setRootIsDecorated(true);
320
321 connect(this, SIGNAL(selectionChanged(void)),
322 SLOT(updateSelection(void)));
323
324 if (name) {
325 configSettings->beginGroup(name);
326 showName = configSettings->value("/showName", false).toBool();
327 showRange = configSettings->value("/showRange", false).toBool();
328 showData = configSettings->value("/showData", false).toBool();
329 optMode = (enum optionMode)configSettings->value("/optionMode", 0).toInt();
330 configSettings->endGroup();
331 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
332 }
333
334 addColumn(promptColIdx);
335
336 reinit();
337}
338
339bool ConfigList::menuSkip(struct menu *menu)
340{
341 if (optMode == normalOpt && menu_is_visible(menu))
342 return false;
343 if (optMode == promptOpt && menu_has_prompt(menu))
344 return false;
345 if (optMode == allOpt)
346 return false;
347 return true;
166} 348}
167 349
168void ConfigList::reinit(void) 350void ConfigList::reinit(void)
169{ 351{
352 removeColumn(dataColIdx);
353 removeColumn(yesColIdx);
354 removeColumn(modColIdx);
355 removeColumn(noColIdx);
356 removeColumn(nameColIdx);
357
358 if (showName)
359 addColumn(nameColIdx);
360 if (showRange) {
361 addColumn(noColIdx);
362 addColumn(modColIdx);
363 addColumn(yesColIdx);
364 }
365 if (showData)
366 addColumn(dataColIdx);
367
368 updateListAll();
170} 369}
171 370
172void ConfigList::saveSettings(void) 371void ConfigList::saveSettings(void)
173{ 372{
373 if (!objectName().isEmpty()) {
374 configSettings->beginGroup(objectName());
375 configSettings->setValue("/showName", showName);
376 configSettings->setValue("/showRange", showRange);
377 configSettings->setValue("/showData", showData);
378 configSettings->setValue("/optionMode", (int)optMode);
379 configSettings->endGroup();
380 }
174} 381}
175 382
176ConfigItem* ConfigList::findConfigItem(struct menu *menu) 383ConfigItem* ConfigList::findConfigItem(struct menu *menu)
177{ 384{
385 ConfigItem* item = (ConfigItem*)menu->data;
386
387 for (; item; item = item->nextItem) {
388 if (this == item->listView())
389 break;
390 }
391
392 return item;
178} 393}
179 394
180void ConfigList::updateSelection(void) 395void ConfigList::updateSelection(void)
181{ 396{
397 struct menu *menu;
398 enum prop_type type;
399
400 ConfigItem* item = (ConfigItem*)selectedItems().first();
401 if (!item)
402 return;
403
404 menu = item->menu;
405 emit menuChanged(menu);
406 if (!menu)
407 return;
408 type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
409 if (mode == menuMode && type == P_MENU)
410 emit menuSelected(menu);
182} 411}
183 412
184void ConfigList::updateList(ConfigItem* item) 413void ConfigList::updateList(ConfigItem* item)
185{ 414{
415 ConfigItem* last = 0;
416
417 if (!rootEntry) {
418 if (mode != listMode)
419 goto update;
420 QTreeWidgetItemIterator it(this);
421 ConfigItem* item;
422
423 while (*it) {
424 item = (ConfigItem*)(*it);
425 if (!item->menu)
426 continue;
427 item->testUpdateMenu(menu_is_visible(item->menu));
428
429 ++it;
430 }
431 return;
432 }
433
434 if (rootEntry != &rootmenu && (mode == singleMode ||
435 (mode == symbolMode && rootEntry->parent != &rootmenu))) {
436 item = firstChild();
437 if (!item)
438 item = new ConfigItem(this, 0, true);
439 last = item;
440 }
441 if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) &&
442 rootEntry->sym && rootEntry->prompt) {
443 item = last ? last->nextSibling() : firstChild();
444 if (!item)
445 item = new ConfigItem(this, last, rootEntry, true);
446 else
447 item->testUpdateMenu(true);
448
449 updateMenuList(item, rootEntry);
450 update();
451 return;
452 }
453update:
454 updateMenuList(this, rootEntry);
455 update();
186} 456}
187 457
188void ConfigList::setValue(ConfigItem* item, tristate val) 458void ConfigList::setValue(ConfigItem* item, tristate val)
189{ 459{
460 struct symbol* sym;
461 int type;
462 tristate oldval;
463
464 sym = item->menu ? item->menu->sym : 0;
465 if (!sym)
466 return;
467
468 type = sym_get_type(sym);
469 switch (type) {
470 case S_BOOLEAN:
471 case S_TRISTATE:
472 oldval = sym_get_tristate_value(sym);
473
474 if (!sym_set_tristate_value(sym, val))
475 return;
476 if (oldval == no && item->menu->list)
477 item->setExpanded(true);
478 parent()->updateList(item);
479 break;
480 }
190} 481}
191 482
192void ConfigList::changeValue(ConfigItem* item) 483void ConfigList::changeValue(ConfigItem* item)
193{ 484{
485 struct symbol* sym;
486 struct menu* menu;
487 int type, oldexpr, newexpr;
488
489 menu = item->menu;
490 if (!menu)
491 return;
492 sym = menu->sym;
493 if (!sym) {
494 if (item->menu->list)
495 item->setExpanded(!item->isExpanded());
496 return;
497 }
498
499 type = sym_get_type(sym);
500 switch (type) {
501 case S_BOOLEAN:
502 case S_TRISTATE:
503 oldexpr = sym_get_tristate_value(sym);
504 newexpr = sym_toggle_tristate_value(sym);
505 if (item->menu->list) {
506 if (oldexpr == newexpr)
507 item->setExpanded(!item->isExpanded());
508 else if (oldexpr == no)
509 item->setExpanded(true);
510 }
511 if (oldexpr != newexpr)
512 parent()->updateList(item);
513 break;
514 case S_INT:
515 case S_HEX:
516 case S_STRING:
517 break;
518 }
194} 519}
195 520
196void ConfigList::setRootMenu(struct menu *menu) 521void ConfigList::setRootMenu(struct menu *menu)
197{ 522{
523 enum prop_type type;
524
525 if (rootEntry == menu)
526 return;
527 type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN;
528 if (type != P_MENU)
529 return;
530 updateMenuList(this, 0);
531 rootEntry = menu;
532 updateListAll();
533 if (currentItem()) {
534 currentItem()->setSelected(hasFocus());
535 scrollToItem(currentItem());
536 }
198} 537}
199 538
200void ConfigList::setParentMenu(void) 539void ConfigList::setParentMenu(void)
201{ 540{
541 ConfigItem* item;
542 struct menu *oldroot;
543
544 oldroot = rootEntry;
545 if (rootEntry == &rootmenu)
546 return;
547 setRootMenu(menu_get_parent_menu(rootEntry->parent));
548
549 QTreeWidgetItemIterator it(this);
550 while (*it) {
551 item = (ConfigItem *)(*it);
552 if (item->menu == oldroot) {
553 setCurrentItem(item);
554 scrollToItem(item);
555 break;
556 }
557
558 ++it;
559 }
202} 560}
203 561
204/* 562/*
@@ -211,34 +569,250 @@ void ConfigList::setParentMenu(void)
211template <class P> 569template <class P>
212void ConfigList::updateMenuList(P* parent, struct menu* menu) 570void ConfigList::updateMenuList(P* parent, struct menu* menu)
213{ 571{
572 struct menu* child;
573 ConfigItem* item;
574 ConfigItem* last;
575 bool visible;
576 enum prop_type type;
577
578 if (!menu) {
579 while ((item = parent->firstChild()))
580 item->parent()->removeChild(item);
581 delete item;
582 return;
583 }
584
585 last = parent->firstChild();
586 if (last && !last->goParent)
587 last = 0;
588 for (child = menu->list; child; child = child->next) {
589 item = last ? last->nextSibling() : parent->firstChild();
590 type = child->prompt ? child->prompt->type : P_UNKNOWN;
591
592 switch (mode) {
593 case menuMode:
594 if (!(child->flags & MENU_ROOT))
595 goto hide;
596 break;
597 case symbolMode:
598 if (child->flags & MENU_ROOT)
599 goto hide;
600 break;
601 default:
602 break;
603 }
604
605 visible = menu_is_visible(child);
606 if (!menuSkip(child)) {
607 if (!child->sym && !child->list && !child->prompt)
608 continue;
609 if (!item || item->menu != child)
610 item = new ConfigItem(parent, last, child, visible);
611 else
612 item->testUpdateMenu(visible);
613
614 if (mode == fullMode || mode == menuMode || type != P_MENU)
615 updateMenuList(item, child);
616 else
617 updateMenuList(item, 0);
618 last = item;
619 continue;
620 }
621 hide:
622 if (item && item->menu == child) {
623 last = parent->firstChild();
624 if (last == item)
625 last = 0;
626 else while (last->nextSibling() != item)
627 last = last->nextSibling();
628 delete item;
629 }
630 }
214} 631}
215 632
216void ConfigList::keyPressEvent(QKeyEvent* ev) 633void ConfigList::keyPressEvent(QKeyEvent* ev)
217{ 634{
635 QTreeWidgetItem* i = currentItem();
636 ConfigItem* item;
637 struct menu *menu;
638 enum prop_type type;
639
640 if (ev->key() == Qt::Key_Escape && mode != fullMode && mode != listMode) {
641 emit parentSelected();
642 ev->accept();
643 return;
644 }
645
646 if (!i) {
647 Parent::keyPressEvent(ev);
648 return;
649 }
650 item = (ConfigItem*)i;
651
652 switch (ev->key()) {
653 case Qt::Key_Return:
654 case Qt::Key_Enter:
655 if (item->goParent) {
656 emit parentSelected();
657 break;
658 }
659 menu = item->menu;
660 if (!menu)
661 break;
662 type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
663 if (type == P_MENU && rootEntry != menu &&
664 mode != fullMode && mode != menuMode) {
665 emit menuSelected(menu);
666 break;
667 }
668 case Qt::Key_Space:
669 changeValue(item);
670 break;
671 case Qt::Key_N:
672 setValue(item, no);
673 break;
674 case Qt::Key_M:
675 setValue(item, mod);
676 break;
677 case Qt::Key_Y:
678 setValue(item, yes);
679 break;
680 default:
681 Parent::keyPressEvent(ev);
682 return;
683 }
684 ev->accept();
218} 685}
219 686
220void ConfigList::contentsMousePressEvent(QMouseEvent* e) 687void ConfigList::mousePressEvent(QMouseEvent* e)
221{ 688{
689 //QPoint p(contentsToViewport(e->pos()));
690 //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y());
691 Parent::mousePressEvent(e);
222} 692}
223 693
224void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) 694void ConfigList::mouseReleaseEvent(QMouseEvent* e)
225{ 695{
696 QPoint p = e->pos();
697 ConfigItem* item = (ConfigItem*)itemAt(p);
698 struct menu *menu;
699 enum prop_type ptype;
700 QIcon icon;
701 int idx, x;
702
703 if (!item)
704 goto skip;
705
706 menu = item->menu;
707 x = header()->offset() + p.x();
708 idx = header()->sectionPosition(x);
709 switch (idx) {
710 case promptColIdx:
711 icon = item->pixmap(promptColIdx);
712 break;
713 case noColIdx:
714 setValue(item, no);
715 break;
716 case modColIdx:
717 setValue(item, mod);
718 break;
719 case yesColIdx:
720 setValue(item, yes);
721 break;
722 case dataColIdx:
723 changeValue(item);
724 break;
725 }
726
727skip:
728 //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y());
729 Parent::mouseReleaseEvent(e);
226} 730}
227 731
228void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) 732void ConfigList::mouseMoveEvent(QMouseEvent* e)
229{ 733{
734 //QPoint p(contentsToViewport(e->pos()));
735 //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y());
736 Parent::mouseMoveEvent(e);
230} 737}
231 738
232void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) 739void ConfigList::mouseDoubleClickEvent(QMouseEvent* e)
233{ 740{
741 QPoint p = e->pos(); // TODO: Check if this works(was contentsToViewport).
742 ConfigItem* item = (ConfigItem*)itemAt(p);
743 struct menu *menu;
744 enum prop_type ptype;
745
746 if (!item)
747 goto skip;
748 if (item->goParent) {
749 emit parentSelected();
750 goto skip;
751 }
752 menu = item->menu;
753 if (!menu)
754 goto skip;
755 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
756 if (ptype == P_MENU && (mode == singleMode || mode == symbolMode))
757 emit menuSelected(menu);
758 else if (menu->sym)
759 changeValue(item);
760
761skip:
762 //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y());
763 Parent::mouseDoubleClickEvent(e);
234} 764}
235 765
236void ConfigList::focusInEvent(QFocusEvent *e) 766void ConfigList::focusInEvent(QFocusEvent *e)
237{ 767{
768 struct menu *menu = NULL;
769
770 Parent::focusInEvent(e);
771
772 ConfigItem* item = (ConfigItem *)currentItem();
773 if (item) {
774 item->setSelected(true);
775 menu = item->menu;
776 }
777 emit gotFocus(menu);
238} 778}
239 779
240void ConfigList::contextMenuEvent(QContextMenuEvent *e) 780void ConfigList::contextMenuEvent(QContextMenuEvent *e)
241{ 781{
782 if (e->y() <= header()->geometry().bottom()) {
783 if (!headerPopup) {
784 QAction *action;
785
786 headerPopup = new QMenu(this);
787 action = new QAction(_("Show Name"), this);
788 action->setCheckable(true);
789 connect(action, SIGNAL(toggled(bool)),
790 parent(), SLOT(setShowName(bool)));
791 connect(parent(), SIGNAL(showNameChanged(bool)),
792 action, SLOT(setOn(bool)));
793 action->setChecked(showName);
794 headerPopup->addAction(action);
795 action = new QAction(_("Show Range"), this);
796 action->setCheckable(true);
797 connect(action, SIGNAL(toggled(bool)),
798 parent(), SLOT(setShowRange(bool)));
799 connect(parent(), SIGNAL(showRangeChanged(bool)),
800 action, SLOT(setOn(bool)));
801 action->setChecked(showRange);
802 headerPopup->addAction(action);
803 action = new QAction(_("Show Data"), this);
804 action->setCheckable(true);
805 connect(action, SIGNAL(toggled(bool)),
806 parent(), SLOT(setShowData(bool)));
807 connect(parent(), SIGNAL(showDataChanged(bool)),
808 action, SLOT(setOn(bool)));
809 action->setChecked(showData);
810 headerPopup->addAction(action);
811 }
812 headerPopup->exec(e->globalPos());
813 e->accept();
814 } else
815 e->ignore();
242} 816}
243 817
244ConfigView*ConfigView::viewList; 818ConfigView*ConfigView::viewList;
@@ -276,33 +850,78 @@ ConfigView::~ConfigView(void)
276 850
277void ConfigView::setOptionMode(QAction *act) 851void ConfigView::setOptionMode(QAction *act)
278{ 852{
853 if (act == showNormalAction)
854 list->optMode = normalOpt;
855 else if (act == showAllAction)
856 list->optMode = allOpt;
857 else
858 list->optMode = promptOpt;
859
860 list->updateListAll();
279} 861}
280 862
281void ConfigView::setShowName(bool b) 863void ConfigView::setShowName(bool b)
282{ 864{
865 if (list->showName != b) {
866 list->showName = b;
867 list->reinit();
868 emit showNameChanged(b);
869 }
283} 870}
284 871
285void ConfigView::setShowRange(bool b) 872void ConfigView::setShowRange(bool b)
286{ 873{
874 if (list->showRange != b) {
875 list->showRange = b;
876 list->reinit();
877 emit showRangeChanged(b);
878 }
287} 879}
288 880
289void ConfigView::setShowData(bool b) 881void ConfigView::setShowData(bool b)
290{ 882{
883 if (list->showData != b) {
884 list->showData = b;
885 list->reinit();
886 emit showDataChanged(b);
887 }
888}
889
890void ConfigList::setAllOpen(bool open)
891{
892 QTreeWidgetItemIterator it(this);
893
894 while (*it) {
895 (*it)->setExpanded(open);
896
897 ++it;
898 }
291} 899}
292 900
293void ConfigView::updateList(ConfigItem* item) 901void ConfigView::updateList(ConfigItem* item)
294{ 902{
903 ConfigView* v;
904
905 for (v = viewList; v; v = v->nextView)
906 v->list->updateList(item);
295} 907}
296 908
297void ConfigView::updateListAll(void) 909void ConfigView::updateListAll(void)
298{ 910{
911 ConfigView* v;
912
913 for (v = viewList; v; v = v->nextView)
914 v->list->updateListAll();
299} 915}
300 916
301ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) 917ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
302 : Parent(parent), sym(0), _menu(0) 918 : Parent(parent), sym(0), _menu(0)
303{ 919{
304 if (name) { 920 setObjectName(name);
305 configSettings->beginGroup(name); 921
922
923 if (!objectName().isEmpty()) {
924 configSettings->beginGroup(objectName());
306 _showDebug = configSettings->value("/showDebug", false).toBool(); 925 _showDebug = configSettings->value("/showDebug", false).toBool();
307 configSettings->endGroup(); 926 configSettings->endGroup();
308 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); 927 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
@@ -311,6 +930,11 @@ ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
311 930
312void ConfigInfoView::saveSettings(void) 931void ConfigInfoView::saveSettings(void)
313{ 932{
933 if (!objectName().isEmpty()) {
934 configSettings->beginGroup(objectName());
935 configSettings->setValue("/showDebug", showDebug());
936 configSettings->endGroup();
937 }
314} 938}
315 939
316void ConfigInfoView::setShowDebug(bool b) 940void ConfigInfoView::setShowDebug(bool b)
@@ -528,6 +1152,7 @@ void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e)
528ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name) 1152ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name)
529 : Parent(parent), result(NULL) 1153 : Parent(parent), result(NULL)
530{ 1154{
1155 setObjectName(name);
531 setWindowTitle("Search Config"); 1156 setWindowTitle("Search Config");
532 1157
533 QVBoxLayout* layout1 = new QVBoxLayout(this); 1158 QVBoxLayout* layout1 = new QVBoxLayout(this);
@@ -549,6 +1174,7 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam
549 split = new QSplitter(this); 1174 split = new QSplitter(this);
550 split->setOrientation(Qt::Vertical); 1175 split->setOrientation(Qt::Vertical);
551 list = new ConfigView(split, name); 1176 list = new ConfigView(split, name);
1177 list->list->mode = listMode;
552 info = new ConfigInfoView(split, name); 1178 info = new ConfigInfoView(split, name);
553 connect(list->list, SIGNAL(menuChanged(struct menu *)), 1179 connect(list->list, SIGNAL(menuChanged(struct menu *)),
554 info, SLOT(setInfo(struct menu *))); 1180 info, SLOT(setInfo(struct menu *)));
@@ -580,10 +1206,35 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam
580 1206
581void ConfigSearchWindow::saveSettings(void) 1207void ConfigSearchWindow::saveSettings(void)
582{ 1208{
1209 if (!objectName().isEmpty()) {
1210 configSettings->beginGroup(objectName());
1211 configSettings->setValue("/window x", pos().x());
1212 configSettings->setValue("/window y", pos().y());
1213 configSettings->setValue("/window width", size().width());
1214 configSettings->setValue("/window height", size().height());
1215 configSettings->writeSizes("/split", split->sizes());
1216 configSettings->endGroup();
1217 }
583} 1218}
584 1219
585void ConfigSearchWindow::search(void) 1220void ConfigSearchWindow::search(void)
586{ 1221{
1222 struct symbol **p;
1223 struct property *prop;
1224 ConfigItem *lastItem = NULL;
1225
1226 free(result);
1227 list->list->clear();
1228 info->clear();
1229
1230 result = sym_re_search(editField->text().toLatin1());
1231 if (!result)
1232 return;
1233 for (p = result; *p; p++) {
1234 for_all_prompts((*p), prop)
1235 lastItem = new ConfigItem(list->list, lastItem, prop->menu,
1236 menu_is_visible(prop->menu));
1237 }
587} 1238}
588 1239
589/* 1240/*
@@ -739,6 +1390,23 @@ ConfigMainWindow::ConfigMainWindow(void)
739 helpMenu->addAction(showIntroAction); 1390 helpMenu->addAction(showIntroAction);
740 helpMenu->addAction(showAboutAction); 1391 helpMenu->addAction(showAboutAction);
741 1392
1393 connect(configList, SIGNAL(menuChanged(struct menu *)),
1394 helpText, SLOT(setInfo(struct menu *)));
1395 connect(configList, SIGNAL(menuSelected(struct menu *)),
1396 SLOT(changeMenu(struct menu *)));
1397 connect(configList, SIGNAL(parentSelected()),
1398 SLOT(goBack()));
1399 connect(menuList, SIGNAL(menuChanged(struct menu *)),
1400 helpText, SLOT(setInfo(struct menu *)));
1401 connect(menuList, SIGNAL(menuSelected(struct menu *)),
1402 SLOT(changeMenu(struct menu *)));
1403
1404 connect(configList, SIGNAL(gotFocus(struct menu *)),
1405 helpText, SLOT(setInfo(struct menu *)));
1406 connect(menuList, SIGNAL(gotFocus(struct menu *)),
1407 helpText, SLOT(setInfo(struct menu *)));
1408 connect(menuList, SIGNAL(gotFocus(struct menu *)),
1409 SLOT(listFocusChanged(void)));
742 connect(helpText, SIGNAL(menuSelected(struct menu *)), 1410 connect(helpText, SIGNAL(menuSelected(struct menu *)),
743 SLOT(setMenuLink(struct menu *))); 1411 SLOT(setMenuLink(struct menu *)));
744 1412
@@ -796,19 +1464,86 @@ void ConfigMainWindow::searchConfig(void)
796 1464
797void ConfigMainWindow::changeMenu(struct menu *menu) 1465void ConfigMainWindow::changeMenu(struct menu *menu)
798{ 1466{
799 1467 configList->setRootMenu(menu);
1468 if (configList->rootEntry->parent == &rootmenu)
1469 backAction->setEnabled(false);
1470 else
1471 backAction->setEnabled(true);
800} 1472}
801 1473
802void ConfigMainWindow::setMenuLink(struct menu *menu) 1474void ConfigMainWindow::setMenuLink(struct menu *menu)
803{ 1475{
1476 struct menu *parent;
1477 ConfigList* list = NULL;
1478 ConfigItem* item;
1479
1480 if (configList->menuSkip(menu))
1481 return;
1482
1483 switch (configList->mode) {
1484 case singleMode:
1485 list = configList;
1486 parent = menu_get_parent_menu(menu);
1487 if (!parent)
1488 return;
1489 list->setRootMenu(parent);
1490 break;
1491 case symbolMode:
1492 if (menu->flags & MENU_ROOT) {
1493 configList->setRootMenu(menu);
1494 configList->clearSelection();
1495 list = menuList;
1496 } else {
1497 list = configList;
1498 parent = menu_get_parent_menu(menu->parent);
1499 if (!parent)
1500 return;
1501 item = menuList->findConfigItem(parent);
1502 if (item) {
1503 item->setSelected(true);
1504 menuList->scrollToItem(item);
1505 }
1506 list->setRootMenu(parent);
1507 }
1508 break;
1509 case fullMode:
1510 list = configList;
1511 break;
1512 default:
1513 break;
1514 }
1515
1516 if (list) {
1517 item = list->findConfigItem(menu);
1518 if (item) {
1519 item->setSelected(true);
1520 list->scrollToItem(item);
1521 list->setFocus();
1522 }
1523 }
804} 1524}
805 1525
806void ConfigMainWindow::listFocusChanged(void) 1526void ConfigMainWindow::listFocusChanged(void)
807{ 1527{
1528 if (menuList->mode == menuMode)
1529 configList->clearSelection();
808} 1530}
809 1531
810void ConfigMainWindow::goBack(void) 1532void ConfigMainWindow::goBack(void)
811{ 1533{
1534 ConfigItem* item;
1535
1536 configList->setParentMenu();
1537 if (configList->rootEntry == &rootmenu)
1538 backAction->setEnabled(false);
1539 item = (ConfigItem*)menuList->selectedItems().first();
1540 while (item) {
1541 if (item->menu == configList->rootEntry) {
1542 item->setSelected(true);
1543 break;
1544 }
1545 item = (ConfigItem*)item->parent();
1546 }
812} 1547}
813 1548
814void ConfigMainWindow::showSingleView(void) 1549void ConfigMainWindow::showSingleView(void)
@@ -821,6 +1556,12 @@ void ConfigMainWindow::showSingleView(void)
821 fullViewAction->setChecked(false); 1556 fullViewAction->setChecked(false);
822 1557
823 menuView->hide(); 1558 menuView->hide();
1559 menuList->setRootMenu(0);
1560 configList->mode = singleMode;
1561 if (configList->rootEntry == &rootmenu)
1562 configList->updateListAll();
1563 else
1564 configList->setRootMenu(&rootmenu);
824 configList->setFocus(); 1565 configList->setFocus();
825} 1566}
826 1567
@@ -833,6 +1574,16 @@ void ConfigMainWindow::showSplitView(void)
833 fullViewAction->setEnabled(true); 1574 fullViewAction->setEnabled(true);
834 fullViewAction->setChecked(false); 1575 fullViewAction->setChecked(false);
835 1576
1577 configList->mode = symbolMode;
1578 if (configList->rootEntry == &rootmenu)
1579 configList->updateListAll();
1580 else
1581 configList->setRootMenu(&rootmenu);
1582 configList->setAllOpen(true);
1583 configApp->processEvents();
1584 menuList->mode = menuMode;
1585 menuList->setRootMenu(&rootmenu);
1586 menuList->setAllOpen(true);
836 menuView->show(); 1587 menuView->show();
837 menuList->setFocus(); 1588 menuList->setFocus();
838} 1589}
@@ -847,6 +1598,12 @@ void ConfigMainWindow::showFullView(void)
847 fullViewAction->setChecked(true); 1598 fullViewAction->setChecked(true);
848 1599
849 menuView->hide(); 1600 menuView->hide();
1601 menuList->setRootMenu(0);
1602 configList->mode = fullMode;
1603 if (configList->rootEntry == &rootmenu)
1604 configList->updateListAll();
1605 else
1606 configList->setRootMenu(&rootmenu);
850 configList->setFocus(); 1607 configList->setFocus();
851} 1608}
852 1609
@@ -914,7 +1671,22 @@ void ConfigMainWindow::saveSettings(void)
914 configSettings->setValue("/window height", size().height()); 1671 configSettings->setValue("/window height", size().height());
915 1672
916 QString entry; 1673 QString entry;
1674 switch(configList->mode) {
1675 case singleMode :
1676 entry = "single";
1677 break;
1678
1679 case symbolMode :
1680 entry = "split";
1681 break;
1682
1683 case fullMode :
1684 entry = "full";
1685 break;
917 1686
1687 default:
1688 break;
1689 }
918 configSettings->setValue("/listMode", entry); 1690 configSettings->setValue("/listMode", entry);
919 1691
920 configSettings->writeSizes("/split1", split1->sizes()); 1692 configSettings->writeSizes("/split1", split1->sizes());