Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild

Pull kconfig updates from Michal Marek:

- 'make xconfig' ported to Qt5, dropping support for Qt3

- merge_config.sh supports a single-input-file mode and also respects
$KCONFIG_CONFIG

- Fix for incorrect display of >= and > in dependency expressions

* 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: (44 commits)
Add current selection check.
Use pkg-config to find Qt 4 and 5 instead of direct qmake
kconfig: Fix copy&paste error
kconfig/merge_config.sh: Accept a single file
kconfig/merge_config.sh: Support KCONFIG_CONFIG
Update the buildsystem for KConfig finding Qt
Port xconfig to Qt5 - Update copyright.
Port xconfig to Qt5 - Fix goParent issue.
Port xconfig to Qt5 - on Back clicked, deselect old item.
Port xconfig to Qt5 - Add(back) one click checkbox toggle.
Port xconfig to Qt5 - Add(back) lineedit editing.
Port xconfig to Qt5 - Remove some commented code.
Port xconfig to Qt5 - Source format.
Port xconfig to Qt5 - Add horizontal scrollbar, and scroll per pixel.
Port xconfig to Qt5 - Change ConfigItem constructor parent type.
Port xconfig to Qt5 - Disable ConfigList soring
Port xconfig to Qt5 - Remove ConfigList::updateMenuList template.
Port xconfig to Qt5 - Add ConfigList::mode to initializer list.
Port xconfig to Qt5 - Add ConfigItem::nextItem to initializer list.
Port xconfig to Qt5 - Tree widget set column titles.
...

+791 -433
+57
Documentation/kbuild/Kconfig.recursion-issue-01
··· 1 + # Simple Kconfig recursive issue 2 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 + # 4 + # Test with: 5 + # 6 + # make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-01 allnoconfig 7 + # 8 + # This Kconfig file has a simple recursive dependency issue. In order to 9 + # understand why this recursive dependency issue occurs lets consider what 10 + # Kconfig needs to address. We iterate over what Kconfig needs to address 11 + # by stepping through the questions it needs to address sequentially. 12 + # 13 + # * What values are possible for CORE? 14 + # 15 + # CORE_BELL_A_ADVANCED selects CORE, which means that it influences the values 16 + # that are possible for CORE. So for example if CORE_BELL_A_ADVANCED is 'y', 17 + # CORE must be 'y' too. 18 + # 19 + # * What influences CORE_BELL_A_ADVANCED ? 20 + # 21 + # As the name implies CORE_BELL_A_ADVANCED is an advanced feature of 22 + # CORE_BELL_A so naturally it depends on CORE_BELL_A. So if CORE_BELL_A is 'y' 23 + # we know CORE_BELL_A_ADVANCED can be 'y' too. 24 + # 25 + # * What influences CORE_BELL_A ? 26 + # 27 + # CORE_BELL_A depends on CORE, so CORE influences CORE_BELL_A. 28 + # 29 + # But that is a problem, because this means that in order to determine 30 + # what values are possible for CORE we ended up needing to address questions 31 + # regarding possible values of CORE itself again. Answering the original 32 + # question of what are the possible values of CORE would make the kconfig 33 + # tools run in a loop. When this happens Kconfig exits and complains about 34 + # the "recursive dependency detected" error. 35 + # 36 + # Reading the Documentation/kbuild/Kconfig.recursion-issue-01 file it may be 37 + # obvious that an easy to solution to this problem should just be the removal 38 + # of the "select CORE" from CORE_BELL_A_ADVANCED as that is implicit already 39 + # since CORE_BELL_A depends on CORE. Recursive dependency issues are not always 40 + # so trivial to resolve, we provide another example below of practical 41 + # implications of this recursive issue where the solution is perhaps not so 42 + # easy to understand. Note that matching semantics on the dependency on 43 + # CORE also consist of a solution to this recursive problem. 44 + 45 + mainmenu "Simple example to demo kconfig recursive dependency issue" 46 + 47 + config CORE 48 + tristate 49 + 50 + config CORE_BELL_A 51 + tristate 52 + depends on CORE 53 + 54 + config CORE_BELL_A_ADVANCED 55 + tristate 56 + depends on CORE_BELL_A 57 + select CORE
+63
Documentation/kbuild/Kconfig.recursion-issue-02
··· 1 + # Cumulative Kconfig recursive issue 2 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 + # 4 + # Test with: 5 + # 6 + # make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig 7 + # 8 + # The recursive limitations with Kconfig has some non intuitive implications on 9 + # kconfig sematics which are documented here. One known practical implication 10 + # of the recursive limitation is that drivers cannot negate features from other 11 + # drivers if they share a common core requirement and use disjoint semantics to 12 + # annotate those requirements, ie, some drivers use "depends on" while others 13 + # use "select". For instance it means if a driver A and driver B share the same 14 + # core requirement, and one uses "select" while the other uses "depends on" to 15 + # annotate this, all features that driver A selects cannot now be negated by 16 + # driver B. 17 + # 18 + # A perhaps not so obvious implication of this is that, if semantics on these 19 + # core requirements are not carefully synced, as drivers evolve features 20 + # they select or depend on end up becoming shared requirements which cannot be 21 + # negated by other drivers. 22 + # 23 + # The example provided in Documentation/kbuild/Kconfig.recursion-issue-02 24 + # describes a simple driver core layout of example features a kernel might 25 + # have. Let's assume we have some CORE functionality, then the kernel has a 26 + # series of bells and whistles it desires to implement, its not so advanced so 27 + # it only supports bells at this time: CORE_BELL_A and CORE_BELL_B. If 28 + # CORE_BELL_A has some advanced feature CORE_BELL_A_ADVANCED which selects 29 + # CORE_BELL_A then CORE_BELL_A ends up becoming a common BELL feature which 30 + # other bells in the system cannot negate. The reason for this issue is 31 + # due to the disjoint use of semantics on expressing each bell's relationship 32 + # with CORE, one uses "depends on" while the other uses "select". Another 33 + # more important reason is that kconfig does not check for dependencies listed 34 + # under 'select' for a symbol, when such symbols are selected kconfig them 35 + # as mandatory required symbols. For more details on the heavy handed nature 36 + # of select refer to Documentation/kbuild/Kconfig.select-break 37 + # 38 + # To fix this the "depends on CORE" must be changed to "select CORE", or the 39 + # "select CORE" must be changed to "depends on CORE". 40 + # 41 + # For an example real world scenario issue refer to the attempt to remove 42 + # "select FW_LOADER" [0], in the end the simple alternative solution to this 43 + # problem consisted on matching semantics with newly introduced features. 44 + # 45 + # [0] http://lkml.kernel.org/r/1432241149-8762-1-git-send-email-mcgrof@do-not-panic.com 46 + 47 + mainmenu "Simple example to demo cumulative kconfig recursive dependency implication" 48 + 49 + config CORE 50 + tristate 51 + 52 + config CORE_BELL_A 53 + tristate 54 + depends on CORE 55 + 56 + config CORE_BELL_A_ADVANCED 57 + tristate 58 + select CORE_BELL_A 59 + 60 + config CORE_BELL_B 61 + tristate 62 + depends on !CORE_BELL_A 63 + select CORE
+33
Documentation/kbuild/Kconfig.select-break
··· 1 + # Select broken dependency issue 2 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 + # 4 + # Test with: 5 + # 6 + # make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.select-break menuconfig 7 + # 8 + # kconfig will not complain and enable this layout for configuration. This is 9 + # currently a feature of kconfig, given select was designed to be heavy handed. 10 + # Kconfig currently does not check the list of symbols listed on a symbol's 11 + # "select" list, this is done on purpose to help load a set of known required 12 + # symbols. Because of this use of select should be used with caution. An 13 + # example of this issue is below. 14 + # 15 + # The option B and C are clearly contradicting with respect to A. 16 + # However, when A is set, C can be set as well because Kconfig does not 17 + # visit the dependencies of the select target (in this case B). And since 18 + # Kconfig does not visit the dependencies, it breaks the dependencies of B 19 + # (!A). 20 + 21 + mainmenu "Simple example to demo kconfig select broken dependency issue" 22 + 23 + config A 24 + bool "CONFIG A" 25 + 26 + config B 27 + bool "CONFIG B" 28 + depends on !A 29 + 30 + config C 31 + bool "CONFIG C" 32 + depends on A 33 + select B
+161
Documentation/kbuild/kconfig-language.txt
··· 393 393 depends on BAR && m 394 394 395 395 limits FOO to module (=m) or disabled (=n). 396 + 397 + Kconfig recursive dependency limitations 398 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 399 + 400 + If you've hit the Kconfig error: "recursive dependency detected" you've run 401 + into a recursive dependency issue with Kconfig, a recursive dependency can be 402 + summarized as a circular dependency. The kconfig tools need to ensure that 403 + Kconfig files comply with specified configuration requirements. In order to do 404 + that kconfig must determine the values that are possible for all Kconfig 405 + symbols, this is currently not possible if there is a circular relation 406 + between two or more Kconfig symbols. For more details refer to the "Simple 407 + Kconfig recursive issue" subsection below. Kconfig does not do recursive 408 + dependency resolution; this has a few implications for Kconfig file writers. 409 + We'll first explain why this issues exists and then provide an example 410 + technical limitation which this brings upon Kconfig developers. Eager 411 + developers wishing to try to address this limitation should read the next 412 + subsections. 413 + 414 + Simple Kconfig recursive issue 415 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 416 + 417 + Read: Documentation/kbuild/Kconfig.recursion-issue-01 418 + 419 + Test with: 420 + 421 + make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-01 allnoconfig 422 + 423 + Cumulative Kconfig recursive issue 424 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 425 + 426 + Read: Documentation/kbuild/Kconfig.recursion-issue-02 427 + 428 + Test with: 429 + 430 + make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig 431 + 432 + Practical solutions to kconfig recursive issue 433 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 434 + 435 + Developers who run into the recursive Kconfig issue have three options 436 + at their disposal. We document them below and also provide a list of 437 + historical issues resolved through these different solutions. 438 + 439 + a) Remove any superfluous "select FOO" or "depends on FOO" 440 + b) Match dependency semantics: 441 + b1) Swap all "select FOO" to "depends on FOO" or, 442 + b2) Swap all "depends on FOO" to "select FOO" 443 + 444 + The resolution to a) can be tested with the sample Kconfig file 445 + Documentation/kbuild/Kconfig.recursion-issue-01 through the removal 446 + of the "select CORE" from CORE_BELL_A_ADVANCED as that is implicit already 447 + since CORE_BELL_A depends on CORE. At times it may not be possible to remove 448 + some dependency criteria, for such cases you can work with solution b). 449 + 450 + The two different resolutions for b) can be tested in the sample Kconfig file 451 + Documentation/kbuild/Kconfig.recursion-issue-02. 452 + 453 + Below is a list of examples of prior fixes for these types of recursive issues; 454 + all errors appear to involve one or more select's and one or more "depends on". 455 + 456 + commit fix 457 + ====== === 458 + 06b718c01208 select A -> depends on A 459 + c22eacfe82f9 depends on A -> depends on B 460 + 6a91e854442c select A -> depends on A 461 + 118c565a8f2e select A -> select B 462 + f004e5594705 select A -> depends on A 463 + c7861f37b4c6 depends on A -> (null) 464 + 80c69915e5fb select A -> (null) (1) 465 + c2218e26c0d0 select A -> depends on A (1) 466 + d6ae99d04e1c select A -> depends on A 467 + 95ca19cf8cbf select A -> depends on A 468 + 8f057d7bca54 depends on A -> (null) 469 + 8f057d7bca54 depends on A -> select A 470 + a0701f04846e select A -> depends on A 471 + 0c8b92f7f259 depends on A -> (null) 472 + e4e9e0540928 select A -> depends on A (2) 473 + 7453ea886e87 depends on A > (null) (1) 474 + 7b1fff7e4fdf select A -> depends on A 475 + 86c747d2a4f0 select A -> depends on A 476 + d9f9ab51e55e select A -> depends on A 477 + 0c51a4d8abd6 depends on A -> select A (3) 478 + e98062ed6dc4 select A -> depends on A (3) 479 + 91e5d284a7f1 select A -> (null) 480 + 481 + (1) Partial (or no) quote of error. 482 + (2) That seems to be the gist of that fix. 483 + (3) Same error. 484 + 485 + Future kconfig work 486 + ~~~~~~~~~~~~~~~~~~~ 487 + 488 + Work on kconfig is welcomed on both areas of clarifying semantics and on 489 + evaluating the use of a full SAT solver for it. A full SAT solver can be 490 + desirable to enable more complex dependency mappings and / or queries, 491 + for instance on possible use case for a SAT solver could be that of handling 492 + the current known recursive dependency issues. It is not known if this would 493 + address such issues but such evaluation is desirable. If support for a full SAT 494 + solver proves too complex or that it cannot address recursive dependency issues 495 + Kconfig should have at least clear and well defined semantics which also 496 + addresses and documents limitations or requirements such as the ones dealing 497 + with recursive dependencies. 498 + 499 + Further work on both of these areas is welcomed on Kconfig. We elaborate 500 + on both of these in the next two subsections. 501 + 502 + Semantics of Kconfig 503 + ~~~~~~~~~~~~~~~~~~~~ 504 + 505 + The use of Kconfig is broad, Linux is now only one of Kconfig's users: 506 + one study has completed a broad analysis of Kconfig use in 12 projects [0]. 507 + Despite its widespread use, and although this document does a reasonable job 508 + in documenting basic Kconfig syntax a more precise definition of Kconfig 509 + semantics is welcomed. One project deduced Kconfig semantics through 510 + the use of the xconfig configurator [1]. Work should be done to confirm if 511 + the deduced semantics matches our intended Kconfig design goals. 512 + 513 + Having well defined semantics can be useful for tools for practical 514 + evaluation of depenencies, for instance one such use known case was work to 515 + express in boolean abstraction of the inferred semantics of Kconfig to 516 + translate Kconfig logic into boolean formulas and run a SAT solver on this to 517 + find dead code / features (always inactive), 114 dead features were found in 518 + Linux using this methodology [1] (Section 8: Threats to validity). 519 + 520 + Confirming this could prove useful as Kconfig stands as one of the the leading 521 + industrial variability modeling languages [1] [2]. Its study would help 522 + evaluate practical uses of such languages, their use was only theoretical 523 + and real world requirements were not well understood. As it stands though 524 + only reverse engineering techniques have been used to deduce semantics from 525 + variability modeling languages such as Kconfig [3]. 526 + 527 + [0] http://www.eng.uwaterloo.ca/~shshe/kconfig_semantics.pdf 528 + [1] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf 529 + [2] http://gsd.uwaterloo.ca/sites/default/files/ase241-berger_0.pdf 530 + [3] http://gsd.uwaterloo.ca/sites/default/files/icse2011.pdf 531 + 532 + Full SAT solver for Kconfig 533 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 534 + 535 + Although SAT solvers [0] haven't yet been used by Kconfig directly, as noted in 536 + the previous subsection, work has been done however to express in boolean 537 + abstraction the inferred semantics of Kconfig to translate Kconfig logic into 538 + boolean formulas and run a SAT solver on it [1]. Another known related project 539 + is CADOS [2] (former VAMOS [3]) and the tools, mainly undertaker [4], which has 540 + been introduced first with [5]. The basic concept of undertaker is to exract 541 + variability models from Kconfig, and put them together with a propositional 542 + formula extracted from CPP #ifdefs and build-rules into a SAT solver in order 543 + to find dead code, dead files, and dead symbols. If using a SAT solver is 544 + desirable on Kconfig one approach would be to evaluate repurposing such efforts 545 + somehow on Kconfig. There is enough interest from mentors of existing projects 546 + to not only help advise how to integrate this work upstream but also help 547 + maintain it long term. Interested developers should visit: 548 + 549 + http://kernelnewbies.org/KernelProjects/kconfig-sat 550 + 551 + [0] http://www.cs.cornell.edu/~sabhar/chapters/SATSolvers-KR-Handbook.pdf 552 + [1] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf 553 + [2] https://cados.cs.fau.de 554 + [3] https://vamos.cs.fau.de 555 + [4] https://undertaker.cs.fau.de 556 + [5] https://www4.cs.fau.de/Publications/2011/tartler_11_eurosys.pdf
+14 -42
scripts/kconfig/Makefile
··· 229 229 230 230 # Qt needs some extra effort... 231 231 $(obj)/.tmp_qtcheck: 232 - @set -e; $(kecho) " CHECK qt"; dir=""; pkg=""; \ 233 - if ! pkg-config --exists QtCore 2> /dev/null; then \ 234 - echo "* Unable to find the Qt4 tool qmake. Trying to use Qt3"; \ 235 - pkg-config --exists qt 2> /dev/null && pkg=qt; \ 236 - pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \ 237 - if [ -n "$$pkg" ]; then \ 238 - cflags="\$$(shell pkg-config $$pkg --cflags)"; \ 239 - libs="\$$(shell pkg-config $$pkg --libs)"; \ 240 - moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \ 241 - dir="$$(pkg-config $$pkg --variable=prefix)"; \ 242 - else \ 243 - for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \ 244 - if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ 245 - done; \ 246 - if [ -z "$$dir" ]; then \ 247 - echo >&2 "*"; \ 248 - echo >&2 "* Unable to find any Qt installation. Please make sure that"; \ 249 - echo >&2 "* the Qt4 or Qt3 development package is correctly installed and"; \ 250 - echo >&2 "* either qmake can be found or install pkg-config or set"; \ 251 - echo >&2 "* the QTDIR environment variable to the correct location."; \ 252 - echo >&2 "*"; \ 253 - false; \ 254 - fi; \ 255 - libpath=$$dir/lib; lib=qt; osdir=""; \ 256 - $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \ 257 - osdir=x$$($(HOSTCXX) -print-multi-os-directory); \ 258 - test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \ 259 - test -f $$libpath/libqt-mt.so && lib=qt-mt; \ 260 - cflags="-I$$dir/include"; \ 261 - libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \ 262 - moc="$$dir/bin/moc"; \ 263 - fi; \ 264 - if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \ 265 - echo "*"; \ 266 - echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \ 267 - echo "*"; \ 268 - moc="/usr/bin/moc"; \ 269 - fi; \ 232 + @set -e; $(kecho) " CHECK qt"; \ 233 + if pkg-config --exists Qt5Core; then \ 234 + cflags="-std=c++11 -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets`"; \ 235 + libs=`pkg-config --libs Qt5Core Qt5Gui Qt5Widgets`; \ 236 + moc=`pkg-config --variable=host_bins Qt5Core`/moc; \ 237 + elif pkg-config --exists QtCore; then \ 238 + cflags=`pkg-config --cflags QtCore QtGui`; \ 239 + libs=`pkg-config --libs QtCore QtGui`; \ 240 + moc=`pkg-config --variable=moc_location QtCore`; \ 270 241 else \ 271 - cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \ 272 - libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \ 273 - moc="\$$(shell pkg-config QtCore --variable=moc_location)"; \ 274 - [ -n "$$moc" ] || moc="\$$(shell pkg-config QtCore --variable=prefix)/bin/moc"; \ 242 + echo >&2 "*"; \ 243 + echo >&2 "* Could not find Qt via pkg-config."; \ 244 + echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"; \ 245 + echo >&2 "*"; \ 246 + exit 1; \ 275 247 fi; \ 276 248 echo "KC_QT_CFLAGS=$$cflags" > $@; \ 277 249 echo "KC_QT_LIBS=$$libs" >> $@; \
+1 -1
scripts/kconfig/expr.c
··· 1113 1113 fn(data, e->left.sym, e->left.sym->name); 1114 1114 else 1115 1115 fn(data, NULL, "<choice>"); 1116 - fn(data, NULL, e->type == E_LEQ ? ">=" : ">"); 1116 + fn(data, NULL, e->type == E_GEQ ? ">=" : ">"); 1117 1117 fn(data, e->right.sym, e->right.sym->name); 1118 1118 break; 1119 1119 case E_UNEQUAL:
+13 -5
scripts/kconfig/merge_config.sh
··· 32 32 echo " -m only merge the fragments, do not execute the make command" 33 33 echo " -n use allnoconfig instead of alldefconfig" 34 34 echo " -r list redundant entries when merging fragments" 35 - echo " -O dir to put generated output files" 35 + echo " -O dir to put generated output files. Consider setting \$KCONFIG_CONFIG instead." 36 36 } 37 37 38 38 RUNMAKE=true ··· 77 77 esac 78 78 done 79 79 80 - if [ "$#" -lt 2 ] ; then 80 + if [ "$#" -lt 1 ] ; then 81 81 usage 82 82 exit 83 + fi 84 + 85 + if [ -z "$KCONFIG_CONFIG" ]; then 86 + if [ "$OUTPUT" != . ]; then 87 + KCONFIG_CONFIG=$(readlink -m -- "$OUTPUT/.config") 88 + else 89 + KCONFIG_CONFIG=.config 90 + fi 83 91 fi 84 92 85 93 INITFILE=$1 ··· 132 124 done 133 125 134 126 if [ "$RUNMAKE" = "false" ]; then 135 - cp $TMP_FILE $OUTPUT/.config 127 + cp -T -- "$TMP_FILE" "$KCONFIG_CONFIG" 136 128 echo "#" 137 - echo "# merged configuration written to $OUTPUT/.config (needs make)" 129 + echo "# merged configuration written to $KCONFIG_CONFIG (needs make)" 138 130 echo "#" 139 131 clean_up 140 132 exit ··· 158 150 for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do 159 151 160 152 REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE) 161 - ACTUAL_VAL=$(grep -w -e "$CFG" $OUTPUT/.config) 153 + ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG") 162 154 if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then 163 155 echo "Value requested for $CFG not in final .config" 164 156 echo "Requested value: $REQUESTED_VAL"
+376 -306
scripts/kconfig/qconf.cc
··· 1 1 /* 2 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 3 + * Copyright (C) 2015 Boris Barbulovski <bbarbulovski@gmail.com> 3 4 * Released under the terms of the GNU GPL v2.0. 4 5 */ 5 6 6 7 #include <qglobal.h> 7 8 8 - #if QT_VERSION < 0x040000 9 - #include <stddef.h> 10 - #include <qmainwindow.h> 11 - #include <qvbox.h> 12 - #include <qvaluelist.h> 9 + #include <QMainWindow> 10 + #include <QList> 13 11 #include <qtextbrowser.h> 14 - #include <qaction.h> 15 - #include <qheader.h> 16 - #include <qfiledialog.h> 17 - #include <qdragobject.h> 18 - #include <qpopupmenu.h> 19 - #else 20 - #include <q3mainwindow.h> 21 - #include <q3vbox.h> 22 - #include <q3valuelist.h> 23 - #include <q3textbrowser.h> 24 - #include <q3action.h> 25 - #include <q3header.h> 26 - #include <q3filedialog.h> 27 - #include <q3dragobject.h> 28 - #include <q3popupmenu.h> 29 - #endif 12 + #include <QAction> 13 + #include <QFileDialog> 14 + #include <QMenu> 30 15 31 16 #include <qapplication.h> 32 17 #include <qdesktopwidget.h> ··· 42 57 static QApplication *configApp; 43 58 static ConfigSettings *configSettings; 44 59 45 - Q3Action *ConfigMainWindow::saveAction; 60 + QAction *ConfigMainWindow::saveAction; 46 61 47 62 static inline QString qgettext(const char* str) 48 63 { ··· 51 66 52 67 static inline QString qgettext(const QString& str) 53 68 { 54 - return QString::fromLocal8Bit(gettext(str.latin1())); 69 + return QString::fromLocal8Bit(gettext(str.toLatin1())); 55 70 } 56 71 57 72 ConfigSettings::ConfigSettings() ··· 62 77 /** 63 78 * Reads a list of integer values from the application settings. 64 79 */ 65 - Q3ValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok) 80 + QList<int> ConfigSettings::readSizes(const QString& key, bool *ok) 66 81 { 67 - Q3ValueList<int> result; 68 - QStringList entryList = readListEntry(key, ok); 82 + QList<int> result; 83 + QStringList entryList = value(key).toStringList(); 69 84 QStringList::Iterator it; 70 85 71 86 for (it = entryList.begin(); it != entryList.end(); ++it) ··· 77 92 /** 78 93 * Writes a list of integer values to the application settings. 79 94 */ 80 - bool ConfigSettings::writeSizes(const QString& key, const Q3ValueList<int>& value) 95 + bool ConfigSettings::writeSizes(const QString& key, const QList<int>& value) 81 96 { 82 97 QStringList stringList; 83 - Q3ValueList<int>::ConstIterator it; 98 + QList<int>::ConstIterator it; 84 99 85 100 for (it = value.begin(); it != value.end(); ++it) 86 101 stringList.push_back(QString::number(*it)); 87 - return writeEntry(key, stringList); 102 + setValue(key, stringList); 103 + 104 + return true; 88 105 } 89 106 90 107 ··· 96 109 */ 97 110 void ConfigItem::okRename(int col) 98 111 { 99 - Parent::okRename(col); 100 - sym_set_string_value(menu->sym, text(dataColIdx).latin1()); 101 - listView()->updateList(this); 102 112 } 103 113 104 114 /* ··· 133 149 } else { 134 150 if (sym) 135 151 break; 136 - setPixmap(promptColIdx, 0); 152 + setPixmap(promptColIdx, QIcon()); 137 153 } 138 154 goto set_prompt; 139 155 case P_COMMENT: 140 - setPixmap(promptColIdx, 0); 156 + setPixmap(promptColIdx, QIcon()); 141 157 goto set_prompt; 142 158 default: 143 159 ; ··· 154 170 char ch; 155 171 156 172 if (!sym_is_changable(sym) && list->optMode == normalOpt) { 157 - setPixmap(promptColIdx, 0); 173 + setPixmap(promptColIdx, QIcon()); 158 174 setText(noColIdx, QString::null); 159 175 setText(modColIdx, QString::null); 160 176 setText(yesColIdx, QString::null); ··· 200 216 201 217 data = sym_get_string_value(sym); 202 218 203 - int i = list->mapIdx(dataColIdx); 204 - if (i >= 0) 205 - setRenameEnabled(i, TRUE); 206 219 setText(dataColIdx, data); 207 220 if (type == S_STRING) 208 221 prompt = QString("%1: %2").arg(prompt).arg(data); ··· 231 250 updateMenu(); 232 251 } 233 252 234 - void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) 235 - { 236 - ConfigList* list = listView(); 237 - 238 - if (visible) { 239 - if (isSelected() && !list->hasFocus() && list->mode == menuMode) 240 - Parent::paintCell(p, list->inactivedColorGroup, column, width, align); 241 - else 242 - Parent::paintCell(p, cg, column, width, align); 243 - } else 244 - Parent::paintCell(p, list->disabledColorGroup, column, width, align); 245 - } 246 253 247 254 /* 248 255 * construct a menu entry ··· 243 274 menu->data = this; 244 275 245 276 if (list->mode != fullMode) 246 - setOpen(TRUE); 277 + setExpanded(true); 247 278 sym_calc_value(menu->sym); 248 279 } 249 280 updateMenu(); ··· 268 299 ConfigLineEdit::ConfigLineEdit(ConfigView* parent) 269 300 : Parent(parent) 270 301 { 271 - connect(this, SIGNAL(lostFocus()), SLOT(hide())); 302 + connect(this, SIGNAL(editingFinished()), SLOT(hide())); 272 303 } 273 304 274 305 void ConfigLineEdit::show(ConfigItem* i) ··· 289 320 break; 290 321 case Qt::Key_Return: 291 322 case Qt::Key_Enter: 292 - sym_set_string_value(item->menu->sym, text().latin1()); 323 + sym_set_string_value(item->menu->sym, text().toLatin1()); 293 324 parent()->updateList(item); 294 325 break; 295 326 default: ··· 302 333 } 303 334 304 335 ConfigList::ConfigList(ConfigView* p, const char *name) 305 - : Parent(p, name), 336 + : Parent(p), 306 337 updateAll(false), 307 338 symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), 308 339 choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), 309 340 menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), 310 - showName(false), showRange(false), showData(false), optMode(normalOpt), 341 + showName(false), showRange(false), showData(false), mode(singleMode), optMode(normalOpt), 311 342 rootEntry(0), headerPopup(0) 312 343 { 313 344 int i; 314 345 315 - setSorting(-1); 316 - setRootIsDecorated(TRUE); 317 - disabledColorGroup = palette().active(); 318 - disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text()); 319 - inactivedColorGroup = palette().active(); 320 - inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight()); 346 + setObjectName(name); 347 + setSortingEnabled(false); 348 + setRootIsDecorated(true); 321 349 322 - connect(this, SIGNAL(selectionChanged(void)), 350 + setVerticalScrollMode(ScrollPerPixel); 351 + setHorizontalScrollMode(ScrollPerPixel); 352 + 353 + setHeaderLabels(QStringList() << _("Option") << _("Name") << "N" << "M" << "Y" << _("Value")); 354 + 355 + connect(this, SIGNAL(itemSelectionChanged(void)), 323 356 SLOT(updateSelection(void))); 324 357 325 358 if (name) { 326 359 configSettings->beginGroup(name); 327 - showName = configSettings->readBoolEntry("/showName", false); 328 - showRange = configSettings->readBoolEntry("/showRange", false); 329 - showData = configSettings->readBoolEntry("/showData", false); 330 - optMode = (enum optionMode)configSettings->readNumEntry("/optionMode", false); 360 + showName = configSettings->value("/showName", false).toBool(); 361 + showRange = configSettings->value("/showRange", false).toBool(); 362 + showData = configSettings->value("/showData", false).toBool(); 363 + optMode = (enum optionMode)configSettings->value("/optionMode", 0).toInt(); 331 364 configSettings->endGroup(); 332 365 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); 333 366 } 334 367 335 - for (i = 0; i < colNr; i++) 336 - colMap[i] = colRevMap[i] = -1; 337 - addColumn(promptColIdx, _("Option")); 368 + addColumn(promptColIdx); 338 369 339 370 reinit(); 340 371 } ··· 359 390 removeColumn(nameColIdx); 360 391 361 392 if (showName) 362 - addColumn(nameColIdx, _("Name")); 393 + addColumn(nameColIdx); 363 394 if (showRange) { 364 - addColumn(noColIdx, "N"); 365 - addColumn(modColIdx, "M"); 366 - addColumn(yesColIdx, "Y"); 395 + addColumn(noColIdx); 396 + addColumn(modColIdx); 397 + addColumn(yesColIdx); 367 398 } 368 399 if (showData) 369 - addColumn(dataColIdx, _("Value")); 400 + addColumn(dataColIdx); 370 401 371 402 updateListAll(); 372 403 } 373 404 374 405 void ConfigList::saveSettings(void) 375 406 { 376 - if (name()) { 377 - configSettings->beginGroup(name()); 378 - configSettings->writeEntry("/showName", showName); 379 - configSettings->writeEntry("/showRange", showRange); 380 - configSettings->writeEntry("/showData", showData); 381 - configSettings->writeEntry("/optionMode", (int)optMode); 407 + if (!objectName().isEmpty()) { 408 + configSettings->beginGroup(objectName()); 409 + configSettings->setValue("/showName", showName); 410 + configSettings->setValue("/showRange", showRange); 411 + configSettings->setValue("/showData", showData); 412 + configSettings->setValue("/optionMode", (int)optMode); 382 413 configSettings->endGroup(); 383 414 } 384 415 } ··· 400 431 struct menu *menu; 401 432 enum prop_type type; 402 433 403 - ConfigItem* item = (ConfigItem*)selectedItem(); 434 + if (selectedItems().count() == 0) 435 + return; 436 + 437 + ConfigItem* item = (ConfigItem*)selectedItems().first(); 404 438 if (!item) 405 439 return; 406 440 ··· 423 451 if (!rootEntry) { 424 452 if (mode != listMode) 425 453 goto update; 426 - Q3ListViewItemIterator it(this); 454 + QTreeWidgetItemIterator it(this); 427 455 ConfigItem* item; 428 456 429 - for (; it.current(); ++it) { 430 - item = (ConfigItem*)it.current(); 457 + while (*it) { 458 + item = (ConfigItem*)(*it); 431 459 if (!item->menu) 432 460 continue; 433 461 item->testUpdateMenu(menu_is_visible(item->menu)); 462 + 463 + ++it; 434 464 } 435 465 return; 436 466 } 437 467 438 468 if (rootEntry != &rootmenu && (mode == singleMode || 439 469 (mode == symbolMode && rootEntry->parent != &rootmenu))) { 440 - item = firstChild(); 470 + item = (ConfigItem *)topLevelItem(0); 441 471 if (!item) 442 472 item = new ConfigItem(this, 0, true); 443 473 last = item; ··· 453 479 item->testUpdateMenu(true); 454 480 455 481 updateMenuList(item, rootEntry); 456 - triggerUpdate(); 482 + update(); 483 + resizeColumnToContents(0); 457 484 return; 458 485 } 459 486 update: 460 487 updateMenuList(this, rootEntry); 461 - triggerUpdate(); 488 + update(); 489 + resizeColumnToContents(0); 462 490 } 463 491 464 492 void ConfigList::setValue(ConfigItem* item, tristate val) ··· 482 506 if (!sym_set_tristate_value(sym, val)) 483 507 return; 484 508 if (oldval == no && item->menu->list) 485 - item->setOpen(TRUE); 509 + item->setExpanded(true); 486 510 parent()->updateList(item); 487 511 break; 488 512 } ··· 500 524 sym = menu->sym; 501 525 if (!sym) { 502 526 if (item->menu->list) 503 - item->setOpen(!item->isOpen()); 527 + item->setExpanded(!item->isExpanded()); 504 528 return; 505 529 } 506 530 ··· 512 536 newexpr = sym_toggle_tristate_value(sym); 513 537 if (item->menu->list) { 514 538 if (oldexpr == newexpr) 515 - item->setOpen(!item->isOpen()); 539 + item->setExpanded(!item->isExpanded()); 516 540 else if (oldexpr == no) 517 - item->setOpen(TRUE); 541 + item->setExpanded(true); 518 542 } 519 543 if (oldexpr != newexpr) 520 544 parent()->updateList(item); ··· 522 546 case S_INT: 523 547 case S_HEX: 524 548 case S_STRING: 525 - if (colMap[dataColIdx] >= 0) 526 - item->startRename(colMap[dataColIdx]); 527 - else 528 - parent()->lineEdit->show(item); 549 + parent()->lineEdit->show(item); 529 550 break; 530 551 } 531 552 } ··· 539 566 updateMenuList(this, 0); 540 567 rootEntry = menu; 541 568 updateListAll(); 542 - setSelected(currentItem(), hasFocus()); 543 - ensureItemVisible(currentItem()); 569 + if (currentItem()) { 570 + currentItem()->setSelected(hasFocus()); 571 + scrollToItem(currentItem()); 572 + } 544 573 } 545 574 546 575 void ConfigList::setParentMenu(void) ··· 555 580 return; 556 581 setRootMenu(menu_get_parent_menu(rootEntry->parent)); 557 582 558 - Q3ListViewItemIterator it(this); 559 - for (; (item = (ConfigItem*)it.current()); it++) { 583 + QTreeWidgetItemIterator it(this); 584 + while (*it) { 585 + item = (ConfigItem *)(*it); 560 586 if (item->menu == oldroot) { 561 587 setCurrentItem(item); 562 - ensureItemVisible(item); 588 + scrollToItem(item); 563 589 break; 564 590 } 591 + 592 + ++it; 565 593 } 566 594 } 567 595 ··· 575 597 * parent: either the menu list widget or a menu entry widget 576 598 * menu: entry to be updated 577 599 */ 578 - template <class P> 579 - void ConfigList::updateMenuList(P* parent, struct menu* menu) 600 + void ConfigList::updateMenuList(ConfigItem *parent, struct menu* menu) 580 601 { 581 602 struct menu* child; 582 603 ConfigItem* item; ··· 584 607 enum prop_type type; 585 608 586 609 if (!menu) { 587 - while ((item = parent->firstChild())) 588 - delete item; 610 + while (parent->childCount() > 0) 611 + { 612 + delete parent->takeChild(0); 613 + } 614 + 589 615 return; 590 616 } 591 617 ··· 640 660 } 641 661 } 642 662 663 + void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) 664 + { 665 + struct menu* child; 666 + ConfigItem* item; 667 + ConfigItem* last; 668 + bool visible; 669 + enum prop_type type; 670 + 671 + if (!menu) { 672 + while (parent->topLevelItemCount() > 0) 673 + { 674 + delete parent->takeTopLevelItem(0); 675 + } 676 + 677 + return; 678 + } 679 + 680 + last = (ConfigItem*)parent->topLevelItem(0); 681 + if (last && !last->goParent) 682 + last = 0; 683 + for (child = menu->list; child; child = child->next) { 684 + item = last ? last->nextSibling() : (ConfigItem*)parent->topLevelItem(0); 685 + type = child->prompt ? child->prompt->type : P_UNKNOWN; 686 + 687 + switch (mode) { 688 + case menuMode: 689 + if (!(child->flags & MENU_ROOT)) 690 + goto hide; 691 + break; 692 + case symbolMode: 693 + if (child->flags & MENU_ROOT) 694 + goto hide; 695 + break; 696 + default: 697 + break; 698 + } 699 + 700 + visible = menu_is_visible(child); 701 + if (!menuSkip(child)) { 702 + if (!child->sym && !child->list && !child->prompt) 703 + continue; 704 + if (!item || item->menu != child) 705 + item = new ConfigItem(parent, last, child, visible); 706 + else 707 + item->testUpdateMenu(visible); 708 + 709 + if (mode == fullMode || mode == menuMode || type != P_MENU) 710 + updateMenuList(item, child); 711 + else 712 + updateMenuList(item, 0); 713 + last = item; 714 + continue; 715 + } 716 + hide: 717 + if (item && item->menu == child) { 718 + last = (ConfigItem*)parent->topLevelItem(0); 719 + if (last == item) 720 + last = 0; 721 + else while (last->nextSibling() != item) 722 + last = last->nextSibling(); 723 + delete item; 724 + } 725 + } 726 + } 727 + 643 728 void ConfigList::keyPressEvent(QKeyEvent* ev) 644 729 { 645 - Q3ListViewItem* i = currentItem(); 730 + QTreeWidgetItem* i = currentItem(); 646 731 ConfigItem* item; 647 732 struct menu *menu; 648 733 enum prop_type type; ··· 759 714 ev->accept(); 760 715 } 761 716 762 - void ConfigList::contentsMousePressEvent(QMouseEvent* e) 717 + void ConfigList::mousePressEvent(QMouseEvent* e) 763 718 { 764 719 //QPoint p(contentsToViewport(e->pos())); 765 720 //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); 766 - Parent::contentsMousePressEvent(e); 721 + Parent::mousePressEvent(e); 767 722 } 768 723 769 - void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) 724 + void ConfigList::mouseReleaseEvent(QMouseEvent* e) 770 725 { 771 - QPoint p(contentsToViewport(e->pos())); 726 + QPoint p = e->pos(); 772 727 ConfigItem* item = (ConfigItem*)itemAt(p); 773 728 struct menu *menu; 774 729 enum prop_type ptype; 775 - const QPixmap* pm; 730 + QIcon icon; 776 731 int idx, x; 777 732 778 733 if (!item) ··· 780 735 781 736 menu = item->menu; 782 737 x = header()->offset() + p.x(); 783 - idx = colRevMap[header()->sectionAt(x)]; 738 + idx = header()->logicalIndexAt(x); 784 739 switch (idx) { 785 740 case promptColIdx: 786 - pm = item->pixmap(promptColIdx); 787 - if (pm) { 788 - int off = header()->sectionPos(0) + itemMargin() + 789 - treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); 790 - if (x >= off && x < off + pm->width()) { 741 + icon = item->pixmap(promptColIdx); 742 + if (!icon.isNull()) { 743 + int off = header()->sectionPosition(0) + visualRect(indexAt(p)).x() + 4; // 4 is Hardcoded image offset. There might be a way to do it properly. 744 + if (x >= off && x < off + icon.availableSizes().first().width()) { 791 745 if (item->goParent) { 792 746 emit parentSelected(); 793 747 break; ··· 817 773 818 774 skip: 819 775 //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); 820 - Parent::contentsMouseReleaseEvent(e); 776 + Parent::mouseReleaseEvent(e); 821 777 } 822 778 823 - void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) 779 + void ConfigList::mouseMoveEvent(QMouseEvent* e) 824 780 { 825 781 //QPoint p(contentsToViewport(e->pos())); 826 782 //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); 827 - Parent::contentsMouseMoveEvent(e); 783 + Parent::mouseMoveEvent(e); 828 784 } 829 785 830 - void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) 786 + void ConfigList::mouseDoubleClickEvent(QMouseEvent* e) 831 787 { 832 - QPoint p(contentsToViewport(e->pos())); 788 + QPoint p = e->pos(); // TODO: Check if this works(was contentsToViewport). 833 789 ConfigItem* item = (ConfigItem*)itemAt(p); 834 790 struct menu *menu; 835 791 enum prop_type ptype; ··· 851 807 852 808 skip: 853 809 //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); 854 - Parent::contentsMouseDoubleClickEvent(e); 810 + Parent::mouseDoubleClickEvent(e); 855 811 } 856 812 857 813 void ConfigList::focusInEvent(QFocusEvent *e) ··· 862 818 863 819 ConfigItem* item = (ConfigItem *)currentItem(); 864 820 if (item) { 865 - setSelected(item, TRUE); 821 + item->setSelected(true); 866 822 menu = item->menu; 867 823 } 868 824 emit gotFocus(menu); ··· 872 828 { 873 829 if (e->y() <= header()->geometry().bottom()) { 874 830 if (!headerPopup) { 875 - Q3Action *action; 831 + QAction *action; 876 832 877 - headerPopup = new Q3PopupMenu(this); 878 - action = new Q3Action(NULL, _("Show Name"), 0, this); 879 - action->setToggleAction(TRUE); 833 + headerPopup = new QMenu(this); 834 + action = new QAction(_("Show Name"), this); 835 + action->setCheckable(true); 880 836 connect(action, SIGNAL(toggled(bool)), 881 837 parent(), SLOT(setShowName(bool))); 882 838 connect(parent(), SIGNAL(showNameChanged(bool)), 883 839 action, SLOT(setOn(bool))); 884 - action->setOn(showName); 885 - action->addTo(headerPopup); 886 - action = new Q3Action(NULL, _("Show Range"), 0, this); 887 - action->setToggleAction(TRUE); 840 + action->setChecked(showName); 841 + headerPopup->addAction(action); 842 + action = new QAction(_("Show Range"), this); 843 + action->setCheckable(true); 888 844 connect(action, SIGNAL(toggled(bool)), 889 845 parent(), SLOT(setShowRange(bool))); 890 846 connect(parent(), SIGNAL(showRangeChanged(bool)), 891 847 action, SLOT(setOn(bool))); 892 - action->setOn(showRange); 893 - action->addTo(headerPopup); 894 - action = new Q3Action(NULL, _("Show Data"), 0, this); 895 - action->setToggleAction(TRUE); 848 + action->setChecked(showRange); 849 + headerPopup->addAction(action); 850 + action = new QAction(_("Show Data"), this); 851 + action->setCheckable(true); 896 852 connect(action, SIGNAL(toggled(bool)), 897 853 parent(), SLOT(setShowData(bool))); 898 854 connect(parent(), SIGNAL(showDataChanged(bool)), 899 855 action, SLOT(setOn(bool))); 900 - action->setOn(showData); 901 - action->addTo(headerPopup); 856 + action->setChecked(showData); 857 + headerPopup->addAction(action); 902 858 } 903 859 headerPopup->exec(e->globalPos()); 904 860 e->accept(); ··· 912 868 QAction *ConfigView::showPromptAction; 913 869 914 870 ConfigView::ConfigView(QWidget* parent, const char *name) 915 - : Parent(parent, name) 871 + : Parent(parent) 916 872 { 917 - list = new ConfigList(this, name); 873 + setObjectName(name); 874 + QVBoxLayout *verticalLayout = new QVBoxLayout(this); 875 + verticalLayout->setContentsMargins(0, 0, 0, 0); 876 + 877 + list = new ConfigList(this); 878 + verticalLayout->addWidget(list); 918 879 lineEdit = new ConfigLineEdit(this); 919 880 lineEdit->hide(); 881 + verticalLayout->addWidget(lineEdit); 920 882 921 883 this->nextView = viewList; 922 884 viewList = this; ··· 981 931 982 932 void ConfigList::setAllOpen(bool open) 983 933 { 984 - Q3ListViewItemIterator it(this); 934 + QTreeWidgetItemIterator it(this); 985 935 986 - for (; it.current(); it++) 987 - it.current()->setOpen(open); 936 + while (*it) { 937 + (*it)->setExpanded(open); 938 + 939 + ++it; 940 + } 988 941 } 989 942 990 943 void ConfigView::updateList(ConfigItem* item) ··· 1007 954 } 1008 955 1009 956 ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) 1010 - : Parent(parent, name), sym(0), _menu(0) 957 + : Parent(parent), sym(0), _menu(0) 1011 958 { 1012 - if (name) { 1013 - configSettings->beginGroup(name); 1014 - _showDebug = configSettings->readBoolEntry("/showDebug", false); 959 + setObjectName(name); 960 + 961 + 962 + if (!objectName().isEmpty()) { 963 + configSettings->beginGroup(objectName()); 964 + _showDebug = configSettings->value("/showDebug", false).toBool(); 1015 965 configSettings->endGroup(); 1016 966 connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); 1017 967 } ··· 1022 966 1023 967 void ConfigInfoView::saveSettings(void) 1024 968 { 1025 - if (name()) { 1026 - configSettings->beginGroup(name()); 1027 - configSettings->writeEntry("/showDebug", showDebug()); 969 + if (!objectName().isEmpty()) { 970 + configSettings->beginGroup(objectName()); 971 + configSettings->setValue("/showDebug", showDebug()); 1028 972 configSettings->endGroup(); 1029 973 } 1030 974 } ··· 1183 1127 { 1184 1128 QRegExp re("[<>&\"\\n]"); 1185 1129 QString res = str; 1186 - for (int i = 0; (i = res.find(re, i)) >= 0;) { 1187 - switch (res[i].latin1()) { 1130 + for (int i = 0; (i = res.indexOf(re, i)) >= 0;) { 1131 + switch (res[i].toLatin1()) { 1188 1132 case '<': 1189 1133 res.replace(i, 1, "&lt;"); 1190 1134 i += 4; ··· 1223 1167 *text += str2; 1224 1168 } 1225 1169 1226 - Q3PopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos) 1170 + QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos) 1227 1171 { 1228 - Q3PopupMenu* popup = Parent::createPopupMenu(pos); 1229 - Q3Action* action = new Q3Action(NULL, _("Show Debug Info"), 0, popup); 1230 - action->setToggleAction(TRUE); 1172 + QMenu* popup = Parent::createStandardContextMenu(pos); 1173 + QAction* action = new QAction(_("Show Debug Info"), popup); 1174 + action->setCheckable(true); 1231 1175 connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); 1232 1176 connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); 1233 - action->setOn(showDebug()); 1234 - popup->insertSeparator(); 1235 - action->addTo(popup); 1177 + action->setChecked(showDebug()); 1178 + popup->addSeparator(); 1179 + popup->addAction(action); 1236 1180 return popup; 1237 1181 } 1238 1182 1239 - void ConfigInfoView::contentsContextMenuEvent(QContextMenuEvent *e) 1183 + void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e) 1240 1184 { 1241 - Parent::contentsContextMenuEvent(e); 1185 + Parent::contextMenuEvent(e); 1242 1186 } 1243 1187 1244 1188 ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name) 1245 - : Parent(parent, name), result(NULL) 1189 + : Parent(parent), result(NULL) 1246 1190 { 1247 - setCaption("Search Config"); 1191 + setObjectName(name); 1192 + setWindowTitle("Search Config"); 1248 1193 1249 - QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6); 1250 - QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 6); 1194 + QVBoxLayout* layout1 = new QVBoxLayout(this); 1195 + layout1->setContentsMargins(11, 11, 11, 11); 1196 + layout1->setSpacing(6); 1197 + QHBoxLayout* layout2 = new QHBoxLayout(0); 1198 + layout2->setContentsMargins(0, 0, 0, 0); 1199 + layout2->setSpacing(6); 1251 1200 layout2->addWidget(new QLabel(_("Find:"), this)); 1252 1201 editField = new QLineEdit(this); 1253 1202 connect(editField, SIGNAL(returnPressed()), SLOT(search())); 1254 1203 layout2->addWidget(editField); 1255 1204 searchButton = new QPushButton(_("Search"), this); 1256 - searchButton->setAutoDefault(FALSE); 1205 + searchButton->setAutoDefault(false); 1257 1206 connect(searchButton, SIGNAL(clicked()), SLOT(search())); 1258 1207 layout2->addWidget(searchButton); 1259 1208 layout1->addLayout(layout2); ··· 1276 1215 layout1->addWidget(split); 1277 1216 1278 1217 if (name) { 1279 - int x, y, width, height; 1218 + QVariant x, y; 1219 + int width, height; 1280 1220 bool ok; 1281 1221 1282 1222 configSettings->beginGroup(name); 1283 - width = configSettings->readNumEntry("/window width", parent->width() / 2); 1284 - height = configSettings->readNumEntry("/window height", parent->height() / 2); 1223 + width = configSettings->value("/window width", parent->width() / 2).toInt(); 1224 + height = configSettings->value("/window height", parent->height() / 2).toInt(); 1285 1225 resize(width, height); 1286 - x = configSettings->readNumEntry("/window x", 0, &ok); 1287 - if (ok) 1288 - y = configSettings->readNumEntry("/window y", 0, &ok); 1289 - if (ok) 1290 - move(x, y); 1291 - Q3ValueList<int> sizes = configSettings->readSizes("/split", &ok); 1226 + x = configSettings->value("/window x"); 1227 + y = configSettings->value("/window y"); 1228 + if ((x.isValid())&&(y.isValid())) 1229 + move(x.toInt(), y.toInt()); 1230 + QList<int> sizes = configSettings->readSizes("/split", &ok); 1292 1231 if (ok) 1293 1232 split->setSizes(sizes); 1294 1233 configSettings->endGroup(); ··· 1298 1237 1299 1238 void ConfigSearchWindow::saveSettings(void) 1300 1239 { 1301 - if (name()) { 1302 - configSettings->beginGroup(name()); 1303 - configSettings->writeEntry("/window x", pos().x()); 1304 - configSettings->writeEntry("/window y", pos().y()); 1305 - configSettings->writeEntry("/window width", size().width()); 1306 - configSettings->writeEntry("/window height", size().height()); 1240 + if (!objectName().isEmpty()) { 1241 + configSettings->beginGroup(objectName()); 1242 + configSettings->setValue("/window x", pos().x()); 1243 + configSettings->setValue("/window y", pos().y()); 1244 + configSettings->setValue("/window width", size().width()); 1245 + configSettings->setValue("/window height", size().height()); 1307 1246 configSettings->writeSizes("/split", split->sizes()); 1308 1247 configSettings->endGroup(); 1309 1248 } ··· 1319 1258 list->list->clear(); 1320 1259 info->clear(); 1321 1260 1322 - result = sym_re_search(editField->text().latin1()); 1261 + result = sym_re_search(editField->text().toLatin1()); 1323 1262 if (!result) 1324 1263 return; 1325 1264 for (p = result; *p; p++) { ··· 1336 1275 : searchWindow(0) 1337 1276 { 1338 1277 QMenuBar* menu; 1339 - bool ok; 1340 - int x, y, width, height; 1278 + bool ok = true; 1279 + QVariant x, y; 1280 + int width, height; 1341 1281 char title[256]; 1342 1282 1343 1283 QDesktopWidget *d = configApp->desktop(); 1344 1284 snprintf(title, sizeof(title), "%s%s", 1345 1285 rootmenu.prompt->text, 1346 - #if QT_VERSION < 0x040000 1347 - " (Qt3)" 1348 - #else 1349 1286 "" 1350 - #endif 1351 1287 ); 1352 - setCaption(title); 1288 + setWindowTitle(title); 1353 1289 1354 - width = configSettings->readNumEntry("/window width", d->width() - 64); 1355 - height = configSettings->readNumEntry("/window height", d->height() - 64); 1290 + width = configSettings->value("/window width", d->width() - 64).toInt(); 1291 + height = configSettings->value("/window height", d->height() - 64).toInt(); 1356 1292 resize(width, height); 1357 - x = configSettings->readNumEntry("/window x", 0, &ok); 1358 - if (ok) 1359 - y = configSettings->readNumEntry("/window y", 0, &ok); 1360 - if (ok) 1361 - move(x, y); 1293 + x = configSettings->value("/window x"); 1294 + y = configSettings->value("/window y"); 1295 + if ((x.isValid())&&(y.isValid())) 1296 + move(x.toInt(), y.toInt()); 1362 1297 1363 1298 split1 = new QSplitter(this); 1364 1299 split1->setOrientation(Qt::Horizontal); ··· 1371 1314 configList = configView->list; 1372 1315 1373 1316 helpText = new ConfigInfoView(split2, "help"); 1374 - helpText->setTextFormat(Qt::RichText); 1375 1317 1376 1318 setTabOrder(configList, helpText); 1377 1319 configList->setFocus(); 1378 1320 1379 1321 menu = menuBar(); 1380 - toolBar = new Q3ToolBar("Tools", this); 1322 + toolBar = new QToolBar("Tools", this); 1323 + addToolBar(toolBar); 1381 1324 1382 - backAction = new Q3Action("Back", QPixmap(xpm_back), _("Back"), 0, this); 1383 - connect(backAction, SIGNAL(activated()), SLOT(goBack())); 1384 - backAction->setEnabled(FALSE); 1385 - Q3Action *quitAction = new Q3Action("Quit", _("&Quit"), Qt::CTRL + Qt::Key_Q, this); 1386 - connect(quitAction, SIGNAL(activated()), SLOT(close())); 1387 - Q3Action *loadAction = new Q3Action("Load", QPixmap(xpm_load), _("&Load"), Qt::CTRL + Qt::Key_L, this); 1388 - connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); 1389 - saveAction = new Q3Action("Save", QPixmap(xpm_save), _("&Save"), Qt::CTRL + Qt::Key_S, this); 1390 - connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); 1325 + backAction = new QAction(QPixmap(xpm_back), _("Back"), this); 1326 + connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack())); 1327 + backAction->setEnabled(false); 1328 + QAction *quitAction = new QAction(_("&Quit"), this); 1329 + quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); 1330 + connect(quitAction, SIGNAL(triggered(bool)), SLOT(close())); 1331 + QAction *loadAction = new QAction(QPixmap(xpm_load), _("&Load"), this); 1332 + loadAction->setShortcut(Qt::CTRL + Qt::Key_L); 1333 + connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig())); 1334 + saveAction = new QAction(QPixmap(xpm_save), _("&Save"), this); 1335 + saveAction->setShortcut(Qt::CTRL + Qt::Key_S); 1336 + connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig())); 1391 1337 conf_set_changed_callback(conf_changed); 1392 1338 // Set saveAction's initial state 1393 1339 conf_changed(); 1394 - Q3Action *saveAsAction = new Q3Action("Save As...", _("Save &As..."), 0, this); 1395 - connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); 1396 - Q3Action *searchAction = new Q3Action("Find", _("&Find"), Qt::CTRL + Qt::Key_F, this); 1397 - connect(searchAction, SIGNAL(activated()), SLOT(searchConfig())); 1398 - Q3Action *singleViewAction = new Q3Action("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this); 1399 - connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); 1400 - Q3Action *splitViewAction = new Q3Action("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this); 1401 - connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); 1402 - Q3Action *fullViewAction = new Q3Action("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this); 1403 - connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); 1340 + QAction *saveAsAction = new QAction(_("Save &As..."), this); 1341 + connect(saveAsAction, SIGNAL(triggered(bool)), SLOT(saveConfigAs())); 1342 + QAction *searchAction = new QAction(_("&Find"), this); 1343 + searchAction->setShortcut(Qt::CTRL + Qt::Key_F); 1344 + connect(searchAction, SIGNAL(triggered(bool)), SLOT(searchConfig())); 1345 + singleViewAction = new QAction(QPixmap(xpm_single_view), _("Single View"), this); 1346 + singleViewAction->setCheckable(true); 1347 + connect(singleViewAction, SIGNAL(triggered(bool)), SLOT(showSingleView())); 1348 + splitViewAction = new QAction(QPixmap(xpm_split_view), _("Split View"), this); 1349 + splitViewAction->setCheckable(true); 1350 + connect(splitViewAction, SIGNAL(triggered(bool)), SLOT(showSplitView())); 1351 + fullViewAction = new QAction(QPixmap(xpm_tree_view), _("Full View"), this); 1352 + fullViewAction->setCheckable(true); 1353 + connect(fullViewAction, SIGNAL(triggered(bool)), SLOT(showFullView())); 1404 1354 1405 - Q3Action *showNameAction = new Q3Action(NULL, _("Show Name"), 0, this); 1406 - showNameAction->setToggleAction(TRUE); 1355 + QAction *showNameAction = new QAction(_("Show Name"), this); 1356 + showNameAction->setCheckable(true); 1407 1357 connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool))); 1408 - connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool))); 1409 - showNameAction->setOn(configView->showName()); 1410 - Q3Action *showRangeAction = new Q3Action(NULL, _("Show Range"), 0, this); 1411 - showRangeAction->setToggleAction(TRUE); 1358 + showNameAction->setChecked(configView->showName()); 1359 + QAction *showRangeAction = new QAction(_("Show Range"), this); 1360 + showRangeAction->setCheckable(true); 1412 1361 connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); 1413 - connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool))); 1414 - showRangeAction->setOn(configList->showRange); 1415 - Q3Action *showDataAction = new Q3Action(NULL, _("Show Data"), 0, this); 1416 - showDataAction->setToggleAction(TRUE); 1362 + QAction *showDataAction = new QAction(_("Show Data"), this); 1363 + showDataAction->setCheckable(true); 1417 1364 connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); 1418 - connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); 1419 - showDataAction->setOn(configList->showData); 1420 1365 1421 1366 QActionGroup *optGroup = new QActionGroup(this); 1422 - optGroup->setExclusive(TRUE); 1423 - connect(optGroup, SIGNAL(selected(QAction *)), configView, 1367 + optGroup->setExclusive(true); 1368 + connect(optGroup, SIGNAL(triggered(QAction*)), configView, 1424 1369 SLOT(setOptionMode(QAction *))); 1425 - connect(optGroup, SIGNAL(selected(QAction *)), menuView, 1370 + connect(optGroup, SIGNAL(triggered(QAction *)), menuView, 1426 1371 SLOT(setOptionMode(QAction *))); 1427 1372 1428 - #if QT_VERSION >= 0x040000 1429 1373 configView->showNormalAction = new QAction(_("Show Normal Options"), optGroup); 1430 1374 configView->showAllAction = new QAction(_("Show All Options"), optGroup); 1431 1375 configView->showPromptAction = new QAction(_("Show Prompt Options"), optGroup); 1432 - #else 1433 - configView->showNormalAction = new QAction(_("Show Normal Options"), 0, optGroup); 1434 - configView->showAllAction = new QAction(_("Show All Options"), 0, optGroup); 1435 - configView->showPromptAction = new QAction(_("Show Prompt Options"), 0, optGroup); 1436 - #endif 1437 - configView->showNormalAction->setToggleAction(TRUE); 1438 - configView->showNormalAction->setOn(configList->optMode == normalOpt); 1439 - configView->showAllAction->setToggleAction(TRUE); 1440 - configView->showAllAction->setOn(configList->optMode == allOpt); 1441 - configView->showPromptAction->setToggleAction(TRUE); 1442 - configView->showPromptAction->setOn(configList->optMode == promptOpt); 1376 + configView->showNormalAction->setCheckable(true); 1377 + configView->showAllAction->setCheckable(true); 1378 + configView->showPromptAction->setCheckable(true); 1443 1379 1444 - Q3Action *showDebugAction = new Q3Action(NULL, _("Show Debug Info"), 0, this); 1445 - showDebugAction->setToggleAction(TRUE); 1380 + QAction *showDebugAction = new QAction( _("Show Debug Info"), this); 1381 + showDebugAction->setCheckable(true); 1446 1382 connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); 1447 - connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool))); 1448 - showDebugAction->setOn(helpText->showDebug()); 1383 + showDebugAction->setChecked(helpText->showDebug()); 1449 1384 1450 - Q3Action *showIntroAction = new Q3Action(NULL, _("Introduction"), 0, this); 1451 - connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); 1452 - Q3Action *showAboutAction = new Q3Action(NULL, _("About"), 0, this); 1453 - connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); 1385 + QAction *showIntroAction = new QAction( _("Introduction"), this); 1386 + connect(showIntroAction, SIGNAL(triggered(bool)), SLOT(showIntro())); 1387 + QAction *showAboutAction = new QAction( _("About"), this); 1388 + connect(showAboutAction, SIGNAL(triggered(bool)), SLOT(showAbout())); 1454 1389 1455 1390 // init tool bar 1456 - backAction->addTo(toolBar); 1391 + toolBar->addAction(backAction); 1457 1392 toolBar->addSeparator(); 1458 - loadAction->addTo(toolBar); 1459 - saveAction->addTo(toolBar); 1393 + toolBar->addAction(loadAction); 1394 + toolBar->addAction(saveAction); 1460 1395 toolBar->addSeparator(); 1461 - singleViewAction->addTo(toolBar); 1462 - splitViewAction->addTo(toolBar); 1463 - fullViewAction->addTo(toolBar); 1396 + toolBar->addAction(singleViewAction); 1397 + toolBar->addAction(splitViewAction); 1398 + toolBar->addAction(fullViewAction); 1464 1399 1465 1400 // create config menu 1466 - Q3PopupMenu* config = new Q3PopupMenu(this); 1467 - menu->insertItem(_("&File"), config); 1468 - loadAction->addTo(config); 1469 - saveAction->addTo(config); 1470 - saveAsAction->addTo(config); 1471 - config->insertSeparator(); 1472 - quitAction->addTo(config); 1401 + QMenu* config = menu->addMenu(_("&File")); 1402 + config->addAction(loadAction); 1403 + config->addAction(saveAction); 1404 + config->addAction(saveAsAction); 1405 + config->addSeparator(); 1406 + config->addAction(quitAction); 1473 1407 1474 1408 // create edit menu 1475 - Q3PopupMenu* editMenu = new Q3PopupMenu(this); 1476 - menu->insertItem(_("&Edit"), editMenu); 1477 - searchAction->addTo(editMenu); 1409 + QMenu* editMenu = menu->addMenu(_("&Edit")); 1410 + editMenu->addAction(searchAction); 1478 1411 1479 1412 // create options menu 1480 - Q3PopupMenu* optionMenu = new Q3PopupMenu(this); 1481 - menu->insertItem(_("&Option"), optionMenu); 1482 - showNameAction->addTo(optionMenu); 1483 - showRangeAction->addTo(optionMenu); 1484 - showDataAction->addTo(optionMenu); 1485 - optionMenu->insertSeparator(); 1486 - optGroup->addTo(optionMenu); 1487 - optionMenu->insertSeparator(); 1413 + QMenu* optionMenu = menu->addMenu(_("&Option")); 1414 + optionMenu->addAction(showNameAction); 1415 + optionMenu->addAction(showRangeAction); 1416 + optionMenu->addAction(showDataAction); 1417 + optionMenu->addSeparator(); 1418 + optionMenu->addActions(optGroup->actions()); 1419 + optionMenu->addSeparator(); 1488 1420 1489 1421 // create help menu 1490 - Q3PopupMenu* helpMenu = new Q3PopupMenu(this); 1491 - menu->insertSeparator(); 1492 - menu->insertItem(_("&Help"), helpMenu); 1493 - showIntroAction->addTo(helpMenu); 1494 - showAboutAction->addTo(helpMenu); 1422 + menu->addSeparator(); 1423 + QMenu* helpMenu = menu->addMenu(_("&Help")); 1424 + helpMenu->addAction(showIntroAction); 1425 + helpMenu->addAction(showAboutAction); 1495 1426 1496 1427 connect(configList, SIGNAL(menuChanged(struct menu *)), 1497 1428 helpText, SLOT(setInfo(struct menu *))); ··· 1501 1456 connect(helpText, SIGNAL(menuSelected(struct menu *)), 1502 1457 SLOT(setMenuLink(struct menu *))); 1503 1458 1504 - QString listMode = configSettings->readEntry("/listMode", "symbol"); 1459 + QString listMode = configSettings->value("/listMode", "symbol").toString(); 1505 1460 if (listMode == "single") 1506 1461 showSingleView(); 1507 1462 else if (listMode == "full") ··· 1510 1465 showSplitView(); 1511 1466 1512 1467 // UI setup done, restore splitter positions 1513 - Q3ValueList<int> sizes = configSettings->readSizes("/split1", &ok); 1468 + QList<int> sizes = configSettings->readSizes("/split1", &ok); 1514 1469 if (ok) 1515 1470 split1->setSizes(sizes); 1516 1471 ··· 1521 1476 1522 1477 void ConfigMainWindow::loadConfig(void) 1523 1478 { 1524 - QString s = Q3FileDialog::getOpenFileName(conf_get_configname(), NULL, this); 1479 + QString s = QFileDialog::getOpenFileName(this, "", conf_get_configname()); 1525 1480 if (s.isNull()) 1526 1481 return; 1527 1482 if (conf_read(QFile::encodeName(s))) ··· 1540 1495 1541 1496 void ConfigMainWindow::saveConfigAs(void) 1542 1497 { 1543 - QString s = Q3FileDialog::getSaveFileName(conf_get_configname(), NULL, this); 1498 + QString s = QFileDialog::getSaveFileName(this, "", conf_get_configname()); 1544 1499 if (s.isNull()) 1545 1500 return; 1546 1501 saveConfig(); ··· 1557 1512 { 1558 1513 configList->setRootMenu(menu); 1559 1514 if (configList->rootEntry->parent == &rootmenu) 1560 - backAction->setEnabled(FALSE); 1515 + backAction->setEnabled(false); 1561 1516 else 1562 - backAction->setEnabled(TRUE); 1517 + backAction->setEnabled(true); 1563 1518 } 1564 1519 1565 1520 void ConfigMainWindow::setMenuLink(struct menu *menu) ··· 1591 1546 return; 1592 1547 item = menuList->findConfigItem(parent); 1593 1548 if (item) { 1594 - menuList->setSelected(item, TRUE); 1595 - menuList->ensureItemVisible(item); 1549 + item->setSelected(true); 1550 + menuList->scrollToItem(item); 1596 1551 } 1597 1552 list->setRootMenu(parent); 1598 1553 } ··· 1607 1562 if (list) { 1608 1563 item = list->findConfigItem(menu); 1609 1564 if (item) { 1610 - list->setSelected(item, TRUE); 1611 - list->ensureItemVisible(item); 1565 + item->setSelected(true); 1566 + list->scrollToItem(item); 1612 1567 list->setFocus(); 1613 1568 } 1614 1569 } ··· 1622 1577 1623 1578 void ConfigMainWindow::goBack(void) 1624 1579 { 1625 - ConfigItem* item; 1580 + ConfigItem* item, *oldSelection; 1626 1581 1627 1582 configList->setParentMenu(); 1628 1583 if (configList->rootEntry == &rootmenu) 1629 - backAction->setEnabled(FALSE); 1630 - item = (ConfigItem*)menuList->selectedItem(); 1584 + backAction->setEnabled(false); 1585 + 1586 + if (menuList->selectedItems().count() == 0) 1587 + return; 1588 + 1589 + item = (ConfigItem*)menuList->selectedItems().first(); 1590 + oldSelection = item; 1631 1591 while (item) { 1632 1592 if (item->menu == configList->rootEntry) { 1633 - menuList->setSelected(item, TRUE); 1593 + oldSelection->setSelected(false); 1594 + item->setSelected(true); 1634 1595 break; 1635 1596 } 1636 1597 item = (ConfigItem*)item->parent(); ··· 1645 1594 1646 1595 void ConfigMainWindow::showSingleView(void) 1647 1596 { 1597 + singleViewAction->setEnabled(false); 1598 + singleViewAction->setChecked(true); 1599 + splitViewAction->setEnabled(true); 1600 + splitViewAction->setChecked(false); 1601 + fullViewAction->setEnabled(true); 1602 + fullViewAction->setChecked(false); 1603 + 1648 1604 menuView->hide(); 1649 1605 menuList->setRootMenu(0); 1650 1606 configList->mode = singleMode; ··· 1659 1601 configList->updateListAll(); 1660 1602 else 1661 1603 configList->setRootMenu(&rootmenu); 1662 - configList->setAllOpen(TRUE); 1663 1604 configList->setFocus(); 1664 1605 } 1665 1606 1666 1607 void ConfigMainWindow::showSplitView(void) 1667 1608 { 1609 + singleViewAction->setEnabled(true); 1610 + singleViewAction->setChecked(false); 1611 + splitViewAction->setEnabled(false); 1612 + splitViewAction->setChecked(true); 1613 + fullViewAction->setEnabled(true); 1614 + fullViewAction->setChecked(false); 1615 + 1668 1616 configList->mode = symbolMode; 1669 1617 if (configList->rootEntry == &rootmenu) 1670 1618 configList->updateListAll(); 1671 1619 else 1672 1620 configList->setRootMenu(&rootmenu); 1673 - configList->setAllOpen(TRUE); 1621 + configList->setAllOpen(true); 1674 1622 configApp->processEvents(); 1675 1623 menuList->mode = menuMode; 1676 1624 menuList->setRootMenu(&rootmenu); 1677 - menuList->setAllOpen(TRUE); 1625 + menuList->setAllOpen(true); 1678 1626 menuView->show(); 1679 1627 menuList->setFocus(); 1680 1628 } 1681 1629 1682 1630 void ConfigMainWindow::showFullView(void) 1683 1631 { 1632 + singleViewAction->setEnabled(true); 1633 + singleViewAction->setChecked(false); 1634 + splitViewAction->setEnabled(true); 1635 + splitViewAction->setChecked(false); 1636 + fullViewAction->setEnabled(false); 1637 + fullViewAction->setChecked(true); 1638 + 1684 1639 menuView->hide(); 1685 1640 menuList->setRootMenu(0); 1686 1641 configList->mode = fullMode; ··· 1701 1630 configList->updateListAll(); 1702 1631 else 1703 1632 configList->setRootMenu(&rootmenu); 1704 - configList->setAllOpen(FALSE); 1705 1633 configList->setFocus(); 1706 1634 } 1707 1635 ··· 1754 1684 1755 1685 void ConfigMainWindow::showAbout(void) 1756 1686 { 1757 - static const QString str = _("qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n" 1687 + static const QString str = _("qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n" 1688 + "Copyright (C) 2015 Boris Barbulovski <bbarbulovski@gmail.com>.\n\n" 1758 1689 "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"); 1759 1690 1760 1691 QMessageBox::information(this, "qconf", str); ··· 1763 1692 1764 1693 void ConfigMainWindow::saveSettings(void) 1765 1694 { 1766 - configSettings->writeEntry("/window x", pos().x()); 1767 - configSettings->writeEntry("/window y", pos().y()); 1768 - configSettings->writeEntry("/window width", size().width()); 1769 - configSettings->writeEntry("/window height", size().height()); 1695 + configSettings->setValue("/window x", pos().x()); 1696 + configSettings->setValue("/window y", pos().y()); 1697 + configSettings->setValue("/window width", size().width()); 1698 + configSettings->setValue("/window height", size().height()); 1770 1699 1771 1700 QString entry; 1772 1701 switch(configList->mode) { ··· 1785 1714 default: 1786 1715 break; 1787 1716 } 1788 - configSettings->writeEntry("/listMode", entry); 1717 + configSettings->setValue("/listMode", entry); 1789 1718 1790 1719 configSettings->writeSizes("/split1", split1->sizes()); 1791 1720 configSettings->writeSizes("/split2", split2->sizes()); ··· 1817 1746 1818 1747 static void usage(void) 1819 1748 { 1820 - printf(_("%s [-s] <config>\n"), progname); 1749 + printf(_("%s [-s] <config>\n").toLatin1().constData(), progname); 1821 1750 exit(0); 1822 1751 } 1823 1752 ··· 1856 1785 v = new ConfigMainWindow(); 1857 1786 1858 1787 //zconfdump(stdout); 1859 - configApp->setMainWidget(v); 1860 1788 configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); 1861 1789 configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings())); 1862 1790 v->show();
+71 -79
scripts/kconfig/qconf.h
··· 3 3 * Released under the terms of the GNU GPL v2.0. 4 4 */ 5 5 6 - #if QT_VERSION < 0x040000 7 - #include <qlistview.h> 8 - #else 9 - #include <q3listview.h> 10 - #endif 6 + #include <QTextBrowser> 7 + #include <QTreeWidget> 8 + #include <QMainWindow> 9 + #include <QHeaderView> 11 10 #include <qsettings.h> 12 - 13 - #if QT_VERSION < 0x040000 14 - #define Q3ValueList QValueList 15 - #define Q3PopupMenu QPopupMenu 16 - #define Q3ListView QListView 17 - #define Q3ListViewItem QListViewItem 18 - #define Q3VBox QVBox 19 - #define Q3TextBrowser QTextBrowser 20 - #define Q3MainWindow QMainWindow 21 - #define Q3Action QAction 22 - #define Q3ToolBar QToolBar 23 - #define Q3ListViewItemIterator QListViewItemIterator 24 - #define Q3FileDialog QFileDialog 25 - #endif 11 + #include <QPushButton> 12 + #include <QSettings> 13 + #include <QLineEdit> 14 + #include <QSplitter> 15 + #include <QCheckBox> 16 + #include <QDialog> 17 + #include "expr.h" 26 18 27 19 class ConfigView; 28 20 class ConfigList; ··· 25 33 class ConfigSettings : public QSettings { 26 34 public: 27 35 ConfigSettings(); 28 - Q3ValueList<int> readSizes(const QString& key, bool *ok); 29 - bool writeSizes(const QString& key, const Q3ValueList<int>& value); 36 + QList<int> readSizes(const QString& key, bool *ok); 37 + bool writeSizes(const QString& key, const QList<int>& value); 30 38 }; 31 39 32 40 enum colIdx { ··· 39 47 normalOpt = 0, allOpt, promptOpt 40 48 }; 41 49 42 - class ConfigList : public Q3ListView { 50 + class ConfigList : public QTreeWidget { 43 51 Q_OBJECT 44 - typedef class Q3ListView Parent; 52 + typedef class QTreeWidget Parent; 45 53 public: 46 54 ConfigList(ConfigView* p, const char *name = 0); 47 55 void reinit(void); ··· 53 61 54 62 protected: 55 63 void keyPressEvent(QKeyEvent *e); 56 - void contentsMousePressEvent(QMouseEvent *e); 57 - void contentsMouseReleaseEvent(QMouseEvent *e); 58 - void contentsMouseMoveEvent(QMouseEvent *e); 59 - void contentsMouseDoubleClickEvent(QMouseEvent *e); 64 + void mousePressEvent(QMouseEvent *e); 65 + void mouseReleaseEvent(QMouseEvent *e); 66 + void mouseMoveEvent(QMouseEvent *e); 67 + void mouseDoubleClickEvent(QMouseEvent *e); 60 68 void focusInEvent(QFocusEvent *e); 61 69 void contextMenuEvent(QContextMenuEvent *e); 62 70 ··· 87 95 } 88 96 ConfigItem* firstChild() const 89 97 { 90 - return (ConfigItem *)Parent::firstChild(); 98 + return (ConfigItem *)children().first(); 91 99 } 92 - int mapIdx(colIdx idx) 100 + void addColumn(colIdx idx) 93 101 { 94 - return colMap[idx]; 95 - } 96 - void addColumn(colIdx idx, const QString& label) 97 - { 98 - colMap[idx] = Parent::addColumn(label); 99 - colRevMap[colMap[idx]] = idx; 102 + showColumn(idx); 100 103 } 101 104 void removeColumn(colIdx idx) 102 105 { 103 - int col = colMap[idx]; 104 - if (col >= 0) { 105 - Parent::removeColumn(col); 106 - colRevMap[col] = colMap[idx] = -1; 107 - } 106 + hideColumn(idx); 108 107 } 109 108 void setAllOpen(bool open); 110 109 void setParentMenu(void); 111 110 112 111 bool menuSkip(struct menu *); 113 112 114 - template <class P> 115 - void updateMenuList(P*, struct menu*); 113 + void updateMenuList(ConfigItem *parent, struct menu*); 114 + void updateMenuList(ConfigList *parent, struct menu*); 116 115 117 116 bool updateAll; 118 117 ··· 115 132 enum listMode mode; 116 133 enum optionMode optMode; 117 134 struct menu *rootEntry; 118 - QColorGroup disabledColorGroup; 119 - QColorGroup inactivedColorGroup; 120 - Q3PopupMenu* headerPopup; 121 - 122 - private: 123 - int colMap[colNr]; 124 - int colRevMap[colNr]; 135 + QPalette disabledColorGroup; 136 + QPalette inactivedColorGroup; 137 + QMenu* headerPopup; 125 138 }; 126 139 127 - class ConfigItem : public Q3ListViewItem { 128 - typedef class Q3ListViewItem Parent; 140 + class ConfigItem : public QTreeWidgetItem { 141 + typedef class QTreeWidgetItem Parent; 129 142 public: 130 - ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v) 131 - : Parent(parent, after), menu(m), visible(v), goParent(false) 143 + ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v) 144 + : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false) 132 145 { 133 146 init(); 134 147 } 135 148 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) 136 - : Parent(parent, after), menu(m), visible(v), goParent(false) 149 + : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false) 137 150 { 138 151 init(); 139 152 } 140 - ConfigItem(Q3ListView *parent, ConfigItem *after, bool v) 141 - : Parent(parent, after), menu(0), visible(v), goParent(true) 153 + ConfigItem(ConfigList *parent, ConfigItem *after, bool v) 154 + : Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true) 142 155 { 143 156 init(); 144 157 } ··· 145 166 void testUpdateMenu(bool v); 146 167 ConfigList* listView() const 147 168 { 148 - return (ConfigList*)Parent::listView(); 169 + return (ConfigList*)Parent::treeWidget(); 149 170 } 150 171 ConfigItem* firstChild() const 151 172 { 152 - return (ConfigItem *)Parent::firstChild(); 173 + return (ConfigItem *)Parent::child(0); 153 174 } 154 - ConfigItem* nextSibling() const 175 + ConfigItem* nextSibling() 155 176 { 156 - return (ConfigItem *)Parent::nextSibling(); 177 + ConfigItem *ret = NULL; 178 + ConfigItem *_parent = (ConfigItem *)parent(); 179 + 180 + if(_parent) { 181 + ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1); 182 + } else { 183 + QTreeWidget *_treeWidget = treeWidget(); 184 + ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1); 185 + } 186 + 187 + return ret; 157 188 } 158 189 void setText(colIdx idx, const QString& text) 159 190 { 160 - Parent::setText(listView()->mapIdx(idx), text); 191 + Parent::setText(idx, text); 161 192 } 162 193 QString text(colIdx idx) const 163 194 { 164 - return Parent::text(listView()->mapIdx(idx)); 195 + return Parent::text(idx); 165 196 } 166 - void setPixmap(colIdx idx, const QPixmap& pm) 197 + void setPixmap(colIdx idx, const QIcon &icon) 167 198 { 168 - Parent::setPixmap(listView()->mapIdx(idx), pm); 199 + Parent::setIcon(idx, icon); 169 200 } 170 - const QPixmap* pixmap(colIdx idx) const 201 + const QIcon pixmap(colIdx idx) const 171 202 { 172 - return Parent::pixmap(listView()->mapIdx(idx)); 203 + return icon(idx); 173 204 } 174 - void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); 205 + // TODO: Implement paintCell 175 206 176 207 ConfigItem* nextItem; 177 208 struct menu *menu; ··· 205 216 ConfigItem *item; 206 217 }; 207 218 208 - class ConfigView : public Q3VBox { 219 + class ConfigView : public QWidget { 209 220 Q_OBJECT 210 - typedef class Q3VBox Parent; 221 + typedef class QWidget Parent; 211 222 public: 212 223 ConfigView(QWidget* parent, const char *name = 0); 213 224 ~ConfigView(void); ··· 238 249 static QAction *showPromptAction; 239 250 }; 240 251 241 - class ConfigInfoView : public Q3TextBrowser { 252 + class ConfigInfoView : public QTextBrowser { 242 253 Q_OBJECT 243 - typedef class Q3TextBrowser Parent; 254 + typedef class QTextBrowser Parent; 244 255 public: 245 256 ConfigInfoView(QWidget* parent, const char *name = 0); 246 257 bool showDebug(void) const { return _showDebug; } ··· 260 271 QString debug_info(struct symbol *sym); 261 272 static QString print_filter(const QString &str); 262 273 static void expr_print_help(void *data, struct symbol *sym, const char *str); 263 - Q3PopupMenu* createPopupMenu(const QPoint& pos); 264 - void contentsContextMenuEvent(QContextMenuEvent *e); 274 + QMenu *createStandardContextMenu(const QPoint & pos); 275 + void contextMenuEvent(QContextMenuEvent *e); 265 276 266 277 struct symbol *sym; 267 278 struct menu *_menu; ··· 288 299 struct symbol **result; 289 300 }; 290 301 291 - class ConfigMainWindow : public Q3MainWindow { 302 + class ConfigMainWindow : public QMainWindow { 292 303 Q_OBJECT 293 304 294 - static Q3Action *saveAction; 305 + static QAction *saveAction; 295 306 static void conf_changed(void); 296 307 public: 297 308 ConfigMainWindow(void); ··· 320 331 ConfigView *configView; 321 332 ConfigList *configList; 322 333 ConfigInfoView *helpText; 323 - Q3ToolBar *toolBar; 324 - Q3Action *backAction; 325 - QSplitter* split1; 326 - QSplitter* split2; 334 + QToolBar *toolBar; 335 + QAction *backAction; 336 + QAction *singleViewAction; 337 + QAction *splitViewAction; 338 + QAction *fullViewAction; 339 + QSplitter *split1; 340 + QSplitter *split2; 327 341 };
+2
scripts/kconfig/symbol.c
··· 1116 1116 if (stack->sym == last_sym) 1117 1117 fprintf(stderr, "%s:%d:error: recursive dependency detected!\n", 1118 1118 prop->file->name, prop->lineno); 1119 + fprintf(stderr, "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n"); 1120 + fprintf(stderr, "subsection \"Kconfig recursive dependency limitations\"\n"); 1119 1121 if (stack->expr) { 1120 1122 fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", 1121 1123 prop->file->name, prop->lineno,