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