summaryrefslogtreecommitdiff
path: root/scripts/kconfig/qconf.cc
Unidiff
Diffstat (limited to 'scripts/kconfig/qconf.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--scripts/kconfig/qconf.cc274
1 files changed, 202 insertions, 72 deletions
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index feefa1c..bed541d 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -18,4 +18,8 @@
18#include <qfiledialog.h> 18#include <qfiledialog.h>
19#include <qregexp.h> 19#include <qregexp.h>
20#if QT_VERSION >= 300
21#include <qsettings.h>
22#endif
23
20#include <stdlib.h> 24#include <stdlib.h>
21 25
@@ -27,4 +31,7 @@
27 31
28static QApplication *configApp; 32static QApplication *configApp;
33#if QT_VERSION >= 300
34static QSettings *configSettings;
35#endif
29 36
30/* 37/*
@@ -74,7 +81,15 @@ static void updateMenuList(P* parent, struct menu* menu)
74 if (showAll || visible) { 81 if (showAll || visible) {
75 if (!item || item->menu != child) 82 if (!item || item->menu != child)
76 item = new ConfigItem(parent, last, child); 83 item = new ConfigItem(parent, last, child, visible);
77 item->visible = visible; 84 else {
78 item->updateMenu(); 85 item->visible = visible;
86 if (item->updateNeeded()) {
87 ConfigItem* i = (ConfigItem*)child->data;
88 for (; i; i = i->nextItem) {
89 i->updateMenu();
90 }
91 } else if (list->updateAll)
92 item->updateMenu();
93 }
79 94
80 if (mode == fullMode || mode == menuMode || 95 if (mode == fullMode || mode == menuMode ||
@@ -121,34 +136,20 @@ void ConfigItem::updateMenu(void)
121 enum prop_type ptype; 136 enum prop_type ptype;
122 tristate expr; 137 tristate expr;
123 bool update;
124 138
125 list = listView(); 139 list = listView();
126 update = doInit;
127 if (update)
128 doInit = false;
129 else
130 update = list->updateAll;
131 140
132 sym = menu->sym; 141 sym = menu->sym;
133 if (!sym) { 142 if (!sym) {
134 if (update) { 143 setText(promptColIdx, menu_get_prompt(menu));
135 setText(promptColIdx, menu_get_prompt(menu)); 144 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
136 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; 145 if ((ptype == P_ROOTMENU || ptype == P_MENU) &&
137 if ((ptype == P_ROOTMENU || ptype == P_MENU) && 146 (list->mode == singleMode || list->mode == symbolMode))
138 (list->mode == singleMode || list->mode == symbolMode)) 147 setPixmap(promptColIdx, list->menuPix);
139 setPixmap(promptColIdx, list->menuPix); 148 else
140 else 149 setPixmap(promptColIdx, 0);
141 setPixmap(promptColIdx, 0);
142 }
143 return; 150 return;
144 } 151 }
145 152
146 sym_calc_value(sym); 153 setText(nameColIdx, sym->name);
147 if (!(sym->flags & SYMBOL_CHANGED) && !update)
148 return;
149
150 sym->flags &= ~SYMBOL_CHANGED;
151
152 setText(nameColIdx, menu->sym->name);
153 154
154 type = sym_get_type(sym); 155 type = sym_get_type(sym);
@@ -205,5 +206,7 @@ void ConfigItem::updateMenu(void)
205 data = sym_get_string_value(sym); 206 data = sym_get_string_value(sym);
206#if QT_VERSION >= 300 207#if QT_VERSION >= 300
207 setRenameEnabled(list->mapIdx(dataColIdx), TRUE); 208 int i = list->mapIdx(dataColIdx);
209 if (i >= 0)
210 setRenameEnabled(i, TRUE);
208#endif 211#endif
209 setText(dataColIdx, data); 212 setText(dataColIdx, data);
@@ -219,4 +222,16 @@ void ConfigItem::updateMenu(void)
219} 222}
220 223
224bool ConfigItem::updateNeeded(void)
225{
226 struct symbol* sym = menu->sym;
227 if (sym)
228 sym_calc_value(sym);
229 if (menu->flags & MENU_CHANGED) {
230 menu->flags &= ~MENU_CHANGED;
231 return true;
232 }
233 return false;
234}
235
221void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) 236void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align)
222{ 237{
@@ -238,11 +253,12 @@ void ConfigItem::init(void)
238{ 253{
239 ConfigList* list = listView(); 254 ConfigList* list = listView();
240#if QT_VERSION < 300 255 nextItem = (ConfigItem*)menu->data;
241 visible = TRUE; 256 menu->data = this;
242#endif 257
243 //menu->data = this;
244 if (list->mode != fullMode) 258 if (list->mode != fullMode)
245 setOpen(TRUE); 259 setOpen(TRUE);
246 doInit= true; 260 if (menu->sym)
261 sym_calc_value(menu->sym);
262 updateMenu();
247} 263}
248 264
@@ -252,5 +268,11 @@ void ConfigItem::init(void)
252ConfigItem::~ConfigItem(void) 268ConfigItem::~ConfigItem(void)
253{ 269{
254 //menu->data = 0; 270 ConfigItem** ip = &(ConfigItem*)menu->data;
271 for (; *ip; ip = &(*ip)->nextItem) {
272 if (*ip == this) {
273 *ip = nextItem;
274 break;
275 }
276 }
255} 277}
256 278
@@ -274,5 +296,5 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
274 case Key_Enter: 296 case Key_Enter:
275 sym_set_string_value(item->menu->sym, text().latin1()); 297 sym_set_string_value(item->menu->sym, text().latin1());
276 emit lineChanged(item); 298 parent()->updateList(item);
277 break; 299 break;
278 default: 300 default:
@@ -281,8 +303,9 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
281 } 303 }
282 e->accept(); 304 e->accept();
305 parent()->list->setFocus();
283 hide(); 306 hide();
284} 307}
285 308
286ConfigList::ConfigList(QWidget* p, ConfigView* cv) 309ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv)
287 : Parent(p), cview(cv), 310 : Parent(p), cview(cv),
288 updateAll(false), 311 updateAll(false),
@@ -353,4 +376,5 @@ void ConfigList::updateList(ConfigItem* item)
353 (void)item;// unused so far 376 (void)item;// unused so far
354 updateMenuList(this, rootEntry); 377 updateMenuList(this, rootEntry);
378 triggerUpdate();
355} 379}
356 380
@@ -383,5 +407,5 @@ void ConfigList::setValue(ConfigItem* item, tristate val)
383 if (oldval == no && item->menu->list) 407 if (oldval == no && item->menu->list)
384 item->setOpen(TRUE); 408 item->setOpen(TRUE);
385 emit symbolChanged(item); 409 parent()->updateList(item);
386 break; 410 break;
387 } 411 }
@@ -415,5 +439,5 @@ void ConfigList::changeValue(ConfigItem* item)
415 } 439 }
416 if (oldexpr != newexpr) 440 if (oldexpr != newexpr)
417 emit symbolChanged(item); 441 parent()->updateList(item);
418 break; 442 break;
419 case S_INT: 443 case S_INT:
@@ -425,5 +449,5 @@ void ConfigList::changeValue(ConfigItem* item)
425 else 449 else
426#endif 450#endif
427 lineEdit->show(item); 451 parent()->lineEdit->show(item);
428 break; 452 break;
429 } 453 }
@@ -517,5 +541,5 @@ void ConfigList::contentsMousePressEvent(QMouseEvent* e)
517 //QPoint p(contentsToViewport(e->pos())); 541 //QPoint p(contentsToViewport(e->pos()));
518 //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); 542 //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y());
519 QListView::contentsMousePressEvent(e); 543 Parent::contentsMousePressEvent(e);
520} 544}
521 545
@@ -564,5 +588,5 @@ void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e)
564skip: 588skip:
565 //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); 589 //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y());
566 QListView::contentsMouseReleaseEvent(e); 590 Parent::contentsMouseReleaseEvent(e);
567} 591}
568 592
@@ -571,5 +595,5 @@ void ConfigList::contentsMouseMoveEvent(QMouseEvent* e)
571 //QPoint p(contentsToViewport(e->pos())); 595 //QPoint p(contentsToViewport(e->pos()));
572 //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); 596 //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y());
573 QListView::contentsMouseMoveEvent(e); 597 Parent::contentsMouseMoveEvent(e);
574} 598}
575 599
@@ -588,8 +612,10 @@ void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e)
588 (mode == singleMode || mode == symbolMode)) 612 (mode == singleMode || mode == symbolMode))
589 emit menuSelected(menu); 613 emit menuSelected(menu);
614 else if (menu->sym)
615 changeValue(item);
590 616
591skip: 617skip:
592 //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); 618 //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y());
593 QListView::contentsMouseDoubleClickEvent(e); 619 Parent::contentsMouseDoubleClickEvent(e);
594} 620}
595 621
@@ -606,12 +632,73 @@ void ConfigList::focusInEvent(QFocusEvent *e)
606} 632}
607 633
634ConfigView* ConfigView::viewList;
635
636ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview)
637 : Parent(parent)
638{
639 list = new ConfigList(this, cview);
640 lineEdit = new ConfigLineEdit(this);
641 lineEdit->hide();
642
643 this->nextView = viewList;
644 viewList = this;
645}
646
647ConfigView::~ConfigView(void)
648{
649 ConfigView** vp;
650
651 for (vp = &viewList; *vp; vp = &(*vp)->nextView) {
652 if (*vp == this) {
653 *vp = nextView;
654 break;
655 }
656 }
657}
658
659void ConfigView::updateList(ConfigItem* item)
660{
661 ConfigView* v;
662
663 for (v = viewList; v; v = v->nextView)
664 v->list->updateList(item);
665}
666
667void ConfigView::updateListAll(void)
668{
669 ConfigView* v;
670
671 for (v = viewList; v; v = v->nextView)
672 v->list->updateListAll();
673}
674
608/* 675/*
609 * Construct the complete config widget 676 * Construct the complete config widget
610 */ 677 */
611ConfigView::ConfigView(void) 678ConfigMainWindow::ConfigMainWindow(void)
612{ 679{
680 ConfigView* view;
613 QMenuBar* menu; 681 QMenuBar* menu;
614 QSplitter* split1; 682 QSplitter* split1;
615 QSplitter* split2; 683 QSplitter* split2;
684 bool ok;
685 int x, y, width, height;
686
687 QWidget *d = configApp->desktop();
688
689#if QT_VERSION >= 300
690 width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64);
691 height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64);
692 resize(width, height);
693 x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok);
694 if (ok)
695 y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok);
696 if (ok)
697 move(x, y);
698#else
699 width = d->width() - 64;
700 height = d->height() - 64;
701 resize(width, height);
702#endif
616 703
617 showDebug = false; 704 showDebug = false;
@@ -621,5 +708,6 @@ ConfigView::ConfigView(void)
621 setCentralWidget(split1); 708 setCentralWidget(split1);
622 709
623 menuList = new ConfigList(split1, this); 710 view = new ConfigView(split1, this);
711 menuList = view->list;
624 712
625 split2 = new QSplitter(split1); 713 split2 = new QSplitter(split1);
@@ -627,14 +715,6 @@ ConfigView::ConfigView(void)
627 715
628 // create config tree 716 // create config tree
629 QVBox* box = new QVBox(split2); 717 view = new ConfigView(split2, this);
630 configList = new ConfigList(box, this); 718 configList = view->list;
631 configList->lineEdit = new ConfigLineEdit(box);
632 configList->lineEdit->hide();
633 configList->connect(configList, SIGNAL(symbolChanged(ConfigItem*)),
634 configList, SLOT(updateList(ConfigItem*)));
635 configList->connect(configList, SIGNAL(symbolChanged(ConfigItem*)),
636 menuList, SLOT(updateList(ConfigItem*)));
637 configList->connect(configList->lineEdit, SIGNAL(lineChanged(ConfigItem*)),
638 SLOT(updateList(ConfigItem*)));
639 719
640 helpText = new QTextView(split2); 720 helpText = new QTextView(split2);
@@ -686,4 +766,9 @@ ConfigView::ConfigView(void)
686 connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); 766 connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
687 767
768 QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this);
769 connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
770 QAction *showAboutAction = new QAction(NULL, "About", 0, this);
771 connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
772
688 // init tool bar 773 // init tool bar
689 backAction->addTo(toolBar); 774 backAction->addTo(toolBar);
@@ -715,4 +800,11 @@ ConfigView::ConfigView(void)
715 showDebugAction->addTo(optionMenu); 800 showDebugAction->addTo(optionMenu);
716 801
802 // create help menu
803 QPopupMenu* helpMenu = new QPopupMenu(this);
804 menu->insertSeparator();
805 menu->insertItem("&Help", helpMenu);
806 showIntroAction->addTo(helpMenu);
807 showAboutAction->addTo(helpMenu);
808
717 connect(configList, SIGNAL(menuSelected(struct menu *)), 809 connect(configList, SIGNAL(menuSelected(struct menu *)),
718 SLOT(changeMenu(struct menu *))); 810 SLOT(changeMenu(struct menu *)));
@@ -770,10 +862,10 @@ static void expr_print_help(void *data, const char *str)
770 * display a new help entry as soon as a new menu entry is selected 862 * display a new help entry as soon as a new menu entry is selected
771 */ 863 */
772void ConfigView::setHelp(QListViewItem* item) 864void ConfigMainWindow::setHelp(QListViewItem* item)
773{ 865{
774 struct symbol* sym; 866 struct symbol* sym;
775 struct menu* menu; 867 struct menu* menu;
776 868
777 configList->lineEdit->hide(); 869 configList->parent()->lineEdit->hide();
778 if (item) { 870 if (item) {
779 QString head, debug, help; 871 QString head, debug, help;
@@ -858,5 +950,5 @@ void ConfigView::setHelp(QListViewItem* item)
858} 950}
859 951
860void ConfigView::loadConfig(void) 952void ConfigMainWindow::loadConfig(void)
861{ 953{
862 QString s = QFileDialog::getOpenFileName(".config", NULL, this); 954 QString s = QFileDialog::getOpenFileName(".config", NULL, this);
@@ -865,7 +957,8 @@ void ConfigView::loadConfig(void)
865 if (conf_read(s.latin1())) 957 if (conf_read(s.latin1()))
866 QMessageBox::information(this, "qconf", "Unable to load configuration!"); 958 QMessageBox::information(this, "qconf", "Unable to load configuration!");
959 ConfigView::updateListAll();
867} 960}
868 961
869void ConfigView::saveConfig(void) 962void ConfigMainWindow::saveConfig(void)
870{ 963{
871 if (conf_write(NULL)) 964 if (conf_write(NULL))
@@ -873,5 +966,5 @@ void ConfigView::saveConfig(void)
873} 966}
874 967
875void ConfigView::saveConfigAs(void) 968void ConfigMainWindow::saveConfigAs(void)
876{ 969{
877 QString s = QFileDialog::getSaveFileName(".config", NULL, this); 970 QString s = QFileDialog::getSaveFileName(".config", NULL, this);
@@ -882,5 +975,5 @@ void ConfigView::saveConfigAs(void)
882} 975}
883 976
884void ConfigView::changeMenu(struct menu *menu) 977void ConfigMainWindow::changeMenu(struct menu *menu)
885{ 978{
886 configList->setRootMenu(menu); 979 configList->setRootMenu(menu);
@@ -888,5 +981,5 @@ void ConfigView::changeMenu(struct menu *menu)
888} 981}
889 982
890void ConfigView::listFocusChanged(void) 983void ConfigMainWindow::listFocusChanged(void)
891{ 984{
892 if (menuList->hasFocus()) { 985 if (menuList->hasFocus()) {
@@ -899,5 +992,5 @@ void ConfigView::listFocusChanged(void)
899} 992}
900 993
901void ConfigView::goBack(void) 994void ConfigMainWindow::goBack(void)
902{ 995{
903 ConfigItem* item; 996 ConfigItem* item;
@@ -916,5 +1009,5 @@ void ConfigView::goBack(void)
916} 1009}
917 1010
918void ConfigView::showSingleView(void) 1011void ConfigMainWindow::showSingleView(void)
919{ 1012{
920 menuList->hide(); 1013 menuList->hide();
@@ -929,5 +1022,5 @@ void ConfigView::showSingleView(void)
929} 1022}
930 1023
931void ConfigView::showSplitView(void) 1024void ConfigMainWindow::showSplitView(void)
932{ 1025{
933 configList->mode = symbolMode; 1026 configList->mode = symbolMode;
@@ -945,5 +1038,5 @@ void ConfigView::showSplitView(void)
945} 1038}
946 1039
947void ConfigView::showFullView(void) 1040void ConfigMainWindow::showFullView(void)
948{ 1041{
949 menuList->hide(); 1042 menuList->hide();
@@ -958,5 +1051,5 @@ void ConfigView::showFullView(void)
958} 1051}
959 1052
960void ConfigView::setShowAll(bool b) 1053void ConfigMainWindow::setShowAll(bool b)
961{ 1054{
962 if (configList->showAll == b) 1055 if (configList->showAll == b)
@@ -968,5 +1061,5 @@ void ConfigView::setShowAll(bool b)
968} 1061}
969 1062
970void ConfigView::setShowDebug(bool b) 1063void ConfigMainWindow::setShowDebug(bool b)
971{ 1064{
972 if (showDebug == b) 1065 if (showDebug == b)
@@ -975,5 +1068,5 @@ void ConfigView::setShowDebug(bool b)
975} 1068}
976 1069
977void ConfigView::setShowName(bool b) 1070void ConfigMainWindow::setShowName(bool b)
978{ 1071{
979 if (configList->showName == b) 1072 if (configList->showName == b)
@@ -983,5 +1076,5 @@ void ConfigView::setShowName(bool b)
983} 1076}
984 1077
985void ConfigView::setShowRange(bool b) 1078void ConfigMainWindow::setShowRange(bool b)
986{ 1079{
987 if (configList->showRange == b) 1080 if (configList->showRange == b)
@@ -991,5 +1084,5 @@ void ConfigView::setShowRange(bool b)
991} 1084}
992 1085
993void ConfigView::setShowData(bool b) 1086void ConfigMainWindow::setShowData(bool b)
994{ 1087{
995 if (configList->showData == b) 1088 if (configList->showData == b)
@@ -1003,5 +1096,5 @@ void ConfigView::setShowData(bool b)
1003 * TODO ask only when something changed 1096 * TODO ask only when something changed
1004 */ 1097 */
1005void ConfigView::closeEvent(QCloseEvent* e) 1098void ConfigMainWindow::closeEvent(QCloseEvent* e)
1006{ 1099{
1007 if (!sym_change_count) { 1100 if (!sym_change_count) {
@@ -1026,4 +1119,29 @@ void ConfigView::closeEvent(QCloseEvent* e)
1026} 1119}
1027 1120
1121void ConfigMainWindow::showIntro(void)
1122{
1123 static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n"
1124 "For each option, a blank box indicates the feature is disabled, a check\n"
1125 "indicates it is enabled, and a dot indicates that it is to be compiled\n"
1126 "as a module. Clicking on the box will cycle through the three states.\n\n"
1127 "If you do not see an option (e.g., a device driver) that you believe\n"
1128 "should be present, try turning on Show All Options under the Options menu.\n"
1129 "Although there is no cross reference yet to help you figure out what other\n"
1130 "options must be enabled to support the option you are interested in, you can\n"
1131 "still view the help of a grayed-out option.\n\n"
1132 "Toggling Show Debug Info under the Options menu will show the dependencies,\n"
1133 "which you can then match by examining other options.\n\n";
1134
1135 QMessageBox::information(this, "qconf", str);
1136}
1137
1138void ConfigMainWindow::showAbout(void)
1139{
1140 static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n"
1141 "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n";
1142
1143 QMessageBox::information(this, "qconf", str);
1144}
1145
1028void fixup_rootmenu(struct menu *menu) 1146void fixup_rootmenu(struct menu *menu)
1029{ 1147{
@@ -1039,5 +1157,5 @@ void fixup_rootmenu(struct menu *menu)
1039int main(int ac, char** av) 1157int main(int ac, char** av)
1040{ 1158{
1041 ConfigView* v; 1159 ConfigMainWindow* v;
1042 const char *name; 1160 const char *name;
1043 1161
@@ -1047,4 +1165,7 @@ int main(int ac, char** av)
1047 1165
1048 configApp = new QApplication(ac, av); 1166 configApp = new QApplication(ac, av);
1167#if QT_VERSION >= 300
1168 configSettings = new QSettings;
1169#endif
1049 if (ac > 1 && av[1][0] == '-') { 1170 if (ac > 1 && av[1][0] == '-') {
1050 switch (av[1][1]) { 1171 switch (av[1][1]) {
@@ -1064,5 +1185,6 @@ int main(int ac, char** av)
1064 conf_read(NULL); 1185 conf_read(NULL);
1065 //zconfdump(stdout); 1186 //zconfdump(stdout);
1066 v = new ConfigView(); 1187
1188 v = new ConfigMainWindow();
1067 1189
1068 //zconfdump(stdout); 1190 //zconfdump(stdout);
@@ -1070,4 +1192,12 @@ int main(int ac, char** av)
1070 configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); 1192 configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit()));
1071 configApp->exec(); 1193 configApp->exec();
1194
1195#if QT_VERSION >= 300
1196 configSettings->writeEntry("/kconfig/qconf/window x", v->pos().x());
1197 configSettings->writeEntry("/kconfig/qconf/window y", v->pos().y());
1198 configSettings->writeEntry("/kconfig/qconf/window width", v->size().width());
1199 configSettings->writeEntry("/kconfig/qconf/window height", v->size().height());
1200 delete configSettings;
1201#endif
1072 return 0; 1202 return 0;
1073} 1203}