hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/scripts/kconfig/qconf.cc
....@@ -1,49 +1,35 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
34 * Copyright (C) 2015 Boris Barbulovski <bbarbulovski@gmail.com>
4
- * Released under the terms of the GNU GPL v2.0.
55 */
66
7
-#include <qglobal.h>
8
-
9
-#include <QMainWindow>
10
-#include <QList>
11
-#include <qtextbrowser.h>
127 #include <QAction>
8
+#include <QApplication>
9
+#include <QCloseEvent>
10
+#include <QDebug>
11
+#include <QDesktopWidget>
1312 #include <QFileDialog>
13
+#include <QLabel>
14
+#include <QLayout>
15
+#include <QList>
1416 #include <QMenu>
15
-
16
-#include <qapplication.h>
17
-#include <qdesktopwidget.h>
18
-#include <qtoolbar.h>
19
-#include <qlayout.h>
20
-#include <qsplitter.h>
21
-#include <qlineedit.h>
22
-#include <qlabel.h>
23
-#include <qpushbutton.h>
24
-#include <qmenubar.h>
25
-#include <qmessagebox.h>
26
-#include <qregexp.h>
27
-#include <qevent.h>
17
+#include <QMenuBar>
18
+#include <QMessageBox>
19
+#include <QToolBar>
2820
2921 #include <stdlib.h>
3022
3123 #include "lkc.h"
3224 #include "qconf.h"
3325
34
-#include "qconf.moc"
35
-#include "images.c"
26
+#include "images.h"
3627
3728
3829 static QApplication *configApp;
3930 static ConfigSettings *configSettings;
4031
4132 QAction *ConfigMainWindow::saveAction;
42
-
43
-static inline QString qgettext(const char* str)
44
-{
45
- return QString::fromLocal8Bit(str);
46
-}
4733
4834 ConfigSettings::ConfigSettings()
4935 : QSettings("kernel.org", "qconf")
....@@ -88,14 +74,13 @@
8874 return true;
8975 }
9076
91
-
92
-/*
93
- * set the new data
94
- * TODO check the value
95
- */
96
-void ConfigItem::okRename(int col)
97
-{
98
-}
77
+QIcon ConfigItem::symbolYesIcon;
78
+QIcon ConfigItem::symbolModIcon;
79
+QIcon ConfigItem::symbolNoIcon;
80
+QIcon ConfigItem::choiceYesIcon;
81
+QIcon ConfigItem::choiceNoIcon;
82
+QIcon ConfigItem::menuIcon;
83
+QIcon ConfigItem::menubackIcon;
9984
10085 /*
10186 * update the displayed of a menu entry
....@@ -111,14 +96,14 @@
11196
11297 list = listView();
11398 if (goParent) {
114
- setPixmap(promptColIdx, list->menuBackPix);
99
+ setIcon(promptColIdx, menubackIcon);
115100 prompt = "..";
116101 goto set_prompt;
117102 }
118103
119104 sym = menu->sym;
120105 prop = menu->prompt;
121
- prompt = qgettext(menu_get_prompt(menu));
106
+ prompt = menu_get_prompt(menu);
122107
123108 if (prop) switch (prop->type) {
124109 case P_MENU:
....@@ -128,15 +113,15 @@
128113 */
129114 if (sym && list->rootEntry == menu)
130115 break;
131
- setPixmap(promptColIdx, list->menuPix);
116
+ setIcon(promptColIdx, menuIcon);
132117 } else {
133118 if (sym)
134119 break;
135
- setPixmap(promptColIdx, QIcon());
120
+ setIcon(promptColIdx, QIcon());
136121 }
137122 goto set_prompt;
138123 case P_COMMENT:
139
- setPixmap(promptColIdx, QIcon());
124
+ setIcon(promptColIdx, QIcon());
140125 goto set_prompt;
141126 default:
142127 ;
....@@ -144,7 +129,7 @@
144129 if (!sym)
145130 goto set_prompt;
146131
147
- setText(nameColIdx, QString::fromLocal8Bit(sym->name));
132
+ setText(nameColIdx, sym->name);
148133
149134 type = sym_get_type(sym);
150135 switch (type) {
....@@ -152,58 +137,38 @@
152137 case S_TRISTATE:
153138 char ch;
154139
155
- if (!sym_is_changable(sym) && list->optMode == normalOpt) {
156
- setPixmap(promptColIdx, QIcon());
157
- setText(noColIdx, QString::null);
158
- setText(modColIdx, QString::null);
159
- setText(yesColIdx, QString::null);
140
+ if (!sym_is_changeable(sym) && list->optMode == normalOpt) {
141
+ setIcon(promptColIdx, QIcon());
160142 break;
161143 }
162144 expr = sym_get_tristate_value(sym);
163145 switch (expr) {
164146 case yes:
165147 if (sym_is_choice_value(sym) && type == S_BOOLEAN)
166
- setPixmap(promptColIdx, list->choiceYesPix);
148
+ setIcon(promptColIdx, choiceYesIcon);
167149 else
168
- setPixmap(promptColIdx, list->symbolYesPix);
169
- setText(yesColIdx, "Y");
150
+ setIcon(promptColIdx, symbolYesIcon);
170151 ch = 'Y';
171152 break;
172153 case mod:
173
- setPixmap(promptColIdx, list->symbolModPix);
174
- setText(modColIdx, "M");
154
+ setIcon(promptColIdx, symbolModIcon);
175155 ch = 'M';
176156 break;
177157 default:
178158 if (sym_is_choice_value(sym) && type == S_BOOLEAN)
179
- setPixmap(promptColIdx, list->choiceNoPix);
159
+ setIcon(promptColIdx, choiceNoIcon);
180160 else
181
- setPixmap(promptColIdx, list->symbolNoPix);
182
- setText(noColIdx, "N");
161
+ setIcon(promptColIdx, symbolNoIcon);
183162 ch = 'N';
184163 break;
185164 }
186
- if (expr != no)
187
- setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0);
188
- if (expr != mod)
189
- setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0);
190
- if (expr != yes)
191
- setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0);
192165
193166 setText(dataColIdx, QChar(ch));
194167 break;
195168 case S_INT:
196169 case S_HEX:
197170 case S_STRING:
198
- const char* data;
199
-
200
- data = sym_get_string_value(sym);
201
-
202
- setText(dataColIdx, data);
203
- if (type == S_STRING)
204
- prompt = QString("%1: %2").arg(prompt).arg(data);
205
- else
206
- prompt = QString("(%2) %1").arg(prompt).arg(data);
171
+ setText(dataColIdx, sym_get_string_value(sym));
207172 break;
208173 }
209174 if (!sym_has_value(sym) && visible)
....@@ -244,6 +209,17 @@
244209 if (list->mode != fullMode)
245210 setExpanded(true);
246211 sym_calc_value(menu->sym);
212
+
213
+ if (menu->sym) {
214
+ enum symbol_type type = menu->sym->type;
215
+
216
+ // Allow to edit "int", "hex", and "string" in-place in
217
+ // the data column. Unfortunately, you cannot specify
218
+ // the flags per column. Set ItemIsEditable for all
219
+ // columns here, and check the column in createEditor().
220
+ if (type == S_INT || type == S_HEX || type == S_STRING)
221
+ setFlags(flags() | Qt::ItemIsEditable);
222
+ }
247223 }
248224 updateMenu();
249225 }
....@@ -264,53 +240,67 @@
264240 }
265241 }
266242
267
-ConfigLineEdit::ConfigLineEdit(ConfigView* parent)
268
- : Parent(parent)
243
+QWidget *ConfigItemDelegate::createEditor(QWidget *parent,
244
+ const QStyleOptionViewItem &option,
245
+ const QModelIndex &index) const
269246 {
270
- connect(this, SIGNAL(editingFinished()), SLOT(hide()));
247
+ ConfigItem *item;
248
+
249
+ // Only the data column is editable
250
+ if (index.column() != dataColIdx)
251
+ return nullptr;
252
+
253
+ // You cannot edit invisible menus
254
+ item = static_cast<ConfigItem *>(index.internalPointer());
255
+ if (!item || !item->menu || !menu_is_visible(item->menu))
256
+ return nullptr;
257
+
258
+ return QStyledItemDelegate::createEditor(parent, option, index);
271259 }
272260
273
-void ConfigLineEdit::show(ConfigItem* i)
261
+void ConfigItemDelegate::setModelData(QWidget *editor,
262
+ QAbstractItemModel *model,
263
+ const QModelIndex &index) const
274264 {
275
- item = i;
276
- if (sym_get_string_value(item->menu->sym))
277
- setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym)));
278
- else
279
- setText(QString::null);
280
- Parent::show();
281
- setFocus();
282
-}
265
+ QLineEdit *lineEdit;
266
+ ConfigItem *item;
267
+ struct symbol *sym;
268
+ bool success;
283269
284
-void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
285
-{
286
- switch (e->key()) {
287
- case Qt::Key_Escape:
288
- break;
289
- case Qt::Key_Return:
290
- case Qt::Key_Enter:
291
- sym_set_string_value(item->menu->sym, text().toLatin1());
292
- parent()->updateList(item);
293
- break;
294
- default:
295
- Parent::keyPressEvent(e);
296
- return;
270
+ lineEdit = qobject_cast<QLineEdit *>(editor);
271
+ // If this is not a QLineEdit, use the parent's default.
272
+ // (does this happen?)
273
+ if (!lineEdit)
274
+ goto parent;
275
+
276
+ item = static_cast<ConfigItem *>(index.internalPointer());
277
+ if (!item || !item->menu)
278
+ goto parent;
279
+
280
+ sym = item->menu->sym;
281
+ if (!sym)
282
+ goto parent;
283
+
284
+ success = sym_set_string_value(sym, lineEdit->text().toUtf8().data());
285
+ if (success) {
286
+ ConfigList::updateListForAll();
287
+ } else {
288
+ QMessageBox::information(editor, "qconf",
289
+ "Cannot set the data (maybe due to out of range).\n"
290
+ "Setting the old value.");
291
+ lineEdit->setText(sym_get_string_value(sym));
297292 }
298
- e->accept();
299
- parent()->list->setFocus();
300
- hide();
293
+
294
+parent:
295
+ QStyledItemDelegate::setModelData(editor, model, index);
301296 }
302297
303
-ConfigList::ConfigList(ConfigView* p, const char *name)
304
- : Parent(p),
298
+ConfigList::ConfigList(QWidget *parent, const char *name)
299
+ : QTreeWidget(parent),
305300 updateAll(false),
306
- symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
307
- choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
308
- menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),
309
- showName(false), showRange(false), showData(false), mode(singleMode), optMode(normalOpt),
301
+ showName(false), mode(singleMode), optMode(normalOpt),
310302 rootEntry(0), headerPopup(0)
311303 {
312
- int i;
313
-
314304 setObjectName(name);
315305 setSortingEnabled(false);
316306 setRootIsDecorated(true);
....@@ -318,7 +308,7 @@
318308 setVerticalScrollMode(ScrollPerPixel);
319309 setHorizontalScrollMode(ScrollPerPixel);
320310
321
- setHeaderLabels(QStringList() << "Option" << "Name" << "N" << "M" << "Y" << "Value");
311
+ setHeaderLabels(QStringList() << "Option" << "Name" << "Value");
322312
323313 connect(this, SIGNAL(itemSelectionChanged(void)),
324314 SLOT(updateSelection(void)));
....@@ -326,16 +316,23 @@
326316 if (name) {
327317 configSettings->beginGroup(name);
328318 showName = configSettings->value("/showName", false).toBool();
329
- showRange = configSettings->value("/showRange", false).toBool();
330
- showData = configSettings->value("/showData", false).toBool();
331319 optMode = (enum optionMode)configSettings->value("/optionMode", 0).toInt();
332320 configSettings->endGroup();
333321 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
334322 }
335323
336
- addColumn(promptColIdx);
324
+ showColumn(promptColIdx);
325
+
326
+ setItemDelegate(new ConfigItemDelegate(this));
327
+
328
+ allLists.append(this);
337329
338330 reinit();
331
+}
332
+
333
+ConfigList::~ConfigList()
334
+{
335
+ allLists.removeOne(this);
339336 }
340337
341338 bool ConfigList::menuSkip(struct menu *menu)
....@@ -351,21 +348,22 @@
351348
352349 void ConfigList::reinit(void)
353350 {
354
- removeColumn(dataColIdx);
355
- removeColumn(yesColIdx);
356
- removeColumn(modColIdx);
357
- removeColumn(noColIdx);
358
- removeColumn(nameColIdx);
351
+ hideColumn(nameColIdx);
359352
360353 if (showName)
361
- addColumn(nameColIdx);
362
- if (showRange) {
363
- addColumn(noColIdx);
364
- addColumn(modColIdx);
365
- addColumn(yesColIdx);
366
- }
367
- if (showData)
368
- addColumn(dataColIdx);
354
+ showColumn(nameColIdx);
355
+
356
+ updateListAll();
357
+}
358
+
359
+void ConfigList::setOptionMode(QAction *action)
360
+{
361
+ if (action == showNormalAction)
362
+ optMode = normalOpt;
363
+ else if (action == showAllAction)
364
+ optMode = allOpt;
365
+ else
366
+ optMode = promptOpt;
369367
370368 updateListAll();
371369 }
....@@ -375,8 +373,6 @@
375373 if (!objectName().isEmpty()) {
376374 configSettings->beginGroup(objectName());
377375 configSettings->setValue("/showName", showName);
378
- configSettings->setValue("/showRange", showRange);
379
- configSettings->setValue("/showData", showData);
380376 configSettings->setValue("/optionMode", (int)optMode);
381377 configSettings->endGroup();
382378 }
....@@ -415,15 +411,15 @@
415411 emit menuSelected(menu);
416412 }
417413
418
-void ConfigList::updateList(ConfigItem* item)
414
+void ConfigList::updateList()
419415 {
420416 ConfigItem* last = 0;
417
+ ConfigItem *item;
421418
422419 if (!rootEntry) {
423420 if (mode != listMode)
424421 goto update;
425422 QTreeWidgetItemIterator it(this);
426
- ConfigItem* item;
427423
428424 while (*it) {
429425 item = (ConfigItem*)(*it);
....@@ -445,7 +441,7 @@
445441 }
446442 if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) &&
447443 rootEntry->sym && rootEntry->prompt) {
448
- item = last ? last->nextSibling() : firstChild();
444
+ item = last ? last->nextSibling() : nullptr;
449445 if (!item)
450446 item = new ConfigItem(this, last, rootEntry, true);
451447 else
....@@ -457,9 +453,31 @@
457453 return;
458454 }
459455 update:
460
- updateMenuList(this, rootEntry);
456
+ updateMenuList(rootEntry);
461457 update();
462458 resizeColumnToContents(0);
459
+}
460
+
461
+void ConfigList::updateListForAll()
462
+{
463
+ QListIterator<ConfigList *> it(allLists);
464
+
465
+ while (it.hasNext()) {
466
+ ConfigList *list = it.next();
467
+
468
+ list->updateList();
469
+ }
470
+}
471
+
472
+void ConfigList::updateListAllForAll()
473
+{
474
+ QListIterator<ConfigList *> it(allLists);
475
+
476
+ while (it.hasNext()) {
477
+ ConfigList *list = it.next();
478
+
479
+ list->updateList();
480
+ }
463481 }
464482
465483 void ConfigList::setValue(ConfigItem* item, tristate val)
....@@ -482,7 +500,7 @@
482500 return;
483501 if (oldval == no && item->menu->list)
484502 item->setExpanded(true);
485
- parent()->updateList(item);
503
+ ConfigList::updateListForAll();
486504 break;
487505 }
488506 }
....@@ -516,12 +534,9 @@
516534 item->setExpanded(true);
517535 }
518536 if (oldexpr != newexpr)
519
- parent()->updateList(item);
537
+ ConfigList::updateListForAll();
520538 break;
521
- case S_INT:
522
- case S_HEX:
523
- case S_STRING:
524
- parent()->lineEdit->show(item);
539
+ default:
525540 break;
526541 }
527542 }
....@@ -535,11 +550,11 @@
535550 type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN;
536551 if (type != P_MENU)
537552 return;
538
- updateMenuList(this, 0);
553
+ updateMenuList(0);
539554 rootEntry = menu;
540555 updateListAll();
541556 if (currentItem()) {
542
- currentItem()->setSelected(hasFocus());
557
+ setSelected(currentItem(), hasFocus());
543558 scrollToItem(currentItem());
544559 }
545560 }
....@@ -639,7 +654,7 @@
639654 }
640655 }
641656
642
-void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu)
657
+void ConfigList::updateMenuList(struct menu *menu)
643658 {
644659 struct menu* child;
645660 ConfigItem* item;
....@@ -648,19 +663,19 @@
648663 enum prop_type type;
649664
650665 if (!menu) {
651
- while (parent->topLevelItemCount() > 0)
666
+ while (topLevelItemCount() > 0)
652667 {
653
- delete parent->takeTopLevelItem(0);
668
+ delete takeTopLevelItem(0);
654669 }
655670
656671 return;
657672 }
658673
659
- last = (ConfigItem*)parent->topLevelItem(0);
674
+ last = (ConfigItem *)topLevelItem(0);
660675 if (last && !last->goParent)
661676 last = 0;
662677 for (child = menu->list; child; child = child->next) {
663
- item = last ? last->nextSibling() : (ConfigItem*)parent->topLevelItem(0);
678
+ item = last ? last->nextSibling() : (ConfigItem *)topLevelItem(0);
664679 type = child->prompt ? child->prompt->type : P_UNKNOWN;
665680
666681 switch (mode) {
....@@ -681,7 +696,7 @@
681696 if (!child->sym && !child->list && !child->prompt)
682697 continue;
683698 if (!item || item->menu != child)
684
- item = new ConfigItem(parent, last, child, visible);
699
+ item = new ConfigItem(this, last, child, visible);
685700 else
686701 item->testUpdateMenu(visible);
687702
....@@ -694,7 +709,7 @@
694709 }
695710 hide:
696711 if (item && item->menu == child) {
697
- last = (ConfigItem*)parent->topLevelItem(0);
712
+ last = (ConfigItem *)topLevelItem(0);
698713 if (last == item)
699714 last = 0;
700715 else while (last->nextSibling() != item)
....@@ -736,7 +751,10 @@
736751 type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
737752 if (type == P_MENU && rootEntry != menu &&
738753 mode != fullMode && mode != menuMode) {
739
- emit menuSelected(menu);
754
+ if (mode == menuMode)
755
+ emit menuSelected(menu);
756
+ else
757
+ emit itemSelected(menu);
740758 break;
741759 }
742760 case Qt::Key_Space:
....@@ -782,7 +800,7 @@
782800 idx = header()->logicalIndexAt(x);
783801 switch (idx) {
784802 case promptColIdx:
785
- icon = item->pixmap(promptColIdx);
803
+ icon = item->icon(promptColIdx);
786804 if (!icon.isNull()) {
787805 int off = header()->sectionPosition(0) + visualRect(indexAt(p)).x() + 4; // 4 is Hardcoded image offset. There might be a way to do it properly.
788806 if (x >= off && x < off + icon.availableSizes().first().width()) {
....@@ -793,21 +811,13 @@
793811 break;
794812 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
795813 if (ptype == P_MENU && rootEntry != menu &&
796
- mode != fullMode && mode != menuMode)
814
+ mode != fullMode && mode != menuMode &&
815
+ mode != listMode)
797816 emit menuSelected(menu);
798817 else
799818 changeValue(item);
800819 }
801820 }
802
- break;
803
- case noColIdx:
804
- setValue(item, no);
805
- break;
806
- case modColIdx:
807
- setValue(item, mod);
808
- break;
809
- case yesColIdx:
810
- setValue(item, yes);
811821 break;
812822 case dataColIdx:
813823 changeValue(item);
....@@ -828,7 +838,7 @@
828838
829839 void ConfigList::mouseDoubleClickEvent(QMouseEvent* e)
830840 {
831
- QPoint p = e->pos(); // TODO: Check if this works(was contentsToViewport).
841
+ QPoint p = e->pos();
832842 ConfigItem* item = (ConfigItem*)itemAt(p);
833843 struct menu *menu;
834844 enum prop_type ptype;
....@@ -843,9 +853,12 @@
843853 if (!menu)
844854 goto skip;
845855 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
846
- if (ptype == P_MENU && (mode == singleMode || mode == symbolMode))
847
- emit menuSelected(menu);
848
- else if (menu->sym)
856
+ if (ptype == P_MENU && mode != listMode) {
857
+ if (mode == singleMode)
858
+ emit itemSelected(menu);
859
+ else if (mode == symbolMode)
860
+ emit menuSelected(menu);
861
+ } else if (menu->sym)
849862 changeValue(item);
850863
851864 skip:
....@@ -861,7 +874,7 @@
861874
862875 ConfigItem* item = (ConfigItem *)currentItem();
863876 if (item) {
864
- item->setSelected(true);
877
+ setSelected(item, true);
865878 menu = item->menu;
866879 }
867880 emit gotFocus(menu);
....@@ -876,28 +889,10 @@
876889 action = new QAction("Show Name", this);
877890 action->setCheckable(true);
878891 connect(action, SIGNAL(toggled(bool)),
879
- parent(), SLOT(setShowName(bool)));
880
- connect(parent(), SIGNAL(showNameChanged(bool)),
892
+ SLOT(setShowName(bool)));
893
+ connect(this, SIGNAL(showNameChanged(bool)),
881894 action, SLOT(setChecked(bool)));
882895 action->setChecked(showName);
883
- headerPopup->addAction(action);
884
-
885
- action = new QAction("Show Range", this);
886
- action->setCheckable(true);
887
- connect(action, SIGNAL(toggled(bool)),
888
- parent(), SLOT(setShowRange(bool)));
889
- connect(parent(), SIGNAL(showRangeChanged(bool)),
890
- action, SLOT(setChecked(bool)));
891
- action->setChecked(showRange);
892
- headerPopup->addAction(action);
893
-
894
- action = new QAction("Show Data", this);
895
- action->setCheckable(true);
896
- connect(action, SIGNAL(toggled(bool)),
897
- parent(), SLOT(setShowData(bool)));
898
- connect(parent(), SIGNAL(showDataChanged(bool)),
899
- action, SLOT(setChecked(bool)));
900
- action->setChecked(showData);
901896 headerPopup->addAction(action);
902897 }
903898
....@@ -905,78 +900,20 @@
905900 e->accept();
906901 }
907902
908
-ConfigView*ConfigView::viewList;
909
-QAction *ConfigView::showNormalAction;
910
-QAction *ConfigView::showAllAction;
911
-QAction *ConfigView::showPromptAction;
912
-
913
-ConfigView::ConfigView(QWidget* parent, const char *name)
914
- : Parent(parent)
903
+void ConfigList::setShowName(bool on)
915904 {
916
- setObjectName(name);
917
- QVBoxLayout *verticalLayout = new QVBoxLayout(this);
918
- verticalLayout->setContentsMargins(0, 0, 0, 0);
905
+ if (showName == on)
906
+ return;
919907
920
- list = new ConfigList(this);
921
- verticalLayout->addWidget(list);
922
- lineEdit = new ConfigLineEdit(this);
923
- lineEdit->hide();
924
- verticalLayout->addWidget(lineEdit);
925
-
926
- this->nextView = viewList;
927
- viewList = this;
908
+ showName = on;
909
+ reinit();
910
+ emit showNameChanged(on);
928911 }
929912
930
-ConfigView::~ConfigView(void)
931
-{
932
- ConfigView** vp;
933
-
934
- for (vp = &viewList; *vp; vp = &(*vp)->nextView) {
935
- if (*vp == this) {
936
- *vp = nextView;
937
- break;
938
- }
939
- }
940
-}
941
-
942
-void ConfigView::setOptionMode(QAction *act)
943
-{
944
- if (act == showNormalAction)
945
- list->optMode = normalOpt;
946
- else if (act == showAllAction)
947
- list->optMode = allOpt;
948
- else
949
- list->optMode = promptOpt;
950
-
951
- list->updateListAll();
952
-}
953
-
954
-void ConfigView::setShowName(bool b)
955
-{
956
- if (list->showName != b) {
957
- list->showName = b;
958
- list->reinit();
959
- emit showNameChanged(b);
960
- }
961
-}
962
-
963
-void ConfigView::setShowRange(bool b)
964
-{
965
- if (list->showRange != b) {
966
- list->showRange = b;
967
- list->reinit();
968
- emit showRangeChanged(b);
969
- }
970
-}
971
-
972
-void ConfigView::setShowData(bool b)
973
-{
974
- if (list->showData != b) {
975
- list->showData = b;
976
- list->reinit();
977
- emit showDataChanged(b);
978
- }
979
-}
913
+QList<ConfigList *> ConfigList::allLists;
914
+QAction *ConfigList::showNormalAction;
915
+QAction *ConfigList::showAllAction;
916
+QAction *ConfigList::showPromptAction;
980917
981918 void ConfigList::setAllOpen(bool open)
982919 {
....@@ -989,27 +926,11 @@
989926 }
990927 }
991928
992
-void ConfigView::updateList(ConfigItem* item)
993
-{
994
- ConfigView* v;
995
-
996
- for (v = viewList; v; v = v->nextView)
997
- v->list->updateList(item);
998
-}
999
-
1000
-void ConfigView::updateListAll(void)
1001
-{
1002
- ConfigView* v;
1003
-
1004
- for (v = viewList; v; v = v->nextView)
1005
- v->list->updateListAll();
1006
-}
1007
-
1008929 ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
1009930 : Parent(parent), sym(0), _menu(0)
1010931 {
1011932 setObjectName(name);
1012
-
933
+ setOpenLinks(false);
1013934
1014935 if (!objectName().isEmpty()) {
1015936 configSettings->beginGroup(objectName());
....@@ -1017,6 +938,16 @@
1017938 configSettings->endGroup();
1018939 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
1019940 }
941
+
942
+ contextMenu = createStandardContextMenu();
943
+ QAction *action = new QAction("Show Debug Info", contextMenu);
944
+
945
+ action->setCheckable(true);
946
+ connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
947
+ connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setChecked(bool)));
948
+ action->setChecked(showDebug());
949
+ contextMenu->addSeparator();
950
+ contextMenu->addAction(action);
1020951 }
1021952
1022953 void ConfigInfoView::saveSettings(void)
....@@ -1071,108 +1002,119 @@
10711002 void ConfigInfoView::menuInfo(void)
10721003 {
10731004 struct symbol* sym;
1074
- QString head, debug, help;
1005
+ QString info;
1006
+ QTextStream stream(&info);
10751007
10761008 sym = _menu->sym;
10771009 if (sym) {
10781010 if (_menu->prompt) {
1079
- head += "<big><b>";
1080
- head += print_filter(_menu->prompt->text);
1081
- head += "</b></big>";
1011
+ stream << "<big><b>";
1012
+ stream << print_filter(_menu->prompt->text);
1013
+ stream << "</b></big>";
10821014 if (sym->name) {
1083
- head += " (";
1015
+ stream << " (";
10841016 if (showDebug())
1085
- head += QString().sprintf("<a href=\"s%p\">", sym);
1086
- head += print_filter(sym->name);
1017
+ stream << "<a href=\"s" << sym->name << "\">";
1018
+ stream << print_filter(sym->name);
10871019 if (showDebug())
1088
- head += "</a>";
1089
- head += ")";
1020
+ stream << "</a>";
1021
+ stream << ")";
10901022 }
10911023 } else if (sym->name) {
1092
- head += "<big><b>";
1024
+ stream << "<big><b>";
10931025 if (showDebug())
1094
- head += QString().sprintf("<a href=\"s%p\">", sym);
1095
- head += print_filter(sym->name);
1026
+ stream << "<a href=\"s" << sym->name << "\">";
1027
+ stream << print_filter(sym->name);
10961028 if (showDebug())
1097
- head += "</a>";
1098
- head += "</b></big>";
1029
+ stream << "</a>";
1030
+ stream << "</b></big>";
10991031 }
1100
- head += "<br><br>";
1032
+ stream << "<br><br>";
11011033
11021034 if (showDebug())
1103
- debug = debug_info(sym);
1035
+ stream << debug_info(sym);
11041036
11051037 struct gstr help_gstr = str_new();
1038
+
11061039 menu_get_ext_help(_menu, &help_gstr);
1107
- help = print_filter(str_get(&help_gstr));
1040
+ stream << print_filter(str_get(&help_gstr));
11081041 str_free(&help_gstr);
11091042 } else if (_menu->prompt) {
1110
- head += "<big><b>";
1111
- head += print_filter(_menu->prompt->text);
1112
- head += "</b></big><br><br>";
1043
+ stream << "<big><b>";
1044
+ stream << print_filter(_menu->prompt->text);
1045
+ stream << "</b></big><br><br>";
11131046 if (showDebug()) {
11141047 if (_menu->prompt->visible.expr) {
1115
- debug += "&nbsp;&nbsp;dep: ";
1116
- expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
1117
- debug += "<br><br>";
1048
+ stream << "&nbsp;&nbsp;dep: ";
1049
+ expr_print(_menu->prompt->visible.expr,
1050
+ expr_print_help, &stream, E_NONE);
1051
+ stream << "<br><br>";
11181052 }
1053
+
1054
+ stream << "defined at " << _menu->file->name << ":"
1055
+ << _menu->lineno << "<br><br>";
11191056 }
11201057 }
1121
- if (showDebug())
1122
- debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno);
11231058
1124
- setText(head + debug + help);
1059
+ setText(info);
11251060 }
11261061
11271062 QString ConfigInfoView::debug_info(struct symbol *sym)
11281063 {
11291064 QString debug;
1065
+ QTextStream stream(&debug);
11301066
1131
- debug += "type: ";
1132
- debug += print_filter(sym_type_name(sym->type));
1067
+ stream << "type: ";
1068
+ stream << print_filter(sym_type_name(sym->type));
11331069 if (sym_is_choice(sym))
1134
- debug += " (choice)";
1070
+ stream << " (choice)";
11351071 debug += "<br>";
11361072 if (sym->rev_dep.expr) {
1137
- debug += "reverse dep: ";
1138
- expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE);
1139
- debug += "<br>";
1073
+ stream << "reverse dep: ";
1074
+ expr_print(sym->rev_dep.expr, expr_print_help, &stream, E_NONE);
1075
+ stream << "<br>";
11401076 }
11411077 for (struct property *prop = sym->prop; prop; prop = prop->next) {
11421078 switch (prop->type) {
11431079 case P_PROMPT:
11441080 case P_MENU:
1145
- debug += QString().sprintf("prompt: <a href=\"m%p\">", prop->menu);
1146
- debug += print_filter(prop->text);
1147
- debug += "</a><br>";
1081
+ stream << "prompt: <a href=\"m" << sym->name << "\">";
1082
+ stream << print_filter(prop->text);
1083
+ stream << "</a><br>";
11481084 break;
11491085 case P_DEFAULT:
11501086 case P_SELECT:
11511087 case P_RANGE:
1152
- debug += prop_get_type_name(prop->type);
1153
- debug += ": ";
1154
- expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1155
- debug += "<br>";
1088
+ case P_COMMENT:
1089
+ case P_IMPLY:
1090
+ case P_SYMBOL:
1091
+ stream << prop_get_type_name(prop->type);
1092
+ stream << ": ";
1093
+ expr_print(prop->expr, expr_print_help,
1094
+ &stream, E_NONE);
1095
+ stream << "<br>";
11561096 break;
11571097 case P_CHOICE:
11581098 if (sym_is_choice(sym)) {
1159
- debug += "choice: ";
1160
- expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1161
- debug += "<br>";
1099
+ stream << "choice: ";
1100
+ expr_print(prop->expr, expr_print_help,
1101
+ &stream, E_NONE);
1102
+ stream << "<br>";
11621103 }
11631104 break;
11641105 default:
1165
- debug += "unknown property: ";
1166
- debug += prop_get_type_name(prop->type);
1167
- debug += "<br>";
1106
+ stream << "unknown property: ";
1107
+ stream << prop_get_type_name(prop->type);
1108
+ stream << "<br>";
11681109 }
11691110 if (prop->visible.expr) {
1170
- debug += "&nbsp;&nbsp;&nbsp;&nbsp;dep: ";
1171
- expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
1172
- debug += "<br>";
1111
+ stream << "&nbsp;&nbsp;&nbsp;&nbsp;dep: ";
1112
+ expr_print(prop->visible.expr, expr_print_help,
1113
+ &stream, E_NONE);
1114
+ stream << "<br>";
11731115 }
11741116 }
1175
- debug += "<br>";
1117
+ stream << "<br>";
11761118
11771119 return debug;
11781120 }
....@@ -1210,46 +1152,81 @@
12101152
12111153 void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str)
12121154 {
1213
- QString* text = reinterpret_cast<QString*>(data);
1214
- QString str2 = print_filter(str);
1155
+ QTextStream *stream = reinterpret_cast<QTextStream *>(data);
12151156
12161157 if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
1217
- *text += QString().sprintf("<a href=\"s%p\">", sym);
1218
- *text += str2;
1219
- *text += "</a>";
1220
- } else
1221
- *text += str2;
1158
+ *stream << "<a href=\"s" << sym->name << "\">";
1159
+ *stream << print_filter(str);
1160
+ *stream << "</a>";
1161
+ } else {
1162
+ *stream << print_filter(str);
1163
+ }
12221164 }
12231165
1224
-QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
1166
+void ConfigInfoView::clicked(const QUrl &url)
12251167 {
1226
- QMenu* popup = Parent::createStandardContextMenu(pos);
1227
- QAction* action = new QAction("Show Debug Info", popup);
1168
+ QByteArray str = url.toEncoded();
1169
+ const std::size_t count = str.size();
1170
+ char *data = new char[count + 1];
1171
+ struct symbol **result;
1172
+ struct menu *m = NULL;
12281173
1229
- action->setCheckable(true);
1230
- connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
1231
- connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setChecked(bool)));
1232
- action->setChecked(showDebug());
1233
- popup->addSeparator();
1234
- popup->addAction(action);
1235
- return popup;
1174
+ if (count < 1) {
1175
+ delete[] data;
1176
+ return;
1177
+ }
1178
+
1179
+ memcpy(data, str.constData(), count);
1180
+ data[count] = '\0';
1181
+
1182
+ /* Seek for exact match */
1183
+ data[0] = '^';
1184
+ strcat(data, "$");
1185
+ result = sym_re_search(data);
1186
+ if (!result) {
1187
+ delete[] data;
1188
+ return;
1189
+ }
1190
+
1191
+ sym = *result;
1192
+
1193
+ /* Seek for the menu which holds the symbol */
1194
+ for (struct property *prop = sym->prop; prop; prop = prop->next) {
1195
+ if (prop->type != P_PROMPT && prop->type != P_MENU)
1196
+ continue;
1197
+ m = prop->menu;
1198
+ break;
1199
+ }
1200
+
1201
+ if (!m) {
1202
+ /* Symbol is not visible as a menu */
1203
+ symbolInfo();
1204
+ emit showDebugChanged(true);
1205
+ } else {
1206
+ emit menuSelected(m);
1207
+ }
1208
+
1209
+ free(result);
1210
+ delete[] data;
12361211 }
12371212
1238
-void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e)
1213
+void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
12391214 {
1240
- Parent::contextMenuEvent(e);
1215
+ contextMenu->popup(event->globalPos());
1216
+ event->accept();
12411217 }
12421218
1243
-ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name)
1219
+ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow *parent)
12441220 : Parent(parent), result(NULL)
12451221 {
1246
- setObjectName(name);
1222
+ setObjectName("search");
12471223 setWindowTitle("Search Config");
12481224
12491225 QVBoxLayout* layout1 = new QVBoxLayout(this);
12501226 layout1->setContentsMargins(11, 11, 11, 11);
12511227 layout1->setSpacing(6);
1252
- QHBoxLayout* layout2 = new QHBoxLayout(0);
1228
+
1229
+ QHBoxLayout* layout2 = new QHBoxLayout();
12531230 layout2->setContentsMargins(0, 0, 0, 0);
12541231 layout2->setSpacing(6);
12551232 layout2->addWidget(new QLabel("Find:", this));
....@@ -1264,35 +1241,33 @@
12641241
12651242 split = new QSplitter(this);
12661243 split->setOrientation(Qt::Vertical);
1267
- list = new ConfigView(split, name);
1268
- list->list->mode = listMode;
1269
- info = new ConfigInfoView(split, name);
1270
- connect(list->list, SIGNAL(menuChanged(struct menu *)),
1244
+ list = new ConfigList(split, "search");
1245
+ list->mode = listMode;
1246
+ info = new ConfigInfoView(split, "search");
1247
+ connect(list, SIGNAL(menuChanged(struct menu *)),
12711248 info, SLOT(setInfo(struct menu *)));
1272
- connect(list->list, SIGNAL(menuChanged(struct menu *)),
1249
+ connect(list, SIGNAL(menuChanged(struct menu *)),
12731250 parent, SLOT(setMenuLink(struct menu *)));
12741251
12751252 layout1->addWidget(split);
12761253
1277
- if (name) {
1278
- QVariant x, y;
1279
- int width, height;
1280
- bool ok;
1254
+ QVariant x, y;
1255
+ int width, height;
1256
+ bool ok;
12811257
1282
- configSettings->beginGroup(name);
1283
- width = configSettings->value("/window width", parent->width() / 2).toInt();
1284
- height = configSettings->value("/window height", parent->height() / 2).toInt();
1285
- resize(width, height);
1286
- x = configSettings->value("/window x");
1287
- y = configSettings->value("/window y");
1288
- if ((x.isValid())&&(y.isValid()))
1289
- move(x.toInt(), y.toInt());
1290
- QList<int> sizes = configSettings->readSizes("/split", &ok);
1291
- if (ok)
1292
- split->setSizes(sizes);
1293
- configSettings->endGroup();
1294
- connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
1295
- }
1258
+ configSettings->beginGroup("search");
1259
+ width = configSettings->value("/window width", parent->width() / 2).toInt();
1260
+ height = configSettings->value("/window height", parent->height() / 2).toInt();
1261
+ resize(width, height);
1262
+ x = configSettings->value("/window x");
1263
+ y = configSettings->value("/window y");
1264
+ if (x.isValid() && y.isValid())
1265
+ move(x.toInt(), y.toInt());
1266
+ QList<int> sizes = configSettings->readSizes("/split", &ok);
1267
+ if (ok)
1268
+ split->setSizes(sizes);
1269
+ configSettings->endGroup();
1270
+ connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
12961271 }
12971272
12981273 void ConfigSearchWindow::saveSettings(void)
....@@ -1315,7 +1290,7 @@
13151290 ConfigItem *lastItem = NULL;
13161291
13171292 free(result);
1318
- list->list->clear();
1293
+ list->clear();
13191294 info->clear();
13201295
13211296 result = sym_re_search(editField->text().toLatin1());
....@@ -1323,7 +1298,7 @@
13231298 return;
13241299 for (p = result; *p; p++) {
13251300 for_all_prompts((*p), prop)
1326
- lastItem = new ConfigItem(list->list, lastItem, prop->menu,
1301
+ lastItem = new ConfigItem(list, lastItem, prop->menu,
13271302 menu_is_visible(prop->menu));
13281303 }
13291304 }
....@@ -1334,7 +1309,6 @@
13341309 ConfigMainWindow::ConfigMainWindow(void)
13351310 : searchWindow(0)
13361311 {
1337
- QMenuBar* menu;
13381312 bool ok = true;
13391313 QVariant x, y;
13401314 int width, height;
....@@ -1355,44 +1329,64 @@
13551329 if ((x.isValid())&&(y.isValid()))
13561330 move(x.toInt(), y.toInt());
13571331
1358
- split1 = new QSplitter(this);
1332
+ // set up icons
1333
+ ConfigItem::symbolYesIcon = QIcon(QPixmap(xpm_symbol_yes));
1334
+ ConfigItem::symbolModIcon = QIcon(QPixmap(xpm_symbol_mod));
1335
+ ConfigItem::symbolNoIcon = QIcon(QPixmap(xpm_symbol_no));
1336
+ ConfigItem::choiceYesIcon = QIcon(QPixmap(xpm_choice_yes));
1337
+ ConfigItem::choiceNoIcon = QIcon(QPixmap(xpm_choice_no));
1338
+ ConfigItem::menuIcon = QIcon(QPixmap(xpm_menu));
1339
+ ConfigItem::menubackIcon = QIcon(QPixmap(xpm_menuback));
1340
+
1341
+ QWidget *widget = new QWidget(this);
1342
+ QVBoxLayout *layout = new QVBoxLayout(widget);
1343
+ setCentralWidget(widget);
1344
+
1345
+ split1 = new QSplitter(widget);
13591346 split1->setOrientation(Qt::Horizontal);
1360
- setCentralWidget(split1);
1347
+ split1->setChildrenCollapsible(false);
13611348
1362
- menuView = new ConfigView(split1, "menu");
1363
- menuList = menuView->list;
1349
+ menuList = new ConfigList(widget, "menu");
13641350
1365
- split2 = new QSplitter(split1);
1351
+ split2 = new QSplitter(widget);
1352
+ split2->setChildrenCollapsible(false);
13661353 split2->setOrientation(Qt::Vertical);
13671354
13681355 // create config tree
1369
- configView = new ConfigView(split2, "config");
1370
- configList = configView->list;
1356
+ configList = new ConfigList(widget, "config");
13711357
1372
- helpText = new ConfigInfoView(split2, "help");
1358
+ helpText = new ConfigInfoView(widget, "help");
1359
+
1360
+ layout->addWidget(split2);
1361
+ split2->addWidget(split1);
1362
+ split1->addWidget(configList);
1363
+ split1->addWidget(menuList);
1364
+ split2->addWidget(helpText);
13731365
13741366 setTabOrder(configList, helpText);
13751367 configList->setFocus();
13761368
1377
- menu = menuBar();
1378
- toolBar = new QToolBar("Tools", this);
1379
- addToolBar(toolBar);
1380
-
13811369 backAction = new QAction(QPixmap(xpm_back), "Back", this);
1382
- connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack()));
1383
- backAction->setEnabled(false);
1370
+ connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack()));
1371
+
13841372 QAction *quitAction = new QAction("&Quit", this);
13851373 quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
1386
- connect(quitAction, SIGNAL(triggered(bool)), SLOT(close()));
1374
+ connect(quitAction, SIGNAL(triggered(bool)), SLOT(close()));
1375
+
13871376 QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this);
13881377 loadAction->setShortcut(Qt::CTRL + Qt::Key_L);
1389
- connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig()));
1378
+ connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig()));
1379
+
13901380 saveAction = new QAction(QPixmap(xpm_save), "&Save", this);
13911381 saveAction->setShortcut(Qt::CTRL + Qt::Key_S);
1392
- connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig()));
1382
+ connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig()));
1383
+
13931384 conf_set_changed_callback(conf_changed);
1385
+
13941386 // Set saveAction's initial state
13951387 conf_changed();
1388
+ configname = xstrdup(conf_get_configname());
1389
+
13961390 QAction *saveAsAction = new QAction("Save &As...", this);
13971391 connect(saveAsAction, SIGNAL(triggered(bool)), SLOT(saveConfigAs()));
13981392 QAction *searchAction = new QAction("&Find", this);
....@@ -1410,28 +1404,22 @@
14101404
14111405 QAction *showNameAction = new QAction("Show Name", this);
14121406 showNameAction->setCheckable(true);
1413
- connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool)));
1414
- showNameAction->setChecked(configView->showName());
1415
- QAction *showRangeAction = new QAction("Show Range", this);
1416
- showRangeAction->setCheckable(true);
1417
- connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool)));
1418
- QAction *showDataAction = new QAction("Show Data", this);
1419
- showDataAction->setCheckable(true);
1420
- connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
1407
+ connect(showNameAction, SIGNAL(toggled(bool)), configList, SLOT(setShowName(bool)));
1408
+ showNameAction->setChecked(configList->showName);
14211409
14221410 QActionGroup *optGroup = new QActionGroup(this);
14231411 optGroup->setExclusive(true);
1424
- connect(optGroup, SIGNAL(triggered(QAction*)), configView,
1412
+ connect(optGroup, SIGNAL(triggered(QAction*)), configList,
14251413 SLOT(setOptionMode(QAction *)));
1426
- connect(optGroup, SIGNAL(triggered(QAction *)), menuView,
1414
+ connect(optGroup, SIGNAL(triggered(QAction *)), menuList,
14271415 SLOT(setOptionMode(QAction *)));
14281416
1429
- configView->showNormalAction = new QAction("Show Normal Options", optGroup);
1430
- configView->showAllAction = new QAction("Show All Options", optGroup);
1431
- configView->showPromptAction = new QAction("Show Prompt Options", optGroup);
1432
- configView->showNormalAction->setCheckable(true);
1433
- configView->showAllAction->setCheckable(true);
1434
- configView->showPromptAction->setCheckable(true);
1417
+ ConfigList::showNormalAction = new QAction("Show Normal Options", optGroup);
1418
+ ConfigList::showNormalAction->setCheckable(true);
1419
+ ConfigList::showAllAction = new QAction("Show All Options", optGroup);
1420
+ ConfigList::showAllAction->setCheckable(true);
1421
+ ConfigList::showPromptAction = new QAction("Show Prompt Options", optGroup);
1422
+ ConfigList::showPromptAction->setCheckable(true);
14351423
14361424 QAction *showDebugAction = new QAction("Show Debug Info", this);
14371425 showDebugAction->setCheckable(true);
....@@ -1444,6 +1432,7 @@
14441432 connect(showAboutAction, SIGNAL(triggered(bool)), SLOT(showAbout()));
14451433
14461434 // init tool bar
1435
+ QToolBar *toolBar = addToolBar("Tools");
14471436 toolBar->addAction(backAction);
14481437 toolBar->addSeparator();
14491438 toolBar->addAction(loadAction);
....@@ -1453,38 +1442,40 @@
14531442 toolBar->addAction(splitViewAction);
14541443 toolBar->addAction(fullViewAction);
14551444
1456
- // create config menu
1457
- QMenu* config = menu->addMenu("&File");
1458
- config->addAction(loadAction);
1459
- config->addAction(saveAction);
1460
- config->addAction(saveAsAction);
1461
- config->addSeparator();
1462
- config->addAction(quitAction);
1445
+ // create file menu
1446
+ QMenu *menu = menuBar()->addMenu("&File");
1447
+ menu->addAction(loadAction);
1448
+ menu->addAction(saveAction);
1449
+ menu->addAction(saveAsAction);
1450
+ menu->addSeparator();
1451
+ menu->addAction(quitAction);
14631452
14641453 // create edit menu
1465
- QMenu* editMenu = menu->addMenu("&Edit");
1466
- editMenu->addAction(searchAction);
1454
+ menu = menuBar()->addMenu("&Edit");
1455
+ menu->addAction(searchAction);
14671456
14681457 // create options menu
1469
- QMenu* optionMenu = menu->addMenu("&Option");
1470
- optionMenu->addAction(showNameAction);
1471
- optionMenu->addAction(showRangeAction);
1472
- optionMenu->addAction(showDataAction);
1473
- optionMenu->addSeparator();
1474
- optionMenu->addActions(optGroup->actions());
1475
- optionMenu->addSeparator();
1476
- optionMenu->addAction(showDebugAction);
1458
+ menu = menuBar()->addMenu("&Option");
1459
+ menu->addAction(showNameAction);
1460
+ menu->addSeparator();
1461
+ menu->addActions(optGroup->actions());
1462
+ menu->addSeparator();
1463
+ menu->addAction(showDebugAction);
14771464
14781465 // create help menu
1479
- menu->addSeparator();
1480
- QMenu* helpMenu = menu->addMenu("&Help");
1481
- helpMenu->addAction(showIntroAction);
1482
- helpMenu->addAction(showAboutAction);
1466
+ menu = menuBar()->addMenu("&Help");
1467
+ menu->addAction(showIntroAction);
1468
+ menu->addAction(showAboutAction);
1469
+
1470
+ connect (helpText, SIGNAL (anchorClicked (const QUrl &)),
1471
+ helpText, SLOT (clicked (const QUrl &)) );
14831472
14841473 connect(configList, SIGNAL(menuChanged(struct menu *)),
14851474 helpText, SLOT(setInfo(struct menu *)));
14861475 connect(configList, SIGNAL(menuSelected(struct menu *)),
14871476 SLOT(changeMenu(struct menu *)));
1477
+ connect(configList, SIGNAL(itemSelected(struct menu *)),
1478
+ SLOT(changeItens(struct menu *)));
14881479 connect(configList, SIGNAL(parentSelected()),
14891480 SLOT(goBack()));
14901481 connect(menuList, SIGNAL(menuChanged(struct menu *)),
....@@ -1521,17 +1512,29 @@
15211512
15221513 void ConfigMainWindow::loadConfig(void)
15231514 {
1524
- QString s = QFileDialog::getOpenFileName(this, "", conf_get_configname());
1525
- if (s.isNull())
1515
+ QString str;
1516
+ QByteArray ba;
1517
+ const char *name;
1518
+
1519
+ str = QFileDialog::getOpenFileName(this, "", configname);
1520
+ if (str.isNull())
15261521 return;
1527
- if (conf_read(QFile::encodeName(s)))
1522
+
1523
+ ba = str.toLocal8Bit();
1524
+ name = ba.data();
1525
+
1526
+ if (conf_read(name))
15281527 QMessageBox::information(this, "qconf", "Unable to load configuration!");
1529
- ConfigView::updateListAll();
1528
+
1529
+ free(configname);
1530
+ configname = xstrdup(name);
1531
+
1532
+ ConfigList::updateListAllForAll();
15301533 }
15311534
15321535 bool ConfigMainWindow::saveConfig(void)
15331536 {
1534
- if (conf_write(NULL)) {
1537
+ if (conf_write(configname)) {
15351538 QMessageBox::information(this, "qconf", "Unable to save configuration!");
15361539 return false;
15371540 }
....@@ -1542,26 +1545,41 @@
15421545
15431546 void ConfigMainWindow::saveConfigAs(void)
15441547 {
1545
- QString s = QFileDialog::getSaveFileName(this, "", conf_get_configname());
1546
- if (s.isNull())
1548
+ QString str;
1549
+ QByteArray ba;
1550
+ const char *name;
1551
+
1552
+ str = QFileDialog::getSaveFileName(this, "", configname);
1553
+ if (str.isNull())
15471554 return;
1548
- saveConfig();
1555
+
1556
+ ba = str.toLocal8Bit();
1557
+ name = ba.data();
1558
+
1559
+ if (conf_write(name)) {
1560
+ QMessageBox::information(this, "qconf", "Unable to save configuration!");
1561
+ }
1562
+ conf_write_autoconf(0);
1563
+
1564
+ free(configname);
1565
+ configname = xstrdup(name);
15491566 }
15501567
15511568 void ConfigMainWindow::searchConfig(void)
15521569 {
15531570 if (!searchWindow)
1554
- searchWindow = new ConfigSearchWindow(this, "search");
1571
+ searchWindow = new ConfigSearchWindow(this);
15551572 searchWindow->show();
1573
+}
1574
+
1575
+void ConfigMainWindow::changeItens(struct menu *menu)
1576
+{
1577
+ configList->setRootMenu(menu);
15561578 }
15571579
15581580 void ConfigMainWindow::changeMenu(struct menu *menu)
15591581 {
1560
- configList->setRootMenu(menu);
1561
- if (configList->rootEntry->parent == &rootmenu)
1562
- backAction->setEnabled(false);
1563
- else
1564
- backAction->setEnabled(true);
1582
+ menuList->setRootMenu(menu);
15651583 }
15661584
15671585 void ConfigMainWindow::setMenuLink(struct menu *menu)
....@@ -1581,22 +1599,26 @@
15811599 return;
15821600 list->setRootMenu(parent);
15831601 break;
1584
- case symbolMode:
1602
+ case menuMode:
15851603 if (menu->flags & MENU_ROOT) {
1586
- configList->setRootMenu(menu);
1604
+ menuList->setRootMenu(menu);
15871605 configList->clearSelection();
1588
- list = menuList;
1589
- } else {
15901606 list = configList;
1607
+ } else {
15911608 parent = menu_get_parent_menu(menu->parent);
15921609 if (!parent)
15931610 return;
1594
- item = menuList->findConfigItem(parent);
1611
+
1612
+ /* Select the config view */
1613
+ item = configList->findConfigItem(parent);
15951614 if (item) {
1596
- item->setSelected(true);
1597
- menuList->scrollToItem(item);
1615
+ configList->setSelected(item, true);
1616
+ configList->scrollToItem(item);
15981617 }
1599
- list->setRootMenu(parent);
1618
+
1619
+ menuList->setRootMenu(parent);
1620
+ menuList->clearSelection();
1621
+ list = menuList;
16001622 }
16011623 break;
16021624 case fullMode:
....@@ -1609,9 +1631,10 @@
16091631 if (list) {
16101632 item = list->findConfigItem(menu);
16111633 if (item) {
1612
- item->setSelected(true);
1634
+ list->setSelected(item, true);
16131635 list->scrollToItem(item);
16141636 list->setFocus();
1637
+ helpText->setInfo(menu);
16151638 }
16161639 }
16171640 }
....@@ -1624,25 +1647,10 @@
16241647
16251648 void ConfigMainWindow::goBack(void)
16261649 {
1627
- ConfigItem* item, *oldSelection;
1628
-
1629
- configList->setParentMenu();
16301650 if (configList->rootEntry == &rootmenu)
1631
- backAction->setEnabled(false);
1632
-
1633
- if (menuList->selectedItems().count() == 0)
16341651 return;
16351652
1636
- item = (ConfigItem*)menuList->selectedItems().first();
1637
- oldSelection = item;
1638
- while (item) {
1639
- if (item->menu == configList->rootEntry) {
1640
- oldSelection->setSelected(false);
1641
- item->setSelected(true);
1642
- break;
1643
- }
1644
- item = (ConfigItem*)item->parent();
1645
- }
1653
+ configList->setParentMenu();
16461654 }
16471655
16481656 void ConfigMainWindow::showSingleView(void)
....@@ -1654,7 +1662,9 @@
16541662 fullViewAction->setEnabled(true);
16551663 fullViewAction->setChecked(false);
16561664
1657
- menuView->hide();
1665
+ backAction->setEnabled(true);
1666
+
1667
+ menuList->hide();
16581668 menuList->setRootMenu(0);
16591669 configList->mode = singleMode;
16601670 if (configList->rootEntry == &rootmenu)
....@@ -1673,17 +1683,19 @@
16731683 fullViewAction->setEnabled(true);
16741684 fullViewAction->setChecked(false);
16751685
1676
- configList->mode = symbolMode;
1686
+ backAction->setEnabled(false);
1687
+
1688
+ configList->mode = menuMode;
16771689 if (configList->rootEntry == &rootmenu)
16781690 configList->updateListAll();
16791691 else
16801692 configList->setRootMenu(&rootmenu);
16811693 configList->setAllOpen(true);
16821694 configApp->processEvents();
1683
- menuList->mode = menuMode;
1695
+ menuList->mode = symbolMode;
16841696 menuList->setRootMenu(&rootmenu);
16851697 menuList->setAllOpen(true);
1686
- menuView->show();
1698
+ menuList->show();
16871699 menuList->setFocus();
16881700 }
16891701
....@@ -1696,7 +1708,9 @@
16961708 fullViewAction->setEnabled(false);
16971709 fullViewAction->setChecked(true);
16981710
1699
- menuView->hide();
1711
+ backAction->setEnabled(false);
1712
+
1713
+ menuList->hide();
17001714 menuList->setRootMenu(0);
17011715 configList->mode = fullMode;
17021716 if (configList->rootEntry == &rootmenu)
....@@ -1708,7 +1722,6 @@
17081722
17091723 /*
17101724 * ask for saving configuration before quitting
1711
- * TODO ask only when something changed
17121725 */
17131726 void ConfigMainWindow::closeEvent(QCloseEvent* e)
17141727 {
....@@ -1739,17 +1752,26 @@
17391752
17401753 void ConfigMainWindow::showIntro(void)
17411754 {
1742
- static const QString str = "Welcome to the qconf graphical configuration tool.\n\n"
1743
- "For each option, a blank box indicates the feature is disabled, a check\n"
1744
- "indicates it is enabled, and a dot indicates that it is to be compiled\n"
1745
- "as a module. Clicking on the box will cycle through the three states.\n\n"
1746
- "If you do not see an option (e.g., a device driver) that you believe\n"
1747
- "should be present, try turning on Show All Options under the Options menu.\n"
1748
- "Although there is no cross reference yet to help you figure out what other\n"
1749
- "options must be enabled to support the option you are interested in, you can\n"
1750
- "still view the help of a grayed-out option.\n\n"
1751
- "Toggling Show Debug Info under the Options menu will show the dependencies,\n"
1752
- "which you can then match by examining other options.\n\n";
1755
+ static const QString str =
1756
+ "Welcome to the qconf graphical configuration tool.\n"
1757
+ "\n"
1758
+ "For bool and tristate options, a blank box indicates the "
1759
+ "feature is disabled, a check indicates it is enabled, and a "
1760
+ "dot indicates that it is to be compiled as a module. Clicking "
1761
+ "on the box will cycle through the three states. For int, hex, "
1762
+ "and string options, double-clicking or pressing F2 on the "
1763
+ "Value cell will allow you to edit the value.\n"
1764
+ "\n"
1765
+ "If you do not see an option (e.g., a device driver) that you "
1766
+ "believe should be present, try turning on Show All Options "
1767
+ "under the Options menu. Enabling Show Debug Info will help you"
1768
+ "figure out what other options must be enabled to support the "
1769
+ "option you are interested in, and hyperlinks will navigate to "
1770
+ "them.\n"
1771
+ "\n"
1772
+ "Toggling Show Debug Info under the Options menu will show the "
1773
+ "dependencies, which you can then match by examining other "
1774
+ "options.\n";
17531775
17541776 QMessageBox::information(this, "qconf", str);
17551777 }
....@@ -1829,7 +1851,6 @@
18291851 const char *name;
18301852
18311853 progname = av[0];
1832
- configApp = new QApplication(ac, av);
18331854 if (ac > 1 && av[1][0] == '-') {
18341855 switch (av[1][1]) {
18351856 case 's':
....@@ -1850,6 +1871,8 @@
18501871 conf_read(NULL);
18511872 //zconfdump(stdout);
18521873
1874
+ configApp = new QApplication(ac, av);
1875
+
18531876 configSettings = new ConfigSettings();
18541877 configSettings->beginGroup("/kconfig/qconf");
18551878 v = new ConfigMainWindow();