diff options
Diffstat (limited to 'scripts/kconfig/qconf.cc')
-rw-r--r-- | scripts/kconfig/qconf.cc | 1048 |
1 files changed, 676 insertions, 372 deletions
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 4590cd31623f..393f3749f330 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc | |||
@@ -6,16 +6,20 @@ | |||
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 <qlayout.h> | ||
9 | #include <qvbox.h> | 10 | #include <qvbox.h> |
10 | #include <qsplitter.h> | 11 | #include <qsplitter.h> |
11 | #include <qlistview.h> | 12 | #include <qlistview.h> |
12 | #include <qtextview.h> | 13 | #include <qtextbrowser.h> |
13 | #include <qlineedit.h> | 14 | #include <qlineedit.h> |
15 | #include <qlabel.h> | ||
16 | #include <qpushbutton.h> | ||
14 | #include <qmenubar.h> | 17 | #include <qmenubar.h> |
15 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
16 | #include <qaction.h> | 19 | #include <qaction.h> |
17 | #include <qheader.h> | 20 | #include <qheader.h> |
18 | #include <qfiledialog.h> | 21 | #include <qfiledialog.h> |
22 | #include <qdragobject.h> | ||
19 | #include <qregexp.h> | 23 | #include <qregexp.h> |
20 | 24 | ||
21 | #include <stdlib.h> | 25 | #include <stdlib.h> |
@@ -32,32 +36,16 @@ | |||
32 | #endif | 36 | #endif |
33 | 37 | ||
34 | static QApplication *configApp; | 38 | static QApplication *configApp; |
39 | static ConfigSettings *configSettings; | ||
35 | 40 | ||
36 | static inline QString qgettext(const char* str) | 41 | static inline QString qgettext(const char* str) |
37 | { | 42 | { |
38 | return QString::fromLocal8Bit(gettext(str)); | 43 | return QString::fromLocal8Bit(gettext(str)); |
39 | } | 44 | } |
40 | 45 | ||
41 | static inline QString qgettext(const QString& str) | 46 | static inline QString qgettext(const QString& str) |
42 | { | 47 | { |
43 | return QString::fromLocal8Bit(gettext(str.latin1())); | 48 | return QString::fromLocal8Bit(gettext(str.latin1())); |
44 | } | ||
45 | |||
46 | ConfigSettings::ConfigSettings() | ||
47 | : showAll(false), showName(false), showRange(false), showData(false) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | #if QT_VERSION >= 300 | ||
52 | /** | ||
53 | * Reads the list column settings from the application settings. | ||
54 | */ | ||
55 | void ConfigSettings::readListSettings() | ||
56 | { | ||
57 | showAll = readBoolEntry("/kconfig/qconf/showAll", false); | ||
58 | showName = readBoolEntry("/kconfig/qconf/showName", false); | ||
59 | showRange = readBoolEntry("/kconfig/qconf/showRange", false); | ||
60 | showData = readBoolEntry("/kconfig/qconf/showData", false); | ||
61 | } | 49 | } |
62 | 50 | ||
63 | /** | 51 | /** |
@@ -88,76 +76,7 @@ bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value | |||
88 | stringList.push_back(QString::number(*it)); | 76 | stringList.push_back(QString::number(*it)); |
89 | return writeEntry(key, stringList); | 77 | return writeEntry(key, stringList); |
90 | } | 78 | } |
91 | #endif | ||
92 | |||
93 | |||
94 | /* | ||
95 | * update all the children of a menu entry | ||
96 | * removes/adds the entries from the parent widget as necessary | ||
97 | * | ||
98 | * parent: either the menu list widget or a menu entry widget | ||
99 | * menu: entry to be updated | ||
100 | */ | ||
101 | template <class P> | ||
102 | void ConfigList::updateMenuList(P* parent, struct menu* menu) | ||
103 | { | ||
104 | struct menu* child; | ||
105 | ConfigItem* item; | ||
106 | ConfigItem* last; | ||
107 | bool visible; | ||
108 | enum prop_type type; | ||
109 | 79 | ||
110 | if (!menu) { | ||
111 | while ((item = parent->firstChild())) | ||
112 | delete item; | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | last = parent->firstChild(); | ||
117 | if (last && !last->goParent) | ||
118 | last = 0; | ||
119 | for (child = menu->list; child; child = child->next) { | ||
120 | item = last ? last->nextSibling() : parent->firstChild(); | ||
121 | type = child->prompt ? child->prompt->type : P_UNKNOWN; | ||
122 | |||
123 | switch (mode) { | ||
124 | case menuMode: | ||
125 | if (!(child->flags & MENU_ROOT)) | ||
126 | goto hide; | ||
127 | break; | ||
128 | case symbolMode: | ||
129 | if (child->flags & MENU_ROOT) | ||
130 | goto hide; | ||
131 | break; | ||
132 | default: | ||
133 | break; | ||
134 | } | ||
135 | |||
136 | visible = menu_is_visible(child); | ||
137 | if (showAll || visible) { | ||
138 | if (!item || item->menu != child) | ||
139 | item = new ConfigItem(parent, last, child, visible); | ||
140 | else | ||
141 | item->testUpdateMenu(visible); | ||
142 | |||
143 | if (mode == fullMode || mode == menuMode || type != P_MENU) | ||
144 | updateMenuList(item, child); | ||
145 | else | ||
146 | updateMenuList(item, 0); | ||
147 | last = item; | ||
148 | continue; | ||
149 | } | ||
150 | hide: | ||
151 | if (item && item->menu == child) { | ||
152 | last = parent->firstChild(); | ||
153 | if (last == item) | ||
154 | last = 0; | ||
155 | else while (last->nextSibling() != item) | ||
156 | last = last->nextSibling(); | ||
157 | delete item; | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | 80 | ||
162 | #if QT_VERSION >= 300 | 81 | #if QT_VERSION >= 300 |
163 | /* | 82 | /* |
@@ -355,6 +274,12 @@ ConfigItem::~ConfigItem(void) | |||
355 | } | 274 | } |
356 | } | 275 | } |
357 | 276 | ||
277 | ConfigLineEdit::ConfigLineEdit(ConfigView* parent) | ||
278 | : Parent(parent) | ||
279 | { | ||
280 | connect(this, SIGNAL(lostFocus()), SLOT(hide())); | ||
281 | } | ||
282 | |||
358 | void ConfigLineEdit::show(ConfigItem* i) | 283 | void ConfigLineEdit::show(ConfigItem* i) |
359 | { | 284 | { |
360 | item = i; | 285 | item = i; |
@@ -385,14 +310,14 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | |||
385 | hide(); | 310 | hide(); |
386 | } | 311 | } |
387 | 312 | ||
388 | ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv, ConfigSettings* configSettings) | 313 | ConfigList::ConfigList(ConfigView* p, const char *name) |
389 | : Parent(p), cview(cv), | 314 | : Parent(p, name), |
390 | updateAll(false), | 315 | updateAll(false), |
391 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), | 316 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), |
392 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), | 317 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), |
393 | menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), | 318 | menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), |
394 | showAll(false), showName(false), showRange(false), showData(false), | 319 | showAll(false), showName(false), showRange(false), showData(false), |
395 | rootEntry(0) | 320 | rootEntry(0), headerPopup(0) |
396 | { | 321 | { |
397 | int i; | 322 | int i; |
398 | 323 | ||
@@ -406,11 +331,14 @@ ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv, ConfigSettings* conf | |||
406 | connect(this, SIGNAL(selectionChanged(void)), | 331 | connect(this, SIGNAL(selectionChanged(void)), |
407 | SLOT(updateSelection(void))); | 332 | SLOT(updateSelection(void))); |
408 | 333 | ||
409 | if (configSettings) { | 334 | if (name) { |
410 | showAll = configSettings->showAll; | 335 | configSettings->beginGroup(name); |
411 | showName = configSettings->showName; | 336 | showAll = configSettings->readBoolEntry("/showAll", false); |
412 | showRange = configSettings->showRange; | 337 | showName = configSettings->readBoolEntry("/showName", false); |
413 | showData = configSettings->showData; | 338 | showRange = configSettings->readBoolEntry("/showRange", false); |
339 | showData = configSettings->readBoolEntry("/showData", false); | ||
340 | configSettings->endGroup(); | ||
341 | connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); | ||
414 | } | 342 | } |
415 | 343 | ||
416 | for (i = 0; i < colNr; i++) | 344 | for (i = 0; i < colNr; i++) |
@@ -441,6 +369,30 @@ void ConfigList::reinit(void) | |||
441 | updateListAll(); | 369 | updateListAll(); |
442 | } | 370 | } |
443 | 371 | ||
372 | void ConfigList::saveSettings(void) | ||
373 | { | ||
374 | if (name()) { | ||
375 | configSettings->beginGroup(name()); | ||
376 | configSettings->writeEntry("/showName", showName); | ||
377 | configSettings->writeEntry("/showRange", showRange); | ||
378 | configSettings->writeEntry("/showData", showData); | ||
379 | configSettings->writeEntry("/showAll", showAll); | ||
380 | configSettings->endGroup(); | ||
381 | } | ||
382 | } | ||
383 | |||
384 | ConfigItem* ConfigList::findConfigItem(struct menu *menu) | ||
385 | { | ||
386 | ConfigItem* item = (ConfigItem*)menu->data; | ||
387 | |||
388 | for (; item; item = item->nextItem) { | ||
389 | if (this == item->listView()) | ||
390 | break; | ||
391 | } | ||
392 | |||
393 | return item; | ||
394 | } | ||
395 | |||
444 | void ConfigList::updateSelection(void) | 396 | void ConfigList::updateSelection(void) |
445 | { | 397 | { |
446 | struct menu *menu; | 398 | struct menu *menu; |
@@ -450,9 +402,8 @@ void ConfigList::updateSelection(void) | |||
450 | if (!item) | 402 | if (!item) |
451 | return; | 403 | return; |
452 | 404 | ||
453 | cview->setHelp(item); | ||
454 | |||
455 | menu = item->menu; | 405 | menu = item->menu; |
406 | emit menuChanged(menu); | ||
456 | if (!menu) | 407 | if (!menu) |
457 | return; | 408 | return; |
458 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 409 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
@@ -464,8 +415,20 @@ void ConfigList::updateList(ConfigItem* item) | |||
464 | { | 415 | { |
465 | ConfigItem* last = 0; | 416 | ConfigItem* last = 0; |
466 | 417 | ||
467 | if (!rootEntry) | 418 | if (!rootEntry) { |
468 | goto update; | 419 | if (mode != listMode) |
420 | goto update; | ||
421 | QListViewItemIterator it(this); | ||
422 | ConfigItem* item; | ||
423 | |||
424 | for (; it.current(); ++it) { | ||
425 | item = (ConfigItem*)it.current(); | ||
426 | if (!item->menu) | ||
427 | continue; | ||
428 | item->testUpdateMenu(menu_is_visible(item->menu)); | ||
429 | } | ||
430 | return; | ||
431 | } | ||
469 | 432 | ||
470 | if (rootEntry != &rootmenu && (mode == singleMode || | 433 | if (rootEntry != &rootmenu && (mode == singleMode || |
471 | (mode == symbolMode && rootEntry->parent != &rootmenu))) { | 434 | (mode == symbolMode && rootEntry->parent != &rootmenu))) { |
@@ -491,14 +454,6 @@ update: | |||
491 | triggerUpdate(); | 454 | triggerUpdate(); |
492 | } | 455 | } |
493 | 456 | ||
494 | void ConfigList::setAllOpen(bool open) | ||
495 | { | ||
496 | QListViewItemIterator it(this); | ||
497 | |||
498 | for (; it.current(); it++) | ||
499 | it.current()->setOpen(open); | ||
500 | } | ||
501 | |||
502 | void ConfigList::setValue(ConfigItem* item, tristate val) | 457 | void ConfigList::setValue(ConfigItem* item, tristate val) |
503 | { | 458 | { |
504 | struct symbol* sym; | 459 | struct symbol* sym; |
@@ -581,6 +536,7 @@ void ConfigList::setRootMenu(struct menu *menu) | |||
581 | rootEntry = menu; | 536 | rootEntry = menu; |
582 | updateListAll(); | 537 | updateListAll(); |
583 | setSelected(currentItem(), hasFocus()); | 538 | setSelected(currentItem(), hasFocus()); |
539 | ensureItemVisible(currentItem()); | ||
584 | } | 540 | } |
585 | 541 | ||
586 | void ConfigList::setParentMenu(void) | 542 | void ConfigList::setParentMenu(void) |
@@ -603,6 +559,74 @@ void ConfigList::setParentMenu(void) | |||
603 | } | 559 | } |
604 | } | 560 | } |
605 | 561 | ||
562 | /* | ||
563 | * update all the children of a menu entry | ||
564 | * removes/adds the entries from the parent widget as necessary | ||
565 | * | ||
566 | * parent: either the menu list widget or a menu entry widget | ||
567 | * menu: entry to be updated | ||
568 | */ | ||
569 | template <class P> | ||
570 | void ConfigList::updateMenuList(P* parent, struct menu* menu) | ||
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 | delete item; | ||
581 | return; | ||
582 | } | ||
583 | |||
584 | last = parent->firstChild(); | ||
585 | if (last && !last->goParent) | ||
586 | last = 0; | ||
587 | for (child = menu->list; child; child = child->next) { | ||
588 | item = last ? last->nextSibling() : parent->firstChild(); | ||
589 | type = child->prompt ? child->prompt->type : P_UNKNOWN; | ||
590 | |||
591 | switch (mode) { | ||
592 | case menuMode: | ||
593 | if (!(child->flags & MENU_ROOT)) | ||
594 | goto hide; | ||
595 | break; | ||
596 | case symbolMode: | ||
597 | if (child->flags & MENU_ROOT) | ||
598 | goto hide; | ||
599 | break; | ||
600 | default: | ||
601 | break; | ||
602 | } | ||
603 | |||
604 | visible = menu_is_visible(child); | ||
605 | if (showAll || visible) { | ||
606 | if (!item || item->menu != child) | ||
607 | item = new ConfigItem(parent, last, child, visible); | ||
608 | else | ||
609 | item->testUpdateMenu(visible); | ||
610 | |||
611 | if (mode == fullMode || mode == menuMode || type != P_MENU) | ||
612 | updateMenuList(item, child); | ||
613 | else | ||
614 | updateMenuList(item, 0); | ||
615 | last = item; | ||
616 | continue; | ||
617 | } | ||
618 | hide: | ||
619 | if (item && item->menu == child) { | ||
620 | last = parent->firstChild(); | ||
621 | if (last == item) | ||
622 | last = 0; | ||
623 | else while (last->nextSibling() != item) | ||
624 | last = last->nextSibling(); | ||
625 | delete item; | ||
626 | } | ||
627 | } | ||
628 | } | ||
629 | |||
606 | void ConfigList::keyPressEvent(QKeyEvent* ev) | 630 | void ConfigList::keyPressEvent(QKeyEvent* ev) |
607 | { | 631 | { |
608 | QListViewItem* i = currentItem(); | 632 | QListViewItem* i = currentItem(); |
@@ -610,7 +634,7 @@ void ConfigList::keyPressEvent(QKeyEvent* ev) | |||
610 | struct menu *menu; | 634 | struct menu *menu; |
611 | enum prop_type type; | 635 | enum prop_type type; |
612 | 636 | ||
613 | if (ev->key() == Key_Escape && mode != fullMode) { | 637 | if (ev->key() == Key_Escape && mode != fullMode && mode != listMode) { |
614 | emit parentSelected(); | 638 | emit parentSelected(); |
615 | ev->accept(); | 639 | ev->accept(); |
616 | return; | 640 | return; |
@@ -755,23 +779,62 @@ skip: | |||
755 | 779 | ||
756 | void ConfigList::focusInEvent(QFocusEvent *e) | 780 | void ConfigList::focusInEvent(QFocusEvent *e) |
757 | { | 781 | { |
782 | struct menu *menu = NULL; | ||
783 | |||
758 | Parent::focusInEvent(e); | 784 | Parent::focusInEvent(e); |
759 | 785 | ||
760 | QListViewItem* item = currentItem(); | 786 | ConfigItem* item = (ConfigItem *)currentItem(); |
761 | if (!item) | 787 | if (item) { |
762 | return; | 788 | setSelected(item, TRUE); |
789 | menu = item->menu; | ||
790 | } | ||
791 | emit gotFocus(menu); | ||
792 | } | ||
763 | 793 | ||
764 | setSelected(item, TRUE); | 794 | void ConfigList::contextMenuEvent(QContextMenuEvent *e) |
765 | emit gotFocus(); | 795 | { |
796 | if (e->y() <= header()->geometry().bottom()) { | ||
797 | if (!headerPopup) { | ||
798 | QAction *action; | ||
799 | |||
800 | headerPopup = new QPopupMenu(this); | ||
801 | action = new QAction("Show Name", 0, this); | ||
802 | action->setToggleAction(TRUE); | ||
803 | connect(action, SIGNAL(toggled(bool)), | ||
804 | parent(), SLOT(setShowName(bool))); | ||
805 | connect(parent(), SIGNAL(showNameChanged(bool)), | ||
806 | action, SLOT(setOn(bool))); | ||
807 | action->setOn(showName); | ||
808 | action->addTo(headerPopup); | ||
809 | action = new QAction("Show Range", 0, this); | ||
810 | action->setToggleAction(TRUE); | ||
811 | connect(action, SIGNAL(toggled(bool)), | ||
812 | parent(), SLOT(setShowRange(bool))); | ||
813 | connect(parent(), SIGNAL(showRangeChanged(bool)), | ||
814 | action, SLOT(setOn(bool))); | ||
815 | action->setOn(showRange); | ||
816 | action->addTo(headerPopup); | ||
817 | action = new QAction("Show Data", 0, this); | ||
818 | action->setToggleAction(TRUE); | ||
819 | connect(action, SIGNAL(toggled(bool)), | ||
820 | parent(), SLOT(setShowData(bool))); | ||
821 | connect(parent(), SIGNAL(showDataChanged(bool)), | ||
822 | action, SLOT(setOn(bool))); | ||
823 | action->setOn(showData); | ||
824 | action->addTo(headerPopup); | ||
825 | } | ||
826 | headerPopup->exec(e->globalPos()); | ||
827 | e->accept(); | ||
828 | } else | ||
829 | e->ignore(); | ||
766 | } | 830 | } |
767 | 831 | ||
768 | ConfigView* ConfigView::viewList; | 832 | ConfigView* ConfigView::viewList; |
769 | 833 | ||
770 | ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview, | 834 | ConfigView::ConfigView(QWidget* parent, const char *name) |
771 | ConfigSettings *configSettings) | 835 | : Parent(parent, name) |
772 | : Parent(parent) | ||
773 | { | 836 | { |
774 | list = new ConfigList(this, cview, configSettings); | 837 | list = new ConfigList(this, name); |
775 | lineEdit = new ConfigLineEdit(this); | 838 | lineEdit = new ConfigLineEdit(this); |
776 | lineEdit->hide(); | 839 | lineEdit->hide(); |
777 | 840 | ||
@@ -791,6 +854,50 @@ ConfigView::~ConfigView(void) | |||
791 | } | 854 | } |
792 | } | 855 | } |
793 | 856 | ||
857 | void ConfigView::setShowAll(bool b) | ||
858 | { | ||
859 | if (list->showAll != b) { | ||
860 | list->showAll = b; | ||
861 | list->updateListAll(); | ||
862 | emit showAllChanged(b); | ||
863 | } | ||
864 | } | ||
865 | |||
866 | void ConfigView::setShowName(bool b) | ||
867 | { | ||
868 | if (list->showName != b) { | ||
869 | list->showName = b; | ||
870 | list->reinit(); | ||
871 | emit showNameChanged(b); | ||
872 | } | ||
873 | } | ||
874 | |||
875 | void ConfigView::setShowRange(bool b) | ||
876 | { | ||
877 | if (list->showRange != b) { | ||
878 | list->showRange = b; | ||
879 | list->reinit(); | ||
880 | emit showRangeChanged(b); | ||
881 | } | ||
882 | } | ||
883 | |||
884 | void ConfigView::setShowData(bool b) | ||
885 | { | ||
886 | if (list->showData != b) { | ||
887 | list->showData = b; | ||
888 | list->reinit(); | ||
889 | emit showDataChanged(b); | ||
890 | } | ||
891 | } | ||
892 | |||
893 | void ConfigList::setAllOpen(bool open) | ||
894 | { | ||
895 | QListViewItemIterator it(this); | ||
896 | |||
897 | for (; it.current(); it++) | ||
898 | it.current()->setOpen(open); | ||
899 | } | ||
900 | |||
794 | void ConfigView::updateList(ConfigItem* item) | 901 | void ConfigView::updateList(ConfigItem* item) |
795 | { | 902 | { |
796 | ConfigView* v; | 903 | ConfigView* v; |
@@ -807,6 +914,347 @@ void ConfigView::updateListAll(void) | |||
807 | v->list->updateListAll(); | 914 | v->list->updateListAll(); |
808 | } | 915 | } |
809 | 916 | ||
917 | ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) | ||
918 | : Parent(parent, name), menu(0) | ||
919 | { | ||
920 | if (name) { | ||
921 | configSettings->beginGroup(name); | ||
922 | _showDebug = configSettings->readBoolEntry("/showDebug", false); | ||
923 | configSettings->endGroup(); | ||
924 | connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); | ||
925 | } | ||
926 | } | ||
927 | |||
928 | void ConfigInfoView::saveSettings(void) | ||
929 | { | ||
930 | if (name()) { | ||
931 | configSettings->beginGroup(name()); | ||
932 | configSettings->writeEntry("/showDebug", showDebug()); | ||
933 | configSettings->endGroup(); | ||
934 | } | ||
935 | } | ||
936 | |||
937 | void ConfigInfoView::setShowDebug(bool b) | ||
938 | { | ||
939 | if (_showDebug != b) { | ||
940 | _showDebug = b; | ||
941 | if (menu) | ||
942 | menuInfo(); | ||
943 | else if (sym) | ||
944 | symbolInfo(); | ||
945 | emit showDebugChanged(b); | ||
946 | } | ||
947 | } | ||
948 | |||
949 | void ConfigInfoView::setInfo(struct menu *m) | ||
950 | { | ||
951 | if (menu == m) | ||
952 | return; | ||
953 | menu = m; | ||
954 | if (!menu) | ||
955 | clear(); | ||
956 | else | ||
957 | menuInfo(); | ||
958 | } | ||
959 | |||
960 | void ConfigInfoView::setSource(const QString& name) | ||
961 | { | ||
962 | const char *p = name.latin1(); | ||
963 | |||
964 | menu = NULL; | ||
965 | sym = NULL; | ||
966 | |||
967 | switch (p[0]) { | ||
968 | case 'm': | ||
969 | struct menu *m; | ||
970 | |||
971 | if (sscanf(p, "m%p", &m) == 1 && menu != m) { | ||
972 | menu = m; | ||
973 | menuInfo(); | ||
974 | emit menuSelected(menu); | ||
975 | } | ||
976 | break; | ||
977 | case 's': | ||
978 | struct symbol *s; | ||
979 | |||
980 | if (sscanf(p, "s%p", &s) == 1 && sym != s) { | ||
981 | sym = s; | ||
982 | symbolInfo(); | ||
983 | } | ||
984 | break; | ||
985 | } | ||
986 | } | ||
987 | |||
988 | void ConfigInfoView::symbolInfo(void) | ||
989 | { | ||
990 | QString str; | ||
991 | |||
992 | str += "<big>Symbol: <b>"; | ||
993 | str += print_filter(sym->name); | ||
994 | str += "</b></big><br><br>value: "; | ||
995 | str += print_filter(sym_get_string_value(sym)); | ||
996 | str += "<br>visibility: "; | ||
997 | str += sym->visible == yes ? "y" : sym->visible == mod ? "m" : "n"; | ||
998 | str += "<br>"; | ||
999 | str += debug_info(sym); | ||
1000 | |||
1001 | setText(str); | ||
1002 | } | ||
1003 | |||
1004 | void ConfigInfoView::menuInfo(void) | ||
1005 | { | ||
1006 | struct symbol* sym; | ||
1007 | QString head, debug, help; | ||
1008 | |||
1009 | sym = menu->sym; | ||
1010 | if (sym) { | ||
1011 | if (menu->prompt) { | ||
1012 | head += "<big><b>"; | ||
1013 | head += print_filter(_(menu->prompt->text)); | ||
1014 | head += "</b></big>"; | ||
1015 | if (sym->name) { | ||
1016 | head += " ("; | ||
1017 | if (showDebug()) | ||
1018 | head += QString().sprintf("<a href=\"s%p\">", sym); | ||
1019 | head += print_filter(sym->name); | ||
1020 | if (showDebug()) | ||
1021 | head += "</a>"; | ||
1022 | head += ")"; | ||
1023 | } | ||
1024 | } else if (sym->name) { | ||
1025 | head += "<big><b>"; | ||
1026 | if (showDebug()) | ||
1027 | head += QString().sprintf("<a href=\"s%p\">", sym); | ||
1028 | head += print_filter(sym->name); | ||
1029 | if (showDebug()) | ||
1030 | head += "</a>"; | ||
1031 | head += "</b></big>"; | ||
1032 | } | ||
1033 | head += "<br><br>"; | ||
1034 | |||
1035 | if (showDebug()) | ||
1036 | debug = debug_info(sym); | ||
1037 | |||
1038 | help = print_filter(_(sym->help)); | ||
1039 | } else if (menu->prompt) { | ||
1040 | head += "<big><b>"; | ||
1041 | head += print_filter(_(menu->prompt->text)); | ||
1042 | head += "</b></big><br><br>"; | ||
1043 | if (showDebug()) { | ||
1044 | if (menu->prompt->visible.expr) { | ||
1045 | debug += " dep: "; | ||
1046 | expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); | ||
1047 | debug += "<br><br>"; | ||
1048 | } | ||
1049 | } | ||
1050 | } | ||
1051 | if (showDebug()) | ||
1052 | debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno); | ||
1053 | |||
1054 | setText(head + debug + help); | ||
1055 | } | ||
1056 | |||
1057 | QString ConfigInfoView::debug_info(struct symbol *sym) | ||
1058 | { | ||
1059 | QString debug; | ||
1060 | |||
1061 | debug += "type: "; | ||
1062 | debug += print_filter(sym_type_name(sym->type)); | ||
1063 | if (sym_is_choice(sym)) | ||
1064 | debug += " (choice)"; | ||
1065 | debug += "<br>"; | ||
1066 | if (sym->rev_dep.expr) { | ||
1067 | debug += "reverse dep: "; | ||
1068 | expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); | ||
1069 | debug += "<br>"; | ||
1070 | } | ||
1071 | for (struct property *prop = sym->prop; prop; prop = prop->next) { | ||
1072 | switch (prop->type) { | ||
1073 | case P_PROMPT: | ||
1074 | case P_MENU: | ||
1075 | debug += QString().sprintf("prompt: <a href=\"m%p\">", prop->menu); | ||
1076 | debug += print_filter(_(prop->text)); | ||
1077 | debug += "</a><br>"; | ||
1078 | break; | ||
1079 | case P_DEFAULT: | ||
1080 | debug += "default: "; | ||
1081 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1082 | debug += "<br>"; | ||
1083 | break; | ||
1084 | case P_CHOICE: | ||
1085 | if (sym_is_choice(sym)) { | ||
1086 | debug += "choice: "; | ||
1087 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1088 | debug += "<br>"; | ||
1089 | } | ||
1090 | break; | ||
1091 | case P_SELECT: | ||
1092 | debug += "select: "; | ||
1093 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1094 | debug += "<br>"; | ||
1095 | break; | ||
1096 | case P_RANGE: | ||
1097 | debug += "range: "; | ||
1098 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1099 | debug += "<br>"; | ||
1100 | break; | ||
1101 | default: | ||
1102 | debug += "unknown property: "; | ||
1103 | debug += prop_get_type_name(prop->type); | ||
1104 | debug += "<br>"; | ||
1105 | } | ||
1106 | if (prop->visible.expr) { | ||
1107 | debug += " dep: "; | ||
1108 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); | ||
1109 | debug += "<br>"; | ||
1110 | } | ||
1111 | } | ||
1112 | debug += "<br>"; | ||
1113 | |||
1114 | return debug; | ||
1115 | } | ||
1116 | |||
1117 | QString ConfigInfoView::print_filter(const QString &str) | ||
1118 | { | ||
1119 | QRegExp re("[<>&\"\\n]"); | ||
1120 | QString res = str; | ||
1121 | for (int i = 0; (i = res.find(re, i)) >= 0;) { | ||
1122 | switch (res[i].latin1()) { | ||
1123 | case '<': | ||
1124 | res.replace(i, 1, "<"); | ||
1125 | i += 4; | ||
1126 | break; | ||
1127 | case '>': | ||
1128 | res.replace(i, 1, ">"); | ||
1129 | i += 4; | ||
1130 | break; | ||
1131 | case '&': | ||
1132 | res.replace(i, 1, "&"); | ||
1133 | i += 5; | ||
1134 | break; | ||
1135 | case '"': | ||
1136 | res.replace(i, 1, """); | ||
1137 | i += 6; | ||
1138 | break; | ||
1139 | case '\n': | ||
1140 | res.replace(i, 1, "<br>"); | ||
1141 | i += 4; | ||
1142 | break; | ||
1143 | } | ||
1144 | } | ||
1145 | return res; | ||
1146 | } | ||
1147 | |||
1148 | void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str) | ||
1149 | { | ||
1150 | QString* text = reinterpret_cast<QString*>(data); | ||
1151 | QString str2 = print_filter(str); | ||
1152 | |||
1153 | if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) { | ||
1154 | *text += QString().sprintf("<a href=\"s%p\">", sym); | ||
1155 | *text += str2; | ||
1156 | *text += "</a>"; | ||
1157 | } else | ||
1158 | *text += str2; | ||
1159 | } | ||
1160 | |||
1161 | QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos) | ||
1162 | { | ||
1163 | QPopupMenu* popup = Parent::createPopupMenu(pos); | ||
1164 | QAction* action = new QAction("Show Debug Info", 0, popup); | ||
1165 | action->setToggleAction(TRUE); | ||
1166 | connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); | ||
1167 | connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); | ||
1168 | action->setOn(showDebug()); | ||
1169 | popup->insertSeparator(); | ||
1170 | action->addTo(popup); | ||
1171 | return popup; | ||
1172 | } | ||
1173 | |||
1174 | void ConfigInfoView::contentsContextMenuEvent(QContextMenuEvent *e) | ||
1175 | { | ||
1176 | Parent::contentsContextMenuEvent(e); | ||
1177 | } | ||
1178 | |||
1179 | ConfigSearchWindow::ConfigSearchWindow(QWidget* parent, const char *name) | ||
1180 | : Parent(parent, name), result(NULL) | ||
1181 | { | ||
1182 | setCaption("Search Config"); | ||
1183 | |||
1184 | QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6); | ||
1185 | QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 6); | ||
1186 | layout2->addWidget(new QLabel("Find:", this)); | ||
1187 | editField = new QLineEdit(this); | ||
1188 | connect(editField, SIGNAL(returnPressed()), SLOT(search())); | ||
1189 | layout2->addWidget(editField); | ||
1190 | searchButton = new QPushButton("Search", this); | ||
1191 | searchButton->setAutoDefault(FALSE); | ||
1192 | connect(searchButton, SIGNAL(clicked()), SLOT(search())); | ||
1193 | layout2->addWidget(searchButton); | ||
1194 | layout1->addLayout(layout2); | ||
1195 | |||
1196 | split = new QSplitter(this); | ||
1197 | split->setOrientation(QSplitter::Vertical); | ||
1198 | list = new ConfigView(split, name); | ||
1199 | list->list->mode = listMode; | ||
1200 | info = new ConfigInfoView(split, name); | ||
1201 | connect(list->list, SIGNAL(menuChanged(struct menu *)), | ||
1202 | info, SLOT(setInfo(struct menu *))); | ||
1203 | layout1->addWidget(split); | ||
1204 | |||
1205 | if (name) { | ||
1206 | int x, y, width, height; | ||
1207 | bool ok; | ||
1208 | |||
1209 | configSettings->beginGroup(name); | ||
1210 | width = configSettings->readNumEntry("/window width", parent->width() / 2); | ||
1211 | height = configSettings->readNumEntry("/window height", parent->height() / 2); | ||
1212 | resize(width, height); | ||
1213 | x = configSettings->readNumEntry("/window x", 0, &ok); | ||
1214 | if (ok) | ||
1215 | y = configSettings->readNumEntry("/window y", 0, &ok); | ||
1216 | if (ok) | ||
1217 | move(x, y); | ||
1218 | QValueList<int> sizes = configSettings->readSizes("/split", &ok); | ||
1219 | if (ok) | ||
1220 | split->setSizes(sizes); | ||
1221 | configSettings->endGroup(); | ||
1222 | connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); | ||
1223 | } | ||
1224 | } | ||
1225 | |||
1226 | void ConfigSearchWindow::saveSettings(void) | ||
1227 | { | ||
1228 | if (name()) { | ||
1229 | configSettings->beginGroup(name()); | ||
1230 | configSettings->writeEntry("/window x", pos().x()); | ||
1231 | configSettings->writeEntry("/window y", pos().y()); | ||
1232 | configSettings->writeEntry("/window width", size().width()); | ||
1233 | configSettings->writeEntry("/window height", size().height()); | ||
1234 | configSettings->writeSizes("/split", split->sizes()); | ||
1235 | configSettings->endGroup(); | ||
1236 | } | ||
1237 | } | ||
1238 | |||
1239 | void ConfigSearchWindow::search(void) | ||
1240 | { | ||
1241 | struct symbol **p; | ||
1242 | struct property *prop; | ||
1243 | ConfigItem *lastItem = NULL; | ||
1244 | |||
1245 | free(result); | ||
1246 | list->list->clear(); | ||
1247 | |||
1248 | result = sym_re_search(editField->text().latin1()); | ||
1249 | if (!result) | ||
1250 | return; | ||
1251 | for (p = result; *p; p++) { | ||
1252 | for_all_prompts((*p), prop) | ||
1253 | lastItem = new ConfigItem(list->list, lastItem, prop->menu, | ||
1254 | menu_is_visible(prop->menu)); | ||
1255 | } | ||
1256 | } | ||
1257 | |||
810 | /* | 1258 | /* |
811 | * Construct the complete config widget | 1259 | * Construct the complete config widget |
812 | */ | 1260 | */ |
@@ -818,42 +1266,30 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
818 | 1266 | ||
819 | QWidget *d = configApp->desktop(); | 1267 | QWidget *d = configApp->desktop(); |
820 | 1268 | ||
821 | ConfigSettings* configSettings = new ConfigSettings(); | 1269 | width = configSettings->readNumEntry("/window width", d->width() - 64); |
822 | #if QT_VERSION >= 300 | 1270 | height = configSettings->readNumEntry("/window height", d->height() - 64); |
823 | width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64); | ||
824 | height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64); | ||
825 | resize(width, height); | 1271 | resize(width, height); |
826 | x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok); | 1272 | x = configSettings->readNumEntry("/window x", 0, &ok); |
827 | if (ok) | 1273 | if (ok) |
828 | y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok); | 1274 | y = configSettings->readNumEntry("/window y", 0, &ok); |
829 | if (ok) | 1275 | if (ok) |
830 | move(x, y); | 1276 | move(x, y); |
831 | showDebug = configSettings->readBoolEntry("/kconfig/qconf/showDebug", false); | ||
832 | |||
833 | // read list settings into configSettings, will be used later for ConfigList setup | ||
834 | configSettings->readListSettings(); | ||
835 | #else | ||
836 | width = d->width() - 64; | ||
837 | height = d->height() - 64; | ||
838 | resize(width, height); | ||
839 | showDebug = false; | ||
840 | #endif | ||
841 | 1277 | ||
842 | split1 = new QSplitter(this); | 1278 | split1 = new QSplitter(this); |
843 | split1->setOrientation(QSplitter::Horizontal); | 1279 | split1->setOrientation(QSplitter::Horizontal); |
844 | setCentralWidget(split1); | 1280 | setCentralWidget(split1); |
845 | 1281 | ||
846 | menuView = new ConfigView(split1, this, configSettings); | 1282 | menuView = new ConfigView(split1, "menu"); |
847 | menuList = menuView->list; | 1283 | menuList = menuView->list; |
848 | 1284 | ||
849 | split2 = new QSplitter(split1); | 1285 | split2 = new QSplitter(split1); |
850 | split2->setOrientation(QSplitter::Vertical); | 1286 | split2->setOrientation(QSplitter::Vertical); |
851 | 1287 | ||
852 | // create config tree | 1288 | // create config tree |
853 | configView = new ConfigView(split2, this, configSettings); | 1289 | configView = new ConfigView(split2, "config"); |
854 | configList = configView->list; | 1290 | configList = configView->list; |
855 | 1291 | ||
856 | helpText = new QTextView(split2); | 1292 | helpText = new ConfigInfoView(split2, "help"); |
857 | helpText->setTextFormat(Qt::RichText); | 1293 | helpText->setTextFormat(Qt::RichText); |
858 | 1294 | ||
859 | setTabOrder(configList, helpText); | 1295 | setTabOrder(configList, helpText); |
@@ -873,6 +1309,8 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
873 | connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); | 1309 | connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); |
874 | QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); | 1310 | QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); |
875 | connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); | 1311 | connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); |
1312 | QAction *searchAction = new QAction("Search", "&Search", CTRL+Key_F, this); | ||
1313 | connect(searchAction, SIGNAL(activated()), SLOT(searchConfig())); | ||
876 | QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); | 1314 | QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); |
877 | connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); | 1315 | connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); |
878 | QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); | 1316 | QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); |
@@ -882,24 +1320,29 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
882 | 1320 | ||
883 | QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); | 1321 | QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); |
884 | showNameAction->setToggleAction(TRUE); | 1322 | showNameAction->setToggleAction(TRUE); |
885 | showNameAction->setOn(configList->showName); | 1323 | connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool))); |
886 | connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool))); | 1324 | connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool))); |
1325 | showNameAction->setOn(configView->showName()); | ||
887 | QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); | 1326 | QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); |
888 | showRangeAction->setToggleAction(TRUE); | 1327 | showRangeAction->setToggleAction(TRUE); |
1328 | connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); | ||
1329 | connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool))); | ||
889 | showRangeAction->setOn(configList->showRange); | 1330 | showRangeAction->setOn(configList->showRange); |
890 | connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool))); | ||
891 | QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); | 1331 | QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); |
892 | showDataAction->setToggleAction(TRUE); | 1332 | showDataAction->setToggleAction(TRUE); |
1333 | connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); | ||
1334 | connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); | ||
893 | showDataAction->setOn(configList->showData); | 1335 | showDataAction->setOn(configList->showData); |
894 | connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool))); | ||
895 | QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); | 1336 | QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); |
896 | showAllAction->setToggleAction(TRUE); | 1337 | showAllAction->setToggleAction(TRUE); |
1338 | connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool))); | ||
1339 | connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool))); | ||
897 | showAllAction->setOn(configList->showAll); | 1340 | showAllAction->setOn(configList->showAll); |
898 | connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool))); | ||
899 | QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); | 1341 | QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); |
900 | showDebugAction->setToggleAction(TRUE); | 1342 | showDebugAction->setToggleAction(TRUE); |
901 | showDebugAction->setOn(showDebug); | 1343 | connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); |
902 | connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); | 1344 | connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool))); |
1345 | showDebugAction->setOn(helpText->showDebug()); | ||
903 | 1346 | ||
904 | QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this); | 1347 | QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this); |
905 | connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); | 1348 | connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); |
@@ -923,6 +1366,8 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
923 | saveAction->addTo(config); | 1366 | saveAction->addTo(config); |
924 | saveAsAction->addTo(config); | 1367 | saveAsAction->addTo(config); |
925 | config->insertSeparator(); | 1368 | config->insertSeparator(); |
1369 | searchAction->addTo(config); | ||
1370 | config->insertSeparator(); | ||
926 | quitAction->addTo(config); | 1371 | quitAction->addTo(config); |
927 | 1372 | ||
928 | // create options menu | 1373 | // create options menu |
@@ -942,20 +1387,27 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
942 | showIntroAction->addTo(helpMenu); | 1387 | showIntroAction->addTo(helpMenu); |
943 | showAboutAction->addTo(helpMenu); | 1388 | showAboutAction->addTo(helpMenu); |
944 | 1389 | ||
1390 | connect(configList, SIGNAL(menuChanged(struct menu *)), | ||
1391 | helpText, SLOT(setInfo(struct menu *))); | ||
945 | connect(configList, SIGNAL(menuSelected(struct menu *)), | 1392 | connect(configList, SIGNAL(menuSelected(struct menu *)), |
946 | SLOT(changeMenu(struct menu *))); | 1393 | SLOT(changeMenu(struct menu *))); |
947 | connect(configList, SIGNAL(parentSelected()), | 1394 | connect(configList, SIGNAL(parentSelected()), |
948 | SLOT(goBack())); | 1395 | SLOT(goBack())); |
1396 | connect(menuList, SIGNAL(menuChanged(struct menu *)), | ||
1397 | helpText, SLOT(setInfo(struct menu *))); | ||
949 | connect(menuList, SIGNAL(menuSelected(struct menu *)), | 1398 | connect(menuList, SIGNAL(menuSelected(struct menu *)), |
950 | SLOT(changeMenu(struct menu *))); | 1399 | SLOT(changeMenu(struct menu *))); |
951 | 1400 | ||
952 | connect(configList, SIGNAL(gotFocus(void)), | 1401 | connect(configList, SIGNAL(gotFocus(struct menu *)), |
953 | SLOT(listFocusChanged(void))); | 1402 | helpText, SLOT(setInfo(struct menu *))); |
954 | connect(menuList, SIGNAL(gotFocus(void)), | 1403 | connect(menuList, SIGNAL(gotFocus(struct menu *)), |
1404 | helpText, SLOT(setInfo(struct menu *))); | ||
1405 | connect(menuList, SIGNAL(gotFocus(struct menu *)), | ||
955 | SLOT(listFocusChanged(void))); | 1406 | SLOT(listFocusChanged(void))); |
1407 | connect(helpText, SIGNAL(menuSelected(struct menu *)), | ||
1408 | SLOT(setMenuLink(struct menu *))); | ||
956 | 1409 | ||
957 | #if QT_VERSION >= 300 | 1410 | QString listMode = configSettings->readEntry("/listMode", "symbol"); |
958 | QString listMode = configSettings->readEntry("/kconfig/qconf/listMode", "symbol"); | ||
959 | if (listMode == "single") | 1411 | if (listMode == "single") |
960 | showSingleView(); | 1412 | showSingleView(); |
961 | else if (listMode == "full") | 1413 | else if (listMode == "full") |
@@ -964,162 +1416,13 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
964 | showSplitView(); | 1416 | showSplitView(); |
965 | 1417 | ||
966 | // UI setup done, restore splitter positions | 1418 | // UI setup done, restore splitter positions |
967 | QValueList<int> sizes = configSettings->readSizes("/kconfig/qconf/split1", &ok); | 1419 | QValueList<int> sizes = configSettings->readSizes("/split1", &ok); |
968 | if (ok) | 1420 | if (ok) |
969 | split1->setSizes(sizes); | 1421 | split1->setSizes(sizes); |
970 | 1422 | ||
971 | sizes = configSettings->readSizes("/kconfig/qconf/split2", &ok); | 1423 | sizes = configSettings->readSizes("/split2", &ok); |
972 | if (ok) | 1424 | if (ok) |
973 | split2->setSizes(sizes); | 1425 | split2->setSizes(sizes); |
974 | #else | ||
975 | showSplitView(); | ||
976 | #endif | ||
977 | delete configSettings; | ||
978 | } | ||
979 | |||
980 | static QString print_filter(const QString &str) | ||
981 | { | ||
982 | QRegExp re("[<>&\"\\n]"); | ||
983 | QString res = str; | ||
984 | for (int i = 0; (i = res.find(re, i)) >= 0;) { | ||
985 | switch (res[i].latin1()) { | ||
986 | case '<': | ||
987 | res.replace(i, 1, "<"); | ||
988 | i += 4; | ||
989 | break; | ||
990 | case '>': | ||
991 | res.replace(i, 1, ">"); | ||
992 | i += 4; | ||
993 | break; | ||
994 | case '&': | ||
995 | res.replace(i, 1, "&"); | ||
996 | i += 5; | ||
997 | break; | ||
998 | case '"': | ||
999 | res.replace(i, 1, """); | ||
1000 | i += 6; | ||
1001 | break; | ||
1002 | case '\n': | ||
1003 | res.replace(i, 1, "<br>"); | ||
1004 | i += 4; | ||
1005 | break; | ||
1006 | } | ||
1007 | } | ||
1008 | return res; | ||
1009 | } | ||
1010 | |||
1011 | static void expr_print_help(void *data, const char *str) | ||
1012 | { | ||
1013 | reinterpret_cast<QString*>(data)->append(print_filter(str)); | ||
1014 | } | ||
1015 | |||
1016 | /* | ||
1017 | * display a new help entry as soon as a new menu entry is selected | ||
1018 | */ | ||
1019 | void ConfigMainWindow::setHelp(QListViewItem* item) | ||
1020 | { | ||
1021 | struct symbol* sym; | ||
1022 | struct menu* menu = 0; | ||
1023 | |||
1024 | configList->parent()->lineEdit->hide(); | ||
1025 | if (item) | ||
1026 | menu = ((ConfigItem*)item)->menu; | ||
1027 | if (!menu) { | ||
1028 | helpText->setText(QString::null); | ||
1029 | return; | ||
1030 | } | ||
1031 | |||
1032 | QString head, debug, help; | ||
1033 | menu = ((ConfigItem*)item)->menu; | ||
1034 | sym = menu->sym; | ||
1035 | if (sym) { | ||
1036 | if (menu->prompt) { | ||
1037 | head += "<big><b>"; | ||
1038 | head += print_filter(_(menu->prompt->text)); | ||
1039 | head += "</b></big>"; | ||
1040 | if (sym->name) { | ||
1041 | head += " ("; | ||
1042 | head += print_filter(_(sym->name)); | ||
1043 | head += ")"; | ||
1044 | } | ||
1045 | } else if (sym->name) { | ||
1046 | head += "<big><b>"; | ||
1047 | head += print_filter(_(sym->name)); | ||
1048 | head += "</b></big>"; | ||
1049 | } | ||
1050 | head += "<br><br>"; | ||
1051 | |||
1052 | if (showDebug) { | ||
1053 | debug += "type: "; | ||
1054 | debug += print_filter(sym_type_name(sym->type)); | ||
1055 | if (sym_is_choice(sym)) | ||
1056 | debug += " (choice)"; | ||
1057 | debug += "<br>"; | ||
1058 | if (sym->rev_dep.expr) { | ||
1059 | debug += "reverse dep: "; | ||
1060 | expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); | ||
1061 | debug += "<br>"; | ||
1062 | } | ||
1063 | for (struct property *prop = sym->prop; prop; prop = prop->next) { | ||
1064 | switch (prop->type) { | ||
1065 | case P_PROMPT: | ||
1066 | case P_MENU: | ||
1067 | debug += "prompt: "; | ||
1068 | debug += print_filter(_(prop->text)); | ||
1069 | debug += "<br>"; | ||
1070 | break; | ||
1071 | case P_DEFAULT: | ||
1072 | debug += "default: "; | ||
1073 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1074 | debug += "<br>"; | ||
1075 | break; | ||
1076 | case P_CHOICE: | ||
1077 | if (sym_is_choice(sym)) { | ||
1078 | debug += "choice: "; | ||
1079 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1080 | debug += "<br>"; | ||
1081 | } | ||
1082 | break; | ||
1083 | case P_SELECT: | ||
1084 | debug += "select: "; | ||
1085 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1086 | debug += "<br>"; | ||
1087 | break; | ||
1088 | case P_RANGE: | ||
1089 | debug += "range: "; | ||
1090 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1091 | debug += "<br>"; | ||
1092 | break; | ||
1093 | default: | ||
1094 | debug += "unknown property: "; | ||
1095 | debug += prop_get_type_name(prop->type); | ||
1096 | debug += "<br>"; | ||
1097 | } | ||
1098 | if (prop->visible.expr) { | ||
1099 | debug += " dep: "; | ||
1100 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); | ||
1101 | debug += "<br>"; | ||
1102 | } | ||
1103 | } | ||
1104 | debug += "<br>"; | ||
1105 | } | ||
1106 | |||
1107 | help = print_filter(_(sym->help)); | ||
1108 | } else if (menu->prompt) { | ||
1109 | head += "<big><b>"; | ||
1110 | head += print_filter(_(menu->prompt->text)); | ||
1111 | head += "</b></big><br><br>"; | ||
1112 | if (showDebug) { | ||
1113 | if (menu->prompt->visible.expr) { | ||
1114 | debug += " dep: "; | ||
1115 | expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); | ||
1116 | debug += "<br><br>"; | ||
1117 | } | ||
1118 | } | ||
1119 | } | ||
1120 | if (showDebug) | ||
1121 | debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno); | ||
1122 | helpText->setText(head + debug + help); | ||
1123 | } | 1426 | } |
1124 | 1427 | ||
1125 | void ConfigMainWindow::loadConfig(void) | 1428 | void ConfigMainWindow::loadConfig(void) |
@@ -1147,21 +1450,73 @@ void ConfigMainWindow::saveConfigAs(void) | |||
1147 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); | 1450 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); |
1148 | } | 1451 | } |
1149 | 1452 | ||
1453 | void ConfigMainWindow::searchConfig(void) | ||
1454 | { | ||
1455 | if (!searchWindow) | ||
1456 | searchWindow = new ConfigSearchWindow(this, "search"); | ||
1457 | searchWindow->show(); | ||
1458 | } | ||
1459 | |||
1150 | void ConfigMainWindow::changeMenu(struct menu *menu) | 1460 | void ConfigMainWindow::changeMenu(struct menu *menu) |
1151 | { | 1461 | { |
1152 | configList->setRootMenu(menu); | 1462 | configList->setRootMenu(menu); |
1153 | backAction->setEnabled(TRUE); | 1463 | backAction->setEnabled(TRUE); |
1154 | } | 1464 | } |
1155 | 1465 | ||
1156 | void ConfigMainWindow::listFocusChanged(void) | 1466 | void ConfigMainWindow::setMenuLink(struct menu *menu) |
1157 | { | 1467 | { |
1158 | if (menuList->hasFocus()) { | 1468 | struct menu *parent; |
1159 | if (menuList->mode == menuMode) | 1469 | ConfigList* list = NULL; |
1470 | ConfigItem* item; | ||
1471 | |||
1472 | if (!menu_is_visible(menu) && !configView->showAll()) | ||
1473 | return; | ||
1474 | |||
1475 | switch (configList->mode) { | ||
1476 | case singleMode: | ||
1477 | list = configList; | ||
1478 | parent = menu_get_parent_menu(menu); | ||
1479 | if (!parent) | ||
1480 | return; | ||
1481 | list->setRootMenu(parent); | ||
1482 | break; | ||
1483 | case symbolMode: | ||
1484 | if (menu->flags & MENU_ROOT) { | ||
1485 | configList->setRootMenu(menu); | ||
1160 | configList->clearSelection(); | 1486 | configList->clearSelection(); |
1161 | setHelp(menuList->selectedItem()); | 1487 | list = menuList; |
1162 | } else if (configList->hasFocus()) { | 1488 | } else { |
1163 | setHelp(configList->selectedItem()); | 1489 | list = configList; |
1490 | parent = menu_get_parent_menu(menu->parent); | ||
1491 | if (!parent) | ||
1492 | return; | ||
1493 | item = menuList->findConfigItem(parent); | ||
1494 | if (item) { | ||
1495 | menuList->setSelected(item, TRUE); | ||
1496 | menuList->ensureItemVisible(item); | ||
1497 | } | ||
1498 | list->setRootMenu(parent); | ||
1499 | } | ||
1500 | break; | ||
1501 | case fullMode: | ||
1502 | list = configList; | ||
1503 | break; | ||
1164 | } | 1504 | } |
1505 | |||
1506 | if (list) { | ||
1507 | item = list->findConfigItem(menu); | ||
1508 | if (item) { | ||
1509 | list->setSelected(item, TRUE); | ||
1510 | list->ensureItemVisible(item); | ||
1511 | list->setFocus(); | ||
1512 | } | ||
1513 | } | ||
1514 | } | ||
1515 | |||
1516 | void ConfigMainWindow::listFocusChanged(void) | ||
1517 | { | ||
1518 | if (menuList->mode == menuMode) | ||
1519 | configList->clearSelection(); | ||
1165 | } | 1520 | } |
1166 | 1521 | ||
1167 | void ConfigMainWindow::goBack(void) | 1522 | void ConfigMainWindow::goBack(void) |
@@ -1223,53 +1578,6 @@ void ConfigMainWindow::showFullView(void) | |||
1223 | configList->setFocus(); | 1578 | configList->setFocus(); |
1224 | } | 1579 | } |
1225 | 1580 | ||
1226 | void ConfigMainWindow::setShowAll(bool b) | ||
1227 | { | ||
1228 | if (configList->showAll == b) | ||
1229 | return; | ||
1230 | configList->showAll = b; | ||
1231 | configList->updateListAll(); | ||
1232 | menuList->showAll = b; | ||
1233 | menuList->updateListAll(); | ||
1234 | } | ||
1235 | |||
1236 | void ConfigMainWindow::setShowDebug(bool b) | ||
1237 | { | ||
1238 | if (showDebug == b) | ||
1239 | return; | ||
1240 | showDebug = b; | ||
1241 | } | ||
1242 | |||
1243 | void ConfigMainWindow::setShowName(bool b) | ||
1244 | { | ||
1245 | if (configList->showName == b) | ||
1246 | return; | ||
1247 | configList->showName = b; | ||
1248 | configList->reinit(); | ||
1249 | menuList->showName = b; | ||
1250 | menuList->reinit(); | ||
1251 | } | ||
1252 | |||
1253 | void ConfigMainWindow::setShowRange(bool b) | ||
1254 | { | ||
1255 | if (configList->showRange == b) | ||
1256 | return; | ||
1257 | configList->showRange = b; | ||
1258 | configList->reinit(); | ||
1259 | menuList->showRange = b; | ||
1260 | menuList->reinit(); | ||
1261 | } | ||
1262 | |||
1263 | void ConfigMainWindow::setShowData(bool b) | ||
1264 | { | ||
1265 | if (configList->showData == b) | ||
1266 | return; | ||
1267 | configList->showData = b; | ||
1268 | configList->reinit(); | ||
1269 | menuList->showData = b; | ||
1270 | menuList->reinit(); | ||
1271 | } | ||
1272 | |||
1273 | /* | 1581 | /* |
1274 | * ask for saving configuration before quitting | 1582 | * ask for saving configuration before quitting |
1275 | * TODO ask only when something changed | 1583 | * TODO ask only when something changed |
@@ -1324,17 +1632,10 @@ void ConfigMainWindow::showAbout(void) | |||
1324 | 1632 | ||
1325 | void ConfigMainWindow::saveSettings(void) | 1633 | void ConfigMainWindow::saveSettings(void) |
1326 | { | 1634 | { |
1327 | #if QT_VERSION >= 300 | 1635 | configSettings->writeEntry("/window x", pos().x()); |
1328 | ConfigSettings *configSettings = new ConfigSettings; | 1636 | configSettings->writeEntry("/window y", pos().y()); |
1329 | configSettings->writeEntry("/kconfig/qconf/window x", pos().x()); | 1637 | configSettings->writeEntry("/window width", size().width()); |
1330 | configSettings->writeEntry("/kconfig/qconf/window y", pos().y()); | 1638 | configSettings->writeEntry("/window height", size().height()); |
1331 | configSettings->writeEntry("/kconfig/qconf/window width", size().width()); | ||
1332 | configSettings->writeEntry("/kconfig/qconf/window height", size().height()); | ||
1333 | configSettings->writeEntry("/kconfig/qconf/showName", configList->showName); | ||
1334 | configSettings->writeEntry("/kconfig/qconf/showRange", configList->showRange); | ||
1335 | configSettings->writeEntry("/kconfig/qconf/showData", configList->showData); | ||
1336 | configSettings->writeEntry("/kconfig/qconf/showAll", configList->showAll); | ||
1337 | configSettings->writeEntry("/kconfig/qconf/showDebug", showDebug); | ||
1338 | 1639 | ||
1339 | QString entry; | 1640 | QString entry; |
1340 | switch(configList->mode) { | 1641 | switch(configList->mode) { |
@@ -1350,13 +1651,10 @@ void ConfigMainWindow::saveSettings(void) | |||
1350 | entry = "full"; | 1651 | entry = "full"; |
1351 | break; | 1652 | break; |
1352 | } | 1653 | } |
1353 | configSettings->writeEntry("/kconfig/qconf/listMode", entry); | 1654 | configSettings->writeEntry("/listMode", entry); |
1354 | 1655 | ||
1355 | configSettings->writeSizes("/kconfig/qconf/split1", split1->sizes()); | 1656 | configSettings->writeSizes("/split1", split1->sizes()); |
1356 | configSettings->writeSizes("/kconfig/qconf/split2", split2->sizes()); | 1657 | configSettings->writeSizes("/split2", split2->sizes()); |
1357 | |||
1358 | delete configSettings; | ||
1359 | #endif | ||
1360 | } | 1658 | } |
1361 | 1659 | ||
1362 | void fixup_rootmenu(struct menu *menu) | 1660 | void fixup_rootmenu(struct menu *menu) |
@@ -1414,13 +1712,19 @@ int main(int ac, char** av) | |||
1414 | conf_read(NULL); | 1712 | conf_read(NULL); |
1415 | //zconfdump(stdout); | 1713 | //zconfdump(stdout); |
1416 | 1714 | ||
1715 | configSettings = new ConfigSettings(); | ||
1716 | configSettings->beginGroup("/kconfig/qconf"); | ||
1417 | v = new ConfigMainWindow(); | 1717 | v = new ConfigMainWindow(); |
1418 | 1718 | ||
1419 | //zconfdump(stdout); | 1719 | //zconfdump(stdout); |
1420 | v->show(); | 1720 | configApp->setMainWidget(v); |
1421 | configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); | 1721 | configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); |
1422 | configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings())); | 1722 | configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings())); |
1723 | v->show(); | ||
1423 | configApp->exec(); | 1724 | configApp->exec(); |
1424 | 1725 | ||
1726 | configSettings->endGroup(); | ||
1727 | delete configSettings; | ||
1728 | |||
1425 | return 0; | 1729 | return 0; |
1426 | } | 1730 | } |