~ubuntu-branches/ubuntu/trusty/apex/trusty

« back to all changes in this revision

Viewing changes to scripts/kconfig/qconf.cc

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2009-11-10 11:55:15 UTC
  • mfrom: (2.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091110115515-6jjsf6rc8py35awe
Tags: 1.6.10ubuntu1
* Merge from debian testing, remaining changes:
  - Move apex VMA address to 4MiB to leave enough space for the ubuntu
  kernel and not overwrite apex in ram when loading.
  - nslu2 configuration: set CONFIG_RAMDISK_SIZE=0x0055FFF0 instead of
  0x005FFFF0 to make enough room for ubuntu initramfs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
#include <qapplication.h>
7
7
#include <qmainwindow.h>
8
8
#include <qtoolbar.h>
 
9
#include <qlayout.h>
9
10
#include <qvbox.h>
10
11
#include <qsplitter.h>
11
12
#include <qlistview.h>
12
 
#include <qtextview.h>
 
13
#include <qtextbrowser.h>
13
14
#include <qlineedit.h>
 
15
#include <qlabel.h>
 
16
#include <qpushbutton.h>
14
17
#include <qmenubar.h>
15
18
#include <qmessagebox.h>
16
19
#include <qaction.h>
17
20
#include <qheader.h>
18
21
#include <qfiledialog.h>
 
22
#include <qdragobject.h>
19
23
#include <qregexp.h>
20
24
 
21
25
#include <stdlib.h>
32
36
#endif
33
37
 
34
38
static QApplication *configApp;
 
39
static ConfigSettings *configSettings;
 
40
 
 
41
QAction *ConfigMainWindow::saveAction;
35
42
 
36
43
static inline QString qgettext(const char* str)
37
44
{
38
 
  return QString::fromLocal8Bit(gettext(str));
 
45
        return QString::fromLocal8Bit(gettext(str));
39
46
}
40
47
 
41
48
static inline QString qgettext(const QString& str)
42
49
{
43
 
  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);
 
50
        return QString::fromLocal8Bit(gettext(str.latin1()));
61
51
}
62
52
 
63
53
/**
88
78
                stringList.push_back(QString::number(*it));
89
79
        return writeEntry(key, stringList);
90
80
}
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
 
 
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
 
}
 
81
 
161
82
 
162
83
#if QT_VERSION >= 300
163
84
/*
168
89
{
169
90
        Parent::okRename(col);
170
91
        sym_set_string_value(menu->sym, text(dataColIdx).latin1());
 
92
        listView()->updateList(this);
171
93
}
172
94
#endif
173
95
 
192
114
 
193
115
        sym = menu->sym;
194
116
        prop = menu->prompt;
195
 
        prompt = QString::fromLocal8Bit(menu_get_prompt(menu));
 
117
        prompt = _(menu_get_prompt(menu));
196
118
 
197
119
        if (prop) switch (prop->type) {
198
120
        case P_MENU:
286
208
                break;
287
209
        }
288
210
        if (!sym_has_value(sym) && visible)
289
 
                prompt += " (NEW)";
 
211
                prompt += _(" (NEW)");
290
212
set_prompt:
291
213
        setText(promptColIdx, prompt);
292
214
}
355
277
        }
356
278
}
357
279
 
 
280
ConfigLineEdit::ConfigLineEdit(ConfigView* parent)
 
281
        : Parent(parent)
 
282
{
 
283
        connect(this, SIGNAL(lostFocus()), SLOT(hide()));
 
284
}
 
285
 
358
286
void ConfigLineEdit::show(ConfigItem* i)
359
287
{
360
288
        item = i;
385
313
        hide();
386
314
}
387
315
 
388
 
ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv, ConfigSettings* configSettings)
389
 
        : Parent(p), cview(cv),
 
316
ConfigList::ConfigList(ConfigView* p, const char *name)
 
317
        : Parent(p, name),
390
318
          updateAll(false),
391
319
          symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
392
320
          choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
393
321
          menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),
394
322
          showAll(false), showName(false), showRange(false), showData(false),
395
 
          rootEntry(0)
 
323
          rootEntry(0), headerPopup(0)
396
324
{
397
325
        int i;
398
326
 
406
334
        connect(this, SIGNAL(selectionChanged(void)),
407
335
                SLOT(updateSelection(void)));
408
336
 
409
 
        if (configSettings) {
410
 
                showAll = configSettings->showAll;
411
 
                showName = configSettings->showName;
412
 
                showRange = configSettings->showRange;
413
 
                showData = configSettings->showData;
 
337
        if (name) {
 
338
                configSettings->beginGroup(name);
 
339
                showAll = configSettings->readBoolEntry("/showAll", false);
 
340
                showName = configSettings->readBoolEntry("/showName", false);
 
341
                showRange = configSettings->readBoolEntry("/showRange", false);
 
342
                showData = configSettings->readBoolEntry("/showData", false);
 
343
                configSettings->endGroup();
 
344
                connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
414
345
        }
415
346
 
416
347
        for (i = 0; i < colNr; i++)
417
348
                colMap[i] = colRevMap[i] = -1;
418
 
        addColumn(promptColIdx, "Option");
 
349
        addColumn(promptColIdx, _("Option"));
419
350
 
420
351
        reinit();
421
352
}
429
360
        removeColumn(nameColIdx);
430
361
 
431
362
        if (showName)
432
 
                addColumn(nameColIdx, "Name");
 
363
                addColumn(nameColIdx, _("Name"));
433
364
        if (showRange) {
434
365
                addColumn(noColIdx, "N");
435
366
                addColumn(modColIdx, "M");
436
367
                addColumn(yesColIdx, "Y");
437
368
        }
438
369
        if (showData)
439
 
                addColumn(dataColIdx, "Value");
 
370
                addColumn(dataColIdx, _("Value"));
440
371
 
441
372
        updateListAll();
442
373
}
443
374
 
 
375
void ConfigList::saveSettings(void)
 
376
{
 
377
        if (name()) {
 
378
                configSettings->beginGroup(name());
 
379
                configSettings->writeEntry("/showName", showName);
 
380
                configSettings->writeEntry("/showRange", showRange);
 
381
                configSettings->writeEntry("/showData", showData);
 
382
                configSettings->writeEntry("/showAll", showAll);
 
383
                configSettings->endGroup();
 
384
        }
 
385
}
 
386
 
 
387
ConfigItem* ConfigList::findConfigItem(struct menu *menu)
 
388
{
 
389
        ConfigItem* item = (ConfigItem*)menu->data;
 
390
 
 
391
        for (; item; item = item->nextItem) {
 
392
                if (this == item->listView())
 
393
                        break;
 
394
        }
 
395
 
 
396
        return item;
 
397
}
 
398
 
444
399
void ConfigList::updateSelection(void)
445
400
{
446
401
        struct menu *menu;
450
405
        if (!item)
451
406
                return;
452
407
 
453
 
        cview->setHelp(item);
454
 
 
455
408
        menu = item->menu;
 
409
        emit menuChanged(menu);
456
410
        if (!menu)
457
411
                return;
458
412
        type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
464
418
{
465
419
        ConfigItem* last = 0;
466
420
 
467
 
        if (!rootEntry)
468
 
                goto update;
 
421
        if (!rootEntry) {
 
422
                if (mode != listMode)
 
423
                        goto update;
 
424
                QListViewItemIterator it(this);
 
425
                ConfigItem* item;
 
426
 
 
427
                for (; it.current(); ++it) {
 
428
                        item = (ConfigItem*)it.current();
 
429
                        if (!item->menu)
 
430
                                continue;
 
431
                        item->testUpdateMenu(menu_is_visible(item->menu));
 
432
                }
 
433
                return;
 
434
        }
469
435
 
470
436
        if (rootEntry != &rootmenu && (mode == singleMode ||
471
437
            (mode == symbolMode && rootEntry->parent != &rootmenu))) {
491
457
        triggerUpdate();
492
458
}
493
459
 
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
460
void ConfigList::setValue(ConfigItem* item, tristate val)
503
461
{
504
462
        struct symbol* sym;
581
539
        rootEntry = menu;
582
540
        updateListAll();
583
541
        setSelected(currentItem(), hasFocus());
 
542
        ensureItemVisible(currentItem());
584
543
}
585
544
 
586
545
void ConfigList::setParentMenu(void)
603
562
        }
604
563
}
605
564
 
 
565
/*
 
566
 * update all the children of a menu entry
 
567
 *   removes/adds the entries from the parent widget as necessary
 
568
 *
 
569
 * parent: either the menu list widget or a menu entry widget
 
570
 * menu: entry to be updated
 
571
 */
 
572
template <class P>
 
573
void ConfigList::updateMenuList(P* parent, struct menu* menu)
 
574
{
 
575
        struct menu* child;
 
576
        ConfigItem* item;
 
577
        ConfigItem* last;
 
578
        bool visible;
 
579
        enum prop_type type;
 
580
 
 
581
        if (!menu) {
 
582
                while ((item = parent->firstChild()))
 
583
                        delete item;
 
584
                return;
 
585
        }
 
586
 
 
587
        last = parent->firstChild();
 
588
        if (last && !last->goParent)
 
589
                last = 0;
 
590
        for (child = menu->list; child; child = child->next) {
 
591
                item = last ? last->nextSibling() : parent->firstChild();
 
592
                type = child->prompt ? child->prompt->type : P_UNKNOWN;
 
593
 
 
594
                switch (mode) {
 
595
                case menuMode:
 
596
                        if (!(child->flags & MENU_ROOT))
 
597
                                goto hide;
 
598
                        break;
 
599
                case symbolMode:
 
600
                        if (child->flags & MENU_ROOT)
 
601
                                goto hide;
 
602
                        break;
 
603
                default:
 
604
                        break;
 
605
                }
 
606
 
 
607
                visible = menu_is_visible(child);
 
608
                if (showAll || visible) {
 
609
                        if (!child->sym && !child->list && !child->prompt)
 
610
                                continue;
 
611
                        if (!item || item->menu != child)
 
612
                                item = new ConfigItem(parent, last, child, visible);
 
613
                        else
 
614
                                item->testUpdateMenu(visible);
 
615
 
 
616
                        if (mode == fullMode || mode == menuMode || type != P_MENU)
 
617
                                updateMenuList(item, child);
 
618
                        else
 
619
                                updateMenuList(item, 0);
 
620
                        last = item;
 
621
                        continue;
 
622
                }
 
623
        hide:
 
624
                if (item && item->menu == child) {
 
625
                        last = parent->firstChild();
 
626
                        if (last == item)
 
627
                                last = 0;
 
628
                        else while (last->nextSibling() != item)
 
629
                                last = last->nextSibling();
 
630
                        delete item;
 
631
                }
 
632
        }
 
633
}
 
634
 
606
635
void ConfigList::keyPressEvent(QKeyEvent* ev)
607
636
{
608
637
        QListViewItem* i = currentItem();
610
639
        struct menu *menu;
611
640
        enum prop_type type;
612
641
 
613
 
        if (ev->key() == Key_Escape && mode != fullMode) {
 
642
        if (ev->key() == Key_Escape && mode != fullMode && mode != listMode) {
614
643
                emit parentSelected();
615
644
                ev->accept();
616
645
                return;
755
784
 
756
785
void ConfigList::focusInEvent(QFocusEvent *e)
757
786
{
 
787
        struct menu *menu = NULL;
 
788
 
758
789
        Parent::focusInEvent(e);
759
790
 
760
 
        QListViewItem* item = currentItem();
761
 
        if (!item)
762
 
                return;
763
 
 
764
 
        setSelected(item, TRUE);
765
 
        emit gotFocus();
 
791
        ConfigItem* item = (ConfigItem *)currentItem();
 
792
        if (item) {
 
793
                setSelected(item, TRUE);
 
794
                menu = item->menu;
 
795
        }
 
796
        emit gotFocus(menu);
 
797
}
 
798
 
 
799
void ConfigList::contextMenuEvent(QContextMenuEvent *e)
 
800
{
 
801
        if (e->y() <= header()->geometry().bottom()) {
 
802
                if (!headerPopup) {
 
803
                        QAction *action;
 
804
 
 
805
                        headerPopup = new QPopupMenu(this);
 
806
                        action = new QAction(NULL, _("Show Name"), 0, this);
 
807
                          action->setToggleAction(TRUE);
 
808
                          connect(action, SIGNAL(toggled(bool)),
 
809
                                  parent(), SLOT(setShowName(bool)));
 
810
                          connect(parent(), SIGNAL(showNameChanged(bool)),
 
811
                                  action, SLOT(setOn(bool)));
 
812
                          action->setOn(showName);
 
813
                          action->addTo(headerPopup);
 
814
                        action = new QAction(NULL, _("Show Range"), 0, this);
 
815
                          action->setToggleAction(TRUE);
 
816
                          connect(action, SIGNAL(toggled(bool)),
 
817
                                  parent(), SLOT(setShowRange(bool)));
 
818
                          connect(parent(), SIGNAL(showRangeChanged(bool)),
 
819
                                  action, SLOT(setOn(bool)));
 
820
                          action->setOn(showRange);
 
821
                          action->addTo(headerPopup);
 
822
                        action = new QAction(NULL, _("Show Data"), 0, this);
 
823
                          action->setToggleAction(TRUE);
 
824
                          connect(action, SIGNAL(toggled(bool)),
 
825
                                  parent(), SLOT(setShowData(bool)));
 
826
                          connect(parent(), SIGNAL(showDataChanged(bool)),
 
827
                                  action, SLOT(setOn(bool)));
 
828
                          action->setOn(showData);
 
829
                          action->addTo(headerPopup);
 
830
                }
 
831
                headerPopup->exec(e->globalPos());
 
832
                e->accept();
 
833
        } else
 
834
                e->ignore();
766
835
}
767
836
 
768
837
ConfigView* ConfigView::viewList;
769
838
 
770
 
ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview,
771
 
                       ConfigSettings *configSettings)
772
 
        : Parent(parent)
 
839
ConfigView::ConfigView(QWidget* parent, const char *name)
 
840
        : Parent(parent, name)
773
841
{
774
 
        list = new ConfigList(this, cview, configSettings);
 
842
        list = new ConfigList(this, name);
775
843
        lineEdit = new ConfigLineEdit(this);
776
844
        lineEdit->hide();
777
845
 
791
859
        }
792
860
}
793
861
 
 
862
void ConfigView::setShowAll(bool b)
 
863
{
 
864
        if (list->showAll != b) {
 
865
                list->showAll = b;
 
866
                list->updateListAll();
 
867
                emit showAllChanged(b);
 
868
        }
 
869
}
 
870
 
 
871
void ConfigView::setShowName(bool b)
 
872
{
 
873
        if (list->showName != b) {
 
874
                list->showName = b;
 
875
                list->reinit();
 
876
                emit showNameChanged(b);
 
877
        }
 
878
}
 
879
 
 
880
void ConfigView::setShowRange(bool b)
 
881
{
 
882
        if (list->showRange != b) {
 
883
                list->showRange = b;
 
884
                list->reinit();
 
885
                emit showRangeChanged(b);
 
886
        }
 
887
}
 
888
 
 
889
void ConfigView::setShowData(bool b)
 
890
{
 
891
        if (list->showData != b) {
 
892
                list->showData = b;
 
893
                list->reinit();
 
894
                emit showDataChanged(b);
 
895
        }
 
896
}
 
897
 
 
898
void ConfigList::setAllOpen(bool open)
 
899
{
 
900
        QListViewItemIterator it(this);
 
901
 
 
902
        for (; it.current(); it++)
 
903
                it.current()->setOpen(open);
 
904
}
 
905
 
794
906
void ConfigView::updateList(ConfigItem* item)
795
907
{
796
908
        ConfigView* v;
807
919
                v->list->updateListAll();
808
920
}
809
921
 
 
922
ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
 
923
        : Parent(parent, name), menu(0), sym(0)
 
924
{
 
925
        if (name) {
 
926
                configSettings->beginGroup(name);
 
927
                _showDebug = configSettings->readBoolEntry("/showDebug", false);
 
928
                configSettings->endGroup();
 
929
                connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
 
930
        }
 
931
}
 
932
 
 
933
void ConfigInfoView::saveSettings(void)
 
934
{
 
935
        if (name()) {
 
936
                configSettings->beginGroup(name());
 
937
                configSettings->writeEntry("/showDebug", showDebug());
 
938
                configSettings->endGroup();
 
939
        }
 
940
}
 
941
 
 
942
void ConfigInfoView::setShowDebug(bool b)
 
943
{
 
944
        if (_showDebug != b) {
 
945
                _showDebug = b;
 
946
                if (menu)
 
947
                        menuInfo();
 
948
                else if (sym)
 
949
                        symbolInfo();
 
950
                emit showDebugChanged(b);
 
951
        }
 
952
}
 
953
 
 
954
void ConfigInfoView::setInfo(struct menu *m)
 
955
{
 
956
        if (menu == m)
 
957
                return;
 
958
        menu = m;
 
959
        sym = NULL;
 
960
        if (!menu)
 
961
                clear();
 
962
        else
 
963
                menuInfo();
 
964
}
 
965
 
 
966
void ConfigInfoView::setSource(const QString& name)
 
967
{
 
968
        const char *p = name.latin1();
 
969
 
 
970
        menu = NULL;
 
971
        sym = NULL;
 
972
 
 
973
        switch (p[0]) {
 
974
        case 'm':
 
975
                struct menu *m;
 
976
 
 
977
                if (sscanf(p, "m%p", &m) == 1 && menu != m) {
 
978
                        menu = m;
 
979
                        menuInfo();
 
980
                        emit menuSelected(menu);
 
981
                }
 
982
                break;
 
983
        case 's':
 
984
                struct symbol *s;
 
985
 
 
986
                if (sscanf(p, "s%p", &s) == 1 && sym != s) {
 
987
                        sym = s;
 
988
                        symbolInfo();
 
989
                }
 
990
                break;
 
991
        }
 
992
}
 
993
 
 
994
void ConfigInfoView::symbolInfo(void)
 
995
{
 
996
        QString str;
 
997
 
 
998
        str += "<big>Symbol: <b>";
 
999
        str += print_filter(sym->name);
 
1000
        str += "</b></big><br><br>value: ";
 
1001
        str += print_filter(sym_get_string_value(sym));
 
1002
        str += "<br>visibility: ";
 
1003
        str += sym->visible == yes ? "y" : sym->visible == mod ? "m" : "n";
 
1004
        str += "<br>";
 
1005
        str += debug_info(sym);
 
1006
 
 
1007
        setText(str);
 
1008
}
 
1009
 
 
1010
void ConfigInfoView::menuInfo(void)
 
1011
{
 
1012
        struct symbol* sym;
 
1013
        QString head, debug, help;
 
1014
 
 
1015
        sym = menu->sym;
 
1016
        if (sym) {
 
1017
                if (menu->prompt) {
 
1018
                        head += "<big><b>";
 
1019
                        head += print_filter(_(menu->prompt->text));
 
1020
                        head += "</b></big>";
 
1021
                        if (sym->name) {
 
1022
                                head += " (";
 
1023
                                if (showDebug())
 
1024
                                        head += QString().sprintf("<a href=\"s%p\">", sym);
 
1025
                                head += print_filter(sym->name);
 
1026
                                if (showDebug())
 
1027
                                        head += "</a>";
 
1028
                                head += ")";
 
1029
                        }
 
1030
                } else if (sym->name) {
 
1031
                        head += "<big><b>";
 
1032
                        if (showDebug())
 
1033
                                head += QString().sprintf("<a href=\"s%p\">", sym);
 
1034
                        head += print_filter(sym->name);
 
1035
                        if (showDebug())
 
1036
                                head += "</a>";
 
1037
                        head += "</b></big>";
 
1038
                }
 
1039
                head += "<br><br>";
 
1040
 
 
1041
                if (showDebug())
 
1042
                        debug = debug_info(sym);
 
1043
 
 
1044
                help = menu_get_help(menu);
 
1045
                /* Gettextize if the help text not empty */
 
1046
                if (help.isEmpty())
 
1047
                        help = print_filter(menu_get_help(menu));
 
1048
                else
 
1049
                        help = print_filter(_(menu_get_help(menu)));
 
1050
        } else if (menu->prompt) {
 
1051
                head += "<big><b>";
 
1052
                head += print_filter(_(menu->prompt->text));
 
1053
                head += "</b></big><br><br>";
 
1054
                if (showDebug()) {
 
1055
                        if (menu->prompt->visible.expr) {
 
1056
                                debug += "&nbsp;&nbsp;dep: ";
 
1057
                                expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
 
1058
                                debug += "<br><br>";
 
1059
                        }
 
1060
                }
 
1061
        }
 
1062
        if (showDebug())
 
1063
                debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno);
 
1064
 
 
1065
        setText(head + debug + help);
 
1066
}
 
1067
 
 
1068
QString ConfigInfoView::debug_info(struct symbol *sym)
 
1069
{
 
1070
        QString debug;
 
1071
 
 
1072
        debug += "type: ";
 
1073
        debug += print_filter(sym_type_name(sym->type));
 
1074
        if (sym_is_choice(sym))
 
1075
                debug += " (choice)";
 
1076
        debug += "<br>";
 
1077
        if (sym->rev_dep.expr) {
 
1078
                debug += "reverse dep: ";
 
1079
                expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE);
 
1080
                debug += "<br>";
 
1081
        }
 
1082
        for (struct property *prop = sym->prop; prop; prop = prop->next) {
 
1083
                switch (prop->type) {
 
1084
                case P_PROMPT:
 
1085
                case P_MENU:
 
1086
                        debug += QString().sprintf("prompt: <a href=\"m%p\">", prop->menu);
 
1087
                        debug += print_filter(_(prop->text));
 
1088
                        debug += "</a><br>";
 
1089
                        break;
 
1090
                case P_DEFAULT:
 
1091
                case P_SELECT:
 
1092
                case P_RANGE:
 
1093
                case P_ENV:
 
1094
                        debug += prop_get_type_name(prop->type);
 
1095
                        debug += ": ";
 
1096
                        expr_print(prop->expr, expr_print_help, &debug, E_NONE);
 
1097
                        debug += "<br>";
 
1098
                        break;
 
1099
                case P_CHOICE:
 
1100
                        if (sym_is_choice(sym)) {
 
1101
                                debug += "choice: ";
 
1102
                                expr_print(prop->expr, expr_print_help, &debug, E_NONE);
 
1103
                                debug += "<br>";
 
1104
                        }
 
1105
                        break;
 
1106
                default:
 
1107
                        debug += "unknown property: ";
 
1108
                        debug += prop_get_type_name(prop->type);
 
1109
                        debug += "<br>";
 
1110
                }
 
1111
                if (prop->visible.expr) {
 
1112
                        debug += "&nbsp;&nbsp;&nbsp;&nbsp;dep: ";
 
1113
                        expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
 
1114
                        debug += "<br>";
 
1115
                }
 
1116
        }
 
1117
        debug += "<br>";
 
1118
 
 
1119
        return debug;
 
1120
}
 
1121
 
 
1122
QString ConfigInfoView::print_filter(const QString &str)
 
1123
{
 
1124
        QRegExp re("[<>&\"\\n]");
 
1125
        QString res = str;
 
1126
        for (int i = 0; (i = res.find(re, i)) >= 0;) {
 
1127
                switch (res[i].latin1()) {
 
1128
                case '<':
 
1129
                        res.replace(i, 1, "&lt;");
 
1130
                        i += 4;
 
1131
                        break;
 
1132
                case '>':
 
1133
                        res.replace(i, 1, "&gt;");
 
1134
                        i += 4;
 
1135
                        break;
 
1136
                case '&':
 
1137
                        res.replace(i, 1, "&amp;");
 
1138
                        i += 5;
 
1139
                        break;
 
1140
                case '"':
 
1141
                        res.replace(i, 1, "&quot;");
 
1142
                        i += 6;
 
1143
                        break;
 
1144
                case '\n':
 
1145
                        res.replace(i, 1, "<br>");
 
1146
                        i += 4;
 
1147
                        break;
 
1148
                }
 
1149
        }
 
1150
        return res;
 
1151
}
 
1152
 
 
1153
void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str)
 
1154
{
 
1155
        QString* text = reinterpret_cast<QString*>(data);
 
1156
        QString str2 = print_filter(str);
 
1157
 
 
1158
        if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
 
1159
                *text += QString().sprintf("<a href=\"s%p\">", sym);
 
1160
                *text += str2;
 
1161
                *text += "</a>";
 
1162
        } else
 
1163
                *text += str2;
 
1164
}
 
1165
 
 
1166
QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
 
1167
{
 
1168
        QPopupMenu* popup = Parent::createPopupMenu(pos);
 
1169
        QAction* action = new QAction(NULL, _("Show Debug Info"), 0, popup);
 
1170
          action->setToggleAction(TRUE);
 
1171
          connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
 
1172
          connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
 
1173
          action->setOn(showDebug());
 
1174
        popup->insertSeparator();
 
1175
        action->addTo(popup);
 
1176
        return popup;
 
1177
}
 
1178
 
 
1179
void ConfigInfoView::contentsContextMenuEvent(QContextMenuEvent *e)
 
1180
{
 
1181
        Parent::contentsContextMenuEvent(e);
 
1182
}
 
1183
 
 
1184
ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name)
 
1185
        : Parent(parent, name), result(NULL)
 
1186
{
 
1187
        setCaption("Search Config");
 
1188
 
 
1189
        QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6);
 
1190
        QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 6);
 
1191
        layout2->addWidget(new QLabel(_("Find:"), this));
 
1192
        editField = new QLineEdit(this);
 
1193
        connect(editField, SIGNAL(returnPressed()), SLOT(search()));
 
1194
        layout2->addWidget(editField);
 
1195
        searchButton = new QPushButton(_("Search"), this);
 
1196
        searchButton->setAutoDefault(FALSE);
 
1197
        connect(searchButton, SIGNAL(clicked()), SLOT(search()));
 
1198
        layout2->addWidget(searchButton);
 
1199
        layout1->addLayout(layout2);
 
1200
 
 
1201
        split = new QSplitter(this);
 
1202
        split->setOrientation(QSplitter::Vertical);
 
1203
        list = new ConfigView(split, name);
 
1204
        list->list->mode = listMode;
 
1205
        info = new ConfigInfoView(split, name);
 
1206
        connect(list->list, SIGNAL(menuChanged(struct menu *)),
 
1207
                info, SLOT(setInfo(struct menu *)));
 
1208
        connect(list->list, SIGNAL(menuChanged(struct menu *)),
 
1209
                parent, SLOT(setMenuLink(struct menu *)));
 
1210
 
 
1211
        layout1->addWidget(split);
 
1212
 
 
1213
        if (name) {
 
1214
                int x, y, width, height;
 
1215
                bool ok;
 
1216
 
 
1217
                configSettings->beginGroup(name);
 
1218
                width = configSettings->readNumEntry("/window width", parent->width() / 2);
 
1219
                height = configSettings->readNumEntry("/window height", parent->height() / 2);
 
1220
                resize(width, height);
 
1221
                x = configSettings->readNumEntry("/window x", 0, &ok);
 
1222
                if (ok)
 
1223
                        y = configSettings->readNumEntry("/window y", 0, &ok);
 
1224
                if (ok)
 
1225
                        move(x, y);
 
1226
                QValueList<int> sizes = configSettings->readSizes("/split", &ok);
 
1227
                if (ok)
 
1228
                        split->setSizes(sizes);
 
1229
                configSettings->endGroup();
 
1230
                connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
 
1231
        }
 
1232
}
 
1233
 
 
1234
void ConfigSearchWindow::saveSettings(void)
 
1235
{
 
1236
        if (name()) {
 
1237
                configSettings->beginGroup(name());
 
1238
                configSettings->writeEntry("/window x", pos().x());
 
1239
                configSettings->writeEntry("/window y", pos().y());
 
1240
                configSettings->writeEntry("/window width", size().width());
 
1241
                configSettings->writeEntry("/window height", size().height());
 
1242
                configSettings->writeSizes("/split", split->sizes());
 
1243
                configSettings->endGroup();
 
1244
        }
 
1245
}
 
1246
 
 
1247
void ConfigSearchWindow::search(void)
 
1248
{
 
1249
        struct symbol **p;
 
1250
        struct property *prop;
 
1251
        ConfigItem *lastItem = NULL;
 
1252
 
 
1253
        free(result);
 
1254
        list->list->clear();
 
1255
        info->clear();
 
1256
 
 
1257
        result = sym_re_search(editField->text().latin1());
 
1258
        if (!result)
 
1259
                return;
 
1260
        for (p = result; *p; p++) {
 
1261
                for_all_prompts((*p), prop)
 
1262
                        lastItem = new ConfigItem(list->list, lastItem, prop->menu,
 
1263
                                                  menu_is_visible(prop->menu));
 
1264
        }
 
1265
}
 
1266
 
810
1267
/*
811
1268
 * Construct the complete config widget
812
1269
 */
813
1270
ConfigMainWindow::ConfigMainWindow(void)
 
1271
        : searchWindow(0)
814
1272
{
815
1273
        QMenuBar* menu;
816
1274
        bool ok;
817
1275
        int x, y, width, height;
 
1276
        char title[256];
818
1277
 
819
1278
        QWidget *d = configApp->desktop();
 
1279
        snprintf(title, sizeof(title), _("Linux Kernel v%s Configuration"),
 
1280
                getenv("KERNELVERSION"));
 
1281
        setCaption(title);
820
1282
 
821
 
        ConfigSettings* configSettings = new ConfigSettings();
822
 
#if QT_VERSION >= 300
823
 
        width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64);
824
 
        height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64);
 
1283
        width = configSettings->readNumEntry("/window width", d->width() - 64);
 
1284
        height = configSettings->readNumEntry("/window height", d->height() - 64);
825
1285
        resize(width, height);
826
 
        x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok);
 
1286
        x = configSettings->readNumEntry("/window x", 0, &ok);
827
1287
        if (ok)
828
 
                y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok);
 
1288
                y = configSettings->readNumEntry("/window y", 0, &ok);
829
1289
        if (ok)
830
1290
                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
1291
 
842
1292
        split1 = new QSplitter(this);
843
1293
        split1->setOrientation(QSplitter::Horizontal);
844
1294
        setCentralWidget(split1);
845
1295
 
846
 
        menuView = new ConfigView(split1, this, configSettings);
 
1296
        menuView = new ConfigView(split1, "menu");
847
1297
        menuList = menuView->list;
848
1298
 
849
1299
        split2 = new QSplitter(split1);
850
1300
        split2->setOrientation(QSplitter::Vertical);
851
1301
 
852
1302
        // create config tree
853
 
        configView = new ConfigView(split2, this, configSettings);
 
1303
        configView = new ConfigView(split2, "config");
854
1304
        configList = configView->list;
855
1305
 
856
 
        helpText = new QTextView(split2);
 
1306
        helpText = new ConfigInfoView(split2, "help");
857
1307
        helpText->setTextFormat(Qt::RichText);
858
1308
 
859
1309
        setTabOrder(configList, helpText);
862
1312
        menu = menuBar();
863
1313
        toolBar = new QToolBar("Tools", this);
864
1314
 
865
 
        backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this);
 
1315
        backAction = new QAction("Back", QPixmap(xpm_back), _("Back"), 0, this);
866
1316
          connect(backAction, SIGNAL(activated()), SLOT(goBack()));
867
1317
          backAction->setEnabled(FALSE);
868
 
        QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this);
 
1318
        QAction *quitAction = new QAction("Quit", _("&Quit"), CTRL+Key_Q, this);
869
1319
          connect(quitAction, SIGNAL(activated()), SLOT(close()));
870
 
        QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this);
 
1320
        QAction *loadAction = new QAction("Load", QPixmap(xpm_load), _("&Load"), CTRL+Key_L, this);
871
1321
          connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
872
 
        QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this);
 
1322
        saveAction = new QAction("Save", QPixmap(xpm_save), _("&Save"), CTRL+Key_S, this);
873
1323
          connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
874
 
        QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this);
 
1324
        conf_set_changed_callback(conf_changed);
 
1325
        // Set saveAction's initial state
 
1326
        conf_changed();
 
1327
        QAction *saveAsAction = new QAction("Save As...", _("Save &As..."), 0, this);
875
1328
          connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
876
 
        QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this);
 
1329
        QAction *searchAction = new QAction("Find", _("&Find"), CTRL+Key_F, this);
 
1330
          connect(searchAction, SIGNAL(activated()), SLOT(searchConfig()));
 
1331
        QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this);
877
1332
          connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
878
 
        QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this);
 
1333
        QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this);
879
1334
          connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
880
 
        QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this);
 
1335
        QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this);
881
1336
          connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
882
1337
 
883
 
        QAction *showNameAction = new QAction(NULL, "Show Name", 0, this);
 
1338
        QAction *showNameAction = new QAction(NULL, _("Show Name"), 0, this);
884
1339
          showNameAction->setToggleAction(TRUE);
885
 
          showNameAction->setOn(configList->showName);
886
 
          connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool)));
887
 
        QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this);
 
1340
          connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool)));
 
1341
          connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool)));
 
1342
          showNameAction->setOn(configView->showName());
 
1343
        QAction *showRangeAction = new QAction(NULL, _("Show Range"), 0, this);
888
1344
          showRangeAction->setToggleAction(TRUE);
 
1345
          connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool)));
 
1346
          connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool)));
889
1347
          showRangeAction->setOn(configList->showRange);
890
 
          connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool)));
891
 
        QAction *showDataAction = new QAction(NULL, "Show Data", 0, this);
 
1348
        QAction *showDataAction = new QAction(NULL, _("Show Data"), 0, this);
892
1349
          showDataAction->setToggleAction(TRUE);
 
1350
          connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
 
1351
          connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
893
1352
          showDataAction->setOn(configList->showData);
894
 
          connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool)));
895
 
        QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this);
 
1353
        QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this);
896
1354
          showAllAction->setToggleAction(TRUE);
 
1355
          connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool)));
 
1356
          connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool)));
897
1357
          showAllAction->setOn(configList->showAll);
898
 
          connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool)));
899
 
        QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this);
 
1358
        QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this);
900
1359
          showDebugAction->setToggleAction(TRUE);
901
 
          showDebugAction->setOn(showDebug);
902
 
          connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
 
1360
          connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
 
1361
          connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool)));
 
1362
          showDebugAction->setOn(helpText->showDebug());
903
1363
 
904
 
        QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this);
 
1364
        QAction *showIntroAction = new QAction(NULL, _("Introduction"), 0, this);
905
1365
          connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
906
 
        QAction *showAboutAction = new QAction(NULL, "About", 0, this);
 
1366
        QAction *showAboutAction = new QAction(NULL, _("About"), 0, this);
907
1367
          connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
908
1368
 
909
1369
        // init tool bar
918
1378
 
919
1379
        // create config menu
920
1380
        QPopupMenu* config = new QPopupMenu(this);
921
 
        menu->insertItem("&File", config);
 
1381
        menu->insertItem(_("&File"), config);
922
1382
        loadAction->addTo(config);
923
1383
        saveAction->addTo(config);
924
1384
        saveAsAction->addTo(config);
925
1385
        config->insertSeparator();
926
1386
        quitAction->addTo(config);
927
1387
 
 
1388
        // create edit menu
 
1389
        QPopupMenu* editMenu = new QPopupMenu(this);
 
1390
        menu->insertItem(_("&Edit"), editMenu);
 
1391
        searchAction->addTo(editMenu);
 
1392
 
928
1393
        // create options menu
929
1394
        QPopupMenu* optionMenu = new QPopupMenu(this);
930
 
        menu->insertItem("&Option", optionMenu);
 
1395
        menu->insertItem(_("&Option"), optionMenu);
931
1396
        showNameAction->addTo(optionMenu);
932
1397
        showRangeAction->addTo(optionMenu);
933
1398
        showDataAction->addTo(optionMenu);
938
1403
        // create help menu
939
1404
        QPopupMenu* helpMenu = new QPopupMenu(this);
940
1405
        menu->insertSeparator();
941
 
        menu->insertItem("&Help", helpMenu);
 
1406
        menu->insertItem(_("&Help"), helpMenu);
942
1407
        showIntroAction->addTo(helpMenu);
943
1408
        showAboutAction->addTo(helpMenu);
944
1409
 
 
1410
        connect(configList, SIGNAL(menuChanged(struct menu *)),
 
1411
                helpText, SLOT(setInfo(struct menu *)));
945
1412
        connect(configList, SIGNAL(menuSelected(struct menu *)),
946
1413
                SLOT(changeMenu(struct menu *)));
947
1414
        connect(configList, SIGNAL(parentSelected()),
948
1415
                SLOT(goBack()));
 
1416
        connect(menuList, SIGNAL(menuChanged(struct menu *)),
 
1417
                helpText, SLOT(setInfo(struct menu *)));
949
1418
        connect(menuList, SIGNAL(menuSelected(struct menu *)),
950
1419
                SLOT(changeMenu(struct menu *)));
951
1420
 
952
 
        connect(configList, SIGNAL(gotFocus(void)),
953
 
                SLOT(listFocusChanged(void)));
954
 
        connect(menuList, SIGNAL(gotFocus(void)),
955
 
                SLOT(listFocusChanged(void)));
 
1421
        connect(configList, SIGNAL(gotFocus(struct menu *)),
 
1422
                helpText, SLOT(setInfo(struct menu *)));
 
1423
        connect(menuList, SIGNAL(gotFocus(struct menu *)),
 
1424
                helpText, SLOT(setInfo(struct menu *)));
 
1425
        connect(menuList, SIGNAL(gotFocus(struct menu *)),
 
1426
                SLOT(listFocusChanged(void)));
 
1427
        connect(helpText, SIGNAL(menuSelected(struct menu *)),
 
1428
                SLOT(setMenuLink(struct menu *)));
956
1429
 
957
 
#if QT_VERSION >= 300
958
 
        QString listMode = configSettings->readEntry("/kconfig/qconf/listMode", "symbol");
 
1430
        QString listMode = configSettings->readEntry("/listMode", "symbol");
959
1431
        if (listMode == "single")
960
1432
                showSingleView();
961
1433
        else if (listMode == "full")
964
1436
                showSplitView();
965
1437
 
966
1438
        // UI setup done, restore splitter positions
967
 
        QValueList<int> sizes = configSettings->readSizes("/kconfig/qconf/split1", &ok);
 
1439
        QValueList<int> sizes = configSettings->readSizes("/split1", &ok);
968
1440
        if (ok)
969
1441
                split1->setSizes(sizes);
970
1442
 
971
 
        sizes = configSettings->readSizes("/kconfig/qconf/split2", &ok);
 
1443
        sizes = configSettings->readSizes("/split2", &ok);
972
1444
        if (ok)
973
1445
                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, "&lt;");
988
 
                        i += 4;
989
 
                        break;
990
 
                case '>':
991
 
                        res.replace(i, 1, "&gt;");
992
 
                        i += 4;
993
 
                        break;
994
 
                case '&':
995
 
                        res.replace(i, 1, "&amp;");
996
 
                        i += 5;
997
 
                        break;
998
 
                case '"':
999
 
                        res.replace(i, 1, "&quot;");
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 += "&nbsp;&nbsp;&nbsp;&nbsp;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 += "&nbsp;&nbsp;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
1446
}
1124
1447
 
1125
1448
void ConfigMainWindow::loadConfig(void)
1128
1451
        if (s.isNull())
1129
1452
                return;
1130
1453
        if (conf_read(QFile::encodeName(s)))
1131
 
                QMessageBox::information(this, "qconf", "Unable to load configuration!");
 
1454
                QMessageBox::information(this, "qconf", _("Unable to load configuration!"));
1132
1455
        ConfigView::updateListAll();
1133
1456
}
1134
1457
 
1135
1458
void ConfigMainWindow::saveConfig(void)
1136
1459
{
1137
1460
        if (conf_write(NULL))
1138
 
                QMessageBox::information(this, "qconf", "Unable to save configuration!");
 
1461
                QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
1139
1462
}
1140
1463
 
1141
1464
void ConfigMainWindow::saveConfigAs(void)
1144
1467
        if (s.isNull())
1145
1468
                return;
1146
1469
        if (conf_write(QFile::encodeName(s)))
1147
 
                QMessageBox::information(this, "qconf", "Unable to save configuration!");
 
1470
                QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
 
1471
}
 
1472
 
 
1473
void ConfigMainWindow::searchConfig(void)
 
1474
{
 
1475
        if (!searchWindow)
 
1476
                searchWindow = new ConfigSearchWindow(this, "search");
 
1477
        searchWindow->show();
1148
1478
}
1149
1479
 
1150
1480
void ConfigMainWindow::changeMenu(struct menu *menu)
1151
1481
{
1152
1482
        configList->setRootMenu(menu);
1153
 
        backAction->setEnabled(TRUE);
 
1483
        if (configList->rootEntry->parent == &rootmenu)
 
1484
                backAction->setEnabled(FALSE);
 
1485
        else
 
1486
                backAction->setEnabled(TRUE);
 
1487
}
 
1488
 
 
1489
void ConfigMainWindow::setMenuLink(struct menu *menu)
 
1490
{
 
1491
        struct menu *parent;
 
1492
        ConfigList* list = NULL;
 
1493
        ConfigItem* item;
 
1494
 
 
1495
        if (!menu_is_visible(menu) && !configView->showAll())
 
1496
                return;
 
1497
 
 
1498
        switch (configList->mode) {
 
1499
        case singleMode:
 
1500
                list = configList;
 
1501
                parent = menu_get_parent_menu(menu);
 
1502
                if (!parent)
 
1503
                        return;
 
1504
                list->setRootMenu(parent);
 
1505
                break;
 
1506
        case symbolMode:
 
1507
                if (menu->flags & MENU_ROOT) {
 
1508
                        configList->setRootMenu(menu);
 
1509
                        configList->clearSelection();
 
1510
                        list = menuList;
 
1511
                } else {
 
1512
                        list = configList;
 
1513
                        parent = menu_get_parent_menu(menu->parent);
 
1514
                        if (!parent)
 
1515
                                return;
 
1516
                        item = menuList->findConfigItem(parent);
 
1517
                        if (item) {
 
1518
                                menuList->setSelected(item, TRUE);
 
1519
                                menuList->ensureItemVisible(item);
 
1520
                        }
 
1521
                        list->setRootMenu(parent);
 
1522
                }
 
1523
                break;
 
1524
        case fullMode:
 
1525
                list = configList;
 
1526
                break;
 
1527
        }
 
1528
 
 
1529
        if (list) {
 
1530
                item = list->findConfigItem(menu);
 
1531
                if (item) {
 
1532
                        list->setSelected(item, TRUE);
 
1533
                        list->ensureItemVisible(item);
 
1534
                        list->setFocus();
 
1535
                }
 
1536
        }
1154
1537
}
1155
1538
 
1156
1539
void ConfigMainWindow::listFocusChanged(void)
1157
1540
{
1158
 
        if (menuList->hasFocus()) {
1159
 
                if (menuList->mode == menuMode)
1160
 
                        configList->clearSelection();
1161
 
                setHelp(menuList->selectedItem());
1162
 
        } else if (configList->hasFocus()) {
1163
 
                setHelp(configList->selectedItem());
1164
 
        }
 
1541
        if (menuList->mode == menuMode)
 
1542
                configList->clearSelection();
1165
1543
}
1166
1544
 
1167
1545
void ConfigMainWindow::goBack(void)
1223
1601
        configList->setFocus();
1224
1602
}
1225
1603
 
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
1604
/*
1274
1605
 * ask for saving configuration before quitting
1275
1606
 * TODO ask only when something changed
1276
1607
 */
1277
1608
void ConfigMainWindow::closeEvent(QCloseEvent* e)
1278
1609
{
1279
 
        if (!sym_change_count) {
 
1610
        if (!conf_get_changed()) {
1280
1611
                e->accept();
1281
1612
                return;
1282
1613
        }
1283
 
        QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning,
 
1614
        QMessageBox mb("qconf", _("Save configuration?"), QMessageBox::Warning,
1284
1615
                        QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape);
1285
 
        mb.setButtonText(QMessageBox::Yes, "&Save Changes");
1286
 
        mb.setButtonText(QMessageBox::No, "&Discard Changes");
1287
 
        mb.setButtonText(QMessageBox::Cancel, "Cancel Exit");
 
1616
        mb.setButtonText(QMessageBox::Yes, _("&Save Changes"));
 
1617
        mb.setButtonText(QMessageBox::No, _("&Discard Changes"));
 
1618
        mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
1288
1619
        switch (mb.exec()) {
1289
1620
        case QMessageBox::Yes:
1290
1621
                conf_write(NULL);
1299
1630
 
1300
1631
void ConfigMainWindow::showIntro(void)
1301
1632
{
1302
 
        static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n"
 
1633
        static const QString str = _("Welcome to the qconf graphical kernel configuration tool for Linux.\n\n"
1303
1634
                "For each option, a blank box indicates the feature is disabled, a check\n"
1304
1635
                "indicates it is enabled, and a dot indicates that it is to be compiled\n"
1305
1636
                "as a module.  Clicking on the box will cycle through the three states.\n\n"
1309
1640
                "options must be enabled to support the option you are interested in, you can\n"
1310
1641
                "still view the help of a grayed-out option.\n\n"
1311
1642
                "Toggling Show Debug Info under the Options menu will show the dependencies,\n"
1312
 
                "which you can then match by examining other options.\n\n";
 
1643
                "which you can then match by examining other options.\n\n");
1313
1644
 
1314
1645
        QMessageBox::information(this, "qconf", str);
1315
1646
}
1316
1647
 
1317
1648
void ConfigMainWindow::showAbout(void)
1318
1649
{
1319
 
        static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n"
1320
 
                "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n";
 
1650
        static const QString str = _("qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n"
 
1651
                "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n");
1321
1652
 
1322
1653
        QMessageBox::information(this, "qconf", str);
1323
1654
}
1324
1655
 
1325
1656
void ConfigMainWindow::saveSettings(void)
1326
1657
{
1327
 
#if QT_VERSION >= 300
1328
 
        ConfigSettings *configSettings = new ConfigSettings;
1329
 
        configSettings->writeEntry("/kconfig/qconf/window x", pos().x());
1330
 
        configSettings->writeEntry("/kconfig/qconf/window y", pos().y());
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);
 
1658
        configSettings->writeEntry("/window x", pos().x());
 
1659
        configSettings->writeEntry("/window y", pos().y());
 
1660
        configSettings->writeEntry("/window width", size().width());
 
1661
        configSettings->writeEntry("/window height", size().height());
1338
1662
 
1339
1663
        QString entry;
1340
1664
        switch(configList->mode) {
1350
1674
                entry = "full";
1351
1675
                break;
1352
1676
        }
1353
 
        configSettings->writeEntry("/kconfig/qconf/listMode", entry);
1354
 
 
1355
 
        configSettings->writeSizes("/kconfig/qconf/split1", split1->sizes());
1356
 
        configSettings->writeSizes("/kconfig/qconf/split2", split2->sizes());
1357
 
 
1358
 
        delete configSettings;
1359
 
#endif
 
1677
        configSettings->writeEntry("/listMode", entry);
 
1678
 
 
1679
        configSettings->writeSizes("/split1", split1->sizes());
 
1680
        configSettings->writeSizes("/split2", split2->sizes());
 
1681
}
 
1682
 
 
1683
void ConfigMainWindow::conf_changed(void)
 
1684
{
 
1685
        if (saveAction)
 
1686
                saveAction->setEnabled(conf_get_changed());
1360
1687
}
1361
1688
 
1362
1689
void fixup_rootmenu(struct menu *menu)
1379
1706
 
1380
1707
static void usage(void)
1381
1708
{
1382
 
        printf("%s <config>\n", progname);
 
1709
        printf(_("%s <config>\n"), progname);
1383
1710
        exit(0);
1384
1711
}
1385
1712
 
1414
1741
        conf_read(NULL);
1415
1742
        //zconfdump(stdout);
1416
1743
 
 
1744
        configSettings = new ConfigSettings();
 
1745
        configSettings->beginGroup("/kconfig/qconf");
1417
1746
        v = new ConfigMainWindow();
1418
1747
 
1419
1748
        //zconfdump(stdout);
1420
 
        v->show();
 
1749
        configApp->setMainWidget(v);
1421
1750
        configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit()));
1422
1751
        configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings()));
 
1752
        v->show();
1423
1753
        configApp->exec();
1424
1754
 
 
1755
        configSettings->endGroup();
 
1756
        delete configSettings;
 
1757
 
1425
1758
        return 0;
1426
1759
}