.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
---|
3 | 4 | * Copyright (C) 2015 Boris Barbulovski <bbarbulovski@gmail.com> |
---|
4 | | - * Released under the terms of the GNU GPL v2.0. |
---|
5 | 5 | */ |
---|
6 | 6 | |
---|
7 | | -#include <qglobal.h> |
---|
8 | | - |
---|
9 | | -#include <QMainWindow> |
---|
10 | | -#include <QList> |
---|
11 | | -#include <qtextbrowser.h> |
---|
12 | 7 | #include <QAction> |
---|
| 8 | +#include <QApplication> |
---|
| 9 | +#include <QCloseEvent> |
---|
| 10 | +#include <QDebug> |
---|
| 11 | +#include <QDesktopWidget> |
---|
13 | 12 | #include <QFileDialog> |
---|
| 13 | +#include <QLabel> |
---|
| 14 | +#include <QLayout> |
---|
| 15 | +#include <QList> |
---|
14 | 16 | #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> |
---|
28 | 20 | |
---|
29 | 21 | #include <stdlib.h> |
---|
30 | 22 | |
---|
31 | 23 | #include "lkc.h" |
---|
32 | 24 | #include "qconf.h" |
---|
33 | 25 | |
---|
34 | | -#include "qconf.moc" |
---|
35 | | -#include "images.c" |
---|
| 26 | +#include "images.h" |
---|
36 | 27 | |
---|
37 | 28 | |
---|
38 | 29 | static QApplication *configApp; |
---|
39 | 30 | static ConfigSettings *configSettings; |
---|
40 | 31 | |
---|
41 | 32 | QAction *ConfigMainWindow::saveAction; |
---|
42 | | - |
---|
43 | | -static inline QString qgettext(const char* str) |
---|
44 | | -{ |
---|
45 | | - return QString::fromLocal8Bit(str); |
---|
46 | | -} |
---|
47 | 33 | |
---|
48 | 34 | ConfigSettings::ConfigSettings() |
---|
49 | 35 | : QSettings("kernel.org", "qconf") |
---|
.. | .. |
---|
88 | 74 | return true; |
---|
89 | 75 | } |
---|
90 | 76 | |
---|
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; |
---|
99 | 84 | |
---|
100 | 85 | /* |
---|
101 | 86 | * update the displayed of a menu entry |
---|
.. | .. |
---|
111 | 96 | |
---|
112 | 97 | list = listView(); |
---|
113 | 98 | if (goParent) { |
---|
114 | | - setPixmap(promptColIdx, list->menuBackPix); |
---|
| 99 | + setIcon(promptColIdx, menubackIcon); |
---|
115 | 100 | prompt = ".."; |
---|
116 | 101 | goto set_prompt; |
---|
117 | 102 | } |
---|
118 | 103 | |
---|
119 | 104 | sym = menu->sym; |
---|
120 | 105 | prop = menu->prompt; |
---|
121 | | - prompt = qgettext(menu_get_prompt(menu)); |
---|
| 106 | + prompt = menu_get_prompt(menu); |
---|
122 | 107 | |
---|
123 | 108 | if (prop) switch (prop->type) { |
---|
124 | 109 | case P_MENU: |
---|
.. | .. |
---|
128 | 113 | */ |
---|
129 | 114 | if (sym && list->rootEntry == menu) |
---|
130 | 115 | break; |
---|
131 | | - setPixmap(promptColIdx, list->menuPix); |
---|
| 116 | + setIcon(promptColIdx, menuIcon); |
---|
132 | 117 | } else { |
---|
133 | 118 | if (sym) |
---|
134 | 119 | break; |
---|
135 | | - setPixmap(promptColIdx, QIcon()); |
---|
| 120 | + setIcon(promptColIdx, QIcon()); |
---|
136 | 121 | } |
---|
137 | 122 | goto set_prompt; |
---|
138 | 123 | case P_COMMENT: |
---|
139 | | - setPixmap(promptColIdx, QIcon()); |
---|
| 124 | + setIcon(promptColIdx, QIcon()); |
---|
140 | 125 | goto set_prompt; |
---|
141 | 126 | default: |
---|
142 | 127 | ; |
---|
.. | .. |
---|
144 | 129 | if (!sym) |
---|
145 | 130 | goto set_prompt; |
---|
146 | 131 | |
---|
147 | | - setText(nameColIdx, QString::fromLocal8Bit(sym->name)); |
---|
| 132 | + setText(nameColIdx, sym->name); |
---|
148 | 133 | |
---|
149 | 134 | type = sym_get_type(sym); |
---|
150 | 135 | switch (type) { |
---|
.. | .. |
---|
152 | 137 | case S_TRISTATE: |
---|
153 | 138 | char ch; |
---|
154 | 139 | |
---|
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()); |
---|
160 | 142 | break; |
---|
161 | 143 | } |
---|
162 | 144 | expr = sym_get_tristate_value(sym); |
---|
163 | 145 | switch (expr) { |
---|
164 | 146 | case yes: |
---|
165 | 147 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) |
---|
166 | | - setPixmap(promptColIdx, list->choiceYesPix); |
---|
| 148 | + setIcon(promptColIdx, choiceYesIcon); |
---|
167 | 149 | else |
---|
168 | | - setPixmap(promptColIdx, list->symbolYesPix); |
---|
169 | | - setText(yesColIdx, "Y"); |
---|
| 150 | + setIcon(promptColIdx, symbolYesIcon); |
---|
170 | 151 | ch = 'Y'; |
---|
171 | 152 | break; |
---|
172 | 153 | case mod: |
---|
173 | | - setPixmap(promptColIdx, list->symbolModPix); |
---|
174 | | - setText(modColIdx, "M"); |
---|
| 154 | + setIcon(promptColIdx, symbolModIcon); |
---|
175 | 155 | ch = 'M'; |
---|
176 | 156 | break; |
---|
177 | 157 | default: |
---|
178 | 158 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) |
---|
179 | | - setPixmap(promptColIdx, list->choiceNoPix); |
---|
| 159 | + setIcon(promptColIdx, choiceNoIcon); |
---|
180 | 160 | else |
---|
181 | | - setPixmap(promptColIdx, list->symbolNoPix); |
---|
182 | | - setText(noColIdx, "N"); |
---|
| 161 | + setIcon(promptColIdx, symbolNoIcon); |
---|
183 | 162 | ch = 'N'; |
---|
184 | 163 | break; |
---|
185 | 164 | } |
---|
186 | | - if (expr != no) |
---|
187 | | - setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); |
---|
188 | | - if (expr != mod) |
---|
189 | | - setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); |
---|
190 | | - if (expr != yes) |
---|
191 | | - setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); |
---|
192 | 165 | |
---|
193 | 166 | setText(dataColIdx, QChar(ch)); |
---|
194 | 167 | break; |
---|
195 | 168 | case S_INT: |
---|
196 | 169 | case S_HEX: |
---|
197 | 170 | 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)); |
---|
207 | 172 | break; |
---|
208 | 173 | } |
---|
209 | 174 | if (!sym_has_value(sym) && visible) |
---|
.. | .. |
---|
244 | 209 | if (list->mode != fullMode) |
---|
245 | 210 | setExpanded(true); |
---|
246 | 211 | 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 | + } |
---|
247 | 223 | } |
---|
248 | 224 | updateMenu(); |
---|
249 | 225 | } |
---|
.. | .. |
---|
264 | 240 | } |
---|
265 | 241 | } |
---|
266 | 242 | |
---|
267 | | -ConfigLineEdit::ConfigLineEdit(ConfigView* parent) |
---|
268 | | - : Parent(parent) |
---|
| 243 | +QWidget *ConfigItemDelegate::createEditor(QWidget *parent, |
---|
| 244 | + const QStyleOptionViewItem &option, |
---|
| 245 | + const QModelIndex &index) const |
---|
269 | 246 | { |
---|
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); |
---|
271 | 259 | } |
---|
272 | 260 | |
---|
273 | | -void ConfigLineEdit::show(ConfigItem* i) |
---|
| 261 | +void ConfigItemDelegate::setModelData(QWidget *editor, |
---|
| 262 | + QAbstractItemModel *model, |
---|
| 263 | + const QModelIndex &index) const |
---|
274 | 264 | { |
---|
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; |
---|
283 | 269 | |
---|
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)); |
---|
297 | 292 | } |
---|
298 | | - e->accept(); |
---|
299 | | - parent()->list->setFocus(); |
---|
300 | | - hide(); |
---|
| 293 | + |
---|
| 294 | +parent: |
---|
| 295 | + QStyledItemDelegate::setModelData(editor, model, index); |
---|
301 | 296 | } |
---|
302 | 297 | |
---|
303 | | -ConfigList::ConfigList(ConfigView* p, const char *name) |
---|
304 | | - : Parent(p), |
---|
| 298 | +ConfigList::ConfigList(QWidget *parent, const char *name) |
---|
| 299 | + : QTreeWidget(parent), |
---|
305 | 300 | 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), |
---|
310 | 302 | rootEntry(0), headerPopup(0) |
---|
311 | 303 | { |
---|
312 | | - int i; |
---|
313 | | - |
---|
314 | 304 | setObjectName(name); |
---|
315 | 305 | setSortingEnabled(false); |
---|
316 | 306 | setRootIsDecorated(true); |
---|
.. | .. |
---|
318 | 308 | setVerticalScrollMode(ScrollPerPixel); |
---|
319 | 309 | setHorizontalScrollMode(ScrollPerPixel); |
---|
320 | 310 | |
---|
321 | | - setHeaderLabels(QStringList() << "Option" << "Name" << "N" << "M" << "Y" << "Value"); |
---|
| 311 | + setHeaderLabels(QStringList() << "Option" << "Name" << "Value"); |
---|
322 | 312 | |
---|
323 | 313 | connect(this, SIGNAL(itemSelectionChanged(void)), |
---|
324 | 314 | SLOT(updateSelection(void))); |
---|
.. | .. |
---|
326 | 316 | if (name) { |
---|
327 | 317 | configSettings->beginGroup(name); |
---|
328 | 318 | showName = configSettings->value("/showName", false).toBool(); |
---|
329 | | - showRange = configSettings->value("/showRange", false).toBool(); |
---|
330 | | - showData = configSettings->value("/showData", false).toBool(); |
---|
331 | 319 | optMode = (enum optionMode)configSettings->value("/optionMode", 0).toInt(); |
---|
332 | 320 | configSettings->endGroup(); |
---|
333 | 321 | connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); |
---|
334 | 322 | } |
---|
335 | 323 | |
---|
336 | | - addColumn(promptColIdx); |
---|
| 324 | + showColumn(promptColIdx); |
---|
| 325 | + |
---|
| 326 | + setItemDelegate(new ConfigItemDelegate(this)); |
---|
| 327 | + |
---|
| 328 | + allLists.append(this); |
---|
337 | 329 | |
---|
338 | 330 | reinit(); |
---|
| 331 | +} |
---|
| 332 | + |
---|
| 333 | +ConfigList::~ConfigList() |
---|
| 334 | +{ |
---|
| 335 | + allLists.removeOne(this); |
---|
339 | 336 | } |
---|
340 | 337 | |
---|
341 | 338 | bool ConfigList::menuSkip(struct menu *menu) |
---|
.. | .. |
---|
351 | 348 | |
---|
352 | 349 | void ConfigList::reinit(void) |
---|
353 | 350 | { |
---|
354 | | - removeColumn(dataColIdx); |
---|
355 | | - removeColumn(yesColIdx); |
---|
356 | | - removeColumn(modColIdx); |
---|
357 | | - removeColumn(noColIdx); |
---|
358 | | - removeColumn(nameColIdx); |
---|
| 351 | + hideColumn(nameColIdx); |
---|
359 | 352 | |
---|
360 | 353 | 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; |
---|
369 | 367 | |
---|
370 | 368 | updateListAll(); |
---|
371 | 369 | } |
---|
.. | .. |
---|
375 | 373 | if (!objectName().isEmpty()) { |
---|
376 | 374 | configSettings->beginGroup(objectName()); |
---|
377 | 375 | configSettings->setValue("/showName", showName); |
---|
378 | | - configSettings->setValue("/showRange", showRange); |
---|
379 | | - configSettings->setValue("/showData", showData); |
---|
380 | 376 | configSettings->setValue("/optionMode", (int)optMode); |
---|
381 | 377 | configSettings->endGroup(); |
---|
382 | 378 | } |
---|
.. | .. |
---|
415 | 411 | emit menuSelected(menu); |
---|
416 | 412 | } |
---|
417 | 413 | |
---|
418 | | -void ConfigList::updateList(ConfigItem* item) |
---|
| 414 | +void ConfigList::updateList() |
---|
419 | 415 | { |
---|
420 | 416 | ConfigItem* last = 0; |
---|
| 417 | + ConfigItem *item; |
---|
421 | 418 | |
---|
422 | 419 | if (!rootEntry) { |
---|
423 | 420 | if (mode != listMode) |
---|
424 | 421 | goto update; |
---|
425 | 422 | QTreeWidgetItemIterator it(this); |
---|
426 | | - ConfigItem* item; |
---|
427 | 423 | |
---|
428 | 424 | while (*it) { |
---|
429 | 425 | item = (ConfigItem*)(*it); |
---|
.. | .. |
---|
445 | 441 | } |
---|
446 | 442 | if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) && |
---|
447 | 443 | rootEntry->sym && rootEntry->prompt) { |
---|
448 | | - item = last ? last->nextSibling() : firstChild(); |
---|
| 444 | + item = last ? last->nextSibling() : nullptr; |
---|
449 | 445 | if (!item) |
---|
450 | 446 | item = new ConfigItem(this, last, rootEntry, true); |
---|
451 | 447 | else |
---|
.. | .. |
---|
457 | 453 | return; |
---|
458 | 454 | } |
---|
459 | 455 | update: |
---|
460 | | - updateMenuList(this, rootEntry); |
---|
| 456 | + updateMenuList(rootEntry); |
---|
461 | 457 | update(); |
---|
462 | 458 | 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 | + } |
---|
463 | 481 | } |
---|
464 | 482 | |
---|
465 | 483 | void ConfigList::setValue(ConfigItem* item, tristate val) |
---|
.. | .. |
---|
482 | 500 | return; |
---|
483 | 501 | if (oldval == no && item->menu->list) |
---|
484 | 502 | item->setExpanded(true); |
---|
485 | | - parent()->updateList(item); |
---|
| 503 | + ConfigList::updateListForAll(); |
---|
486 | 504 | break; |
---|
487 | 505 | } |
---|
488 | 506 | } |
---|
.. | .. |
---|
516 | 534 | item->setExpanded(true); |
---|
517 | 535 | } |
---|
518 | 536 | if (oldexpr != newexpr) |
---|
519 | | - parent()->updateList(item); |
---|
| 537 | + ConfigList::updateListForAll(); |
---|
520 | 538 | break; |
---|
521 | | - case S_INT: |
---|
522 | | - case S_HEX: |
---|
523 | | - case S_STRING: |
---|
524 | | - parent()->lineEdit->show(item); |
---|
| 539 | + default: |
---|
525 | 540 | break; |
---|
526 | 541 | } |
---|
527 | 542 | } |
---|
.. | .. |
---|
535 | 550 | type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; |
---|
536 | 551 | if (type != P_MENU) |
---|
537 | 552 | return; |
---|
538 | | - updateMenuList(this, 0); |
---|
| 553 | + updateMenuList(0); |
---|
539 | 554 | rootEntry = menu; |
---|
540 | 555 | updateListAll(); |
---|
541 | 556 | if (currentItem()) { |
---|
542 | | - currentItem()->setSelected(hasFocus()); |
---|
| 557 | + setSelected(currentItem(), hasFocus()); |
---|
543 | 558 | scrollToItem(currentItem()); |
---|
544 | 559 | } |
---|
545 | 560 | } |
---|
.. | .. |
---|
639 | 654 | } |
---|
640 | 655 | } |
---|
641 | 656 | |
---|
642 | | -void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) |
---|
| 657 | +void ConfigList::updateMenuList(struct menu *menu) |
---|
643 | 658 | { |
---|
644 | 659 | struct menu* child; |
---|
645 | 660 | ConfigItem* item; |
---|
.. | .. |
---|
648 | 663 | enum prop_type type; |
---|
649 | 664 | |
---|
650 | 665 | if (!menu) { |
---|
651 | | - while (parent->topLevelItemCount() > 0) |
---|
| 666 | + while (topLevelItemCount() > 0) |
---|
652 | 667 | { |
---|
653 | | - delete parent->takeTopLevelItem(0); |
---|
| 668 | + delete takeTopLevelItem(0); |
---|
654 | 669 | } |
---|
655 | 670 | |
---|
656 | 671 | return; |
---|
657 | 672 | } |
---|
658 | 673 | |
---|
659 | | - last = (ConfigItem*)parent->topLevelItem(0); |
---|
| 674 | + last = (ConfigItem *)topLevelItem(0); |
---|
660 | 675 | if (last && !last->goParent) |
---|
661 | 676 | last = 0; |
---|
662 | 677 | 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); |
---|
664 | 679 | type = child->prompt ? child->prompt->type : P_UNKNOWN; |
---|
665 | 680 | |
---|
666 | 681 | switch (mode) { |
---|
.. | .. |
---|
681 | 696 | if (!child->sym && !child->list && !child->prompt) |
---|
682 | 697 | continue; |
---|
683 | 698 | if (!item || item->menu != child) |
---|
684 | | - item = new ConfigItem(parent, last, child, visible); |
---|
| 699 | + item = new ConfigItem(this, last, child, visible); |
---|
685 | 700 | else |
---|
686 | 701 | item->testUpdateMenu(visible); |
---|
687 | 702 | |
---|
.. | .. |
---|
694 | 709 | } |
---|
695 | 710 | hide: |
---|
696 | 711 | if (item && item->menu == child) { |
---|
697 | | - last = (ConfigItem*)parent->topLevelItem(0); |
---|
| 712 | + last = (ConfigItem *)topLevelItem(0); |
---|
698 | 713 | if (last == item) |
---|
699 | 714 | last = 0; |
---|
700 | 715 | else while (last->nextSibling() != item) |
---|
.. | .. |
---|
736 | 751 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
---|
737 | 752 | if (type == P_MENU && rootEntry != menu && |
---|
738 | 753 | mode != fullMode && mode != menuMode) { |
---|
739 | | - emit menuSelected(menu); |
---|
| 754 | + if (mode == menuMode) |
---|
| 755 | + emit menuSelected(menu); |
---|
| 756 | + else |
---|
| 757 | + emit itemSelected(menu); |
---|
740 | 758 | break; |
---|
741 | 759 | } |
---|
742 | 760 | case Qt::Key_Space: |
---|
.. | .. |
---|
782 | 800 | idx = header()->logicalIndexAt(x); |
---|
783 | 801 | switch (idx) { |
---|
784 | 802 | case promptColIdx: |
---|
785 | | - icon = item->pixmap(promptColIdx); |
---|
| 803 | + icon = item->icon(promptColIdx); |
---|
786 | 804 | if (!icon.isNull()) { |
---|
787 | 805 | int off = header()->sectionPosition(0) + visualRect(indexAt(p)).x() + 4; // 4 is Hardcoded image offset. There might be a way to do it properly. |
---|
788 | 806 | if (x >= off && x < off + icon.availableSizes().first().width()) { |
---|
.. | .. |
---|
793 | 811 | break; |
---|
794 | 812 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
---|
795 | 813 | if (ptype == P_MENU && rootEntry != menu && |
---|
796 | | - mode != fullMode && mode != menuMode) |
---|
| 814 | + mode != fullMode && mode != menuMode && |
---|
| 815 | + mode != listMode) |
---|
797 | 816 | emit menuSelected(menu); |
---|
798 | 817 | else |
---|
799 | 818 | changeValue(item); |
---|
800 | 819 | } |
---|
801 | 820 | } |
---|
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); |
---|
811 | 821 | break; |
---|
812 | 822 | case dataColIdx: |
---|
813 | 823 | changeValue(item); |
---|
.. | .. |
---|
828 | 838 | |
---|
829 | 839 | void ConfigList::mouseDoubleClickEvent(QMouseEvent* e) |
---|
830 | 840 | { |
---|
831 | | - QPoint p = e->pos(); // TODO: Check if this works(was contentsToViewport). |
---|
| 841 | + QPoint p = e->pos(); |
---|
832 | 842 | ConfigItem* item = (ConfigItem*)itemAt(p); |
---|
833 | 843 | struct menu *menu; |
---|
834 | 844 | enum prop_type ptype; |
---|
.. | .. |
---|
843 | 853 | if (!menu) |
---|
844 | 854 | goto skip; |
---|
845 | 855 | 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) |
---|
849 | 862 | changeValue(item); |
---|
850 | 863 | |
---|
851 | 864 | skip: |
---|
.. | .. |
---|
861 | 874 | |
---|
862 | 875 | ConfigItem* item = (ConfigItem *)currentItem(); |
---|
863 | 876 | if (item) { |
---|
864 | | - item->setSelected(true); |
---|
| 877 | + setSelected(item, true); |
---|
865 | 878 | menu = item->menu; |
---|
866 | 879 | } |
---|
867 | 880 | emit gotFocus(menu); |
---|
.. | .. |
---|
876 | 889 | action = new QAction("Show Name", this); |
---|
877 | 890 | action->setCheckable(true); |
---|
878 | 891 | 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)), |
---|
881 | 894 | action, SLOT(setChecked(bool))); |
---|
882 | 895 | 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); |
---|
901 | 896 | headerPopup->addAction(action); |
---|
902 | 897 | } |
---|
903 | 898 | |
---|
.. | .. |
---|
905 | 900 | e->accept(); |
---|
906 | 901 | } |
---|
907 | 902 | |
---|
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) |
---|
915 | 904 | { |
---|
916 | | - setObjectName(name); |
---|
917 | | - QVBoxLayout *verticalLayout = new QVBoxLayout(this); |
---|
918 | | - verticalLayout->setContentsMargins(0, 0, 0, 0); |
---|
| 905 | + if (showName == on) |
---|
| 906 | + return; |
---|
919 | 907 | |
---|
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); |
---|
928 | 911 | } |
---|
929 | 912 | |
---|
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; |
---|
980 | 917 | |
---|
981 | 918 | void ConfigList::setAllOpen(bool open) |
---|
982 | 919 | { |
---|
.. | .. |
---|
989 | 926 | } |
---|
990 | 927 | } |
---|
991 | 928 | |
---|
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 | | - |
---|
1008 | 929 | ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) |
---|
1009 | 930 | : Parent(parent), sym(0), _menu(0) |
---|
1010 | 931 | { |
---|
1011 | 932 | setObjectName(name); |
---|
1012 | | - |
---|
| 933 | + setOpenLinks(false); |
---|
1013 | 934 | |
---|
1014 | 935 | if (!objectName().isEmpty()) { |
---|
1015 | 936 | configSettings->beginGroup(objectName()); |
---|
.. | .. |
---|
1017 | 938 | configSettings->endGroup(); |
---|
1018 | 939 | connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); |
---|
1019 | 940 | } |
---|
| 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); |
---|
1020 | 951 | } |
---|
1021 | 952 | |
---|
1022 | 953 | void ConfigInfoView::saveSettings(void) |
---|
.. | .. |
---|
1071 | 1002 | void ConfigInfoView::menuInfo(void) |
---|
1072 | 1003 | { |
---|
1073 | 1004 | struct symbol* sym; |
---|
1074 | | - QString head, debug, help; |
---|
| 1005 | + QString info; |
---|
| 1006 | + QTextStream stream(&info); |
---|
1075 | 1007 | |
---|
1076 | 1008 | sym = _menu->sym; |
---|
1077 | 1009 | if (sym) { |
---|
1078 | 1010 | 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>"; |
---|
1082 | 1014 | if (sym->name) { |
---|
1083 | | - head += " ("; |
---|
| 1015 | + stream << " ("; |
---|
1084 | 1016 | 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); |
---|
1087 | 1019 | if (showDebug()) |
---|
1088 | | - head += "</a>"; |
---|
1089 | | - head += ")"; |
---|
| 1020 | + stream << "</a>"; |
---|
| 1021 | + stream << ")"; |
---|
1090 | 1022 | } |
---|
1091 | 1023 | } else if (sym->name) { |
---|
1092 | | - head += "<big><b>"; |
---|
| 1024 | + stream << "<big><b>"; |
---|
1093 | 1025 | 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); |
---|
1096 | 1028 | if (showDebug()) |
---|
1097 | | - head += "</a>"; |
---|
1098 | | - head += "</b></big>"; |
---|
| 1029 | + stream << "</a>"; |
---|
| 1030 | + stream << "</b></big>"; |
---|
1099 | 1031 | } |
---|
1100 | | - head += "<br><br>"; |
---|
| 1032 | + stream << "<br><br>"; |
---|
1101 | 1033 | |
---|
1102 | 1034 | if (showDebug()) |
---|
1103 | | - debug = debug_info(sym); |
---|
| 1035 | + stream << debug_info(sym); |
---|
1104 | 1036 | |
---|
1105 | 1037 | struct gstr help_gstr = str_new(); |
---|
| 1038 | + |
---|
1106 | 1039 | menu_get_ext_help(_menu, &help_gstr); |
---|
1107 | | - help = print_filter(str_get(&help_gstr)); |
---|
| 1040 | + stream << print_filter(str_get(&help_gstr)); |
---|
1108 | 1041 | str_free(&help_gstr); |
---|
1109 | 1042 | } 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>"; |
---|
1113 | 1046 | if (showDebug()) { |
---|
1114 | 1047 | if (_menu->prompt->visible.expr) { |
---|
1115 | | - debug += " dep: "; |
---|
1116 | | - expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); |
---|
1117 | | - debug += "<br><br>"; |
---|
| 1048 | + stream << " dep: "; |
---|
| 1049 | + expr_print(_menu->prompt->visible.expr, |
---|
| 1050 | + expr_print_help, &stream, E_NONE); |
---|
| 1051 | + stream << "<br><br>"; |
---|
1118 | 1052 | } |
---|
| 1053 | + |
---|
| 1054 | + stream << "defined at " << _menu->file->name << ":" |
---|
| 1055 | + << _menu->lineno << "<br><br>"; |
---|
1119 | 1056 | } |
---|
1120 | 1057 | } |
---|
1121 | | - if (showDebug()) |
---|
1122 | | - debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno); |
---|
1123 | 1058 | |
---|
1124 | | - setText(head + debug + help); |
---|
| 1059 | + setText(info); |
---|
1125 | 1060 | } |
---|
1126 | 1061 | |
---|
1127 | 1062 | QString ConfigInfoView::debug_info(struct symbol *sym) |
---|
1128 | 1063 | { |
---|
1129 | 1064 | QString debug; |
---|
| 1065 | + QTextStream stream(&debug); |
---|
1130 | 1066 | |
---|
1131 | | - debug += "type: "; |
---|
1132 | | - debug += print_filter(sym_type_name(sym->type)); |
---|
| 1067 | + stream << "type: "; |
---|
| 1068 | + stream << print_filter(sym_type_name(sym->type)); |
---|
1133 | 1069 | if (sym_is_choice(sym)) |
---|
1134 | | - debug += " (choice)"; |
---|
| 1070 | + stream << " (choice)"; |
---|
1135 | 1071 | debug += "<br>"; |
---|
1136 | 1072 | 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>"; |
---|
1140 | 1076 | } |
---|
1141 | 1077 | for (struct property *prop = sym->prop; prop; prop = prop->next) { |
---|
1142 | 1078 | switch (prop->type) { |
---|
1143 | 1079 | case P_PROMPT: |
---|
1144 | 1080 | 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>"; |
---|
1148 | 1084 | break; |
---|
1149 | 1085 | case P_DEFAULT: |
---|
1150 | 1086 | case P_SELECT: |
---|
1151 | 1087 | 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>"; |
---|
1156 | 1096 | break; |
---|
1157 | 1097 | case P_CHOICE: |
---|
1158 | 1098 | 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>"; |
---|
1162 | 1103 | } |
---|
1163 | 1104 | break; |
---|
1164 | 1105 | 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>"; |
---|
1168 | 1109 | } |
---|
1169 | 1110 | if (prop->visible.expr) { |
---|
1170 | | - debug += " dep: "; |
---|
1171 | | - expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); |
---|
1172 | | - debug += "<br>"; |
---|
| 1111 | + stream << " dep: "; |
---|
| 1112 | + expr_print(prop->visible.expr, expr_print_help, |
---|
| 1113 | + &stream, E_NONE); |
---|
| 1114 | + stream << "<br>"; |
---|
1173 | 1115 | } |
---|
1174 | 1116 | } |
---|
1175 | | - debug += "<br>"; |
---|
| 1117 | + stream << "<br>"; |
---|
1176 | 1118 | |
---|
1177 | 1119 | return debug; |
---|
1178 | 1120 | } |
---|
.. | .. |
---|
1210 | 1152 | |
---|
1211 | 1153 | void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str) |
---|
1212 | 1154 | { |
---|
1213 | | - QString* text = reinterpret_cast<QString*>(data); |
---|
1214 | | - QString str2 = print_filter(str); |
---|
| 1155 | + QTextStream *stream = reinterpret_cast<QTextStream *>(data); |
---|
1215 | 1156 | |
---|
1216 | 1157 | 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 | + } |
---|
1222 | 1164 | } |
---|
1223 | 1165 | |
---|
1224 | | -QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos) |
---|
| 1166 | +void ConfigInfoView::clicked(const QUrl &url) |
---|
1225 | 1167 | { |
---|
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; |
---|
1228 | 1173 | |
---|
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; |
---|
1236 | 1211 | } |
---|
1237 | 1212 | |
---|
1238 | | -void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e) |
---|
| 1213 | +void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event) |
---|
1239 | 1214 | { |
---|
1240 | | - Parent::contextMenuEvent(e); |
---|
| 1215 | + contextMenu->popup(event->globalPos()); |
---|
| 1216 | + event->accept(); |
---|
1241 | 1217 | } |
---|
1242 | 1218 | |
---|
1243 | | -ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name) |
---|
| 1219 | +ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow *parent) |
---|
1244 | 1220 | : Parent(parent), result(NULL) |
---|
1245 | 1221 | { |
---|
1246 | | - setObjectName(name); |
---|
| 1222 | + setObjectName("search"); |
---|
1247 | 1223 | setWindowTitle("Search Config"); |
---|
1248 | 1224 | |
---|
1249 | 1225 | QVBoxLayout* layout1 = new QVBoxLayout(this); |
---|
1250 | 1226 | layout1->setContentsMargins(11, 11, 11, 11); |
---|
1251 | 1227 | layout1->setSpacing(6); |
---|
1252 | | - QHBoxLayout* layout2 = new QHBoxLayout(0); |
---|
| 1228 | + |
---|
| 1229 | + QHBoxLayout* layout2 = new QHBoxLayout(); |
---|
1253 | 1230 | layout2->setContentsMargins(0, 0, 0, 0); |
---|
1254 | 1231 | layout2->setSpacing(6); |
---|
1255 | 1232 | layout2->addWidget(new QLabel("Find:", this)); |
---|
.. | .. |
---|
1264 | 1241 | |
---|
1265 | 1242 | split = new QSplitter(this); |
---|
1266 | 1243 | 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 *)), |
---|
1271 | 1248 | info, SLOT(setInfo(struct menu *))); |
---|
1272 | | - connect(list->list, SIGNAL(menuChanged(struct menu *)), |
---|
| 1249 | + connect(list, SIGNAL(menuChanged(struct menu *)), |
---|
1273 | 1250 | parent, SLOT(setMenuLink(struct menu *))); |
---|
1274 | 1251 | |
---|
1275 | 1252 | layout1->addWidget(split); |
---|
1276 | 1253 | |
---|
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; |
---|
1281 | 1257 | |
---|
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())); |
---|
1296 | 1271 | } |
---|
1297 | 1272 | |
---|
1298 | 1273 | void ConfigSearchWindow::saveSettings(void) |
---|
.. | .. |
---|
1315 | 1290 | ConfigItem *lastItem = NULL; |
---|
1316 | 1291 | |
---|
1317 | 1292 | free(result); |
---|
1318 | | - list->list->clear(); |
---|
| 1293 | + list->clear(); |
---|
1319 | 1294 | info->clear(); |
---|
1320 | 1295 | |
---|
1321 | 1296 | result = sym_re_search(editField->text().toLatin1()); |
---|
.. | .. |
---|
1323 | 1298 | return; |
---|
1324 | 1299 | for (p = result; *p; p++) { |
---|
1325 | 1300 | for_all_prompts((*p), prop) |
---|
1326 | | - lastItem = new ConfigItem(list->list, lastItem, prop->menu, |
---|
| 1301 | + lastItem = new ConfigItem(list, lastItem, prop->menu, |
---|
1327 | 1302 | menu_is_visible(prop->menu)); |
---|
1328 | 1303 | } |
---|
1329 | 1304 | } |
---|
.. | .. |
---|
1334 | 1309 | ConfigMainWindow::ConfigMainWindow(void) |
---|
1335 | 1310 | : searchWindow(0) |
---|
1336 | 1311 | { |
---|
1337 | | - QMenuBar* menu; |
---|
1338 | 1312 | bool ok = true; |
---|
1339 | 1313 | QVariant x, y; |
---|
1340 | 1314 | int width, height; |
---|
.. | .. |
---|
1355 | 1329 | if ((x.isValid())&&(y.isValid())) |
---|
1356 | 1330 | move(x.toInt(), y.toInt()); |
---|
1357 | 1331 | |
---|
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); |
---|
1359 | 1346 | split1->setOrientation(Qt::Horizontal); |
---|
1360 | | - setCentralWidget(split1); |
---|
| 1347 | + split1->setChildrenCollapsible(false); |
---|
1361 | 1348 | |
---|
1362 | | - menuView = new ConfigView(split1, "menu"); |
---|
1363 | | - menuList = menuView->list; |
---|
| 1349 | + menuList = new ConfigList(widget, "menu"); |
---|
1364 | 1350 | |
---|
1365 | | - split2 = new QSplitter(split1); |
---|
| 1351 | + split2 = new QSplitter(widget); |
---|
| 1352 | + split2->setChildrenCollapsible(false); |
---|
1366 | 1353 | split2->setOrientation(Qt::Vertical); |
---|
1367 | 1354 | |
---|
1368 | 1355 | // create config tree |
---|
1369 | | - configView = new ConfigView(split2, "config"); |
---|
1370 | | - configList = configView->list; |
---|
| 1356 | + configList = new ConfigList(widget, "config"); |
---|
1371 | 1357 | |
---|
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); |
---|
1373 | 1365 | |
---|
1374 | 1366 | setTabOrder(configList, helpText); |
---|
1375 | 1367 | configList->setFocus(); |
---|
1376 | 1368 | |
---|
1377 | | - menu = menuBar(); |
---|
1378 | | - toolBar = new QToolBar("Tools", this); |
---|
1379 | | - addToolBar(toolBar); |
---|
1380 | | - |
---|
1381 | 1369 | 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 | + |
---|
1384 | 1372 | QAction *quitAction = new QAction("&Quit", this); |
---|
1385 | 1373 | quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); |
---|
1386 | | - connect(quitAction, SIGNAL(triggered(bool)), SLOT(close())); |
---|
| 1374 | + connect(quitAction, SIGNAL(triggered(bool)), SLOT(close())); |
---|
| 1375 | + |
---|
1387 | 1376 | QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this); |
---|
1388 | 1377 | loadAction->setShortcut(Qt::CTRL + Qt::Key_L); |
---|
1389 | | - connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig())); |
---|
| 1378 | + connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig())); |
---|
| 1379 | + |
---|
1390 | 1380 | saveAction = new QAction(QPixmap(xpm_save), "&Save", this); |
---|
1391 | 1381 | saveAction->setShortcut(Qt::CTRL + Qt::Key_S); |
---|
1392 | | - connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig())); |
---|
| 1382 | + connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig())); |
---|
| 1383 | + |
---|
1393 | 1384 | conf_set_changed_callback(conf_changed); |
---|
| 1385 | + |
---|
1394 | 1386 | // Set saveAction's initial state |
---|
1395 | 1387 | conf_changed(); |
---|
| 1388 | + configname = xstrdup(conf_get_configname()); |
---|
| 1389 | + |
---|
1396 | 1390 | QAction *saveAsAction = new QAction("Save &As...", this); |
---|
1397 | 1391 | connect(saveAsAction, SIGNAL(triggered(bool)), SLOT(saveConfigAs())); |
---|
1398 | 1392 | QAction *searchAction = new QAction("&Find", this); |
---|
.. | .. |
---|
1410 | 1404 | |
---|
1411 | 1405 | QAction *showNameAction = new QAction("Show Name", this); |
---|
1412 | 1406 | 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); |
---|
1421 | 1409 | |
---|
1422 | 1410 | QActionGroup *optGroup = new QActionGroup(this); |
---|
1423 | 1411 | optGroup->setExclusive(true); |
---|
1424 | | - connect(optGroup, SIGNAL(triggered(QAction*)), configView, |
---|
| 1412 | + connect(optGroup, SIGNAL(triggered(QAction*)), configList, |
---|
1425 | 1413 | SLOT(setOptionMode(QAction *))); |
---|
1426 | | - connect(optGroup, SIGNAL(triggered(QAction *)), menuView, |
---|
| 1414 | + connect(optGroup, SIGNAL(triggered(QAction *)), menuList, |
---|
1427 | 1415 | SLOT(setOptionMode(QAction *))); |
---|
1428 | 1416 | |
---|
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); |
---|
1435 | 1423 | |
---|
1436 | 1424 | QAction *showDebugAction = new QAction("Show Debug Info", this); |
---|
1437 | 1425 | showDebugAction->setCheckable(true); |
---|
.. | .. |
---|
1444 | 1432 | connect(showAboutAction, SIGNAL(triggered(bool)), SLOT(showAbout())); |
---|
1445 | 1433 | |
---|
1446 | 1434 | // init tool bar |
---|
| 1435 | + QToolBar *toolBar = addToolBar("Tools"); |
---|
1447 | 1436 | toolBar->addAction(backAction); |
---|
1448 | 1437 | toolBar->addSeparator(); |
---|
1449 | 1438 | toolBar->addAction(loadAction); |
---|
.. | .. |
---|
1453 | 1442 | toolBar->addAction(splitViewAction); |
---|
1454 | 1443 | toolBar->addAction(fullViewAction); |
---|
1455 | 1444 | |
---|
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); |
---|
1463 | 1452 | |
---|
1464 | 1453 | // create edit menu |
---|
1465 | | - QMenu* editMenu = menu->addMenu("&Edit"); |
---|
1466 | | - editMenu->addAction(searchAction); |
---|
| 1454 | + menu = menuBar()->addMenu("&Edit"); |
---|
| 1455 | + menu->addAction(searchAction); |
---|
1467 | 1456 | |
---|
1468 | 1457 | // 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); |
---|
1477 | 1464 | |
---|
1478 | 1465 | // 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 &)) ); |
---|
1483 | 1472 | |
---|
1484 | 1473 | connect(configList, SIGNAL(menuChanged(struct menu *)), |
---|
1485 | 1474 | helpText, SLOT(setInfo(struct menu *))); |
---|
1486 | 1475 | connect(configList, SIGNAL(menuSelected(struct menu *)), |
---|
1487 | 1476 | SLOT(changeMenu(struct menu *))); |
---|
| 1477 | + connect(configList, SIGNAL(itemSelected(struct menu *)), |
---|
| 1478 | + SLOT(changeItens(struct menu *))); |
---|
1488 | 1479 | connect(configList, SIGNAL(parentSelected()), |
---|
1489 | 1480 | SLOT(goBack())); |
---|
1490 | 1481 | connect(menuList, SIGNAL(menuChanged(struct menu *)), |
---|
.. | .. |
---|
1521 | 1512 | |
---|
1522 | 1513 | void ConfigMainWindow::loadConfig(void) |
---|
1523 | 1514 | { |
---|
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()) |
---|
1526 | 1521 | return; |
---|
1527 | | - if (conf_read(QFile::encodeName(s))) |
---|
| 1522 | + |
---|
| 1523 | + ba = str.toLocal8Bit(); |
---|
| 1524 | + name = ba.data(); |
---|
| 1525 | + |
---|
| 1526 | + if (conf_read(name)) |
---|
1528 | 1527 | QMessageBox::information(this, "qconf", "Unable to load configuration!"); |
---|
1529 | | - ConfigView::updateListAll(); |
---|
| 1528 | + |
---|
| 1529 | + free(configname); |
---|
| 1530 | + configname = xstrdup(name); |
---|
| 1531 | + |
---|
| 1532 | + ConfigList::updateListAllForAll(); |
---|
1530 | 1533 | } |
---|
1531 | 1534 | |
---|
1532 | 1535 | bool ConfigMainWindow::saveConfig(void) |
---|
1533 | 1536 | { |
---|
1534 | | - if (conf_write(NULL)) { |
---|
| 1537 | + if (conf_write(configname)) { |
---|
1535 | 1538 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); |
---|
1536 | 1539 | return false; |
---|
1537 | 1540 | } |
---|
.. | .. |
---|
1542 | 1545 | |
---|
1543 | 1546 | void ConfigMainWindow::saveConfigAs(void) |
---|
1544 | 1547 | { |
---|
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()) |
---|
1547 | 1554 | 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); |
---|
1549 | 1566 | } |
---|
1550 | 1567 | |
---|
1551 | 1568 | void ConfigMainWindow::searchConfig(void) |
---|
1552 | 1569 | { |
---|
1553 | 1570 | if (!searchWindow) |
---|
1554 | | - searchWindow = new ConfigSearchWindow(this, "search"); |
---|
| 1571 | + searchWindow = new ConfigSearchWindow(this); |
---|
1555 | 1572 | searchWindow->show(); |
---|
| 1573 | +} |
---|
| 1574 | + |
---|
| 1575 | +void ConfigMainWindow::changeItens(struct menu *menu) |
---|
| 1576 | +{ |
---|
| 1577 | + configList->setRootMenu(menu); |
---|
1556 | 1578 | } |
---|
1557 | 1579 | |
---|
1558 | 1580 | void ConfigMainWindow::changeMenu(struct menu *menu) |
---|
1559 | 1581 | { |
---|
1560 | | - configList->setRootMenu(menu); |
---|
1561 | | - if (configList->rootEntry->parent == &rootmenu) |
---|
1562 | | - backAction->setEnabled(false); |
---|
1563 | | - else |
---|
1564 | | - backAction->setEnabled(true); |
---|
| 1582 | + menuList->setRootMenu(menu); |
---|
1565 | 1583 | } |
---|
1566 | 1584 | |
---|
1567 | 1585 | void ConfigMainWindow::setMenuLink(struct menu *menu) |
---|
.. | .. |
---|
1581 | 1599 | return; |
---|
1582 | 1600 | list->setRootMenu(parent); |
---|
1583 | 1601 | break; |
---|
1584 | | - case symbolMode: |
---|
| 1602 | + case menuMode: |
---|
1585 | 1603 | if (menu->flags & MENU_ROOT) { |
---|
1586 | | - configList->setRootMenu(menu); |
---|
| 1604 | + menuList->setRootMenu(menu); |
---|
1587 | 1605 | configList->clearSelection(); |
---|
1588 | | - list = menuList; |
---|
1589 | | - } else { |
---|
1590 | 1606 | list = configList; |
---|
| 1607 | + } else { |
---|
1591 | 1608 | parent = menu_get_parent_menu(menu->parent); |
---|
1592 | 1609 | if (!parent) |
---|
1593 | 1610 | return; |
---|
1594 | | - item = menuList->findConfigItem(parent); |
---|
| 1611 | + |
---|
| 1612 | + /* Select the config view */ |
---|
| 1613 | + item = configList->findConfigItem(parent); |
---|
1595 | 1614 | if (item) { |
---|
1596 | | - item->setSelected(true); |
---|
1597 | | - menuList->scrollToItem(item); |
---|
| 1615 | + configList->setSelected(item, true); |
---|
| 1616 | + configList->scrollToItem(item); |
---|
1598 | 1617 | } |
---|
1599 | | - list->setRootMenu(parent); |
---|
| 1618 | + |
---|
| 1619 | + menuList->setRootMenu(parent); |
---|
| 1620 | + menuList->clearSelection(); |
---|
| 1621 | + list = menuList; |
---|
1600 | 1622 | } |
---|
1601 | 1623 | break; |
---|
1602 | 1624 | case fullMode: |
---|
.. | .. |
---|
1609 | 1631 | if (list) { |
---|
1610 | 1632 | item = list->findConfigItem(menu); |
---|
1611 | 1633 | if (item) { |
---|
1612 | | - item->setSelected(true); |
---|
| 1634 | + list->setSelected(item, true); |
---|
1613 | 1635 | list->scrollToItem(item); |
---|
1614 | 1636 | list->setFocus(); |
---|
| 1637 | + helpText->setInfo(menu); |
---|
1615 | 1638 | } |
---|
1616 | 1639 | } |
---|
1617 | 1640 | } |
---|
.. | .. |
---|
1624 | 1647 | |
---|
1625 | 1648 | void ConfigMainWindow::goBack(void) |
---|
1626 | 1649 | { |
---|
1627 | | - ConfigItem* item, *oldSelection; |
---|
1628 | | - |
---|
1629 | | - configList->setParentMenu(); |
---|
1630 | 1650 | if (configList->rootEntry == &rootmenu) |
---|
1631 | | - backAction->setEnabled(false); |
---|
1632 | | - |
---|
1633 | | - if (menuList->selectedItems().count() == 0) |
---|
1634 | 1651 | return; |
---|
1635 | 1652 | |
---|
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(); |
---|
1646 | 1654 | } |
---|
1647 | 1655 | |
---|
1648 | 1656 | void ConfigMainWindow::showSingleView(void) |
---|
.. | .. |
---|
1654 | 1662 | fullViewAction->setEnabled(true); |
---|
1655 | 1663 | fullViewAction->setChecked(false); |
---|
1656 | 1664 | |
---|
1657 | | - menuView->hide(); |
---|
| 1665 | + backAction->setEnabled(true); |
---|
| 1666 | + |
---|
| 1667 | + menuList->hide(); |
---|
1658 | 1668 | menuList->setRootMenu(0); |
---|
1659 | 1669 | configList->mode = singleMode; |
---|
1660 | 1670 | if (configList->rootEntry == &rootmenu) |
---|
.. | .. |
---|
1673 | 1683 | fullViewAction->setEnabled(true); |
---|
1674 | 1684 | fullViewAction->setChecked(false); |
---|
1675 | 1685 | |
---|
1676 | | - configList->mode = symbolMode; |
---|
| 1686 | + backAction->setEnabled(false); |
---|
| 1687 | + |
---|
| 1688 | + configList->mode = menuMode; |
---|
1677 | 1689 | if (configList->rootEntry == &rootmenu) |
---|
1678 | 1690 | configList->updateListAll(); |
---|
1679 | 1691 | else |
---|
1680 | 1692 | configList->setRootMenu(&rootmenu); |
---|
1681 | 1693 | configList->setAllOpen(true); |
---|
1682 | 1694 | configApp->processEvents(); |
---|
1683 | | - menuList->mode = menuMode; |
---|
| 1695 | + menuList->mode = symbolMode; |
---|
1684 | 1696 | menuList->setRootMenu(&rootmenu); |
---|
1685 | 1697 | menuList->setAllOpen(true); |
---|
1686 | | - menuView->show(); |
---|
| 1698 | + menuList->show(); |
---|
1687 | 1699 | menuList->setFocus(); |
---|
1688 | 1700 | } |
---|
1689 | 1701 | |
---|
.. | .. |
---|
1696 | 1708 | fullViewAction->setEnabled(false); |
---|
1697 | 1709 | fullViewAction->setChecked(true); |
---|
1698 | 1710 | |
---|
1699 | | - menuView->hide(); |
---|
| 1711 | + backAction->setEnabled(false); |
---|
| 1712 | + |
---|
| 1713 | + menuList->hide(); |
---|
1700 | 1714 | menuList->setRootMenu(0); |
---|
1701 | 1715 | configList->mode = fullMode; |
---|
1702 | 1716 | if (configList->rootEntry == &rootmenu) |
---|
.. | .. |
---|
1708 | 1722 | |
---|
1709 | 1723 | /* |
---|
1710 | 1724 | * ask for saving configuration before quitting |
---|
1711 | | - * TODO ask only when something changed |
---|
1712 | 1725 | */ |
---|
1713 | 1726 | void ConfigMainWindow::closeEvent(QCloseEvent* e) |
---|
1714 | 1727 | { |
---|
.. | .. |
---|
1739 | 1752 | |
---|
1740 | 1753 | void ConfigMainWindow::showIntro(void) |
---|
1741 | 1754 | { |
---|
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"; |
---|
1753 | 1775 | |
---|
1754 | 1776 | QMessageBox::information(this, "qconf", str); |
---|
1755 | 1777 | } |
---|
.. | .. |
---|
1829 | 1851 | const char *name; |
---|
1830 | 1852 | |
---|
1831 | 1853 | progname = av[0]; |
---|
1832 | | - configApp = new QApplication(ac, av); |
---|
1833 | 1854 | if (ac > 1 && av[1][0] == '-') { |
---|
1834 | 1855 | switch (av[1][1]) { |
---|
1835 | 1856 | case 's': |
---|
.. | .. |
---|
1850 | 1871 | conf_read(NULL); |
---|
1851 | 1872 | //zconfdump(stdout); |
---|
1852 | 1873 | |
---|
| 1874 | + configApp = new QApplication(ac, av); |
---|
| 1875 | + |
---|
1853 | 1876 | configSettings = new ConfigSettings(); |
---|
1854 | 1877 | configSettings->beginGroup("/kconfig/qconf"); |
---|
1855 | 1878 | v = new ConfigMainWindow(); |
---|