1 // SPDX-License-Identifier: GPL-2.0 1 // SPDX-License-Identifier: GPL-2.0 2 /* 2 /* 3 * Copyright (C) 2002 Roman Zippel <zippel@lin 3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 4 * Copyright (C) 2015 Boris Barbulovski <bbarb 4 * Copyright (C) 2015 Boris Barbulovski <bbarbulovski@gmail.com> 5 */ 5 */ 6 6 7 #include <QAction> 7 #include <QAction> 8 #include <QActionGroup> << 9 #include <QApplication> 8 #include <QApplication> 10 #include <QCloseEvent> 9 #include <QCloseEvent> 11 #include <QDebug> 10 #include <QDebug> >> 11 #include <QDesktopWidget> 12 #include <QFileDialog> 12 #include <QFileDialog> 13 #include <QLabel> 13 #include <QLabel> 14 #include <QLayout> 14 #include <QLayout> 15 #include <QList> 15 #include <QList> 16 #include <QMenu> 16 #include <QMenu> 17 #include <QMenuBar> 17 #include <QMenuBar> 18 #include <QMessageBox> 18 #include <QMessageBox> 19 #include <QRegularExpression> << 20 #include <QScreen> << 21 #include <QToolBar> 19 #include <QToolBar> 22 20 23 #include <stdlib.h> 21 #include <stdlib.h> 24 22 25 #include <xalloc.h> << 26 #include "lkc.h" 23 #include "lkc.h" 27 #include "qconf.h" 24 #include "qconf.h" 28 25 29 #include "images.h" 26 #include "images.h" 30 27 31 28 32 static QApplication *configApp; 29 static QApplication *configApp; 33 static ConfigSettings *configSettings; 30 static ConfigSettings *configSettings; 34 31 35 QAction *ConfigMainWindow::saveAction; 32 QAction *ConfigMainWindow::saveAction; 36 33 >> 34 static inline QString qgettext(const char* str) >> 35 { >> 36 return QString::fromLocal8Bit(str); >> 37 } >> 38 37 ConfigSettings::ConfigSettings() 39 ConfigSettings::ConfigSettings() 38 : QSettings("kernel.org", "qconf") 40 : QSettings("kernel.org", "qconf") 39 { 41 { 40 } 42 } 41 43 42 /** 44 /** 43 * Reads a list of integer values from the app 45 * Reads a list of integer values from the application settings. 44 */ 46 */ 45 QList<int> ConfigSettings::readSizes(const QSt 47 QList<int> ConfigSettings::readSizes(const QString& key, bool *ok) 46 { 48 { 47 QList<int> result; 49 QList<int> result; 48 50 49 if (contains(key)) 51 if (contains(key)) 50 { 52 { 51 QStringList entryList = value( 53 QStringList entryList = value(key).toStringList(); 52 QStringList::Iterator it; 54 QStringList::Iterator it; 53 55 54 for (it = entryList.begin(); i 56 for (it = entryList.begin(); it != entryList.end(); ++it) 55 result.push_back((*it) 57 result.push_back((*it).toInt()); 56 58 57 *ok = true; 59 *ok = true; 58 } 60 } 59 else 61 else 60 *ok = false; 62 *ok = false; 61 63 62 return result; 64 return result; 63 } 65 } 64 66 65 /** 67 /** 66 * Writes a list of integer values to the appl 68 * Writes a list of integer values to the application settings. 67 */ 69 */ 68 bool ConfigSettings::writeSizes(const QString& 70 bool ConfigSettings::writeSizes(const QString& key, const QList<int>& value) 69 { 71 { 70 QStringList stringList; 72 QStringList stringList; 71 QList<int>::ConstIterator it; 73 QList<int>::ConstIterator it; 72 74 73 for (it = value.begin(); it != value.e 75 for (it = value.begin(); it != value.end(); ++it) 74 stringList.push_back(QString:: 76 stringList.push_back(QString::number(*it)); 75 setValue(key, stringList); 77 setValue(key, stringList); 76 78 77 return true; 79 return true; 78 } 80 } 79 81 80 QIcon ConfigItem::symbolYesIcon; !! 82 81 QIcon ConfigItem::symbolModIcon; !! 83 /* 82 QIcon ConfigItem::symbolNoIcon; !! 84 * set the new data 83 QIcon ConfigItem::choiceYesIcon; !! 85 * TODO check the value 84 QIcon ConfigItem::choiceNoIcon; !! 86 */ 85 QIcon ConfigItem::menuIcon; !! 87 void ConfigItem::okRename(int col) 86 QIcon ConfigItem::menubackIcon; !! 88 { >> 89 } 87 90 88 /* 91 /* 89 * update the displayed of a menu entry 92 * update the displayed of a menu entry 90 */ 93 */ 91 void ConfigItem::updateMenu(void) 94 void ConfigItem::updateMenu(void) 92 { 95 { 93 ConfigList* list; 96 ConfigList* list; 94 struct symbol* sym; 97 struct symbol* sym; 95 struct property *prop; 98 struct property *prop; 96 QString prompt; 99 QString prompt; 97 int type; 100 int type; 98 tristate expr; 101 tristate expr; 99 102 100 list = listView(); 103 list = listView(); 101 if (goParent) { 104 if (goParent) { 102 setIcon(promptColIdx, menuback !! 105 setPixmap(promptColIdx, list->menuBackPix); 103 prompt = ".."; 106 prompt = ".."; 104 goto set_prompt; 107 goto set_prompt; 105 } 108 } 106 109 107 sym = menu->sym; 110 sym = menu->sym; 108 prop = menu->prompt; 111 prop = menu->prompt; 109 prompt = menu_get_prompt(menu); !! 112 prompt = qgettext(menu_get_prompt(menu)); 110 113 111 if (prop) switch (prop->type) { 114 if (prop) switch (prop->type) { 112 case P_MENU: 115 case P_MENU: 113 if (list->mode == singleMode | 116 if (list->mode == singleMode || list->mode == symbolMode) { 114 /* a menuconfig entry 117 /* a menuconfig entry is displayed differently 115 * depending whether i 118 * depending whether it's at the view root or a child. 116 */ 119 */ 117 if (sym && list->rootE 120 if (sym && list->rootEntry == menu) 118 break; 121 break; 119 setIcon(promptColIdx, !! 122 setPixmap(promptColIdx, list->menuPix); 120 } else { 123 } else { 121 if (sym) 124 if (sym) 122 break; 125 break; 123 setIcon(promptColIdx, !! 126 setPixmap(promptColIdx, QIcon()); 124 } 127 } 125 goto set_prompt; 128 goto set_prompt; 126 case P_COMMENT: 129 case P_COMMENT: 127 setIcon(promptColIdx, QIcon()) !! 130 setPixmap(promptColIdx, QIcon()); 128 prompt = "*** " + prompt + " * << 129 goto set_prompt; 131 goto set_prompt; 130 default: 132 default: 131 ; 133 ; 132 } 134 } 133 if (!sym) 135 if (!sym) 134 goto set_prompt; 136 goto set_prompt; 135 137 136 setText(nameColIdx, sym->name); !! 138 setText(nameColIdx, QString::fromLocal8Bit(sym->name)); 137 139 138 type = sym_get_type(sym); 140 type = sym_get_type(sym); 139 switch (type) { 141 switch (type) { 140 case S_BOOLEAN: 142 case S_BOOLEAN: 141 case S_TRISTATE: 143 case S_TRISTATE: 142 char ch; 144 char ch; 143 145 144 if (!sym_is_changeable(sym) && 146 if (!sym_is_changeable(sym) && list->optMode == normalOpt) { 145 setIcon(promptColIdx, !! 147 setPixmap(promptColIdx, QIcon()); >> 148 setText(noColIdx, QString()); >> 149 setText(modColIdx, QString()); >> 150 setText(yesColIdx, QString()); 146 break; 151 break; 147 } 152 } 148 expr = sym_get_tristate_value( 153 expr = sym_get_tristate_value(sym); 149 switch (expr) { 154 switch (expr) { 150 case yes: 155 case yes: 151 if (sym_is_choice_valu !! 156 if (sym_is_choice_value(sym) && type == S_BOOLEAN) 152 setIcon(prompt !! 157 setPixmap(promptColIdx, list->choiceYesPix); 153 else 158 else 154 setIcon(prompt !! 159 setPixmap(promptColIdx, list->symbolYesPix); >> 160 setText(yesColIdx, "Y"); 155 ch = 'Y'; 161 ch = 'Y'; 156 break; 162 break; 157 case mod: 163 case mod: 158 setIcon(promptColIdx, !! 164 setPixmap(promptColIdx, list->symbolModPix); >> 165 setText(modColIdx, "M"); 159 ch = 'M'; 166 ch = 'M'; 160 break; 167 break; 161 default: 168 default: 162 if (sym_is_choice_valu 169 if (sym_is_choice_value(sym) && type == S_BOOLEAN) 163 setIcon(prompt !! 170 setPixmap(promptColIdx, list->choiceNoPix); 164 else 171 else 165 setIcon(prompt !! 172 setPixmap(promptColIdx, list->symbolNoPix); >> 173 setText(noColIdx, "N"); 166 ch = 'N'; 174 ch = 'N'; 167 break; 175 break; 168 } 176 } >> 177 if (expr != no) >> 178 setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); >> 179 if (expr != mod) >> 180 setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); >> 181 if (expr != yes) >> 182 setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); 169 183 170 setText(dataColIdx, QChar(ch)) 184 setText(dataColIdx, QChar(ch)); 171 break; 185 break; 172 case S_INT: 186 case S_INT: 173 case S_HEX: 187 case S_HEX: 174 case S_STRING: 188 case S_STRING: 175 setText(dataColIdx, sym_get_st !! 189 const char* data; >> 190 >> 191 data = sym_get_string_value(sym); >> 192 >> 193 setText(dataColIdx, data); >> 194 if (type == S_STRING) >> 195 prompt = QString("%1: %2").arg(prompt).arg(data); >> 196 else >> 197 prompt = QString("(%2) %1").arg(prompt).arg(data); 176 break; 198 break; 177 } 199 } 178 if (!sym_has_value(sym) && visible) 200 if (!sym_has_value(sym) && visible) 179 prompt += " (NEW)"; 201 prompt += " (NEW)"; 180 set_prompt: 202 set_prompt: 181 setText(promptColIdx, prompt); 203 setText(promptColIdx, prompt); 182 } 204 } 183 205 184 void ConfigItem::testUpdateMenu(bool v) 206 void ConfigItem::testUpdateMenu(bool v) 185 { 207 { 186 ConfigItem* i; 208 ConfigItem* i; 187 209 188 visible = v; 210 visible = v; 189 if (!menu) 211 if (!menu) 190 return; 212 return; 191 213 192 sym_calc_value(menu->sym); 214 sym_calc_value(menu->sym); 193 if (menu->flags & MENU_CHANGED) { 215 if (menu->flags & MENU_CHANGED) { 194 /* the menu entry changed, so 216 /* the menu entry changed, so update all list items */ 195 menu->flags &= ~MENU_CHANGED; 217 menu->flags &= ~MENU_CHANGED; 196 for (i = (ConfigItem*)menu->da 218 for (i = (ConfigItem*)menu->data; i; i = i->nextItem) 197 i->updateMenu(); 219 i->updateMenu(); 198 } else if (listView()->updateAll) 220 } else if (listView()->updateAll) 199 updateMenu(); 221 updateMenu(); 200 } 222 } 201 223 202 224 203 /* 225 /* 204 * construct a menu entry 226 * construct a menu entry 205 */ 227 */ 206 void ConfigItem::init(void) 228 void ConfigItem::init(void) 207 { 229 { 208 if (menu) { 230 if (menu) { 209 ConfigList* list = listView(); 231 ConfigList* list = listView(); 210 nextItem = (ConfigItem*)menu-> 232 nextItem = (ConfigItem*)menu->data; 211 menu->data = this; 233 menu->data = this; 212 234 213 if (list->mode != fullMode) 235 if (list->mode != fullMode) 214 setExpanded(true); 236 setExpanded(true); 215 sym_calc_value(menu->sym); 237 sym_calc_value(menu->sym); 216 << 217 if (menu->sym) { << 218 enum symbol_type type << 219 << 220 // Allow to edit "int" << 221 // the data column. Un << 222 // the flags per colum << 223 // columns here, and c << 224 if (type == S_INT || t << 225 setFlags(flags << 226 } << 227 } 238 } 228 updateMenu(); 239 updateMenu(); 229 } 240 } 230 241 231 /* 242 /* 232 * destruct a menu entry 243 * destruct a menu entry 233 */ 244 */ 234 ConfigItem::~ConfigItem(void) 245 ConfigItem::~ConfigItem(void) 235 { 246 { 236 if (menu) { 247 if (menu) { 237 ConfigItem** ip = (ConfigItem* 248 ConfigItem** ip = (ConfigItem**)&menu->data; 238 for (; *ip; ip = &(*ip)->nextI 249 for (; *ip; ip = &(*ip)->nextItem) { 239 if (*ip == this) { 250 if (*ip == this) { 240 *ip = nextItem 251 *ip = nextItem; 241 break; 252 break; 242 } 253 } 243 } 254 } 244 } 255 } 245 } 256 } 246 257 247 QWidget *ConfigItemDelegate::createEditor(QWid !! 258 ConfigLineEdit::ConfigLineEdit(ConfigView* parent) 248 cons !! 259 : Parent(parent) 249 cons << 250 { 260 { 251 ConfigItem *item; !! 261 connect(this, SIGNAL(editingFinished()), SLOT(hide())); 252 << 253 // Only the data column is editable << 254 if (index.column() != dataColIdx) << 255 return nullptr; << 256 << 257 // You cannot edit invisible menus << 258 item = static_cast<ConfigItem *>(index << 259 if (!item || !item->menu || !menu_is_v << 260 return nullptr; << 261 << 262 return QStyledItemDelegate::createEdit << 263 } 262 } 264 263 265 void ConfigItemDelegate::setModelData(QWidget !! 264 void ConfigLineEdit::show(ConfigItem* i) 266 QAbstrac << 267 const QM << 268 { 265 { 269 QLineEdit *lineEdit; !! 266 item = i; 270 ConfigItem *item; !! 267 if (sym_get_string_value(item->menu->sym)) 271 struct symbol *sym; !! 268 setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym))); 272 bool success; !! 269 else 273 !! 270 setText(QString()); 274 lineEdit = qobject_cast<QLineEdit *>(e !! 271 Parent::show(); 275 // If this is not a QLineEdit, use the !! 272 setFocus(); 276 // (does this happen?) !! 273 } 277 if (!lineEdit) << 278 goto parent; << 279 << 280 item = static_cast<ConfigItem *>(index << 281 if (!item || !item->menu) << 282 goto parent; << 283 << 284 sym = item->menu->sym; << 285 if (!sym) << 286 goto parent; << 287 274 288 success = sym_set_string_value(sym, li !! 275 void ConfigLineEdit::keyPressEvent(QKeyEvent* e) 289 if (success) { !! 276 { 290 ConfigList::updateListForAll() !! 277 switch (e->key()) { 291 } else { !! 278 case Qt::Key_Escape: 292 QMessageBox::information(edito !! 279 break; 293 "Cannot set the data ( !! 280 case Qt::Key_Return: 294 "Setting the old value !! 281 case Qt::Key_Enter: 295 lineEdit->setText(sym_get_stri !! 282 sym_set_string_value(item->menu->sym, text().toLatin1()); >> 283 parent()->updateList(item); >> 284 break; >> 285 default: >> 286 Parent::keyPressEvent(e); >> 287 return; 296 } 288 } 297 !! 289 e->accept(); 298 parent: !! 290 parent()->list->setFocus(); 299 QStyledItemDelegate::setModelData(edit !! 291 hide(); 300 } 292 } 301 293 302 ConfigList::ConfigList(QWidget *parent, const !! 294 ConfigList::ConfigList(ConfigView* p, const char *name) 303 : QTreeWidget(parent), !! 295 : Parent(p), 304 updateAll(false), 296 updateAll(false), 305 showName(false), mode(singleMode), o !! 297 symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), >> 298 choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), >> 299 menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), >> 300 showName(false), showRange(false), showData(false), mode(singleMode), optMode(normalOpt), 306 rootEntry(0), headerPopup(0) 301 rootEntry(0), headerPopup(0) 307 { 302 { 308 setObjectName(name); 303 setObjectName(name); 309 setSortingEnabled(false); 304 setSortingEnabled(false); 310 setRootIsDecorated(true); 305 setRootIsDecorated(true); 311 306 312 setVerticalScrollMode(ScrollPerPixel); 307 setVerticalScrollMode(ScrollPerPixel); 313 setHorizontalScrollMode(ScrollPerPixel 308 setHorizontalScrollMode(ScrollPerPixel); 314 309 315 setHeaderLabels(QStringList() << "Opti !! 310 setHeaderLabels(QStringList() << "Option" << "Name" << "N" << "M" << "Y" << "Value"); 316 311 317 connect(this, &ConfigList::itemSelecti !! 312 connect(this, SIGNAL(itemSelectionChanged(void)), 318 this, &ConfigList::updateSelec !! 313 SLOT(updateSelection(void))); 319 314 320 if (name) { 315 if (name) { 321 configSettings->beginGroup(nam 316 configSettings->beginGroup(name); 322 showName = configSettings->val 317 showName = configSettings->value("/showName", false).toBool(); >> 318 showRange = configSettings->value("/showRange", false).toBool(); >> 319 showData = configSettings->value("/showData", false).toBool(); 323 optMode = (enum optionMode)con 320 optMode = (enum optionMode)configSettings->value("/optionMode", 0).toInt(); 324 configSettings->endGroup(); 321 configSettings->endGroup(); 325 connect(configApp, &QApplicati !! 322 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); 326 this, &ConfigList::sav << 327 } 323 } 328 324 329 showColumn(promptColIdx); !! 325 addColumn(promptColIdx); 330 << 331 setItemDelegate(new ConfigItemDelegate << 332 << 333 allLists.append(this); << 334 326 335 reinit(); 327 reinit(); 336 } 328 } 337 329 338 ConfigList::~ConfigList() << 339 { << 340 allLists.removeOne(this); << 341 } << 342 << 343 bool ConfigList::menuSkip(struct menu *menu) 330 bool ConfigList::menuSkip(struct menu *menu) 344 { 331 { 345 if (optMode == normalOpt && menu_is_vi 332 if (optMode == normalOpt && menu_is_visible(menu)) 346 return false; 333 return false; 347 if (optMode == promptOpt && menu_has_p 334 if (optMode == promptOpt && menu_has_prompt(menu)) 348 return false; 335 return false; 349 if (optMode == allOpt) 336 if (optMode == allOpt) 350 return false; 337 return false; 351 return true; 338 return true; 352 } 339 } 353 340 354 void ConfigList::reinit(void) 341 void ConfigList::reinit(void) 355 { 342 { 356 hideColumn(nameColIdx); !! 343 removeColumn(dataColIdx); >> 344 removeColumn(yesColIdx); >> 345 removeColumn(modColIdx); >> 346 removeColumn(noColIdx); >> 347 removeColumn(nameColIdx); 357 348 358 if (showName) 349 if (showName) 359 showColumn(nameColIdx); !! 350 addColumn(nameColIdx); 360 !! 351 if (showRange) { 361 updateListAll(); !! 352 addColumn(noColIdx); 362 } !! 353 addColumn(modColIdx); 363 !! 354 addColumn(yesColIdx); 364 void ConfigList::setOptionMode(QAction *action !! 355 } 365 { !! 356 if (showData) 366 if (action == showNormalAction) !! 357 addColumn(dataColIdx); 367 optMode = normalOpt; << 368 else if (action == showAllAction) << 369 optMode = allOpt; << 370 else << 371 optMode = promptOpt; << 372 358 373 updateListAll(); 359 updateListAll(); 374 } 360 } 375 361 376 void ConfigList::saveSettings(void) 362 void ConfigList::saveSettings(void) 377 { 363 { 378 if (!objectName().isEmpty()) { 364 if (!objectName().isEmpty()) { 379 configSettings->beginGroup(obj 365 configSettings->beginGroup(objectName()); 380 configSettings->setValue("/sho 366 configSettings->setValue("/showName", showName); >> 367 configSettings->setValue("/showRange", showRange); >> 368 configSettings->setValue("/showData", showData); 381 configSettings->setValue("/opt 369 configSettings->setValue("/optionMode", (int)optMode); 382 configSettings->endGroup(); 370 configSettings->endGroup(); 383 } 371 } 384 } 372 } 385 373 386 ConfigItem* ConfigList::findConfigItem(struct 374 ConfigItem* ConfigList::findConfigItem(struct menu *menu) 387 { 375 { 388 ConfigItem* item = (ConfigItem*)menu-> 376 ConfigItem* item = (ConfigItem*)menu->data; 389 377 390 for (; item; item = item->nextItem) { 378 for (; item; item = item->nextItem) { 391 if (this == item->listView()) 379 if (this == item->listView()) 392 break; 380 break; 393 } 381 } 394 382 395 return item; 383 return item; 396 } 384 } 397 385 398 void ConfigList::updateSelection(void) 386 void ConfigList::updateSelection(void) 399 { 387 { 400 struct menu *menu; 388 struct menu *menu; 401 enum prop_type type; 389 enum prop_type type; 402 390 403 if (selectedItems().count() == 0) 391 if (selectedItems().count() == 0) 404 return; 392 return; 405 393 406 ConfigItem* item = (ConfigItem*)select 394 ConfigItem* item = (ConfigItem*)selectedItems().first(); 407 if (!item) 395 if (!item) 408 return; 396 return; 409 397 410 menu = item->menu; 398 menu = item->menu; 411 emit menuChanged(menu); 399 emit menuChanged(menu); 412 if (!menu) 400 if (!menu) 413 return; 401 return; 414 type = menu->prompt ? menu->prompt->ty 402 type = menu->prompt ? menu->prompt->type : P_UNKNOWN; 415 if (mode == menuMode && type == P_MENU 403 if (mode == menuMode && type == P_MENU) 416 emit menuSelected(menu); 404 emit menuSelected(menu); 417 } 405 } 418 406 419 void ConfigList::updateList() !! 407 void ConfigList::updateList(ConfigItem* item) 420 { 408 { 421 ConfigItem* last = 0; 409 ConfigItem* last = 0; 422 ConfigItem *item; << 423 410 424 if (!rootEntry) { 411 if (!rootEntry) { 425 if (mode != listMode) 412 if (mode != listMode) 426 goto update; 413 goto update; 427 QTreeWidgetItemIterator it(thi 414 QTreeWidgetItemIterator it(this); >> 415 ConfigItem* item; 428 416 429 while (*it) { 417 while (*it) { 430 item = (ConfigItem*)(* 418 item = (ConfigItem*)(*it); 431 if (!item->menu) 419 if (!item->menu) 432 continue; 420 continue; 433 item->testUpdateMenu(m 421 item->testUpdateMenu(menu_is_visible(item->menu)); 434 422 435 ++it; 423 ++it; 436 } 424 } 437 return; 425 return; 438 } 426 } 439 427 440 if (rootEntry != &rootmenu && (mode == 428 if (rootEntry != &rootmenu && (mode == singleMode || 441 (mode == symbolMode && rootEntry-> 429 (mode == symbolMode && rootEntry->parent != &rootmenu))) { 442 item = (ConfigItem *)topLevelI 430 item = (ConfigItem *)topLevelItem(0); 443 if (!item) 431 if (!item) 444 item = new ConfigItem( 432 item = new ConfigItem(this, 0, true); 445 last = item; 433 last = item; 446 } 434 } 447 if ((mode == singleMode || (mode == sy 435 if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) && 448 rootEntry->sym && rootEntry->promp 436 rootEntry->sym && rootEntry->prompt) { 449 item = last ? last->nextSiblin 437 item = last ? last->nextSibling() : nullptr; 450 if (!item) 438 if (!item) 451 item = new ConfigItem( 439 item = new ConfigItem(this, last, rootEntry, true); 452 else 440 else 453 item->testUpdateMenu(t 441 item->testUpdateMenu(true); 454 442 455 updateMenuList(item, rootEntry 443 updateMenuList(item, rootEntry); 456 update(); 444 update(); 457 resizeColumnToContents(0); 445 resizeColumnToContents(0); 458 return; 446 return; 459 } 447 } 460 update: 448 update: 461 updateMenuList(rootEntry); !! 449 updateMenuList(this, rootEntry); 462 update(); 450 update(); 463 resizeColumnToContents(0); 451 resizeColumnToContents(0); 464 } 452 } 465 453 466 void ConfigList::updateListForAll() << 467 { << 468 QListIterator<ConfigList *> it(allList << 469 << 470 while (it.hasNext()) { << 471 ConfigList *list = it.next(); << 472 << 473 list->updateList(); << 474 } << 475 } << 476 << 477 void ConfigList::updateListAllForAll() << 478 { << 479 QListIterator<ConfigList *> it(allList << 480 << 481 while (it.hasNext()) { << 482 ConfigList *list = it.next(); << 483 << 484 list->updateList(); << 485 } << 486 } << 487 << 488 void ConfigList::setValue(ConfigItem* item, tr 454 void ConfigList::setValue(ConfigItem* item, tristate val) 489 { 455 { 490 struct symbol* sym; 456 struct symbol* sym; 491 int type; 457 int type; 492 tristate oldval; 458 tristate oldval; 493 459 494 sym = item->menu ? item->menu->sym : 0 460 sym = item->menu ? item->menu->sym : 0; 495 if (!sym) 461 if (!sym) 496 return; 462 return; 497 463 498 type = sym_get_type(sym); 464 type = sym_get_type(sym); 499 switch (type) { 465 switch (type) { 500 case S_BOOLEAN: 466 case S_BOOLEAN: 501 case S_TRISTATE: 467 case S_TRISTATE: 502 oldval = sym_get_tristate_valu 468 oldval = sym_get_tristate_value(sym); 503 469 504 if (!sym_set_tristate_value(sy 470 if (!sym_set_tristate_value(sym, val)) 505 return; 471 return; 506 if (oldval == no && item->menu 472 if (oldval == no && item->menu->list) 507 item->setExpanded(true 473 item->setExpanded(true); 508 ConfigList::updateListForAll() !! 474 parent()->updateList(item); 509 break; 475 break; 510 } 476 } 511 } 477 } 512 478 513 void ConfigList::changeValue(ConfigItem* item) 479 void ConfigList::changeValue(ConfigItem* item) 514 { 480 { 515 struct symbol* sym; 481 struct symbol* sym; 516 struct menu* menu; 482 struct menu* menu; 517 int type, oldexpr, newexpr; 483 int type, oldexpr, newexpr; 518 484 519 menu = item->menu; 485 menu = item->menu; 520 if (!menu) 486 if (!menu) 521 return; 487 return; 522 sym = menu->sym; 488 sym = menu->sym; 523 if (!sym) { 489 if (!sym) { 524 if (item->menu->list) 490 if (item->menu->list) 525 item->setExpanded(!ite 491 item->setExpanded(!item->isExpanded()); 526 return; 492 return; 527 } 493 } 528 494 529 type = sym_get_type(sym); 495 type = sym_get_type(sym); 530 switch (type) { 496 switch (type) { 531 case S_BOOLEAN: 497 case S_BOOLEAN: 532 case S_TRISTATE: 498 case S_TRISTATE: 533 oldexpr = sym_get_tristate_val 499 oldexpr = sym_get_tristate_value(sym); 534 newexpr = sym_toggle_tristate_ 500 newexpr = sym_toggle_tristate_value(sym); 535 if (item->menu->list) { 501 if (item->menu->list) { 536 if (oldexpr == newexpr 502 if (oldexpr == newexpr) 537 item->setExpan 503 item->setExpanded(!item->isExpanded()); 538 else if (oldexpr == no 504 else if (oldexpr == no) 539 item->setExpan 505 item->setExpanded(true); 540 } 506 } 541 if (oldexpr != newexpr) 507 if (oldexpr != newexpr) 542 ConfigList::updateList !! 508 parent()->updateList(item); 543 break; 509 break; 544 default: !! 510 case S_INT: >> 511 case S_HEX: >> 512 case S_STRING: >> 513 parent()->lineEdit->show(item); 545 break; 514 break; 546 } 515 } 547 } 516 } 548 517 549 void ConfigList::setRootMenu(struct menu *menu 518 void ConfigList::setRootMenu(struct menu *menu) 550 { 519 { 551 enum prop_type type; 520 enum prop_type type; 552 521 553 if (rootEntry == menu) 522 if (rootEntry == menu) 554 return; 523 return; 555 type = menu && menu->prompt ? menu->pr 524 type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; 556 if (type != P_MENU) 525 if (type != P_MENU) 557 return; 526 return; 558 updateMenuList(0); !! 527 updateMenuList(this, 0); 559 rootEntry = menu; 528 rootEntry = menu; 560 updateListAll(); 529 updateListAll(); 561 if (currentItem()) { 530 if (currentItem()) { 562 setSelected(currentItem(), has 531 setSelected(currentItem(), hasFocus()); 563 scrollToItem(currentItem()); 532 scrollToItem(currentItem()); 564 } 533 } 565 } 534 } 566 535 567 void ConfigList::setParentMenu(void) 536 void ConfigList::setParentMenu(void) 568 { 537 { 569 ConfigItem* item; 538 ConfigItem* item; 570 struct menu *oldroot; 539 struct menu *oldroot; 571 540 572 oldroot = rootEntry; 541 oldroot = rootEntry; 573 if (rootEntry == &rootmenu) 542 if (rootEntry == &rootmenu) 574 return; 543 return; 575 setRootMenu(menu_get_parent_menu(rootE 544 setRootMenu(menu_get_parent_menu(rootEntry->parent)); 576 545 577 QTreeWidgetItemIterator it(this); 546 QTreeWidgetItemIterator it(this); 578 while (*it) { 547 while (*it) { 579 item = (ConfigItem *)(*it); 548 item = (ConfigItem *)(*it); 580 if (item->menu == oldroot) { 549 if (item->menu == oldroot) { 581 setCurrentItem(item); 550 setCurrentItem(item); 582 scrollToItem(item); 551 scrollToItem(item); 583 break; 552 break; 584 } 553 } 585 554 586 ++it; 555 ++it; 587 } 556 } 588 } 557 } 589 558 590 /* 559 /* 591 * update all the children of a menu entry 560 * update all the children of a menu entry 592 * removes/adds the entries from the parent 561 * removes/adds the entries from the parent widget as necessary 593 * 562 * 594 * parent: either the menu list widget or a me 563 * parent: either the menu list widget or a menu entry widget 595 * menu: entry to be updated 564 * menu: entry to be updated 596 */ 565 */ 597 void ConfigList::updateMenuList(ConfigItem *pa 566 void ConfigList::updateMenuList(ConfigItem *parent, struct menu* menu) 598 { 567 { 599 struct menu* child; 568 struct menu* child; 600 ConfigItem* item; 569 ConfigItem* item; 601 ConfigItem* last; 570 ConfigItem* last; 602 bool visible; 571 bool visible; 603 enum prop_type type; 572 enum prop_type type; 604 573 605 if (!menu) { 574 if (!menu) { 606 while (parent->childCount() > 575 while (parent->childCount() > 0) 607 { 576 { 608 delete parent->takeChi 577 delete parent->takeChild(0); 609 } 578 } 610 579 611 return; 580 return; 612 } 581 } 613 582 614 last = parent->firstChild(); 583 last = parent->firstChild(); 615 if (last && !last->goParent) 584 if (last && !last->goParent) 616 last = 0; 585 last = 0; 617 for (child = menu->list; child; child 586 for (child = menu->list; child; child = child->next) { 618 item = last ? last->nextSiblin 587 item = last ? last->nextSibling() : parent->firstChild(); 619 type = child->prompt ? child-> 588 type = child->prompt ? child->prompt->type : P_UNKNOWN; 620 589 621 switch (mode) { 590 switch (mode) { 622 case menuMode: 591 case menuMode: 623 if (!(child->flags & M 592 if (!(child->flags & MENU_ROOT)) 624 goto hide; 593 goto hide; 625 break; 594 break; 626 case symbolMode: 595 case symbolMode: 627 if (child->flags & MEN 596 if (child->flags & MENU_ROOT) 628 goto hide; 597 goto hide; 629 break; 598 break; 630 default: 599 default: 631 break; 600 break; 632 } 601 } 633 602 634 visible = menu_is_visible(chil 603 visible = menu_is_visible(child); 635 if (!menuSkip(child)) { 604 if (!menuSkip(child)) { 636 if (!child->sym && !ch 605 if (!child->sym && !child->list && !child->prompt) 637 continue; 606 continue; 638 if (!item || item->men 607 if (!item || item->menu != child) 639 item = new Con 608 item = new ConfigItem(parent, last, child, visible); 640 else 609 else 641 item->testUpda 610 item->testUpdateMenu(visible); 642 611 643 if (mode == fullMode | 612 if (mode == fullMode || mode == menuMode || type != P_MENU) 644 updateMenuList 613 updateMenuList(item, child); 645 else 614 else 646 updateMenuList 615 updateMenuList(item, 0); 647 last = item; 616 last = item; 648 continue; 617 continue; 649 } 618 } 650 hide: 619 hide: 651 if (item && item->menu == chil 620 if (item && item->menu == child) { 652 last = parent->firstCh 621 last = parent->firstChild(); 653 if (last == item) 622 if (last == item) 654 last = 0; 623 last = 0; 655 else while (last->next 624 else while (last->nextSibling() != item) 656 last = last->n 625 last = last->nextSibling(); 657 delete item; 626 delete item; 658 } 627 } 659 } 628 } 660 } 629 } 661 630 662 void ConfigList::updateMenuList(struct menu *m !! 631 void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) 663 { 632 { 664 struct menu* child; 633 struct menu* child; 665 ConfigItem* item; 634 ConfigItem* item; 666 ConfigItem* last; 635 ConfigItem* last; 667 bool visible; 636 bool visible; 668 enum prop_type type; 637 enum prop_type type; 669 638 670 if (!menu) { 639 if (!menu) { 671 while (topLevelItemCount() > 0 !! 640 while (parent->topLevelItemCount() > 0) 672 { 641 { 673 delete takeTopLevelIte !! 642 delete parent->takeTopLevelItem(0); 674 } 643 } 675 644 676 return; 645 return; 677 } 646 } 678 647 679 last = (ConfigItem *)topLevelItem(0); !! 648 last = (ConfigItem*)parent->topLevelItem(0); 680 if (last && !last->goParent) 649 if (last && !last->goParent) 681 last = 0; 650 last = 0; 682 for (child = menu->list; child; child 651 for (child = menu->list; child; child = child->next) { 683 item = last ? last->nextSiblin !! 652 item = last ? last->nextSibling() : (ConfigItem*)parent->topLevelItem(0); 684 type = child->prompt ? child-> 653 type = child->prompt ? child->prompt->type : P_UNKNOWN; 685 654 686 switch (mode) { 655 switch (mode) { 687 case menuMode: 656 case menuMode: 688 if (!(child->flags & M 657 if (!(child->flags & MENU_ROOT)) 689 goto hide; 658 goto hide; 690 break; 659 break; 691 case symbolMode: 660 case symbolMode: 692 if (child->flags & MEN 661 if (child->flags & MENU_ROOT) 693 goto hide; 662 goto hide; 694 break; 663 break; 695 default: 664 default: 696 break; 665 break; 697 } 666 } 698 667 699 visible = menu_is_visible(chil 668 visible = menu_is_visible(child); 700 if (!menuSkip(child)) { 669 if (!menuSkip(child)) { 701 if (!child->sym && !ch 670 if (!child->sym && !child->list && !child->prompt) 702 continue; 671 continue; 703 if (!item || item->men 672 if (!item || item->menu != child) 704 item = new Con !! 673 item = new ConfigItem(parent, last, child, visible); 705 else 674 else 706 item->testUpda 675 item->testUpdateMenu(visible); 707 676 708 if (mode == fullMode | 677 if (mode == fullMode || mode == menuMode || type != P_MENU) 709 updateMenuList 678 updateMenuList(item, child); 710 else 679 else 711 updateMenuList 680 updateMenuList(item, 0); 712 last = item; 681 last = item; 713 continue; 682 continue; 714 } 683 } 715 hide: 684 hide: 716 if (item && item->menu == chil 685 if (item && item->menu == child) { 717 last = (ConfigItem *)t !! 686 last = (ConfigItem*)parent->topLevelItem(0); 718 if (last == item) 687 if (last == item) 719 last = 0; 688 last = 0; 720 else while (last->next 689 else while (last->nextSibling() != item) 721 last = last->n 690 last = last->nextSibling(); 722 delete item; 691 delete item; 723 } 692 } 724 } 693 } 725 } 694 } 726 695 727 void ConfigList::keyPressEvent(QKeyEvent* ev) 696 void ConfigList::keyPressEvent(QKeyEvent* ev) 728 { 697 { 729 QTreeWidgetItem* i = currentItem(); 698 QTreeWidgetItem* i = currentItem(); 730 ConfigItem* item; 699 ConfigItem* item; 731 struct menu *menu; 700 struct menu *menu; 732 enum prop_type type; 701 enum prop_type type; 733 702 734 if (ev->key() == Qt::Key_Escape && mod 703 if (ev->key() == Qt::Key_Escape && mode != fullMode && mode != listMode) { 735 emit parentSelected(); 704 emit parentSelected(); 736 ev->accept(); 705 ev->accept(); 737 return; 706 return; 738 } 707 } 739 708 740 if (!i) { 709 if (!i) { 741 Parent::keyPressEvent(ev); 710 Parent::keyPressEvent(ev); 742 return; 711 return; 743 } 712 } 744 item = (ConfigItem*)i; 713 item = (ConfigItem*)i; 745 714 746 switch (ev->key()) { 715 switch (ev->key()) { 747 case Qt::Key_Return: 716 case Qt::Key_Return: 748 case Qt::Key_Enter: 717 case Qt::Key_Enter: 749 if (item->goParent) { 718 if (item->goParent) { 750 emit parentSelected(); 719 emit parentSelected(); 751 break; 720 break; 752 } 721 } 753 menu = item->menu; 722 menu = item->menu; 754 if (!menu) 723 if (!menu) 755 break; 724 break; 756 type = menu->prompt ? menu->pr 725 type = menu->prompt ? menu->prompt->type : P_UNKNOWN; 757 if (type == P_MENU && rootEntr 726 if (type == P_MENU && rootEntry != menu && 758 mode != fullMode && mode ! 727 mode != fullMode && mode != menuMode) { 759 if (mode == menuMode) 728 if (mode == menuMode) 760 emit menuSelec 729 emit menuSelected(menu); 761 else 730 else 762 emit itemSelec 731 emit itemSelected(menu); 763 break; 732 break; 764 } 733 } 765 case Qt::Key_Space: 734 case Qt::Key_Space: 766 changeValue(item); 735 changeValue(item); 767 break; 736 break; 768 case Qt::Key_N: 737 case Qt::Key_N: 769 setValue(item, no); 738 setValue(item, no); 770 break; 739 break; 771 case Qt::Key_M: 740 case Qt::Key_M: 772 setValue(item, mod); 741 setValue(item, mod); 773 break; 742 break; 774 case Qt::Key_Y: 743 case Qt::Key_Y: 775 setValue(item, yes); 744 setValue(item, yes); 776 break; 745 break; 777 default: 746 default: 778 Parent::keyPressEvent(ev); 747 Parent::keyPressEvent(ev); 779 return; 748 return; 780 } 749 } 781 ev->accept(); 750 ev->accept(); 782 } 751 } 783 752 784 void ConfigList::mousePressEvent(QMouseEvent* 753 void ConfigList::mousePressEvent(QMouseEvent* e) 785 { 754 { 786 //QPoint p(contentsToViewport(e->pos() 755 //QPoint p(contentsToViewport(e->pos())); 787 //printf("contentsMousePressEvent: %d, 756 //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); 788 Parent::mousePressEvent(e); 757 Parent::mousePressEvent(e); 789 } 758 } 790 759 791 void ConfigList::mouseReleaseEvent(QMouseEvent 760 void ConfigList::mouseReleaseEvent(QMouseEvent* e) 792 { 761 { 793 QPoint p = e->pos(); 762 QPoint p = e->pos(); 794 ConfigItem* item = (ConfigItem*)itemAt 763 ConfigItem* item = (ConfigItem*)itemAt(p); 795 struct menu *menu; 764 struct menu *menu; 796 enum prop_type ptype; 765 enum prop_type ptype; 797 QIcon icon; 766 QIcon icon; 798 int idx, x; 767 int idx, x; 799 768 800 if (!item) 769 if (!item) 801 goto skip; 770 goto skip; 802 771 803 menu = item->menu; 772 menu = item->menu; 804 x = header()->offset() + p.x(); 773 x = header()->offset() + p.x(); 805 idx = header()->logicalIndexAt(x); 774 idx = header()->logicalIndexAt(x); 806 switch (idx) { 775 switch (idx) { 807 case promptColIdx: 776 case promptColIdx: 808 icon = item->icon(promptColIdx !! 777 icon = item->pixmap(promptColIdx); 809 if (!icon.isNull()) { 778 if (!icon.isNull()) { 810 int off = header()->se 779 int off = header()->sectionPosition(0) + visualRect(indexAt(p)).x() + 4; // 4 is Hardcoded image offset. There might be a way to do it properly. 811 if (x >= off && x < of 780 if (x >= off && x < off + icon.availableSizes().first().width()) { 812 if (item->goPa 781 if (item->goParent) { 813 emit p 782 emit parentSelected(); 814 break; 783 break; 815 } else if (!me 784 } else if (!menu) 816 break; 785 break; 817 ptype = menu-> 786 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; 818 if (ptype == P 787 if (ptype == P_MENU && rootEntry != menu && 819 mode != fu !! 788 mode != fullMode && mode != menuMode) 820 mode != li << 821 emit m 789 emit menuSelected(menu); 822 else 790 else 823 change 791 changeValue(item); 824 } 792 } 825 } 793 } 826 break; 794 break; >> 795 case noColIdx: >> 796 setValue(item, no); >> 797 break; >> 798 case modColIdx: >> 799 setValue(item, mod); >> 800 break; >> 801 case yesColIdx: >> 802 setValue(item, yes); >> 803 break; 827 case dataColIdx: 804 case dataColIdx: 828 changeValue(item); 805 changeValue(item); 829 break; 806 break; 830 } 807 } 831 808 832 skip: 809 skip: 833 //printf("contentsMouseReleaseEvent: % 810 //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); 834 Parent::mouseReleaseEvent(e); 811 Parent::mouseReleaseEvent(e); 835 } 812 } 836 813 837 void ConfigList::mouseMoveEvent(QMouseEvent* e 814 void ConfigList::mouseMoveEvent(QMouseEvent* e) 838 { 815 { 839 //QPoint p(contentsToViewport(e->pos() 816 //QPoint p(contentsToViewport(e->pos())); 840 //printf("contentsMouseMoveEvent: %d,% 817 //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); 841 Parent::mouseMoveEvent(e); 818 Parent::mouseMoveEvent(e); 842 } 819 } 843 820 844 void ConfigList::mouseDoubleClickEvent(QMouseE 821 void ConfigList::mouseDoubleClickEvent(QMouseEvent* e) 845 { 822 { 846 QPoint p = e->pos(); 823 QPoint p = e->pos(); 847 ConfigItem* item = (ConfigItem*)itemAt 824 ConfigItem* item = (ConfigItem*)itemAt(p); 848 struct menu *menu; 825 struct menu *menu; 849 enum prop_type ptype; 826 enum prop_type ptype; 850 827 851 if (!item) 828 if (!item) 852 goto skip; 829 goto skip; 853 if (item->goParent) { 830 if (item->goParent) { 854 emit parentSelected(); 831 emit parentSelected(); 855 goto skip; 832 goto skip; 856 } 833 } 857 menu = item->menu; 834 menu = item->menu; 858 if (!menu) 835 if (!menu) 859 goto skip; 836 goto skip; 860 ptype = menu->prompt ? menu->prompt->t 837 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; 861 if (ptype == P_MENU && mode != listMod !! 838 if (ptype == P_MENU) { 862 if (mode == singleMode) 839 if (mode == singleMode) 863 emit itemSelected(menu 840 emit itemSelected(menu); 864 else if (mode == symbolMode) 841 else if (mode == symbolMode) 865 emit menuSelected(menu 842 emit menuSelected(menu); 866 } else if (menu->sym) 843 } else if (menu->sym) 867 changeValue(item); 844 changeValue(item); 868 845 869 skip: 846 skip: 870 //printf("contentsMouseDoubleClickEven 847 //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); 871 Parent::mouseDoubleClickEvent(e); 848 Parent::mouseDoubleClickEvent(e); 872 } 849 } 873 850 874 void ConfigList::focusInEvent(QFocusEvent *e) 851 void ConfigList::focusInEvent(QFocusEvent *e) 875 { 852 { 876 struct menu *menu = NULL; 853 struct menu *menu = NULL; 877 854 878 Parent::focusInEvent(e); 855 Parent::focusInEvent(e); 879 856 880 ConfigItem* item = (ConfigItem *)curre 857 ConfigItem* item = (ConfigItem *)currentItem(); 881 if (item) { 858 if (item) { 882 setSelected(item, true); 859 setSelected(item, true); 883 menu = item->menu; 860 menu = item->menu; 884 } 861 } 885 emit gotFocus(menu); 862 emit gotFocus(menu); 886 } 863 } 887 864 888 void ConfigList::contextMenuEvent(QContextMenu 865 void ConfigList::contextMenuEvent(QContextMenuEvent *e) 889 { 866 { 890 if (!headerPopup) { 867 if (!headerPopup) { 891 QAction *action; 868 QAction *action; 892 869 893 headerPopup = new QMenu(this); 870 headerPopup = new QMenu(this); 894 action = new QAction("Show Nam 871 action = new QAction("Show Name", this); 895 action->setCheckable(true); 872 action->setCheckable(true); 896 connect(action, &QAction::togg !! 873 connect(action, SIGNAL(toggled(bool)), 897 this, &ConfigList::set !! 874 parent(), SLOT(setShowName(bool))); 898 connect(this, &ConfigList::sho !! 875 connect(parent(), SIGNAL(showNameChanged(bool)), 899 action, &QAction::setC !! 876 action, SLOT(setChecked(bool))); 900 action->setChecked(showName); 877 action->setChecked(showName); 901 headerPopup->addAction(action) 878 headerPopup->addAction(action); >> 879 >> 880 action = new QAction("Show Range", this); >> 881 action->setCheckable(true); >> 882 connect(action, SIGNAL(toggled(bool)), >> 883 parent(), SLOT(setShowRange(bool))); >> 884 connect(parent(), SIGNAL(showRangeChanged(bool)), >> 885 action, SLOT(setChecked(bool))); >> 886 action->setChecked(showRange); >> 887 headerPopup->addAction(action); >> 888 >> 889 action = new QAction("Show Data", this); >> 890 action->setCheckable(true); >> 891 connect(action, SIGNAL(toggled(bool)), >> 892 parent(), SLOT(setShowData(bool))); >> 893 connect(parent(), SIGNAL(showDataChanged(bool)), >> 894 action, SLOT(setChecked(bool))); >> 895 action->setChecked(showData); >> 896 headerPopup->addAction(action); 902 } 897 } 903 898 904 headerPopup->exec(e->globalPos()); 899 headerPopup->exec(e->globalPos()); 905 e->accept(); 900 e->accept(); 906 } 901 } 907 902 908 void ConfigList::setShowName(bool on) !! 903 ConfigView*ConfigView::viewList; >> 904 QAction *ConfigView::showNormalAction; >> 905 QAction *ConfigView::showAllAction; >> 906 QAction *ConfigView::showPromptAction; >> 907 >> 908 ConfigView::ConfigView(QWidget* parent, const char *name) >> 909 : Parent(parent) 909 { 910 { 910 if (showName == on) !! 911 setObjectName(name); 911 return; !! 912 QVBoxLayout *verticalLayout = new QVBoxLayout(this); >> 913 verticalLayout->setContentsMargins(0, 0, 0, 0); 912 914 913 showName = on; !! 915 list = new ConfigList(this); 914 reinit(); !! 916 verticalLayout->addWidget(list); 915 emit showNameChanged(on); !! 917 lineEdit = new ConfigLineEdit(this); >> 918 lineEdit->hide(); >> 919 verticalLayout->addWidget(lineEdit); >> 920 >> 921 this->nextView = viewList; >> 922 viewList = this; 916 } 923 } 917 924 918 QList<ConfigList *> ConfigList::allLists; !! 925 ConfigView::~ConfigView(void) 919 QAction *ConfigList::showNormalAction; !! 926 { 920 QAction *ConfigList::showAllAction; !! 927 ConfigView** vp; 921 QAction *ConfigList::showPromptAction; !! 928 >> 929 for (vp = &viewList; *vp; vp = &(*vp)->nextView) { >> 930 if (*vp == this) { >> 931 *vp = nextView; >> 932 break; >> 933 } >> 934 } >> 935 } >> 936 >> 937 void ConfigView::setOptionMode(QAction *act) >> 938 { >> 939 if (act == showNormalAction) >> 940 list->optMode = normalOpt; >> 941 else if (act == showAllAction) >> 942 list->optMode = allOpt; >> 943 else >> 944 list->optMode = promptOpt; >> 945 >> 946 list->updateListAll(); >> 947 } >> 948 >> 949 void ConfigView::setShowName(bool b) >> 950 { >> 951 if (list->showName != b) { >> 952 list->showName = b; >> 953 list->reinit(); >> 954 emit showNameChanged(b); >> 955 } >> 956 } >> 957 >> 958 void ConfigView::setShowRange(bool b) >> 959 { >> 960 if (list->showRange != b) { >> 961 list->showRange = b; >> 962 list->reinit(); >> 963 emit showRangeChanged(b); >> 964 } >> 965 } >> 966 >> 967 void ConfigView::setShowData(bool b) >> 968 { >> 969 if (list->showData != b) { >> 970 list->showData = b; >> 971 list->reinit(); >> 972 emit showDataChanged(b); >> 973 } >> 974 } 922 975 923 void ConfigList::setAllOpen(bool open) 976 void ConfigList::setAllOpen(bool open) 924 { 977 { 925 QTreeWidgetItemIterator it(this); 978 QTreeWidgetItemIterator it(this); 926 979 927 while (*it) { 980 while (*it) { 928 (*it)->setExpanded(open); 981 (*it)->setExpanded(open); 929 982 930 ++it; 983 ++it; 931 } 984 } 932 } 985 } 933 986 >> 987 void ConfigView::updateList(ConfigItem* item) >> 988 { >> 989 ConfigView* v; >> 990 >> 991 for (v = viewList; v; v = v->nextView) >> 992 v->list->updateList(item); >> 993 } >> 994 >> 995 void ConfigView::updateListAll(void) >> 996 { >> 997 ConfigView* v; >> 998 >> 999 for (v = viewList; v; v = v->nextView) >> 1000 v->list->updateListAll(); >> 1001 } >> 1002 934 ConfigInfoView::ConfigInfoView(QWidget* parent 1003 ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) 935 : Parent(parent), sym(0), _menu(0) 1004 : Parent(parent), sym(0), _menu(0) 936 { 1005 { 937 setObjectName(name); 1006 setObjectName(name); 938 setOpenLinks(false); 1007 setOpenLinks(false); 939 1008 940 if (!objectName().isEmpty()) { 1009 if (!objectName().isEmpty()) { 941 configSettings->beginGroup(obj 1010 configSettings->beginGroup(objectName()); 942 setShowDebug(configSettings->v 1011 setShowDebug(configSettings->value("/showDebug", false).toBool()); 943 configSettings->endGroup(); 1012 configSettings->endGroup(); 944 connect(configApp, &QApplicati !! 1013 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); 945 this, &ConfigInfoView: << 946 } 1014 } 947 << 948 contextMenu = createStandardContextMen << 949 QAction *action = new QAction("Show De << 950 << 951 action->setCheckable(true); << 952 connect(action, &QAction::toggled, << 953 this, &ConfigInfoView::setShow << 954 connect(this, &ConfigInfoView::showDeb << 955 action, &QAction::setChecked); << 956 action->setChecked(showDebug()); << 957 contextMenu->addSeparator(); << 958 contextMenu->addAction(action); << 959 } 1015 } 960 1016 961 void ConfigInfoView::saveSettings(void) 1017 void ConfigInfoView::saveSettings(void) 962 { 1018 { 963 if (!objectName().isEmpty()) { 1019 if (!objectName().isEmpty()) { 964 configSettings->beginGroup(obj 1020 configSettings->beginGroup(objectName()); 965 configSettings->setValue("/sho 1021 configSettings->setValue("/showDebug", showDebug()); 966 configSettings->endGroup(); 1022 configSettings->endGroup(); 967 } 1023 } 968 } 1024 } 969 1025 970 void ConfigInfoView::setShowDebug(bool b) 1026 void ConfigInfoView::setShowDebug(bool b) 971 { 1027 { 972 if (_showDebug != b) { 1028 if (_showDebug != b) { 973 _showDebug = b; 1029 _showDebug = b; 974 if (_menu) 1030 if (_menu) 975 menuInfo(); 1031 menuInfo(); 976 else if (sym) 1032 else if (sym) 977 symbolInfo(); 1033 symbolInfo(); 978 emit showDebugChanged(b); 1034 emit showDebugChanged(b); 979 } 1035 } 980 } 1036 } 981 1037 982 void ConfigInfoView::setInfo(struct menu *m) 1038 void ConfigInfoView::setInfo(struct menu *m) 983 { 1039 { 984 if (_menu == m) 1040 if (_menu == m) 985 return; 1041 return; 986 _menu = m; 1042 _menu = m; 987 sym = NULL; 1043 sym = NULL; 988 if (!_menu) 1044 if (!_menu) 989 clear(); 1045 clear(); 990 else 1046 else 991 menuInfo(); 1047 menuInfo(); 992 } 1048 } 993 1049 994 void ConfigInfoView::symbolInfo(void) 1050 void ConfigInfoView::symbolInfo(void) 995 { 1051 { 996 QString str; 1052 QString str; 997 1053 998 str += "<big>Symbol: <b>"; 1054 str += "<big>Symbol: <b>"; 999 str += print_filter(sym->name); 1055 str += print_filter(sym->name); 1000 str += "</b></big><br><br>value: "; 1056 str += "</b></big><br><br>value: "; 1001 str += print_filter(sym_get_string_va 1057 str += print_filter(sym_get_string_value(sym)); 1002 str += "<br>visibility: "; 1058 str += "<br>visibility: "; 1003 str += sym->visible == yes ? "y" : sy 1059 str += sym->visible == yes ? "y" : sym->visible == mod ? "m" : "n"; 1004 str += "<br>"; 1060 str += "<br>"; 1005 str += debug_info(sym); 1061 str += debug_info(sym); 1006 1062 1007 setText(str); 1063 setText(str); 1008 } 1064 } 1009 1065 1010 void ConfigInfoView::menuInfo(void) 1066 void ConfigInfoView::menuInfo(void) 1011 { 1067 { 1012 struct symbol* sym; 1068 struct symbol* sym; 1013 QString info; !! 1069 QString head, debug, help; 1014 QTextStream stream(&info); << 1015 1070 1016 sym = _menu->sym; 1071 sym = _menu->sym; 1017 if (sym) { 1072 if (sym) { 1018 if (_menu->prompt) { 1073 if (_menu->prompt) { 1019 stream << "<big><b>"; !! 1074 head += "<big><b>"; 1020 stream << print_filte !! 1075 head += print_filter(_menu->prompt->text); 1021 stream << "</b></big> !! 1076 head += "</b></big>"; 1022 if (sym->name) { 1077 if (sym->name) { 1023 stream << " ( !! 1078 head += " ("; 1024 if (showDebug 1079 if (showDebug()) 1025 strea !! 1080 head += QString().sprintf("<a href=\"s%s\">", sym->name); 1026 stream << pri !! 1081 head += print_filter(sym->name); 1027 if (showDebug 1082 if (showDebug()) 1028 strea !! 1083 head += "</a>"; 1029 stream << ")" !! 1084 head += ")"; 1030 } 1085 } 1031 } else if (sym->name) { 1086 } else if (sym->name) { 1032 stream << "<big><b>"; !! 1087 head += "<big><b>"; 1033 if (showDebug()) 1088 if (showDebug()) 1034 stream << "<a !! 1089 head += QString().sprintf("<a href=\"s%s\">", sym->name); 1035 stream << print_filte !! 1090 head += print_filter(sym->name); 1036 if (showDebug()) 1091 if (showDebug()) 1037 stream << "</ !! 1092 head += "</a>"; 1038 stream << "</b></big> !! 1093 head += "</b></big>"; 1039 } 1094 } 1040 stream << "<br><br>"; !! 1095 head += "<br><br>"; 1041 1096 1042 if (showDebug()) 1097 if (showDebug()) 1043 stream << debug_info( !! 1098 debug = debug_info(sym); 1044 1099 1045 struct gstr help_gstr = str_n 1100 struct gstr help_gstr = str_new(); 1046 << 1047 menu_get_ext_help(_menu, &hel 1101 menu_get_ext_help(_menu, &help_gstr); 1048 stream << print_filter(str_ge !! 1102 help = print_filter(str_get(&help_gstr)); 1049 str_free(&help_gstr); 1103 str_free(&help_gstr); 1050 } else if (_menu->prompt) { 1104 } else if (_menu->prompt) { 1051 stream << "<big><b>"; !! 1105 head += "<big><b>"; 1052 stream << print_filter(_menu- !! 1106 head += print_filter(_menu->prompt->text); 1053 stream << "</b></big><br><br> !! 1107 head += "</b></big><br><br>"; 1054 if (showDebug()) { 1108 if (showDebug()) { 1055 if (_menu->prompt->vi 1109 if (_menu->prompt->visible.expr) { 1056 stream << "&n !! 1110 debug += " dep: "; 1057 expr_print(_m !! 1111 expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); 1058 ex !! 1112 debug += "<br><br>"; 1059 stream << "<b << 1060 } 1113 } 1061 << 1062 stream << "defined at << 1063 << _menu->line << 1064 } 1114 } 1065 } 1115 } >> 1116 if (showDebug()) >> 1117 debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno); 1066 1118 1067 setText(info); !! 1119 setText(head + debug + help); 1068 } 1120 } 1069 1121 1070 QString ConfigInfoView::debug_info(struct sym 1122 QString ConfigInfoView::debug_info(struct symbol *sym) 1071 { 1123 { 1072 QString debug; 1124 QString debug; 1073 QTextStream stream(&debug); << 1074 1125 1075 stream << "type: "; !! 1126 debug += "type: "; 1076 stream << print_filter(sym_type_name( !! 1127 debug += print_filter(sym_type_name(sym->type)); 1077 if (sym_is_choice(sym)) 1128 if (sym_is_choice(sym)) 1078 stream << " (choice)"; !! 1129 debug += " (choice)"; 1079 debug += "<br>"; 1130 debug += "<br>"; 1080 if (sym->rev_dep.expr) { 1131 if (sym->rev_dep.expr) { 1081 stream << "reverse dep: "; !! 1132 debug += "reverse dep: "; 1082 expr_print(sym->rev_dep.expr, !! 1133 expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); 1083 stream << "<br>"; !! 1134 debug += "<br>"; 1084 } 1135 } 1085 for (struct property *prop = sym->pro 1136 for (struct property *prop = sym->prop; prop; prop = prop->next) { 1086 switch (prop->type) { 1137 switch (prop->type) { 1087 case P_PROMPT: 1138 case P_PROMPT: 1088 case P_MENU: 1139 case P_MENU: 1089 stream << "prompt: <a !! 1140 debug += QString().sprintf("prompt: <a href=\"m%s\">", sym->name); 1090 stream << print_filte !! 1141 debug += print_filter(prop->text); 1091 stream << "</a><br>"; !! 1142 debug += "</a><br>"; 1092 break; 1143 break; 1093 case P_DEFAULT: 1144 case P_DEFAULT: 1094 case P_SELECT: 1145 case P_SELECT: 1095 case P_RANGE: 1146 case P_RANGE: 1096 case P_COMMENT: 1147 case P_COMMENT: 1097 case P_IMPLY: 1148 case P_IMPLY: 1098 stream << prop_get_ty !! 1149 case P_SYMBOL: 1099 stream << ": "; !! 1150 debug += prop_get_type_name(prop->type); 1100 expr_print(prop->expr !! 1151 debug += ": "; 1101 &stream, E !! 1152 expr_print(prop->expr, expr_print_help, &debug, E_NONE); 1102 stream << "<br>"; !! 1153 debug += "<br>"; >> 1154 break; >> 1155 case P_CHOICE: >> 1156 if (sym_is_choice(sym)) { >> 1157 debug += "choice: "; >> 1158 expr_print(prop->expr, expr_print_help, &debug, E_NONE); >> 1159 debug += "<br>"; >> 1160 } 1103 break; 1161 break; 1104 default: 1162 default: 1105 stream << "unknown pr !! 1163 debug += "unknown property: "; 1106 stream << prop_get_ty !! 1164 debug += prop_get_type_name(prop->type); 1107 stream << "<br>"; !! 1165 debug += "<br>"; 1108 } 1166 } 1109 if (prop->visible.expr) { 1167 if (prop->visible.expr) { 1110 stream << " &nbs !! 1168 debug += " dep: "; 1111 expr_print(prop->visi !! 1169 expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); 1112 &stream, E !! 1170 debug += "<br>"; 1113 stream << "<br>"; << 1114 } 1171 } 1115 } 1172 } 1116 stream << "<br>"; !! 1173 debug += "<br>"; 1117 1174 1118 return debug; 1175 return debug; 1119 } 1176 } 1120 1177 1121 QString ConfigInfoView::print_filter(const QS 1178 QString ConfigInfoView::print_filter(const QString &str) 1122 { 1179 { 1123 QRegularExpression re("[<>&\"\\n]"); !! 1180 QRegExp re("[<>&\"\\n]"); 1124 QString res = str; 1181 QString res = str; 1125 for (int i = 0; (i = res.indexOf(re, 1182 for (int i = 0; (i = res.indexOf(re, i)) >= 0;) { 1126 switch (res[i].toLatin1()) { 1183 switch (res[i].toLatin1()) { 1127 case '<': 1184 case '<': 1128 res.replace(i, 1, "&l 1185 res.replace(i, 1, "<"); 1129 i += 4; 1186 i += 4; 1130 break; 1187 break; 1131 case '>': 1188 case '>': 1132 res.replace(i, 1, "&g 1189 res.replace(i, 1, ">"); 1133 i += 4; 1190 i += 4; 1134 break; 1191 break; 1135 case '&': 1192 case '&': 1136 res.replace(i, 1, "&a 1193 res.replace(i, 1, "&"); 1137 i += 5; 1194 i += 5; 1138 break; 1195 break; 1139 case '"': 1196 case '"': 1140 res.replace(i, 1, "&q 1197 res.replace(i, 1, """); 1141 i += 6; 1198 i += 6; 1142 break; 1199 break; 1143 case '\n': 1200 case '\n': 1144 res.replace(i, 1, "<b 1201 res.replace(i, 1, "<br>"); 1145 i += 4; 1202 i += 4; 1146 break; 1203 break; 1147 } 1204 } 1148 } 1205 } 1149 return res; 1206 return res; 1150 } 1207 } 1151 1208 1152 void ConfigInfoView::expr_print_help(void *da 1209 void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str) 1153 { 1210 { 1154 QTextStream *stream = reinterpret_cas !! 1211 QString* text = reinterpret_cast<QString*>(data); >> 1212 QString str2 = print_filter(str); 1155 1213 1156 if (sym && sym->name && !(sym->flags 1214 if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) { 1157 *stream << "<a href=\"s" << s !! 1215 *text += QString().sprintf("<a href=\"s%s\">", sym->name); 1158 *stream << print_filter(str); !! 1216 *text += str2; 1159 *stream << "</a>"; !! 1217 *text += "</a>"; 1160 } else { !! 1218 } else 1161 *stream << print_filter(str); !! 1219 *text += str2; 1162 } << 1163 } 1220 } 1164 1221 1165 void ConfigInfoView::clicked(const QUrl &url) 1222 void ConfigInfoView::clicked(const QUrl &url) 1166 { 1223 { 1167 QByteArray str = url.toEncoded(); 1224 QByteArray str = url.toEncoded(); 1168 const std::size_t count = str.size(); 1225 const std::size_t count = str.size(); 1169 char *data = new char[count + 2]; // !! 1226 char *data = new char[count + 1]; 1170 struct symbol **result; 1227 struct symbol **result; 1171 struct menu *m = NULL; 1228 struct menu *m = NULL; 1172 1229 1173 if (count < 1) { 1230 if (count < 1) { 1174 delete[] data; 1231 delete[] data; 1175 return; 1232 return; 1176 } 1233 } 1177 1234 1178 memcpy(data, str.constData(), count); 1235 memcpy(data, str.constData(), count); 1179 data[count] = '\0'; 1236 data[count] = '\0'; 1180 1237 1181 /* Seek for exact match */ 1238 /* Seek for exact match */ 1182 data[0] = '^'; 1239 data[0] = '^'; 1183 strcat(data, "$"); 1240 strcat(data, "$"); 1184 result = sym_re_search(data); 1241 result = sym_re_search(data); 1185 if (!result) { 1242 if (!result) { 1186 delete[] data; 1243 delete[] data; 1187 return; 1244 return; 1188 } 1245 } 1189 1246 1190 sym = *result; 1247 sym = *result; 1191 1248 1192 /* Seek for the menu which holds the 1249 /* Seek for the menu which holds the symbol */ 1193 for (struct property *prop = sym->pro 1250 for (struct property *prop = sym->prop; prop; prop = prop->next) { 1194 if (prop->type != P_PROMP 1251 if (prop->type != P_PROMPT && prop->type != P_MENU) 1195 continue; 1252 continue; 1196 m = prop->menu; 1253 m = prop->menu; 1197 break; 1254 break; 1198 } 1255 } 1199 1256 1200 if (!m) { 1257 if (!m) { 1201 /* Symbol is not visible as a 1258 /* Symbol is not visible as a menu */ 1202 symbolInfo(); 1259 symbolInfo(); 1203 emit showDebugChanged(true); 1260 emit showDebugChanged(true); 1204 } else { 1261 } else { 1205 emit menuSelected(m); 1262 emit menuSelected(m); 1206 } 1263 } 1207 1264 1208 free(result); 1265 free(result); 1209 delete[] data; 1266 delete[] data; 1210 } 1267 } 1211 1268 1212 void ConfigInfoView::contextMenuEvent(QContex !! 1269 QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos) >> 1270 { >> 1271 QMenu* popup = Parent::createStandardContextMenu(pos); >> 1272 QAction* action = new QAction("Show Debug Info", popup); >> 1273 >> 1274 action->setCheckable(true); >> 1275 connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); >> 1276 connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setChecked(bool))); >> 1277 action->setChecked(showDebug()); >> 1278 popup->addSeparator(); >> 1279 popup->addAction(action); >> 1280 return popup; >> 1281 } >> 1282 >> 1283 void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e) 1213 { 1284 { 1214 contextMenu->popup(event->globalPos() !! 1285 Parent::contextMenuEvent(e); 1215 event->accept(); << 1216 } 1286 } 1217 1287 1218 ConfigSearchWindow::ConfigSearchWindow(Config !! 1288 ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name) 1219 : Parent(parent), result(NULL) 1289 : Parent(parent), result(NULL) 1220 { 1290 { 1221 setObjectName("search"); !! 1291 setObjectName(name); 1222 setWindowTitle("Search Config"); 1292 setWindowTitle("Search Config"); 1223 1293 1224 QVBoxLayout* layout1 = new QVBoxLayou 1294 QVBoxLayout* layout1 = new QVBoxLayout(this); 1225 layout1->setContentsMargins(11, 11, 1 1295 layout1->setContentsMargins(11, 11, 11, 11); 1226 layout1->setSpacing(6); 1296 layout1->setSpacing(6); 1227 !! 1297 QHBoxLayout* layout2 = new QHBoxLayout(0); 1228 QHBoxLayout* layout2 = new QHBoxLayou << 1229 layout2->setContentsMargins(0, 0, 0, 1298 layout2->setContentsMargins(0, 0, 0, 0); 1230 layout2->setSpacing(6); 1299 layout2->setSpacing(6); 1231 layout2->addWidget(new QLabel("Find:" 1300 layout2->addWidget(new QLabel("Find:", this)); 1232 editField = new QLineEdit(this); 1301 editField = new QLineEdit(this); 1233 connect(editField, &QLineEdit::return !! 1302 connect(editField, SIGNAL(returnPressed()), SLOT(search())); 1234 this, &ConfigSearchWindow::se << 1235 layout2->addWidget(editField); 1303 layout2->addWidget(editField); 1236 searchButton = new QPushButton("Searc 1304 searchButton = new QPushButton("Search", this); 1237 searchButton->setAutoDefault(false); 1305 searchButton->setAutoDefault(false); 1238 connect(searchButton, &QPushButton::c !! 1306 connect(searchButton, SIGNAL(clicked()), SLOT(search())); 1239 this, &ConfigSearchWindow::se << 1240 layout2->addWidget(searchButton); 1307 layout2->addWidget(searchButton); 1241 layout1->addLayout(layout2); 1308 layout1->addLayout(layout2); 1242 1309 1243 split = new QSplitter(this); 1310 split = new QSplitter(this); 1244 split->setOrientation(Qt::Vertical); 1311 split->setOrientation(Qt::Vertical); 1245 list = new ConfigList(split, "search" !! 1312 list = new ConfigView(split, name); 1246 list->mode = listMode; !! 1313 list->list->mode = listMode; 1247 info = new ConfigInfoView(split, "sea !! 1314 info = new ConfigInfoView(split, name); 1248 connect(list, &ConfigList::menuChange !! 1315 connect(list->list, SIGNAL(menuChanged(struct menu *)), 1249 info, &ConfigInfoView::setInf !! 1316 info, SLOT(setInfo(struct menu *))); 1250 connect(list, &ConfigList::menuChange !! 1317 connect(list->list, SIGNAL(menuChanged(struct menu *)), 1251 parent, &ConfigMainWindow::se !! 1318 parent, SLOT(setMenuLink(struct menu *))); 1252 1319 1253 layout1->addWidget(split); 1320 layout1->addWidget(split); 1254 1321 1255 QVariant x, y; !! 1322 if (name) { 1256 int width, height; !! 1323 QVariant x, y; 1257 bool ok; !! 1324 int width, height; >> 1325 bool ok; 1258 1326 1259 configSettings->beginGroup("search"); !! 1327 configSettings->beginGroup(name); 1260 width = configSettings->value("/windo !! 1328 width = configSettings->value("/window width", parent->width() / 2).toInt(); 1261 height = configSettings->value("/wind !! 1329 height = configSettings->value("/window height", parent->height() / 2).toInt(); 1262 resize(width, height); !! 1330 resize(width, height); 1263 x = configSettings->value("/window x" !! 1331 x = configSettings->value("/window x"); 1264 y = configSettings->value("/window y" !! 1332 y = configSettings->value("/window y"); 1265 if (x.isValid() && y.isValid()) !! 1333 if ((x.isValid())&&(y.isValid())) 1266 move(x.toInt(), y.toInt()); !! 1334 move(x.toInt(), y.toInt()); 1267 QList<int> sizes = configSettings->re !! 1335 QList<int> sizes = configSettings->readSizes("/split", &ok); 1268 if (ok) !! 1336 if (ok) 1269 split->setSizes(sizes); !! 1337 split->setSizes(sizes); 1270 configSettings->endGroup(); !! 1338 configSettings->endGroup(); 1271 connect(configApp, &QApplication::abo !! 1339 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); 1272 this, &ConfigSearchWindow::sa !! 1340 } 1273 } 1341 } 1274 1342 1275 void ConfigSearchWindow::saveSettings(void) 1343 void ConfigSearchWindow::saveSettings(void) 1276 { 1344 { 1277 if (!objectName().isEmpty()) { 1345 if (!objectName().isEmpty()) { 1278 configSettings->beginGroup(ob 1346 configSettings->beginGroup(objectName()); 1279 configSettings->setValue("/wi 1347 configSettings->setValue("/window x", pos().x()); 1280 configSettings->setValue("/wi 1348 configSettings->setValue("/window y", pos().y()); 1281 configSettings->setValue("/wi 1349 configSettings->setValue("/window width", size().width()); 1282 configSettings->setValue("/wi 1350 configSettings->setValue("/window height", size().height()); 1283 configSettings->writeSizes("/ 1351 configSettings->writeSizes("/split", split->sizes()); 1284 configSettings->endGroup(); 1352 configSettings->endGroup(); 1285 } 1353 } 1286 } 1354 } 1287 1355 1288 void ConfigSearchWindow::search(void) 1356 void ConfigSearchWindow::search(void) 1289 { 1357 { 1290 struct symbol **p; 1358 struct symbol **p; 1291 struct property *prop; 1359 struct property *prop; 1292 ConfigItem *lastItem = NULL; 1360 ConfigItem *lastItem = NULL; 1293 1361 1294 free(result); 1362 free(result); 1295 list->clear(); !! 1363 list->list->clear(); 1296 info->clear(); 1364 info->clear(); 1297 1365 1298 result = sym_re_search(editField->tex 1366 result = sym_re_search(editField->text().toLatin1()); 1299 if (!result) 1367 if (!result) 1300 return; 1368 return; 1301 for (p = result; *p; p++) { 1369 for (p = result; *p; p++) { 1302 for_all_prompts((*p), prop) 1370 for_all_prompts((*p), prop) 1303 lastItem = new Config !! 1371 lastItem = new ConfigItem(list->list, lastItem, prop->menu, 1304 1372 menu_is_visible(prop->menu)); 1305 } 1373 } 1306 } 1374 } 1307 1375 1308 /* 1376 /* 1309 * Construct the complete config widget 1377 * Construct the complete config widget 1310 */ 1378 */ 1311 ConfigMainWindow::ConfigMainWindow(void) 1379 ConfigMainWindow::ConfigMainWindow(void) 1312 : searchWindow(0) 1380 : searchWindow(0) 1313 { 1381 { >> 1382 QMenuBar* menu; 1314 bool ok = true; 1383 bool ok = true; 1315 QVariant x, y; 1384 QVariant x, y; 1316 int width, height; 1385 int width, height; 1317 char title[256]; 1386 char title[256]; 1318 1387 >> 1388 QDesktopWidget *d = configApp->desktop(); 1319 snprintf(title, sizeof(title), "%s%s" 1389 snprintf(title, sizeof(title), "%s%s", 1320 rootmenu.prompt->text, 1390 rootmenu.prompt->text, 1321 "" 1391 "" 1322 ); 1392 ); 1323 setWindowTitle(title); 1393 setWindowTitle(title); 1324 1394 1325 QRect g = configApp->primaryScreen()- !! 1395 width = configSettings->value("/window width", d->width() - 64).toInt(); 1326 width = configSettings->value("/windo !! 1396 height = configSettings->value("/window height", d->height() - 64).toInt(); 1327 height = configSettings->value("/wind << 1328 resize(width, height); 1397 resize(width, height); 1329 x = configSettings->value("/window x" 1398 x = configSettings->value("/window x"); 1330 y = configSettings->value("/window y" 1399 y = configSettings->value("/window y"); 1331 if ((x.isValid())&&(y.isValid())) 1400 if ((x.isValid())&&(y.isValid())) 1332 move(x.toInt(), y.toInt()); 1401 move(x.toInt(), y.toInt()); 1333 1402 1334 // set up icons << 1335 ConfigItem::symbolYesIcon = QIcon(QPi << 1336 ConfigItem::symbolModIcon = QIcon(QPi << 1337 ConfigItem::symbolNoIcon = QIcon(QPix << 1338 ConfigItem::choiceYesIcon = QIcon(QPi << 1339 ConfigItem::choiceNoIcon = QIcon(QPix << 1340 ConfigItem::menuIcon = QIcon(QPixmap( << 1341 ConfigItem::menubackIcon = QIcon(QPix << 1342 << 1343 QWidget *widget = new QWidget(this); 1403 QWidget *widget = new QWidget(this); 1344 QVBoxLayout *layout = new QVBoxLayout 1404 QVBoxLayout *layout = new QVBoxLayout(widget); 1345 setCentralWidget(widget); 1405 setCentralWidget(widget); 1346 1406 1347 split1 = new QSplitter(widget); 1407 split1 = new QSplitter(widget); 1348 split1->setOrientation(Qt::Horizontal 1408 split1->setOrientation(Qt::Horizontal); 1349 split1->setChildrenCollapsible(false) 1409 split1->setChildrenCollapsible(false); 1350 1410 1351 menuList = new ConfigList(widget, "me !! 1411 menuView = new ConfigView(widget, "menu"); >> 1412 menuList = menuView->list; 1352 1413 1353 split2 = new QSplitter(widget); 1414 split2 = new QSplitter(widget); 1354 split2->setChildrenCollapsible(false) 1415 split2->setChildrenCollapsible(false); 1355 split2->setOrientation(Qt::Vertical); 1416 split2->setOrientation(Qt::Vertical); 1356 1417 1357 // create config tree 1418 // create config tree 1358 configList = new ConfigList(widget, " !! 1419 configView = new ConfigView(widget, "config"); >> 1420 configList = configView->list; 1359 1421 1360 helpText = new ConfigInfoView(widget, 1422 helpText = new ConfigInfoView(widget, "help"); 1361 1423 1362 layout->addWidget(split2); 1424 layout->addWidget(split2); 1363 split2->addWidget(split1); 1425 split2->addWidget(split1); 1364 split1->addWidget(configList); !! 1426 split1->addWidget(configView); 1365 split1->addWidget(menuList); !! 1427 split1->addWidget(menuView); 1366 split2->addWidget(helpText); 1428 split2->addWidget(helpText); 1367 1429 1368 setTabOrder(configList, helpText); 1430 setTabOrder(configList, helpText); 1369 configList->setFocus(); 1431 configList->setFocus(); 1370 1432 >> 1433 menu = menuBar(); >> 1434 toolBar = new QToolBar("Tools", this); >> 1435 addToolBar(toolBar); >> 1436 1371 backAction = new QAction(QPixmap(xpm_ 1437 backAction = new QAction(QPixmap(xpm_back), "Back", this); 1372 connect(backAction, &QAction::trigger !! 1438 connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack())); 1373 this, &ConfigMainWindow::goBa << 1374 1439 1375 QAction *quitAction = new QAction("&Q 1440 QAction *quitAction = new QAction("&Quit", this); 1376 quitAction->setShortcut(Qt::CTRL | Qt !! 1441 quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); 1377 connect(quitAction, &QAction::trigger !! 1442 connect(quitAction, SIGNAL(triggered(bool)), SLOT(close())); 1378 this, &ConfigMainWindow::clos << 1379 1443 1380 QAction *loadAction = new QAction(QPi 1444 QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this); 1381 loadAction->setShortcut(Qt::CTRL | Qt !! 1445 loadAction->setShortcut(Qt::CTRL + Qt::Key_L); 1382 connect(loadAction, &QAction::trigger !! 1446 connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig())); 1383 this, &ConfigMainWindow::load << 1384 1447 1385 saveAction = new QAction(QPixmap(xpm_ 1448 saveAction = new QAction(QPixmap(xpm_save), "&Save", this); 1386 saveAction->setShortcut(Qt::CTRL | Qt !! 1449 saveAction->setShortcut(Qt::CTRL + Qt::Key_S); 1387 connect(saveAction, &QAction::trigger !! 1450 connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig())); 1388 this, &ConfigMainWindow::save << 1389 1451 1390 conf_set_changed_callback(conf_change 1452 conf_set_changed_callback(conf_changed); 1391 1453 >> 1454 // Set saveAction's initial state >> 1455 conf_changed(); 1392 configname = xstrdup(conf_get_confign 1456 configname = xstrdup(conf_get_configname()); 1393 1457 1394 QAction *saveAsAction = new QAction(" 1458 QAction *saveAsAction = new QAction("Save &As...", this); 1395 connect(saveAsAction, &QAction::trigg !! 1459 connect(saveAsAction, SIGNAL(triggered(bool)), SLOT(saveConfigAs())); 1396 this, &ConfigMainWindow::save << 1397 QAction *searchAction = new QAction(" 1460 QAction *searchAction = new QAction("&Find", this); 1398 searchAction->setShortcut(Qt::CTRL | !! 1461 searchAction->setShortcut(Qt::CTRL + Qt::Key_F); 1399 connect(searchAction, &QAction::trigg !! 1462 connect(searchAction, SIGNAL(triggered(bool)), SLOT(searchConfig())); 1400 this, &ConfigMainWindow::sear << 1401 singleViewAction = new QAction(QPixma 1463 singleViewAction = new QAction(QPixmap(xpm_single_view), "Single View", this); 1402 singleViewAction->setCheckable(true); 1464 singleViewAction->setCheckable(true); 1403 connect(singleViewAction, &QAction::t !! 1465 connect(singleViewAction, SIGNAL(triggered(bool)), SLOT(showSingleView())); 1404 this, &ConfigMainWindow::show << 1405 splitViewAction = new QAction(QPixmap 1466 splitViewAction = new QAction(QPixmap(xpm_split_view), "Split View", this); 1406 splitViewAction->setCheckable(true); 1467 splitViewAction->setCheckable(true); 1407 connect(splitViewAction, &QAction::tr !! 1468 connect(splitViewAction, SIGNAL(triggered(bool)), SLOT(showSplitView())); 1408 this, &ConfigMainWindow::show << 1409 fullViewAction = new QAction(QPixmap( 1469 fullViewAction = new QAction(QPixmap(xpm_tree_view), "Full View", this); 1410 fullViewAction->setCheckable(true); 1470 fullViewAction->setCheckable(true); 1411 connect(fullViewAction, &QAction::tri !! 1471 connect(fullViewAction, SIGNAL(triggered(bool)), SLOT(showFullView())); 1412 this, &ConfigMainWindow::show << 1413 1472 1414 QAction *showNameAction = new QAction 1473 QAction *showNameAction = new QAction("Show Name", this); 1415 showNameAction->setCheckable(true); 1474 showNameAction->setCheckable(true); 1416 connect(showNameAction, &QAction::tog !! 1475 connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool))); 1417 configList, &ConfigList::setS !! 1476 showNameAction->setChecked(configView->showName()); 1418 showNameAction->setChecked(configList !! 1477 QAction *showRangeAction = new QAction("Show Range", this); >> 1478 showRangeAction->setCheckable(true); >> 1479 connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); >> 1480 QAction *showDataAction = new QAction("Show Data", this); >> 1481 showDataAction->setCheckable(true); >> 1482 connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); 1419 1483 1420 QActionGroup *optGroup = new QActionG 1484 QActionGroup *optGroup = new QActionGroup(this); 1421 optGroup->setExclusive(true); 1485 optGroup->setExclusive(true); 1422 connect(optGroup, &QActionGroup::trig !! 1486 connect(optGroup, SIGNAL(triggered(QAction*)), configView, 1423 configList, &ConfigList::setO !! 1487 SLOT(setOptionMode(QAction *))); 1424 connect(optGroup, &QActionGroup::trig !! 1488 connect(optGroup, SIGNAL(triggered(QAction *)), menuView, 1425 menuList, &ConfigList::setOpt !! 1489 SLOT(setOptionMode(QAction *))); 1426 !! 1490 1427 ConfigList::showNormalAction = new QA !! 1491 configView->showNormalAction = new QAction("Show Normal Options", optGroup); 1428 ConfigList::showNormalAction->setChec !! 1492 configView->showAllAction = new QAction("Show All Options", optGroup); 1429 ConfigList::showAllAction = new QActi !! 1493 configView->showPromptAction = new QAction("Show Prompt Options", optGroup); 1430 ConfigList::showAllAction->setCheckab !! 1494 configView->showNormalAction->setCheckable(true); 1431 ConfigList::showPromptAction = new QA !! 1495 configView->showAllAction->setCheckable(true); 1432 ConfigList::showPromptAction->setChec !! 1496 configView->showPromptAction->setCheckable(true); 1433 1497 1434 QAction *showDebugAction = new QActio 1498 QAction *showDebugAction = new QAction("Show Debug Info", this); 1435 showDebugAction->setCheckable(true) 1499 showDebugAction->setCheckable(true); 1436 connect(showDebugAction, &QAction::to !! 1500 connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); 1437 helpText, &ConfigInfoView::se << 1438 showDebugAction->setChecked(helpTex 1501 showDebugAction->setChecked(helpText->showDebug()); 1439 1502 1440 QAction *showIntroAction = new QActio 1503 QAction *showIntroAction = new QAction("Introduction", this); 1441 connect(showIntroAction, &QAction::tr !! 1504 connect(showIntroAction, SIGNAL(triggered(bool)), SLOT(showIntro())); 1442 this, &ConfigMainWindow::show << 1443 QAction *showAboutAction = new QActio 1505 QAction *showAboutAction = new QAction("About", this); 1444 connect(showAboutAction, &QAction::tr !! 1506 connect(showAboutAction, SIGNAL(triggered(bool)), SLOT(showAbout())); 1445 this, &ConfigMainWindow::show << 1446 1507 1447 // init tool bar 1508 // init tool bar 1448 QToolBar *toolBar = addToolBar("Tools << 1449 toolBar->addAction(backAction); 1509 toolBar->addAction(backAction); 1450 toolBar->addSeparator(); 1510 toolBar->addSeparator(); 1451 toolBar->addAction(loadAction); 1511 toolBar->addAction(loadAction); 1452 toolBar->addAction(saveAction); 1512 toolBar->addAction(saveAction); 1453 toolBar->addSeparator(); 1513 toolBar->addSeparator(); 1454 toolBar->addAction(singleViewAction); 1514 toolBar->addAction(singleViewAction); 1455 toolBar->addAction(splitViewAction); 1515 toolBar->addAction(splitViewAction); 1456 toolBar->addAction(fullViewAction); 1516 toolBar->addAction(fullViewAction); 1457 1517 1458 // create file menu !! 1518 // create config menu 1459 QMenu *menu = menuBar()->addMenu("&Fi !! 1519 QMenu* config = menu->addMenu("&File"); 1460 menu->addAction(loadAction); !! 1520 config->addAction(loadAction); 1461 menu->addAction(saveAction); !! 1521 config->addAction(saveAction); 1462 menu->addAction(saveAsAction); !! 1522 config->addAction(saveAsAction); 1463 menu->addSeparator(); !! 1523 config->addSeparator(); 1464 menu->addAction(quitAction); !! 1524 config->addAction(quitAction); 1465 1525 1466 // create edit menu 1526 // create edit menu 1467 menu = menuBar()->addMenu("&Edit"); !! 1527 QMenu* editMenu = menu->addMenu("&Edit"); 1468 menu->addAction(searchAction); !! 1528 editMenu->addAction(searchAction); 1469 1529 1470 // create options menu 1530 // create options menu 1471 menu = menuBar()->addMenu("&Option"); !! 1531 QMenu* optionMenu = menu->addMenu("&Option"); 1472 menu->addAction(showNameAction); !! 1532 optionMenu->addAction(showNameAction); 1473 menu->addSeparator(); !! 1533 optionMenu->addAction(showRangeAction); 1474 menu->addActions(optGroup->actions()) !! 1534 optionMenu->addAction(showDataAction); 1475 menu->addSeparator(); !! 1535 optionMenu->addSeparator(); 1476 menu->addAction(showDebugAction); !! 1536 optionMenu->addActions(optGroup->actions()); >> 1537 optionMenu->addSeparator(); >> 1538 optionMenu->addAction(showDebugAction); 1477 1539 1478 // create help menu 1540 // create help menu 1479 menu = menuBar()->addMenu("&Help"); !! 1541 menu->addSeparator(); 1480 menu->addAction(showIntroAction); !! 1542 QMenu* helpMenu = menu->addMenu("&Help"); 1481 menu->addAction(showAboutAction); !! 1543 helpMenu->addAction(showIntroAction); 1482 !! 1544 helpMenu->addAction(showAboutAction); 1483 connect(helpText, &ConfigInfoView::an !! 1545 1484 helpText, &ConfigInfoView::cl !! 1546 connect (helpText, SIGNAL (anchorClicked (const QUrl &)), 1485 !! 1547 helpText, SLOT (clicked (const QUrl &)) ); 1486 connect(configList, &ConfigList::menu !! 1548 1487 helpText, &ConfigInfoView::se !! 1549 connect(configList, SIGNAL(menuChanged(struct menu *)), 1488 connect(configList, &ConfigList::menu !! 1550 helpText, SLOT(setInfo(struct menu *))); 1489 this, &ConfigMainWindow::chan !! 1551 connect(configList, SIGNAL(menuSelected(struct menu *)), 1490 connect(configList, &ConfigList::item !! 1552 SLOT(changeMenu(struct menu *))); 1491 this, &ConfigMainWindow::chan !! 1553 connect(configList, SIGNAL(itemSelected(struct menu *)), 1492 connect(configList, &ConfigList::pare !! 1554 SLOT(changeItens(struct menu *))); 1493 this, &ConfigMainWindow::goBa !! 1555 connect(configList, SIGNAL(parentSelected()), 1494 connect(menuList, &ConfigList::menuCh !! 1556 SLOT(goBack())); 1495 helpText, &ConfigInfoView::se !! 1557 connect(menuList, SIGNAL(menuChanged(struct menu *)), 1496 connect(menuList, &ConfigList::menuSe !! 1558 helpText, SLOT(setInfo(struct menu *))); 1497 this, &ConfigMainWindow::chan !! 1559 connect(menuList, SIGNAL(menuSelected(struct menu *)), 1498 !! 1560 SLOT(changeMenu(struct menu *))); 1499 connect(configList, &ConfigList::gotF !! 1561 1500 helpText, &ConfigInfoView::se !! 1562 connect(configList, SIGNAL(gotFocus(struct menu *)), 1501 connect(menuList, &ConfigList::gotFoc !! 1563 helpText, SLOT(setInfo(struct menu *))); 1502 helpText, &ConfigInfoView::se !! 1564 connect(menuList, SIGNAL(gotFocus(struct menu *)), 1503 connect(menuList, &ConfigList::gotFoc !! 1565 helpText, SLOT(setInfo(struct menu *))); 1504 this, &ConfigMainWindow::list !! 1566 connect(menuList, SIGNAL(gotFocus(struct menu *)), 1505 connect(helpText, &ConfigInfoView::me !! 1567 SLOT(listFocusChanged(void))); 1506 this, &ConfigMainWindow::setM !! 1568 connect(helpText, SIGNAL(menuSelected(struct menu *)), 1507 !! 1569 SLOT(setMenuLink(struct menu *))); 1508 conf_read(NULL); << 1509 1570 1510 QString listMode = configSettings->va 1571 QString listMode = configSettings->value("/listMode", "symbol").toString(); 1511 if (listMode == "single") 1572 if (listMode == "single") 1512 showSingleView(); 1573 showSingleView(); 1513 else if (listMode == "full") 1574 else if (listMode == "full") 1514 showFullView(); 1575 showFullView(); 1515 else /*if (listMode == "split")*/ 1576 else /*if (listMode == "split")*/ 1516 showSplitView(); 1577 showSplitView(); 1517 1578 1518 // UI setup done, restore splitter po 1579 // UI setup done, restore splitter positions 1519 QList<int> sizes = configSettings->re 1580 QList<int> sizes = configSettings->readSizes("/split1", &ok); 1520 if (ok) 1581 if (ok) 1521 split1->setSizes(sizes); 1582 split1->setSizes(sizes); 1522 1583 1523 sizes = configSettings->readSizes("/s 1584 sizes = configSettings->readSizes("/split2", &ok); 1524 if (ok) 1585 if (ok) 1525 split2->setSizes(sizes); 1586 split2->setSizes(sizes); 1526 } 1587 } 1527 1588 1528 void ConfigMainWindow::loadConfig(void) 1589 void ConfigMainWindow::loadConfig(void) 1529 { 1590 { 1530 QString str; 1591 QString str; 1531 QByteArray ba; 1592 QByteArray ba; 1532 const char *name; 1593 const char *name; 1533 1594 1534 str = QFileDialog::getOpenFileName(th 1595 str = QFileDialog::getOpenFileName(this, "", configname); 1535 if (str.isNull()) 1596 if (str.isNull()) 1536 return; 1597 return; 1537 1598 1538 ba = str.toLocal8Bit(); 1599 ba = str.toLocal8Bit(); 1539 name = ba.data(); 1600 name = ba.data(); 1540 1601 1541 if (conf_read(name)) 1602 if (conf_read(name)) 1542 QMessageBox::information(this 1603 QMessageBox::information(this, "qconf", "Unable to load configuration!"); 1543 1604 1544 free(configname); 1605 free(configname); 1545 configname = xstrdup(name); 1606 configname = xstrdup(name); 1546 1607 1547 ConfigList::updateListAllForAll(); !! 1608 ConfigView::updateListAll(); 1548 } 1609 } 1549 1610 1550 bool ConfigMainWindow::saveConfig(void) 1611 bool ConfigMainWindow::saveConfig(void) 1551 { 1612 { 1552 if (conf_write(configname)) { 1613 if (conf_write(configname)) { 1553 QMessageBox::information(this 1614 QMessageBox::information(this, "qconf", "Unable to save configuration!"); 1554 return false; 1615 return false; 1555 } 1616 } 1556 conf_write_autoconf(0); 1617 conf_write_autoconf(0); 1557 1618 1558 return true; 1619 return true; 1559 } 1620 } 1560 1621 1561 void ConfigMainWindow::saveConfigAs(void) 1622 void ConfigMainWindow::saveConfigAs(void) 1562 { 1623 { 1563 QString str; 1624 QString str; 1564 QByteArray ba; 1625 QByteArray ba; 1565 const char *name; 1626 const char *name; 1566 1627 1567 str = QFileDialog::getSaveFileName(th 1628 str = QFileDialog::getSaveFileName(this, "", configname); 1568 if (str.isNull()) 1629 if (str.isNull()) 1569 return; 1630 return; 1570 1631 1571 ba = str.toLocal8Bit(); 1632 ba = str.toLocal8Bit(); 1572 name = ba.data(); 1633 name = ba.data(); 1573 1634 1574 if (conf_write(name)) { 1635 if (conf_write(name)) { 1575 QMessageBox::information(this 1636 QMessageBox::information(this, "qconf", "Unable to save configuration!"); 1576 } 1637 } 1577 conf_write_autoconf(0); 1638 conf_write_autoconf(0); 1578 1639 1579 free(configname); 1640 free(configname); 1580 configname = xstrdup(name); 1641 configname = xstrdup(name); 1581 } 1642 } 1582 1643 1583 void ConfigMainWindow::searchConfig(void) 1644 void ConfigMainWindow::searchConfig(void) 1584 { 1645 { 1585 if (!searchWindow) 1646 if (!searchWindow) 1586 searchWindow = new ConfigSear !! 1647 searchWindow = new ConfigSearchWindow(this, "search"); 1587 searchWindow->show(); 1648 searchWindow->show(); 1588 } 1649 } 1589 1650 1590 void ConfigMainWindow::changeItens(struct men 1651 void ConfigMainWindow::changeItens(struct menu *menu) 1591 { 1652 { 1592 configList->setRootMenu(menu); 1653 configList->setRootMenu(menu); 1593 } 1654 } 1594 1655 1595 void ConfigMainWindow::changeMenu(struct menu 1656 void ConfigMainWindow::changeMenu(struct menu *menu) 1596 { 1657 { 1597 menuList->setRootMenu(menu); 1658 menuList->setRootMenu(menu); 1598 } 1659 } 1599 1660 1600 void ConfigMainWindow::setMenuLink(struct men 1661 void ConfigMainWindow::setMenuLink(struct menu *menu) 1601 { 1662 { 1602 struct menu *parent; 1663 struct menu *parent; 1603 ConfigList* list = NULL; 1664 ConfigList* list = NULL; 1604 ConfigItem* item; 1665 ConfigItem* item; 1605 1666 1606 if (configList->menuSkip(menu)) 1667 if (configList->menuSkip(menu)) 1607 return; 1668 return; 1608 1669 1609 switch (configList->mode) { 1670 switch (configList->mode) { 1610 case singleMode: 1671 case singleMode: 1611 list = configList; 1672 list = configList; 1612 parent = menu_get_parent_menu 1673 parent = menu_get_parent_menu(menu); 1613 if (!parent) 1674 if (!parent) 1614 return; 1675 return; 1615 list->setRootMenu(parent); 1676 list->setRootMenu(parent); 1616 break; 1677 break; 1617 case menuMode: 1678 case menuMode: 1618 if (menu->flags & MENU_ROOT) 1679 if (menu->flags & MENU_ROOT) { 1619 menuList->setRootMenu 1680 menuList->setRootMenu(menu); 1620 configList->clearSele 1681 configList->clearSelection(); 1621 list = configList; 1682 list = configList; 1622 } else { 1683 } else { 1623 parent = menu_get_par 1684 parent = menu_get_parent_menu(menu->parent); 1624 if (!parent) 1685 if (!parent) 1625 return; 1686 return; 1626 1687 1627 /* Select the config 1688 /* Select the config view */ 1628 item = configList->fi 1689 item = configList->findConfigItem(parent); 1629 if (item) { 1690 if (item) { 1630 configList->s 1691 configList->setSelected(item, true); 1631 configList->s 1692 configList->scrollToItem(item); 1632 } 1693 } 1633 1694 1634 menuList->setRootMenu 1695 menuList->setRootMenu(parent); 1635 menuList->clearSelect 1696 menuList->clearSelection(); 1636 list = menuList; 1697 list = menuList; 1637 } 1698 } 1638 break; 1699 break; 1639 case fullMode: 1700 case fullMode: 1640 list = configList; 1701 list = configList; 1641 break; 1702 break; 1642 default: 1703 default: 1643 break; 1704 break; 1644 } 1705 } 1645 1706 1646 if (list) { 1707 if (list) { 1647 item = list->findConfigItem(m 1708 item = list->findConfigItem(menu); 1648 if (item) { 1709 if (item) { 1649 list->setSelected(ite 1710 list->setSelected(item, true); 1650 list->scrollToItem(it 1711 list->scrollToItem(item); 1651 list->setFocus(); 1712 list->setFocus(); 1652 helpText->setInfo(men 1713 helpText->setInfo(menu); 1653 } 1714 } 1654 } 1715 } 1655 } 1716 } 1656 1717 1657 void ConfigMainWindow::listFocusChanged(void) 1718 void ConfigMainWindow::listFocusChanged(void) 1658 { 1719 { 1659 if (menuList->mode == menuMode) 1720 if (menuList->mode == menuMode) 1660 configList->clearSelection(); 1721 configList->clearSelection(); 1661 } 1722 } 1662 1723 1663 void ConfigMainWindow::goBack(void) 1724 void ConfigMainWindow::goBack(void) 1664 { 1725 { 1665 if (configList->rootEntry == &rootmen 1726 if (configList->rootEntry == &rootmenu) 1666 return; 1727 return; 1667 1728 1668 configList->setParentMenu(); 1729 configList->setParentMenu(); 1669 } 1730 } 1670 1731 1671 void ConfigMainWindow::showSingleView(void) 1732 void ConfigMainWindow::showSingleView(void) 1672 { 1733 { 1673 singleViewAction->setEnabled(false); 1734 singleViewAction->setEnabled(false); 1674 singleViewAction->setChecked(true); 1735 singleViewAction->setChecked(true); 1675 splitViewAction->setEnabled(true); 1736 splitViewAction->setEnabled(true); 1676 splitViewAction->setChecked(false); 1737 splitViewAction->setChecked(false); 1677 fullViewAction->setEnabled(true); 1738 fullViewAction->setEnabled(true); 1678 fullViewAction->setChecked(false); 1739 fullViewAction->setChecked(false); 1679 1740 1680 backAction->setEnabled(true); 1741 backAction->setEnabled(true); 1681 1742 1682 menuList->hide(); !! 1743 menuView->hide(); 1683 menuList->setRootMenu(0); 1744 menuList->setRootMenu(0); 1684 configList->mode = singleMode; 1745 configList->mode = singleMode; 1685 if (configList->rootEntry == &rootmen 1746 if (configList->rootEntry == &rootmenu) 1686 configList->updateListAll(); 1747 configList->updateListAll(); 1687 else 1748 else 1688 configList->setRootMenu(&root 1749 configList->setRootMenu(&rootmenu); 1689 configList->setFocus(); 1750 configList->setFocus(); 1690 } 1751 } 1691 1752 1692 void ConfigMainWindow::showSplitView(void) 1753 void ConfigMainWindow::showSplitView(void) 1693 { 1754 { 1694 singleViewAction->setEnabled(true); 1755 singleViewAction->setEnabled(true); 1695 singleViewAction->setChecked(false); 1756 singleViewAction->setChecked(false); 1696 splitViewAction->setEnabled(false); 1757 splitViewAction->setEnabled(false); 1697 splitViewAction->setChecked(true); 1758 splitViewAction->setChecked(true); 1698 fullViewAction->setEnabled(true); 1759 fullViewAction->setEnabled(true); 1699 fullViewAction->setChecked(false); 1760 fullViewAction->setChecked(false); 1700 1761 1701 backAction->setEnabled(false); 1762 backAction->setEnabled(false); 1702 1763 1703 configList->mode = menuMode; 1764 configList->mode = menuMode; 1704 if (configList->rootEntry == &rootmen 1765 if (configList->rootEntry == &rootmenu) 1705 configList->updateListAll(); 1766 configList->updateListAll(); 1706 else 1767 else 1707 configList->setRootMenu(&root 1768 configList->setRootMenu(&rootmenu); 1708 configList->setAllOpen(true); 1769 configList->setAllOpen(true); 1709 configApp->processEvents(); 1770 configApp->processEvents(); 1710 menuList->mode = symbolMode; 1771 menuList->mode = symbolMode; 1711 menuList->setRootMenu(&rootmenu); 1772 menuList->setRootMenu(&rootmenu); 1712 menuList->setAllOpen(true); 1773 menuList->setAllOpen(true); 1713 menuList->show(); !! 1774 menuView->show(); 1714 menuList->setFocus(); 1775 menuList->setFocus(); 1715 } 1776 } 1716 1777 1717 void ConfigMainWindow::showFullView(void) 1778 void ConfigMainWindow::showFullView(void) 1718 { 1779 { 1719 singleViewAction->setEnabled(true); 1780 singleViewAction->setEnabled(true); 1720 singleViewAction->setChecked(false); 1781 singleViewAction->setChecked(false); 1721 splitViewAction->setEnabled(true); 1782 splitViewAction->setEnabled(true); 1722 splitViewAction->setChecked(false); 1783 splitViewAction->setChecked(false); 1723 fullViewAction->setEnabled(false); 1784 fullViewAction->setEnabled(false); 1724 fullViewAction->setChecked(true); 1785 fullViewAction->setChecked(true); 1725 1786 1726 backAction->setEnabled(false); 1787 backAction->setEnabled(false); 1727 1788 1728 menuList->hide(); !! 1789 menuView->hide(); 1729 menuList->setRootMenu(0); 1790 menuList->setRootMenu(0); 1730 configList->mode = fullMode; 1791 configList->mode = fullMode; 1731 if (configList->rootEntry == &rootmen 1792 if (configList->rootEntry == &rootmenu) 1732 configList->updateListAll(); 1793 configList->updateListAll(); 1733 else 1794 else 1734 configList->setRootMenu(&root 1795 configList->setRootMenu(&rootmenu); 1735 configList->setFocus(); 1796 configList->setFocus(); 1736 } 1797 } 1737 1798 1738 /* 1799 /* 1739 * ask for saving configuration before quitti 1800 * ask for saving configuration before quitting 1740 */ 1801 */ 1741 void ConfigMainWindow::closeEvent(QCloseEvent 1802 void ConfigMainWindow::closeEvent(QCloseEvent* e) 1742 { 1803 { 1743 if (!conf_get_changed()) { 1804 if (!conf_get_changed()) { 1744 e->accept(); 1805 e->accept(); 1745 return; 1806 return; 1746 } 1807 } 1747 !! 1808 QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, 1748 QMessageBox mb(QMessageBox::Icon::War !! 1809 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); 1749 "Save configuration?") !! 1810 mb.setButtonText(QMessageBox::Yes, "&Save Changes"); 1750 !! 1811 mb.setButtonText(QMessageBox::No, "&Discard Changes"); 1751 QPushButton *yb = mb.addButton(QMessa !! 1812 mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); 1752 QPushButton *db = mb.addButton(QMessa << 1753 QPushButton *cb = mb.addButton(QMessa << 1754 << 1755 yb->setText("&Save Changes"); << 1756 db->setText("&Discard Changes"); << 1757 cb->setText("Cancel Exit"); << 1758 << 1759 mb.setDefaultButton(yb); << 1760 mb.setEscapeButton(cb); << 1761 << 1762 switch (mb.exec()) { 1813 switch (mb.exec()) { 1763 case QMessageBox::Yes: 1814 case QMessageBox::Yes: 1764 if (saveConfig()) 1815 if (saveConfig()) 1765 e->accept(); 1816 e->accept(); 1766 else 1817 else 1767 e->ignore(); 1818 e->ignore(); 1768 break; 1819 break; 1769 case QMessageBox::No: 1820 case QMessageBox::No: 1770 e->accept(); 1821 e->accept(); 1771 break; 1822 break; 1772 case QMessageBox::Cancel: 1823 case QMessageBox::Cancel: 1773 e->ignore(); 1824 e->ignore(); 1774 break; 1825 break; 1775 } 1826 } 1776 } 1827 } 1777 1828 1778 void ConfigMainWindow::showIntro(void) 1829 void ConfigMainWindow::showIntro(void) 1779 { 1830 { 1780 static const QString str = !! 1831 static const QString str = "Welcome to the qconf graphical configuration tool.\n\n" 1781 "Welcome to the qconf graphic !! 1832 "For each option, a blank box indicates the feature is disabled, a check\n" 1782 "\n" !! 1833 "indicates it is enabled, and a dot indicates that it is to be compiled\n" 1783 "For bool and tristate option !! 1834 "as a module. Clicking on the box will cycle through the three states.\n\n" 1784 "feature is disabled, a check !! 1835 "If you do not see an option (e.g., a device driver) that you believe\n" 1785 "dot indicates that it is to !! 1836 "should be present, try turning on Show All Options under the Options menu.\n" 1786 "on the box will cycle throug !! 1837 "Although there is no cross reference yet to help you figure out what other\n" 1787 "and string options, double-c !! 1838 "options must be enabled to support the option you are interested in, you can\n" 1788 "Value cell will allow you to !! 1839 "still view the help of a grayed-out option.\n\n" 1789 "\n" !! 1840 "Toggling Show Debug Info under the Options menu will show the dependencies,\n" 1790 "If you do not see an option !! 1841 "which you can then match by examining other options.\n\n"; 1791 "believe should be present, t << 1792 "under the Options menu. Enab << 1793 "figure out what other option << 1794 "option you are interested in << 1795 "them.\n" << 1796 "\n" << 1797 "Toggling Show Debug Info und << 1798 "dependencies, which you can << 1799 "options.\n"; << 1800 1842 1801 QMessageBox::information(this, "qconf 1843 QMessageBox::information(this, "qconf", str); 1802 } 1844 } 1803 1845 1804 void ConfigMainWindow::showAbout(void) 1846 void ConfigMainWindow::showAbout(void) 1805 { 1847 { 1806 static const QString str = "qconf is 1848 static const QString str = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n" 1807 "Copyright (C) 2015 Boris Bar !! 1849 "Copyright (C) 2015 Boris Barbulovski <bbarbulovski@gmail.com>.\n\n" 1808 "\n" !! 1850 "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; 1809 "Bug reports and feature requ << 1810 "\n" << 1811 "Qt Version: "; << 1812 1851 1813 QMessageBox::information(this, "qconf !! 1852 QMessageBox::information(this, "qconf", str); 1814 } 1853 } 1815 1854 1816 void ConfigMainWindow::saveSettings(void) 1855 void ConfigMainWindow::saveSettings(void) 1817 { 1856 { 1818 configSettings->setValue("/window x", 1857 configSettings->setValue("/window x", pos().x()); 1819 configSettings->setValue("/window y", 1858 configSettings->setValue("/window y", pos().y()); 1820 configSettings->setValue("/window wid 1859 configSettings->setValue("/window width", size().width()); 1821 configSettings->setValue("/window hei 1860 configSettings->setValue("/window height", size().height()); 1822 1861 1823 QString entry; 1862 QString entry; 1824 switch(configList->mode) { 1863 switch(configList->mode) { 1825 case singleMode : 1864 case singleMode : 1826 entry = "single"; 1865 entry = "single"; 1827 break; 1866 break; 1828 1867 1829 case symbolMode : 1868 case symbolMode : 1830 entry = "split"; 1869 entry = "split"; 1831 break; 1870 break; 1832 1871 1833 case fullMode : 1872 case fullMode : 1834 entry = "full"; 1873 entry = "full"; 1835 break; 1874 break; 1836 1875 1837 default: 1876 default: 1838 break; 1877 break; 1839 } 1878 } 1840 configSettings->setValue("/listMode", 1879 configSettings->setValue("/listMode", entry); 1841 1880 1842 configSettings->writeSizes("/split1", 1881 configSettings->writeSizes("/split1", split1->sizes()); 1843 configSettings->writeSizes("/split2", 1882 configSettings->writeSizes("/split2", split2->sizes()); 1844 } 1883 } 1845 1884 1846 void ConfigMainWindow::conf_changed(bool dirt !! 1885 void ConfigMainWindow::conf_changed(void) 1847 { 1886 { 1848 if (saveAction) 1887 if (saveAction) 1849 saveAction->setEnabled(dirty) !! 1888 saveAction->setEnabled(conf_get_changed()); 1850 } 1889 } 1851 1890 1852 void fixup_rootmenu(struct menu *menu) 1891 void fixup_rootmenu(struct menu *menu) 1853 { 1892 { 1854 struct menu *child; 1893 struct menu *child; 1855 static int menu_cnt = 0; 1894 static int menu_cnt = 0; 1856 1895 1857 menu->flags |= MENU_ROOT; 1896 menu->flags |= MENU_ROOT; 1858 for (child = menu->list; child; child 1897 for (child = menu->list; child; child = child->next) { 1859 if (child->prompt && child->p 1898 if (child->prompt && child->prompt->type == P_MENU) { 1860 menu_cnt++; 1899 menu_cnt++; 1861 fixup_rootmenu(child) 1900 fixup_rootmenu(child); 1862 menu_cnt--; 1901 menu_cnt--; 1863 } else if (!menu_cnt) 1902 } else if (!menu_cnt) 1864 fixup_rootmenu(child) 1903 fixup_rootmenu(child); 1865 } 1904 } 1866 } 1905 } 1867 1906 1868 static const char *progname; 1907 static const char *progname; 1869 1908 1870 static void usage(void) 1909 static void usage(void) 1871 { 1910 { 1872 printf("%s [-s] <config>\n", progname 1911 printf("%s [-s] <config>\n", progname); 1873 exit(0); 1912 exit(0); 1874 } 1913 } 1875 1914 1876 int main(int ac, char** av) 1915 int main(int ac, char** av) 1877 { 1916 { 1878 ConfigMainWindow* v; 1917 ConfigMainWindow* v; 1879 const char *name; 1918 const char *name; 1880 1919 1881 progname = av[0]; 1920 progname = av[0]; >> 1921 configApp = new QApplication(ac, av); 1882 if (ac > 1 && av[1][0] == '-') { 1922 if (ac > 1 && av[1][0] == '-') { 1883 switch (av[1][1]) { 1923 switch (av[1][1]) { 1884 case 's': 1924 case 's': 1885 conf_set_message_call 1925 conf_set_message_callback(NULL); 1886 break; 1926 break; 1887 case 'h': 1927 case 'h': 1888 case '?': 1928 case '?': 1889 usage(); 1929 usage(); 1890 } 1930 } 1891 name = av[2]; 1931 name = av[2]; 1892 } else 1932 } else 1893 name = av[1]; 1933 name = av[1]; 1894 if (!name) 1934 if (!name) 1895 usage(); 1935 usage(); 1896 1936 1897 conf_parse(name); 1937 conf_parse(name); 1898 fixup_rootmenu(&rootmenu); 1938 fixup_rootmenu(&rootmenu); >> 1939 conf_read(NULL); 1899 //zconfdump(stdout); 1940 //zconfdump(stdout); 1900 1941 1901 configApp = new QApplication(ac, av); << 1902 << 1903 configSettings = new ConfigSettings() 1942 configSettings = new ConfigSettings(); 1904 configSettings->beginGroup("/kconfig/ 1943 configSettings->beginGroup("/kconfig/qconf"); 1905 v = new ConfigMainWindow(); 1944 v = new ConfigMainWindow(); 1906 1945 1907 //zconfdump(stdout); 1946 //zconfdump(stdout); 1908 configApp->connect(configApp, SIGNAL( 1947 configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); 1909 configApp->connect(configApp, SIGNAL( 1948 configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings())); 1910 << 1911 v->show(); 1949 v->show(); 1912 configApp->exec(); 1950 configApp->exec(); 1913 1951 1914 configSettings->endGroup(); 1952 configSettings->endGroup(); 1915 delete configSettings; 1953 delete configSettings; 1916 delete v; 1954 delete v; 1917 delete configApp; 1955 delete configApp; 1918 1956 1919 return 0; 1957 return 0; 1920 } 1958 } 1921 1959
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.