diff options
| author | Boris Barbulovski <bbarbulovski@gmail.com> | 2015-09-22 14:36:14 -0400 |
|---|---|---|
| committer | Michal Marek <mmarek@suse.com> | 2015-10-14 08:59:02 -0400 |
| commit | 76538660fb08f2f794d569a594a95fc55eb03932 (patch) | |
| tree | 8594586cb8a8a77d2ce3fab373ebd2ed095e8604 /scripts | |
| parent | 780505e33f0af32808257fd8b6ace5c3e3d9666f (diff) | |
Port xconfig to Qt5 - Remove custom ListView classes.
Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/kconfig/qconf.cc | 904 | ||||
| -rw-r--r-- | scripts/kconfig/qconf.h | 177 |
2 files changed, 15 insertions, 1066 deletions
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index f439f355dddc..319559f361ac 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc | |||
| @@ -87,213 +87,15 @@ bool ConfigSettings::writeSizes(const QString& key, const QList<int>& value) | |||
| 87 | return writeEntry(key, stringList); | 87 | return writeEntry(key, stringList); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | |||
| 91 | /* | ||
| 92 | * set the new data | ||
| 93 | * TODO check the value | ||
| 94 | */ | ||
| 95 | void ConfigItem::okRename(int col) | ||
| 96 | { | ||
| 97 | Parent::okRename(col); | ||
| 98 | sym_set_string_value(menu->sym, text(dataColIdx).latin1()); | ||
| 99 | listView()->updateList(this); | ||
| 100 | } | ||
| 101 | |||
| 102 | /* | ||
| 103 | * update the displayed of a menu entry | ||
| 104 | */ | ||
| 105 | void ConfigItem::updateMenu(void) | ||
| 106 | { | ||
| 107 | ConfigList* list; | ||
| 108 | struct symbol* sym; | ||
| 109 | struct property *prop; | ||
| 110 | QString prompt; | ||
| 111 | int type; | ||
| 112 | tristate expr; | ||
| 113 | |||
| 114 | list = listView(); | ||
| 115 | if (goParent) { | ||
| 116 | setPixmap(promptColIdx, list->menuBackPix); | ||
| 117 | prompt = ".."; | ||
| 118 | goto set_prompt; | ||
| 119 | } | ||
| 120 | |||
| 121 | sym = menu->sym; | ||
| 122 | prop = menu->prompt; | ||
| 123 | prompt = _(menu_get_prompt(menu)); | ||
| 124 | |||
| 125 | if (prop) switch (prop->type) { | ||
| 126 | case P_MENU: | ||
| 127 | if (list->mode == singleMode || list->mode == symbolMode) { | ||
| 128 | /* a menuconfig entry is displayed differently | ||
| 129 | * depending whether it's at the view root or a child. | ||
| 130 | */ | ||
| 131 | if (sym && list->rootEntry == menu) | ||
| 132 | break; | ||
| 133 | setPixmap(promptColIdx, list->menuPix); | ||
| 134 | } else { | ||
| 135 | if (sym) | ||
| 136 | break; | ||
| 137 | setPixmap(promptColIdx, 0); | ||
| 138 | } | ||
| 139 | goto set_prompt; | ||
| 140 | case P_COMMENT: | ||
| 141 | setPixmap(promptColIdx, 0); | ||
| 142 | goto set_prompt; | ||
| 143 | default: | ||
| 144 | ; | ||
| 145 | } | ||
| 146 | if (!sym) | ||
| 147 | goto set_prompt; | ||
| 148 | |||
| 149 | setText(nameColIdx, QString::fromLocal8Bit(sym->name)); | ||
| 150 | |||
| 151 | type = sym_get_type(sym); | ||
| 152 | switch (type) { | ||
| 153 | case S_BOOLEAN: | ||
| 154 | case S_TRISTATE: | ||
| 155 | char ch; | ||
| 156 | |||
| 157 | if (!sym_is_changable(sym) && list->optMode == normalOpt) { | ||
| 158 | setPixmap(promptColIdx, 0); | ||
| 159 | setText(noColIdx, QString::null); | ||
| 160 | setText(modColIdx, QString::null); | ||
| 161 | setText(yesColIdx, QString::null); | ||
| 162 | break; | ||
| 163 | } | ||
| 164 | expr = sym_get_tristate_value(sym); | ||
| 165 | switch (expr) { | ||
| 166 | case yes: | ||
| 167 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) | ||
| 168 | setPixmap(promptColIdx, list->choiceYesPix); | ||
| 169 | else | ||
| 170 | setPixmap(promptColIdx, list->symbolYesPix); | ||
| 171 | setText(yesColIdx, "Y"); | ||
| 172 | ch = 'Y'; | ||
| 173 | break; | ||
| 174 | case mod: | ||
| 175 | setPixmap(promptColIdx, list->symbolModPix); | ||
| 176 | setText(modColIdx, "M"); | ||
| 177 | ch = 'M'; | ||
| 178 | break; | ||
| 179 | default: | ||
| 180 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) | ||
| 181 | setPixmap(promptColIdx, list->choiceNoPix); | ||
| 182 | else | ||
| 183 | setPixmap(promptColIdx, list->symbolNoPix); | ||
| 184 | setText(noColIdx, "N"); | ||
| 185 | ch = 'N'; | ||
| 186 | break; | ||
| 187 | } | ||
| 188 | if (expr != no) | ||
| 189 | setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); | ||
| 190 | if (expr != mod) | ||
| 191 | setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); | ||
| 192 | if (expr != yes) | ||
| 193 | setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); | ||
| 194 | |||
| 195 | setText(dataColIdx, QChar(ch)); | ||
| 196 | break; | ||
| 197 | case S_INT: | ||
| 198 | case S_HEX: | ||
| 199 | case S_STRING: | ||
| 200 | const char* data; | ||
| 201 | |||
| 202 | data = sym_get_string_value(sym); | ||
| 203 | |||
| 204 | int i = list->mapIdx(dataColIdx); | ||
| 205 | if (i >= 0) | ||
| 206 | setRenameEnabled(i, TRUE); | ||
| 207 | setText(dataColIdx, data); | ||
| 208 | if (type == S_STRING) | ||
| 209 | prompt = QString("%1: %2").arg(prompt).arg(data); | ||
| 210 | else | ||
| 211 | prompt = QString("(%2) %1").arg(prompt).arg(data); | ||
| 212 | break; | ||
| 213 | } | ||
| 214 | if (!sym_has_value(sym) && visible) | ||
| 215 | prompt += _(" (NEW)"); | ||
| 216 | set_prompt: | ||
| 217 | setText(promptColIdx, prompt); | ||
| 218 | } | ||
| 219 | |||
| 220 | void ConfigItem::testUpdateMenu(bool v) | ||
| 221 | { | ||
| 222 | ConfigItem* i; | ||
| 223 | |||
| 224 | visible = v; | ||
| 225 | if (!menu) | ||
| 226 | return; | ||
| 227 | |||
| 228 | sym_calc_value(menu->sym); | ||
| 229 | if (menu->flags & MENU_CHANGED) { | ||
| 230 | /* the menu entry changed, so update all list items */ | ||
| 231 | menu->flags &= ~MENU_CHANGED; | ||
| 232 | for (i = (ConfigItem*)menu->data; i; i = i->nextItem) | ||
| 233 | i->updateMenu(); | ||
| 234 | } else if (listView()->updateAll) | ||
| 235 | updateMenu(); | ||
| 236 | } | ||
| 237 | |||
| 238 | void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) | ||
| 239 | { | ||
| 240 | ConfigList* list = listView(); | ||
| 241 | |||
| 242 | if (visible) { | ||
| 243 | if (isSelected() && !list->hasFocus() && list->mode == menuMode) | ||
| 244 | Parent::paintCell(p, list->inactivedColorGroup, column, width, align); | ||
| 245 | else | ||
| 246 | Parent::paintCell(p, cg, column, width, align); | ||
| 247 | } else | ||
| 248 | Parent::paintCell(p, list->disabledColorGroup, column, width, align); | ||
| 249 | } | ||
| 250 | |||
| 251 | /* | ||
| 252 | * construct a menu entry | ||
| 253 | */ | ||
| 254 | void ConfigItem::init(void) | ||
| 255 | { | ||
| 256 | if (menu) { | ||
| 257 | ConfigList* list = listView(); | ||
| 258 | nextItem = (ConfigItem*)menu->data; | ||
| 259 | menu->data = this; | ||
| 260 | |||
| 261 | if (list->mode != fullMode) | ||
| 262 | setOpen(TRUE); | ||
| 263 | sym_calc_value(menu->sym); | ||
| 264 | } | ||
| 265 | updateMenu(); | ||
| 266 | } | ||
| 267 | |||
| 268 | /* | ||
| 269 | * destruct a menu entry | ||
| 270 | */ | ||
| 271 | ConfigItem::~ConfigItem(void) | ||
| 272 | { | ||
| 273 | if (menu) { | ||
| 274 | ConfigItem** ip = (ConfigItem**)&menu->data; | ||
| 275 | for (; *ip; ip = &(*ip)->nextItem) { | ||
| 276 | if (*ip == this) { | ||
| 277 | *ip = nextItem; | ||
| 278 | break; | ||
| 279 | } | ||
| 280 | } | ||
| 281 | } | ||
| 282 | } | ||
| 283 | |||
| 284 | ConfigLineEdit::ConfigLineEdit(ConfigView* parent) | 90 | ConfigLineEdit::ConfigLineEdit(ConfigView* parent) |
| 285 | : Parent(parent) | 91 | : Parent(parent) |
| 286 | { | 92 | { |
| 287 | connect(this, SIGNAL(lostFocus()), SLOT(hide())); | 93 | connect(this, SIGNAL(lostFocus()), SLOT(hide())); |
| 288 | } | 94 | } |
| 289 | 95 | ||
| 290 | void ConfigLineEdit::show(ConfigItem* i) | 96 | void ConfigLineEdit::show(Q3ListViewItem *i) |
| 291 | { | 97 | { |
| 292 | item = i; | 98 | item = i; |
| 293 | if (sym_get_string_value(item->menu->sym)) | ||
| 294 | setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym))); | ||
| 295 | else | ||
| 296 | setText(QString::null); | ||
| 297 | Parent::show(); | 99 | Parent::show(); |
| 298 | setFocus(); | 100 | setFocus(); |
| 299 | } | 101 | } |
| @@ -305,7 +107,6 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | |||
| 305 | break; | 107 | break; |
| 306 | case Qt::Key_Return: | 108 | case Qt::Key_Return: |
| 307 | case Qt::Key_Enter: | 109 | case Qt::Key_Enter: |
| 308 | sym_set_string_value(item->menu->sym, text().latin1()); | ||
| 309 | parent()->updateList(item); | 110 | parent()->updateList(item); |
| 310 | break; | 111 | break; |
| 311 | default: | 112 | default: |
| @@ -317,536 +118,6 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | |||
| 317 | hide(); | 118 | hide(); |
| 318 | } | 119 | } |
| 319 | 120 | ||
| 320 | ConfigList::ConfigList(ConfigView* p, const char *name) | ||
| 321 | : Parent(p, name), | ||
| 322 | updateAll(false), | ||
| 323 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), | ||
| 324 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), | ||
| 325 | menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), | ||
| 326 | showName(false), showRange(false), showData(false), optMode(normalOpt), | ||
| 327 | rootEntry(0), headerPopup(0) | ||
| 328 | { | ||
| 329 | int i; | ||
| 330 | |||
| 331 | setSorting(-1); | ||
| 332 | setRootIsDecorated(TRUE); | ||
| 333 | disabledColorGroup = palette().active(); | ||
| 334 | disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text()); | ||
| 335 | inactivedColorGroup = palette().active(); | ||
| 336 | inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight()); | ||
| 337 | |||
| 338 | connect(this, SIGNAL(selectionChanged(void)), | ||
| 339 | SLOT(updateSelection(void))); | ||
| 340 | |||
| 341 | if (name) { | ||
| 342 | configSettings->beginGroup(name); | ||
| 343 | showName = configSettings->readBoolEntry("/showName", false); | ||
| 344 | showRange = configSettings->readBoolEntry("/showRange", false); | ||
| 345 | showData = configSettings->readBoolEntry("/showData", false); | ||
| 346 | optMode = (enum optionMode)configSettings->readNumEntry("/optionMode", false); | ||
| 347 | configSettings->endGroup(); | ||
| 348 | connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); | ||
| 349 | } | ||
| 350 | |||
| 351 | for (i = 0; i < colNr; i++) | ||
| 352 | colMap[i] = colRevMap[i] = -1; | ||
| 353 | addColumn(promptColIdx, _("Option")); | ||
| 354 | |||
| 355 | reinit(); | ||
| 356 | } | ||
| 357 | |||
| 358 | bool ConfigList::menuSkip(struct menu *menu) | ||
| 359 | { | ||
| 360 | if (optMode == normalOpt && menu_is_visible(menu)) | ||
| 361 | return false; | ||
| 362 | if (optMode == promptOpt && menu_has_prompt(menu)) | ||
| 363 | return false; | ||
| 364 | if (optMode == allOpt) | ||
| 365 | return false; | ||
| 366 | return true; | ||
| 367 | } | ||
| 368 | |||
| 369 | void ConfigList::reinit(void) | ||
| 370 | { | ||
| 371 | removeColumn(dataColIdx); | ||
| 372 | removeColumn(yesColIdx); | ||
| 373 | removeColumn(modColIdx); | ||
| 374 | removeColumn(noColIdx); | ||
| 375 | removeColumn(nameColIdx); | ||
| 376 | |||
| 377 | if (showName) | ||
| 378 | addColumn(nameColIdx, _("Name")); | ||
| 379 | if (showRange) { | ||
| 380 | addColumn(noColIdx, "N"); | ||
| 381 | addColumn(modColIdx, "M"); | ||
| 382 | addColumn(yesColIdx, "Y"); | ||
| 383 | } | ||
| 384 | if (showData) | ||
| 385 | addColumn(dataColIdx, _("Value")); | ||
| 386 | |||
| 387 | updateListAll(); | ||
| 388 | } | ||
| 389 | |||
| 390 | void ConfigList::saveSettings(void) | ||
| 391 | { | ||
| 392 | if (name()) { | ||
| 393 | configSettings->beginGroup(name()); | ||
| 394 | configSettings->writeEntry("/showName", showName); | ||
| 395 | configSettings->writeEntry("/showRange", showRange); | ||
| 396 | configSettings->writeEntry("/showData", showData); | ||
| 397 | configSettings->writeEntry("/optionMode", (int)optMode); | ||
| 398 | configSettings->endGroup(); | ||
| 399 | } | ||
| 400 | } | ||
| 401 | |||
| 402 | ConfigItem* ConfigList::findConfigItem(struct menu *menu) | ||
| 403 | { | ||
| 404 | ConfigItem* item = (ConfigItem*)menu->data; | ||
| 405 | |||
| 406 | for (; item; item = item->nextItem) { | ||
| 407 | if (this == item->listView()) | ||
| 408 | break; | ||
| 409 | } | ||
| 410 | |||
| 411 | return item; | ||
| 412 | } | ||
| 413 | |||
| 414 | void ConfigList::updateSelection(void) | ||
| 415 | { | ||
| 416 | struct menu *menu; | ||
| 417 | enum prop_type type; | ||
| 418 | |||
| 419 | ConfigItem* item = (ConfigItem*)selectedItem(); | ||
| 420 | if (!item) | ||
| 421 | return; | ||
| 422 | |||
| 423 | menu = item->menu; | ||
| 424 | emit menuChanged(menu); | ||
| 425 | if (!menu) | ||
| 426 | return; | ||
| 427 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
| 428 | if (mode == menuMode && type == P_MENU) | ||
| 429 | emit menuSelected(menu); | ||
| 430 | } | ||
| 431 | |||
| 432 | void ConfigList::updateList(ConfigItem* item) | ||
| 433 | { | ||
| 434 | ConfigItem* last = 0; | ||
| 435 | |||
| 436 | if (!rootEntry) { | ||
| 437 | if (mode != listMode) | ||
| 438 | goto update; | ||
| 439 | Q3ListViewItemIterator it(this); | ||
| 440 | ConfigItem* item; | ||
| 441 | |||
| 442 | for (; it.current(); ++it) { | ||
| 443 | item = (ConfigItem*)it.current(); | ||
| 444 | if (!item->menu) | ||
| 445 | continue; | ||
| 446 | item->testUpdateMenu(menu_is_visible(item->menu)); | ||
| 447 | } | ||
| 448 | return; | ||
| 449 | } | ||
| 450 | |||
| 451 | if (rootEntry != &rootmenu && (mode == singleMode || | ||
| 452 | (mode == symbolMode && rootEntry->parent != &rootmenu))) { | ||
| 453 | item = firstChild(); | ||
| 454 | if (!item) | ||
| 455 | item = new ConfigItem(this, 0, true); | ||
| 456 | last = item; | ||
| 457 | } | ||
| 458 | if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) && | ||
| 459 | rootEntry->sym && rootEntry->prompt) { | ||
| 460 | item = last ? last->nextSibling() : firstChild(); | ||
| 461 | if (!item) | ||
| 462 | item = new ConfigItem(this, last, rootEntry, true); | ||
| 463 | else | ||
| 464 | item->testUpdateMenu(true); | ||
| 465 | |||
| 466 | updateMenuList(item, rootEntry); | ||
| 467 | triggerUpdate(); | ||
| 468 | return; | ||
| 469 | } | ||
| 470 | update: | ||
| 471 | updateMenuList(this, rootEntry); | ||
| 472 | triggerUpdate(); | ||
| 473 | } | ||
| 474 | |||
| 475 | void ConfigList::setValue(ConfigItem* item, tristate val) | ||
| 476 | { | ||
| 477 | struct symbol* sym; | ||
| 478 | int type; | ||
| 479 | tristate oldval; | ||
| 480 | |||
| 481 | sym = item->menu ? item->menu->sym : 0; | ||
| 482 | if (!sym) | ||
| 483 | return; | ||
| 484 | |||
| 485 | type = sym_get_type(sym); | ||
| 486 | switch (type) { | ||
| 487 | case S_BOOLEAN: | ||
| 488 | case S_TRISTATE: | ||
| 489 | oldval = sym_get_tristate_value(sym); | ||
| 490 | |||
| 491 | if (!sym_set_tristate_value(sym, val)) | ||
| 492 | return; | ||
| 493 | if (oldval == no && item->menu->list) | ||
| 494 | item->setOpen(TRUE); | ||
| 495 | parent()->updateList(item); | ||
| 496 | break; | ||
| 497 | } | ||
| 498 | } | ||
| 499 | |||
| 500 | void ConfigList::changeValue(ConfigItem* item) | ||
| 501 | { | ||
| 502 | struct symbol* sym; | ||
| 503 | struct menu* menu; | ||
| 504 | int type, oldexpr, newexpr; | ||
| 505 | |||
| 506 | menu = item->menu; | ||
| 507 | if (!menu) | ||
| 508 | return; | ||
| 509 | sym = menu->sym; | ||
| 510 | if (!sym) { | ||
| 511 | if (item->menu->list) | ||
| 512 | item->setOpen(!item->isOpen()); | ||
| 513 | return; | ||
| 514 | } | ||
| 515 | |||
| 516 | type = sym_get_type(sym); | ||
| 517 | switch (type) { | ||
| 518 | case S_BOOLEAN: | ||
| 519 | case S_TRISTATE: | ||
| 520 | oldexpr = sym_get_tristate_value(sym); | ||
| 521 | newexpr = sym_toggle_tristate_value(sym); | ||
| 522 | if (item->menu->list) { | ||
| 523 | if (oldexpr == newexpr) | ||
| 524 | item->setOpen(!item->isOpen()); | ||
| 525 | else if (oldexpr == no) | ||
| 526 | item->setOpen(TRUE); | ||
| 527 | } | ||
| 528 | if (oldexpr != newexpr) | ||
| 529 | parent()->updateList(item); | ||
| 530 | break; | ||
| 531 | case S_INT: | ||
| 532 | case S_HEX: | ||
| 533 | case S_STRING: | ||
| 534 | if (colMap[dataColIdx] >= 0) | ||
| 535 | item->startRename(colMap[dataColIdx]); | ||
| 536 | else | ||
| 537 | parent()->lineEdit->show(item); | ||
| 538 | break; | ||
| 539 | } | ||
| 540 | } | ||
| 541 | |||
| 542 | void ConfigList::setRootMenu(struct menu *menu) | ||
| 543 | { | ||
| 544 | enum prop_type type; | ||
| 545 | |||
| 546 | if (rootEntry == menu) | ||
| 547 | return; | ||
| 548 | type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
| 549 | if (type != P_MENU) | ||
| 550 | return; | ||
| 551 | updateMenuList(this, 0); | ||
| 552 | rootEntry = menu; | ||
| 553 | updateListAll(); | ||
| 554 | setSelected(currentItem(), hasFocus()); | ||
| 555 | ensureItemVisible(currentItem()); | ||
| 556 | } | ||
| 557 | |||
| 558 | void ConfigList::setParentMenu(void) | ||
| 559 | { | ||
| 560 | ConfigItem* item; | ||
| 561 | struct menu *oldroot; | ||
| 562 | |||
| 563 | oldroot = rootEntry; | ||
| 564 | if (rootEntry == &rootmenu) | ||
| 565 | return; | ||
| 566 | setRootMenu(menu_get_parent_menu(rootEntry->parent)); | ||
| 567 | |||
| 568 | Q3ListViewItemIterator it(this); | ||
| 569 | for (; (item = (ConfigItem*)it.current()); it++) { | ||
| 570 | if (item->menu == oldroot) { | ||
| 571 | setCurrentItem(item); | ||
| 572 | ensureItemVisible(item); | ||
| 573 | break; | ||
| 574 | } | ||
| 575 | } | ||
| 576 | } | ||
| 577 | |||
| 578 | /* | ||
| 579 | * update all the children of a menu entry | ||
| 580 | * removes/adds the entries from the parent widget as necessary | ||
| 581 | * | ||
| 582 | * parent: either the menu list widget or a menu entry widget | ||
| 583 | * menu: entry to be updated | ||
| 584 | */ | ||
| 585 | template <class P> | ||
| 586 | void ConfigList::updateMenuList(P* parent, struct menu* menu) | ||
| 587 | { | ||
| 588 | struct menu* child; | ||
| 589 | ConfigItem* item; | ||
| 590 | ConfigItem* last; | ||
| 591 | bool visible; | ||
| 592 | enum prop_type type; | ||
| 593 | |||
| 594 | if (!menu) { | ||
| 595 | while ((item = parent->firstChild())) | ||
| 596 | delete item; | ||
| 597 | return; | ||
| 598 | } | ||
| 599 | |||
| 600 | last = parent->firstChild(); | ||
| 601 | if (last && !last->goParent) | ||
| 602 | last = 0; | ||
| 603 | for (child = menu->list; child; child = child->next) { | ||
| 604 | item = last ? last->nextSibling() : parent->firstChild(); | ||
| 605 | type = child->prompt ? child->prompt->type : P_UNKNOWN; | ||
| 606 | |||
| 607 | switch (mode) { | ||
| 608 | case menuMode: | ||
| 609 | if (!(child->flags & MENU_ROOT)) | ||
| 610 | goto hide; | ||
| 611 | break; | ||
| 612 | case symbolMode: | ||
| 613 | if (child->flags & MENU_ROOT) | ||
| 614 | goto hide; | ||
| 615 | break; | ||
| 616 | default: | ||
| 617 | break; | ||
| 618 | } | ||
| 619 | |||
| 620 | visible = menu_is_visible(child); | ||
| 621 | if (!menuSkip(child)) { | ||
| 622 | if (!child->sym && !child->list && !child->prompt) | ||
| 623 | continue; | ||
| 624 | if (!item || item->menu != child) | ||
| 625 | item = new ConfigItem(parent, last, child, visible); | ||
| 626 | else | ||
| 627 | item->testUpdateMenu(visible); | ||
| 628 | |||
| 629 | if (mode == fullMode || mode == menuMode || type != P_MENU) | ||
| 630 | updateMenuList(item, child); | ||
| 631 | else | ||
| 632 | updateMenuList(item, 0); | ||
| 633 | last = item; | ||
| 634 | continue; | ||
| 635 | } | ||
| 636 | hide: | ||
| 637 | if (item && item->menu == child) { | ||
| 638 | last = parent->firstChild(); | ||
| 639 | if (last == item) | ||
| 640 | last = 0; | ||
| 641 | else while (last->nextSibling() != item) | ||
| 642 | last = last->nextSibling(); | ||
| 643 | delete item; | ||
| 644 | } | ||
| 645 | } | ||
| 646 | } | ||
| 647 | |||
| 648 | void ConfigList::keyPressEvent(QKeyEvent* ev) | ||
| 649 | { | ||
| 650 | Q3ListViewItem* i = currentItem(); | ||
| 651 | ConfigItem* item; | ||
| 652 | struct menu *menu; | ||
| 653 | enum prop_type type; | ||
| 654 | |||
| 655 | if (ev->key() == Qt::Key_Escape && mode != fullMode && mode != listMode) { | ||
| 656 | emit parentSelected(); | ||
| 657 | ev->accept(); | ||
| 658 | return; | ||
| 659 | } | ||
| 660 | |||
| 661 | if (!i) { | ||
| 662 | Parent::keyPressEvent(ev); | ||
| 663 | return; | ||
| 664 | } | ||
| 665 | item = (ConfigItem*)i; | ||
| 666 | |||
| 667 | switch (ev->key()) { | ||
| 668 | case Qt::Key_Return: | ||
| 669 | case Qt::Key_Enter: | ||
| 670 | if (item->goParent) { | ||
| 671 | emit parentSelected(); | ||
| 672 | break; | ||
| 673 | } | ||
| 674 | menu = item->menu; | ||
| 675 | if (!menu) | ||
| 676 | break; | ||
| 677 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
| 678 | if (type == P_MENU && rootEntry != menu && | ||
| 679 | mode != fullMode && mode != menuMode) { | ||
| 680 | emit menuSelected(menu); | ||
| 681 | break; | ||
| 682 | } | ||
| 683 | case Qt::Key_Space: | ||
| 684 | changeValue(item); | ||
| 685 | break; | ||
| 686 | case Qt::Key_N: | ||
| 687 | setValue(item, no); | ||
| 688 | break; | ||
| 689 | case Qt::Key_M: | ||
| 690 | setValue(item, mod); | ||
| 691 | break; | ||
| 692 | case Qt::Key_Y: | ||
| 693 | setValue(item, yes); | ||
| 694 | break; | ||
| 695 | default: | ||
| 696 | Parent::keyPressEvent(ev); | ||
| 697 | return; | ||
| 698 | } | ||
| 699 | ev->accept(); | ||
| 700 | } | ||
| 701 | |||
| 702 | void ConfigList::contentsMousePressEvent(QMouseEvent* e) | ||
| 703 | { | ||
| 704 | //QPoint p(contentsToViewport(e->pos())); | ||
| 705 | //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); | ||
| 706 | Parent::contentsMousePressEvent(e); | ||
| 707 | } | ||
| 708 | |||
| 709 | void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) | ||
| 710 | { | ||
| 711 | QPoint p(contentsToViewport(e->pos())); | ||
| 712 | ConfigItem* item = (ConfigItem*)itemAt(p); | ||
| 713 | struct menu *menu; | ||
| 714 | enum prop_type ptype; | ||
| 715 | const QPixmap* pm; | ||
| 716 | int idx, x; | ||
| 717 | |||
| 718 | if (!item) | ||
| 719 | goto skip; | ||
| 720 | |||
| 721 | menu = item->menu; | ||
| 722 | x = header()->offset() + p.x(); | ||
| 723 | idx = colRevMap[header()->sectionAt(x)]; | ||
| 724 | switch (idx) { | ||
| 725 | case promptColIdx: | ||
| 726 | pm = item->pixmap(promptColIdx); | ||
| 727 | if (pm) { | ||
| 728 | int off = header()->sectionPos(0) + itemMargin() + | ||
| 729 | treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); | ||
| 730 | if (x >= off && x < off + pm->width()) { | ||
| 731 | if (item->goParent) { | ||
| 732 | emit parentSelected(); | ||
| 733 | break; | ||
| 734 | } else if (!menu) | ||
| 735 | break; | ||
| 736 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
| 737 | if (ptype == P_MENU && rootEntry != menu && | ||
| 738 | mode != fullMode && mode != menuMode) | ||
| 739 | emit menuSelected(menu); | ||
| 740 | else | ||
| 741 | changeValue(item); | ||
| 742 | } | ||
| 743 | } | ||
| 744 | break; | ||
| 745 | case noColIdx: | ||
| 746 | setValue(item, no); | ||
| 747 | break; | ||
| 748 | case modColIdx: | ||
| 749 | setValue(item, mod); | ||
| 750 | break; | ||
| 751 | case yesColIdx: | ||
| 752 | setValue(item, yes); | ||
| 753 | break; | ||
| 754 | case dataColIdx: | ||
| 755 | changeValue(item); | ||
| 756 | break; | ||
| 757 | } | ||
| 758 | |||
| 759 | skip: | ||
| 760 | //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); | ||
| 761 | Parent::contentsMouseReleaseEvent(e); | ||
| 762 | } | ||
| 763 | |||
| 764 | void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) | ||
| 765 | { | ||
| 766 | //QPoint p(contentsToViewport(e->pos())); | ||
| 767 | //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); | ||
| 768 | Parent::contentsMouseMoveEvent(e); | ||
| 769 | } | ||
| 770 | |||
| 771 | void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) | ||
| 772 | { | ||
| 773 | QPoint p(contentsToViewport(e->pos())); | ||
| 774 | ConfigItem* item = (ConfigItem*)itemAt(p); | ||
| 775 | struct menu *menu; | ||
| 776 | enum prop_type ptype; | ||
| 777 | |||
| 778 | if (!item) | ||
| 779 | goto skip; | ||
| 780 | if (item->goParent) { | ||
| 781 | emit parentSelected(); | ||
| 782 | goto skip; | ||
| 783 | } | ||
| 784 | menu = item->menu; | ||
| 785 | if (!menu) | ||
| 786 | goto skip; | ||
| 787 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
| 788 | if (ptype == P_MENU && (mode == singleMode || mode == symbolMode)) | ||
| 789 | emit menuSelected(menu); | ||
| 790 | else if (menu->sym) | ||
| 791 | changeValue(item); | ||
| 792 | |||
| 793 | skip: | ||
| 794 | //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); | ||
| 795 | Parent::contentsMouseDoubleClickEvent(e); | ||
| 796 | } | ||
| 797 | |||
| 798 | void ConfigList::focusInEvent(QFocusEvent *e) | ||
| 799 | { | ||
| 800 | struct menu *menu = NULL; | ||
| 801 | |||
| 802 | Parent::focusInEvent(e); | ||
| 803 | |||
| 804 | ConfigItem* item = (ConfigItem *)currentItem(); | ||
| 805 | if (item) { | ||
| 806 | setSelected(item, TRUE); | ||
| 807 | menu = item->menu; | ||
| 808 | } | ||
| 809 | emit gotFocus(menu); | ||
| 810 | } | ||
| 811 | |||
| 812 | void ConfigList::contextMenuEvent(QContextMenuEvent *e) | ||
| 813 | { | ||
| 814 | if (e->y() <= header()->geometry().bottom()) { | ||
| 815 | if (!headerPopup) { | ||
| 816 | QAction *action; | ||
| 817 | |||
| 818 | headerPopup = new QMenu(this); | ||
| 819 | action = new QAction(_("Show Name"), this); | ||
| 820 | action->setCheckable(TRUE); | ||
| 821 | connect(action, SIGNAL(toggled(bool)), | ||
| 822 | parent(), SLOT(setShowName(bool))); | ||
| 823 | connect(parent(), SIGNAL(showNameChanged(bool)), | ||
| 824 | action, SLOT(setOn(bool))); | ||
| 825 | action->setChecked(showName); | ||
| 826 | action->addTo(headerPopup); | ||
| 827 | action = new QAction(_("Show Range"), this); | ||
| 828 | action->setCheckable(TRUE); | ||
| 829 | connect(action, SIGNAL(toggled(bool)), | ||
| 830 | parent(), SLOT(setShowRange(bool))); | ||
| 831 | connect(parent(), SIGNAL(showRangeChanged(bool)), | ||
| 832 | action, SLOT(setOn(bool))); | ||
| 833 | action->setChecked(showRange); | ||
| 834 | action->addTo(headerPopup); | ||
| 835 | action = new QAction( _("Show Data"), this); | ||
| 836 | action->setCheckable(TRUE); | ||
| 837 | connect(action, SIGNAL(toggled(bool)), | ||
| 838 | parent(), SLOT(setShowData(bool))); | ||
| 839 | connect(parent(), SIGNAL(showDataChanged(bool)), | ||
| 840 | action, SLOT(setOn(bool))); | ||
| 841 | action->setChecked(showData); | ||
| 842 | action->addTo(headerPopup); | ||
| 843 | } | ||
| 844 | headerPopup->exec(e->globalPos()); | ||
| 845 | e->accept(); | ||
| 846 | } else | ||
| 847 | e->ignore(); | ||
| 848 | } | ||
| 849 | |||
| 850 | ConfigView*ConfigView::viewList; | 121 | ConfigView*ConfigView::viewList; |
| 851 | QAction *ConfigView::showNormalAction; | 122 | QAction *ConfigView::showNormalAction; |
| 852 | QAction *ConfigView::showAllAction; | 123 | QAction *ConfigView::showAllAction; |
| @@ -858,7 +129,7 @@ ConfigView::ConfigView(QWidget* parent, const char *name) | |||
| 858 | QVBoxLayout *verticalLayout = new QVBoxLayout(this); | 129 | QVBoxLayout *verticalLayout = new QVBoxLayout(this); |
| 859 | verticalLayout->setContentsMargins(0, 0, 0, 0); | 130 | verticalLayout->setContentsMargins(0, 0, 0, 0); |
| 860 | 131 | ||
| 861 | list = new ConfigList(this, name); | 132 | list = new Q3ListView(this, name); |
| 862 | verticalLayout->addWidget(list); | 133 | verticalLayout->addWidget(list); |
| 863 | lineEdit = new ConfigLineEdit(this); | 134 | lineEdit = new ConfigLineEdit(this); |
| 864 | lineEdit->hide(); | 135 | lineEdit->hide(); |
| @@ -882,65 +153,26 @@ ConfigView::~ConfigView(void) | |||
| 882 | 153 | ||
| 883 | void ConfigView::setOptionMode(QAction *act) | 154 | void ConfigView::setOptionMode(QAction *act) |
| 884 | { | 155 | { |
| 885 | if (act == showNormalAction) | ||
| 886 | list->optMode = normalOpt; | ||
| 887 | else if (act == showAllAction) | ||
| 888 | list->optMode = allOpt; | ||
| 889 | else | ||
| 890 | list->optMode = promptOpt; | ||
| 891 | |||
| 892 | list->updateListAll(); | ||
| 893 | } | 156 | } |
| 894 | 157 | ||
| 895 | void ConfigView::setShowName(bool b) | 158 | void ConfigView::setShowName(bool b) |
| 896 | { | 159 | { |
| 897 | if (list->showName != b) { | ||
| 898 | list->showName = b; | ||
| 899 | list->reinit(); | ||
| 900 | emit showNameChanged(b); | ||
| 901 | } | ||
| 902 | } | 160 | } |
| 903 | 161 | ||
| 904 | void ConfigView::setShowRange(bool b) | 162 | void ConfigView::setShowRange(bool b) |
| 905 | { | 163 | { |
| 906 | if (list->showRange != b) { | ||
| 907 | list->showRange = b; | ||
| 908 | list->reinit(); | ||
| 909 | emit showRangeChanged(b); | ||
| 910 | } | ||
| 911 | } | 164 | } |
| 912 | 165 | ||
| 913 | void ConfigView::setShowData(bool b) | 166 | void ConfigView::setShowData(bool b) |
| 914 | { | 167 | { |
| 915 | if (list->showData != b) { | ||
| 916 | list->showData = b; | ||
| 917 | list->reinit(); | ||
| 918 | emit showDataChanged(b); | ||
| 919 | } | ||
| 920 | } | ||
| 921 | |||
| 922 | void ConfigList::setAllOpen(bool open) | ||
| 923 | { | ||
| 924 | Q3ListViewItemIterator it(this); | ||
| 925 | |||
| 926 | for (; it.current(); it++) | ||
| 927 | it.current()->setOpen(open); | ||
| 928 | } | 168 | } |
| 929 | 169 | ||
| 930 | void ConfigView::updateList(ConfigItem* item) | 170 | void ConfigView::updateList(Q3ListViewItem* item) |
| 931 | { | 171 | { |
| 932 | ConfigView* v; | ||
| 933 | |||
| 934 | for (v = viewList; v; v = v->nextView) | ||
| 935 | v->list->updateList(item); | ||
| 936 | } | 172 | } |
| 937 | 173 | ||
| 938 | void ConfigView::updateListAll(void) | 174 | void ConfigView::updateListAll(void) |
| 939 | { | 175 | { |
| 940 | ConfigView* v; | ||
| 941 | |||
| 942 | for (v = viewList; v; v = v->nextView) | ||
| 943 | v->list->updateListAll(); | ||
| 944 | } | 176 | } |
| 945 | 177 | ||
| 946 | ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) | 178 | ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) |
| @@ -1195,7 +427,6 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam | |||
| 1195 | split = new QSplitter(this); | 427 | split = new QSplitter(this); |
| 1196 | split->setOrientation(Qt::Vertical); | 428 | split->setOrientation(Qt::Vertical); |
| 1197 | list = new ConfigView(split, name); | 429 | list = new ConfigView(split, name); |
| 1198 | list->list->mode = listMode; | ||
| 1199 | info = new ConfigInfoView(split, name); | 430 | info = new ConfigInfoView(split, name); |
| 1200 | connect(list->list, SIGNAL(menuChanged(struct menu *)), | 431 | connect(list->list, SIGNAL(menuChanged(struct menu *)), |
| 1201 | info, SLOT(setInfo(struct menu *))); | 432 | info, SLOT(setInfo(struct menu *))); |
| @@ -1240,22 +471,6 @@ void ConfigSearchWindow::saveSettings(void) | |||
| 1240 | 471 | ||
| 1241 | void ConfigSearchWindow::search(void) | 472 | void ConfigSearchWindow::search(void) |
| 1242 | { | 473 | { |
| 1243 | struct symbol **p; | ||
| 1244 | struct property *prop; | ||
| 1245 | ConfigItem *lastItem = NULL; | ||
| 1246 | |||
| 1247 | free(result); | ||
| 1248 | list->list->clear(); | ||
| 1249 | info->clear(); | ||
| 1250 | |||
| 1251 | result = sym_re_search(editField->text().latin1()); | ||
| 1252 | if (!result) | ||
| 1253 | return; | ||
| 1254 | for (p = result; *p; p++) { | ||
| 1255 | for_all_prompts((*p), prop) | ||
| 1256 | lastItem = new ConfigItem(list->list, lastItem, prop->menu, | ||
| 1257 | menu_is_visible(prop->menu)); | ||
| 1258 | } | ||
| 1259 | } | 474 | } |
| 1260 | 475 | ||
| 1261 | /* | 476 | /* |
| @@ -1348,12 +563,10 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
| 1348 | showRangeAction->setCheckable(TRUE); | 563 | showRangeAction->setCheckable(TRUE); |
| 1349 | connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); | 564 | connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); |
| 1350 | connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool))); | 565 | connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool))); |
| 1351 | showRangeAction->setChecked(configList->showRange); | ||
| 1352 | QAction *showDataAction = new QAction(_("Show Data"), this); | 566 | QAction *showDataAction = new QAction(_("Show Data"), this); |
| 1353 | showDataAction->setCheckable(TRUE); | 567 | showDataAction->setCheckable(TRUE); |
| 1354 | connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); | 568 | connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); |
| 1355 | connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); | 569 | connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); |
| 1356 | showDataAction->setChecked(configList->showData); | ||
| 1357 | 570 | ||
| 1358 | QActionGroup *optGroup = new QActionGroup(this); | 571 | QActionGroup *optGroup = new QActionGroup(this); |
| 1359 | optGroup->setExclusive(TRUE); | 572 | optGroup->setExclusive(TRUE); |
| @@ -1366,11 +579,8 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
| 1366 | configView->showAllAction = new QAction(_("Show All Options"), optGroup); | 579 | configView->showAllAction = new QAction(_("Show All Options"), optGroup); |
| 1367 | configView->showPromptAction = new QAction(_("Show Prompt Options"), optGroup); | 580 | configView->showPromptAction = new QAction(_("Show Prompt Options"), optGroup); |
| 1368 | configView->showNormalAction->setCheckable(TRUE); | 581 | configView->showNormalAction->setCheckable(TRUE); |
| 1369 | configView->showNormalAction->setChecked(configList->optMode == normalOpt); | ||
| 1370 | configView->showAllAction->setCheckable(TRUE); | 582 | configView->showAllAction->setCheckable(TRUE); |
| 1371 | configView->showAllAction->setChecked(configList->optMode == allOpt); | ||
| 1372 | configView->showPromptAction->setCheckable(TRUE); | 583 | configView->showPromptAction->setCheckable(TRUE); |
| 1373 | configView->showPromptAction->setChecked(configList->optMode == promptOpt); | ||
| 1374 | 584 | ||
| 1375 | QAction *showDebugAction = new QAction( _("Show Debug Info"), this); | 585 | QAction *showDebugAction = new QAction( _("Show Debug Info"), this); |
| 1376 | showDebugAction->setCheckable(TRUE); | 586 | showDebugAction->setCheckable(TRUE); |
| @@ -1498,86 +708,19 @@ void ConfigMainWindow::searchConfig(void) | |||
| 1498 | 708 | ||
| 1499 | void ConfigMainWindow::changeMenu(struct menu *menu) | 709 | void ConfigMainWindow::changeMenu(struct menu *menu) |
| 1500 | { | 710 | { |
| 1501 | configList->setRootMenu(menu); | 711 | |
| 1502 | if (configList->rootEntry->parent == &rootmenu) | ||
| 1503 | backAction->setEnabled(FALSE); | ||
| 1504 | else | ||
| 1505 | backAction->setEnabled(TRUE); | ||
| 1506 | } | 712 | } |
| 1507 | 713 | ||
| 1508 | void ConfigMainWindow::setMenuLink(struct menu *menu) | 714 | void ConfigMainWindow::setMenuLink(struct menu *menu) |
| 1509 | { | 715 | { |
| 1510 | struct menu *parent; | ||
| 1511 | ConfigList* list = NULL; | ||
| 1512 | ConfigItem* item; | ||
| 1513 | |||
| 1514 | if (configList->menuSkip(menu)) | ||
| 1515 | return; | ||
| 1516 | |||
| 1517 | switch (configList->mode) { | ||
| 1518 | case singleMode: | ||
| 1519 | list = configList; | ||
| 1520 | parent = menu_get_parent_menu(menu); | ||
| 1521 | if (!parent) | ||
| 1522 | return; | ||
| 1523 | list->setRootMenu(parent); | ||
| 1524 | break; | ||
| 1525 | case symbolMode: | ||
| 1526 | if (menu->flags & MENU_ROOT) { | ||
| 1527 | configList->setRootMenu(menu); | ||
| 1528 | configList->clearSelection(); | ||
| 1529 | list = menuList; | ||
| 1530 | } else { | ||
| 1531 | list = configList; | ||
| 1532 | parent = menu_get_parent_menu(menu->parent); | ||
| 1533 | if (!parent) | ||
| 1534 | return; | ||
| 1535 | item = menuList->findConfigItem(parent); | ||
| 1536 | if (item) { | ||
| 1537 | menuList->setSelected(item, TRUE); | ||
| 1538 | menuList->ensureItemVisible(item); | ||
| 1539 | } | ||
| 1540 | list->setRootMenu(parent); | ||
| 1541 | } | ||
| 1542 | break; | ||
| 1543 | case fullMode: | ||
| 1544 | list = configList; | ||
| 1545 | break; | ||
| 1546 | default: | ||
| 1547 | break; | ||
| 1548 | } | ||
| 1549 | |||
| 1550 | if (list) { | ||
| 1551 | item = list->findConfigItem(menu); | ||
| 1552 | if (item) { | ||
| 1553 | list->setSelected(item, TRUE); | ||
| 1554 | list->ensureItemVisible(item); | ||
| 1555 | list->setFocus(); | ||
| 1556 | } | ||
| 1557 | } | ||
| 1558 | } | 716 | } |
| 1559 | 717 | ||
| 1560 | void ConfigMainWindow::listFocusChanged(void) | 718 | void ConfigMainWindow::listFocusChanged(void) |
| 1561 | { | 719 | { |
| 1562 | if (menuList->mode == menuMode) | ||
| 1563 | configList->clearSelection(); | ||
| 1564 | } | 720 | } |
| 1565 | 721 | ||
| 1566 | void ConfigMainWindow::goBack(void) | 722 | void ConfigMainWindow::goBack(void) |
| 1567 | { | 723 | { |
| 1568 | ConfigItem* item; | ||
| 1569 | |||
| 1570 | configList->setParentMenu(); | ||
| 1571 | if (configList->rootEntry == &rootmenu) | ||
| 1572 | backAction->setEnabled(FALSE); | ||
| 1573 | item = (ConfigItem*)menuList->selectedItem(); | ||
| 1574 | while (item) { | ||
| 1575 | if (item->menu == configList->rootEntry) { | ||
| 1576 | menuList->setSelected(item, TRUE); | ||
| 1577 | break; | ||
| 1578 | } | ||
| 1579 | item = (ConfigItem*)item->parent(); | ||
| 1580 | } | ||
| 1581 | } | 724 | } |
| 1582 | 725 | ||
| 1583 | void ConfigMainWindow::showSingleView(void) | 726 | void ConfigMainWindow::showSingleView(void) |
| @@ -1590,13 +733,6 @@ void ConfigMainWindow::showSingleView(void) | |||
| 1590 | fullViewAction->setChecked(false); | 733 | fullViewAction->setChecked(false); |
| 1591 | 734 | ||
| 1592 | menuView->hide(); | 735 | menuView->hide(); |
| 1593 | menuList->setRootMenu(0); | ||
| 1594 | configList->mode = singleMode; | ||
| 1595 | if (configList->rootEntry == &rootmenu) | ||
| 1596 | configList->updateListAll(); | ||
| 1597 | else | ||
| 1598 | configList->setRootMenu(&rootmenu); | ||
| 1599 | configList->setAllOpen(TRUE); | ||
| 1600 | configList->setFocus(); | 736 | configList->setFocus(); |
| 1601 | } | 737 | } |
| 1602 | 738 | ||
| @@ -1609,16 +745,6 @@ void ConfigMainWindow::showSplitView(void) | |||
| 1609 | fullViewAction->setEnabled(true); | 745 | fullViewAction->setEnabled(true); |
| 1610 | fullViewAction->setChecked(false); | 746 | fullViewAction->setChecked(false); |
| 1611 | 747 | ||
| 1612 | configList->mode = symbolMode; | ||
| 1613 | if (configList->rootEntry == &rootmenu) | ||
| 1614 | configList->updateListAll(); | ||
| 1615 | else | ||
| 1616 | configList->setRootMenu(&rootmenu); | ||
| 1617 | configList->setAllOpen(TRUE); | ||
| 1618 | configApp->processEvents(); | ||
| 1619 | menuList->mode = menuMode; | ||
| 1620 | menuList->setRootMenu(&rootmenu); | ||
| 1621 | menuList->setAllOpen(TRUE); | ||
| 1622 | menuView->show(); | 748 | menuView->show(); |
| 1623 | menuList->setFocus(); | 749 | menuList->setFocus(); |
| 1624 | } | 750 | } |
| @@ -1633,13 +759,6 @@ void ConfigMainWindow::showFullView(void) | |||
| 1633 | fullViewAction->setChecked(true); | 759 | fullViewAction->setChecked(true); |
| 1634 | 760 | ||
| 1635 | menuView->hide(); | 761 | menuView->hide(); |
| 1636 | menuList->setRootMenu(0); | ||
| 1637 | configList->mode = fullMode; | ||
| 1638 | if (configList->rootEntry == &rootmenu) | ||
| 1639 | configList->updateListAll(); | ||
| 1640 | else | ||
| 1641 | configList->setRootMenu(&rootmenu); | ||
| 1642 | configList->setAllOpen(FALSE); | ||
| 1643 | configList->setFocus(); | 762 | configList->setFocus(); |
| 1644 | } | 763 | } |
| 1645 | 764 | ||
| @@ -1707,22 +826,7 @@ void ConfigMainWindow::saveSettings(void) | |||
| 1707 | configSettings->writeEntry("/window height", size().height()); | 826 | configSettings->writeEntry("/window height", size().height()); |
| 1708 | 827 | ||
| 1709 | QString entry; | 828 | QString entry; |
| 1710 | switch(configList->mode) { | ||
| 1711 | case singleMode : | ||
| 1712 | entry = "single"; | ||
| 1713 | break; | ||
| 1714 | |||
| 1715 | case symbolMode : | ||
| 1716 | entry = "split"; | ||
| 1717 | break; | ||
| 1718 | |||
| 1719 | case fullMode : | ||
| 1720 | entry = "full"; | ||
| 1721 | break; | ||
| 1722 | 829 | ||
| 1723 | default: | ||
| 1724 | break; | ||
| 1725 | } | ||
| 1726 | configSettings->writeEntry("/listMode", entry); | 830 | configSettings->writeEntry("/listMode", entry); |
| 1727 | 831 | ||
| 1728 | configSettings->writeSizes("/split1", split1->sizes()); | 832 | configSettings->writeSizes("/split1", split1->sizes()); |
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 213990129e51..d025f29694c6 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h | |||
| @@ -8,8 +8,6 @@ | |||
| 8 | #include <qsettings.h> | 8 | #include <qsettings.h> |
| 9 | 9 | ||
| 10 | class ConfigView; | 10 | class ConfigView; |
| 11 | class ConfigList; | ||
| 12 | class ConfigItem; | ||
| 13 | class ConfigLineEdit; | 11 | class ConfigLineEdit; |
| 14 | class ConfigMainWindow; | 12 | class ConfigMainWindow; |
| 15 | 13 | ||
| @@ -30,159 +28,6 @@ enum optionMode { | |||
| 30 | normalOpt = 0, allOpt, promptOpt | 28 | normalOpt = 0, allOpt, promptOpt |
| 31 | }; | 29 | }; |
| 32 | 30 | ||
| 33 | class ConfigList : public Q3ListView { | ||
| 34 | Q_OBJECT | ||
| 35 | typedef class Q3ListView Parent; | ||
| 36 | public: | ||
| 37 | ConfigList(ConfigView* p, const char *name = 0); | ||
| 38 | void reinit(void); | ||
| 39 | ConfigView* parent(void) const | ||
| 40 | { | ||
| 41 | return (ConfigView*)Parent::parent(); | ||
| 42 | } | ||
| 43 | ConfigItem* findConfigItem(struct menu *); | ||
| 44 | |||
| 45 | protected: | ||
| 46 | void keyPressEvent(QKeyEvent *e); | ||
| 47 | void contentsMousePressEvent(QMouseEvent *e); | ||
| 48 | void contentsMouseReleaseEvent(QMouseEvent *e); | ||
| 49 | void contentsMouseMoveEvent(QMouseEvent *e); | ||
| 50 | void contentsMouseDoubleClickEvent(QMouseEvent *e); | ||
| 51 | void focusInEvent(QFocusEvent *e); | ||
| 52 | void contextMenuEvent(QContextMenuEvent *e); | ||
| 53 | |||
| 54 | public slots: | ||
| 55 | void setRootMenu(struct menu *menu); | ||
| 56 | |||
| 57 | void updateList(ConfigItem *item); | ||
| 58 | void setValue(ConfigItem* item, tristate val); | ||
| 59 | void changeValue(ConfigItem* item); | ||
| 60 | void updateSelection(void); | ||
| 61 | void saveSettings(void); | ||
| 62 | signals: | ||
| 63 | void menuChanged(struct menu *menu); | ||
| 64 | void menuSelected(struct menu *menu); | ||
| 65 | void parentSelected(void); | ||
| 66 | void gotFocus(struct menu *); | ||
| 67 | |||
| 68 | public: | ||
| 69 | void updateListAll(void) | ||
| 70 | { | ||
| 71 | updateAll = true; | ||
| 72 | updateList(NULL); | ||
| 73 | updateAll = false; | ||
| 74 | } | ||
| 75 | ConfigList* listView() | ||
| 76 | { | ||
| 77 | return this; | ||
| 78 | } | ||
| 79 | ConfigItem* firstChild() const | ||
| 80 | { | ||
| 81 | return (ConfigItem *)Parent::firstChild(); | ||
| 82 | } | ||
| 83 | int mapIdx(colIdx idx) | ||
| 84 | { | ||
| 85 | return colMap[idx]; | ||
| 86 | } | ||
| 87 | void addColumn(colIdx idx, const QString& label) | ||
| 88 | { | ||
| 89 | colMap[idx] = Parent::addColumn(label); | ||
| 90 | colRevMap[colMap[idx]] = idx; | ||
| 91 | } | ||
| 92 | void removeColumn(colIdx idx) | ||
| 93 | { | ||
| 94 | int col = colMap[idx]; | ||
| 95 | if (col >= 0) { | ||
| 96 | Parent::removeColumn(col); | ||
| 97 | colRevMap[col] = colMap[idx] = -1; | ||
| 98 | } | ||
| 99 | } | ||
| 100 | void setAllOpen(bool open); | ||
| 101 | void setParentMenu(void); | ||
| 102 | |||
| 103 | bool menuSkip(struct menu *); | ||
| 104 | |||
| 105 | template <class P> | ||
| 106 | void updateMenuList(P*, struct menu*); | ||
| 107 | |||
| 108 | bool updateAll; | ||
| 109 | |||
| 110 | QPixmap symbolYesPix, symbolModPix, symbolNoPix; | ||
| 111 | QPixmap choiceYesPix, choiceNoPix; | ||
| 112 | QPixmap menuPix, menuInvPix, menuBackPix, voidPix; | ||
| 113 | |||
| 114 | bool showName, showRange, showData; | ||
| 115 | enum listMode mode; | ||
| 116 | enum optionMode optMode; | ||
| 117 | struct menu *rootEntry; | ||
| 118 | QColorGroup disabledColorGroup; | ||
| 119 | QColorGroup inactivedColorGroup; | ||
| 120 | QMenu* headerPopup; | ||
| 121 | |||
| 122 | private: | ||
| 123 | int colMap[colNr]; | ||
| 124 | int colRevMap[colNr]; | ||
| 125 | }; | ||
| 126 | |||
| 127 | class ConfigItem : public Q3ListViewItem { | ||
| 128 | typedef class Q3ListViewItem Parent; | ||
| 129 | public: | ||
| 130 | ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v) | ||
| 131 | : Parent(parent, after), menu(m), visible(v), goParent(false) | ||
| 132 | { | ||
| 133 | init(); | ||
| 134 | } | ||
| 135 | ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) | ||
| 136 | : Parent(parent, after), menu(m), visible(v), goParent(false) | ||
| 137 | { | ||
| 138 | init(); | ||
| 139 | } | ||
| 140 | ConfigItem(Q3ListView *parent, ConfigItem *after, bool v) | ||
| 141 | : Parent(parent, after), menu(0), visible(v), goParent(true) | ||
| 142 | { | ||
| 143 | init(); | ||
| 144 | } | ||
| 145 | ~ConfigItem(void); | ||
| 146 | void init(void); | ||
| 147 | void okRename(int col); | ||
| 148 | void updateMenu(void); | ||
| 149 | void testUpdateMenu(bool v); | ||
| 150 | ConfigList* listView() const | ||
| 151 | { | ||
| 152 | return (ConfigList*)Parent::listView(); | ||
| 153 | } | ||
| 154 | ConfigItem* firstChild() const | ||
| 155 | { | ||
| 156 | return (ConfigItem *)Parent::firstChild(); | ||
| 157 | } | ||
| 158 | ConfigItem* nextSibling() const | ||
| 159 | { | ||
| 160 | return (ConfigItem *)Parent::nextSibling(); | ||
| 161 | } | ||
| 162 | void setText(colIdx idx, const QString& text) | ||
| 163 | { | ||
| 164 | Parent::setText(listView()->mapIdx(idx), text); | ||
| 165 | } | ||
| 166 | QString text(colIdx idx) const | ||
| 167 | { | ||
| 168 | return Parent::text(listView()->mapIdx(idx)); | ||
| 169 | } | ||
| 170 | void setPixmap(colIdx idx, const QPixmap& pm) | ||
| 171 | { | ||
| 172 | Parent::setPixmap(listView()->mapIdx(idx), pm); | ||
| 173 | } | ||
| 174 | const QPixmap* pixmap(colIdx idx) const | ||
| 175 | { | ||
| 176 | return Parent::pixmap(listView()->mapIdx(idx)); | ||
| 177 | } | ||
| 178 | void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); | ||
| 179 | |||
| 180 | ConfigItem* nextItem; | ||
| 181 | struct menu *menu; | ||
| 182 | bool visible; | ||
| 183 | bool goParent; | ||
| 184 | }; | ||
| 185 | |||
| 186 | class ConfigLineEdit : public QLineEdit { | 31 | class ConfigLineEdit : public QLineEdit { |
| 187 | Q_OBJECT | 32 | Q_OBJECT |
| 188 | typedef class QLineEdit Parent; | 33 | typedef class QLineEdit Parent; |
| @@ -192,11 +37,11 @@ public: | |||
| 192 | { | 37 | { |
| 193 | return (ConfigView*)Parent::parent(); | 38 | return (ConfigView*)Parent::parent(); |
| 194 | } | 39 | } |
| 195 | void show(ConfigItem *i); | 40 | void show(Q3ListViewItem *i); |
| 196 | void keyPressEvent(QKeyEvent *e); | 41 | void keyPressEvent(QKeyEvent *e); |
| 197 | 42 | ||
| 198 | public: | 43 | public: |
| 199 | ConfigItem *item; | 44 | Q3ListViewItem *item; |
| 200 | }; | 45 | }; |
| 201 | 46 | ||
| 202 | class ConfigView : public QWidget { | 47 | class ConfigView : public QWidget { |
| @@ -205,12 +50,12 @@ class ConfigView : public QWidget { | |||
| 205 | public: | 50 | public: |
| 206 | ConfigView(QWidget* parent, const char *name = 0); | 51 | ConfigView(QWidget* parent, const char *name = 0); |
| 207 | ~ConfigView(void); | 52 | ~ConfigView(void); |
| 208 | static void updateList(ConfigItem* item); | 53 | static void updateList(Q3ListViewItem* item); |
| 209 | static void updateListAll(void); | 54 | static void updateListAll(void); |
| 210 | 55 | ||
| 211 | bool showName(void) const { return list->showName; } | 56 | bool showName(void) const { return false; } // TODO: Implement me. |
| 212 | bool showRange(void) const { return list->showRange; } | 57 | bool showRange(void) const { return false; } // TODO: Implement me. |
| 213 | bool showData(void) const { return list->showData; } | 58 | bool showData(void) const { return false; } // TODO: Implement me. |
| 214 | public slots: | 59 | public slots: |
| 215 | void setShowName(bool); | 60 | void setShowName(bool); |
| 216 | void setShowRange(bool); | 61 | void setShowRange(bool); |
| @@ -221,7 +66,7 @@ signals: | |||
| 221 | void showRangeChanged(bool); | 66 | void showRangeChanged(bool); |
| 222 | void showDataChanged(bool); | 67 | void showDataChanged(bool); |
| 223 | public: | 68 | public: |
| 224 | ConfigList* list; | 69 | Q3ListView* list; |
| 225 | ConfigLineEdit* lineEdit; | 70 | ConfigLineEdit* lineEdit; |
| 226 | 71 | ||
| 227 | static ConfigView* viewList; | 72 | static ConfigView* viewList; |
| @@ -310,15 +155,15 @@ protected: | |||
| 310 | 155 | ||
| 311 | ConfigSearchWindow *searchWindow; | 156 | ConfigSearchWindow *searchWindow; |
| 312 | ConfigView *menuView; | 157 | ConfigView *menuView; |
| 313 | ConfigList *menuList; | 158 | Q3ListView *menuList; |
| 314 | ConfigView *configView; | 159 | ConfigView *configView; |
| 315 | ConfigList *configList; | 160 | Q3ListView *configList; |
| 316 | ConfigInfoView *helpText; | 161 | ConfigInfoView *helpText; |
| 317 | QToolBar *toolBar; | 162 | QToolBar *toolBar; |
| 318 | QAction *backAction; | 163 | QAction *backAction; |
| 319 | QAction *singleViewAction; | 164 | QAction *singleViewAction; |
| 320 | QAction *splitViewAction; | 165 | QAction *splitViewAction; |
| 321 | QAction *fullViewAction; | 166 | QAction *fullViewAction; |
| 322 | QSplitter* split1; | 167 | QSplitter *split1; |
| 323 | QSplitter* split2; | 168 | QSplitter *split2; |
| 324 | }; | 169 | }; |
