From 5159cd2beb2e87806a5b54e9991b7895285c9d3e Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 27 Jan 2013 01:04:16 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- tdecore/CMakeLists.txt | 16 +- tdecore/DESIGN.kconfig | 224 -- tdecore/DESIGN.tdeconfig | 224 ++ tdecore/MAINTAINERS | 10 +- tdecore/Makefile.am | 22 +- tdecore/README.kiosk | 2 +- tdecore/README.kstartupinfo | 2 +- tdecore/kaccelaction.cpp | 2 +- tdecore/kaccelbase.cpp | 2 +- tdecore/kappdcopiface.cpp | 2 +- tdecore/kapplication.cpp | 4 +- tdecore/kcharsets.cpp | 2 +- tdecore/kcheckaccelerators.cpp | 2 +- tdecore/kclipboard.cpp | 2 +- tdecore/kconfig.cpp | 367 ---- tdecore/kconfig.h | 296 --- tdecore/kconfig_compiler/CMakeLists.txt | 29 - tdecore/kconfig_compiler/Makefile.am | 18 - tdecore/kconfig_compiler/README.dox | 255 --- tdecore/kconfig_compiler/TODO | 0 tdecore/kconfig_compiler/checkkcfg.pl | 83 - tdecore/kconfig_compiler/example/Makefile.am | 27 - tdecore/kconfig_compiler/example/autoexample.cpp | 64 - tdecore/kconfig_compiler/example/example.cpp | 52 - tdecore/kconfig_compiler/example/example.kcfg | 63 - .../example/exampleprefs_base.kcfgc | 18 - tdecore/kconfig_compiler/example/general_base.ui | 46 - tdecore/kconfig_compiler/example/myoptions_base.ui | 35 - tdecore/kconfig_compiler/kcfg.xsd | 192 -- tdecore/kconfig_compiler/kconfig_compiler.cpp | 1700 --------------- tdecore/kconfig_compiler/tests/Makefile.am | 134 -- .../tests/kconfigcompiler_test.cpp | 96 - .../kconfig_compiler/tests/kconfigcompiler_test.h | 35 - tdecore/kconfig_compiler/tests/myprefs.h | 7 - tdecore/kconfig_compiler/tests/test1.cpp.ref | 72 - tdecore/kconfig_compiler/tests/test1.h.ref | 196 -- tdecore/kconfig_compiler/tests/test1.kcfg | 55 - tdecore/kconfig_compiler/tests/test1.kcfgc | 18 - tdecore/kconfig_compiler/tests/test1main.cpp | 29 - tdecore/kconfig_compiler/tests/test2.cpp.ref | 98 - tdecore/kconfig_compiler/tests/test2.h.ref | 333 --- tdecore/kconfig_compiler/tests/test2.kcfg | 78 - tdecore/kconfig_compiler/tests/test2.kcfgc | 11 - tdecore/kconfig_compiler/tests/test2main.cpp | 29 - tdecore/kconfig_compiler/tests/test3.cpp.ref | 29 - tdecore/kconfig_compiler/tests/test3.h.ref | 138 -- tdecore/kconfig_compiler/tests/test3.kcfg | 26 - tdecore/kconfig_compiler/tests/test3.kcfgc | 12 - tdecore/kconfig_compiler/tests/test3main.cpp | 29 - tdecore/kconfig_compiler/tests/test4.cpp.ref | 82 - tdecore/kconfig_compiler/tests/test4.h.ref | 135 -- tdecore/kconfig_compiler/tests/test4.kcfg | 42 - tdecore/kconfig_compiler/tests/test4.kcfgc | 11 - tdecore/kconfig_compiler/tests/test4main.cpp | 30 - tdecore/kconfig_compiler/tests/test5.cpp.ref | 82 - tdecore/kconfig_compiler/tests/test5.h.ref | 127 -- tdecore/kconfig_compiler/tests/test5.kcfg | 42 - tdecore/kconfig_compiler/tests/test5.kcfgc | 11 - tdecore/kconfig_compiler/tests/test5main.cpp | 30 - tdecore/kconfig_compiler/tests/test6.cpp.ref | 31 - tdecore/kconfig_compiler/tests/test6.h.ref | 93 - tdecore/kconfig_compiler/tests/test6.kcfg | 25 - tdecore/kconfig_compiler/tests/test6.kcfgc | 11 - tdecore/kconfig_compiler/tests/test6main.cpp | 30 - tdecore/kconfig_compiler/tests/test7.cpp.ref | 31 - tdecore/kconfig_compiler/tests/test7.h.ref | 93 - tdecore/kconfig_compiler/tests/test7.kcfg | 25 - tdecore/kconfig_compiler/tests/test7.kcfgc | 11 - tdecore/kconfig_compiler/tests/test7main.cpp | 30 - tdecore/kconfig_compiler/tests/test8a.cpp.ref | 22 - tdecore/kconfig_compiler/tests/test8a.h.ref | 61 - tdecore/kconfig_compiler/tests/test8a.kcfg | 17 - tdecore/kconfig_compiler/tests/test8a.kcfgc | 3 - tdecore/kconfig_compiler/tests/test8b.cpp.ref | 46 - tdecore/kconfig_compiler/tests/test8b.h.ref | 96 - tdecore/kconfig_compiler/tests/test8b.kcfg | 21 - tdecore/kconfig_compiler/tests/test8b.kcfgc | 6 - tdecore/kconfig_compiler/tests/test8main.cpp | 34 - tdecore/kconfig_compiler/tests/test9.cpp.ref | 35 - tdecore/kconfig_compiler/tests/test9.h.ref | 82 - tdecore/kconfig_compiler/tests/test9.kcfg | 24 - tdecore/kconfig_compiler/tests/test9.kcfgc | 18 - tdecore/kconfig_compiler/tests/test9main.cpp | 43 - .../kconfig_compiler/tests/test_dpointer.cpp.ref | 344 --- tdecore/kconfig_compiler/tests/test_dpointer.h.ref | 224 -- tdecore/kconfig_compiler/tests/test_dpointer.kcfg | 78 - tdecore/kconfig_compiler/tests/test_dpointer.kcfgc | 11 - .../kconfig_compiler/tests/test_dpointer_main.cpp | 30 - tdecore/kconfigbackend.cpp | 1190 ----------- tdecore/kconfigbackend.h | 299 --- tdecore/kconfigbase.cpp | 1937 ----------------- tdecore/kconfigbase.h | 2180 -------------------- tdecore/kconfigdata.h | 146 -- tdecore/kconfigdialogmanager.cpp | 398 ---- tdecore/kconfigdialogmanager.h | 236 --- tdecore/kconfigskeleton.cpp | 1207 ----------- tdecore/kconfigskeleton.h | 1230 ----------- tdecore/kcrash.cpp | 4 +- tdecore/kdebug.areas | 20 +- tdecore/kdebug.cpp | 2 +- tdecore/kdesktopfile.cpp | 2 +- tdecore/kdesktopfile.h | 2 +- tdecore/kdetcompmgr.cpp | 2 +- tdecore/kglobal.cpp | 2 +- tdecore/kglobalsettings.cpp | 2 +- tdecore/kiconeffect.cpp | 2 +- tdecore/kiconloader.cpp | 2 +- tdecore/kicontheme.cpp | 2 +- tdecore/kinstance.cpp | 2 +- tdecore/kkeyserver_x11.cpp | 2 +- tdecore/klocale.cpp | 4 +- tdecore/kmdcodec_compat.h | 2 +- tdecore/knotifyclient.cpp | 2 +- tdecore/kprotocolinfo_tdecore.cpp | 4 +- tdecore/kprotocolinfofactory.h | 2 +- tdecore/kshortcutlist.cpp | 2 +- tdecore/ksimpleconfig.cpp | 2 +- tdecore/ksimpleconfig.h | 2 +- tdecore/ksimpledirwatch.cpp | 4 +- tdecore/ksocks.cpp | 2 +- tdecore/kstandarddirs.cpp | 2 +- tdecore/kstdaccel.cpp | 2 +- tdecore/kuniqueapplication.cpp | 2 +- .../network-manager/network-manager.cpp | 10 +- tdecore/tdeconfig.cpp | 367 ++++ tdecore/tdeconfig.h | 296 +++ tdecore/tdeconfig_compiler/CMakeLists.txt | 29 + tdecore/tdeconfig_compiler/Makefile.am | 18 + tdecore/tdeconfig_compiler/README.dox | 255 +++ tdecore/tdeconfig_compiler/TODO | 0 tdecore/tdeconfig_compiler/checkkcfg.pl | 83 + tdecore/tdeconfig_compiler/example/Makefile.am | 27 + tdecore/tdeconfig_compiler/example/autoexample.cpp | 64 + tdecore/tdeconfig_compiler/example/example.cpp | 52 + tdecore/tdeconfig_compiler/example/example.kcfg | 63 + .../example/exampleprefs_base.kcfgc | 18 + tdecore/tdeconfig_compiler/example/general_base.ui | 46 + .../tdeconfig_compiler/example/myoptions_base.ui | 35 + tdecore/tdeconfig_compiler/kcfg.xsd | 192 ++ tdecore/tdeconfig_compiler/tdeconfig_compiler.cpp | 1700 +++++++++++++++ tdecore/tdeconfig_compiler/tests/Makefile.am | 134 ++ tdecore/tdeconfig_compiler/tests/myprefs.h | 7 + .../tests/tdeconfigcompiler_test.cpp | 96 + .../tests/tdeconfigcompiler_test.h | 35 + tdecore/tdeconfig_compiler/tests/test1.cpp.ref | 72 + tdecore/tdeconfig_compiler/tests/test1.h.ref | 196 ++ tdecore/tdeconfig_compiler/tests/test1.kcfg | 55 + tdecore/tdeconfig_compiler/tests/test1.kcfgc | 18 + tdecore/tdeconfig_compiler/tests/test1main.cpp | 29 + tdecore/tdeconfig_compiler/tests/test2.cpp.ref | 98 + tdecore/tdeconfig_compiler/tests/test2.h.ref | 333 +++ tdecore/tdeconfig_compiler/tests/test2.kcfg | 78 + tdecore/tdeconfig_compiler/tests/test2.kcfgc | 11 + tdecore/tdeconfig_compiler/tests/test2main.cpp | 29 + tdecore/tdeconfig_compiler/tests/test3.cpp.ref | 29 + tdecore/tdeconfig_compiler/tests/test3.h.ref | 138 ++ tdecore/tdeconfig_compiler/tests/test3.kcfg | 26 + tdecore/tdeconfig_compiler/tests/test3.kcfgc | 12 + tdecore/tdeconfig_compiler/tests/test3main.cpp | 29 + tdecore/tdeconfig_compiler/tests/test4.cpp.ref | 82 + tdecore/tdeconfig_compiler/tests/test4.h.ref | 135 ++ tdecore/tdeconfig_compiler/tests/test4.kcfg | 42 + tdecore/tdeconfig_compiler/tests/test4.kcfgc | 11 + tdecore/tdeconfig_compiler/tests/test4main.cpp | 30 + tdecore/tdeconfig_compiler/tests/test5.cpp.ref | 82 + tdecore/tdeconfig_compiler/tests/test5.h.ref | 127 ++ tdecore/tdeconfig_compiler/tests/test5.kcfg | 42 + tdecore/tdeconfig_compiler/tests/test5.kcfgc | 11 + tdecore/tdeconfig_compiler/tests/test5main.cpp | 30 + tdecore/tdeconfig_compiler/tests/test6.cpp.ref | 31 + tdecore/tdeconfig_compiler/tests/test6.h.ref | 93 + tdecore/tdeconfig_compiler/tests/test6.kcfg | 25 + tdecore/tdeconfig_compiler/tests/test6.kcfgc | 11 + tdecore/tdeconfig_compiler/tests/test6main.cpp | 30 + tdecore/tdeconfig_compiler/tests/test7.cpp.ref | 31 + tdecore/tdeconfig_compiler/tests/test7.h.ref | 93 + tdecore/tdeconfig_compiler/tests/test7.kcfg | 25 + tdecore/tdeconfig_compiler/tests/test7.kcfgc | 11 + tdecore/tdeconfig_compiler/tests/test7main.cpp | 30 + tdecore/tdeconfig_compiler/tests/test8a.cpp.ref | 22 + tdecore/tdeconfig_compiler/tests/test8a.h.ref | 61 + tdecore/tdeconfig_compiler/tests/test8a.kcfg | 17 + tdecore/tdeconfig_compiler/tests/test8a.kcfgc | 3 + tdecore/tdeconfig_compiler/tests/test8b.cpp.ref | 46 + tdecore/tdeconfig_compiler/tests/test8b.h.ref | 96 + tdecore/tdeconfig_compiler/tests/test8b.kcfg | 21 + tdecore/tdeconfig_compiler/tests/test8b.kcfgc | 6 + tdecore/tdeconfig_compiler/tests/test8main.cpp | 34 + tdecore/tdeconfig_compiler/tests/test9.cpp.ref | 35 + tdecore/tdeconfig_compiler/tests/test9.h.ref | 82 + tdecore/tdeconfig_compiler/tests/test9.kcfg | 24 + tdecore/tdeconfig_compiler/tests/test9.kcfgc | 18 + tdecore/tdeconfig_compiler/tests/test9main.cpp | 43 + .../tdeconfig_compiler/tests/test_dpointer.cpp.ref | 344 +++ .../tdeconfig_compiler/tests/test_dpointer.h.ref | 224 ++ .../tdeconfig_compiler/tests/test_dpointer.kcfg | 78 + .../tdeconfig_compiler/tests/test_dpointer.kcfgc | 11 + .../tests/test_dpointer_main.cpp | 30 + tdecore/tdeconfigbackend.cpp | 1190 +++++++++++ tdecore/tdeconfigbackend.h | 299 +++ tdecore/tdeconfigbase.cpp | 1937 +++++++++++++++++ tdecore/tdeconfigbase.h | 2180 ++++++++++++++++++++ tdecore/tdeconfigdata.h | 146 ++ tdecore/tdeconfigdialogmanager.cpp | 398 ++++ tdecore/tdeconfigdialogmanager.h | 236 +++ tdecore/tdeconfigskeleton.cpp | 1207 +++++++++++ tdecore/tdeconfigskeleton.h | 1230 +++++++++++ tdecore/tdehardwaredevices.cpp | 2 +- tdecore/tdesycoca.cpp | 2 +- tdecore/tdesycoca.h | 4 +- tdecore/tests/Makefile.am | 12 +- tdecore/tests/kconfigtest.cpp | 162 -- tdecore/tests/kconfigtestgui.cpp | 200 -- tdecore/tests/kconfigtestgui.h | 72 - tdecore/tests/ksimpleconfigtest.cpp | 2 +- tdecore/tests/kstddirstest.cpp | 2 +- tdecore/tests/kurltest.cpp | 10 +- tdecore/tests/tdeconfigtest.cpp | 162 ++ tdecore/tests/tdeconfigtestgui.cpp | 200 ++ tdecore/tests/tdeconfigtestgui.h | 72 + 220 files changed, 16413 insertions(+), 16413 deletions(-) delete mode 100644 tdecore/DESIGN.kconfig create mode 100644 tdecore/DESIGN.tdeconfig delete mode 100644 tdecore/kconfig.cpp delete mode 100644 tdecore/kconfig.h delete mode 100644 tdecore/kconfig_compiler/CMakeLists.txt delete mode 100644 tdecore/kconfig_compiler/Makefile.am delete mode 100644 tdecore/kconfig_compiler/README.dox delete mode 100644 tdecore/kconfig_compiler/TODO delete mode 100755 tdecore/kconfig_compiler/checkkcfg.pl delete mode 100644 tdecore/kconfig_compiler/example/Makefile.am delete mode 100644 tdecore/kconfig_compiler/example/autoexample.cpp delete mode 100644 tdecore/kconfig_compiler/example/example.cpp delete mode 100644 tdecore/kconfig_compiler/example/example.kcfg delete mode 100644 tdecore/kconfig_compiler/example/exampleprefs_base.kcfgc delete mode 100644 tdecore/kconfig_compiler/example/general_base.ui delete mode 100644 tdecore/kconfig_compiler/example/myoptions_base.ui delete mode 100644 tdecore/kconfig_compiler/kcfg.xsd delete mode 100644 tdecore/kconfig_compiler/kconfig_compiler.cpp delete mode 100644 tdecore/kconfig_compiler/tests/Makefile.am delete mode 100644 tdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp delete mode 100644 tdecore/kconfig_compiler/tests/kconfigcompiler_test.h delete mode 100644 tdecore/kconfig_compiler/tests/myprefs.h delete mode 100644 tdecore/kconfig_compiler/tests/test1.cpp.ref delete mode 100644 tdecore/kconfig_compiler/tests/test1.h.ref delete mode 100644 tdecore/kconfig_compiler/tests/test1.kcfg delete mode 100644 tdecore/kconfig_compiler/tests/test1.kcfgc delete mode 100644 tdecore/kconfig_compiler/tests/test1main.cpp delete mode 100644 tdecore/kconfig_compiler/tests/test2.cpp.ref delete mode 100644 tdecore/kconfig_compiler/tests/test2.h.ref delete mode 100644 tdecore/kconfig_compiler/tests/test2.kcfg delete mode 100644 tdecore/kconfig_compiler/tests/test2.kcfgc delete mode 100644 tdecore/kconfig_compiler/tests/test2main.cpp delete mode 100644 tdecore/kconfig_compiler/tests/test3.cpp.ref delete mode 100644 tdecore/kconfig_compiler/tests/test3.h.ref delete mode 100644 tdecore/kconfig_compiler/tests/test3.kcfg delete mode 100644 tdecore/kconfig_compiler/tests/test3.kcfgc delete mode 100644 tdecore/kconfig_compiler/tests/test3main.cpp delete mode 100644 tdecore/kconfig_compiler/tests/test4.cpp.ref delete mode 100644 tdecore/kconfig_compiler/tests/test4.h.ref delete mode 100644 tdecore/kconfig_compiler/tests/test4.kcfg delete mode 100644 tdecore/kconfig_compiler/tests/test4.kcfgc delete mode 100644 tdecore/kconfig_compiler/tests/test4main.cpp delete mode 100644 tdecore/kconfig_compiler/tests/test5.cpp.ref delete mode 100644 tdecore/kconfig_compiler/tests/test5.h.ref delete mode 100644 tdecore/kconfig_compiler/tests/test5.kcfg delete mode 100644 tdecore/kconfig_compiler/tests/test5.kcfgc delete mode 100644 tdecore/kconfig_compiler/tests/test5main.cpp delete mode 100644 tdecore/kconfig_compiler/tests/test6.cpp.ref delete mode 100644 tdecore/kconfig_compiler/tests/test6.h.ref delete mode 100644 tdecore/kconfig_compiler/tests/test6.kcfg delete mode 100644 tdecore/kconfig_compiler/tests/test6.kcfgc delete mode 100644 tdecore/kconfig_compiler/tests/test6main.cpp delete mode 100644 tdecore/kconfig_compiler/tests/test7.cpp.ref delete mode 100644 tdecore/kconfig_compiler/tests/test7.h.ref delete mode 100644 tdecore/kconfig_compiler/tests/test7.kcfg delete mode 100644 tdecore/kconfig_compiler/tests/test7.kcfgc delete mode 100644 tdecore/kconfig_compiler/tests/test7main.cpp delete mode 100644 tdecore/kconfig_compiler/tests/test8a.cpp.ref delete mode 100644 tdecore/kconfig_compiler/tests/test8a.h.ref delete mode 100644 tdecore/kconfig_compiler/tests/test8a.kcfg delete mode 100644 tdecore/kconfig_compiler/tests/test8a.kcfgc delete mode 100644 tdecore/kconfig_compiler/tests/test8b.cpp.ref delete mode 100644 tdecore/kconfig_compiler/tests/test8b.h.ref delete mode 100644 tdecore/kconfig_compiler/tests/test8b.kcfg delete mode 100644 tdecore/kconfig_compiler/tests/test8b.kcfgc delete mode 100644 tdecore/kconfig_compiler/tests/test8main.cpp delete mode 100644 tdecore/kconfig_compiler/tests/test9.cpp.ref delete mode 100644 tdecore/kconfig_compiler/tests/test9.h.ref delete mode 100644 tdecore/kconfig_compiler/tests/test9.kcfg delete mode 100644 tdecore/kconfig_compiler/tests/test9.kcfgc delete mode 100644 tdecore/kconfig_compiler/tests/test9main.cpp delete mode 100644 tdecore/kconfig_compiler/tests/test_dpointer.cpp.ref delete mode 100644 tdecore/kconfig_compiler/tests/test_dpointer.h.ref delete mode 100644 tdecore/kconfig_compiler/tests/test_dpointer.kcfg delete mode 100644 tdecore/kconfig_compiler/tests/test_dpointer.kcfgc delete mode 100644 tdecore/kconfig_compiler/tests/test_dpointer_main.cpp delete mode 100644 tdecore/kconfigbackend.cpp delete mode 100644 tdecore/kconfigbackend.h delete mode 100644 tdecore/kconfigbase.cpp delete mode 100644 tdecore/kconfigbase.h delete mode 100644 tdecore/kconfigdata.h delete mode 100644 tdecore/kconfigdialogmanager.cpp delete mode 100644 tdecore/kconfigdialogmanager.h delete mode 100644 tdecore/kconfigskeleton.cpp delete mode 100644 tdecore/kconfigskeleton.h create mode 100644 tdecore/tdeconfig.cpp create mode 100644 tdecore/tdeconfig.h create mode 100644 tdecore/tdeconfig_compiler/CMakeLists.txt create mode 100644 tdecore/tdeconfig_compiler/Makefile.am create mode 100644 tdecore/tdeconfig_compiler/README.dox create mode 100644 tdecore/tdeconfig_compiler/TODO create mode 100755 tdecore/tdeconfig_compiler/checkkcfg.pl create mode 100644 tdecore/tdeconfig_compiler/example/Makefile.am create mode 100644 tdecore/tdeconfig_compiler/example/autoexample.cpp create mode 100644 tdecore/tdeconfig_compiler/example/example.cpp create mode 100644 tdecore/tdeconfig_compiler/example/example.kcfg create mode 100644 tdecore/tdeconfig_compiler/example/exampleprefs_base.kcfgc create mode 100644 tdecore/tdeconfig_compiler/example/general_base.ui create mode 100644 tdecore/tdeconfig_compiler/example/myoptions_base.ui create mode 100644 tdecore/tdeconfig_compiler/kcfg.xsd create mode 100644 tdecore/tdeconfig_compiler/tdeconfig_compiler.cpp create mode 100644 tdecore/tdeconfig_compiler/tests/Makefile.am create mode 100644 tdecore/tdeconfig_compiler/tests/myprefs.h create mode 100644 tdecore/tdeconfig_compiler/tests/tdeconfigcompiler_test.cpp create mode 100644 tdecore/tdeconfig_compiler/tests/tdeconfigcompiler_test.h create mode 100644 tdecore/tdeconfig_compiler/tests/test1.cpp.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test1.h.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test1.kcfg create mode 100644 tdecore/tdeconfig_compiler/tests/test1.kcfgc create mode 100644 tdecore/tdeconfig_compiler/tests/test1main.cpp create mode 100644 tdecore/tdeconfig_compiler/tests/test2.cpp.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test2.h.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test2.kcfg create mode 100644 tdecore/tdeconfig_compiler/tests/test2.kcfgc create mode 100644 tdecore/tdeconfig_compiler/tests/test2main.cpp create mode 100644 tdecore/tdeconfig_compiler/tests/test3.cpp.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test3.h.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test3.kcfg create mode 100644 tdecore/tdeconfig_compiler/tests/test3.kcfgc create mode 100644 tdecore/tdeconfig_compiler/tests/test3main.cpp create mode 100644 tdecore/tdeconfig_compiler/tests/test4.cpp.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test4.h.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test4.kcfg create mode 100644 tdecore/tdeconfig_compiler/tests/test4.kcfgc create mode 100644 tdecore/tdeconfig_compiler/tests/test4main.cpp create mode 100644 tdecore/tdeconfig_compiler/tests/test5.cpp.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test5.h.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test5.kcfg create mode 100644 tdecore/tdeconfig_compiler/tests/test5.kcfgc create mode 100644 tdecore/tdeconfig_compiler/tests/test5main.cpp create mode 100644 tdecore/tdeconfig_compiler/tests/test6.cpp.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test6.h.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test6.kcfg create mode 100644 tdecore/tdeconfig_compiler/tests/test6.kcfgc create mode 100644 tdecore/tdeconfig_compiler/tests/test6main.cpp create mode 100644 tdecore/tdeconfig_compiler/tests/test7.cpp.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test7.h.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test7.kcfg create mode 100644 tdecore/tdeconfig_compiler/tests/test7.kcfgc create mode 100644 tdecore/tdeconfig_compiler/tests/test7main.cpp create mode 100644 tdecore/tdeconfig_compiler/tests/test8a.cpp.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test8a.h.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test8a.kcfg create mode 100644 tdecore/tdeconfig_compiler/tests/test8a.kcfgc create mode 100644 tdecore/tdeconfig_compiler/tests/test8b.cpp.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test8b.h.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test8b.kcfg create mode 100644 tdecore/tdeconfig_compiler/tests/test8b.kcfgc create mode 100644 tdecore/tdeconfig_compiler/tests/test8main.cpp create mode 100644 tdecore/tdeconfig_compiler/tests/test9.cpp.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test9.h.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test9.kcfg create mode 100644 tdecore/tdeconfig_compiler/tests/test9.kcfgc create mode 100644 tdecore/tdeconfig_compiler/tests/test9main.cpp create mode 100644 tdecore/tdeconfig_compiler/tests/test_dpointer.cpp.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test_dpointer.h.ref create mode 100644 tdecore/tdeconfig_compiler/tests/test_dpointer.kcfg create mode 100644 tdecore/tdeconfig_compiler/tests/test_dpointer.kcfgc create mode 100644 tdecore/tdeconfig_compiler/tests/test_dpointer_main.cpp create mode 100644 tdecore/tdeconfigbackend.cpp create mode 100644 tdecore/tdeconfigbackend.h create mode 100644 tdecore/tdeconfigbase.cpp create mode 100644 tdecore/tdeconfigbase.h create mode 100644 tdecore/tdeconfigdata.h create mode 100644 tdecore/tdeconfigdialogmanager.cpp create mode 100644 tdecore/tdeconfigdialogmanager.h create mode 100644 tdecore/tdeconfigskeleton.cpp create mode 100644 tdecore/tdeconfigskeleton.h delete mode 100644 tdecore/tests/kconfigtest.cpp delete mode 100644 tdecore/tests/kconfigtestgui.cpp delete mode 100644 tdecore/tests/kconfigtestgui.h create mode 100644 tdecore/tests/tdeconfigtest.cpp create mode 100644 tdecore/tests/tdeconfigtestgui.cpp create mode 100644 tdecore/tests/tdeconfigtestgui.h (limited to 'tdecore') diff --git a/tdecore/CMakeLists.txt b/tdecore/CMakeLists.txt index 8d4939d83..dbc2a7065 100644 --- a/tdecore/CMakeLists.txt +++ b/tdecore/CMakeLists.txt @@ -11,7 +11,7 @@ add_subdirectory( malloc ) add_subdirectory( network ) -add_subdirectory( kconfig_compiler ) +add_subdirectory( tdeconfig_compiler ) add_subdirectory( hwlibdata ) add_subdirectory( hwlibdaemons ) @@ -53,7 +53,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/libltdl ${CMAKE_SOURCE_DIR}/tdefx ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/kio/kio + ${CMAKE_SOURCE_DIR}/tdeio/tdeio ${LIBART_INCLUDE_DIRS} ${LIBIDN_INCLUDE_DIRS} ${GAMIN_INCLUDEDIR} @@ -69,9 +69,9 @@ link_directories( ##### headers ################################### install( FILES - kconfig.h kconfigskeleton.h kconfigdata.h ksimpleconfig.h - kconfigdialogmanager.h kconfigbase.h kdesktopfile.h - kurl.h ksock.h kaboutdata.h kcmdlineargs.h kconfigbackend.h + tdeconfig.h tdeconfigskeleton.h tdeconfigdata.h ksimpleconfig.h + tdeconfigdialogmanager.h tdeconfigbase.h kdesktopfile.h + kurl.h ksock.h kaboutdata.h kcmdlineargs.h tdeconfigbackend.h kapp.h kapplication.h kuniqueapp.h kuniqueapplication.h kcharsets.h tdeversion.h kpty.h kprocess.h kprocctrl.h klocale.h kicontheme.h kiconloader.h kdebug.h twinmodule.h @@ -110,7 +110,7 @@ install( FILES kdebug.areas kdebugrc language.codes DESTINATION ${CONFIG_INSTALL_DIR} ) install( FILES kmdcodec_compat.h - DESTINATION ${INCLUDE_INSTALL_DIR}/kio RENAME kmdcodec.h ) + DESTINATION ${INCLUDE_INSTALL_DIR}/tdeio RENAME kmdcodec.h ) install( FILES eventsrc DESTINATION ${DATA_INSTALL_DIR}/knotify ) @@ -121,7 +121,7 @@ set( target tdecore ) set( ${target}_SRCS libintl.cpp kapplication.cpp kdebug.cpp netwm.cpp - kconfigbase.cpp kconfig.cpp ksimpleconfig.cpp kconfigbackend.cpp + tdeconfigbase.cpp tdeconfig.cpp ksimpleconfig.cpp tdeconfigbackend.cpp kmanagerselection.cpp kdesktopfile.cpp kstandarddirs.cpp ksock.cpp kpty.cpp kprocess.cpp kprocctrl.cpp klocale.cpp krfcdate.cpp kiconeffect.cpp kicontheme.cpp kiconloader.cpp @@ -148,7 +148,7 @@ set( ${target}_SRCS kcalendarsystemfactory.cpp kmacroexpander.cpp kidna.cpp ktempdir.cpp kshell.cpp kmountpoint.cpp kcalendarsystemjalali.cpp kprotocolinfo_tdecore.cpp kprotocolinfofactory.cpp kxerrorhandler.cpp - kuser.cpp kconfigskeleton.cpp kconfigdialogmanager.cpp klockfile.cpp + kuser.cpp tdeconfigskeleton.cpp tdeconfigdialogmanager.cpp klockfile.cpp kqiodevicegzip_p.cpp ktimezones.cpp tdehardwaredevices.cpp tdenetworkconnections.cpp ksimpledirwatch.cpp ${TDENM_BACKEND_SOURCES} diff --git a/tdecore/DESIGN.kconfig b/tdecore/DESIGN.kconfig deleted file mode 100644 index c4c68b28e..000000000 --- a/tdecore/DESIGN.kconfig +++ /dev/null @@ -1,224 +0,0 @@ -kconfigdata.h contains definitions of the data formats used by kconfig. - -Configuration entries are stored as "KEntry". They are indexed with "KEntryKey". -The primary store is a "KEntryMap" which is defined as a QMap from "KEntryKey" -to "KEntry" - -KEntry's are stored in order in the KEntryMap. The most significant sort -criteria is mGroup. This means that all entries who belong in the same group, -are grouped in the QMap as well. - -The start of a group is indicated with a KEntryKey with an empty mKey and a -dummy KEntry. This allows us to search for the start of the group and then to -iterate until we end up in another group. That way we will find all entries -of a certain group. - -Entries that are localised with the _current_ locale are stored with bLocal -set to true. Entries that are localised with another locale are either not -stored at all (default), or with the localization as part of the key (when -reading a file in order to merge it). -[WABA: Does it make sense to keep both localized and non-localised around? -Can't we just let the localised version override the non-localised version?] - -Currently the localization bit is the least significant sort criteria, that -means that the localised version always follows the non-localised version -immediately. - - -Entries that are being read from a location other than the location to -which is written back are marked as "default" and will be added both as -normal entry as well as an entry with the key marked as default. - -When entries are written to disk, it is checked whether the entry to write -is equal to the default, if so the entry will not be written. The default -entry always follows directly after the normal entry, due to the sorting. -(After that the localised version follows) - -When entries are written to disk, it is checked whether the entry to write -is equal to the default, if so the entry will not be written. - - -Open question: -Should unmodified entries that are written back be compared with the default -too? This seems to be mostly a transition issue. - - -Extra functions: - -bool entryIsImmutable(key); // Can entry be modified? -bool hasDefault(key); // Is there a system wide default set for the entry? -void revertToDefault(key); // Restore to default -void deleteEntry(key); // Remove entry - -Note that there is a subtle difference between revertToDefault() and deleteEntry(). -revertToDefault() will change the entry to the default value set by the system -administrator (Via e.g. $TDEDIR/share/config) or, if no such default was set, -non-existant. -deleteEntry() will make the entry non-existant. - -Entries are marked "immutable" if the key is followed by [$i]. This means -that a user can not override these entries. - -Entries can be marked as deleted if they are followed by [$d]. This -is needed if the system administrator has specified a default value but the -entry was deleted (made 'non-existant'). In that case we can't just leave -the entry out since that would mean we get the default from the system -administrator back the next time we read the file. - - -When an entry is read with readEntry(key, defaultValue), non-existing -entries will return "defaultValue" while hasKey(key) will return "false" -for such entries. - -Currently all entries are stored in memory. When TDEConfig is "sync()'ed" -it reads the file that it is about to overwrite (for the second time), it -then merges in the entries it has in memory and writes the result back to -the file. It does NOT update its map of entries in memory with the entries -(re)read from disk. It only updates the entries in memory when -"reparseConfiguration()" is called. - - -Open Question: The standard writeEntry() function returns the original value, -is this needed? Nobody seems to use it. - -Open Question: The bPersistent flag doesn't seem to be used... could it be removed? - -Open Question: Is the bNLS flag needed? Localised entries seem to be mostly -useful for default files, are they ever created by the user itself? - -Open Question: Would it be worthwhile to lock a user option that is equal to the -default so that it doesn't change when the default changes? - - -KDE3.0 Changes -============== - -*) writeEntry now returns void instead of QString. -*) deleteEntry functions added - - ------------------------------------------------------------------------------- - -TDEConfig XT -========== - -My buzzword picker offered TDEConfig XT ("eXtended Technology") and TDEConfig NG -("Next Generation"). Since the planned changes are ment to be evolutionary -rather than revolutionary, TDEConfig NG was dropped. - -Goals -===== - -* Have the default value for config entries defined in 1 place. Currently it is -not uncommon to have them defined in three places: - 1) In the application that reads the setting in order to use it - 2) In the settings dialog when reading the setting - 3) In the settings dialog when selecting "Use defaults". - -* Provide type-information about config entries to facilate "KConfEdit" like -tools. Ideally type-information also includes range-information; this is even -mandatory if enums become an explicit type. - -* Facilitate the documentation of config entries. - - -Instead of relying on the defaults that are hard-coded in the application, -rely on default configuration files being installed in $TDEDIR. The technical -changes required for this are very minimal, it is mostly a change in policy. - -Type information can be provide by preceding every entry with a formalized -comment. - -Work to be done: -* TDEConfig needs to be extended to provide access to the default values provided -by the default config files. TDEConfig already stores this information internally. -(DONE) -* A formal comment structure needs to be designed that can convey type-information. -Preferably in such a way that it is easily parsable by both machine and user. -* TDEConfig needs to be extended, or another class created, that is able to parse -the formalized comments. -* A tool needs to be developed that can assist developers with the generation -and verification of default configuration files including type-information. - -Drawbacks: -* We rely on default configuration files being properly installed. -* The user can break applications by making improper modifications to these -files. -* It is not possible to store defaults settings in a config file that are -of a dynamic nature. Examples are settings derived from other settings, -e.g. a color setting could be derived from the current color theme, or -e.g. the default high score user name which is determined by the user -currently logged in. - - -Some random ideas: -* The format of the entries would be something like this: - -[Mail Settings] -#!Type=string -#!Description=SMTP server to use for sending mail -#!Description[nl]=SMTP server voor het versturen van mail -Host=wantelbos.zogje.fr - -- the type could be subclassed more, e.g. strings can be "email", "hostname", - "url", etc. - -- having translations in these files is very arguable. external po's would be - better. - - - -Class overview - - TDEConfigBase - | - v - TDEConfigBackend <-----> TDEConfig <------> TDEConfigSkeleton /--< myapp.kcfg - | | | / - v v |*---------------< -TDEConfigINIBackend KSimpleConfig |kconfig_compiler \ - | \--< myconfig.kcfg-codegen - v - MyConfig <-----TDEConfigDialogManager----> MyConfigWidget *---< myconfigwidget.ui - uic - -TDEConfigBase: defines API for generic config class - -TDEConfig: functional generic config class that supports merging of cascaded - configuration files - -KSimpleConfig: functional generic config class without support for cascading - configuration files. - -TDEConfigBackend: defines API for config backend, t.i. the actual handling - of the storage method and storage format. - -TDEConfigINIBackend: the standard (and only one so far) class that implements - the config backend using the file-based .INI format - for configuration files - -TDEConfigSkeleton: base class for deriving classes that store application - specific options providing type-safety and single-point - defaults. - -MyConfig: An application specific class that offers configuration options - to the applications via variables or accessor functions and that - handles type-safety and defaults. MyConfig is just an example - name, the application developer choses the actual name. - -myapp.kcfg: File describing the configuration options used by a specific - application. myapp.kcfg is just an example name, the application - developer choses the actual name. - -myconfig.kcfg-codegen: Implementation specific code generation instructions - for the MyConfig class. myconfig.kcfg-codegen is - just an example name, the application developer - choses the actual name. - -TDEConfigDialogManager: Class that links widgets in a dialog up with their - corresponding confguration options in a configuration - object derived from TDEConfigSkeleton. - -MyConfigWidget: Dialog generated from a .ui description file. Widget names - in the dialog that start with "kcfg_" refer to configuration - options. diff --git a/tdecore/DESIGN.tdeconfig b/tdecore/DESIGN.tdeconfig new file mode 100644 index 000000000..a1fb48dbd --- /dev/null +++ b/tdecore/DESIGN.tdeconfig @@ -0,0 +1,224 @@ +tdeconfigdata.h contains definitions of the data formats used by tdeconfig. + +Configuration entries are stored as "KEntry". They are indexed with "KEntryKey". +The primary store is a "KEntryMap" which is defined as a QMap from "KEntryKey" +to "KEntry" + +KEntry's are stored in order in the KEntryMap. The most significant sort +criteria is mGroup. This means that all entries who belong in the same group, +are grouped in the QMap as well. + +The start of a group is indicated with a KEntryKey with an empty mKey and a +dummy KEntry. This allows us to search for the start of the group and then to +iterate until we end up in another group. That way we will find all entries +of a certain group. + +Entries that are localised with the _current_ locale are stored with bLocal +set to true. Entries that are localised with another locale are either not +stored at all (default), or with the localization as part of the key (when +reading a file in order to merge it). +[WABA: Does it make sense to keep both localized and non-localised around? +Can't we just let the localised version override the non-localised version?] + +Currently the localization bit is the least significant sort criteria, that +means that the localised version always follows the non-localised version +immediately. + + +Entries that are being read from a location other than the location to +which is written back are marked as "default" and will be added both as +normal entry as well as an entry with the key marked as default. + +When entries are written to disk, it is checked whether the entry to write +is equal to the default, if so the entry will not be written. The default +entry always follows directly after the normal entry, due to the sorting. +(After that the localised version follows) + +When entries are written to disk, it is checked whether the entry to write +is equal to the default, if so the entry will not be written. + + +Open question: +Should unmodified entries that are written back be compared with the default +too? This seems to be mostly a transition issue. + + +Extra functions: + +bool entryIsImmutable(key); // Can entry be modified? +bool hasDefault(key); // Is there a system wide default set for the entry? +void revertToDefault(key); // Restore to default +void deleteEntry(key); // Remove entry + +Note that there is a subtle difference between revertToDefault() and deleteEntry(). +revertToDefault() will change the entry to the default value set by the system +administrator (Via e.g. $TDEDIR/share/config) or, if no such default was set, +non-existant. +deleteEntry() will make the entry non-existant. + +Entries are marked "immutable" if the key is followed by [$i]. This means +that a user can not override these entries. + +Entries can be marked as deleted if they are followed by [$d]. This +is needed if the system administrator has specified a default value but the +entry was deleted (made 'non-existant'). In that case we can't just leave +the entry out since that would mean we get the default from the system +administrator back the next time we read the file. + + +When an entry is read with readEntry(key, defaultValue), non-existing +entries will return "defaultValue" while hasKey(key) will return "false" +for such entries. + +Currently all entries are stored in memory. When TDEConfig is "sync()'ed" +it reads the file that it is about to overwrite (for the second time), it +then merges in the entries it has in memory and writes the result back to +the file. It does NOT update its map of entries in memory with the entries +(re)read from disk. It only updates the entries in memory when +"reparseConfiguration()" is called. + + +Open Question: The standard writeEntry() function returns the original value, +is this needed? Nobody seems to use it. + +Open Question: The bPersistent flag doesn't seem to be used... could it be removed? + +Open Question: Is the bNLS flag needed? Localised entries seem to be mostly +useful for default files, are they ever created by the user itself? + +Open Question: Would it be worthwhile to lock a user option that is equal to the +default so that it doesn't change when the default changes? + + +KDE3.0 Changes +============== + +*) writeEntry now returns void instead of QString. +*) deleteEntry functions added + + +------------------------------------------------------------------------------ + +TDEConfig XT +========== + +My buzzword picker offered TDEConfig XT ("eXtended Technology") and TDEConfig NG +("Next Generation"). Since the planned changes are ment to be evolutionary +rather than revolutionary, TDEConfig NG was dropped. + +Goals +===== + +* Have the default value for config entries defined in 1 place. Currently it is +not uncommon to have them defined in three places: + 1) In the application that reads the setting in order to use it + 2) In the settings dialog when reading the setting + 3) In the settings dialog when selecting "Use defaults". + +* Provide type-information about config entries to facilate "KConfEdit" like +tools. Ideally type-information also includes range-information; this is even +mandatory if enums become an explicit type. + +* Facilitate the documentation of config entries. + + +Instead of relying on the defaults that are hard-coded in the application, +rely on default configuration files being installed in $TDEDIR. The technical +changes required for this are very minimal, it is mostly a change in policy. + +Type information can be provide by preceding every entry with a formalized +comment. + +Work to be done: +* TDEConfig needs to be extended to provide access to the default values provided +by the default config files. TDEConfig already stores this information internally. +(DONE) +* A formal comment structure needs to be designed that can convey type-information. +Preferably in such a way that it is easily parsable by both machine and user. +* TDEConfig needs to be extended, or another class created, that is able to parse +the formalized comments. +* A tool needs to be developed that can assist developers with the generation +and verification of default configuration files including type-information. + +Drawbacks: +* We rely on default configuration files being properly installed. +* The user can break applications by making improper modifications to these +files. +* It is not possible to store defaults settings in a config file that are +of a dynamic nature. Examples are settings derived from other settings, +e.g. a color setting could be derived from the current color theme, or +e.g. the default high score user name which is determined by the user +currently logged in. + + +Some random ideas: +* The format of the entries would be something like this: + +[Mail Settings] +#!Type=string +#!Description=SMTP server to use for sending mail +#!Description[nl]=SMTP server voor het versturen van mail +Host=wantelbos.zogje.fr + +- the type could be subclassed more, e.g. strings can be "email", "hostname", + "url", etc. + +- having translations in these files is very arguable. external po's would be + better. + + + +Class overview + + TDEConfigBase + | + v + TDEConfigBackend <-----> TDEConfig <------> TDEConfigSkeleton /--< myapp.kcfg + | | | / + v v |*---------------< +TDEConfigINIBackend KSimpleConfig |tdeconfig_compiler \ + | \--< myconfig.kcfg-codegen + v + MyConfig <-----TDEConfigDialogManager----> MyConfigWidget *---< myconfigwidget.ui + uic + +TDEConfigBase: defines API for generic config class + +TDEConfig: functional generic config class that supports merging of cascaded + configuration files + +KSimpleConfig: functional generic config class without support for cascading + configuration files. + +TDEConfigBackend: defines API for config backend, t.i. the actual handling + of the storage method and storage format. + +TDEConfigINIBackend: the standard (and only one so far) class that implements + the config backend using the file-based .INI format + for configuration files + +TDEConfigSkeleton: base class for deriving classes that store application + specific options providing type-safety and single-point + defaults. + +MyConfig: An application specific class that offers configuration options + to the applications via variables or accessor functions and that + handles type-safety and defaults. MyConfig is just an example + name, the application developer choses the actual name. + +myapp.kcfg: File describing the configuration options used by a specific + application. myapp.kcfg is just an example name, the application + developer choses the actual name. + +myconfig.kcfg-codegen: Implementation specific code generation instructions + for the MyConfig class. myconfig.kcfg-codegen is + just an example name, the application developer + choses the actual name. + +TDEConfigDialogManager: Class that links widgets in a dialog up with their + corresponding confguration options in a configuration + object derived from TDEConfigSkeleton. + +MyConfigWidget: Dialog generated from a .ui description file. Widget names + in the dialog that start with "kcfg_" refer to configuration + options. diff --git a/tdecore/MAINTAINERS b/tdecore/MAINTAINERS index 995ab753a..6295c102d 100644 --- a/tdecore/MAINTAINERS +++ b/tdecore/MAINTAINERS @@ -20,9 +20,9 @@ kckey.cpp kcmdlineargs.cpp Waldo Bastian kcompletion.cpp Carsten Pfeiffer kcompletionbase.cpp -kconfig.cpp Waldo Bastian -kconfigbackend.cpp Waldo Bastian -kconfigbase.cpp Waldo Bastian +tdeconfig.cpp Waldo Bastian +tdeconfigbackend.cpp Waldo Bastian +tdeconfigbase.cpp Waldo Bastian kcrash.cpp Waldo Bastian kdcoppropertyproxy.cpp kdebug.cpp Stephan Kulow @@ -94,8 +94,8 @@ kcalendarsystemhijri.cpp kcalendarsystemjalali.cpp Arash Bijanzadeh and FarsiKDE Project (copyright) kcheckaccelerators.cpp Matthias Kalle Dalheimer (kalle@kde.org) (copyright) kclipboard.cpp Carsten Pfeiffer (copyright) -kconfigdialogmanager.cpp -kconfigskeleton.cpp +tdeconfigdialogmanager.cpp +tdeconfigskeleton.cpp kdebugdcopiface.cpp Andreas Beckermann (b_mann@gmx.de) (copyright) tdeversion.cpp kglobalaccel_win.cpp Ellis Whitehead (copyright) diff --git a/tdecore/Makefile.am b/tdecore/Makefile.am index 75037eccf..2204ab749 100644 --- a/tdecore/Makefile.am +++ b/tdecore/Makefile.am @@ -27,7 +27,7 @@ SVGICONS=svgicons SVGICON_LIB=svgicons/libkdesvgicons.la endif -SUBDIRS = malloc network $(SVGICONS) . kconfig_compiler tests +SUBDIRS = malloc network $(SVGICONS) . tdeconfig_compiler tests # For the future: examine if condensing the tons of *_LDFLAGS variables # into $(all_libraries) isn't better @@ -36,10 +36,10 @@ AM_LDFLAGS = $(LDFLAGS_AS_NEEDED) $(LDFLAGS_NEW_DTAGS) lib_LTLIBRARIES = libtdefakes.la libtdecore.la lib_LIBRARIES = libtdefakes_nonpic.a libtdefakes_pic.a -include_HEADERS = kconfig.h kconfigskeleton.h \ - kconfigdata.h ksimpleconfig.h kconfigdialogmanager.h \ - kconfigbase.h kdesktopfile.h kurl.h ksock.h kaboutdata.h \ - kcmdlineargs.h kconfigbackend.h kapp.h kapplication.h kuniqueapp.h \ +include_HEADERS = tdeconfig.h tdeconfigskeleton.h \ + tdeconfigdata.h ksimpleconfig.h tdeconfigdialogmanager.h \ + tdeconfigbase.h kdesktopfile.h kurl.h ksock.h kaboutdata.h \ + kcmdlineargs.h tdeconfigbackend.h kapp.h kapplication.h kuniqueapp.h \ kuniqueapplication.h kcharsets.h tdeversion.h kpty.h kprocess.h \ kprocctrl.h klocale.h kicontheme.h kiconloader.h kdebug.h \ twinmodule.h twin.h krootprop.h kshortcut.h kkeynative.h kaccel.h \ @@ -90,8 +90,8 @@ noinst_HEADERS = kaccelaction.h kaccelbase.h kaccelprivate.h kckey.h \ kprotocolinfofactory.h kqiodevicegzip_p.h kiconloader_p.h libtdecore_la_SOURCES = libintl.cpp kapplication.cpp \ - kdebug.cpp netwm.cpp kconfigbase.cpp kconfig.cpp ksimpleconfig.cpp \ - kconfigbackend.cpp kmanagerselection.cpp kdesktopfile.cpp \ + kdebug.cpp netwm.cpp tdeconfigbase.cpp tdeconfig.cpp ksimpleconfig.cpp \ + tdeconfigbackend.cpp kmanagerselection.cpp kdesktopfile.cpp \ kstandarddirs.cpp ksock.cpp kpty.cpp kprocess.cpp kprocctrl.cpp \ klocale.cpp krfcdate.cpp kiconeffect.cpp kicontheme.cpp \ kiconloader.cpp twin.cpp twinmodule.cpp krootprop.cpp kcharsets.cpp \ @@ -118,7 +118,7 @@ libtdecore_la_SOURCES = libintl.cpp kapplication.cpp \ kcalendarsystemfactory.cpp kmacroexpander.cpp kidna.cpp \ ktempdir.cpp kshell.cpp kmountpoint.cpp kcalendarsystemjalali.cpp \ kprotocolinfo_tdecore.cpp kprotocolinfofactory.cpp kxerrorhandler.cpp \ - kuser.cpp kconfigskeleton.cpp kconfigdialogmanager.cpp klockfile.cpp \ + kuser.cpp tdeconfigskeleton.cpp tdeconfigdialogmanager.cpp klockfile.cpp \ kqiodevicegzip_p.cpp ktimezones.cpp libtdecore_la_LDFLAGS = $(QT_LDFLAGS) $(KDE_RPATH) $(KDE_MT_LDFLAGS) $(X_LDFLAGS) $(USER_LDFLAGS) -version-info 6:0:2 -no-undefined @@ -143,16 +143,16 @@ kckey_h : $(srcdir)/generate_keys.sh $(QNAMESPACE_H) install-data-local: $(mkinstalldirs) $(DESTDIR)$(kde_locale) $(INSTALL_DATA) $(srcdir)/all_languages.desktop $(DESTDIR)$(kde_locale)/all_languages - $(mkinstalldirs) $(DESTDIR)$(includedir)/kio + $(mkinstalldirs) $(DESTDIR)$(includedir)/tdeio $(mkinstalldirs) $(DESTDIR)$(kde_datadir)/knotify $(INSTALL_DATA) $(srcdir)/eventsrc $(DESTDIR)$(kde_datadir)/knotify/eventsrc - $(INSTALL_DATA) $(srcdir)/kmdcodec_compat.h $(DESTDIR)$(includedir)/kio/kmdcodec.h + $(INSTALL_DATA) $(srcdir)/kmdcodec_compat.h $(DESTDIR)$(includedir)/tdeio/kmdcodec.h rm -f "$(DESTDIR)$(kde_confdir)/colors/40 Colors" rm -f $(DESTDIR)$(kde_confdir)/colors/Web rm -f $(DESTDIR)$(kde_confdir)/colors/Royal uninstall-local: - -rm -f $(DESTDIR)$(includedir)/kio/kmdcodec.h + -rm -f $(DESTDIR)$(includedir)/tdeio/kmdcodec.h # If you add a color palette file here, please change tdelibs/tdeui/kcolordialog.cpp too to allow to translate the name colors_DATA = 40.colors Web.colors Royal.colors Rainbow.colors diff --git a/tdecore/README.kiosk b/tdecore/README.kiosk index 657a6a72b..b0d6cddfb 100644 --- a/tdecore/README.kiosk +++ b/tdecore/README.kiosk @@ -616,7 +616,7 @@ tde-display.desktop tde-proxy.desktop tde-screensaver.desktop -See also kcmshell --list for a list of all the base names. +See also tdecmshell --list for a list of all the base names. Expansion of environment variables in KDE config files. ======================================================= diff --git a/tdecore/README.kstartupinfo b/tdecore/README.kstartupinfo index 051b1fae6..995b9883a 100644 --- a/tdecore/README.kstartupinfo +++ b/tdecore/README.kstartupinfo @@ -173,7 +173,7 @@ matter ). The ASN identification string must be a unique string for every ASN. In KStartupInfo class, it's created as 'hostname;tm.sec;tm.usec;pid', tm being the current time. If the identification string is set to "0", -it means no ASN should be done ( e.g. for things like kio_uiserver, +it means no ASN should be done ( e.g. for things like tdeio_uiserver, which shouldn't get ASN ). Empty identification string means the same like "0", except for the call to KStartupInfoId::initId(), where it means to create a new one. diff --git a/tdecore/kaccelaction.cpp b/tdecore/kaccelaction.cpp index e8696cc26..34448fe90 100644 --- a/tdecore/kaccelaction.cpp +++ b/tdecore/kaccelaction.cpp @@ -25,7 +25,7 @@ #include -#include +#include #include "kckey.h" #include #include diff --git a/tdecore/kaccelbase.cpp b/tdecore/kaccelbase.cpp index 729de1c42..75810b2e3 100644 --- a/tdecore/kaccelbase.cpp +++ b/tdecore/kaccelbase.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include "kckey.h" #include #include diff --git a/tdecore/kappdcopiface.cpp b/tdecore/kappdcopiface.cpp index 768a94fff..9f1148579 100644 --- a/tdecore/kappdcopiface.cpp +++ b/tdecore/kappdcopiface.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include KAppDCOPInterface::KAppDCOPInterface(TDEApplication * theKApp) diff --git a/tdecore/kapplication.cpp b/tdecore/kapplication.cpp index 2950d6170..bd17e972a 100644 --- a/tdecore/kapplication.cpp +++ b/tdecore/kapplication.cpp @@ -68,7 +68,7 @@ #include #include #include -#include +#include #include #include #include @@ -2970,7 +2970,7 @@ void TDEApplication::broadcastKeyCode(unsigned int keyCode) TQCString TDEApplication::launcher() { - return "klauncher"; + return "tdelauncher"; } static int diff --git a/tdecore/kcharsets.cpp b/tdecore/kcharsets.cpp index 4c8a405cb..17617bf9e 100644 --- a/tdecore/kcharsets.cpp +++ b/tdecore/kcharsets.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/tdecore/kcheckaccelerators.cpp b/tdecore/kcheckaccelerators.cpp index 69cd06dee..1051cd362 100644 --- a/tdecore/kcheckaccelerators.cpp +++ b/tdecore/kcheckaccelerators.cpp @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include #include diff --git a/tdecore/kclipboard.cpp b/tdecore/kclipboard.cpp index f7812a713..53865a2c2 100644 --- a/tdecore/kclipboard.cpp +++ b/tdecore/kclipboard.cpp @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include "kclipboard.h" diff --git a/tdecore/kconfig.cpp b/tdecore/kconfig.cpp deleted file mode 100644 index 26459cdde..000000000 --- a/tdecore/kconfig.cpp +++ /dev/null @@ -1,367 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown - Copyright (C) 1997-1999 Matthias Kalle Dalheimer (kalle@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -// $Id$ - -#include - -#ifdef HAVE_SYS_STAT_H -#include -#endif - -#include -#include - -#include - -#include -#include "kconfigbackend.h" - -#include "kconfig.h" -#include "kglobal.h" -#include "kstandarddirs.h" -#include "kstaticdeleter.h" -#include - -TDEConfig::TDEConfig( const TQString& fileName, - bool bReadOnly, bool bUseKderc, const char *resType ) - : TDEConfigBase(), bGroupImmutable(false), bFileImmutable(false), - bForceGlobal(false) -{ - // set the object's read-only status. - setReadOnly(bReadOnly); - - // for right now we will hardcode that we are using the INI - // back end driver. In the future this should be converted over to - // a object factory of some sorts. - TDEConfigINIBackEnd *aBackEnd = new TDEConfigINIBackEnd(this, - fileName, - resType, - bUseKderc); - - // set the object's back end pointer to this new backend - backEnd = aBackEnd; - - // read initial information off disk - reparseConfiguration(); - - // we let KStandardDirs add custom user config files. It will do - // this only once. So only the first call ever to this constructor - // will anything else than return here We have to reparse here as - // configuration files may appear after customized directories have - // been added. and the info they contain needs to be inserted into the - // config object. - // Since this makes only sense for config directories, addCustomized - // returns true only if new config directories appeared. - if (TDEGlobal::dirs()->addCustomized(this)) - reparseConfiguration(); -} - -TDEConfig::TDEConfig(TDEConfigBackEnd *aBackEnd, bool bReadOnly) - : bGroupImmutable(false), bFileImmutable(false), - bForceGlobal(false) -{ - setReadOnly(bReadOnly); - backEnd = aBackEnd; - reparseConfiguration(); -} - -TDEConfig::~TDEConfig() -{ - sync(); - - delete backEnd; -} - -void TDEConfig::rollback(bool bDeep) -{ - TDEConfigBase::rollback(bDeep); - - if (!bDeep) - return; // object's bDeep flag is set in TDEConfigBase method - - // clear any dirty flags that entries might have set - for (KEntryMapIterator aIt = aEntryMap.begin(); - aIt != aEntryMap.end(); ++aIt) - (*aIt).bDirty = false; -} - -TQStringList TDEConfig::groupList() const -{ - TQStringList retList; - - KEntryMapConstIterator aIt = aEntryMap.begin(); - KEntryMapConstIterator aEnd = aEntryMap.end(); - for (; aIt != aEnd; ++aIt) - { - while(aIt.key().mKey.isEmpty()) - { - TQCString group = aIt.key().mGroup; - ++aIt; - while (true) - { - if (aIt == aEnd) - return retList; // done - - if (aIt.key().mKey.isEmpty()) - break; // Group is empty, next group - - if (!aIt.key().bDefault && !(*aIt).bDeleted) - { - if (group != "$Version") // Special case! - retList.append(TQString::fromUtf8(group)); - break; // Group is non-empty, added, next group - } - ++aIt; - } - } - } - - return retList; -} - -TQMap TDEConfig::entryMap(const TQString &pGroup) const -{ - TQCString pGroup_utf = pGroup.utf8(); - KEntryKey groupKey( pGroup_utf, 0 ); - TQMap tmpMap; - - KEntryMapConstIterator aIt = aEntryMap.find(groupKey); - if (aIt == aEntryMap.end()) - return tmpMap; - ++aIt; // advance past special group entry marker - for (; aIt.key().mGroup == pGroup_utf && aIt != aEntryMap.end(); ++aIt) - { - // Leave the default values out && leave deleted entries out - if (!aIt.key().bDefault && !(*aIt).bDeleted) - tmpMap.insert(TQString::fromUtf8(aIt.key().mKey), TQString::fromUtf8((*aIt).mValue.data(), (*aIt).mValue.length())); - } - - return tmpMap; -} - -void TDEConfig::reparseConfiguration() -{ - // Don't lose pending changes - if (!isReadOnly() && backEnd && bDirty) - backEnd->sync(); - - aEntryMap.clear(); - - // add the "default group" marker to the map - KEntryKey groupKey("", 0); - aEntryMap.insert(groupKey, KEntry()); - - bFileImmutable = false; - parseConfigFiles(); - bFileImmutable = bReadOnly; -} - -KEntryMap TDEConfig::internalEntryMap(const TQString &pGroup) const -{ - TQCString pGroup_utf = pGroup.utf8(); - KEntry aEntry; - KEntryMapConstIterator aIt; - KEntryKey aKey(pGroup_utf, 0); - KEntryMap tmpEntryMap; - - aIt = aEntryMap.find(aKey); - if (aIt == aEntryMap.end()) { - // the special group key is not in the map, - // so it must be an invalid group. Return - // an empty map. - return tmpEntryMap; - } - // we now have a pointer to the nodes we want to copy. - for (; aIt.key().mGroup == pGroup_utf && aIt != aEntryMap.end(); ++aIt) - { - tmpEntryMap.insert(aIt.key(), *aIt); - } - - return tmpEntryMap; -} - -void TDEConfig::putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup) -{ - if (bFileImmutable && !_key.bDefault) - return; - - // check to see if the special group key is present, - // and if not, put it in. - if (_checkGroup) - { - KEntryKey groupKey( _key.mGroup, 0); - KEntry &entry = aEntryMap[groupKey]; - bGroupImmutable = entry.bImmutable; - } - if (bGroupImmutable && !_key.bDefault) - return; - - // now either add or replace the data - KEntry &entry = aEntryMap[_key]; - bool immutable = entry.bImmutable; - if (immutable && !_key.bDefault) - return; - - entry = _data; - entry.bImmutable |= immutable; - entry.bGlobal |= bForceGlobal; // force to kdeglobals - - if (_key.bDefault) - { - // We have added the data as default value, - // add it as normal value as well. - KEntryKey key(_key); - key.bDefault = false; - aEntryMap[key] = _data; - } -} - -KEntry TDEConfig::lookupData(const KEntryKey &_key) const -{ - KEntryMapConstIterator aIt = aEntryMap.find(_key); - if (aIt != aEntryMap.end()) - { - const KEntry &entry = *aIt; - if (entry.bDeleted) - return KEntry(); - else - return entry; - } - else { - return KEntry(); - } -} - -bool TDEConfig::internalHasGroup(const TQCString &group) const -{ - KEntryKey groupKey( group, 0); - - KEntryMapConstIterator aIt = aEntryMap.find(groupKey); - KEntryMapConstIterator aEnd = aEntryMap.end(); - - if (aIt == aEnd) - return false; - ++aIt; - for(; (aIt != aEnd); ++aIt) - { - if (aIt.key().mKey.isEmpty()) - break; - - if (!aIt.key().bDefault && !(*aIt).bDeleted) - return true; - } - return false; -} - -void TDEConfig::setFileWriteMode(int mode) -{ - backEnd->setFileWriteMode(mode); -} - -KLockFile::Ptr TDEConfig::lockFile(bool bGlobal) -{ - TDEConfigINIBackEnd *aBackEnd = dynamic_cast(backEnd); - if (!aBackEnd) return 0; - return aBackEnd->lockFile(bGlobal); -} - -void TDEConfig::checkUpdate(const TQString &id, const TQString &updateFile) -{ - TQString oldGroup = group(); - setGroup("$Version"); - TQString cfg_id = updateFile+":"+id; - TQStringList ids = readListEntry("update_info"); - if (!ids.contains(cfg_id)) - { - TQStringList args; - args << "--check" << updateFile; - TDEApplication::tdeinitExecWait("kconf_update", args); - reparseConfiguration(); - } - setGroup(oldGroup); -} - -TDEConfig* TDEConfig::copyTo(const TQString &file, TDEConfig *config) const -{ - if (!config) - config = new TDEConfig(TQString::null, false, false); - config->backEnd->changeFileName(file, "config", false); - config->setReadOnly(false); - config->bFileImmutable = false; - config->backEnd->mConfigState = ReadWrite; - - TQStringList groups = groupList(); - for(TQStringList::ConstIterator it = groups.begin(); - it != groups.end(); ++it) - { - TQMap map = entryMap(*it); - config->setGroup(*it); - for (TQMap::Iterator it2 = map.begin(); - it2 != map.end(); ++it2) - { - config->writeEntry(it2.key(), it2.data()); - } - - } - return config; -} - -void TDEConfig::virtual_hook( int id, void* data ) -{ TDEConfigBase::virtual_hook( id, data ); } - -static KStaticDeleter< TQValueList > sd; -TQValueList *KSharedConfig::s_list = 0; - -KSharedConfig::Ptr KSharedConfig::openConfig(const TQString& fileName, bool readOnly, bool useKDEGlobals ) -{ - if (s_list) - { - for(TQValueList::ConstIterator it = s_list->begin(); - it != s_list->end(); ++it) - { - if ((*it)->backEnd->fileName() == fileName && - (*it)->bReadOnly == readOnly && - (*it)->backEnd->useKDEGlobals == useKDEGlobals ) - return (*it); - } - } - return new KSharedConfig(fileName, readOnly, useKDEGlobals); -} - -KSharedConfig::KSharedConfig( const TQString& fileName, bool readonly, bool usekdeglobals) - : TDEConfig(fileName, readonly, usekdeglobals) -{ - if (!s_list) - { - sd.setObject(s_list, new TQValueList); - } - - s_list->append(this); -} - -KSharedConfig::~KSharedConfig() -{ - if ( s_list ) - s_list->remove(this); -} - -#include "kconfig.moc" diff --git a/tdecore/kconfig.h b/tdecore/kconfig.h deleted file mode 100644 index c5084c109..000000000 --- a/tdecore/kconfig.h +++ /dev/null @@ -1,296 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown - Copyright (C) 1997 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef _KCONFIG_H -#define _KCONFIG_H - -class TQTimer; - -#include - -#include "kconfigbase.h" -#include "klockfile.h" - -class TDEConfigPrivate; - -/** -* Access KDE Configuration entries. -* -* This class implements KDE's default configuration system. -* -* @author Kalle Dalheimer , Preston Brown -* @see TDEGlobal::config(), TDEConfigBase, KSimpleConfig -* @short KDE Configuration Management class -*/ -class TDECORE_EXPORT TDEConfig : public TDEConfigBase -{ - Q_OBJECT - -public: - - /** - * Constructs a TDEConfig object. - * - * @param fileName A file to parse in addition to the - * system-wide file(s). If it is not provided, only global - * KDE configuration data will be read (depending on the value of - * @p bUseKDEGlobals). - * @param bReadOnly Set the config object's read-only status. Note that the - * object will automatically become read-only if either the user does not have - * write permission to @p fileName or if no file was specified. - * @param bUseKDEGlobals Toggle reading the global KDE configuration file. - * @param resType the place to look in (config, data, etc) See KStandardDirs. - */ - TDEConfig( const TQString& fileName = TQString::null, - bool bReadOnly = false, bool bUseKDEGlobals = true, const char *resType="config"); - - TDEConfig(TDEConfigBackEnd *backEnd, bool bReadOnly = false); - - /** - * Destructs the TDEConfig object. - * - * Writes back any dirty configuration entries, and destroys - * dynamically created objects. - */ - virtual ~TDEConfig(); - - /** - * Clears all entries out of the @p dirtyEntryMap, so the - * values will not be written to disk on a later call to - * sync(). - * - * @param bDeep If true, the dirty map is actually emptied. - * otherwise, the config object's global dirty flag is set to - * false, but the dirty entries remain in the dirty entry - * map. - * - * @see TDEConfigBase::rollback - */ - virtual void rollback(bool bDeep = true); - - - /** - * Returns a list of groups that are known. - * @return a list of of groups - */ - virtual TQStringList groupList() const; - - /** - * Returns a map (tree) of entries for all entries in a particular - * group. - * - * Only the actual entry string is returned, none of the - * other internal data should be included. - * - * @param pGroup A group to get keys from. - * @return A map of entries in the group specified, indexed by key. - * The returned map may be empty if the group is not found. - */ - virtual TQMap entryMap(const TQString &pGroup) const; - - /** - * Clears all internal data structures and then reread - * configuration information from disk. - */ - virtual void reparseConfiguration(); - - /** - * Set the file mode for newly created files. - * - * @param mode the mode for new files as described in chmod(2) - * @see man:chmod(2) for a description of @p mode - */ - void setFileWriteMode(int mode); - - /** - * Forces all following write-operations being performed on kdeglobals, - * independent of the bGlobal flag in writeEntry(). - * @param force true to force writing in kdeglobals - * @see forceGlobal - */ - void setForceGlobal( bool force ) { bForceGlobal = force; } - - /** - * Returns true if all entries are being written into kdeglobals. - * @return true if all entries are being written into kdeglobals - * @see setForceGlobal - */ - bool forceGlobal() const { return bForceGlobal; } - - /** - * Checks whether the config file contains the update @p id - * as contained in @p updateFile. If not, it runs kconf_update - * to update the config file. - * - * If you install config update files with critical fixes - * you may wish to use this method to verify that a critical - * update has indeed been performed to catch the case where - * a user restores an old config file from backup that has - * not been updated yet. - * @param id the update to check - * @param updateFile the file containing the update - * @since 3.1 - */ - void checkUpdate(const TQString &id, const TQString &updateFile); - - /** - * Copies all entries from this config object to a new config - * object that will save itself to @p file. - * - * Actual saving to @p file happens when the returned object is - * destructed or when sync() is called upon it. - * - * @param file the new config object will save itself to. - * @param config optional config object to reuse - * @since 3.2 - */ - TDEConfig* copyTo(const TQString &file, TDEConfig *config=0) const; - - /** - * Returns a lock file object for the configuration file or 0 if - * the backend does not support locking. - * @param bGlobal if true, return the lock file for the global config file - * - * NOTE: TDEConfig::sync() requires a lock on both the normal and global - * config file. When calling TDEConfig::sync() while having a lock on the - * global config file, the normal config file MUST be locked AS WELL and the - * normal config file MUST be locked BEFORE the global config file! - * Otherwise there is a risk of deadlock. - * @since 3.3 - */ - KLockFile::Ptr lockFile( bool bGlobal=false ); - -protected: - - /** - * Returns true if the specified group is known. - * - * @param group The group to search for. - * @returns true if the group exists. - */ - virtual bool internalHasGroup(const TQCString &group) const; - - /** - * @internal - * Returns a map (tree) of the entries in the specified group. - * - * Do not use this function, the implementation / return type are - * subject to change. - * - * @param pGroup the group to provide a KEntryMap for. - * @return The map of the entries in the group. - */ - virtual KEntryMap internalEntryMap(const TQString &pGroup) const; - - /** - * @internal - * Returns a copy of the internal map used to hold all entries. - * - * Do not use this function, the implementation / return type are - * subject to change. - * - * @return The map of the entries in the group. - */ - virtual KEntryMap internalEntryMap() const { return aEntryMap; } - - /** - * Inserts a (key, value) pair into the internal storage mechanism of - * the configuration object. - * - * @param _key The key to insert. It contains information both on - * the group of the key and the key itself. If the key already - * exists, the old value will be replaced. - * @param _data the KEntry that is to be stored. - * @param _checkGroup When false, assume that the group already exists. - */ - virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup=true); - - /** - * Looks up an entry in the config object's internal structure. - * - * @param _key The key to look up It contains information both on - * the group of the key and the entry's key itself. - * @return the KEntry value (data) found for the key. KEntry.aValue - * will be the null string if nothing was located. - */ - virtual KEntry lookupData(const KEntryKey &_key) const; - - /** - * Contains all key,value entries, as well as some "special" - * keys which indicate the start of a group of entries. - * - * These special keys will have the .key portion of their KEntryKey - * set to TQString::null. - */ - KEntryMap aEntryMap; - -private: - /** - * @internal - * copy-construction and assignment are not allowed - */ - TDEConfig( const TDEConfig& ); - /** - * @internal - * copy-construction and assignment are not allowed - */ - TDEConfig& operator= ( const TDEConfig& rConfig ); - -private: - bool bGroupImmutable : 1; // Current group is immutable. - bool bFileImmutable : 1; // Current file is immutable. - bool bForceGlobal : 1; // Apply everything to kdeglobals. -protected: - virtual void virtual_hook( int id, void* data ); -private: - TDEConfigPrivate *d; -}; - -/** - * TDEConfig variant using shared memory - * - * KSharedConfig provides a reference counted, shared memory variant - * of TDEConfig. - */ -class TDECORE_EXPORT KSharedConfig : public TDEConfig, public KShared -{ - friend class TQValueList; -public: - typedef KSharedPtr Ptr; - -public: - /** - * Returns a ref-counted pointer to a shared read-write config object. - * @param fileName the name of the file to use for the configuration - * @param readOnly set the config object's read-only status - * @param bUseKDEGlobals Toggle reading the global KDE configuration file. - */ - static KSharedConfig::Ptr openConfig(const TQString& fileName, bool readOnly = false, - bool bUseKDEGlobals = true); - -private: - KSharedConfig( const TQString& fileName, bool readOnly, bool useKDEGlobals ); - ~KSharedConfig(); - - static TQValueList *s_list; -}; - -#endif diff --git a/tdecore/kconfig_compiler/CMakeLists.txt b/tdecore/kconfig_compiler/CMakeLists.txt deleted file mode 100644 index 4acc09f51..000000000 --- a/tdecore/kconfig_compiler/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdecore -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### kconfig_compiler ########################## - -tde_add_executable( kconfig_compiler - SOURCES kconfig_compiler.cpp - LINK tdecore-shared - DESTINATION ${BIN_INSTALL_DIR} -) diff --git a/tdecore/kconfig_compiler/Makefile.am b/tdecore/kconfig_compiler/Makefile.am deleted file mode 100644 index d4f287381..000000000 --- a/tdecore/kconfig_compiler/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -SUBDIRS = example tests - -AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir) $(all_includes) - -bin_PROGRAMS = kconfig_compiler - -kconfig_compiler_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -kconfig_compiler_LDADD = $(LIB_TDECORE) -kconfig_compiler_SOURCES = kconfig_compiler.cpp - -TESTFILES = test1.kcfg test2.kcfg test3.kcfg test4.kcfg test_dpointer.kcfg - -check-local: - for i in $(TESTFILES); \ - do xmllint --noout --schema $(srcdir)/kcfg.xsd $(srcdir)/tests/$$i; \ - perl $(top_srcdir)/tdecore/kconfig_compiler/checkkcfg.pl \ - $(top_srcdir)/tdecore/kconfig_compiler/tests/$$i; done - diff --git a/tdecore/kconfig_compiler/README.dox b/tdecore/kconfig_compiler/README.dox deleted file mode 100644 index 76dbc04c2..000000000 --- a/tdecore/kconfig_compiler/README.dox +++ /dev/null @@ -1,255 +0,0 @@ -/** -\page kconfig_compiler The KDE Configuration Compiler - -kconfig_compiler generates C++ source code from an XML file containing -information about configuration options (.kcfg) and a file that provides -the code generation options (.kcfgc) The generated class is based on -TDEConfigSkeleton and provides an API for the application to access its -configuration data. - -

XML description of the configuration options

- -The structure of the .kcfg file is described by its DTD kcfg.dtd. - -The \ tag contains the name of the configuration file described. -Omitting the name will make the generated class use the default configuration -file ("rc"). - -The \ tags are optional and may contain C++ header files that -are needed to compile the code needed to compute default values. - -The remaining entries in the XML file are grouped by the tag \ -which describes the corresponding group in the configuration file. - -The individual entries must have at least a name or a key. The name is used to -create accessor and modifier functions. It's also used as the key in the config -file. If \ is given, but not \, the name is constructed by removing -all spaces from \. - -An entry must also have a type. The list of allowable types is -specified in the DTD and loosely follows the list of types supported -by the QVariant with exception of the clearly binary types -(e.g. Pixmap, Image...) which are not supported. Besides those basic -type the following special types are supported: - -- Path This is a string that is specially treated as a file-path. - In particular paths in the home directory are prefixed with $HOME in - when being stored in the configuration file. - -- Enum This indicates an enumeration. The possible enum values should - be provided via the \ tag. Enum values are accessed as integers - by the application but stored as string in the configuration file. This - makes it possible to add more values at a later date without breaking - compatibility. - -- IntList This indicates a list of integers. This information is provided - to the application as QValueList. Useful for storing QSplitter - geometries. - -An entry can optionally have a default value which is used as default when -the value isn't specified in any config file. Default values are interpreted -as literal constant values. If a default value needs to be computed -or if it needs to be obtained from a function call, the \ tag -should contain the code="true" attribute. The contents of the \ -tag is then considered to be a C++ expression. Note that in this case you -might have to add an \ tag as described above so that the code -which computes the default value can be compiled. - -Additional code for computing default values can be provided via -the \ tag. The contents of the \ tag is inserted as-is. A -typical use for this is to compute a common default value which can -then be referenced by multiple entries that follow. - -

Code generation options

- -The options for generating the C++ sources are read from the file with the -extension .kcfgc. To generate a class add the corresponding kcfgc file to the -SOURCES line in the Makefile.am. - -The following options are read from the kcfgc file: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
Filestringprogramname.kcfgName of kcfg file containing the options the class is generated for
NameSpacestring-Optional namespace for generated class
ClassNamestring-Name of generated class (required)
InheritsstringTDEConfigSkeletonClass the generated class inherits from. This class must inherit - TDEConfigSkeleton.
Visibilitystring-Inserts visibility directive (for example KDE_EXPORT) between "class" keyword and class - name in header file
SingletonboolfalseGenerated class is a singleton.
CustomAdditionsbool-
MemberVariablesstring: public|protected|privateprivateC++ access modifier used for memeber variables holding the configuration - valuse
IncludeFilescomma separated list of strings-Names of files to be included in the header of the generated class
Mutatorstrue, false or a comma seperated list of options-If true, mutator functions for all configuration options are generated. - If false, no mutator functions are generated. If a list is provided, - mutator functions are generated for the options that are listed.
ItemAccessorsboolfalseGenerate accessor functions for the TDEConfigSkeletonItem objects - corresponding to the configuration options. If SetUserTexts is set, - ItemAccessors also has to be set.
SetUserTextsboolfalseSet the label and whatthis texts of the items from the kcfg file.If - SetUserTexts is set, ItemAccessors also has to be set.
GlobalEnumsboolfalseIf set to true all choices of Enum items will be created in the global - scope of the generated class. If set to false, each Enum item will get an own - namespace for its choices.
- - -

Advanced options

- -There are several possibilities to parameterize entries. - -- Parameterized entries - -An entry can be parameterized using a fixed range parameter specified with -the \ tag. Such parameter can either be an Enum or an int. An Enum -parameter should specify the possible enumeration values with the \ -tag. An int parameter should specify its maximum value. Its minimum value -is always 0. - -A parameterized entry is expanded to a number of entries, one for each -value in the parameter range. The name and key should contain a reference -to the parameter in the form of $(parameter-name). When expanding the entries -the $(parameter-name) part is replaced with the value of the parameter. -In the case of an Enum parameter it is replaced with the name of the -enumuration value. In the case of an int parameter it is replaced with -the numeric value of the parameter. - -Parameterized entries all share the same default value unless different -default values have been specified for specific parameter values. -This can be done with the param= attribute of the \. When a -param attribute is specified the default value only applies to that -particular parameter value. - -Example 1: -\verbatim - - - #ff0000 - #00ff00 - #0000ff - #ffff00 - -\endverbatim - -The above describes 4 color configuration entries with the following defaults: - -\verbatim -color_0=#ff0000 -color_1=#00ff00 -color_2=#0000ff -color_3=#ffff00 -\endverbatim - -The configuration options will be accessible to the application via -a QColor color(int ColorIndex) and a -void setColor(int ColorIndex, const QColor &v) function. - -Example 2: -\verbatim - - - - Explosion - Crash - Missile - - - boom.wav - crash.wav - missile.wav - -\endverbatim - -The above describes 3 string configuration entries with the following defaults: - -sound_Explosion=boom.wav -sound_Crash=crash.wav -sound_Missile=missile.wav - -The configuration options will be accessible to the application via -a QString sound(int SoundEvent) and a -void setSound(int SoundEvent, const QString &v) function. - -- Parameterized groups - -...STILL TODO... - - - - - -If you have questions or comments please contact Cornelius Schumacher - or Waldo Bastian -*/ diff --git a/tdecore/kconfig_compiler/TODO b/tdecore/kconfig_compiler/TODO deleted file mode 100644 index e69de29bb..000000000 diff --git a/tdecore/kconfig_compiler/checkkcfg.pl b/tdecore/kconfig_compiler/checkkcfg.pl deleted file mode 100755 index 2eddbeee6..000000000 --- a/tdecore/kconfig_compiler/checkkcfg.pl +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/perl - -if ( @ARGV != 1 ) { - print STDERR "Missing arg: filename\n"; - exit 1; -} - -$file = $ARGV[0]; - -$file =~ /^(.*)\.[^\.]*$/; -$filebase = $1; - -$file_h = "$filebase.h"; -$file_cpp = "$filebase.cpp"; - -$kcfgc = $file . "c"; - -$cmd = "./kconfig_compiler $file $kcfgc"; - -#print "CMD $cmd\n"; - -if ( system( $cmd ) != 0 ) { - print STDERR "Unable to run kconfig_compiler\n"; - exit 1; -} - -checkfile( $file_h ); -checkfile( $file_cpp ); - -exit 0; - -sub checkfile() -{ - my $file = shift; - - $file =~ /\/([^\/]*)$/; - my $filename = $1; - - print "Checking '$filename':\n"; - - my @ref; - if ( !open( REF, "$file.ref" ) ) { - print STDERR "Unable to open $file.ref\n"; - exit 1; - } - while( ) { - push @ref, $_; - } - close REF; - - if ( !open( READ, $filename ) ) { - print STDERR "Unable to open $filename\n"; - exit 1; - } - - $error = 0; - $i = 0; - $line = 1; - while( ) { - $out = $_; - $ref = @ref[$i++]; - - if ( $out ne $ref ) { - $error++; - print " Line $line: Expected : $ref"; - print " Line $line: Compiler output : $out"; - } - - $line++; - } - - close READ; - - if ( $error > 0 ) { - print "\n FAILED: $error errors found.\n"; - if ( $error > 5 ) { - system( "diff -u $file.ref $filename" ); - } - exit 1; - } else { - print " OK\n"; - } -} diff --git a/tdecore/kconfig_compiler/example/Makefile.am b/tdecore/kconfig_compiler/example/Makefile.am deleted file mode 100644 index 4e7a59fec..000000000 --- a/tdecore/kconfig_compiler/example/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir) $(all_includes) - -check_PROGRAMS = example # autoexample -EXTRA_PROGRAMS = autoexample - -example_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -example_LDADD = $(LIB_TDECORE) -example_SOURCES = example.cpp exampleprefs_base.cpp - -autoexample_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -autoexample_LDADD = $(LIB_TDECORE) $(LIB_TDEUI) -autoexample_SOURCES = exampleprefs_base.cpp general_base.ui myoptions_base.ui \ - autoexample.cpp - -example.o exampleprefs_base.o: exampleprefs_base.h -# avoid running the below command in parallel -exampleprefs_base.cpp: exampleprefs_base.h -exampleprefs_base.cpp exampleprefs_base.h: $(srcdir)/example.kcfg ../kconfig_compiler $(srcdir)/exampleprefs_base.kcfgc - ../kconfig_compiler $(srcdir)/example.kcfg $(srcdir)/exampleprefs_base.kcfgc - -METASOURCES = AUTO - -CLEANFILES = exampleprefs_base.h exampleprefs_base.cpp - -## The example's messages should not go into tdelibs.pot -messages: rc.cpp - true diff --git a/tdecore/kconfig_compiler/example/autoexample.cpp b/tdecore/kconfig_compiler/example/autoexample.cpp deleted file mode 100644 index 53e02f68d..000000000 --- a/tdecore/kconfig_compiler/example/autoexample.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2003 Cornelius Schumacher - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "general_base.h" -#include "myoptions_base.h" - -#include "exampleprefs_base.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -int main( int argc, char **argv ) -{ - TDEAboutData aboutData( "example", I18N_NOOP("autoconfig example"), "0.1" ); - aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); - - TDECmdLineArgs::init( argc, argv, &aboutData ); - - TDEApplication app; - - ExamplePrefsBase configSkeleton( "dummy1", "dummy2" ); - configSkeleton.readConfig(); - - TDEConfigDialog *dialog = new TDEConfigDialog( 0, "settings", &configSkeleton ); - - GeneralBase *general = new GeneralBase( 0 ); - dialog->addPage( general, i18n("General"), "General", "" ); - - MyOptionsBase *myOptions = new MyOptionsBase( 0 ); - dialog->addPage( myOptions, i18n("MyOptions"), "MyOptions", "" ); - - app.setMainWidget( dialog ); - - dialog->show(); - - return app.exec(); -} diff --git a/tdecore/kconfig_compiler/example/example.cpp b/tdecore/kconfig_compiler/example/example.cpp deleted file mode 100644 index cf808c9b2..000000000 --- a/tdecore/kconfig_compiler/example/example.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - This file is part of KDE. - - Copyright (c) 2003 Cornelius Schumacher - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "exampleprefs_base.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -int main( int argc, char **argv ) -{ - TDEAboutData aboutData( "example", I18N_NOOP("cfgc example"), "0.1" ); - aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); - - TDECmdLineArgs::init( argc, argv, &aboutData ); - - TDEApplication app; - - ExamplePrefsBase *prefs = new ExamplePrefsBase("Trans1", "Folder2"); - - prefs->readConfig(); - - prefs->setAnotherOption(17); - - kdWarning() << "Another Option = " << prefs->anotherOption() << endl; - kdWarning() << "Another Option2 = " << prefs->anotherOption2() << endl; - kdWarning() << "MyPaths = " << prefs->myPaths() << endl; - kdWarning() << "MyPaths2 = " << prefs->myPaths2() << endl; -} diff --git a/tdecore/kconfig_compiler/example/example.kcfg b/tdecore/kconfig_compiler/example/example.kcfg deleted file mode 100644 index 076bfb644..000000000 --- a/tdecore/kconfig_compiler/example/example.kcfg +++ /dev/null @@ -1,63 +0,0 @@ - - - qdir.h - - - - - - - - true - - - - 5 - - - - And this is a longer description of this option. Just wondering, how will the translations of those be handled? - - - - - - One - - - - - - Default String - - - - QDir::homeDirPath()+QString::fromLatin1(".hidden_file") - - - - /home,~ - - - - QStringList(QDir::homeDirPath()) - - - - 10 - - - up,down - - - - - 1 - - - diff --git a/tdecore/kconfig_compiler/example/exampleprefs_base.kcfgc b/tdecore/kconfig_compiler/example/exampleprefs_base.kcfgc deleted file mode 100644 index a9ac98dc7..000000000 --- a/tdecore/kconfig_compiler/example/exampleprefs_base.kcfgc +++ /dev/null @@ -1,18 +0,0 @@ -# Code generation options for kconfig_compiler -ClassName=ExamplePrefsBase -# -# Singleton=false -# -# Inherits=TDEConfigSkeleton -# -# IncludeFiles=libtdepim/kpimprefs.h -# -# MemberVariables=public -# -### The following line includes the file exampleprefs_base_addon.h -### It can be used to add extra functions and variables to the -### class. -# CustomAdditions=true -# -### Provide setFooBar(int) style functions -Mutators=true diff --git a/tdecore/kconfig_compiler/example/general_base.ui b/tdecore/kconfig_compiler/example/general_base.ui deleted file mode 100644 index 9b41370c7..000000000 --- a/tdecore/kconfig_compiler/example/general_base.ui +++ /dev/null @@ -1,46 +0,0 @@ - -GeneralBase - - - GeneralBase - - - - 0 - 0 - 600 - 486 - - - - AutoExampleDialog - - - - unnamed - - - - kcfg_OneOption - - - OneOption - - - - - kcfg_AnotherOption2 - - - - - textLabel1 - - - AnotherOption: - - - - - - diff --git a/tdecore/kconfig_compiler/example/myoptions_base.ui b/tdecore/kconfig_compiler/example/myoptions_base.ui deleted file mode 100644 index 3c0c2e6cb..000000000 --- a/tdecore/kconfig_compiler/example/myoptions_base.ui +++ /dev/null @@ -1,35 +0,0 @@ - -MyOptionsBase - - - MyOptionsBase - - - - 0 - 0 - 600 - 486 - - - - - unnamed - - - - textLabel1 - - - MyString: - - - - - kcfg_MyString - - - - - - diff --git a/tdecore/kconfig_compiler/kcfg.xsd b/tdecore/kconfig_compiler/kcfg.xsd deleted file mode 100644 index 9eb18a068..000000000 --- a/tdecore/kconfig_compiler/kcfg.xsd +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - - - Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> - Copyright (c) 2003 Waldo Bastian <bastian@kde.org> - Copyright (c) 2003 Zack Rusin <zack@kde.org> - Copyright (c) 2004 Frans Englich <frans.englich@telia.com> - - Permission to use, copy, modify and distribute this DTD - and its accompanying documentation for any purpose and without fee - is hereby granted in perpetuity, provided that the above copyright - notice and this paragraph appear in all copies. The copyright - holders make no representation about the suitability of the DTD for - any purpose. It is provided "as is" without expressed or implied - warranty. - - - - - - - A Schema for KDE's TDEConfigXT XML format. It is similar to the DTD - found at: - - http://www.kde.org/standards/kcfg/1.0/kcfg.dtd - - Documents valid against the Schema version are backwards compatible - to the DTD. Validating against the Schema instead of the DTD is - recommended, since the former provides better validation. - - A document instance of this Schema should have a declaration - looking like this: - - - - - - - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tdecore/kconfig_compiler/kconfig_compiler.cpp b/tdecore/kconfig_compiler/kconfig_compiler.cpp deleted file mode 100644 index b8839f677..000000000 --- a/tdecore/kconfig_compiler/kconfig_compiler.cpp +++ /dev/null @@ -1,1700 +0,0 @@ -// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*- -/* - This file is part of KDE. - - Copyright (c) 2003 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - Copyright (c) 2003 Zack Rusin - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -static const KCmdLineOptions options[] = -{ - { "d", 0, 0 }, - { "directory ", I18N_NOOP("Directory to generate files in"), "." }, - { "+file.kcfg", I18N_NOOP("Input kcfg XML file"), 0 }, - { "+file.kcfgc", I18N_NOOP("Code generation options file"), 0 }, - KCmdLineLastOption -}; - - -bool globalEnums; -bool itemAccessors; -bool dpointer; -TQStringList allNames; -TQRegExp *validNameRegexp; -TQString This; -TQString Const; - -class CfgEntry -{ - public: - struct Choice - { - TQString name; - TQString label; - TQString whatsThis; - }; - - CfgEntry( const TQString &group, const TQString &type, const TQString &key, - const TQString &name, const TQString &label, - const TQString &whatsThis, const TQString &code, - const TQString &defaultValue, const TQValueList &choices, - bool hidden ) - : mGroup( group ), mType( type ), mKey( key ), mName( name ), - mLabel( label ), mWhatsThis( whatsThis ), mCode( code ), - mDefaultValue( defaultValue ), - mChoices( choices ), mHidden( hidden ) - { - } - - void setGroup( const TQString &group ) { mGroup = group; } - TQString group() const { return mGroup; } - - void setType( const TQString &type ) { mType = type; } - TQString type() const { return mType; } - - void setKey( const TQString &key ) { mKey = key; } - TQString key() const { return mKey; } - - void setName( const TQString &name ) { mName = name; } - TQString name() const { return mName; } - - void setLabel( const TQString &label ) { mLabel = label; } - TQString label() const { return mLabel; } - - void setWhatsThis( const TQString &whatsThis ) { mWhatsThis = whatsThis; } - TQString whatsThis() const { return mWhatsThis; } - - void setDefaultValue( const TQString &d ) { mDefaultValue = d; } - TQString defaultValue() const { return mDefaultValue; } - - void setCode( const TQString &d ) { mCode = d; } - TQString code() const { return mCode; } - - void setMinValue( const TQString &d ) { mMin = d; } - TQString minValue() const { return mMin; } - - void setMaxValue( const TQString &d ) { mMax = d; } - TQString maxValue() const { return mMax; } - - void setParam( const TQString &d ) { mParam = d; } - TQString param() const { return mParam; } - - void setParamName( const TQString &d ) { mParamName = d; } - TQString paramName() const { return mParamName; } - - void setParamType( const TQString &d ) { mParamType = d; } - TQString paramType() const { return mParamType; } - - void setChoices( const TQValueList &d ) { mChoices = d; } - TQValueList choices() const { return mChoices; } - - void setParamValues( const TQStringList &d ) { mParamValues = d; } - TQStringList paramValues() const { return mParamValues; } - - void setParamDefaultValues( const TQStringList &d ) { mParamDefaultValues = d; } - TQString paramDefaultValue(int i) const { return mParamDefaultValues[i]; } - - void setParamMax( int d ) { mParamMax = d; } - int paramMax() const { return mParamMax; } - - bool hidden() const { return mHidden; } - - void dump() const - { - kdDebug() << "" << endl; - kdDebug() << " group: " << mGroup << endl; - kdDebug() << " type: " << mType << endl; - kdDebug() << " key: " << mKey << endl; - kdDebug() << " name: " << mName << endl; - kdDebug() << " label: " << mLabel << endl; -// whatsthis - kdDebug() << " code: " << mCode << endl; -// kdDebug() << " values: " << mValues.join(":") << endl; - - if (!param().isEmpty()) - { - kdDebug() << " param name: "<< mParamName << endl; - kdDebug() << " param type: "<< mParamType << endl; - kdDebug() << " paramvalues: " << mParamValues.join(":") << endl; - } - kdDebug() << " default: " << mDefaultValue << endl; - kdDebug() << " hidden: " << mHidden << endl; - kdDebug() << " min: " << mMin << endl; - kdDebug() << " max: " << mMax << endl; - kdDebug() << "" << endl; - } - - private: - TQString mGroup; - TQString mType; - TQString mKey; - TQString mName; - TQString mLabel; - TQString mWhatsThis; - TQString mCode; - TQString mDefaultValue; - TQString mParam; - TQString mParamName; - TQString mParamType; - TQValueList mChoices; - TQStringList mParamValues; - TQStringList mParamDefaultValues; - int mParamMax; - bool mHidden; - TQString mMin; - TQString mMax; -}; - -class Param { -public: - TQString name; - TQString type; -}; - -// returns the name of an member variable -// use itemPath to know the full path -// like using d-> in case of dpointer -static TQString varName(const TQString &n) -{ - TQString result; - if ( !dpointer ) { - result = "m"+n; - result[1] = result[1].upper(); - } - else { - result = n; - result[0] = result[0].lower(); - } - return result; -} - -static TQString varPath(const TQString &n) -{ - TQString result; - if ( dpointer ) { - result = "d->"+varName(n); - } - else { - result = varName(n); - } - return result; -} - -static TQString enumName(const TQString &n) -{ - TQString result = "Enum"+n; - result[4] = result[4].upper(); - return result; -} - -static TQString setFunction(const TQString &n, const TQString &className = TQString()) -{ - TQString result = "set"+n; - result[3] = result[3].upper(); - - if ( !className.isEmpty() ) - result = className + "::" + result; - return result; -} - - -static TQString getFunction(const TQString &n, const TQString &className = TQString()) -{ - TQString result = n; - result[0] = result[0].lower(); - - if ( !className.isEmpty() ) - result = className + "::" + result; - return result; -} - - -static void addQuotes( TQString &s ) -{ - if ( s.left( 1 ) != "\"" ) s.prepend( "\"" ); - if ( s.right( 1 ) != "\"" ) s.append( "\"" ); -} - -static TQString quoteString( const TQString &s ) -{ - TQString r = s; - r.replace( "\\", "\\\\" ); - r.replace( "\"", "\\\"" ); - r.replace( "\r", "" ); - r.replace( "\n", "\\n\"\n\"" ); - return "\"" + r + "\""; -} - -static TQString literalString( const TQString &s ) -{ - bool isAscii = true; - for(int i = s.length(); i--;) - if (s[i].unicode() > 127) isAscii = false; - - if (isAscii) - return "TQString::fromLatin1( " + quoteString(s) + " )"; - else - return "TQString::fromUtf8( " + quoteString(s) + " )"; -} - -static TQString dumpNode(const TQDomNode &node) -{ - TQString msg; - TQTextStream s(&msg, IO_WriteOnly ); - node.save(s, 0); - - msg = msg.simplifyWhiteSpace(); - if (msg.length() > 40) - return msg.left(37)+"..."; - return msg; -} - -static TQString filenameOnly(TQString path) -{ - int i = path.findRev('/'); - if (i >= 0) - return path.mid(i+1); - return path; -} - -static void preProcessDefault( TQString &defaultValue, const TQString &name, - const TQString &type, - const TQValueList &choices, - TQString &code ) -{ - if ( type == "String" && !defaultValue.isEmpty() ) { - defaultValue = literalString(defaultValue); - - } else if ( type == "Path" && !defaultValue.isEmpty() ) { - defaultValue = literalString( defaultValue ); - - } else if ( (type == "StringList" || type == "PathList") && !defaultValue.isEmpty() ) { - TQTextStream cpp( &code, IO_WriteOnly | IO_Append ); - if (!code.isEmpty()) - cpp << endl; - - cpp << " TQStringList default" << name << ";" << endl; - TQStringList defaults = TQStringList::split( ",", defaultValue ); - TQStringList::ConstIterator it; - for( it = defaults.begin(); it != defaults.end(); ++it ) { - cpp << " default" << name << ".append( TQString::fromUtf8( \"" << *it << "\" ) );" - << endl; - } - defaultValue = "default" + name; - - } else if ( type == "Color" && !defaultValue.isEmpty() ) { - TQRegExp colorRe("\\d+,\\s*\\d+,\\s*\\d+"); - if (colorRe.exactMatch(defaultValue)) - { - defaultValue = "TQColor( " + defaultValue + " )"; - } - else - { - defaultValue = "TQColor( \"" + defaultValue + "\" )"; - } - - } else if ( type == "Enum" ) { - if ( !globalEnums ) { - TQValueList::ConstIterator it; - for( it = choices.begin(); it != choices.end(); ++it ) { - if ( (*it).name == defaultValue ) { - defaultValue.prepend( enumName(name) + "::"); - break; - } - } - } - - } else if ( type == "IntList" ) { - TQTextStream cpp( &code, IO_WriteOnly | IO_Append ); - if (!code.isEmpty()) - cpp << endl; - - cpp << " TQValueList default" << name << ";" << endl; - TQStringList defaults = TQStringList::split( ",", defaultValue ); - TQStringList::ConstIterator it; - for( it = defaults.begin(); it != defaults.end(); ++it ) { - cpp << " default" << name << ".append( " << *it << " );" - << endl; - } - defaultValue = "default" + name; - } -} - - -CfgEntry *parseEntry( const TQString &group, const TQDomElement &element ) -{ - bool defaultCode = false; - TQString type = element.attribute( "type" ); - TQString name = element.attribute( "name" ); - TQString key = element.attribute( "key" ); - TQString hidden = element.attribute( "hidden" ); - TQString label; - TQString whatsThis; - TQString defaultValue; - TQString code; - TQString param; - TQString paramName; - TQString paramType; - TQValueList choices; - TQStringList paramValues; - TQStringList paramDefaultValues; - TQString minValue; - TQString maxValue; - int paramMax = 0; - - TQDomNode n; - for ( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { - TQDomElement e = n.toElement(); - TQString tag = e.tagName(); - if ( tag == "label" ) label = e.text(); - else if ( tag == "whatsthis" ) whatsThis = e.text(); - else if ( tag == "min" ) minValue = e.text(); - else if ( tag == "max" ) maxValue = e.text(); - else if ( tag == "code" ) code = e.text(); - else if ( tag == "parameter" ) - { - param = e.attribute( "name" ); - paramType = e.attribute( "type" ); - if ( param.isEmpty() ) { - kdError() << "Parameter must have a name: " << dumpNode(e) << endl; - return 0; - } - if ( paramType.isEmpty() ) { - kdError() << "Parameter must have a type: " << dumpNode(e) << endl; - return 0; - } - if ((paramType == "Int") || (paramType == "UInt")) - { - bool ok; - paramMax = e.attribute("max").toInt(&ok); - if (!ok) - { - kdError() << "Integer parameter must have a maximum (e.g. max=\"0\"): " << dumpNode(e) << endl; - return 0; - } - } - else if (paramType == "Enum") - { - TQDomNode n2; - for ( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { - TQDomElement e2 = n2.toElement(); - if (e2.tagName() == "values") - { - TQDomNode n3; - for ( n3 = e2.firstChild(); !n3.isNull(); n3 = n3.nextSibling() ) { - TQDomElement e3 = n3.toElement(); - if (e3.tagName() == "value") - { - paramValues.append( e3.text() ); - } - } - break; - } - } - if (paramValues.isEmpty()) - { - kdError() << "No values specified for parameter '" << param << "'." << endl; - return 0; - } - paramMax = paramValues.count()-1; - } - else - { - kdError() << "Parameter '" << param << "' has type " << paramType << " but must be of type int, uint or Enum." << endl; - return 0; - } - } - else if ( tag == "default" ) - { - if (e.attribute("param").isEmpty()) - { - defaultValue = e.text(); - if (e.attribute( "code" ) == "true") - defaultCode = true; - } - } - else if ( tag == "choices" ) { - TQDomNode n2; - for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { - TQDomElement e2 = n2.toElement(); - if ( e2.tagName() == "choice" ) { - TQDomNode n3; - CfgEntry::Choice choice; - choice.name = e2.attribute( "name" ); - if ( choice.name.isEmpty() ) { - kdError() << "Tag requires attribute 'name'." << endl; - } - for( n3 = e2.firstChild(); !n3.isNull(); n3 = n3.nextSibling() ) { - TQDomElement e3 = n3.toElement(); - if ( e3.tagName() == "label" ) choice.label = e3.text(); - if ( e3.tagName() == "whatsthis" ) choice.whatsThis = e3.text(); - } - choices.append( choice ); - } - } - } - } - - bool nameIsEmpty = name.isEmpty(); - if ( nameIsEmpty && key.isEmpty() ) { - kdError() << "Entry must have a name or a key: " << dumpNode(element) << endl; - return 0; - } - - if ( key.isEmpty() ) { - key = name; - } - - if ( nameIsEmpty ) { - name = key; - name.replace( " ", TQString() ); - } else if ( name.contains( ' ' ) ) { - kdWarning()<<"Entry '"< elements can't contain speces!"< paramMax)) - { - kdError() << "Index '" << i << "' for default value is out of range [0, "<< paramMax<<"]." << endl; - return 0; - } - - TQString tmpDefaultValue = e.text(); - - if (e.attribute( "code" ) != "true") - preProcessDefault(tmpDefaultValue, name, type, choices, code); - - paramDefaultValues[i] = tmpDefaultValue; - } - } - } - - if (!validNameRegexp->exactMatch(name)) - { - if (nameIsEmpty) - kdError() << "The key '" << key << "' can not be used as name for the entry because " - "it is not a valid name. You need to specify a valid name for this entry." << endl; - else - kdError() << "The name '" << name << "' is not a valid name for an entry." << endl; - return 0; - } - - if (allNames.contains(name)) - { - if (nameIsEmpty) - kdError() << "The key '" << key << "' can not be used as name for the entry because " - "it does not result in a unique name. You need to specify a unique name for this entry." << endl; - else - kdError() << "The name '" << name << "' is not unique." << endl; - return 0; - } - allNames.append(name); - - if (!defaultCode) - { - preProcessDefault(defaultValue, name, type, choices, code); - } - - CfgEntry *result = new CfgEntry( group, type, key, name, label, whatsThis, - code, defaultValue, choices, - hidden == "true" ); - if (!param.isEmpty()) - { - result->setParam(param); - result->setParamName(paramName); - result->setParamType(paramType); - result->setParamValues(paramValues); - result->setParamDefaultValues(paramDefaultValues); - result->setParamMax(paramMax); - } - result->setMinValue(minValue); - result->setMaxValue(maxValue); - - return result; -} - -/** - Return parameter declaration for given type. -*/ -TQString param( const TQString &type ) -{ - if ( type == "String" ) return "const TQString &"; - else if ( type == "StringList" ) return "const TQStringList &"; - else if ( type == "Font" ) return "const TQFont &"; - else if ( type == "Rect" ) return "const TQRect &"; - else if ( type == "Size" ) return "const TQSize &"; - else if ( type == "Color" ) return "const TQColor &"; - else if ( type == "Point" ) return "const TQPoint &"; - else if ( type == "Int" ) return "int"; - else if ( type == "UInt" ) return "uint"; - else if ( type == "Bool" ) return "bool"; - else if ( type == "Double" ) return "double"; - else if ( type == "DateTime" ) return "const TQDateTime &"; - else if ( type == "Int64" ) return "TQ_INT64"; - else if ( type == "UInt64" ) return "TQ_UINT64"; - else if ( type == "IntList" ) return "const TQValueList &"; - else if ( type == "Enum" ) return "int"; - else if ( type == "Path" ) return "const TQString &"; - else if ( type == "PathList" ) return "const TQStringList &"; - else if ( type == "Password" ) return "const TQString &"; - else { - kdError() <<"kconfig_compiler does not support type \""<< type <<"\""<"; - else if ( type == "Enum" ) return "int"; - else if ( type == "Path" ) return TQSTRING_OBJECT_NAME_STRING; - else if ( type == "PathList" ) return TQSTRINGLIST_OBJECT_NAME_STRING; - else if ( type == "Password" ) return TQSTRING_OBJECT_NAME_STRING; - else { - kdError()<<"kconfig_compiler does not support type \""<< type <<"\""<()"; - else if ( type == "Enum" ) return "0"; - else if ( type == "Path" ) return "\"\""; // Use empty string, not null string! - else if ( type == "PathList" ) return "TQStringList()"; - else if ( type == "Password" ) return "\"\""; // Use empty string, not null string! - else { - kdWarning()<<"Error, kconfig_compiler doesn't support the \""<< type <<"\" type!"<name(); - fCap[0] = fCap[0].upper(); - return " TDEConfigSkeleton::Item"+itemType( e->type() ) + - " *item" + fCap + - ( (!e->param().isEmpty())?(TQString("[%1]").arg(e->paramMax()+1)) : TQString()) + - ";\n"; -} - -// returns the name of an item variable -// use itemPath to know the full path -// like using d-> in case of dpointer -static TQString itemVar(const CfgEntry *e) -{ - TQString result; - if (itemAccessors) - { - if ( !dpointer ) - { - result = "m" + e->name() + "Item"; - result[1] = result[1].upper(); - } - else - { - result = e->name() + "Item"; - result[0] = result[0].lower(); - } - } - else - { - result = "item" + e->name(); - result[4] = result[4].upper(); - } - return result; -} - -static TQString itemPath(const CfgEntry *e) -{ - TQString result; - if ( dpointer ) { - result = "d->"+itemVar(e); - } - else { - result = itemVar(e); - } - return result; -} - -TQString newItem( const TQString &type, const TQString &name, const TQString &key, - const TQString &defaultValue, const TQString ¶m = TQString()) -{ - TQString t = "new TDEConfigSkeleton::Item" + itemType( type ) + - "( currentGroup(), " + key + ", " + varPath( name ) + param; - if ( type == "Enum" ) t += ", values" + name; - if ( !defaultValue.isEmpty() ) { - t += ", "; - if ( type == "String" ) t += defaultValue; - else t+= defaultValue; - } - t += " );"; - - return t; -} - -TQString paramString(const TQString &s, const CfgEntry *e, int i) -{ - TQString result = s; - TQString needle = "$("+e->param()+")"; - if (result.contains(needle)) - { - TQString tmp; - if (e->paramType() == "Enum") - { - tmp = e->paramValues()[i]; - } - else - { - tmp = TQString::number(i); - } - - result.replace(needle, tmp); - } - return result; -} - -TQString paramString(const TQString &group, const TQValueList ¶meters) -{ - TQString paramString = group; - TQString arguments; - int i = 1; - for (TQValueList::ConstIterator it = parameters.begin(); - it != parameters.end(); ++it) - { - if (paramString.contains("$("+(*it).name+")")) - { - TQString tmp; - tmp.sprintf("%%%d", i++); - paramString.replace("$("+(*it).name+")", tmp); - arguments += ".arg( mParam"+(*it).name+" )"; - } - } - if (arguments.isEmpty()) - return "TQString::fromLatin1( \""+group+"\" )"; - - return "TQString::fromLatin1( \""+paramString+"\" )"+arguments; -} - -/* int i is the value of the parameter */ -TQString userTextsFunctions( CfgEntry *e, TQString itemVarStr=TQString(), TQString i=TQString() ) -{ - TQString txt; - if (itemVarStr.isNull()) itemVarStr=itemPath(e); - if ( !e->label().isEmpty() ) { - txt += " " + itemVarStr + "->setLabel( i18n("; - if ( !e->param().isEmpty() ) - txt += quoteString(e->label().replace("$("+e->param()+")", i)); - else - txt+= quoteString(e->label()); - txt+= ") );\n"; - } - if ( !e->whatsThis().isEmpty() ) { - txt += " " + itemVarStr + "->setWhatsThis( i18n("; - if ( !e->param().isEmpty() ) - txt += quoteString(e->whatsThis().replace("$("+e->param()+")", i)); - else - txt+= quoteString(e->whatsThis()); - txt+=") );\n"; - } - return txt; -} - -// returns the member accesor implementation -// which should go in the h file if inline -// or the cpp file if not inline -TQString memberAccessorBody( CfgEntry *e ) -{ - TQString result; - TQTextStream out(&result, IO_WriteOnly); - TQString n = e->name(); - TQString t = e->type(); - - out << "return " << This << varPath(n); - if (!e->param().isEmpty()) out << "[i]"; - out << ";" << endl; - - return result; -} - -// returns the member mutator implementation -// which should go in the h file if inline -// or the cpp file if not inline -TQString memberMutatorBody( CfgEntry *e ) -{ - TQString result; - TQTextStream out(&result, IO_WriteOnly); - TQString n = e->name(); - TQString t = e->type(); - - if (!e->minValue().isEmpty()) - { - out << "if (v < " << e->minValue() << ")" << endl; - out << "{" << endl; - out << " kdDebug() << \"" << setFunction(n); - out << ": value \" << v << \" is less than the minimum value of "; - out << e->minValue()<< "\" << endl;" << endl; - out << " v = " << e->minValue() << ";" << endl; - out << "}" << endl; - } - - if (!e->maxValue().isEmpty()) - { - out << endl << "if (v > " << e->maxValue() << ")" << endl; - out << "{" << endl; - out << " kdDebug() << \"" << setFunction(n); - out << ": value \" << v << \" is greater than the maximum value of "; - out << e->maxValue()<< "\" << endl;" << endl; - out << " v = " << e->maxValue() << ";" << endl; - out << "}" << endl << endl; - } - - out << "if (!" << This << "isImmutable( TQString::fromLatin1( \""; - if (!e->param().isEmpty()) - { - out << e->paramName().replace("$("+e->param()+")", "%1") << "\" ).arg( "; - if ( e->paramType() == "Enum" ) { - out << "TQString::fromLatin1( "; - - if (globalEnums) - out << enumName(e->param()) << "ToString[i]"; - else - out << enumName(e->param()) << "::enumToString[i]"; - - out << " )"; - } - else - { - out << "i"; - } - out << " )"; - } - else - { - out << n << "\" )"; - } - out << " ))" << endl; - out << " " << This << varPath(n); - if (!e->param().isEmpty()) - out << "[i]"; - out << " = v;" << endl; - - return result; -} - -// returns the item accesor implementation -// which should go in the h file if inline -// or the cpp file if not inline -TQString itemAccessorBody( CfgEntry *e ) -{ - TQString result; - TQTextStream out(&result, IO_WriteOnly); - - out << "return " << itemPath(e); - if (!e->param().isEmpty()) out << "[i]"; - out << ";" << endl; - - return result; -} - -//indents text adding X spaces per line -TQString indent(TQString text, int spaces) -{ - TQString result; - TQTextStream out(&result, IO_WriteOnly); - TQTextStream in(&text, IO_ReadOnly); - TQString currLine; - while ( !in.atEnd() ) - { - currLine = in.readLine(); - if (!currLine.isEmpty()) - for (int i=0; i < spaces; i++) - out << " "; - out << currLine << endl; - } - return result; -} - - -int main( int argc, char **argv ) -{ - TDEAboutData aboutData( "kconfig_compiler", I18N_NOOP("TDE .kcfg compiler"), "0.3", - I18N_NOOP("TDEConfig Compiler") , TDEAboutData::License_LGPL ); - aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); - aboutData.addAuthor( "Waldo Bastian", 0, "bastian@kde.org" ); - aboutData.addAuthor( "Zack Rusin", 0, "zack@kde.org" ); - aboutData.addCredit( "Reinhold Kainhofer", "Fix for parametrized entries", - "reinhold@kainhofer.com", "http://reinhold.kainhofer.com" ); - aboutData.addCredit( "Duncan Mac-Vicar P.", "dpointer support", - "duncan@kde.org", "http://www.mac-vicar.com/~duncan" ); - - TDECmdLineArgs::init( argc, argv, &aboutData ); - TDECmdLineArgs::addCmdLineOptions( options ); - - TDEInstance app( &aboutData ); - - TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); - - if ( args->count() < 2 ) { - kdError() << "Too few arguments." << endl; - return 1; - } - if ( args->count() > 2 ) { - kdError() << "Too many arguments." << endl; - return 1; - } - - validNameRegexp = new TQRegExp("[a-zA-Z_][a-zA-Z0-9_]*"); - - TQString baseDir = TQFile::decodeName(args->getOption("directory")); - if (!baseDir.endsWith("/")) - baseDir.append("/"); - - TQString inputFilename = args->url( 0 ).path(); - TQString codegenFilename = args->url( 1 ).path(); - - if (!codegenFilename.endsWith(".kcfgc")) - { - kdError() << "Codegen options file must have extension .kcfgc" << endl; - return 1; - } - TQString baseName = args->url( 1 ).fileName(); - baseName = baseName.left(baseName.length() - 6); - - KSimpleConfig codegenConfig( codegenFilename, true ); - - TQString nameSpace = codegenConfig.readEntry("NameSpace"); - TQString className = codegenConfig.readEntry("ClassName"); - TQString inherits = codegenConfig.readEntry("Inherits"); - TQString visibility = codegenConfig.readEntry("Visibility"); - if (!visibility.isEmpty()) visibility+=" "; - bool singleton = codegenConfig.readBoolEntry("Singleton", false); - bool staticAccessors = singleton; - //bool useDPointer = codegenConfig.readBoolEntry("DPointer", false); - bool customAddons = codegenConfig.readBoolEntry("CustomAdditions"); - TQString memberVariables = codegenConfig.readEntry("MemberVariables"); - TQStringList headerIncludes = codegenConfig.readListEntry("IncludeFiles"); - TQStringList mutators = codegenConfig.readListEntry("Mutators"); - bool allMutators = false; - if ((mutators.count() == 1) && (mutators[0].lower() == "true")) - allMutators = true; - itemAccessors = codegenConfig.readBoolEntry( "ItemAccessors", false ); - bool setUserTexts = codegenConfig.readBoolEntry( "SetUserTexts", false ); - - globalEnums = codegenConfig.readBoolEntry( "GlobalEnums", false ); - - dpointer = (memberVariables == "dpointer"); - - TQFile input( inputFilename ); - - TQDomDocument doc; - TQString errorMsg; - int errorRow; - int errorCol; - if ( !doc.setContent( &input, &errorMsg, &errorRow, &errorCol ) ) { - kdError() << "Unable to load document." << endl; - kdError() << "Parse error in " << args->url( 0 ).fileName() << ", line " << errorRow << ", col " << errorCol << ": " << errorMsg << endl; - return 1; - } - - TQDomElement cfgElement = doc.documentElement(); - - if ( cfgElement.isNull() ) { - kdError() << "No document in kcfg file" << endl; - return 1; - } - - TQString cfgFileName; - bool cfgFileNameArg = false; - TQValueList parameters; - TQStringList includes; - - TQPtrList entries; - entries.setAutoDelete( true ); - - TQDomNode n; - for ( n = cfgElement.firstChild(); !n.isNull(); n = n.nextSibling() ) { - TQDomElement e = n.toElement(); - - TQString tag = e.tagName(); - - if ( tag == "include" ) { - TQString includeFile = e.text(); - if (!includeFile.isEmpty()) - includes.append(includeFile); - - } else if ( tag == "kcfgfile" ) { - cfgFileName = e.attribute( "name" ); - cfgFileNameArg = e.attribute( "arg" ).lower() == "true"; - TQDomNode n2; - for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { - TQDomElement e2 = n2.toElement(); - if ( e2.tagName() == "parameter" ) { - Param p; - p.name = e2.attribute( "name" ); - p.type = e2.attribute( "type" ); - if (p.type.isEmpty()) - p.type = "String"; - parameters.append( p ); - } - } - - } else if ( tag == "group" ) { - TQString group = e.attribute( "name" ); - if ( group.isEmpty() ) { - kdError() << "Group without name" << endl; - return 1; - } - TQDomNode n2; - for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { - TQDomElement e2 = n2.toElement(); - if ( e2.tagName() != "entry" ) continue; - CfgEntry *entry = parseEntry( group, e2 ); - if ( entry ) entries.append( entry ); - else { - kdError() << "Can't parse entry." << endl; - return 1; - } - } - } - } - - if ( inherits.isEmpty() ) inherits = "TDEConfigSkeleton"; - - if ( className.isEmpty() ) { - kdError() << "Class name missing" << endl; - return 1; - } - - if ( singleton && !parameters.isEmpty() ) { - kdError() << "Singleton class can not have parameters" << endl; - return 1; - } - - if ( !cfgFileName.isEmpty() && cfgFileNameArg) - { - kdError() << "Having both a fixed filename and a filename as argument is not possible." << endl; - return 1; - } - - if ( entries.isEmpty() ) { - kdWarning() << "No entries." << endl; - } - -#if 0 - CfgEntry *cfg; - for( cfg = entries.first(); cfg; cfg = entries.next() ) { - cfg->dump(); - } -#endif - - TQString headerFileName = baseName + ".h"; - TQString implementationFileName = baseName + ".cpp"; - TQString cppPreamble; // code to be inserted at the beginnin of the cpp file, e.g. initialization of static values - - TQFile header( baseDir + headerFileName ); - if ( !header.open( IO_WriteOnly ) ) { - kdError() << "Can't open '" << headerFileName << "' for writing." << endl; - return 1; - } - - TQTextStream h( &header ); - - h << "// This file is generated by kconfig_compiler from " << args->url(0).fileName() << "." << endl; - h << "// All changes you do to this file will be lost." << endl; - - h << "#ifndef " << ( !nameSpace.isEmpty() ? nameSpace.upper() + "_" : "" ) - << className.upper() << "_H" << endl; - h << "#define " << ( !nameSpace.isEmpty() ? nameSpace.upper() + "_" : "" ) - << className.upper() << "_H" << endl << endl; - - // Includes - TQStringList::ConstIterator it; - for( it = headerIncludes.begin(); it != headerIncludes.end(); ++it ) { - h << "#include <" << *it << ">" << endl; - } - - if ( headerIncludes.count() > 0 ) h << endl; - - if ( !singleton && cfgFileNameArg && parameters.isEmpty() ) - h << "#include " << endl; - - h << "#include " << endl; - h << "#include " << endl << endl; - - // Includes - for( it = includes.begin(); it != includes.end(); ++it ) { - h << "#include <" << *it << ">" << endl; - } - - - if ( !nameSpace.isEmpty() ) - h << "namespace " << nameSpace << " {" << endl << endl; - - // Private class declaration - if ( dpointer ) - h << "class " << className << "Private;" << endl << endl; - - // Class declaration header - h << "class " << visibility << className << " : public " << inherits << endl; - h << "{" << endl; - h << " public:" << endl; - - // enums - CfgEntry *e; - for( e = entries.first(); e; e = entries.next() ) { - TQValueList choices = e->choices(); - if ( !choices.isEmpty() ) { - TQStringList values; - TQValueList::ConstIterator itChoice; - for( itChoice = choices.begin(); itChoice != choices.end(); ++itChoice ) { - values.append( (*itChoice).name ); - } - if ( globalEnums ) { - h << " enum { " << values.join( ", " ) << " };" << endl; - } else { - h << " class " << enumName(e->name()) << endl; - h << " {" << endl; - h << " public:" << endl; - h << " enum type { " << values.join( ", " ) << ", COUNT };" << endl; - h << " };" << endl; - } - } - TQStringList values = e->paramValues(); - if ( !values.isEmpty() ) { - if ( globalEnums ) { - h << " enum { " << values.join( ", " ) << " };" << endl; - h << " static const char* const " << enumName(e->param()) << "ToString[];" << endl; - cppPreamble += "const char* const " + className + "::" + enumName(e->param()) + "ToString[] = " + - "{ \"" + values.join( "\", \"" ) + "\" };\n"; - } else { - h << " class " << enumName(e->param()) << endl; - h << " {" << endl; - h << " public:" << endl; - h << " enum type { " << values.join( ", " ) << ", COUNT };" << endl; - h << " static const char* const enumToString[];" << endl; - h << " };" << endl; - cppPreamble += "const char* const " + className + "::" + enumName(e->param()) + "::enumToString[] = " + - "{ \"" + values.join( "\", \"" ) + "\" };\n"; - } - } - } - - h << endl; - - // Constructor or singleton accessor - if ( !singleton ) { - h << " " << className << "("; - if (cfgFileNameArg) - h << " KSharedConfig::Ptr config" << (parameters.isEmpty() ? " = TDEGlobal::sharedConfig()" : ", "); - for (TQValueList::ConstIterator it = parameters.begin(); - it != parameters.end(); ++it) - { - if (it != parameters.begin()) - h << ","; - h << " " << param((*it).type) << " " << (*it).name; - } - h << " );" << endl; - } else { - h << " static " << className << " *self();" << endl; - if (cfgFileNameArg) - h << " static void instance(const char * cfgfilename);" << endl; - } - - // Destructor - h << " ~" << className << "();" << endl << endl; - - // global variables - if (staticAccessors) - This = "self()->"; - else - Const = " const"; - - for( e = entries.first(); e; e = entries.next() ) { - TQString n = e->name(); - TQString t = e->type(); - - // Manipulator - if (allMutators || mutators.contains(n)) - { - h << " /**" << endl; - h << " Set " << e->label() << endl; - h << " */" << endl; - if (staticAccessors) - h << " static" << endl; - h << " void " << setFunction(n) << "( "; - if (!e->param().isEmpty()) - h << cppType(e->paramType()) << " i, "; - h << param( t ) << " v )"; - // function body inline only if not using dpointer - // for BC mode - if ( !dpointer ) - { - h << endl << " {" << endl; - h << indent(memberMutatorBody(e), 6 ); - h << " }" << endl; - } - else - { - h << ";" << endl; - } - } - h << endl; - // Accessor - h << " /**" << endl; - h << " Get " << e->label() << endl; - h << " */" << endl; - if (staticAccessors) - h << " static" << endl; - h << " " << cppType(t) << " " << getFunction(n) << "("; - if (!e->param().isEmpty()) - h << " " << cppType(e->paramType()) <<" i "; - h << ")" << Const; - // function body inline only if not using dpointer - // for BC mode - if ( !dpointer ) - { - h << endl << " {" << endl; - h << indent(memberAccessorBody(e), 6 ); - h << " }" << endl; - } - else - { - h << ";" << endl; - } - - // Item accessor - if ( itemAccessors ) { - h << endl; - h << " /**" << endl; - h << " Get Item object corresponding to " << n << "()" - << endl; - h << " */" << endl; - h << " Item" << itemType( e->type() ) << " *" - << getFunction( n ) << "Item("; - if (!e->param().isEmpty()) { - h << " " << cppType(e->paramType()) << " i "; - } - h << ")"; - if (! dpointer ) - { - h << endl << " {" << endl; - h << indent( itemAccessorBody(e), 6); - h << " }" << endl; - } - else - { - h << ";" << endl; - } - } - - h << endl; - } - - // Static writeConfig method for singleton - if ( singleton ) { - h << " static" << endl; - h << " void writeConfig()" << endl; - h << " {" << endl; - h << " static_cast(self())->writeConfig();" << endl; - h << " }" << endl; - } - - h << " protected:" << endl; - - // Private constructor for singleton - if ( singleton ) { - h << " " << className << "("; - if ( cfgFileNameArg ) - h << "const char *arg"; - h << ");" << endl; - h << " static " << className << " *mSelf;" << endl << endl; - } - - // Member variables - if ( !memberVariables.isEmpty() && memberVariables != "private" && memberVariables != "dpointer") { - h << " " << memberVariables << ":" << endl; - } - - // Class Parameters - for (TQValueList::ConstIterator it = parameters.begin(); - it != parameters.end(); ++it) - { - h << " " << cppType((*it).type) << " mParam" << (*it).name << ";" << endl; - } - - if ( memberVariables != "dpointer" ) - { - TQString group; - for( e = entries.first(); e; e = entries.next() ) { - if ( e->group() != group ) { - group = e->group(); - h << endl; - h << " // " << group << endl; - } - h << " " << cppType(e->type()) << " " << varName(e->name()); - if (!e->param().isEmpty()) - { - h << TQString("[%1]").arg(e->paramMax()+1); - } - h << ";" << endl; - } - - h << endl << " private:" << endl; - if ( itemAccessors ) { - for( e = entries.first(); e; e = entries.next() ) { - h << " Item" << itemType( e->type() ) << " *" << itemVar( e ); - if (!e->param().isEmpty() ) h << TQString("[%1]").arg( e->paramMax()+1 ); - h << ";" << endl; - } - } - - } - else - { - // use a private class for both member variables and items - h << " private:" << endl; - h << " " + className + "Private *d;" << endl; - } - - if (customAddons) - { - h << " // Include custom additions" << endl; - h << " #include \"" << filenameOnly(baseName) << "_addons.h\"" <url(0).fileName() << "." << endl; - cpp << "// All changes you do to this file will be lost." << endl << endl; - - cpp << "#include \"" << headerFileName << "\"" << endl << endl; - - if ( setUserTexts ) cpp << "#include " << endl << endl; - - // Header required by singleton implementation - if ( singleton ) - cpp << "#include " << endl << endl; - if ( singleton && cfgFileNameArg ) - cpp << "#include " << endl << endl; - - if ( !nameSpace.isEmpty() ) - cpp << "using namespace " << nameSpace << ";" << endl << endl; - - TQString group; - - // private class implementation - if ( dpointer ) - { - cpp << "class " << className << "Private" << endl; - cpp << "{" << endl; - cpp << " public:" << endl; - for( e = entries.first(); e; e = entries.next() ) { - if ( e->group() != group ) { - group = e->group(); - cpp << endl; - cpp << " // " << group << endl; - } - cpp << " " << cppType(e->type()) << " " << varName(e->name()); - if (!e->param().isEmpty()) - { - cpp << TQString("[%1]").arg(e->paramMax()+1); - } - cpp << ";" << endl; - } - cpp << endl << " // items" << endl; - for( e = entries.first(); e; e = entries.next() ) { - cpp << " TDEConfigSkeleton::Item" << itemType( e->type() ) << " *" << itemVar( e ); - if (!e->param().isEmpty() ) cpp << TQString("[%1]").arg( e->paramMax()+1 ); - cpp << ";" << endl; - } - - cpp << "};" << endl << endl; - } - - // Singleton implementation - if ( singleton ) { - cpp << className << " *" << className << "::mSelf = 0;" << endl; - cpp << "static KStaticDeleter<" << className << "> static" << className << "Deleter;" << endl << endl; - - cpp << className << " *" << className << "::self()" << endl; - cpp << "{" << endl; - if ( cfgFileNameArg ) { - cpp << " if (!mSelf)" << endl; - cpp << " kdFatal() << \"you need to call " << className << "::instance before using\" << endl;" << endl; - } else { - cpp << " if ( !mSelf ) {" << endl; - cpp << " static" << className << "Deleter.setObject( mSelf, new " << className << "() );" << endl; - cpp << " mSelf->readConfig();" << endl; - cpp << " }" << endl << endl; - } - cpp << " return mSelf;" << endl; - cpp << "}" << endl << endl; - - if ( cfgFileNameArg ) { - cpp << "void " << className << "::instance(const char *cfgfilename)" << endl; - cpp << "{" << endl; - cpp << " if (mSelf) {" << endl; - cpp << " kdError() << \"" << className << "::instance called after the first use - ignoring\" << endl;" << endl; - cpp << " return;" << endl; - cpp << " }" << endl; - cpp << " static" << className << "Deleter.setObject( mSelf, new " << className << "(cfgfilename) );" << endl; - cpp << " mSelf->readConfig();" << endl; - cpp << "}" << endl << endl; - } - } - - if ( !cppPreamble.isEmpty() ) - cpp << cppPreamble << endl; - - // Constructor - cpp << className << "::" << className << "( "; - if ( cfgFileNameArg ) { - if ( !singleton ) - cpp << " KSharedConfig::Ptr config"; - else - cpp << " const char *config"; - cpp << (parameters.isEmpty() ? " " : ", "); - } - - for (TQValueList::ConstIterator it = parameters.begin(); - it != parameters.end(); ++it) - { - if (it != parameters.begin()) - cpp << ","; - cpp << " " << param((*it).type) << " " << (*it).name; - } - cpp << " )" << endl; - - cpp << " : " << inherits << "("; - if ( !cfgFileName.isEmpty() ) cpp << " TQString::fromLatin1( \"" << cfgFileName << "\" "; - if ( cfgFileNameArg ) cpp << " config "; - if ( !cfgFileName.isEmpty() ) cpp << ") "; - cpp << ")" << endl; - - // Store parameters - for (TQValueList::ConstIterator it = parameters.begin(); - it != parameters.end(); ++it) - { - cpp << " , mParam" << (*it).name << "(" << (*it).name << ")" << endl; - } - - cpp << "{" << endl; - - if (dpointer) - cpp << " d = new " + className + "Private;" << endl; - // Needed in case the singleton class is used as baseclass for - // another singleton. - if ( singleton ) - cpp << " mSelf = this;" << endl; - - group = TQString(); - for( e = entries.first(); e; e = entries.next() ) { - if ( e->group() != group ) { - if ( !group.isEmpty() ) cpp << endl; - group = e->group(); - cpp << " setCurrentGroup( " << paramString(group, parameters) << " );" << endl << endl; - } - - TQString key = paramString(e->key(), parameters); - if ( !e->code().isEmpty()) - { - cpp << e->code() << endl; - } - if ( e->type() == "Enum" ) { - cpp << " TQValueList values" - << e->name() << ";" << endl; - TQValueList choices = e->choices(); - TQValueList::ConstIterator it; - for( it = choices.begin(); it != choices.end(); ++it ) { - cpp << " {" << endl; - cpp << " TDEConfigSkeleton::ItemEnum::Choice choice;" << endl; - cpp << " choice.name = TQString::fromLatin1( \"" << (*it).name << "\" );" << endl; - if ( setUserTexts ) { - if ( !(*it).label.isEmpty() ) - cpp << " choice.label = i18n(" << quoteString((*it).label) << ");" << endl; - if ( !(*it).whatsThis.isEmpty() ) - cpp << " choice.whatsThis = i18n(" << quoteString((*it).whatsThis) << ");" << endl; - } - cpp << " values" << e->name() << ".append( choice );" << endl; - cpp << " }" << endl; - } - } - - if (!dpointer) - cpp << itemDeclaration(e); - - if (e->param().isEmpty()) - { - // Normal case - cpp << " " << itemPath(e) << " = " - << newItem( e->type(), e->name(), key, e->defaultValue() ) << endl; - - if ( !e->minValue().isEmpty() ) - cpp << " " << itemPath(e) << "->setMinValue(" << e->minValue() << ");" << endl; - if ( !e->maxValue().isEmpty() ) - cpp << " " << itemPath(e) << "->setMaxValue(" << e->maxValue() << ");" << endl; - - if ( setUserTexts ) - cpp << userTextsFunctions( e ); - - cpp << " addItem( " << itemPath(e); - TQString quotedName = e->name(); - addQuotes( quotedName ); - if ( quotedName != key ) cpp << ", TQString::fromLatin1( \"" << e->name() << "\" )"; - cpp << " );" << endl; - } - else - { - // Indexed - for(int i = 0; i <= e->paramMax(); i++) - { - TQString defaultStr; - TQString itemVarStr(itemPath(e)+TQString("[%1]").arg(i)); - - if ( !e->paramDefaultValue(i).isEmpty() ) - defaultStr = e->paramDefaultValue(i); - else if ( !e->defaultValue().isEmpty() ) - defaultStr = paramString(e->defaultValue(), e, i); - else - defaultStr = defaultValue( e->type() ); - - cpp << " " << itemVarStr << " = " - << newItem( e->type(), e->name(), paramString(key, e, i), defaultStr, TQString("[%1]").arg(i) ) - << endl; - - if ( setUserTexts ) - cpp << userTextsFunctions( e, itemVarStr, e->paramName() ); - - // Make mutators for enum parameters work by adding them with $(..) replaced by the - // param name. The check for isImmutable in the set* functions doesn't have the param - // name available, just the corresponding enum value (int), so we need to store the - // param names in a separate static list!. - cpp << " addItem( " << itemVarStr << ", TQString::fromLatin1( \""; - if ( e->paramType()=="Enum" ) - cpp << e->paramName().replace( "$("+e->param()+")", "%1").arg(e->paramValues()[i] ); - else - cpp << e->paramName().replace( "$("+e->param()+")", "%1").arg(i); - cpp << "\" ) );" << endl; - } - } - } - - cpp << "}" << endl << endl; - - if (dpointer) - { - // setters and getters go in Cpp if in dpointer mode - for( e = entries.first(); e; e = entries.next() ) - { - TQString n = e->name(); - TQString t = e->type(); - - // Manipulator - if (allMutators || mutators.contains(n)) - { - cpp << "void " << setFunction(n, className) << "( "; - if (!e->param().isEmpty()) - cpp << cppType(e->paramType()) << " i, "; - cpp << param( t ) << " v )" << endl; - // function body inline only if not using dpointer - // for BC mode - cpp << "{" << endl; - cpp << indent(memberMutatorBody(e), 6); - cpp << "}" << endl << endl; - } - - // Accessor - cpp << cppType(t) << " " << getFunction(n, className) << "("; - if (!e->param().isEmpty()) - cpp << " " << cppType(e->paramType()) <<" i "; - cpp << ")" << Const << endl; - // function body inline only if not using dpointer - // for BC mode - cpp << "{" << endl; - cpp << indent(memberAccessorBody(e), 2); - cpp << "}" << endl << endl; - - // Item accessor - if ( itemAccessors ) - { - cpp << endl; - cpp << "TDEConfigSkeleton::Item" << itemType( e->type() ) << " *" - << getFunction( n, className ) << "Item("; - if (!e->param().isEmpty()) { - cpp << " " << cppType(e->paramType()) << " i "; - } - cpp << ")" << endl; - cpp << "{" << endl; - cpp << indent(itemAccessorBody(e), 2); - cpp << "}" << endl; - } - - cpp << endl; - } - } - - // Destructor - cpp << className << "::~" << className << "()" << endl; - cpp << "{" << endl; - if ( singleton ) { - if ( dpointer ) - cpp << " delete d;" << endl; - cpp << " if ( mSelf == this )" << endl; - cpp << " static" << className << "Deleter.setObject( mSelf, 0, false );" << endl; - } - cpp << "}" << endl << endl; - - implementation.close(); -} diff --git a/tdecore/kconfig_compiler/tests/Makefile.am b/tdecore/kconfig_compiler/tests/Makefile.am deleted file mode 100644 index 953d1c6b4..000000000 --- a/tdecore/kconfig_compiler/tests/Makefile.am +++ /dev/null @@ -1,134 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir)/tdeunittest $(all_includes) -DQT_NO_CAST_ASCII -DSRCDIR=\"$(srcdir)\" - -check_PROGRAMS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test_dpointer - -CLEANFILES = test1.cpp test1.h \ - test2.cpp test2.h \ - test3.cpp test3.h \ - test4.cpp test4.h \ - test5.cpp test5.h \ - test6.cpp test6.h \ - test7.cpp test7.h \ - test8a.cpp test8a.h test8b.cpp test8b.h \ - test9.cpp test9.h \ - test_dpointer.cpp test_dpointer.h \ - md5sums - -test1_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -test1_LDADD = $(LIB_TDECORE) -test1_SOURCES = test1main.cpp test1.cpp - -test2_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -test2_LDADD = $(LIB_TDECORE) -test2_SOURCES = test2main.cpp test2.cpp - -test3_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -test3_LDADD = $(LIB_TDECORE) -test3_SOURCES = test3main.cpp test3.cpp - -test4_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -test4_LDADD = $(LIB_TDECORE) -test4_SOURCES = test4main.cpp test4.cpp - -test5_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -test5_LDADD = $(LIB_TDECORE) -test5_SOURCES = test5main.cpp test5.cpp - -test6_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -test6_LDADD = $(LIB_TDECORE) -test6_SOURCES = test6main.cpp test6.cpp - -test7_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -test7_LDADD = $(LIB_TDECORE) -test7_SOURCES = test7main.cpp test7.cpp - -test8_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -test8_LDADD = $(LIB_TDECORE) -test8_SOURCES = test8main.cpp test8a.cpp test8b.cpp - -test9_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -test9_LDADD = $(LIB_TDECORE) -test9_SOURCES = test9main.cpp test9.cpp - -test_dpointer_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor -test_dpointer_LDADD = $(LIB_TDECORE) -test_dpointer_SOURCES = test_dpointer_main.cpp test_dpointer.cpp - -check_LTLIBRARIES = tdeunittest_kconfigcompiler_test.la - -tdeunittest_kconfigcompiler_test_la_SOURCES = kconfigcompiler_test.cpp -tdeunittest_kconfigcompiler_test_la_LIBADD = \ - $(top_builddir)/tdeunittest/libtdeunittest.la -tdeunittest_kconfigcompiler_test_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) \ - $(all_libraries) - - -test1main.o test1.o: test1.h -# avoid running the below command in parallel -test1.cpp: test1.h -test1.cpp test1.h: $(srcdir)/test1.kcfg ../kconfig_compiler $(srcdir)/test1.kcfgc - ../kconfig_compiler $(srcdir)/test1.kcfg $(srcdir)/test1.kcfgc - -test2main.o test2.o: test2.h -# avoid running the below command in parallel -test2.cpp: test2.h -test2.cpp test2.h: $(srcdir)/test2.kcfg ../kconfig_compiler $(srcdir)/test2.kcfgc - ../kconfig_compiler $(srcdir)/test2.kcfg $(srcdir)/test2.kcfgc - -test3main.o test3.o: test3.h -# avoid running the below command in parallel -test3.cpp: test3.h -test3.cpp test3.h: $(srcdir)/test3.kcfg ../kconfig_compiler $(srcdir)/test3.kcfgc - ../kconfig_compiler $(srcdir)/test3.kcfg $(srcdir)/test3.kcfgc - -test4main.o test4.o: test4.h -# avoid running the below command in parallel -test4.cpp: test4.h -test4.cpp test4.h: $(srcdir)/test4.kcfg ../kconfig_compiler $(srcdir)/test4.kcfgc - ../kconfig_compiler $(srcdir)/test4.kcfg $(srcdir)/test4.kcfgc - -test5main.o test5.o: test5.h -# avoid running the below command in parallel -test5.cpp: test5.h -test5.cpp test5.h: $(srcdir)/test5.kcfg ../kconfig_compiler $(srcdir)/test5.kcfgc - ../kconfig_compiler $(srcdir)/test5.kcfg $(srcdir)/test5.kcfgc - -test6main.o test6.o: test6.h -# avoid running the below command in parallel -test6.cpp: test6.h -test6.cpp test6.h: $(srcdir)/test6.kcfg ../kconfig_compiler $(srcdir)/test6.kcfgc - ../kconfig_compiler $(srcdir)/test6.kcfg $(srcdir)/test6.kcfgc - -test7main.o test7.o: test7.h -# avoid running the below command in parallel -test7.cpp: test7.h -test7.cpp test7.h: $(srcdir)/test7.kcfg ../kconfig_compiler $(srcdir)/test7.kcfgc - ../kconfig_compiler $(srcdir)/test7.kcfg $(srcdir)/test7.kcfgc - -test8main.o test8a.o test8b.o: test8a.h test8b.h -# avoid running the below command in parallel -test8a.cpp: test8a.h -test8a.cpp test8a.h: $(srcdir)/test8a.kcfg ../kconfig_compiler $(srcdir)/test8a.kcfgc - ../kconfig_compiler $(srcdir)/test8a.kcfg $(srcdir)/test8a.kcfgc -test8b.cpp: test8b.h -test8b.cpp test8b.h: $(srcdir)/test8b.kcfg ../kconfig_compiler $(srcdir)/test8b.kcfgc - ../kconfig_compiler $(srcdir)/test8b.kcfg $(srcdir)/test8b.kcfgc - -test9main.o test9.o: test9.h -# avoid running the below command in parallel -test9.cpp: test9.h -test9.cpp test9.h: $(srcdir)/test9.kcfg ../kconfig_compiler $(srcdir)/test9.kcfgc - ../kconfig_compiler $(srcdir)/test9.kcfg $(srcdir)/test9.kcfgc - -test_dpointer_main.o test_dpointer.o: test_dpointer.h -# avoid running the below command in parallel -test_dpointer.cpp: test_dpointer.h -test_dpointer.cpp test_dpointer.h: $(srcdir)/test_dpointer.kcfg ../kconfig_compiler $(srcdir)/test_dpointer.kcfgc - ../kconfig_compiler $(srcdir)/test_dpointer.kcfg $(srcdir)/test_dpointer.kcfgc - -md5sums: - $(MD5SUM) $(srcdir)/test*.ref | sed -e "s,$(srcdir)/,,; s,\.ref$$,," > md5sums - -md5check: test1.cpp test2.cpp test3.cpp test4.cpp test5.cpp test6.cpp test7.cpp test8a.cpp test8b.cpp test9.cpp md5sums - $(MD5SUM) -c md5sums - diff --git a/tdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp b/tdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp deleted file mode 100644 index c9f2f8471..000000000 --- a/tdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - Tests for TDEConfig Compiler - - Copyright (c) 2005 by Duncan Mac-Vicar - - ************************************************************************* - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - ************************************************************************* -*/ - -#include -#include -#include -#include -#include "kconfigcompiler_test.h" - -using namespace KUnitTest; - -KUNITTEST_MODULE( tdeunittest_kconfigcompiler_test, "TDEConfigXT") -KUNITTEST_MODULE_REGISTER_TESTER( TDEConfigCompiler_Test ) - -typedef const char * CompilerTestSet[]; - -static CompilerTestSet testCases = -{ - "test1.cpp", "test1.h", - "test2.cpp", "test2.h", - "test3.cpp", "test3.h", - "test4.cpp", "test4.h", - "test5.cpp", "test5.h", - "test6.cpp", "test6.h", - "test7.cpp", "test7.h", - "test8a.cpp", "test8a.h", - "test8b.cpp", "test8b.h", - "test9.h", "test9.cpp", - "test_dpointer.cpp", "test_dpointer.h", - NULL -}; - -static CompilerTestSet willFailCases = -{ - // where is that TQDir comming from? - //"test9.cpp", NULL - NULL -}; - - -void TDEConfigCompiler_Test::allTests() -{ - testExpectedOutput(); -} - -void TDEConfigCompiler_Test::testExpectedOutput() -{ - uint i = 0; - // Known to pass test cases - while (testCases[ i ]) - { - performCompare(TQString::fromLatin1(testCases[ i ])); - ++i; - } - - // broken test cases - i= 0; - while (willFailCases[ i ]) - { - performCompare(TQString::fromLatin1(willFailCases[ i ]), true); - ++i; - } -} - -void TDEConfigCompiler_Test::performCompare(const TQString &fileName, bool fail) -{ - TQFile file(fileName); - TQFile fileRef(TQString::fromLatin1(SRCDIR) + TQString::fromLatin1("/") + fileName + TQString::fromLatin1(".ref")); - - if ( file.open(IO_ReadOnly) && fileRef.open(IO_ReadOnly) ) - { - TQString content = file.readAll(); - TQString contentRef = fileRef.readAll(); - - if (!fail) - CHECK( content, contentRef); - else - XFAIL( content, contentRef); - } - else - { - SKIP("Can't open file for comparision"); - } -} diff --git a/tdecore/kconfig_compiler/tests/kconfigcompiler_test.h b/tdecore/kconfig_compiler/tests/kconfigcompiler_test.h deleted file mode 100644 index df3f4cf37..000000000 --- a/tdecore/kconfig_compiler/tests/kconfigcompiler_test.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Tests for TDEConfig Compiler - - Copyright (c) 2005 by Duncan Mac-Vicar - - ************************************************************************* - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - ************************************************************************* -*/ - -#ifndef KCONFIGCOMPILER_TEST_H -#define KCONFIGCOMPILER_TEST_H - -#include - -class TQString; - -// change to SlotTester when it works -class TDEConfigCompiler_Test : public KUnitTest::Tester -{ -public: - void allTests(); -public slots: - void testExpectedOutput(); -private: - void performCompare(const TQString &fileName, bool fail=false); -}; - -#endif - diff --git a/tdecore/kconfig_compiler/tests/myprefs.h b/tdecore/kconfig_compiler/tests/myprefs.h deleted file mode 100644 index 020dc6bfa..000000000 --- a/tdecore/kconfig_compiler/tests/myprefs.h +++ /dev/null @@ -1,7 +0,0 @@ -#include - -class MyPrefs : public TDEConfigSkeleton -{ - public: - MyPrefs( const TQString &a ) : TDEConfigSkeleton( a ) {} -}; diff --git a/tdecore/kconfig_compiler/tests/test1.cpp.ref b/tdecore/kconfig_compiler/tests/test1.cpp.ref deleted file mode 100644 index d0b6b76f1..000000000 --- a/tdecore/kconfig_compiler/tests/test1.cpp.ref +++ /dev/null @@ -1,72 +0,0 @@ -// This file is generated by kconfig_compiler from test1.kcfg. -// All changes you do to this file will be lost. - -#include "test1.h" - -Test1::Test1( const TQString & transport, const TQString & folder ) - : TDEConfigSkeleton( TQString::fromLatin1( "examplerc" ) ) - , mParamtransport(transport) - , mParamfolder(folder) -{ - setCurrentGroup( TQString::fromLatin1( "General-%1" ).arg( mParamfolder ) ); - - TDEConfigSkeleton::ItemBool *itemOneOption; - itemOneOption = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "OneOption" ), mOneOption, true ); - addItem( itemOneOption, TQString::fromLatin1( "OneOption" ) ); - TDEConfigSkeleton::ItemInt *itemAnotherOption; - itemAnotherOption = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Another Option" ), mAnotherOption, 5 ); - addItem( itemAnotherOption, TQString::fromLatin1( "AnotherOption" ) ); - TQValueList valuesListOption; - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "One" ); - valuesListOption.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "Two" ); - valuesListOption.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "Three" ); - valuesListOption.append( choice ); - } - TDEConfigSkeleton::ItemEnum *itemListOption; - itemListOption = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "ListOption" ), mListOption, valuesListOption, EnumListOption::One ); - addItem( itemListOption, TQString::fromLatin1( "ListOption" ) ); - - setCurrentGroup( TQString::fromLatin1( "MyOptions" ) ); - - TDEConfigSkeleton::ItemString *itemMyString; - itemMyString = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "MyString" ), mMyString, TQString::fromLatin1( "Default String" ) ); - addItem( itemMyString, TQString::fromLatin1( "MyString" ) ); - TDEConfigSkeleton::ItemPath *itemMyPath; - itemMyPath = new TDEConfigSkeleton::ItemPath( currentGroup(), TQString::fromLatin1( "MyPath" ), mMyPath, TQDir::homeDirPath()+TQString::fromLatin1(".hidden_file") ); - addItem( itemMyPath, TQString::fromLatin1( "MyPath" ) ); - TDEConfigSkeleton::ItemInt *itemAnotherOption2; - itemAnotherOption2 = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Another Option" ), mAnotherOption2, 10 ); - addItem( itemAnotherOption2, TQString::fromLatin1( "AnotherOption2" ) ); - TQStringList defaultMyStringList; - defaultMyStringList.append( TQString::fromUtf8( "up" ) ); - defaultMyStringList.append( TQString::fromUtf8( "down" ) ); - - TDEConfigSkeleton::ItemStringList *itemMyStringList; - itemMyStringList = new TDEConfigSkeleton::ItemStringList( currentGroup(), TQString::fromLatin1( "MyStringList" ), mMyStringList, defaultMyStringList ); - addItem( itemMyStringList, TQString::fromLatin1( "MyStringList" ) ); - TQStringList defaultMyStringListHidden; - defaultMyStringListHidden.append( TQString::fromUtf8( "up" ) ); - defaultMyStringListHidden.append( TQString::fromUtf8( "down" ) ); - - TDEConfigSkeleton::ItemStringList *itemMyStringListHidden; - itemMyStringListHidden = new TDEConfigSkeleton::ItemStringList( currentGroup(), TQString::fromLatin1( "MyStringListHidden" ), mMyStringListHidden, defaultMyStringListHidden ); - addItem( itemMyStringListHidden, TQString::fromLatin1( "MyStringListHidden" ) ); - TDEConfigSkeleton::ItemInt *itemMyNumber; - itemMyNumber = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "List-%1-%2" ).arg( mParamtransport ).arg( mParamfolder ), mMyNumber, 1 ); - addItem( itemMyNumber, TQString::fromLatin1( "MyNumber" ) ); -} - -Test1::~Test1() -{ -} - diff --git a/tdecore/kconfig_compiler/tests/test1.h.ref b/tdecore/kconfig_compiler/tests/test1.h.ref deleted file mode 100644 index 584dcb7ff..000000000 --- a/tdecore/kconfig_compiler/tests/test1.h.ref +++ /dev/null @@ -1,196 +0,0 @@ -// This file is generated by kconfig_compiler from test1.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST1_H -#define TEST1_H - -#include -#include - -#include -class Test1 : public TDEConfigSkeleton -{ - public: - class EnumListOption - { - public: - enum type { One, Two, Three, COUNT }; - }; - - Test1( const TQString & transport, const TQString & folder ); - ~Test1(); - - /** - Set One option - */ - void setOneOption( bool v ) - { - if (!isImmutable( TQString::fromLatin1( "OneOption" ) )) - mOneOption = v; - } - - /** - Get One option - */ - bool oneOption() const - { - return mOneOption; - } - - /** - Set Another option - */ - void setAnotherOption( int v ) - { - if (!isImmutable( TQString::fromLatin1( "AnotherOption" ) )) - mAnotherOption = v; - } - - /** - Get Another option - */ - int anotherOption() const - { - return mAnotherOption; - } - - /** - Set This is some funky option - */ - void setListOption( int v ) - { - if (!isImmutable( TQString::fromLatin1( "ListOption" ) )) - mListOption = v; - } - - /** - Get This is some funky option - */ - int listOption() const - { - return mListOption; - } - - /** - Set This is a string - */ - void setMyString( const TQString & v ) - { - if (!isImmutable( TQString::fromLatin1( "MyString" ) )) - mMyString = v; - } - - /** - Get This is a string - */ - TQString myString() const - { - return mMyString; - } - - /** - Set This is a path - */ - void setMyPath( const TQString & v ) - { - if (!isImmutable( TQString::fromLatin1( "MyPath" ) )) - mMyPath = v; - } - - /** - Get This is a path - */ - TQString myPath() const - { - return mMyPath; - } - - /** - Set Another option - */ - void setAnotherOption2( int v ) - { - if (!isImmutable( TQString::fromLatin1( "AnotherOption2" ) )) - mAnotherOption2 = v; - } - - /** - Get Another option - */ - int anotherOption2() const - { - return mAnotherOption2; - } - - /** - Set MyStringList - */ - void setMyStringList( const TQStringList & v ) - { - if (!isImmutable( TQString::fromLatin1( "MyStringList" ) )) - mMyStringList = v; - } - - /** - Get MyStringList - */ - TQStringList myStringList() const - { - return mMyStringList; - } - - /** - Set MyStringListHidden - */ - void setMyStringListHidden( const TQStringList & v ) - { - if (!isImmutable( TQString::fromLatin1( "MyStringListHidden" ) )) - mMyStringListHidden = v; - } - - /** - Get MyStringListHidden - */ - TQStringList myStringListHidden() const - { - return mMyStringListHidden; - } - - /** - Set List Number - */ - void setMyNumber( int v ) - { - if (!isImmutable( TQString::fromLatin1( "MyNumber" ) )) - mMyNumber = v; - } - - /** - Get List Number - */ - int myNumber() const - { - return mMyNumber; - } - - protected: - TQString mParamtransport; - TQString mParamfolder; - - // General-$(folder) - bool mOneOption; - int mAnotherOption; - int mListOption; - - // MyOptions - TQString mMyString; - TQString mMyPath; - int mAnotherOption2; - TQStringList mMyStringList; - TQStringList mMyStringListHidden; - int mMyNumber; - - private: -}; - -#endif - diff --git a/tdecore/kconfig_compiler/tests/test1.kcfg b/tdecore/kconfig_compiler/tests/test1.kcfg deleted file mode 100644 index ce42aebfb..000000000 --- a/tdecore/kconfig_compiler/tests/test1.kcfg +++ /dev/null @@ -1,55 +0,0 @@ - - - qdir.h - - - - - - - - true - - - - 5 - - - - And this is a longer description of this option. Just wondering, how will the translations of those be handled? - - - - - - One - - - - - - Default String - - - - QDir::homeDirPath()+QString::fromLatin1(".hidden_file") - - - - 10 - - - up,down - - - - - 1 - - - diff --git a/tdecore/kconfig_compiler/tests/test1.kcfgc b/tdecore/kconfig_compiler/tests/test1.kcfgc deleted file mode 100644 index ecab7b851..000000000 --- a/tdecore/kconfig_compiler/tests/test1.kcfgc +++ /dev/null @@ -1,18 +0,0 @@ -# Code generation options for kconfig_compiler -ClassName=Test1 -# -# Singleton=false -# -# Inherits=TDEConfigSkeleton -# -# IncludeFiles=libtdepim/kpimprefs.h -# -# MemberVariables=public -# -### The following line includes the file exampleprefs_base_addon.h -### It can be used to add extra functions and variables to the -### class. -# CustomAdditions=true -# -### Provide setFooBar(int) style functions -Mutators=true diff --git a/tdecore/kconfig_compiler/tests/test1main.cpp b/tdecore/kconfig_compiler/tests/test1main.cpp deleted file mode 100644 index 79546639f..000000000 --- a/tdecore/kconfig_compiler/tests/test1main.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2003 Cornelius Schumacher - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include "test1.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - TDEInstance i("test"); - Test1 *t = new Test1( TQString::null, TQString::null ); - delete t; -} diff --git a/tdecore/kconfig_compiler/tests/test2.cpp.ref b/tdecore/kconfig_compiler/tests/test2.cpp.ref deleted file mode 100644 index fe7b8af80..000000000 --- a/tdecore/kconfig_compiler/tests/test2.cpp.ref +++ /dev/null @@ -1,98 +0,0 @@ -// This file is generated by kconfig_compiler from test2.kcfg. -// All changes you do to this file will be lost. - -#include "test2.h" - -#include - -Test2::Test2( ) - : MyPrefs( TQString::fromLatin1( "korganizerrc" ) ) -{ - setCurrentGroup( TQString::fromLatin1( "General" ) ); - - mAutoSaveItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "Auto Save" ), mAutoSave, false ); - mAutoSaveItem->setLabel( i18n("Enable automatic saving of calendar") ); - mAutoSaveItem->setWhatsThis( i18n("WhatsThis text for AutoSave option") ); - addItem( mAutoSaveItem, TQString::fromLatin1( "AutoSave" ) ); - mAutoSaveIntervalItem = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Auto Save Interval" ), mAutoSaveInterval, 10 ); - mAutoSaveIntervalItem->setLabel( i18n("Auto Save Interval") ); - addItem( mAutoSaveIntervalItem, TQString::fromLatin1( "AutoSaveInterval" ) ); - mConfirmItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "Confirm Deletes" ), mConfirm, true ); - mConfirmItem->setLabel( i18n("Confirm deletes") ); - addItem( mConfirmItem, TQString::fromLatin1( "Confirm" ) ); - mArchiveFileItem = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "Archive File" ), mArchiveFile ); - mArchiveFileItem->setLabel( i18n("Archive File") ); - addItem( mArchiveFileItem, TQString::fromLatin1( "ArchiveFile" ) ); - TQValueList valuesDestination; - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "standardDestination" ); - valuesDestination.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "askDestination" ); - valuesDestination.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "argl1" ); - choice.label = i18n("Argl1 Label"); - valuesDestination.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "argl2" ); - choice.whatsThis = i18n("Argl2 Whatsthis"); - valuesDestination.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "argl3" ); - choice.label = i18n("Argl3 Label"); - choice.whatsThis = i18n("Argl3 Whatsthis"); - valuesDestination.append( choice ); - } - mDestinationItem = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "Destination" ), mDestination, valuesDestination, standardDestination ); - mDestinationItem->setLabel( i18n("New Events/Todos Should") ); - addItem( mDestinationItem, TQString::fromLatin1( "Destination" ) ); - - setCurrentGroup( TQString::fromLatin1( "Views" ) ); - - mHourSizeItem = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Hour Size" ), mHourSize, 10 ); - mHourSizeItem->setLabel( i18n("Hour Size") ); - addItem( mHourSizeItem, TQString::fromLatin1( "HourSize" ) ); - mSelectionStartsEditorItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "SelectionStartsEditor" ), mSelectionStartsEditor, false ); - mSelectionStartsEditorItem->setLabel( i18n("Time range selection in agenda view starts event editor") ); - addItem( mSelectionStartsEditorItem, TQString::fromLatin1( "SelectionStartsEditor" ) ); - - setCurrentGroup( TQString::fromLatin1( "KOrganizer Plugins" ) ); - - TQStringList defaultSelectedPlugins; - defaultSelectedPlugins.append( TQString::fromUtf8( "holidays" ) ); - defaultSelectedPlugins.append( TQString::fromUtf8( "webexport" ) ); - - mSelectedPluginsItem = new TDEConfigSkeleton::ItemStringList( currentGroup(), TQString::fromLatin1( "SelectedPlugins" ), mSelectedPlugins, defaultSelectedPlugins ); - mSelectedPluginsItem->setLabel( i18n("SelectedPlugins") ); - addItem( mSelectedPluginsItem, TQString::fromLatin1( "SelectedPlugins" ) ); - - setCurrentGroup( TQString::fromLatin1( "Colors" ) ); - - mHighlightColorItem = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "Highlight Color" ), mHighlightColor, TQColor( 100, 100, 255 ) ); - mHighlightColorItem->setLabel( i18n("Highlight color") ); - addItem( mHighlightColorItem, TQString::fromLatin1( "HighlightColor" ) ); - mAgendaBgColorItem = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "Agenda Background Color" ), mAgendaBgColor, TQColor( 255, 255, 255 ) ); - mAgendaBgColorItem->setLabel( i18n("Agenda view background color") ); - addItem( mAgendaBgColorItem, TQString::fromLatin1( "AgendaBgColor" ) ); - - setCurrentGroup( TQString::fromLatin1( "Fonts" ) ); - - mTimeBarFontItem = new TDEConfigSkeleton::ItemFont( currentGroup(), TQString::fromLatin1( "TimeBar Font" ), mTimeBarFont ); - mTimeBarFontItem->setLabel( i18n("Time bar") ); - addItem( mTimeBarFontItem, TQString::fromLatin1( "TimeBarFont" ) ); -} - -Test2::~Test2() -{ -} - diff --git a/tdecore/kconfig_compiler/tests/test2.h.ref b/tdecore/kconfig_compiler/tests/test2.h.ref deleted file mode 100644 index 6c0a74d66..000000000 --- a/tdecore/kconfig_compiler/tests/test2.h.ref +++ /dev/null @@ -1,333 +0,0 @@ -// This file is generated by kconfig_compiler from test2.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST2_H -#define TEST2_H - -#include - -#include -#include - -class Test2 : public MyPrefs -{ - public: - enum { standardDestination, askDestination, argl1, argl2, argl3 }; - - Test2( ); - ~Test2(); - - /** - Set Enable automatic saving of calendar - */ - void setAutoSave( bool v ) - { - if (!isImmutable( TQString::fromLatin1( "AutoSave" ) )) - mAutoSave = v; - } - - /** - Get Enable automatic saving of calendar - */ - bool autoSave() const - { - return mAutoSave; - } - - /** - Get Item object corresponding to AutoSave() - */ - ItemBool *autoSaveItem() - { - return mAutoSaveItem; - } - - /** - Set Auto Save Interval - */ - void setAutoSaveInterval( int v ) - { - if (!isImmutable( TQString::fromLatin1( "AutoSaveInterval" ) )) - mAutoSaveInterval = v; - } - - /** - Get Auto Save Interval - */ - int autoSaveInterval() const - { - return mAutoSaveInterval; - } - - /** - Get Item object corresponding to AutoSaveInterval() - */ - ItemInt *autoSaveIntervalItem() - { - return mAutoSaveIntervalItem; - } - - /** - Set Confirm deletes - */ - void setConfirm( bool v ) - { - if (!isImmutable( TQString::fromLatin1( "Confirm" ) )) - mConfirm = v; - } - - /** - Get Confirm deletes - */ - bool confirm() const - { - return mConfirm; - } - - /** - Get Item object corresponding to Confirm() - */ - ItemBool *confirmItem() - { - return mConfirmItem; - } - - /** - Set Archive File - */ - void setArchiveFile( const TQString & v ) - { - if (!isImmutable( TQString::fromLatin1( "ArchiveFile" ) )) - mArchiveFile = v; - } - - /** - Get Archive File - */ - TQString archiveFile() const - { - return mArchiveFile; - } - - /** - Get Item object corresponding to ArchiveFile() - */ - ItemString *archiveFileItem() - { - return mArchiveFileItem; - } - - /** - Set New Events/Todos Should - */ - void setDestination( int v ) - { - if (!isImmutable( TQString::fromLatin1( "Destination" ) )) - mDestination = v; - } - - /** - Get New Events/Todos Should - */ - int destination() const - { - return mDestination; - } - - /** - Get Item object corresponding to Destination() - */ - ItemEnum *destinationItem() - { - return mDestinationItem; - } - - /** - Set Hour Size - */ - void setHourSize( int v ) - { - if (!isImmutable( TQString::fromLatin1( "HourSize" ) )) - mHourSize = v; - } - - /** - Get Hour Size - */ - int hourSize() const - { - return mHourSize; - } - - /** - Get Item object corresponding to HourSize() - */ - ItemInt *hourSizeItem() - { - return mHourSizeItem; - } - - /** - Set Time range selection in agenda view starts event editor - */ - void setSelectionStartsEditor( bool v ) - { - if (!isImmutable( TQString::fromLatin1( "SelectionStartsEditor" ) )) - mSelectionStartsEditor = v; - } - - /** - Get Time range selection in agenda view starts event editor - */ - bool selectionStartsEditor() const - { - return mSelectionStartsEditor; - } - - /** - Get Item object corresponding to SelectionStartsEditor() - */ - ItemBool *selectionStartsEditorItem() - { - return mSelectionStartsEditorItem; - } - - /** - Set SelectedPlugins - */ - void setSelectedPlugins( const TQStringList & v ) - { - if (!isImmutable( TQString::fromLatin1( "SelectedPlugins" ) )) - mSelectedPlugins = v; - } - - /** - Get SelectedPlugins - */ - TQStringList selectedPlugins() const - { - return mSelectedPlugins; - } - - /** - Get Item object corresponding to SelectedPlugins() - */ - ItemStringList *selectedPluginsItem() - { - return mSelectedPluginsItem; - } - - /** - Set Highlight color - */ - void setHighlightColor( const TQColor & v ) - { - if (!isImmutable( TQString::fromLatin1( "HighlightColor" ) )) - mHighlightColor = v; - } - - /** - Get Highlight color - */ - TQColor highlightColor() const - { - return mHighlightColor; - } - - /** - Get Item object corresponding to HighlightColor() - */ - ItemColor *highlightColorItem() - { - return mHighlightColorItem; - } - - /** - Set Agenda view background color - */ - void setAgendaBgColor( const TQColor & v ) - { - if (!isImmutable( TQString::fromLatin1( "AgendaBgColor" ) )) - mAgendaBgColor = v; - } - - /** - Get Agenda view background color - */ - TQColor agendaBgColor() const - { - return mAgendaBgColor; - } - - /** - Get Item object corresponding to AgendaBgColor() - */ - ItemColor *agendaBgColorItem() - { - return mAgendaBgColorItem; - } - - /** - Set Time bar - */ - void setTimeBarFont( const TQFont & v ) - { - if (!isImmutable( TQString::fromLatin1( "TimeBarFont" ) )) - mTimeBarFont = v; - } - - /** - Get Time bar - */ - TQFont timeBarFont() const - { - return mTimeBarFont; - } - - /** - Get Item object corresponding to TimeBarFont() - */ - ItemFont *timeBarFontItem() - { - return mTimeBarFontItem; - } - - protected: - public: - - // General - bool mAutoSave; - int mAutoSaveInterval; - bool mConfirm; - TQString mArchiveFile; - int mDestination; - - // Views - int mHourSize; - bool mSelectionStartsEditor; - - // KOrganizer Plugins - TQStringList mSelectedPlugins; - - // Colors - TQColor mHighlightColor; - TQColor mAgendaBgColor; - - // Fonts - TQFont mTimeBarFont; - - private: - ItemBool *mAutoSaveItem; - ItemInt *mAutoSaveIntervalItem; - ItemBool *mConfirmItem; - ItemString *mArchiveFileItem; - ItemEnum *mDestinationItem; - ItemInt *mHourSizeItem; - ItemBool *mSelectionStartsEditorItem; - ItemStringList *mSelectedPluginsItem; - ItemColor *mHighlightColorItem; - ItemColor *mAgendaBgColorItem; - ItemFont *mTimeBarFontItem; -}; - -#endif - diff --git a/tdecore/kconfig_compiler/tests/test2.kcfg b/tdecore/kconfig_compiler/tests/test2.kcfg deleted file mode 100644 index 3b19e270e..000000000 --- a/tdecore/kconfig_compiler/tests/test2.kcfg +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - WhatsThis text for AutoSave option - false - - - 10 - - - - true - - - - - - - - - - - - - - - Argl2 Whatsthis - - - - Argl3 Whatsthis - - - standardDestination - - - - - - 10 - - - - false - - - - - - holidays,webexport - - - - - - - 100, 100, 255 - - - - 255, 255, 255 - - - - - - - - - - diff --git a/tdecore/kconfig_compiler/tests/test2.kcfgc b/tdecore/kconfig_compiler/tests/test2.kcfgc deleted file mode 100644 index 56620d2f4..000000000 --- a/tdecore/kconfig_compiler/tests/test2.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test2.kcfg -ClassName=Test2 -Singleton=false -Mutators=true -Inherits=MyPrefs -IncludeFiles=myprefs.h -MemberVariables=public -GlobalEnums=true -ItemAccessors=true -SetUserTexts=true diff --git a/tdecore/kconfig_compiler/tests/test2main.cpp b/tdecore/kconfig_compiler/tests/test2main.cpp deleted file mode 100644 index 5970bf03d..000000000 --- a/tdecore/kconfig_compiler/tests/test2main.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2003 Cornelius Schumacher - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include "test2.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - TDEInstance i("test"); - Test2 *t = new Test2(); - delete t; -} diff --git a/tdecore/kconfig_compiler/tests/test3.cpp.ref b/tdecore/kconfig_compiler/tests/test3.cpp.ref deleted file mode 100644 index 3bd0eb8c9..000000000 --- a/tdecore/kconfig_compiler/tests/test3.cpp.ref +++ /dev/null @@ -1,29 +0,0 @@ -// This file is generated by kconfig_compiler from test3.kcfg. -// All changes you do to this file will be lost. - -#include "test3.h" - -using namespace TestNameSpace; - -Test3::Test3( ) - : TDEConfigSkeleton( TQString::fromLatin1( "test3rc" ) ) -{ - setCurrentGroup( TQString::fromLatin1( "General" ) ); - - mAutoSaveItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "Auto Save" ), mAutoSave, false ); - addItem( mAutoSaveItem, TQString::fromLatin1( "AutoSave" ) ); - - setCurrentGroup( TQString::fromLatin1( "Blah" ) ); - - mBlubbItem = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Blubb" ), mBlubb, 10 ); - addItem( mBlubbItem, TQString::fromLatin1( "Blubb" ) ); - mBlahBlahItem = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "BlahBlah" ), mBlahBlah, TQString::fromLatin1( "a string" ) ); - addItem( mBlahBlahItem, TQString::fromLatin1( "BlahBlah" ) ); - mMyPasswordItem = new TDEConfigSkeleton::ItemPassword( currentGroup(), TQString::fromLatin1( "MyPassword" ), mMyPassword ); - addItem( mMyPasswordItem, TQString::fromLatin1( "MyPassword" ) ); -} - -Test3::~Test3() -{ -} - diff --git a/tdecore/kconfig_compiler/tests/test3.h.ref b/tdecore/kconfig_compiler/tests/test3.h.ref deleted file mode 100644 index 4c35a138a..000000000 --- a/tdecore/kconfig_compiler/tests/test3.h.ref +++ /dev/null @@ -1,138 +0,0 @@ -// This file is generated by kconfig_compiler from test3.kcfg. -// All changes you do to this file will be lost. -#ifndef TESTNAMESPACE_TEST3_H -#define TESTNAMESPACE_TEST3_H - -#include -#include - -namespace TestNameSpace { - -class Test3 : public TDEConfigSkeleton -{ - public: - - Test3( ); - ~Test3(); - - /** - Set Enable automatic saving of calendar - */ - void setAutoSave( bool v ) - { - if (!isImmutable( TQString::fromLatin1( "AutoSave" ) )) - mAutoSave = v; - } - - /** - Get Enable automatic saving of calendar - */ - bool autoSave() const - { - return mAutoSave; - } - - /** - Get Item object corresponding to AutoSave() - */ - ItemBool *autoSaveItem() - { - return mAutoSaveItem; - } - - /** - Set Blubb - */ - void setBlubb( int v ) - { - if (!isImmutable( TQString::fromLatin1( "Blubb" ) )) - mBlubb = v; - } - - /** - Get Blubb - */ - int blubb() const - { - return mBlubb; - } - - /** - Get Item object corresponding to Blubb() - */ - ItemInt *blubbItem() - { - return mBlubbItem; - } - - /** - Set BlahBlah - */ - void setBlahBlah( const TQString & v ) - { - if (!isImmutable( TQString::fromLatin1( "BlahBlah" ) )) - mBlahBlah = v; - } - - /** - Get BlahBlah - */ - TQString blahBlah() const - { - return mBlahBlah; - } - - /** - Get Item object corresponding to BlahBlah() - */ - ItemString *blahBlahItem() - { - return mBlahBlahItem; - } - - /** - Set MyPassword - */ - void setMyPassword( const TQString & v ) - { - if (!isImmutable( TQString::fromLatin1( "MyPassword" ) )) - mMyPassword = v; - } - - /** - Get MyPassword - */ - TQString myPassword() const - { - return mMyPassword; - } - - /** - Get Item object corresponding to MyPassword() - */ - ItemPassword *myPasswordItem() - { - return mMyPasswordItem; - } - - protected: - - // General - bool mAutoSave; - - // Blah - int mBlubb; - TQString mBlahBlah; - TQString mMyPassword; - - private: - ItemBool *mAutoSaveItem; - ItemInt *mBlubbItem; - ItemString *mBlahBlahItem; - ItemPassword *mMyPasswordItem; -}; - -} - -#endif - diff --git a/tdecore/kconfig_compiler/tests/test3.kcfg b/tdecore/kconfig_compiler/tests/test3.kcfg deleted file mode 100644 index 77916da40..000000000 --- a/tdecore/kconfig_compiler/tests/test3.kcfg +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - WhatsThis text for AutoSave option - false - - - - - - 10 - - - a string - - - - - diff --git a/tdecore/kconfig_compiler/tests/test3.kcfgc b/tdecore/kconfig_compiler/tests/test3.kcfgc deleted file mode 100644 index ca2c22057..000000000 --- a/tdecore/kconfig_compiler/tests/test3.kcfgc +++ /dev/null @@ -1,12 +0,0 @@ -# Code generation options for kconfig_compiler -File=test3.kcfg -NameSpace=TestNameSpace -ClassName=Test3 -#Singleton=false -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -#MemberVariables=public -GlobalEnums=true -ItemAccessors=true -#SetUserTexts=true diff --git a/tdecore/kconfig_compiler/tests/test3main.cpp b/tdecore/kconfig_compiler/tests/test3main.cpp deleted file mode 100644 index f73ae38e3..000000000 --- a/tdecore/kconfig_compiler/tests/test3main.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2003 Cornelius Schumacher - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include "test3.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - TDEInstance i("test"); - TestNameSpace::Test3 *t = new TestNameSpace::Test3(); - delete t; -} diff --git a/tdecore/kconfig_compiler/tests/test4.cpp.ref b/tdecore/kconfig_compiler/tests/test4.cpp.ref deleted file mode 100644 index c6b29bec2..000000000 --- a/tdecore/kconfig_compiler/tests/test4.cpp.ref +++ /dev/null @@ -1,82 +0,0 @@ -// This file is generated by kconfig_compiler from test4.kcfg. -// All changes you do to this file will be lost. - -#include "test4.h" - -#include - -Test4 *Test4::mSelf = 0; -static KStaticDeleter staticTest4Deleter; - -Test4 *Test4::self() -{ - if ( !mSelf ) { - staticTest4Deleter.setObject( mSelf, new Test4() ); - mSelf->readConfig(); - } - - return mSelf; -} - -const char* const Test4::EnumButton::enumToString[] = { "right", "mid", "left" }; - -Test4::Test4( ) - : TDEConfigSkeleton( TQString::fromLatin1( "test4rc" ) ) -{ - mSelf = this; - setCurrentGroup( TQString::fromLatin1( "Foo" ) ); - -TQColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; - TDEConfigSkeleton::ItemColor *itemColor[4]; - itemColor[0] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #0" ), mColor[0], defaultColor[0] ); - addItem( itemColor[0], TQString::fromLatin1( "Color0" ) ); - itemColor[1] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #1" ), mColor[1], defaultColor[1] ); - addItem( itemColor[1], TQString::fromLatin1( "Color1" ) ); - itemColor[2] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #2" ), mColor[2], defaultColor[2] ); - addItem( itemColor[2], TQString::fromLatin1( "Color2" ) ); - itemColor[3] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #3" ), mColor[3], defaultColor[3] ); - addItem( itemColor[3], TQString::fromLatin1( "Color3" ) ); - TQValueList valuesMouseAction; - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "Encrypt" ); - valuesMouseAction.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "Decrypt" ); - valuesMouseAction.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "CrashNBurn" ); - valuesMouseAction.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "PumpNDump" ); - valuesMouseAction.append( choice ); - } - TDEConfigSkeleton::ItemEnum *itemMouseAction[3]; - itemMouseAction[0] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "right_mouse_action" ), mMouseAction[0], valuesMouseAction, EnumMouseAction::Decrypt ); - addItem( itemMouseAction[0], TQString::fromLatin1( "MouseActionright" ) ); - itemMouseAction[1] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "mid_mouse_action" ), mMouseAction[1], valuesMouseAction, EnumMouseAction::Encrypt ); - addItem( itemMouseAction[1], TQString::fromLatin1( "MouseActionmid" ) ); - itemMouseAction[2] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "left_mouse_action" ), mMouseAction[2], valuesMouseAction, EnumMouseAction::PumpNDump ); - addItem( itemMouseAction[2], TQString::fromLatin1( "MouseActionleft" ) ); - TDEConfigSkeleton::ItemString *itemFooBar; - itemFooBar = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "foo bar" ), mFooBar ); - addItem( itemFooBar, TQString::fromLatin1( "FooBar" ) ); - TDEConfigSkeleton::ItemInt *itemAge; - itemAge = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Age" ), mAge, 35 ); - itemAge->setMinValue(8); - itemAge->setMaxValue(88); - addItem( itemAge, TQString::fromLatin1( "Age" ) ); -} - -Test4::~Test4() -{ - if ( mSelf == this ) - staticTest4Deleter.setObject( mSelf, 0, false ); -} - diff --git a/tdecore/kconfig_compiler/tests/test4.h.ref b/tdecore/kconfig_compiler/tests/test4.h.ref deleted file mode 100644 index 9457413a1..000000000 --- a/tdecore/kconfig_compiler/tests/test4.h.ref +++ /dev/null @@ -1,135 +0,0 @@ -// This file is generated by kconfig_compiler from test4.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST4_H -#define TEST4_H - -#include -#include - -class Test4 : public TDEConfigSkeleton -{ - public: - class EnumMouseAction - { - public: - enum type { Encrypt, Decrypt, CrashNBurn, PumpNDump, COUNT }; - }; - class EnumButton - { - public: - enum type { right, mid, left, COUNT }; - static const char* const enumToString[]; - }; - - static Test4 *self(); - ~Test4(); - - /** - Set Block colors. - */ - static - void setColor( int i, const TQColor & v ) - { - if (!self()->isImmutable( TQString::fromLatin1( "Color%1" ).arg( i ) )) - self()->mColor[i] = v; - } - - /** - Get Block colors. - */ - static - TQColor color( int i ) - { - return self()->mColor[i]; - } - - /** - Set Mouse actions. - */ - static - void setMouseAction( int i, int v ) - { - if (!self()->isImmutable( TQString::fromLatin1( "MouseAction%1" ).arg( TQString::fromLatin1( EnumButton::enumToString[i] ) ) )) - self()->mMouseAction[i] = v; - } - - /** - Get Mouse actions. - */ - static - int mouseAction( int i ) - { - return self()->mMouseAction[i]; - } - - /** - Set foo bar - */ - static - void setFooBar( const TQString & v ) - { - if (!self()->isImmutable( TQString::fromLatin1( "FooBar" ) )) - self()->mFooBar = v; - } - - /** - Get foo bar - */ - static - TQString fooBar() - { - return self()->mFooBar; - } - - /** - Set Age - */ - static - void setAge( int v ) - { - if (v < 8) - { - kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; - v = 8; - } - - if (v > 88) - { - kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; - v = 88; - } - - if (!self()->isImmutable( TQString::fromLatin1( "Age" ) )) - self()->mAge = v; - } - - /** - Get Age - */ - static - int age() - { - return self()->mAge; - } - - static - void writeConfig() - { - static_cast(self())->writeConfig(); - } - protected: - Test4(); - static Test4 *mSelf; - - - // Foo - TQColor mColor[4]; - int mMouseAction[3]; - TQString mFooBar; - int mAge; - - private: -}; - -#endif - diff --git a/tdecore/kconfig_compiler/tests/test4.kcfg b/tdecore/kconfig_compiler/tests/test4.kcfg deleted file mode 100644 index d8ef2bfae..000000000 --- a/tdecore/kconfig_compiler/tests/test4.kcfg +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; - defaultColor[$(Number)] - - - - - right - mid - left - - - - - - - - - - Decrypt - Encrypt - PumpNDump - - - - 35 - 8 - 88 - - - - diff --git a/tdecore/kconfig_compiler/tests/test4.kcfgc b/tdecore/kconfig_compiler/tests/test4.kcfgc deleted file mode 100644 index 754706dff..000000000 --- a/tdecore/kconfig_compiler/tests/test4.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test4.kcfg -ClassName=Test4 -Singleton=true -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -#MemberVariables=public -GlobalEnums=false -ItemAccessors=false -#SetUserTexts=true diff --git a/tdecore/kconfig_compiler/tests/test4main.cpp b/tdecore/kconfig_compiler/tests/test4main.cpp deleted file mode 100644 index 5229d8a87..000000000 --- a/tdecore/kconfig_compiler/tests/test4main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 2003,2004 Waldo Bastian - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "test4.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - TDEInstance i("test"); - Test4 *t = Test4::self(); - delete t; -} diff --git a/tdecore/kconfig_compiler/tests/test5.cpp.ref b/tdecore/kconfig_compiler/tests/test5.cpp.ref deleted file mode 100644 index 9e295bc0e..000000000 --- a/tdecore/kconfig_compiler/tests/test5.cpp.ref +++ /dev/null @@ -1,82 +0,0 @@ -// This file is generated by kconfig_compiler from test5.kcfg. -// All changes you do to this file will be lost. - -#include "test5.h" - -#include - -Test5 *Test5::mSelf = 0; -static KStaticDeleter staticTest5Deleter; - -Test5 *Test5::self() -{ - if ( !mSelf ) { - staticTest5Deleter.setObject( mSelf, new Test5() ); - mSelf->readConfig(); - } - - return mSelf; -} - -const char* const Test5::EnumButtonToString[] = { "right", "mid", "left" }; - -Test5::Test5( ) - : TDEConfigSkeleton( TQString::fromLatin1( "test4rc" ) ) -{ - mSelf = this; - setCurrentGroup( TQString::fromLatin1( "Foo" ) ); - -TQColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; - TDEConfigSkeleton::ItemColor *itemColor[4]; - itemColor[0] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #0" ), mColor[0], defaultColor[0] ); - addItem( itemColor[0], TQString::fromLatin1( "Color0" ) ); - itemColor[1] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #1" ), mColor[1], defaultColor[1] ); - addItem( itemColor[1], TQString::fromLatin1( "Color1" ) ); - itemColor[2] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #2" ), mColor[2], defaultColor[2] ); - addItem( itemColor[2], TQString::fromLatin1( "Color2" ) ); - itemColor[3] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #3" ), mColor[3], defaultColor[3] ); - addItem( itemColor[3], TQString::fromLatin1( "Color3" ) ); - TQValueList valuesMouseAction; - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "Encrypt" ); - valuesMouseAction.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "Decrypt" ); - valuesMouseAction.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "CrashNBurn" ); - valuesMouseAction.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "PumpNDump" ); - valuesMouseAction.append( choice ); - } - TDEConfigSkeleton::ItemEnum *itemMouseAction[3]; - itemMouseAction[0] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "right_mouse_action" ), mMouseAction[0], valuesMouseAction, Decrypt ); - addItem( itemMouseAction[0], TQString::fromLatin1( "MouseActionright" ) ); - itemMouseAction[1] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "mid_mouse_action" ), mMouseAction[1], valuesMouseAction, Encrypt ); - addItem( itemMouseAction[1], TQString::fromLatin1( "MouseActionmid" ) ); - itemMouseAction[2] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "left_mouse_action" ), mMouseAction[2], valuesMouseAction, PumpNDump ); - addItem( itemMouseAction[2], TQString::fromLatin1( "MouseActionleft" ) ); - TDEConfigSkeleton::ItemString *itemFooBar; - itemFooBar = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "foo bar" ), mFooBar ); - addItem( itemFooBar, TQString::fromLatin1( "FooBar" ) ); - TDEConfigSkeleton::ItemInt *itemAge; - itemAge = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Age" ), mAge, 35 ); - itemAge->setMinValue(8); - itemAge->setMaxValue(88); - addItem( itemAge, TQString::fromLatin1( "Age" ) ); -} - -Test5::~Test5() -{ - if ( mSelf == this ) - staticTest5Deleter.setObject( mSelf, 0, false ); -} - diff --git a/tdecore/kconfig_compiler/tests/test5.h.ref b/tdecore/kconfig_compiler/tests/test5.h.ref deleted file mode 100644 index 274da4761..000000000 --- a/tdecore/kconfig_compiler/tests/test5.h.ref +++ /dev/null @@ -1,127 +0,0 @@ -// This file is generated by kconfig_compiler from test5.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST5_H -#define TEST5_H - -#include -#include - -class Test5 : public TDEConfigSkeleton -{ - public: - enum { Encrypt, Decrypt, CrashNBurn, PumpNDump }; - enum { right, mid, left }; - static const char* const EnumButtonToString[]; - - static Test5 *self(); - ~Test5(); - - /** - Set Block colors. - */ - static - void setColor( int i, const TQColor & v ) - { - if (!self()->isImmutable( TQString::fromLatin1( "Color%1" ).arg( i ) )) - self()->mColor[i] = v; - } - - /** - Get Block colors. - */ - static - TQColor color( int i ) - { - return self()->mColor[i]; - } - - /** - Set Mouse actions. - */ - static - void setMouseAction( int i, int v ) - { - if (!self()->isImmutable( TQString::fromLatin1( "MouseAction%1" ).arg( TQString::fromLatin1( EnumButtonToString[i] ) ) )) - self()->mMouseAction[i] = v; - } - - /** - Get Mouse actions. - */ - static - int mouseAction( int i ) - { - return self()->mMouseAction[i]; - } - - /** - Set foo bar - */ - static - void setFooBar( const TQString & v ) - { - if (!self()->isImmutable( TQString::fromLatin1( "FooBar" ) )) - self()->mFooBar = v; - } - - /** - Get foo bar - */ - static - TQString fooBar() - { - return self()->mFooBar; - } - - /** - Set Age - */ - static - void setAge( int v ) - { - if (v < 8) - { - kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; - v = 8; - } - - if (v > 88) - { - kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; - v = 88; - } - - if (!self()->isImmutable( TQString::fromLatin1( "Age" ) )) - self()->mAge = v; - } - - /** - Get Age - */ - static - int age() - { - return self()->mAge; - } - - static - void writeConfig() - { - static_cast(self())->writeConfig(); - } - protected: - Test5(); - static Test5 *mSelf; - - - // Foo - TQColor mColor[4]; - int mMouseAction[3]; - TQString mFooBar; - int mAge; - - private: -}; - -#endif - diff --git a/tdecore/kconfig_compiler/tests/test5.kcfg b/tdecore/kconfig_compiler/tests/test5.kcfg deleted file mode 100644 index d8ef2bfae..000000000 --- a/tdecore/kconfig_compiler/tests/test5.kcfg +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; - defaultColor[$(Number)] - - - - - right - mid - left - - - - - - - - - - Decrypt - Encrypt - PumpNDump - - - - 35 - 8 - 88 - - - - diff --git a/tdecore/kconfig_compiler/tests/test5.kcfgc b/tdecore/kconfig_compiler/tests/test5.kcfgc deleted file mode 100644 index 663005e5e..000000000 --- a/tdecore/kconfig_compiler/tests/test5.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test5.kcfg -ClassName=Test5 -Singleton=true -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -#MemberVariables=public -GlobalEnums=true -ItemAccessors=false -#SetUserTexts=true diff --git a/tdecore/kconfig_compiler/tests/test5main.cpp b/tdecore/kconfig_compiler/tests/test5main.cpp deleted file mode 100644 index 89f28587f..000000000 --- a/tdecore/kconfig_compiler/tests/test5main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 2004 Waldo Bastian - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "test5.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - TDEInstance i("test"); - Test5 *t = Test5::self(); - delete t; -} diff --git a/tdecore/kconfig_compiler/tests/test6.cpp.ref b/tdecore/kconfig_compiler/tests/test6.cpp.ref deleted file mode 100644 index fc19613a9..000000000 --- a/tdecore/kconfig_compiler/tests/test6.cpp.ref +++ /dev/null @@ -1,31 +0,0 @@ -// This file is generated by kconfig_compiler from test6.kcfg. -// All changes you do to this file will be lost. - -#include "test6.h" - -Test6::Test6( const TQString & Number ) - : TDEConfigSkeleton( TQString::fromLatin1( "test4rc" ) ) - , mParamNumber(Number) -{ - setCurrentGroup( TQString::fromLatin1( "Foo" ) ); - - TDEConfigSkeleton::ItemColor *itemColor; - itemColor = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #%1" ).arg( mParamNumber ), mColor, TQColor( "red" ) ); - addItem( itemColor, TQString::fromLatin1( "Color" ) ); - - setCurrentGroup( TQString::fromLatin1( "Bar%1" ).arg( mParamNumber ) ); - - TDEConfigSkeleton::ItemString *itemFooBar; - itemFooBar = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "foo bar" ), mFooBar ); - addItem( itemFooBar, TQString::fromLatin1( "FooBar" ) ); - TDEConfigSkeleton::ItemInt *itemAge; - itemAge = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Age" ), mAge, 35 ); - itemAge->setMinValue(8); - itemAge->setMaxValue(88); - addItem( itemAge, TQString::fromLatin1( "Age" ) ); -} - -Test6::~Test6() -{ -} - diff --git a/tdecore/kconfig_compiler/tests/test6.h.ref b/tdecore/kconfig_compiler/tests/test6.h.ref deleted file mode 100644 index eee776b5a..000000000 --- a/tdecore/kconfig_compiler/tests/test6.h.ref +++ /dev/null @@ -1,93 +0,0 @@ -// This file is generated by kconfig_compiler from test6.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST6_H -#define TEST6_H - -#include -#include - -class Test6 : public TDEConfigSkeleton -{ - public: - - Test6( const TQString & Number ); - ~Test6(); - - /** - Set Block colors. - */ - void setColor( const TQColor & v ) - { - if (!isImmutable( TQString::fromLatin1( "Color" ) )) - mColor = v; - } - - /** - Get Block colors. - */ - TQColor color() const - { - return mColor; - } - - /** - Set foo bar - */ - void setFooBar( const TQString & v ) - { - if (!isImmutable( TQString::fromLatin1( "FooBar" ) )) - mFooBar = v; - } - - /** - Get foo bar - */ - TQString fooBar() const - { - return mFooBar; - } - - /** - Set Age - */ - void setAge( int v ) - { - if (v < 8) - { - kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; - v = 8; - } - - if (v > 88) - { - kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; - v = 88; - } - - if (!isImmutable( TQString::fromLatin1( "Age" ) )) - mAge = v; - } - - /** - Get Age - */ - int age() const - { - return mAge; - } - - protected: - TQString mParamNumber; - - // Foo - TQColor mColor; - - // Bar$(Number) - TQString mFooBar; - int mAge; - - private: -}; - -#endif - diff --git a/tdecore/kconfig_compiler/tests/test6.kcfg b/tdecore/kconfig_compiler/tests/test6.kcfg deleted file mode 100644 index e59fa88f3..000000000 --- a/tdecore/kconfig_compiler/tests/test6.kcfg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - red - - - - - - 35 - 8 - 88 - - - - diff --git a/tdecore/kconfig_compiler/tests/test6.kcfgc b/tdecore/kconfig_compiler/tests/test6.kcfgc deleted file mode 100644 index b69dc152d..000000000 --- a/tdecore/kconfig_compiler/tests/test6.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test6.kcfg -ClassName=Test6 -Singleton=false -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -#MemberVariables=public -GlobalEnums=true -ItemAccessors=false -#SetUserTexts=true diff --git a/tdecore/kconfig_compiler/tests/test6main.cpp b/tdecore/kconfig_compiler/tests/test6main.cpp deleted file mode 100644 index 9b1b7503e..000000000 --- a/tdecore/kconfig_compiler/tests/test6main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 2004 Waldo Bastian - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "test6.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - TDEInstance i("test"); - Test6 *t = new Test6(TQString::null); - delete t; -} diff --git a/tdecore/kconfig_compiler/tests/test7.cpp.ref b/tdecore/kconfig_compiler/tests/test7.cpp.ref deleted file mode 100644 index 81f7de10e..000000000 --- a/tdecore/kconfig_compiler/tests/test7.cpp.ref +++ /dev/null @@ -1,31 +0,0 @@ -// This file is generated by kconfig_compiler from test7.kcfg. -// All changes you do to this file will be lost. - -#include "test7.h" - -Test7::Test7( int Number ) - : TDEConfigSkeleton( TQString::fromLatin1( "test7rc" ) ) - , mParamNumber(Number) -{ - setCurrentGroup( TQString::fromLatin1( "Foo" ) ); - - TDEConfigSkeleton::ItemColor *itemColor; - itemColor = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #%1" ).arg( mParamNumber ), mColor, TQColor( "red" ) ); - addItem( itemColor, TQString::fromLatin1( "Color" ) ); - - setCurrentGroup( TQString::fromLatin1( "Bar%1" ).arg( mParamNumber ) ); - - TDEConfigSkeleton::ItemString *itemFooBar; - itemFooBar = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "foo bar" ), mFooBar ); - addItem( itemFooBar, TQString::fromLatin1( "FooBar" ) ); - TDEConfigSkeleton::ItemInt *itemAge; - itemAge = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Age" ), mAge, 35 ); - itemAge->setMinValue(8); - itemAge->setMaxValue(88); - addItem( itemAge, TQString::fromLatin1( "Age" ) ); -} - -Test7::~Test7() -{ -} - diff --git a/tdecore/kconfig_compiler/tests/test7.h.ref b/tdecore/kconfig_compiler/tests/test7.h.ref deleted file mode 100644 index fb6dd6c77..000000000 --- a/tdecore/kconfig_compiler/tests/test7.h.ref +++ /dev/null @@ -1,93 +0,0 @@ -// This file is generated by kconfig_compiler from test7.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST7_H -#define TEST7_H - -#include -#include - -class Test7 : public TDEConfigSkeleton -{ - public: - - Test7( int Number ); - ~Test7(); - - /** - Set Block colors. - */ - void setColor( const TQColor & v ) - { - if (!isImmutable( TQString::fromLatin1( "Color" ) )) - mColor = v; - } - - /** - Get Block colors. - */ - TQColor color() const - { - return mColor; - } - - /** - Set foo bar - */ - void setFooBar( const TQString & v ) - { - if (!isImmutable( TQString::fromLatin1( "FooBar" ) )) - mFooBar = v; - } - - /** - Get foo bar - */ - TQString fooBar() const - { - return mFooBar; - } - - /** - Set Age - */ - void setAge( int v ) - { - if (v < 8) - { - kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; - v = 8; - } - - if (v > 88) - { - kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; - v = 88; - } - - if (!isImmutable( TQString::fromLatin1( "Age" ) )) - mAge = v; - } - - /** - Get Age - */ - int age() const - { - return mAge; - } - - protected: - int mParamNumber; - - // Foo - TQColor mColor; - - // Bar$(Number) - TQString mFooBar; - int mAge; - - private: -}; - -#endif - diff --git a/tdecore/kconfig_compiler/tests/test7.kcfg b/tdecore/kconfig_compiler/tests/test7.kcfg deleted file mode 100644 index 0a7fd3272..000000000 --- a/tdecore/kconfig_compiler/tests/test7.kcfg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - red - - - - - - 35 - 8 - 88 - - - - diff --git a/tdecore/kconfig_compiler/tests/test7.kcfgc b/tdecore/kconfig_compiler/tests/test7.kcfgc deleted file mode 100644 index 9a6c40954..000000000 --- a/tdecore/kconfig_compiler/tests/test7.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test7.kcfg -ClassName=Test7 -Singleton=false -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -#MemberVariables=public -GlobalEnums=true -ItemAccessors=false -#SetUserTexts=true diff --git a/tdecore/kconfig_compiler/tests/test7main.cpp b/tdecore/kconfig_compiler/tests/test7main.cpp deleted file mode 100644 index 81cca0184..000000000 --- a/tdecore/kconfig_compiler/tests/test7main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 2004 Waldo Bastian - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "test7.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - TDEInstance i("test"); - Test7 *t = new Test7(42); - delete t; -} diff --git a/tdecore/kconfig_compiler/tests/test8a.cpp.ref b/tdecore/kconfig_compiler/tests/test8a.cpp.ref deleted file mode 100644 index c0267452d..000000000 --- a/tdecore/kconfig_compiler/tests/test8a.cpp.ref +++ /dev/null @@ -1,22 +0,0 @@ -// This file is generated by kconfig_compiler from test8a.kcfg. -// All changes you do to this file will be lost. - -#include "test8a.h" - -Test8a::Test8a( KSharedConfig::Ptr config ) - : TDEConfigSkeleton( config ) -{ - setCurrentGroup( TQString::fromLatin1( "Group" ) ); - - TDEConfigSkeleton::ItemFont *itemFont; - itemFont = new TDEConfigSkeleton::ItemFont( currentGroup(), TQString::fromLatin1( "Font" ), mFont, TDEGlobalSettings::generalFont() ); - addItem( itemFont, TQString::fromLatin1( "Font" ) ); - TDEConfigSkeleton::ItemFont *itemTitleFont; - itemTitleFont = new TDEConfigSkeleton::ItemFont( currentGroup(), TQString::fromLatin1( "TitleFont" ), mTitleFont, TDEGlobalSettings::windowTitleFont() ); - addItem( itemTitleFont, TQString::fromLatin1( "TitleFont" ) ); -} - -Test8a::~Test8a() -{ -} - diff --git a/tdecore/kconfig_compiler/tests/test8a.h.ref b/tdecore/kconfig_compiler/tests/test8a.h.ref deleted file mode 100644 index 747c6dd58..000000000 --- a/tdecore/kconfig_compiler/tests/test8a.h.ref +++ /dev/null @@ -1,61 +0,0 @@ -// This file is generated by kconfig_compiler from test8a.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST8A_H -#define TEST8A_H - -#include -#include -#include - -class Test8a : public TDEConfigSkeleton -{ - public: - - Test8a( KSharedConfig::Ptr config = TDEGlobal::sharedConfig() ); - ~Test8a(); - - /** - Set Font - */ - void setFont( const TQFont & v ) - { - if (!isImmutable( TQString::fromLatin1( "Font" ) )) - mFont = v; - } - - /** - Get Font - */ - TQFont font() const - { - return mFont; - } - - /** - Set TitleFont - */ - void setTitleFont( const TQFont & v ) - { - if (!isImmutable( TQString::fromLatin1( "TitleFont" ) )) - mTitleFont = v; - } - - /** - Get TitleFont - */ - TQFont titleFont() const - { - return mTitleFont; - } - - protected: - - // Group - TQFont mFont; - TQFont mTitleFont; - - private: -}; - -#endif - diff --git a/tdecore/kconfig_compiler/tests/test8a.kcfg b/tdecore/kconfig_compiler/tests/test8a.kcfg deleted file mode 100644 index 53448b624..000000000 --- a/tdecore/kconfig_compiler/tests/test8a.kcfg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - TDEGlobalSettings::generalFont() - - - - TDEGlobalSettings::windowTitleFont() - - - diff --git a/tdecore/kconfig_compiler/tests/test8a.kcfgc b/tdecore/kconfig_compiler/tests/test8a.kcfgc deleted file mode 100644 index 5f63c31c2..000000000 --- a/tdecore/kconfig_compiler/tests/test8a.kcfgc +++ /dev/null @@ -1,3 +0,0 @@ -File=test8a.kcfg -ClassName=Test8a -Mutators=true diff --git a/tdecore/kconfig_compiler/tests/test8b.cpp.ref b/tdecore/kconfig_compiler/tests/test8b.cpp.ref deleted file mode 100644 index 6a0a16b48..000000000 --- a/tdecore/kconfig_compiler/tests/test8b.cpp.ref +++ /dev/null @@ -1,46 +0,0 @@ -// This file is generated by kconfig_compiler from test8b.kcfg. -// All changes you do to this file will be lost. - -#include "test8b.h" - -#include - -Test8b *Test8b::mSelf = 0; -static KStaticDeleter staticTest8bDeleter; - -Test8b *Test8b::self() -{ - if ( !mSelf ) { - staticTest8bDeleter.setObject( mSelf, new Test8b() ); - mSelf->readConfig(); - } - - return mSelf; -} - -Test8b::Test8b( ) - : Test8a() -{ - mSelf = this; - setCurrentGroup( TQString::fromLatin1( "Group8b1" ) ); - - TDEConfigSkeleton::ItemUInt *itemSomething; - itemSomething = new TDEConfigSkeleton::ItemUInt( currentGroup(), TQString::fromLatin1( "Something" ), mSomething, 60 ); - addItem( itemSomething, TQString::fromLatin1( "Something" ) ); - - setCurrentGroup( TQString::fromLatin1( "Group8b2" ) ); - - TDEConfigSkeleton::ItemBool *itemFooBoo; - itemFooBoo = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "FooBoo" ), mFooBoo, false ); - addItem( itemFooBoo, TQString::fromLatin1( "FooBoo" ) ); - TDEConfigSkeleton::ItemUInt *itemPort; - itemPort = new TDEConfigSkeleton::ItemUInt( currentGroup(), TQString::fromLatin1( "Port" ), mPort, 1000 ); - addItem( itemPort, TQString::fromLatin1( "Port" ) ); -} - -Test8b::~Test8b() -{ - if ( mSelf == this ) - staticTest8bDeleter.setObject( mSelf, 0, false ); -} - diff --git a/tdecore/kconfig_compiler/tests/test8b.h.ref b/tdecore/kconfig_compiler/tests/test8b.h.ref deleted file mode 100644 index 052746bfb..000000000 --- a/tdecore/kconfig_compiler/tests/test8b.h.ref +++ /dev/null @@ -1,96 +0,0 @@ -// This file is generated by kconfig_compiler from test8b.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST8B_H -#define TEST8B_H - -#include - -#include -#include - -class Test8b : public Test8a -{ - public: - - static Test8b *self(); - ~Test8b(); - - /** - Set Something - */ - static - void setSomething( uint v ) - { - if (!self()->isImmutable( TQString::fromLatin1( "Something" ) )) - self()->mSomething = v; - } - - /** - Get Something - */ - static - uint something() - { - return self()->mSomething; - } - - /** - Set FooBoo - */ - static - void setFooBoo( bool v ) - { - if (!self()->isImmutable( TQString::fromLatin1( "FooBoo" ) )) - self()->mFooBoo = v; - } - - /** - Get FooBoo - */ - static - bool fooBoo() - { - return self()->mFooBoo; - } - - /** - Set Port - */ - static - void setPort( uint v ) - { - if (!self()->isImmutable( TQString::fromLatin1( "Port" ) )) - self()->mPort = v; - } - - /** - Get Port - */ - static - uint port() - { - return self()->mPort; - } - - static - void writeConfig() - { - static_cast(self())->writeConfig(); - } - protected: - Test8b(); - static Test8b *mSelf; - - - // Group8b1 - uint mSomething; - - // Group8b2 - bool mFooBoo; - uint mPort; - - private: -}; - -#endif - diff --git a/tdecore/kconfig_compiler/tests/test8b.kcfg b/tdecore/kconfig_compiler/tests/test8b.kcfg deleted file mode 100644 index 3e203a155..000000000 --- a/tdecore/kconfig_compiler/tests/test8b.kcfg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - 60 - - - - - - false - - - - 1000 - - - diff --git a/tdecore/kconfig_compiler/tests/test8b.kcfgc b/tdecore/kconfig_compiler/tests/test8b.kcfgc deleted file mode 100644 index 7be055203..000000000 --- a/tdecore/kconfig_compiler/tests/test8b.kcfgc +++ /dev/null @@ -1,6 +0,0 @@ -File=test8b.kcfg -ClassName=Test8b -Mutators=true -Singleton=true -IncludeFiles=test8a.h -Inherits=Test8a diff --git a/tdecore/kconfig_compiler/tests/test8main.cpp b/tdecore/kconfig_compiler/tests/test8main.cpp deleted file mode 100644 index 04864a95c..000000000 --- a/tdecore/kconfig_compiler/tests/test8main.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (c) 2005 Michael Brade - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "test8a.h" -#include "test8b.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - TDEInstance i("test"); - Test8a *config1 = new Test8a( KSharedConfig::openConfig( TQString::null ) ); - Test8a *config2 = new Test8a(); - Test8b::self(); - delete config1; - delete config2; -} diff --git a/tdecore/kconfig_compiler/tests/test9.cpp.ref b/tdecore/kconfig_compiler/tests/test9.cpp.ref deleted file mode 100644 index f6765fb42..000000000 --- a/tdecore/kconfig_compiler/tests/test9.cpp.ref +++ /dev/null @@ -1,35 +0,0 @@ -// This file is generated by kconfig_compiler from test9.kcfg. -// All changes you do to this file will be lost. - -#include "test9.h" - -Test9::Test9( const TQString & transport, const TQString & folder ) - : TDEConfigSkeleton( TQString::fromLatin1( "examplerc" ) ) - , mParamtransport(transport) - , mParamfolder(folder) -{ - setCurrentGroup( TQString::fromLatin1( "MyOptionsXX" ) ); - - TQStringList defaultMyStringList; - defaultMyStringList.append( TQString::fromUtf8( "up" ) ); - defaultMyStringList.append( TQString::fromUtf8( "down" ) ); - - TDEConfigSkeleton::ItemStringList *itemMyStringList; - itemMyStringList = new TDEConfigSkeleton::ItemStringList( currentGroup(), TQString::fromLatin1( "MyStringList" ), mMyStringList, defaultMyStringList ); - addItem( itemMyStringList, TQString::fromLatin1( "MyStringList" ) ); - TQStringList defaultMyPathList; - defaultMyPathList.append( TQString::fromUtf8( "/home" ) ); - defaultMyPathList.append( TQString::fromUtf8( "~" ) ); - - TDEConfigSkeleton::ItemPathList *itemMyPathList; - itemMyPathList = new TDEConfigSkeleton::ItemPathList( currentGroup(), TQString::fromLatin1( "MyPathList" ), mMyPathList, defaultMyPathList ); - addItem( itemMyPathList, TQString::fromLatin1( "MyPathList" ) ); - TDEConfigSkeleton::ItemPathList *itemMyPathsList2; - itemMyPathsList2 = new TDEConfigSkeleton::ItemPathList( currentGroup(), TQString::fromLatin1( "MyPathsList2" ), mMyPathsList2, TQStringList(TQString::fromLatin1("/usr/bin")) += TQDir::homeDirPath() ); - addItem( itemMyPathsList2, TQString::fromLatin1( "MyPathsList2" ) ); -} - -Test9::~Test9() -{ -} - diff --git a/tdecore/kconfig_compiler/tests/test9.h.ref b/tdecore/kconfig_compiler/tests/test9.h.ref deleted file mode 100644 index 99d94c957..000000000 --- a/tdecore/kconfig_compiler/tests/test9.h.ref +++ /dev/null @@ -1,82 +0,0 @@ -// This file is generated by kconfig_compiler from test9.kcfg. -// All changes you do to this file will be lost. -#ifndef TEST9_H -#define TEST9_H - -#include -#include - -#include -class Test9 : public TDEConfigSkeleton -{ - public: - - Test9( const TQString & transport, const TQString & folder ); - ~Test9(); - - /** - Set MyStringList - */ - void setMyStringList( const TQStringList & v ) - { - if (!isImmutable( TQString::fromLatin1( "MyStringList" ) )) - mMyStringList = v; - } - - /** - Get MyStringList - */ - TQStringList myStringList() const - { - return mMyStringList; - } - - /** - Set This is a list of paths - */ - void setMyPathList( const TQStringList & v ) - { - if (!isImmutable( TQString::fromLatin1( "MyPathList" ) )) - mMyPathList = v; - } - - /** - Get This is a list of paths - */ - TQStringList myPathList() const - { - return mMyPathList; - } - - /** - Set This is an additional test for PathList - */ - void setMyPathsList2( const TQStringList & v ) - { - if (!isImmutable( TQString::fromLatin1( "MyPathsList2" ) )) - mMyPathsList2 = v; - } - - /** - Get This is an additional test for PathList - */ - TQStringList myPathsList2() const - { - return mMyPathsList2; - } - - protected: - public: - TQString mParamtransport; - TQString mParamfolder; - - // MyOptionsXX - TQStringList mMyStringList; - TQStringList mMyPathList; - TQStringList mMyPathsList2; - - private: -}; - -#endif - diff --git a/tdecore/kconfig_compiler/tests/test9.kcfg b/tdecore/kconfig_compiler/tests/test9.kcfg deleted file mode 100644 index b7495e2b6..000000000 --- a/tdecore/kconfig_compiler/tests/test9.kcfg +++ /dev/null @@ -1,24 +0,0 @@ - - - qdir.h - - - - - - - up,down - - - - /home,~ - - - - QStringList(QString::fromLatin1("/usr/bin")) += QDir::homeDirPath() - - - diff --git a/tdecore/kconfig_compiler/tests/test9.kcfgc b/tdecore/kconfig_compiler/tests/test9.kcfgc deleted file mode 100644 index 0a88064b6..000000000 --- a/tdecore/kconfig_compiler/tests/test9.kcfgc +++ /dev/null @@ -1,18 +0,0 @@ -# Code generation options for kconfig_compiler -ClassName=Test9 -# -# Singleton=false -# -# Inherits=TDEConfigSkeleton -# -# IncludeFiles=libtdepim/kpimprefs.h -# -MemberVariables=public -# -### The following line includes the file exampleprefs_base_addon.h -### It can be used to add extra functions and variables to the -### class. -# CustomAdditions=true -# -### Provide setFooBar(int) style functions -Mutators=true diff --git a/tdecore/kconfig_compiler/tests/test9main.cpp b/tdecore/kconfig_compiler/tests/test9main.cpp deleted file mode 100644 index 8668d8d8c..000000000 --- a/tdecore/kconfig_compiler/tests/test9main.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright (c) 2005 Helge Deller - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ -#include "test9.h" -#include "kinstance.h" -#include -#include - -int main( int, char*[] ) -{ - TDEInstance i("test"); - Test9 *t = new Test9( TQString::null, TQString::null ); - - TQStringList myPathsList2 = t->myPathsList2(); - kdWarning() << myPathsList2 << endl; - - // add another path - TQStringList newlist = TQDir::homeDirPath() + TQString::fromLatin1("/.trinity"); - myPathsList2 = myPathsList2 + newlist; - kdWarning() << myPathsList2 << endl; - - t->setMyPathsList2(myPathsList2); - kdWarning() << t->myPathsList2() << endl; - - delete t; -} diff --git a/tdecore/kconfig_compiler/tests/test_dpointer.cpp.ref b/tdecore/kconfig_compiler/tests/test_dpointer.cpp.ref deleted file mode 100644 index 3aad5b689..000000000 --- a/tdecore/kconfig_compiler/tests/test_dpointer.cpp.ref +++ /dev/null @@ -1,344 +0,0 @@ -// This file is generated by kconfig_compiler from test_dpointer.kcfg. -// All changes you do to this file will be lost. - -#include "test_dpointer.h" - -#include - -#include - -class TestDPointerPrivate -{ - public: - - // General - bool autoSave; - int autoSaveInterval; - bool confirm; - TQString archiveFile; - int destination; - - // Views - int hourSize; - bool selectionStartsEditor; - - // KOrganizer Plugins - TQStringList selectedPlugins; - - // Colors - TQColor highlightColor; - TQColor agendaBgColor; - - // Fonts - TQFont timeBarFont; - - // items - TDEConfigSkeleton::ItemBool *autoSaveItem; - TDEConfigSkeleton::ItemInt *autoSaveIntervalItem; - TDEConfigSkeleton::ItemBool *confirmItem; - TDEConfigSkeleton::ItemString *archiveFileItem; - TDEConfigSkeleton::ItemEnum *destinationItem; - TDEConfigSkeleton::ItemInt *hourSizeItem; - TDEConfigSkeleton::ItemBool *selectionStartsEditorItem; - TDEConfigSkeleton::ItemStringList *selectedPluginsItem; - TDEConfigSkeleton::ItemColor *highlightColorItem; - TDEConfigSkeleton::ItemColor *agendaBgColorItem; - TDEConfigSkeleton::ItemFont *timeBarFontItem; -}; - -TestDPointer *TestDPointer::mSelf = 0; -static KStaticDeleter staticTestDPointerDeleter; - -TestDPointer *TestDPointer::self() -{ - if ( !mSelf ) { - staticTestDPointerDeleter.setObject( mSelf, new TestDPointer() ); - mSelf->readConfig(); - } - - return mSelf; -} - -TestDPointer::TestDPointer( ) - : TDEConfigSkeleton( TQString::fromLatin1( "korganizerrc" ) ) -{ - d = new TestDPointerPrivate; - mSelf = this; - setCurrentGroup( TQString::fromLatin1( "General" ) ); - - d->autoSaveItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "Auto Save" ), d->autoSave, false ); - d->autoSaveItem->setLabel( i18n("Enable automatic saving of calendar") ); - d->autoSaveItem->setWhatsThis( i18n("WhatsThis text for AutoSave option") ); - addItem( d->autoSaveItem, TQString::fromLatin1( "AutoSave" ) ); - d->autoSaveIntervalItem = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Auto Save Interval" ), d->autoSaveInterval, 10 ); - d->autoSaveIntervalItem->setLabel( i18n("Auto Save Interval") ); - addItem( d->autoSaveIntervalItem, TQString::fromLatin1( "AutoSaveInterval" ) ); - d->confirmItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "Confirm Deletes" ), d->confirm, true ); - d->confirmItem->setLabel( i18n("Confirm deletes") ); - addItem( d->confirmItem, TQString::fromLatin1( "Confirm" ) ); - d->archiveFileItem = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "Archive File" ), d->archiveFile ); - d->archiveFileItem->setLabel( i18n("Archive File") ); - addItem( d->archiveFileItem, TQString::fromLatin1( "ArchiveFile" ) ); - TQValueList valuesDestination; - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "standardDestination" ); - valuesDestination.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "askDestination" ); - valuesDestination.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "argl1" ); - choice.label = i18n("Argl1 Label"); - valuesDestination.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "argl2" ); - choice.whatsThis = i18n("Argl2 Whatsthis"); - valuesDestination.append( choice ); - } - { - TDEConfigSkeleton::ItemEnum::Choice choice; - choice.name = TQString::fromLatin1( "argl3" ); - choice.label = i18n("Argl3 Label"); - choice.whatsThis = i18n("Argl3 Whatsthis"); - valuesDestination.append( choice ); - } - d->destinationItem = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "Destination" ), d->destination, valuesDestination, EnumDestination::standardDestination ); - d->destinationItem->setLabel( i18n("New Events/Todos Should") ); - addItem( d->destinationItem, TQString::fromLatin1( "Destination" ) ); - - setCurrentGroup( TQString::fromLatin1( "Views" ) ); - - d->hourSizeItem = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Hour Size" ), d->hourSize, 10 ); - d->hourSizeItem->setLabel( i18n("Hour Size") ); - addItem( d->hourSizeItem, TQString::fromLatin1( "HourSize" ) ); - d->selectionStartsEditorItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "SelectionStartsEditor" ), d->selectionStartsEditor, false ); - d->selectionStartsEditorItem->setLabel( i18n("Time range selection in agenda view starts event editor") ); - addItem( d->selectionStartsEditorItem, TQString::fromLatin1( "SelectionStartsEditor" ) ); - - setCurrentGroup( TQString::fromLatin1( "KOrganizer Plugins" ) ); - - TQStringList defaultSelectedPlugins; - defaultSelectedPlugins.append( TQString::fromUtf8( "holidays" ) ); - defaultSelectedPlugins.append( TQString::fromUtf8( "webexport" ) ); - - d->selectedPluginsItem = new TDEConfigSkeleton::ItemStringList( currentGroup(), TQString::fromLatin1( "SelectedPlugins" ), d->selectedPlugins, defaultSelectedPlugins ); - d->selectedPluginsItem->setLabel( i18n("SelectedPlugins") ); - addItem( d->selectedPluginsItem, TQString::fromLatin1( "SelectedPlugins" ) ); - - setCurrentGroup( TQString::fromLatin1( "Colors" ) ); - - d->highlightColorItem = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "Highlight Color" ), d->highlightColor, TQColor( 100, 100, 255 ) ); - d->highlightColorItem->setLabel( i18n("Highlight color") ); - addItem( d->highlightColorItem, TQString::fromLatin1( "HighlightColor" ) ); - d->agendaBgColorItem = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "Agenda Background Color" ), d->agendaBgColor, TQColor( 255, 255, 255 ) ); - d->agendaBgColorItem->setLabel( i18n("Agenda view background color") ); - addItem( d->agendaBgColorItem, TQString::fromLatin1( "AgendaBgColor" ) ); - - setCurrentGroup( TQString::fromLatin1( "Fonts" ) ); - - d->timeBarFontItem = new TDEConfigSkeleton::ItemFont( currentGroup(), TQString::fromLatin1( "TimeBar Font" ), d->timeBarFont ); - d->timeBarFontItem->setLabel( i18n("Time bar") ); - addItem( d->timeBarFontItem, TQString::fromLatin1( "TimeBarFont" ) ); -} - -void TestDPointer::setAutoSave( bool v ) -{ - if (!self()->isImmutable( TQString::fromLatin1( "AutoSave" ) )) - self()->d->autoSave = v; -} - -bool TestDPointer::autoSave() -{ - return self()->d->autoSave; -} - - -TDEConfigSkeleton::ItemBool *TestDPointer::autoSaveItem() -{ - return d->autoSaveItem; -} - -void TestDPointer::setAutoSaveInterval( int v ) -{ - if (!self()->isImmutable( TQString::fromLatin1( "AutoSaveInterval" ) )) - self()->d->autoSaveInterval = v; -} - -int TestDPointer::autoSaveInterval() -{ - return self()->d->autoSaveInterval; -} - - -TDEConfigSkeleton::ItemInt *TestDPointer::autoSaveIntervalItem() -{ - return d->autoSaveIntervalItem; -} - -void TestDPointer::setConfirm( bool v ) -{ - if (!self()->isImmutable( TQString::fromLatin1( "Confirm" ) )) - self()->d->confirm = v; -} - -bool TestDPointer::confirm() -{ - return self()->d->confirm; -} - - -TDEConfigSkeleton::ItemBool *TestDPointer::confirmItem() -{ - return d->confirmItem; -} - -void TestDPointer::setArchiveFile( const TQString & v ) -{ - if (!self()->isImmutable( TQString::fromLatin1( "ArchiveFile" ) )) - self()->d->archiveFile = v; -} - -TQString TestDPointer::archiveFile() -{ - return self()->d->archiveFile; -} - - -TDEConfigSkeleton::ItemString *TestDPointer::archiveFileItem() -{ - return d->archiveFileItem; -} - -void TestDPointer::setDestination( int v ) -{ - if (!self()->isImmutable( TQString::fromLatin1( "Destination" ) )) - self()->d->destination = v; -} - -int TestDPointer::destination() -{ - return self()->d->destination; -} - - -TDEConfigSkeleton::ItemEnum *TestDPointer::destinationItem() -{ - return d->destinationItem; -} - -void TestDPointer::setHourSize( int v ) -{ - if (!self()->isImmutable( TQString::fromLatin1( "HourSize" ) )) - self()->d->hourSize = v; -} - -int TestDPointer::hourSize() -{ - return self()->d->hourSize; -} - - -TDEConfigSkeleton::ItemInt *TestDPointer::hourSizeItem() -{ - return d->hourSizeItem; -} - -void TestDPointer::setSelectionStartsEditor( bool v ) -{ - if (!self()->isImmutable( TQString::fromLatin1( "SelectionStartsEditor" ) )) - self()->d->selectionStartsEditor = v; -} - -bool TestDPointer::selectionStartsEditor() -{ - return self()->d->selectionStartsEditor; -} - - -TDEConfigSkeleton::ItemBool *TestDPointer::selectionStartsEditorItem() -{ - return d->selectionStartsEditorItem; -} - -void TestDPointer::setSelectedPlugins( const TQStringList & v ) -{ - if (!self()->isImmutable( TQString::fromLatin1( "SelectedPlugins" ) )) - self()->d->selectedPlugins = v; -} - -TQStringList TestDPointer::selectedPlugins() -{ - return self()->d->selectedPlugins; -} - - -TDEConfigSkeleton::ItemStringList *TestDPointer::selectedPluginsItem() -{ - return d->selectedPluginsItem; -} - -void TestDPointer::setHighlightColor( const TQColor & v ) -{ - if (!self()->isImmutable( TQString::fromLatin1( "HighlightColor" ) )) - self()->d->highlightColor = v; -} - -TQColor TestDPointer::highlightColor() -{ - return self()->d->highlightColor; -} - - -TDEConfigSkeleton::ItemColor *TestDPointer::highlightColorItem() -{ - return d->highlightColorItem; -} - -void TestDPointer::setAgendaBgColor( const TQColor & v ) -{ - if (!self()->isImmutable( TQString::fromLatin1( "AgendaBgColor" ) )) - self()->d->agendaBgColor = v; -} - -TQColor TestDPointer::agendaBgColor() -{ - return self()->d->agendaBgColor; -} - - -TDEConfigSkeleton::ItemColor *TestDPointer::agendaBgColorItem() -{ - return d->agendaBgColorItem; -} - -void TestDPointer::setTimeBarFont( const TQFont & v ) -{ - if (!self()->isImmutable( TQString::fromLatin1( "TimeBarFont" ) )) - self()->d->timeBarFont = v; -} - -TQFont TestDPointer::timeBarFont() -{ - return self()->d->timeBarFont; -} - - -TDEConfigSkeleton::ItemFont *TestDPointer::timeBarFontItem() -{ - return d->timeBarFontItem; -} - -TestDPointer::~TestDPointer() -{ - delete d; - if ( mSelf == this ) - staticTestDPointerDeleter.setObject( mSelf, 0, false ); -} - diff --git a/tdecore/kconfig_compiler/tests/test_dpointer.h.ref b/tdecore/kconfig_compiler/tests/test_dpointer.h.ref deleted file mode 100644 index d9b7b94c1..000000000 --- a/tdecore/kconfig_compiler/tests/test_dpointer.h.ref +++ /dev/null @@ -1,224 +0,0 @@ -// This file is generated by kconfig_compiler from test_dpointer.kcfg. -// All changes you do to this file will be lost. -#ifndef TESTDPOINTER_H -#define TESTDPOINTER_H - -#include -#include - -class TestDPointerPrivate; - -class TestDPointer : public TDEConfigSkeleton -{ - public: - class EnumDestination - { - public: - enum type { standardDestination, askDestination, argl1, argl2, argl3, COUNT }; - }; - - static TestDPointer *self(); - ~TestDPointer(); - - /** - Set Enable automatic saving of calendar - */ - static - void setAutoSave( bool v ); - - /** - Get Enable automatic saving of calendar - */ - static - bool autoSave(); - - /** - Get Item object corresponding to AutoSave() - */ - ItemBool *autoSaveItem(); - - /** - Set Auto Save Interval - */ - static - void setAutoSaveInterval( int v ); - - /** - Get Auto Save Interval - */ - static - int autoSaveInterval(); - - /** - Get Item object corresponding to AutoSaveInterval() - */ - ItemInt *autoSaveIntervalItem(); - - /** - Set Confirm deletes - */ - static - void setConfirm( bool v ); - - /** - Get Confirm deletes - */ - static - bool confirm(); - - /** - Get Item object corresponding to Confirm() - */ - ItemBool *confirmItem(); - - /** - Set Archive File - */ - static - void setArchiveFile( const TQString & v ); - - /** - Get Archive File - */ - static - TQString archiveFile(); - - /** - Get Item object corresponding to ArchiveFile() - */ - ItemString *archiveFileItem(); - - /** - Set New Events/Todos Should - */ - static - void setDestination( int v ); - - /** - Get New Events/Todos Should - */ - static - int destination(); - - /** - Get Item object corresponding to Destination() - */ - ItemEnum *destinationItem(); - - /** - Set Hour Size - */ - static - void setHourSize( int v ); - - /** - Get Hour Size - */ - static - int hourSize(); - - /** - Get Item object corresponding to HourSize() - */ - ItemInt *hourSizeItem(); - - /** - Set Time range selection in agenda view starts event editor - */ - static - void setSelectionStartsEditor( bool v ); - - /** - Get Time range selection in agenda view starts event editor - */ - static - bool selectionStartsEditor(); - - /** - Get Item object corresponding to SelectionStartsEditor() - */ - ItemBool *selectionStartsEditorItem(); - - /** - Set SelectedPlugins - */ - static - void setSelectedPlugins( const TQStringList & v ); - - /** - Get SelectedPlugins - */ - static - TQStringList selectedPlugins(); - - /** - Get Item object corresponding to SelectedPlugins() - */ - ItemStringList *selectedPluginsItem(); - - /** - Set Highlight color - */ - static - void setHighlightColor( const TQColor & v ); - - /** - Get Highlight color - */ - static - TQColor highlightColor(); - - /** - Get Item object corresponding to HighlightColor() - */ - ItemColor *highlightColorItem(); - - /** - Set Agenda view background color - */ - static - void setAgendaBgColor( const TQColor & v ); - - /** - Get Agenda view background color - */ - static - TQColor agendaBgColor(); - - /** - Get Item object corresponding to AgendaBgColor() - */ - ItemColor *agendaBgColorItem(); - - /** - Set Time bar - */ - static - void setTimeBarFont( const TQFont & v ); - - /** - Get Time bar - */ - static - TQFont timeBarFont(); - - /** - Get Item object corresponding to TimeBarFont() - */ - ItemFont *timeBarFontItem(); - - static - void writeConfig() - { - static_cast(self())->writeConfig(); - } - protected: - TestDPointer(); - static TestDPointer *mSelf; - - private: - TestDPointerPrivate *d; -}; - -#endif - diff --git a/tdecore/kconfig_compiler/tests/test_dpointer.kcfg b/tdecore/kconfig_compiler/tests/test_dpointer.kcfg deleted file mode 100644 index 3b19e270e..000000000 --- a/tdecore/kconfig_compiler/tests/test_dpointer.kcfg +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - WhatsThis text for AutoSave option - false - - - 10 - - - - true - - - - - - - - - - - - - - - Argl2 Whatsthis - - - - Argl3 Whatsthis - - - standardDestination - - - - - - 10 - - - - false - - - - - - holidays,webexport - - - - - - - 100, 100, 255 - - - - 255, 255, 255 - - - - - - - - - - diff --git a/tdecore/kconfig_compiler/tests/test_dpointer.kcfgc b/tdecore/kconfig_compiler/tests/test_dpointer.kcfgc deleted file mode 100644 index 48baa376e..000000000 --- a/tdecore/kconfig_compiler/tests/test_dpointer.kcfgc +++ /dev/null @@ -1,11 +0,0 @@ -# Code generation options for kconfig_compiler -File=test_dpointer.kcfg -ClassName=TestDPointer -Singleton=true -Mutators=true -#Inherits=MyPrefs -#IncludeFiles=myprefs.h -MemberVariables=dpointer -#GlobalEnums=true -ItemAccessors=true -SetUserTexts=true diff --git a/tdecore/kconfig_compiler/tests/test_dpointer_main.cpp b/tdecore/kconfig_compiler/tests/test_dpointer_main.cpp deleted file mode 100644 index b62ee17af..000000000 --- a/tdecore/kconfig_compiler/tests/test_dpointer_main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 2005 Duncan Mac-Vicar P. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "test_dpointer.h" -#include "kinstance.h" - -int main( int, char*[] ) -{ - TDEInstance i("test"); - TestDPointer *t = TestDPointer::self(); - delete t; -} diff --git a/tdecore/kconfigbackend.cpp b/tdecore/kconfigbackend.cpp deleted file mode 100644 index 178198509..000000000 --- a/tdecore/kconfigbackend.cpp +++ /dev/null @@ -1,1190 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown - Copyright (c) 1997-1999 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include - -#include -#include -#ifdef HAVE_SYS_MMAN_H -#include -#endif -#include -#ifdef HAVE_SYS_STAT_H -#include -#endif -#include -#include -#include - -#include -#include -#include -#include - -#include "kconfigbackend.h" -#include "kconfigbase.h" -#include -#include -#include -#include -#include -#include -#include -#include - -extern bool checkAccess(const TQString& pathname, int mode); -/* translate escaped escape sequences to their actual values. */ -static TQCString printableToString(const char *str, int l) -{ - // Strip leading white-space. - while((l>0) && - ((*str == ' ') || (*str == '\t') || (*str == '\r'))) - { - str++; l--; - } - - // Strip trailing white-space. - while((l>0) && - ((str[l-1] == ' ') || (str[l-1] == '\t') || (str[l-1] == '\r'))) - { - l--; - } - - TQCString result(l + 1); - char *r = result.data(); - - for(int i = 0; i < l;i++, str++) - { - if (*str == '\\') - { - i++, str++; - if (i >= l) // End of line. (Line ends with single slash) - { - *r++ = '\\'; - break; - } - switch(*str) - { - case 's': - *r++ = ' '; - break; - case 't': - *r++ = '\t'; - break; - case 'n': - *r++ = '\n'; - break; - case 'r': - *r++ = '\r'; - break; - case '\\': - *r++ = '\\'; - break; - default: - *r++ = '\\'; - *r++ = *str; - } - } - else - { - *r++ = *str; - } - } - result.truncate(r-result.data()); - return result; -} - -static TQCString stringToPrintable(const TQCString& str){ - TQCString result(str.length()*2); // Maximum 2x as long as source string - register char *r = const_cast(result).data(); - register char *s = const_cast(str).data(); - - if (!s) return TQCString(""); - - // Escape leading space - if (*s == ' ') - { - *r++ = '\\'; *r++ = 's'; - s++; - } - - if (*s) - { - while(*s) - { - if (*s == '\n') - { - *r++ = '\\'; *r++ = 'n'; - } - else if (*s == '\t') - { - *r++ = '\\'; *r++ = 't'; - } - else if (*s == '\r') - { - *r++ = '\\'; *r++ = 'r'; - } - else if (*s == '\\') - { - *r++ = '\\'; *r++ = '\\'; - } - else - { - *r++ = *s; - } - s++; - } - // Escape trailing space - if (*(r-1) == ' ') - { - *(r-1) = '\\'; *r++ = 's'; - } - } - - result.truncate(r - result.data()); - return result; -} - -static TQCString decodeGroup(const char*s, int l) -{ - TQCString result(l); - register char *r = result.data(); - - l--; // Correct for trailing \0 - while(l) - { - if ((*s == '[') && (l > 1)) - { - if ((*(s+1) == '[')) - { - l--; - s++; - } - } - if ((*s == ']') && (l > 1)) - { - if ((*(s+1) == ']')) - { - l--; - s++; - } - } - *r++ = *s++; - l--; - } - result.truncate(r - result.data()); - return result; -} - -static TQCString encodeGroup(const TQCString &str) -{ - int l = str.length(); - TQCString result(l*2+1); - register char *r = const_cast(result).data(); - register char *s = const_cast(str).data(); - while(l) - { - if ((*s == '[') || (*s == ']')) - *r++ = *s; - *r++ = *s++; - l--; - } - result.truncate(r - result.data()); - return result; -} - -static TQCString encodeKey(const char* key) -{ - TQCString newKey(key); - - newKey.replace('[', "%5b"); - newKey.replace(']', "%5d"); - - return newKey; -} - -static TQCString decodeKey(const char* key) -{ - TQCString newKey(key); - - newKey.replace("%5b", "["); - newKey.replace("%5d", "]"); - - return newKey; -} - -class TDEConfigBackEnd::TDEConfigBackEndPrivate -{ -public: - TQDateTime localLastModified; - uint localLastSize; - KLockFile::Ptr localLockFile; - KLockFile::Ptr globalLockFile; -}; - -void TDEConfigBackEnd::changeFileName(const TQString &_fileName, - const char * _resType, - bool _useKDEGlobals) -{ - mfileName = _fileName; - resType = _resType; - useKDEGlobals = _useKDEGlobals; - if (mfileName.isEmpty()) { - mLocalFileName = TQString::null; - } - else if (!TQDir::isRelativePath(mfileName)) { - mLocalFileName = mfileName; - } - else { - mLocalFileName = TDEGlobal::dirs()->saveLocation(resType, TQString(), false) + mfileName; - } - - if (useKDEGlobals) { - mGlobalFileName = TDEGlobal::dirs()->saveLocation("config", TQString(), false) + TQString::fromLatin1("kdeglobals"); - } - else { - mGlobalFileName = TQString::null; - } - - d->localLastModified = TQDateTime(); - d->localLastSize = 0; - d->localLockFile = 0; - d->globalLockFile = 0; -} - -KLockFile::Ptr TDEConfigBackEnd::lockFile(bool bGlobal) -{ - if (bGlobal) - { - if (d->globalLockFile) - return d->globalLockFile; - - if (!mGlobalFileName.isEmpty()) - { - d->globalLockFile = new KLockFile(mGlobalFileName+".lock"); - return d->globalLockFile; - } - } - else - { - if (d->localLockFile) - return d->localLockFile; - - if (!mLocalFileName.isEmpty()) - { - d->localLockFile = new KLockFile(mLocalFileName+".lock"); - return d->localLockFile; - } - } - return 0; -} - -TDEConfigBackEnd::TDEConfigBackEnd(TDEConfigBase *_config, - const TQString &_fileName, - const char * _resType, - bool _useKDEGlobals) - : pConfig(_config), bFileImmutable(false), mConfigState(TDEConfigBase::NoAccess), mFileMode(-1) -{ - d = new TDEConfigBackEndPrivate; - changeFileName(_fileName, _resType, _useKDEGlobals); -} - -TDEConfigBackEnd::~TDEConfigBackEnd() -{ - delete d; -} - -void TDEConfigBackEnd::setFileWriteMode(int mode) -{ - mFileMode = mode; -} - -bool TDEConfigINIBackEnd::parseConfigFiles() -{ - // Check if we can write to the local file. - mConfigState = TDEConfigBase::ReadOnly; - if (!mLocalFileName.isEmpty() && !pConfig->isReadOnly()) - { - if (checkAccess(mLocalFileName, W_OK)) - { - mConfigState = TDEConfigBase::ReadWrite; - } - else - { - // Create the containing dir, maybe it wasn't there - KURL path; - path.setPath(mLocalFileName); - TQString dir=path.directory(); - KStandardDirs::makeDir(dir); - - if (checkAccess(mLocalFileName, W_OK)) - { - mConfigState = TDEConfigBase::ReadWrite; - } - } - TQFileInfo info(mLocalFileName); - d->localLastModified = info.lastModified(); - d->localLastSize = info.size(); - } - - // Parse all desired files from the least to the most specific. - bFileImmutable = false; - - // Parse the general config files - if (useKDEGlobals) { - TQStringList kdercs = TDEGlobal::dirs()-> - findAllResources("config", TQString::fromLatin1("kdeglobals")); - -#ifdef Q_WS_WIN - TQString etc_kderc = TQFile::decodeName( TQCString(getenv("WINDIR")) + "\\kderc" ); -#else - TQString etc_kderc = TQString::fromLatin1("/etc/kderc"); -#endif - - if (checkAccess(etc_kderc, R_OK)) - kdercs += etc_kderc; - - kdercs += TDEGlobal::dirs()-> - findAllResources("config", TQString::fromLatin1("system.kdeglobals")); - - TQStringList::ConstIterator it; - - for (it = kdercs.fromLast(); it != kdercs.end(); --it) { - - TQFile aConfigFile( *it ); - if (!aConfigFile.open( IO_ReadOnly )) - continue; - parseSingleConfigFile( aConfigFile, 0L, true, (*it != mGlobalFileName) ); - aConfigFile.close(); - if (bFileImmutable) - break; - } - } - - bool bReadFile = !mfileName.isEmpty(); - while(bReadFile) { - bReadFile = false; - TQString bootLanguage; - if (useKDEGlobals && localeString.isEmpty() && !TDEGlobal::_locale) { - // Boot strap language - bootLanguage = KLocale::_initLanguage(pConfig); - setLocaleString(bootLanguage.utf8()); - } - - bFileImmutable = false; - TQStringList list; - if ( !TQDir::isRelativePath(mfileName) ) - list << mfileName; - else - list = TDEGlobal::dirs()->findAllResources(resType, mfileName); - - TQStringList::ConstIterator it; - - for (it = list.fromLast(); it != list.end(); --it) { - - TQFile aConfigFile( *it ); - // we can already be sure that this file exists - bool bIsLocal = (*it == mLocalFileName); - if (aConfigFile.open( IO_ReadOnly )) { - parseSingleConfigFile( aConfigFile, 0L, false, !bIsLocal ); - aConfigFile.close(); - if (bFileImmutable) - break; - } - } - if (TDEGlobal::dirs()->isRestrictedResource(resType, mfileName)) - bFileImmutable = true; - TQString currentLanguage; - if (!bootLanguage.isEmpty()) - { - currentLanguage = KLocale::_initLanguage(pConfig); - // If the file changed the language, we need to read the file again - // with the new language setting. - if (bootLanguage != currentLanguage) - { - bReadFile = true; - setLocaleString(currentLanguage.utf8()); - } - } - } - if (bFileImmutable) - mConfigState = TDEConfigBase::ReadOnly; - - return true; -} - -#ifdef HAVE_MMAP -#ifdef SIGBUS -static sigjmp_buf mmap_jmpbuf; -struct sigaction mmap_old_sigact; - -extern "C" { - static void mmap_sigbus_handler(int) - { - siglongjmp (mmap_jmpbuf, 1); - } -} -#endif -#endif - -extern bool kde_kiosk_exception; - -void TDEConfigINIBackEnd::parseSingleConfigFile(TQFile &rFile, - KEntryMap *pWriteBackMap, - bool bGlobal, bool bDefault) -{ - const char *s; // May get clobbered by sigsetjump, but we don't use them afterwards. - const char *eof; // May get clobbered by sigsetjump, but we don't use them afterwards. - TQByteArray data; - - if (!rFile.isOpen()) // come back, if you have real work for us ;-> - return; - - //using kdDebug() here leads to an infinite loop - //remove this for the release, aleXXX - //tqWarning("Parsing %s, global = %s default = %s", - // rFile.name().latin1(), bGlobal ? "true" : "false", bDefault ? "true" : "false"); - - TQCString aCurrentGroup(""); - - unsigned int ll = localeString.length(); - -#ifdef HAVE_MMAP - static volatile const char *map; - map = ( const char* ) mmap(0, rFile.size(), PROT_READ, MAP_PRIVATE, - rFile.handle(), 0); - - if ( map != MAP_FAILED ) - { - s = (const char*) map; - eof = s + rFile.size(); - -#ifdef SIGBUS - struct sigaction act; - act.sa_handler = mmap_sigbus_handler; - sigemptyset( &act.sa_mask ); -#ifdef SA_ONESHOT - act.sa_flags = SA_ONESHOT; -#else - act.sa_flags = SA_RESETHAND; -#endif - sigaction( SIGBUS, &act, &mmap_old_sigact ); - - if (sigsetjmp (mmap_jmpbuf, 1)) - { -tqWarning("SIGBUS while reading %s", rFile.name().latin1()); - munmap(( char* )map, rFile.size()); - sigaction (SIGBUS, &mmap_old_sigact, 0); - return; - } -#endif - } - else -#endif - { - rFile.at(0); - data = rFile.readAll(); - s = data.data(); - eof = s + data.size(); - } - - bool fileOptionImmutable = false; - bool groupOptionImmutable = false; - bool groupSkip = false; - bool foundGettextDomain = false; - TQCString gettextDomain; - - int line = 0; - for(; s < eof; s++) - { - line++; - - while((s < eof) && isspace(*s) && (*s != '\n')) - s++; //skip leading whitespace, shouldn't happen too often - - //skip empty lines, lines starting with # - if ((s < eof) && ((*s == '\n') || (*s == '#'))) - { - sktoeol: //skip till end-of-line - while ((s < eof) && (*s != '\n')) - s++; - continue; // Empty or comment or no keyword - } - const char *startLine = s; - - if (*s == '[') //group - { - // In a group [[ and ]] have a special meaning - while ((s < eof) && (*s != '\n')) - { - if (*s == ']') - { - if ((s+1 < eof) && (*(s+1) == ']')) - s++; // Skip "]]" - else - break; - } - - s++; // Search till end of group - } - const char *e = s; - while ((s < eof) && (*s != '\n')) s++; // Search till end of line / end of file - if ((e >= eof) || (*e != ']')) - { - fprintf(stderr, "Invalid group header at %s:%d\n", rFile.name().latin1(), line); - continue; - } - // group found; get the group name by taking everything in - // between the brackets - if ((e-startLine == 3) && - (startLine[1] == '$') && - (startLine[2] == 'i')) - { - if (!kde_kiosk_exception) - fileOptionImmutable = true; - continue; - } - - aCurrentGroup = decodeGroup(startLine + 1, e - startLine); - //cout<<"found group ["<lookupData(groupKey); - groupSkip = entry.bImmutable; - - if (groupSkip && !bDefault) - continue; - - entry.bImmutable |= groupOptionImmutable; - pConfig->putData(groupKey, entry, false); - - if (pWriteBackMap) - { - // add the special group key indicator - (*pWriteBackMap)[groupKey] = entry; - } - - continue; - } - if (groupSkip && !bDefault) - goto sktoeol; // Skip entry - - - bool optionImmutable = groupOptionImmutable; - bool optionDeleted = false; - bool optionExpand = false; - const char *endOfKey = 0, *locale = 0, *elocale = 0; - for (; (s < eof) && (*s != '\n'); s++) - { - if (*s == '=') //find the equal sign - { - if (!endOfKey) - endOfKey = s; - goto haveeq; - } - if (*s == '[') //find the locale or options. - { - const char *option; - const char *eoption; - endOfKey = s; - option = ++s; - for (;; s++) - { - if ((s >= eof) || (*s == '\n') || (*s == '=')) { - fprintf(stderr, "Invalid entry (missing ']') at %s:%d\n", rFile.name().latin1(), line); - goto sktoeol; - } - if (*s == ']') - break; - } - eoption = s; - if (*option != '$') - { - // Locale - if (locale) { - fprintf(stderr, "Invalid entry (second locale!?) at %s:%d\n", rFile.name().latin1(), line); - goto sktoeol; - } - locale = option; - elocale = eoption; - } - else - { - // Option - while (option < eoption) - { - option++; - if ((*option == 'i') && !kde_kiosk_exception) - optionImmutable = true; - else if (*option == 'e') - optionExpand = true; - else if (*option == 'd') - { - optionDeleted = true; - goto haveeq; - } - else if (*option == ']') - break; - } - } - } - } - fprintf(stderr, "Invalid entry (missing '=') at %s:%d\n", rFile.name().latin1(), line); - continue; - - haveeq: - for (endOfKey--; ; endOfKey--) - { - if (endOfKey < startLine) - { - fprintf(stderr, "Invalid entry (empty key) at %s:%d\n", rFile.name().latin1(), line); - goto sktoeol; - } - if (!isspace(*endOfKey)) - break; - } - - const char *st = ++s; - while ((s < eof) && (*s != '\n')) s++; // Search till end of line / end of file - - if (locale) { - unsigned int cl = static_cast(elocale - locale); - if ((ll != cl) || memcmp(locale, localeString.data(), ll)) - { - // backward compatibility. C == en_US - if ( cl != 1 || ll != 5 || *locale != 'C' || memcmp(localeString.data(), "en_US", 5)) { - //cout<<"mismatched locale '"<insert(aEntryKey, aEntry); - } else { - // directly insert value into config object - // no need to specify localization; if the key we just - // retrieved was localized already, no need to localize it again. - pConfig->putData(aEntryKey, aEntry, false); - } - } - // Look up translations using KLocale - // https://launchpad.net/distros/ubuntu/+spec/langpacks-desktopfiles-kde - // This calls KLocale up to 10 times for each config file (and each TDEConfig has up to 4 files) - // so I'll see how much of a performance hit it is - // it also only acts on the last group in a file - // Ideas: only translate most important fields, only translate "Desktop Entry" files, - // do translation per TDEConfig not per single file - if (!pWriteBackMap) { - TQFile file("file.txt"); - if (foundGettextDomain) { - - KLocale locale(gettextDomain); - - TQString language = locale.language(); - translateKey(locale, aCurrentGroup, TQCString("Name")); - translateKey(locale, aCurrentGroup, TQCString("Comment")); - translateKey(locale, aCurrentGroup, TQCString("Language")); - translateKey(locale, aCurrentGroup, TQCString("Keywords")); - translateKey(locale, aCurrentGroup, TQCString("About")); - translateKey(locale, aCurrentGroup, TQCString("Description")); - translateKey(locale, aCurrentGroup, TQCString("GenericName")); - translateKey(locale, aCurrentGroup, TQCString("Query")); - translateKey(locale, aCurrentGroup, TQCString("ExtraNames")); - translateKey(locale, aCurrentGroup, TQCString("X-TDE-Submenu")); - } - } - - - if (fileOptionImmutable) - bFileImmutable = true; - -#ifdef HAVE_MMAP - if (map) - { - munmap(( char* )map, rFile.size()); -#ifdef SIGBUS - sigaction (SIGBUS, &mmap_old_sigact, 0); -#endif - } -#endif -} - -void TDEConfigINIBackEnd::translateKey(KLocale& locale, TQCString currentGroup, TQCString key) { - KEntryKey entryKey = KEntryKey(currentGroup, key); - KEntry entry = pConfig->lookupData(entryKey); - if (TQString(entry.mValue) != "") { - TQString orig = key + "=" + entry.mValue; - TQString translate = locale.translate(key + "=" + entry.mValue); - if (TQString::compare(orig, translate) != 0) { - translate = translate.mid(key.length() + 1); - entry.mValue = translate.utf8(); - entryKey.bLocal = true; - entry.bNLS = true; - pConfig->putData(entryKey, entry, false); - } - } -} - -void TDEConfigINIBackEnd::sync(bool bMerge) -{ - // write-sync is only necessary if there are dirty entries - if (!pConfig->isDirty()) - return; - - bool bEntriesLeft = true; - - // find out the file to write to (most specific writable file) - // try local app-specific file first - - if (!mfileName.isEmpty()) { - // Create the containing dir if needed - if ((resType!="config") && !TQDir::isRelativePath(mLocalFileName)) - { - KURL path; - path.setPath(mLocalFileName); - TQString dir=path.directory(); - KStandardDirs::makeDir(dir); - } - - // Can we allow the write? We can, if the program - // doesn't run SUID. But if it runs SUID, we must - // check if the user would be allowed to write if - // it wasn't SUID. - if (checkAccess(mLocalFileName, W_OK)) { - // File is writable - KLockFile::Ptr lf; - - bool mergeLocalFile = bMerge; - // Check if the file has been updated since. - if (mergeLocalFile) - { - lf = lockFile(false); // Lock file for local file - if (lf && lf->isLocked()) - lf = 0; // Already locked, we don't need to lock/unlock again - - if (lf) - { - lf->lock( KLockFile::LockForce ); - // But what if the locking failed? Ignore it for now... - } - - TQFileInfo info(mLocalFileName); - if ((d->localLastSize == info.size()) && - (d->localLastModified == info.lastModified())) - { - // Not changed, don't merge. - mergeLocalFile = false; - } - else - { - // Changed... - d->localLastModified = TQDateTime(); - d->localLastSize = 0; - } - } - - bEntriesLeft = writeConfigFile( mLocalFileName, false, mergeLocalFile ); - - // Only if we didn't have to merge anything can we use our in-memory state - // the next time around. Otherwise the config-file may contain entries - // that are different from our in-memory state which means we will have to - // do a merge from then on. - // We do not automatically update the in-memory state with the on-disk - // state when writing the config to disk. We only do so when - // KCOnfig::reparseConfiguration() is called. - // For KDE 4.0 we may wish to reconsider that. - if (!mergeLocalFile) - { - TQFileInfo info(mLocalFileName); - d->localLastModified = info.lastModified(); - d->localLastSize = info.size(); - } - if (lf) lf->unlock(); - } - } - - // only write out entries to the kdeglobals file if there are any - // entries marked global (indicated by bEntriesLeft) and - // the useKDEGlobals flag is set. - if (bEntriesLeft && useKDEGlobals) { - - // can we allow the write? (see above) - if (checkAccess ( mGlobalFileName, W_OK )) { - KLockFile::Ptr lf = lockFile(true); // Lock file for global file - if (lf && lf->isLocked()) - lf = 0; // Already locked, we don't need to lock/unlock again - - if (lf) - { - lf->lock( KLockFile::LockForce ); - // But what if the locking failed? Ignore it for now... - } - writeConfigFile( mGlobalFileName, true, bMerge ); // Always merge - if (lf) lf->unlock(); - } - } - -} - -static void writeEntries(FILE *pStream, const KEntryMap& entryMap, bool defaultGroup, bool &firstEntry, const TQCString &localeString) -{ - // now write out all other groups. - TQCString currentGroup; - for (KEntryMapConstIterator aIt = entryMap.begin(); - aIt != entryMap.end(); ++aIt) - { - const KEntryKey &key = aIt.key(); - - // Either proces the default group or all others - if ((key.mGroup != "") == defaultGroup) - continue; // Skip - - // Skip default values and group headers. - if ((key.bDefault) || key.mKey.isEmpty()) - continue; // Skip - - const KEntry ¤tEntry = *aIt; - - KEntryMapConstIterator aTestIt = aIt; - ++aTestIt; - bool hasDefault = (aTestIt != entryMap.end()); - if (hasDefault) - { - const KEntryKey &defaultKey = aTestIt.key(); - if ((!defaultKey.bDefault) || - (defaultKey.mKey != key.mKey) || - (defaultKey.mGroup != key.mGroup) || - (defaultKey.bLocal != key.bLocal)) - hasDefault = false; - } - - - if (hasDefault) - { - // Entry had a default value - if ((currentEntry.mValue == (*aTestIt).mValue) && - (currentEntry.bDeleted == (*aTestIt).bDeleted)) - continue; // Same as default, don't write. - } - else - { - // Entry had no default value. - if (currentEntry.bDeleted) - continue; // Don't write deleted entries if there is no default. - } - - if (!defaultGroup && (currentGroup != key.mGroup)) { - if (!firstEntry) - fprintf(pStream, "\n"); - currentGroup = key.mGroup; - fprintf(pStream, "[%s]\n", encodeGroup(currentGroup).data()); - } - - firstEntry = false; - // it is data for a group - fputs(encodeKey(key.mKey.data()), pStream); // Key - - if ( currentEntry.bNLS ) - { - fputc('[', pStream); - fputs(localeString.data(), pStream); - fputc(']', pStream); - } - - if (currentEntry.bDeleted) - { - fputs("[$d]\n", pStream); // Deleted - } - else - { - if (currentEntry.bImmutable || currentEntry.bExpand) - { - fputc('[', pStream); - fputc('$', pStream); - if (currentEntry.bImmutable) - fputc('i', pStream); - if (currentEntry.bExpand) - fputc('e', pStream); - - fputc(']', pStream); - } - fputc('=', pStream); - fputs(stringToPrintable(currentEntry.mValue).data(), pStream); - fputc('\n', pStream); - } - } // for loop -} - -bool TDEConfigINIBackEnd::getEntryMap(KEntryMap &aTempMap, bool bGlobal, - TQFile *mergeFile) -{ - bool bEntriesLeft = false; - bFileImmutable = false; - - // Read entries from disk - if (mergeFile && mergeFile->open(IO_ReadOnly)) - { - // fill the temporary structure with entries from the file - parseSingleConfigFile(*mergeFile, &aTempMap, bGlobal, false ); - - if (bFileImmutable) // File has become immutable on disk - return bEntriesLeft; - } - - KEntryMap aMap = pConfig->internalEntryMap(); - - // augment this structure with the dirty entries from the config object - for (KEntryMapIterator aIt = aMap.begin(); - aIt != aMap.end(); ++aIt) - { - const KEntry ¤tEntry = *aIt; - if(aIt.key().bDefault) - { - aTempMap.replace(aIt.key(), currentEntry); - continue; - } - - if (mergeFile && !currentEntry.bDirty) - continue; - - // only write back entries that have the same - // "globality" as the file - if (currentEntry.bGlobal != bGlobal) - { - // wrong "globality" - might have to be saved later - bEntriesLeft = true; - continue; - } - - // put this entry from the config object into the - // temporary map, possibly replacing an existing entry - KEntryMapIterator aIt2 = aTempMap.find(aIt.key()); - if (aIt2 != aTempMap.end() && (*aIt2).bImmutable) - continue; // Bail out if the on-disk entry is immutable - - aTempMap.insert(aIt.key(), currentEntry, true); - } // loop - - return bEntriesLeft; -} - -/* antlarr: KDE 4.0: make the first parameter "const TQString &" */ -bool TDEConfigINIBackEnd::writeConfigFile(TQString filename, bool bGlobal, - bool bMerge) -{ - // is the config object read-only? - if (pConfig->isReadOnly()) - return true; // pretend we wrote it - - KEntryMap aTempMap; - TQFile *mergeFile = (bMerge ? new TQFile(filename) : 0); - bool bEntriesLeft = getEntryMap(aTempMap, bGlobal, mergeFile); - delete mergeFile; - if (bFileImmutable) - return true; // pretend we wrote it - - // OK now the temporary map should be full of ALL entries. - // write it out to disk. - - // Check if file exists: - int fileMode = -1; - bool createNew = true; - - KDE_struct_stat buf; - if (KDE_stat(TQFile::encodeName(filename), &buf) == 0) - { - if (buf.st_uid == getuid()) - { - // Preserve file mode if file exists and is owned by user. - fileMode = buf.st_mode & 0777; - } - else - { - // File is not owned by user: - // Don't create new file but write to existing file instead. - createNew = false; - } - } - - KSaveFile *pConfigFile = 0; - FILE *pStream = 0; - - if (createNew) - { - pConfigFile = new KSaveFile( filename, 0600 ); - - if (pConfigFile->status() != 0) - { - delete pConfigFile; - return bEntriesLeft; - } - - if (!bGlobal && (fileMode == -1)) - fileMode = mFileMode; - - if (fileMode != -1) - { - fchmod(pConfigFile->handle(), fileMode); - } - - pStream = pConfigFile->fstream(); - } - else - { - // Open existing file. - // We use open() to ensure that we call without O_CREAT. - int fd = KDE_open( TQFile::encodeName(filename), O_WRONLY | O_TRUNC ); - if (fd < 0) - { - return bEntriesLeft; - } - pStream = KDE_fdopen( fd, "w"); - if (!pStream) - { - close(fd); - return bEntriesLeft; - } - } - - writeEntries(pStream, aTempMap); - - if (pConfigFile) - { - bool bEmptyFile = (ftell(pStream) == 0); - if ( bEmptyFile && ((fileMode == -1) || (fileMode == 0600)) ) - { - // File is empty and doesn't have special permissions: delete it. - ::unlink(TQFile::encodeName(filename)); - pConfigFile->abort(); - } - else - { - // Normal case: Close the file - pConfigFile->close(); - } - delete pConfigFile; - } - else - { - fclose(pStream); - } - - return bEntriesLeft; -} - -void TDEConfigINIBackEnd::writeEntries(FILE *pStream, const KEntryMap &aTempMap) -{ - bool firstEntry = true; - - // Write default group - ::writeEntries(pStream, aTempMap, true, firstEntry, localeString); - - // Write all other groups - ::writeEntries(pStream, aTempMap, false, firstEntry, localeString); -} - -void TDEConfigBackEnd::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void TDEConfigINIBackEnd::virtual_hook( int id, void* data ) -{ TDEConfigBackEnd::virtual_hook( id, data ); } - -bool TDEConfigBackEnd::checkConfigFilesWritable(bool warnUser) -{ - // WARNING: Do NOT use the event loop as it may not exist at this time. - bool allWritable = true; - TQString errorMsg; - if ( !mLocalFileName.isEmpty() && !bFileImmutable && !checkAccess(mLocalFileName,W_OK) ) - { - errorMsg = i18n("Will not save configuration.\n"); - allWritable = false; - errorMsg += i18n("Configuration file \"%1\" not writable.\n").arg(mLocalFileName); - } - // We do not have an immutability flag for kdeglobals. However, making kdeglobals mutable while making - // the local config file immutable is senseless. - if ( !mGlobalFileName.isEmpty() && useKDEGlobals && !bFileImmutable && !checkAccess(mGlobalFileName,W_OK) ) - { - if ( errorMsg.isEmpty() ) - errorMsg = i18n("Will not save configuration.\n"); - errorMsg += i18n("Configuration file \"%1\" not writable.\n").arg(mGlobalFileName); - allWritable = false; - } - - if (warnUser && !allWritable) - { - // Note: We don't ask the user if we should not ask this question again because we can't save the answer. - errorMsg += i18n("Please contact your system administrator."); - TQString cmdToExec = KStandardDirs::findExe(TQString("kdialog")); - TDEApplication *app = kapp; - if (!cmdToExec.isEmpty() && app) - { - TDEProcess lprocess; - lprocess << cmdToExec << "--title" << app->instanceName() << "--msgbox" << TQCString(errorMsg.local8Bit()); - lprocess.start( TDEProcess::Block ); - } - } - return allWritable; -} diff --git a/tdecore/kconfigbackend.h b/tdecore/kconfigbackend.h deleted file mode 100644 index 87ddfa3bb..000000000 --- a/tdecore/kconfigbackend.h +++ /dev/null @@ -1,299 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown - Portions copyright (c) 1997 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef _KCONFIGBACKEND_H -#define _KCONFIGBACKEND_H - -#include "kconfigdata.h" -#include -#include -#include -#include "tdelibs_export.h" - -class TQFile; -class TDEConfigBackEndPrivate; - -/** - * Abstract base class for KDE configuration file loading/saving. - * - * This class forms the base for all classes that implement some - * manner of loading/saving to configuration files. It is an - * abstract base class, meaning that you cannot directly instantiate - * objects of this class. As of right now, the only back end available - * is one to read/write to INI-style files, but in the future, other - * formats may be available, such as XML or a database. - * - * @author Preston Brown , - * Matthias Kalle Dalheimer - * @short KDE Configuration file loading/saving abstract base class - */ -class TDECORE_EXPORT TDEConfigBackEnd -{ - friend class TDEConfig; - friend class KSharedConfig; -public: - /** - * Constructs a configuration back end. - * - * @param _config Specifies the configuration object which values - * will be passed to as they are read, or from where values - * to be written to will be obtained from. - * @param _fileName The name of the file in which config - * data is stored. All registered configuration directories - * will be looked in in order of decreasing relevance. - * @param _resType the resource type of the fileName specified, _if_ - * it is not an absolute path (otherwise this parameter is ignored). - * @param _useKDEGlobals If true, the user's system-wide kdeglobals file - * will be imported into the config object. If false, only - * the filename specified will be dealt with. - */ - TDEConfigBackEnd(TDEConfigBase *_config, const TQString &_fileName, - const char * _resType, bool _useKDEGlobals); - - /** - * Destructs the configuration backend. - */ - virtual ~TDEConfigBackEnd(); - - /** - * Parses all configuration files for a configuration object. This - * method must be reimplemented by the derived classes. - * - * @returns Whether or not parsing was successful. - */ - virtual bool parseConfigFiles() = 0; - - /** - * Writes configuration data to file(s). This method must be - * reimplemented by the derived classes. - * - * @param bMerge Specifies whether the old config file already - * on disk should be merged in with the data in memory. If true, - * data is read off the disk and merged. If false, the on-disk - * file is removed and only in-memory data is written out. - */ - virtual void sync(bool bMerge = true) = 0; - - /** - * Changes the filenames associated with this back end. You should - * probably reparse your config info after doing this. - * - * @param _fileName the new filename to use - * @param _resType the resource type of the fileName specified, _if_ - * it is not an absolute path (otherwise this parameter is ignored). - * @param _useKDEGlobals specifies whether or not to also parse the - * global KDE configuration files. - */ - void changeFileName(const TQString &_fileName, const char * _resType, - bool _useKDEGlobals); - - /** - * Returns the state of the app-config object. - * - * @see TDEConfig::getConfigState - */ - virtual TDEConfigBase::ConfigState getConfigState() const - { return mConfigState; } - - /** - * Returns the filename as passed to the constructor. - * @return the filename as passed to the constructor. - */ - TQString fileName() const { return mfileName; } - - /** - * Returns the resource type as passed to the constructor. - * @return the resource type as passed to the constructor. - */ - const char * resource() const { return resType; } - - /** - * Set the locale string that defines the current language. - * @param _localeString the identifier of the language - * @see KLocale - */ - void setLocaleString(const TQCString &_localeString) { localeString = _localeString; } - - /** - * Set the file mode for newly created files. - * @param mode the filemode (as in chmod) - */ - void setFileWriteMode(int mode); - - /** - * Check whether the config files are writable. - * @param warnUser Warn the user if the configuration files are not writable. - * @return Indicates that all of the configuration files used are writable. - * @since 3.2 - */ - bool checkConfigFilesWritable(bool warnUser); - - /** - * Returns a lock file object for the configuration file - * @param bGlobal If true, returns a lock file object for kdeglobals - * @since 3.3 - */ - KLockFile::Ptr lockFile( bool bGlobal = false ); - -#ifdef KDE_NO_COMPAT -private: -#endif - /** - * @deprecated Use fileName() instead - */ - KDE_DEPRECATED TQString filename() const { return mfileName; } - -protected: - TDEConfigBase *pConfig; - - TQString mfileName; - TQCString resType; - bool useKDEGlobals : 1; - bool bFileImmutable : 1; - TQCString localeString; - TQString mLocalFileName; - TQString mGlobalFileName; - TDEConfigBase::ConfigState mConfigState; - int mFileMode; - -protected: - virtual void virtual_hook( int id, void* data ); -protected: - class TDEConfigBackEndPrivate; - TDEConfigBackEndPrivate *d; -}; - - -/** - * Class for KDE INI-style configuration file loading/saving. - * - * @author Preston Brown , - * Matthias Kalle Dalheimer - */ -class TDECORE_EXPORT TDEConfigINIBackEnd : public TDEConfigBackEnd -{ - -public: - /** - * Constructs an ini-style configuration back end. - * - * @param _config Specifies the configuration object which values - * will be passed to as they are read, or from where values - * to be written to will be obtained from. - * @param _fileName The name of the file in which config - * data is stored. All registered configuration directories - * will be looked in in order of decreasing relevance. - * @param _resType the resource type of the fileName specified, _if_ - * it is not an absolute path (otherwise this parameter is ignored). - * @param _useKDEGlobals If true, the user's system-wide kdeglobals file - * will be imported into the config object. If false, only - * the filename specified will be dealt with. - */ - TDEConfigINIBackEnd(TDEConfigBase *_config, const TQString &_fileName, - const char * _resType, bool _useKDEGlobals = true) - : TDEConfigBackEnd(_config, _fileName, _resType, _useKDEGlobals) {} - - /** - * Destructs the configuration backend. - */ - virtual ~TDEConfigINIBackEnd() {} - - /** - * Parses all INI-style configuration files for a config object. - * - * @returns Whether or not parsing was successful. - */ - bool parseConfigFiles(); - - /** - * Writes configuration data to file(s). - * @param bMerge Specifies whether the old config file already - * on disk should be merged in with the data in memory. If true, - * data is read off the disk and merged. If false, the on-disk - * file is removed and only in-memory data is written out. - */ - virtual void sync(bool bMerge = true); - -protected: - /** - * Parses one configuration file. - * - * @param rFile The configuration file to parse - * @param pWriteBackMap If specified, points to a KEntryMap where - * the data read from the file should be stored, instead of - * inserting them directly into the configuration object. - * Use this area as a "scratchpad" when you need to know what is - * on disk but don't want to effect the configuration object. - * @param bGlobal Specifies whether entries should be marked as - * belonging to the global KDE configuration file rather - * than the application-specific KDE configuration file(s). - * @param bDefault Specifies whether entries should be marked as - * being default values. - */ - void parseSingleConfigFile(TQFile& rFile, KEntryMap *pWriteBackMap = 0L, - bool bGlobal = false, bool bDefault = false); - - // Kubuntu patch, 2006-08-03 - // looks up a key in with KLocale - // see https://launchpad.net/distros/ubuntu/+spec/langpacks-desktopfiles-kde - void translateKey(KLocale& locale, TQCString currentGroup, TQCString key); - - /** - * Writes configuration file back. - * - * @param filename The name of the file to write. - * @param bGlobal Specifies whether to write only entries which - * are marked as belonging to the global KDE config file. - * If this is false, it skips those entries. - * @param bMerge Specifies whether the old config file already - * on disk should be merged in with the data in memory. If true, - * data is read off the disk and merged. If false, the on-disk - * file is removed and only in-memory data is written out. - * @return Whether some entries are left to be written to other - * files. - */ - bool writeConfigFile(TQString filename, bool bGlobal = false, bool bMerge = true); - - /** Get the entry map. - * - * @param map the entries will be stored in this object. - * @param bGlobal Specifies whether to get only entries which - * are marked as belonging to the global KDE config file. - * If this is false, it skips those entries. - * @param mergeFile if not null, the dirty entries for this file will - * be merged. - * - * @return Whether there will be some entries left for writing to other - * files. - */ - bool getEntryMap(KEntryMap &map, bool bGlobal, TQFile *mergeFile); - - /** Write the entries in @e aTempMap to the file stream.*/ - void writeEntries(FILE *pStream, const KEntryMap &aTempMap); - -protected: - virtual void virtual_hook( int id, void* data ); -private: - class TDEConfigINIBackEndPrivate; - TDEConfigINIBackEndPrivate *not_d; -}; - -#endif diff --git a/tdecore/kconfigbase.cpp b/tdecore/kconfigbase.cpp deleted file mode 100644 index e65338c50..000000000 --- a/tdecore/kconfigbase.cpp +++ /dev/null @@ -1,1937 +0,0 @@ -// -*- c-basic-offset: 2 -*- -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown - Copyright (c) 1997 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "kconfigbase.h" -#include "kconfigbackend.h" -#include "kdebug.h" -#include "kstandarddirs.h" -#include "kstringhandler.h" - -class TDEConfigBase::TDEConfigBasePrivate -{ -public: - TDEConfigBasePrivate() : readDefaults(false) { }; - -public: - bool readDefaults; -}; - -TDEConfigBase::TDEConfigBase() - : backEnd(0L), bDirty(false), bLocaleInitialized(false), - bReadOnly(false), bExpand(false), d(0) -{ - setGroup(TQString::null); -} - -TDEConfigBase::~TDEConfigBase() -{ - delete d; -} - -void TDEConfigBase::setLocale() -{ - bLocaleInitialized = true; - - if (TDEGlobal::locale()) - aLocaleString = TDEGlobal::locale()->language().utf8(); - else - aLocaleString = KLocale::defaultLanguage().utf8(); - if (backEnd) - backEnd->setLocaleString(aLocaleString); -} - -TQString TDEConfigBase::locale() const -{ - return TQString::fromUtf8(aLocaleString); -} - -void TDEConfigBase::setGroup( const TQString& group ) -{ - if ( group.isEmpty() ) - mGroup = ""; - else - mGroup = group.utf8(); -} - -void TDEConfigBase::setGroup( const char *pGroup ) -{ - setGroup(TQCString(pGroup)); -} - -void TDEConfigBase::setGroup( const TQCString &group ) -{ - if ( group.isEmpty() ) - mGroup = ""; - else - mGroup = group; -} - -TQString TDEConfigBase::group() const { - return TQString::fromUtf8(mGroup); -} - -void TDEConfigBase::setDesktopGroup() -{ - mGroup = "Desktop Entry"; -} - -bool TDEConfigBase::hasKey(const TQString &key) const -{ - return hasKey(key.utf8().data()); -} - -bool TDEConfigBase::hasKey(const char *pKey) const -{ - KEntryKey aEntryKey(mGroup, 0); - aEntryKey.c_key = pKey; - aEntryKey.bDefault = readDefaults(); - - if (!locale().isNull()) { - // try the localized key first - aEntryKey.bLocal = true; - KEntry entry = lookupData(aEntryKey); - if (!entry.mValue.isNull()) - return true; - aEntryKey.bLocal = false; - } - - // try the non-localized version - KEntry entry = lookupData(aEntryKey); - return !entry.mValue.isNull(); -} - -bool TDEConfigBase::hasTranslatedKey(const char* pKey) const -{ - KEntryKey aEntryKey(mGroup, 0); - aEntryKey.c_key = pKey; - aEntryKey.bDefault = readDefaults(); - - if (!locale().isNull()) { - // try the localized key first - aEntryKey.bLocal = true; - KEntry entry = lookupData(aEntryKey); - if (!entry.mValue.isNull()) - return true; - aEntryKey.bLocal = false; - } - - return false; -} - -bool TDEConfigBase::hasGroup(const TQString &group) const -{ - return internalHasGroup( group.utf8()); -} - -bool TDEConfigBase::hasGroup(const char *_pGroup) const -{ - return internalHasGroup( TQCString(_pGroup)); -} - -bool TDEConfigBase::hasGroup(const TQCString &_pGroup) const -{ - return internalHasGroup( _pGroup); -} - -bool TDEConfigBase::isImmutable() const -{ - return (getConfigState() != ReadWrite); -} - -bool TDEConfigBase::groupIsImmutable(const TQString &group) const -{ - if (getConfigState() != ReadWrite) - return true; - - KEntryKey groupKey(group.utf8(), 0); - KEntry entry = lookupData(groupKey); - return entry.bImmutable; -} - -bool TDEConfigBase::entryIsImmutable(const TQString &key) const -{ - if (getConfigState() != ReadWrite) - return true; - - KEntryKey entryKey(mGroup, 0); - KEntry aEntryData = lookupData(entryKey); // Group - if (aEntryData.bImmutable) - return true; - - TQCString utf8_key = key.utf8(); - entryKey.c_key = utf8_key.data(); - aEntryData = lookupData(entryKey); // Normal entry - if (aEntryData.bImmutable) - return true; - - entryKey.bLocal = true; - aEntryData = lookupData(entryKey); // Localized entry - return aEntryData.bImmutable; -} - - -TQString TDEConfigBase::readEntryUntranslated( const TQString& pKey, - const TQString& aDefault ) const -{ - return TDEConfigBase::readEntryUntranslated(pKey.utf8().data(), aDefault); -} - - -TQString TDEConfigBase::readEntryUntranslated( const char *pKey, - const TQString& aDefault ) const -{ - TQCString result = readEntryUtf8(pKey); - if (result.isNull()) - return aDefault; - return TQString::fromUtf8(result); -} - - -TQString TDEConfigBase::readEntry( const TQString& pKey, - const TQString& aDefault ) const -{ - return TDEConfigBase::readEntry(pKey.utf8().data(), aDefault); -} - -TQString TDEConfigBase::readEntry( const char *pKey, - const TQString& aDefault ) const -{ - // we need to access _locale instead of the method locale() - // because calling locale() will create a locale object if it - // doesn't exist, which requires TDEConfig, which will create a infinite - // loop, and nobody likes those. - if (!bLocaleInitialized && TDEGlobal::_locale) { - // get around const'ness. - TDEConfigBase *that = const_cast(this); - that->setLocale(); - } - - TQString aValue; - - bool expand = false; - // construct a localized version of the key - // try the localized key first - KEntry aEntryData; - KEntryKey entryKey(mGroup, 0); - entryKey.c_key = pKey; - entryKey.bDefault = readDefaults(); - entryKey.bLocal = true; - aEntryData = lookupData(entryKey); - if (!aEntryData.mValue.isNull()) { - // for GNOME .desktop - aValue = KStringHandler::from8Bit( aEntryData.mValue.data() ); - expand = aEntryData.bExpand; - } else { - entryKey.bLocal = false; - aEntryData = lookupData(entryKey); - if (!aEntryData.mValue.isNull()) { - aValue = TQString::fromUtf8(aEntryData.mValue.data()); - if (aValue.isNull()) - { - static const TQString &emptyString = TDEGlobal::staticQString(""); - aValue = emptyString; - } - expand = aEntryData.bExpand; - } else { - aValue = aDefault; - } - } - - // only do dollar expansion if so desired - if( expand || bExpand ) - { - // check for environment variables and make necessary translations - int nDollarPos = aValue.find( '$' ); - - while( nDollarPos != -1 && nDollarPos+1 < static_cast(aValue.length())) { - // there is at least one $ - if( (aValue)[nDollarPos+1] == '(' ) { - uint nEndPos = nDollarPos+1; - // the next character is no $ - while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!=')') ) - nEndPos++; - nEndPos++; - TQString cmd = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); - - TQString result; - FILE *fs = popen(TQFile::encodeName(cmd).data(), "r"); - if (fs) - { - { - TQTextStream ts(fs, IO_ReadOnly); - result = ts.read().stripWhiteSpace(); - } - pclose(fs); - } - aValue.replace( nDollarPos, nEndPos-nDollarPos, result ); - } else if( (aValue)[nDollarPos+1] != '$' ) { - uint nEndPos = nDollarPos+1; - // the next character is no $ - TQString aVarName; - if (aValue[nEndPos]=='{') - { - while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!='}') ) - nEndPos++; - nEndPos++; - aVarName = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); - } - else - { - while ( nEndPos <= aValue.length() && (aValue[nEndPos].isNumber() - || aValue[nEndPos].isLetter() || aValue[nEndPos]=='_' ) ) - nEndPos++; - aVarName = aValue.mid( nDollarPos+1, nEndPos-nDollarPos-1 ); - } - const char* pEnv = 0; - if (!aVarName.isEmpty()) - pEnv = getenv( aVarName.ascii() ); - if( pEnv ) { - // !!! Sergey A. Sukiyazov !!! - // A environment variables may contain values in 8bit - // locale cpecified encoding or in UTF8 encoding. - aValue.replace( nDollarPos, nEndPos-nDollarPos, KStringHandler::from8Bit( pEnv ) ); - } else - aValue.remove( nDollarPos, nEndPos-nDollarPos ); - } else { - // remove one of the dollar signs - aValue.remove( nDollarPos, 1 ); - nDollarPos++; - } - nDollarPos = aValue.find( '$', nDollarPos ); - } - } - - return aValue; -} - -TQCString TDEConfigBase::readEntryUtf8( const char *pKey) const -{ - // We don't try the localized key - KEntryKey entryKey(mGroup, 0); - entryKey.bDefault = readDefaults(); - entryKey.c_key = pKey; - KEntry aEntryData = lookupData(entryKey); - if (aEntryData.bExpand) - { - // We need to do fancy, take the slow route. - return readEntry(pKey, TQString::null).utf8(); - } - return aEntryData.mValue; -} - -TQVariant TDEConfigBase::readPropertyEntry( const TQString& pKey, - TQVariant::Type type ) const -{ - return readPropertyEntry(pKey.utf8().data(), type); -} - -TQVariant TDEConfigBase::readPropertyEntry( const char *pKey, - TQVariant::Type type ) const -{ - TQVariant va; - if ( !hasKey( pKey ) ) return va; - (void)va.cast(type); - return readPropertyEntry(pKey, va); -} - -TQVariant TDEConfigBase::readPropertyEntry( const TQString& pKey, - const TQVariant &aDefault ) const -{ - return readPropertyEntry(pKey.utf8().data(), aDefault); -} - -TQVariant TDEConfigBase::readPropertyEntry( const char *pKey, - const TQVariant &aDefault ) const -{ - if ( !hasKey( pKey ) ) return aDefault; - - TQVariant tmp = aDefault; - - switch( aDefault.type() ) - { - case TQVariant::Invalid: - return TQVariant(); - case TQVariant::String: - return TQVariant( readEntry( pKey, aDefault.toString() ) ); - case TQVariant::StringList: - return TQVariant( readListEntry( pKey ) ); - case TQVariant::List: { - TQStringList strList = readListEntry( pKey ); - TQStringList::ConstIterator it = strList.begin(); - TQStringList::ConstIterator end = strList.end(); - TQValueList list; - - for (; it != end; ++it ) { - tmp = *it; - list.append( tmp ); - } - return TQVariant( list ); - } - case TQVariant::Font: - return TQVariant( readFontEntry( pKey, &tmp.asFont() ) ); - case TQVariant::Point: - return TQVariant( readPointEntry( pKey, &tmp.asPoint() ) ); - case TQVariant::Rect: - return TQVariant( readRectEntry( pKey, &tmp.asRect() ) ); - case TQVariant::Size: - return TQVariant( readSizeEntry( pKey, &tmp.asSize() ) ); - case TQVariant::Color: - return TQVariant( readColorEntry( pKey, &tmp.asColor() ) ); - case TQVariant::Int: - return TQVariant( readNumEntry( pKey, aDefault.toInt() ) ); - case TQVariant::UInt: - return TQVariant( readUnsignedNumEntry( pKey, aDefault.toUInt() ) ); - case TQVariant::LongLong: - return TQVariant( readNum64Entry( pKey, aDefault.toLongLong() ) ); - case TQVariant::ULongLong: - return TQVariant( readUnsignedNum64Entry( pKey, aDefault.toULongLong() ) ); - case TQVariant::Bool: - return TQVariant( readBoolEntry( pKey, aDefault.toBool() ), 0 ); - case TQVariant::Double: - return TQVariant( readDoubleNumEntry( pKey, aDefault.toDouble() ) ); - case TQVariant::DateTime: - return TQVariant( readDateTimeEntry( pKey, &tmp.asDateTime() ) ); - case TQVariant::Date: - return TQVariant(TQT_TQDATE_OBJECT(readDateTimeEntry( pKey, &tmp.asDateTime() ).date())); - - case TQVariant::Pixmap: - case TQVariant::Image: - case TQVariant::Brush: - case TQVariant::Palette: - case TQVariant::ColorGroup: - case TQVariant::Map: - case TQVariant::IconSet: - case TQVariant::CString: - case TQVariant::PointArray: - case TQVariant::Region: - case TQVariant::Bitmap: - case TQVariant::Cursor: - case TQVariant::SizePolicy: - case TQVariant::Time: -#ifdef USE_QT3 - case TQVariant::ByteArray: -#endif // USE_QT3 - case TQVariant::BitArray: - case TQVariant::KeySequence: - case TQVariant::Pen: -#ifdef USE_QT4 - case TQVariant::Char: - case TQVariant::Url: - case TQVariant::Locale: - case TQVariant::RectF: - case TQVariant::SizeF: - case TQVariant::Line: - case TQVariant::LineF: - case TQVariant::PointF: - case TQVariant::RegExp: - case TQVariant::Hash: - case TQVariant::TextLength: - case QVariant::TextFormat: - case TQVariant::Matrix: - case TQVariant::Transform: - case TQVariant::Matrix4x4: - case TQVariant::Vector2D: - case TQVariant::Vector3D: - case TQVariant::Vector4D: - case TQVariant::Quaternion: - case TQVariant::UserType: -#endif // USE_QT4 - break; - } - - Q_ASSERT( 0 ); - return TQVariant(); -} - -int TDEConfigBase::readListEntry( const TQString& pKey, - TQStrList &list, char sep ) const -{ - return readListEntry(pKey.utf8().data(), list, sep); -} - -int TDEConfigBase::readListEntry( const char *pKey, - TQStrList &list, char sep ) const -{ - if( !hasKey( pKey ) ) - return 0; - - TQCString str_list = readEntryUtf8( pKey ); - if (str_list.isEmpty()) - return 0; - - list.clear(); - TQCString value = ""; - int len = str_list.length(); - - for (int i = 0; i < len; i++) { - if (str_list[i] != sep && str_list[i] != '\\') { - value += str_list[i]; - continue; - } - if (str_list[i] == '\\') { - i++; - if ( i < len ) - value += str_list[i]; - continue; - } - // if we fell through to here, we are at a separator. Append - // contents of value to the list - // !!! Sergey A. Sukiyazov !!! - // A TQStrList may contain values in 8bit locale cpecified - // encoding - list.append( value ); - value.truncate(0); - } - - if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] == '\\' ) ) - list.append( value ); - return list.count(); -} - -TQStringList TDEConfigBase::readListEntry( const TQString& pKey, char sep ) const -{ - return readListEntry(pKey.utf8().data(), sep); -} - -TQStringList TDEConfigBase::readListEntry( const char *pKey, char sep ) const -{ - static const TQString& emptyString = TDEGlobal::staticQString(""); - - TQStringList list; - if( !hasKey( pKey ) ) - return list; - TQString str_list = readEntry( pKey ); - if( str_list.isEmpty() ) - return list; - TQString value(emptyString); - int len = str_list.length(); - // obviously too big, but faster than letting each += resize the string. - value.reserve( len ); - for( int i = 0; i < len; i++ ) - { - if( str_list[i] != sep && str_list[i] != '\\' ) - { - value += str_list[i]; - continue; - } - if( str_list[i] == '\\' ) - { - i++; - if ( i < len ) - value += str_list[i]; - continue; - } - TQString finalvalue( value ); - finalvalue.squeeze(); - list.append( finalvalue ); - value.truncate( 0 ); - } - if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] == '\\' ) ) - { - value.squeeze(); - list.append( value ); - } - return list; -} - -TQStringList TDEConfigBase::readListEntry( const char* pKey, const TQStringList& aDefault, - char sep ) const -{ - if ( !hasKey( pKey ) ) - return aDefault; - else - return readListEntry( pKey, sep ); -} - -TQValueList TDEConfigBase::readIntListEntry( const TQString& pKey ) const -{ - return readIntListEntry(pKey.utf8().data()); -} - -TQValueList TDEConfigBase::readIntListEntry( const char *pKey ) const -{ - TQStringList strlist = readListEntry(pKey); - TQValueList list; - TQStringList::ConstIterator end(strlist.end()); - for (TQStringList::ConstIterator it = strlist.begin(); it != end; ++it) - // I do not check if the toInt failed because I consider the number of items - // more important than their value - list << (*it).toInt(); - - return list; -} - -TQString TDEConfigBase::readPathEntry( const TQString& pKey, const TQString& pDefault ) const -{ - return readPathEntry(pKey.utf8().data(), pDefault); -} - -TQString TDEConfigBase::readPathEntry( const char *pKey, const TQString& pDefault ) const -{ - const bool bExpandSave = bExpand; - bExpand = true; - TQString aValue = readEntry( pKey, pDefault ); - bExpand = bExpandSave; - return aValue; -} - -TQStringList TDEConfigBase::readPathListEntry( const TQString& pKey, char sep ) const -{ - return readPathListEntry(pKey.utf8().data(), sep); -} - -TQStringList TDEConfigBase::readPathListEntry( const char *pKey, char sep ) const -{ - const bool bExpandSave = bExpand; - bExpand = true; - TQStringList aValue = readListEntry( pKey, sep ); - bExpand = bExpandSave; - return aValue; -} - -int TDEConfigBase::readNumEntry( const TQString& pKey, int nDefault) const -{ - return readNumEntry(pKey.utf8().data(), nDefault); -} - -int TDEConfigBase::readNumEntry( const char *pKey, int nDefault) const -{ - TQCString aValue = readEntryUtf8( pKey ); - if( aValue.isNull() ) - return nDefault; - else if( aValue == "true" || aValue == "on" || aValue == "yes" ) - return 1; - else - { - bool ok; - int rc = aValue.toInt( &ok ); - return( ok ? rc : nDefault ); - } -} - - -unsigned int TDEConfigBase::readUnsignedNumEntry( const TQString& pKey, unsigned int nDefault) const -{ - return readUnsignedNumEntry(pKey.utf8().data(), nDefault); -} - -unsigned int TDEConfigBase::readUnsignedNumEntry( const char *pKey, unsigned int nDefault) const -{ - TQCString aValue = readEntryUtf8( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - unsigned int rc = aValue.toUInt( &ok ); - return( ok ? rc : nDefault ); - } -} - - -long TDEConfigBase::readLongNumEntry( const TQString& pKey, long nDefault) const -{ - return readLongNumEntry(pKey.utf8().data(), nDefault); -} - -long TDEConfigBase::readLongNumEntry( const char *pKey, long nDefault) const -{ - TQCString aValue = readEntryUtf8( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - long rc = aValue.toLong( &ok ); - return( ok ? rc : nDefault ); - } -} - - -unsigned long TDEConfigBase::readUnsignedLongNumEntry( const TQString& pKey, unsigned long nDefault) const -{ - return readUnsignedLongNumEntry(pKey.utf8().data(), nDefault); -} - -unsigned long TDEConfigBase::readUnsignedLongNumEntry( const char *pKey, unsigned long nDefault) const -{ - TQCString aValue = readEntryUtf8( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - unsigned long rc = aValue.toULong( &ok ); - return( ok ? rc : nDefault ); - } -} - -TQ_INT64 TDEConfigBase::readNum64Entry( const TQString& pKey, TQ_INT64 nDefault) const -{ - return readNum64Entry(pKey.utf8().data(), nDefault); -} - -TQ_INT64 TDEConfigBase::readNum64Entry( const char *pKey, TQ_INT64 nDefault) const -{ - // Note that TQCString::toLongLong() is missing, we muse use a TQString instead. - TQString aValue = readEntry( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - TQ_INT64 rc = aValue.toLongLong( &ok ); - return( ok ? rc : nDefault ); - } -} - - -TQ_UINT64 TDEConfigBase::readUnsignedNum64Entry( const TQString& pKey, TQ_UINT64 nDefault) const -{ - return readUnsignedNum64Entry(pKey.utf8().data(), nDefault); -} - -TQ_UINT64 TDEConfigBase::readUnsignedNum64Entry( const char *pKey, TQ_UINT64 nDefault) const -{ - // Note that TQCString::toULongLong() is missing, we muse use a TQString instead. - TQString aValue = readEntry( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - TQ_UINT64 rc = aValue.toULongLong( &ok ); - return( ok ? rc : nDefault ); - } -} - -double TDEConfigBase::readDoubleNumEntry( const TQString& pKey, double nDefault) const -{ - return readDoubleNumEntry(pKey.utf8().data(), nDefault); -} - -double TDEConfigBase::readDoubleNumEntry( const char *pKey, double nDefault) const -{ - TQCString aValue = readEntryUtf8( pKey ); - if( aValue.isNull() ) - return nDefault; - else - { - bool ok; - double rc = aValue.toDouble( &ok ); - return( ok ? rc : nDefault ); - } -} - - -bool TDEConfigBase::readBoolEntry( const TQString& pKey, bool bDefault ) const -{ - return readBoolEntry(pKey.utf8().data(), bDefault); -} - -bool TDEConfigBase::readBoolEntry( const char *pKey, bool bDefault ) const -{ - TQCString aValue = readEntryUtf8( pKey ); - - if( aValue.isNull() ) - return bDefault; - else - { - if( aValue == "true" || aValue == "on" || aValue == "yes" || aValue == "1" ) - return true; - else - { - bool bOK; - int val = aValue.toInt( &bOK ); - if( bOK && val != 0 ) - return true; - else - return false; - } - } -} - -TQFont TDEConfigBase::readFontEntry( const TQString& pKey, const TQFont* pDefault ) const -{ - return readFontEntry(pKey.utf8().data(), pDefault); -} - -TQFont TDEConfigBase::readFontEntry( const char *pKey, const TQFont* pDefault ) const -{ - TQFont aRetFont; - - TQString aValue = readEntry( pKey ); - if( !aValue.isNull() ) { - if ( aValue.contains( ',' ) > 5 ) { - // KDE3 and upwards entry - if ( !aRetFont.fromString( aValue ) && pDefault ) - aRetFont = *pDefault; - } - else { - // backward compatibility with older font formats - // ### remove KDE 3.1 ? - // find first part (font family) - int nIndex = aValue.find( ',' ); - if( nIndex == -1 ){ - if( pDefault ) - aRetFont = *pDefault; - return aRetFont; - } - aRetFont.setFamily( aValue.left( nIndex ) ); - - // find second part (point size) - int nOldIndex = nIndex; - nIndex = aValue.find( ',', nOldIndex+1 ); - if( nIndex == -1 ){ - if( pDefault ) - aRetFont = *pDefault; - return aRetFont; - } - - aRetFont.setPointSize( aValue.mid( nOldIndex+1, - nIndex-nOldIndex-1 ).toInt() ); - - // find third part (style hint) - nOldIndex = nIndex; - nIndex = aValue.find( ',', nOldIndex+1 ); - - if( nIndex == -1 ){ - if( pDefault ) - aRetFont = *pDefault; - return aRetFont; - } - - aRetFont.setStyleHint( (TQFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() ); - - // find fourth part (char set) - nOldIndex = nIndex; - nIndex = aValue.find( ',', nOldIndex+1 ); - - if( nIndex == -1 ){ - if( pDefault ) - aRetFont = *pDefault; - return aRetFont; - } - - TQString chStr=aValue.mid( nOldIndex+1, - nIndex-nOldIndex-1 ); - // find fifth part (weight) - nOldIndex = nIndex; - nIndex = aValue.find( ',', nOldIndex+1 ); - - if( nIndex == -1 ){ - if( pDefault ) - aRetFont = *pDefault; - return aRetFont; - } - - aRetFont.setWeight( aValue.mid( nOldIndex+1, - nIndex-nOldIndex-1 ).toUInt() ); - - // find sixth part (font bits) - uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt(); - - aRetFont.setItalic( nFontBits & 0x01 ); - aRetFont.setUnderline( nFontBits & 0x02 ); - aRetFont.setStrikeOut( nFontBits & 0x04 ); - aRetFont.setFixedPitch( nFontBits & 0x08 ); - aRetFont.setRawMode( nFontBits & 0x20 ); - } - } - else - { - if( pDefault ) - aRetFont = *pDefault; - } - - return aRetFont; -} - - -TQRect TDEConfigBase::readRectEntry( const TQString& pKey, const TQRect* pDefault ) const -{ - return readRectEntry(pKey.utf8().data(), pDefault); -} - -TQRect TDEConfigBase::readRectEntry( const char *pKey, const TQRect* pDefault ) const -{ - TQCString aValue = readEntryUtf8(pKey); - - if (!aValue.isEmpty()) - { - int left, top, width, height; - - if (sscanf(aValue.data(), "%d,%d,%d,%d", &left, &top, &width, &height) == 4) - { - return TQRect(left, top, width, height); - } - } - if (pDefault) - return *pDefault; - return TQRect(); -} - - -TQPoint TDEConfigBase::readPointEntry( const TQString& pKey, - const TQPoint* pDefault ) const -{ - return readPointEntry(pKey.utf8().data(), pDefault); -} - -TQPoint TDEConfigBase::readPointEntry( const char *pKey, - const TQPoint* pDefault ) const -{ - TQCString aValue = readEntryUtf8(pKey); - - if (!aValue.isEmpty()) - { - int x,y; - - if (sscanf(aValue.data(), "%d,%d", &x, &y) == 2) - { - return TQPoint(x,y); - } - } - if (pDefault) - return *pDefault; - return TQPoint(); -} - -TQSize TDEConfigBase::readSizeEntry( const TQString& pKey, - const TQSize* pDefault ) const -{ - return readSizeEntry(pKey.utf8().data(), pDefault); -} - -TQSize TDEConfigBase::readSizeEntry( const char *pKey, - const TQSize* pDefault ) const -{ - TQCString aValue = readEntryUtf8(pKey); - - if (!aValue.isEmpty()) - { - int width,height; - - if (sscanf(aValue.data(), "%d,%d", &width, &height) == 2) - { - return TQSize(width, height); - } - } - if (pDefault) - return *pDefault; - return TQSize(); -} - - -TQColor TDEConfigBase::readColorEntry( const TQString& pKey, - const TQColor* pDefault ) const -{ - return readColorEntry(pKey.utf8().data(), pDefault); -} - -TQColor TDEConfigBase::readColorEntry( const char *pKey, - const TQColor* pDefault ) const -{ - TQColor aRetColor; - int nRed = 0, nGreen = 0, nBlue = 0; - - TQString aValue = readEntry( pKey ); - if( !aValue.isEmpty() ) - { - if ( aValue.at(0) == (QChar)'#' ) - { - aRetColor.setNamedColor(aValue); - } - else - { - - bool bOK; - - // find first part (red) - int nIndex = aValue.find( ',' ); - - if( nIndex == -1 ){ - // return a sensible default -- Bernd - if( pDefault ) - aRetColor = *pDefault; - return aRetColor; - } - - nRed = aValue.left( nIndex ).toInt( &bOK ); - - // find second part (green) - int nOldIndex = nIndex; - nIndex = aValue.find( ',', nOldIndex+1 ); - - if( nIndex == -1 ){ - // return a sensible default -- Bernd - if( pDefault ) - aRetColor = *pDefault; - return aRetColor; - } - nGreen = aValue.mid( nOldIndex+1, - nIndex-nOldIndex-1 ).toInt( &bOK ); - - // find third part (blue) - nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK ); - - aRetColor.setRgb( nRed, nGreen, nBlue ); - } - } - else { - - if( pDefault ) - aRetColor = *pDefault; - } - - return aRetColor; -} - - -TQDateTime TDEConfigBase::readDateTimeEntry( const TQString& pKey, - const TQDateTime* pDefault ) const -{ - return readDateTimeEntry(pKey.utf8().data(), pDefault); -} - -// ### currentDateTime() as fallback ? (Harri) -TQDateTime TDEConfigBase::readDateTimeEntry( const char *pKey, - const TQDateTime* pDefault ) const -{ - if( !hasKey( pKey ) ) - { - if( pDefault ) - return *pDefault; - else - return TQDateTime::currentDateTime(); - } - - TQStrList list; - int count = readListEntry( pKey, list, ',' ); - if( count == 6 ) { - TQDate date( atoi( list.at( 0 ) ), atoi( list.at( 1 ) ), - atoi( list.at( 2 ) ) ); - TQTime time( atoi( list.at( 3 ) ), atoi( list.at( 4 ) ), - atoi( list.at( 5 ) ) ); - - return TQDateTime( date, time ); - } - - return TQDateTime::currentDateTime(); -} - -void TDEConfigBase::writeEntry( const TQString& pKey, const TQString& value, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), value, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry( const char *pKey, const TQString& value, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey, value, bPersistent, bGlobal, bNLS, false); -} - -void TDEConfigBase::writeEntry( const char *pKey, const TQString& value, - bool bPersistent, - bool bGlobal, - bool bNLS, - bool bExpand ) -{ - // the TDEConfig object is dirty now - // set this before any IO takes place so that if any derivative - // classes do caching, they won't try and flush the cache out - // from under us before we read. A race condition is still - // possible but minimized. - if( bPersistent ) - setDirty(true); - - if (!bLocaleInitialized && TDEGlobal::locale()) - setLocale(); - - KEntryKey entryKey(mGroup, pKey); - entryKey.bLocal = bNLS; - - KEntry aEntryData; - aEntryData.mValue = value.utf8(); // set new value - aEntryData.bGlobal = bGlobal; - aEntryData.bNLS = bNLS; - aEntryData.bExpand = bExpand; - - if (bPersistent) - aEntryData.bDirty = true; - - // rewrite the new value - putData(entryKey, aEntryData, true); -} - -void TDEConfigBase::writePathEntry( const TQString& pKey, const TQString & path, - bool bPersistent, bool bGlobal, - bool bNLS) -{ - writePathEntry(pKey.utf8().data(), path, bPersistent, bGlobal, bNLS); -} - - -static bool cleanHomeDirPath( TQString &path, const TQString &homeDir ) -{ -#ifdef Q_WS_WIN //safer - if (!TQDir::convertSeparators(path).startsWith(TQDir::convertSeparators(homeDir))) - return false; -#else - if (!path.startsWith(homeDir)) - return false; -#endif - - unsigned int len = homeDir.length(); - // replace by "$HOME" if possible - if (len && (path.length() == len || path[len] == '/')) { - path.replace(0, len, TQString::fromLatin1("$HOME")); - return true; - } else - return false; -} - -static TQString translatePath( TQString path ) -{ - if (path.isEmpty()) - return path; - - // only "our" $HOME should be interpreted - path.replace('$', "$$"); - - bool startsWithFile = path.startsWith("file:", false); - - // return original path, if it refers to another type of URL (e.g. http:/), or - // if the path is already relative to another directory - if (((!startsWithFile) && (path[0] != '/')) || (startsWithFile && (path[5] != '/'))) { - return path; - } - - if (startsWithFile) { - path.remove(0,5); // strip leading "file:/" off the string - } - - // keep only one single '/' at the beginning - needed for cleanHomeDirPath() - while (path[0] == '/' && path[1] == '/') { - path.remove(0,1); - } - - // we can not use TDEGlobal::dirs()->relativeLocation("home", path) here, - // since it would not recognize paths without a trailing '/'. - // All of the 3 following functions to return the user's home directory - // can return different paths. We have to test all them. - TQString homeDir0 = TQFile::decodeName(getenv("HOME")); - TQString homeDir1 = TQDir::homeDirPath(); - TQString homeDir2 = TQDir(homeDir1).canonicalPath(); - if (cleanHomeDirPath(path, homeDir0) || - cleanHomeDirPath(path, homeDir1) || - cleanHomeDirPath(path, homeDir2) ) { - // kdDebug() << "Path was replaced\n"; - } - - if (startsWithFile) - path.prepend( "file://" ); - - return path; -} - -void TDEConfigBase::writePathEntry( const char *pKey, const TQString & path, - bool bPersistent, bool bGlobal, - bool bNLS) -{ - writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS, true); -} - -void TDEConfigBase::writePathEntry ( const TQString& pKey, const TQStringList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - writePathEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writePathEntry ( const char *pKey, const TQStringList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - if( list.isEmpty() ) - { - writeEntry( pKey, TQString::fromLatin1(""), bPersistent ); - return; - } - TQStringList new_list; - TQStringList::ConstIterator it = list.begin(); - for( ; it != list.end(); ++it ) - { - TQString value = *it; - new_list.append( translatePath(value) ); - } - writeEntry( pKey, new_list, sep, bPersistent, bGlobal, bNLS, true ); -} - -void TDEConfigBase::deleteEntry( const TQString& pKey, - bool bNLS, - bool bGlobal) -{ - deleteEntry(pKey.utf8().data(), bNLS, bGlobal); -} - -void TDEConfigBase::deleteEntry( const char *pKey, - bool bNLS, - bool bGlobal) -{ - // the TDEConfig object is dirty now - // set this before any IO takes place so that if any derivative - // classes do caching, they won't try and flush the cache out - // from under us before we read. A race condition is still - // possible but minimized. - setDirty(true); - - if (!bLocaleInitialized && TDEGlobal::locale()) - setLocale(); - - KEntryKey entryKey(mGroup, pKey); - KEntry aEntryData; - - aEntryData.bGlobal = bGlobal; - aEntryData.bNLS = bNLS; - aEntryData.bDirty = true; - aEntryData.bDeleted = true; - - // rewrite the new value - putData(entryKey, aEntryData, true); -} - -bool TDEConfigBase::deleteGroup( const TQString& group, bool bDeep, bool bGlobal ) -{ - KEntryMap aEntryMap = internalEntryMap(group); - - if (!bDeep) { - // Check if it empty - return aEntryMap.isEmpty(); - } - - bool dirty = false; - bool checkGroup = true; - // we want to remove all entries in the group - KEntryMapIterator aIt; - for (aIt = aEntryMap.begin(); aIt != aEntryMap.end(); ++aIt) - { - if (!aIt.key().mKey.isEmpty() && !aIt.key().bDefault && !(*aIt).bDeleted) - { - (*aIt).bDeleted = true; - (*aIt).bDirty = true; - (*aIt).bGlobal = bGlobal; - (*aIt).mValue = 0; - putData(aIt.key(), *aIt, checkGroup); - checkGroup = false; - dirty = true; - } - } - if (dirty) - setDirty(true); - return true; -} - -void TDEConfigBase::writeEntry ( const TQString& pKey, const TQVariant &prop, - bool bPersistent, - bool bGlobal, bool bNLS ) -{ - writeEntry(pKey.utf8().data(), prop, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry ( const char *pKey, const TQVariant &prop, - bool bPersistent, - bool bGlobal, bool bNLS ) -{ - switch( prop.type() ) - { - case TQVariant::Invalid: - writeEntry( pKey, "", bPersistent, bGlobal, bNLS ); - return; - case TQVariant::String: - writeEntry( pKey, prop.toString(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::StringList: - writeEntry( pKey, prop.toStringList(), ',', bPersistent, bGlobal, bNLS ); - return; - case TQVariant::List: { - TQValueList list = prop.toList(); - TQValueList::ConstIterator it = list.begin(); - TQValueList::ConstIterator end = list.end(); - TQStringList strList; - - for (; it != end; ++it ) - strList.append( (*it).toString() ); - - writeEntry( pKey, strList, ',', bPersistent, bGlobal, bNLS ); - - return; - } - case TQVariant::Font: - writeEntry( pKey, prop.toFont(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Point: - writeEntry( pKey, prop.toPoint(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Rect: - writeEntry( pKey, prop.toRect(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Size: - writeEntry( pKey, prop.toSize(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Color: - writeEntry( pKey, prop.toColor(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Int: - writeEntry( pKey, prop.toInt(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::UInt: - writeEntry( pKey, prop.toUInt(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::LongLong: - writeEntry( pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::ULongLong: - writeEntry( pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Bool: - writeEntry( pKey, prop.toBool(), bPersistent, bGlobal, bNLS ); - return; - case TQVariant::Double: - writeEntry( pKey, prop.toDouble(), bPersistent, bGlobal, 'g', 6, bNLS ); - return; - case TQVariant::DateTime: - writeEntry( pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS); - return; - case TQVariant::Date: - writeEntry( pKey, TQDateTime(prop.toDate()), bPersistent, bGlobal, bNLS); - return; - - case TQVariant::Pixmap: - case TQVariant::Image: - case TQVariant::Brush: - case TQVariant::Palette: - case TQVariant::ColorGroup: - case TQVariant::Map: - case TQVariant::IconSet: - case TQVariant::CString: - case TQVariant::PointArray: - case TQVariant::Region: - case TQVariant::Bitmap: - case TQVariant::Cursor: - case TQVariant::SizePolicy: - case TQVariant::Time: -#ifdef USE_QT3 - case TQVariant::ByteArray: -#endif // USE_QT3 - case TQVariant::BitArray: - case TQVariant::KeySequence: - case TQVariant::Pen: -#ifdef USE_QT4 - case TQVariant::Char: - case TQVariant::Url: - case TQVariant::Locale: - case TQVariant::RectF: - case TQVariant::SizeF: - case TQVariant::Line: - case TQVariant::LineF: - case TQVariant::PointF: - case TQVariant::RegExp: - case TQVariant::Hash: - case TQVariant::TextLength: - case QVariant::TextFormat: - case TQVariant::Matrix: - case TQVariant::Transform: - case TQVariant::Matrix4x4: - case TQVariant::Vector2D: - case TQVariant::Vector3D: - case TQVariant::Vector4D: - case TQVariant::Quaternion: - case TQVariant::UserType: -#endif // USE_QT4 - break; - } - - Q_ASSERT( 0 ); -} - -void TDEConfigBase::writeEntry ( const TQString& pKey, const TQStrList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry ( const char *pKey, const TQStrList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - if( list.isEmpty() ) - { - writeEntry( pKey, TQString::fromLatin1(""), bPersistent ); - return; - } - TQString str_list; - TQStrListIterator it( list ); - for( ; it.current(); ++it ) - { - uint i; - TQString value; - // !!! Sergey A. Sukiyazov !!! - // A TQStrList may contain values in 8bit locale cpecified - // encoding or in UTF8 encoding. - value = KStringHandler::from8Bit(it.current()); - uint strLengh(value.length()); - for( i = 0; i < strLengh; i++ ) - { - if( value[i] == sep || value[i] == '\\' ) - str_list += '\\'; - str_list += value[i]; - } - str_list += sep; - } - if( str_list.at(str_list.length() - 1) == (QChar)sep ) - str_list.truncate( str_list.length() -1 ); - writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry ( const TQString& pKey, const TQStringList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry ( const char *pKey, const TQStringList &list, - char sep , bool bPersistent, - bool bGlobal, bool bNLS ) -{ - writeEntry(pKey, list, sep, bPersistent, bGlobal, bNLS, false); -} - -void TDEConfigBase::writeEntry ( const char *pKey, const TQStringList &list, - char sep, bool bPersistent, - bool bGlobal, bool bNLS, bool bExpand ) -{ - if( list.isEmpty() ) - { - writeEntry( pKey, TQString::fromLatin1(""), bPersistent ); - return; - } - TQString str_list; - str_list.reserve( 4096 ); - TQStringList::ConstIterator it = list.begin(); - for( ; it != list.end(); ++it ) - { - TQString value = *it; - uint i; - uint strLength(value.length()); - for( i = 0; i < strLength; i++ ) - { - if( value[i] == sep || value[i] == '\\' ) - str_list += '\\'; - str_list += value[i]; - } - str_list += sep; - } - if( str_list.at(str_list.length() - 1) == (QChar)sep ) - str_list.truncate( str_list.length() -1 ); - writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS, bExpand ); -} - -void TDEConfigBase::writeEntry ( const TQString& pKey, const TQValueList &list, - bool bPersistent, bool bGlobal, bool bNLS ) -{ - writeEntry(pKey.utf8().data(), list, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry ( const char *pKey, const TQValueList &list, - bool bPersistent, bool bGlobal, bool bNLS ) -{ - TQStringList strlist; - TQValueList::ConstIterator end = list.end(); - for (TQValueList::ConstIterator it = list.begin(); it != end; it++) - strlist << TQString::number(*it); - writeEntry(pKey, strlist, ',', bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const TQString& pKey, int nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const char *pKey, int nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - - -void TDEConfigBase::writeEntry( const TQString& pKey, unsigned int nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const char *pKey, unsigned int nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - - -void TDEConfigBase::writeEntry( const TQString& pKey, long nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const char *pKey, long nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - - -void TDEConfigBase::writeEntry( const TQString& pKey, unsigned long nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const char *pKey, unsigned long nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const TQString& pKey, TQ_INT64 nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const char *pKey, TQ_INT64 nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - - -void TDEConfigBase::writeEntry( const TQString& pKey, TQ_UINT64 nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const char *pKey, TQ_UINT64 nValue, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const TQString& pKey, double nValue, - bool bPersistent, bool bGlobal, - char format, int precision, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue, format, precision), - bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const char *pKey, double nValue, - bool bPersistent, bool bGlobal, - char format, int precision, - bool bNLS ) -{ - writeEntry( pKey, TQString::number(nValue, format, precision), - bPersistent, bGlobal, bNLS ); -} - - -void TDEConfigBase::writeEntry( const TQString& pKey, bool bValue, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), bValue, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry( const char *pKey, bool bValue, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - TQString aValue; - - if( bValue ) - aValue = "true"; - else - aValue = "false"; - - writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS ); -} - - -void TDEConfigBase::writeEntry( const TQString& pKey, const TQFont& rFont, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), rFont, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry( const char *pKey, const TQFont& rFont, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey, TQString(rFont.toString()), bPersistent, bGlobal, bNLS ); -} - - -void TDEConfigBase::writeEntry( const TQString& pKey, const TQRect& rRect, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), rRect, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry( const char *pKey, const TQRect& rRect, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - TQStrList list; - TQCString tempstr; - list.insert( 0, tempstr.setNum( rRect.left() ) ); - list.insert( 1, tempstr.setNum( rRect.top() ) ); - list.insert( 2, tempstr.setNum( rRect.width() ) ); - list.insert( 3, tempstr.setNum( rRect.height() ) ); - - writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); -} - - -void TDEConfigBase::writeEntry( const TQString& pKey, const TQPoint& rPoint, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), rPoint, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry( const char *pKey, const TQPoint& rPoint, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - TQStrList list; - TQCString tempstr; - list.insert( 0, tempstr.setNum( rPoint.x() ) ); - list.insert( 1, tempstr.setNum( rPoint.y() ) ); - - writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); -} - - -void TDEConfigBase::writeEntry( const TQString& pKey, const TQSize& rSize, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), rSize, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry( const char *pKey, const TQSize& rSize, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - TQStrList list; - TQCString tempstr; - list.insert( 0, tempstr.setNum( rSize.width() ) ); - list.insert( 1, tempstr.setNum( rSize.height() ) ); - - writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const TQString& pKey, const TQColor& rColor, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - writeEntry( pKey.utf8().data(), rColor, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry( const char *pKey, const TQColor& rColor, - bool bPersistent, - bool bGlobal, - bool bNLS ) -{ - TQString aValue; - if (rColor.isValid()) - aValue.sprintf( "%d,%d,%d", rColor.red(), rColor.green(), rColor.blue() ); - else - aValue = "invalid"; - - writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::writeEntry( const TQString& pKey, const TQDateTime& rDateTime, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - writeEntry(pKey.utf8().data(), rDateTime, bPersistent, bGlobal, bNLS); -} - -void TDEConfigBase::writeEntry( const char *pKey, const TQDateTime& rDateTime, - bool bPersistent, bool bGlobal, - bool bNLS ) -{ - TQStrList list; - TQCString tempstr; - - TQTime time = TQT_TQTIME_OBJECT(rDateTime.time()); - TQDate date = TQT_TQDATE_OBJECT(rDateTime.date()); - - list.insert( 0, tempstr.setNum( date.year() ) ); - list.insert( 1, tempstr.setNum( date.month() ) ); - list.insert( 2, tempstr.setNum( date.day() ) ); - - list.insert( 3, tempstr.setNum( time.hour() ) ); - list.insert( 4, tempstr.setNum( time.minute() ) ); - list.insert( 5, tempstr.setNum( time.second() ) ); - - writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); -} - -void TDEConfigBase::parseConfigFiles() -{ - if (!bLocaleInitialized && TDEGlobal::_locale) { - setLocale(); - } - if (backEnd) - { - backEnd->parseConfigFiles(); - bReadOnly = (backEnd->getConfigState() == ReadOnly); - } -} - -void TDEConfigBase::sync() -{ - if (isReadOnly()) - return; - - if (backEnd) - backEnd->sync(); - if (bDirty) - rollback(); -} - -TDEConfigBase::ConfigState TDEConfigBase::getConfigState() const { - if (backEnd) - return backEnd->getConfigState(); - return ReadOnly; -} - -void TDEConfigBase::rollback( bool /*bDeep = true*/ ) -{ - bDirty = false; -} - - -void TDEConfigBase::setReadDefaults(bool b) -{ - if (!d) - { - if (!b) return; - d = new TDEConfigBasePrivate(); - } - - d->readDefaults = b; -} - -bool TDEConfigBase::readDefaults() const -{ - return (d && d->readDefaults); -} - -void TDEConfigBase::revertToDefault(const TQString &key) -{ - setDirty(true); - - KEntryKey aEntryKey(mGroup, key.utf8()); - aEntryKey.bDefault = true; - - if (!locale().isNull()) { - // try the localized key first - aEntryKey.bLocal = true; - KEntry entry = lookupData(aEntryKey); - if (entry.mValue.isNull()) - entry.bDeleted = true; - - entry.bDirty = true; - putData(aEntryKey, entry, true); // Revert - aEntryKey.bLocal = false; - } - - // try the non-localized version - KEntry entry = lookupData(aEntryKey); - if (entry.mValue.isNull()) - entry.bDeleted = true; - entry.bDirty = true; - putData(aEntryKey, entry, true); // Revert -} - -bool TDEConfigBase::hasDefault(const TQString &key) const -{ - KEntryKey aEntryKey(mGroup, key.utf8()); - aEntryKey.bDefault = true; - - if (!locale().isNull()) { - // try the localized key first - aEntryKey.bLocal = true; - KEntry entry = lookupData(aEntryKey); - if (!entry.mValue.isNull()) - return true; - - aEntryKey.bLocal = false; - } - - // try the non-localized version - KEntry entry = lookupData(aEntryKey); - if (!entry.mValue.isNull()) - return true; - - return false; -} - - - -TDEConfigGroup::TDEConfigGroup(TDEConfigBase *master, const TQString &group) -{ - mMaster = master; - backEnd = mMaster->backEnd; // Needed for getConfigState() - bLocaleInitialized = true; - bReadOnly = mMaster->bReadOnly; - bExpand = false; - bDirty = false; // Not used - mGroup = group.utf8(); - aLocaleString = mMaster->aLocaleString; - setReadDefaults(mMaster->readDefaults()); -} - -TDEConfigGroup::TDEConfigGroup(TDEConfigBase *master, const TQCString &group) -{ - mMaster = master; - backEnd = mMaster->backEnd; // Needed for getConfigState() - bLocaleInitialized = true; - bReadOnly = mMaster->bReadOnly; - bExpand = false; - bDirty = false; // Not used - mGroup = group; - aLocaleString = mMaster->aLocaleString; - setReadDefaults(mMaster->readDefaults()); -} - -TDEConfigGroup::TDEConfigGroup(TDEConfigBase *master, const char * group) -{ - mMaster = master; - backEnd = mMaster->backEnd; // Needed for getConfigState() - bLocaleInitialized = true; - bReadOnly = mMaster->bReadOnly; - bExpand = false; - bDirty = false; // Not used - mGroup = group; - aLocaleString = mMaster->aLocaleString; - setReadDefaults(mMaster->readDefaults()); -} - -void TDEConfigGroup::deleteGroup(bool bGlobal) -{ - mMaster->deleteGroup(TDEConfigBase::group(), true, bGlobal); -} - -bool TDEConfigGroup::groupIsImmutable() const -{ - return mMaster->groupIsImmutable(TDEConfigBase::group()); -} - -void TDEConfigGroup::setDirty(bool _bDirty) -{ - mMaster->setDirty(_bDirty); -} - -void TDEConfigGroup::putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup) -{ - mMaster->putData(_key, _data, _checkGroup); -} - -KEntry TDEConfigGroup::lookupData(const KEntryKey &_key) const -{ - return mMaster->lookupData(_key); -} - -void TDEConfigGroup::sync() -{ - mMaster->sync(); -} - -void TDEConfigBase::virtual_hook( int, void* ) -{ /*BASE::virtual_hook( id, data );*/ } - -void TDEConfigGroup::virtual_hook( int id, void* data ) -{ TDEConfigBase::virtual_hook( id, data ); } - -bool TDEConfigBase::checkConfigFilesWritable(bool warnUser) -{ - if (backEnd) - return backEnd->checkConfigFilesWritable(warnUser); - else - return false; -} - -#include "kconfigbase.moc" diff --git a/tdecore/kconfigbase.h b/tdecore/kconfigbase.h deleted file mode 100644 index ff02babdd..000000000 --- a/tdecore/kconfigbase.h +++ /dev/null @@ -1,2180 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999 Preston Brown - Copyright (c) 1997 Matthias Kalle Dalheimer - Copyright (c) 2001 Waldo Bastian - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef _KCONFIGBASE_H -#define _KCONFIGBASE_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kconfigdata.h" -#include "tdelibs_export.h" - -class TDEConfigBackEnd; -class TDEConfigBasePrivate; -class TDEConfigGroup; - -/** - * @short KDE Configuration Management abstract base class - * - * This class forms the base for all %KDE configuration. It is an - * abstract base class, meaning that you cannot directly instantiate - * objects of this class. Either use TDEConfig (for usual %KDE - * configuration) or KSimpleConfig (for special needs as in ksamba), or - * even KSharedConfig (stores values in shared memory). - * - * All configuration entries are key, value pairs. Each entry also - * belongs to a specific group of related entries. All configuration - * entries that do not explicitly specify which group they are in are - * in a special group called the default group. - * - * If there is a $ character in an entry, TDEConfigBase tries to expand - * environment variable and uses its value instead of its name. You - * can avoid this feature by having two consecutive $ characters in - * your config file which get expanded to one. - * - * \note the '=' char is not allowed in keys and the ']' char is not allowed in - * a group name. - * - * @author Kalle Dalheimer , Preston Brown - * @see TDEGlobal#config() - * @see TDEConfig - * @see KSimpleConfig - * @see KSharedConfig - */ -class TDECORE_EXPORT TDEConfigBase : public TQObject -{ - Q_OBJECT - - - friend class TDEConfigBackEnd; - friend class TDEConfigINIBackEnd; - friend class TDEConfigGroup; - -public: - /** - * Construct a TDEConfigBase object. - */ - TDEConfigBase(); - - /** - * Destructs the TDEConfigBase object. - */ - virtual ~TDEConfigBase(); - - /** - * Specifies the group in which keys will be read and written. - * - * Subsequent - * calls to readEntry() and writeEntry() will be applied only in the - * activated group. - * - * Switch back to the default group by passing a null string. - * @param group The name of the new group. - */ - void setGroup( const TQString& group ); - - /** - * Sets the group to the "Desktop Entry" group used for - * desktop configuration files for applications, mime types, etc. - */ - void setDesktopGroup(); - - /** - * Returns the name of the group in which we are - * searching for keys and from which we are retrieving entries. - * - * @return The current group. - */ - TQString group() const; - - /** - * Returns true if the specified group is known about. - * - * @param group The group to search for. - * @return true if the group exists. - */ - bool hasGroup(const TQString &group) const; - - /** - * Returns a list of groups that are known about. - * - * @return The list of groups. - **/ - virtual TQStringList groupList() const = 0; - - /** - * Returns a the current locale. - * - * @return A string representing the current locale. - */ - TQString locale() const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * If you want to read a path, please use readPathEntry(). - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. Can be TQString::null if aDefault is null. - */ - TQString readEntry(const TQString& pKey, - const TQString& aDefault = TQString::null ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. Can be TQString::null if aDefault is null. - */ - TQString readEntry(const char *pKey, - const TQString& aDefault = TQString::null ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The value is treated as if it is of the given type. - * - * Note that only the following TQVariant types are allowed : String, - * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, - * Double, DateTime and Date. - * @deprecated - * - * @param pKey The key to search for. - * @return An invalid TQVariant if the key was not found or if the - * read value cannot be converted to the given TQVariant::Type. - */ - TQVariant readPropertyEntry( const TQString& pKey, TQVariant::Type ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The value is treated as if it is of the given type. - * - * Note that only the following TQVariant types are allowed : String, - * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, - * Double, DateTime and Date. - * - * @deprecated - * - * @param pKey The key to search for. - * @return An invalid TQVariant if the key was not found or if the - * read value cannot be converted to the given TQVariant::Type. - */ - TQVariant readPropertyEntry( const char *pKey, TQVariant::Type ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The value is treated as if it is of the type of the given default value. - * - * Note that only the following TQVariant types are allowed : String, - * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, - * Double, DateTime and Date. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found or - * if the read value cannot be converted to the TQVariant::Type. - * @return The value for the key or the default value if the key was not - * found. - */ - TQVariant readPropertyEntry( const TQString& pKey, - const TQVariant &aDefault) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The value is treated as if it is of the type of the given default value. - * - * Note that only the following TQVariant types are allowed : String, - * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, - * Double, DateTime and Date. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found or - * if the read value cannot be converted to the TQVariant::Type. - * @return The value for the key or the default value if the key was not - * found. - */ - TQVariant readPropertyEntry( const char *pKey, - const TQVariant &aDefault) const; - - /** - * Reads a list of strings. - * - * @deprecated - * - * @param pKey The key to search for - * @param list In this object, the read list will be returned. - * @param sep The list separator (default ",") - * @return The number of entries in the list. - */ - int readListEntry( const TQString& pKey, TQStrList &list, char sep = ',' ) const; - - /** - * Reads a list of strings. - * - * @deprecated - * - * @param pKey The key to search for - * @param list In this object, the read list will be returned. - * @param sep The list separator (default ",") - * @return The number of entries in the list. - */ - int readListEntry( const char *pKey, TQStrList &list, char sep = ',' ) const; - - /** - * Reads a list of strings. - * - * @param pKey The key to search for. - * @param sep The list separator (default is ","). - * @return The list. Empty if the entry does not exist. - */ - TQStringList readListEntry( const TQString& pKey, char sep = ',' ) const; - - /** - * Reads a list of strings. - * - * @param pKey The key to search for. - * @param sep The list separator (default is ","). - * @return The list. Empty if the entry does not exist. - */ - TQStringList readListEntry( const char *pKey, char sep = ',' ) const; - - /** - * Reads a list of strings, but returns a default if the key - * did not exist. - * @param pKey The key to search for. - * @param aDefault The default value to use if the key does not exist. - * @param sep The list separator (default is ","). - * @return The list. Contains @p aDefault if the Key does not exist. - * @since 3.3 - */ - TQStringList readListEntry( const char* pKey, const TQStringList& aDefault, - char sep = ',' ) const; - - /** - * Reads a list of Integers. - * - * @param pKey The key to search for. - * @return The list. Empty if the entry does not exist. - */ - TQValueList readIntListEntry( const TQString& pKey ) const; - - /** - * Reads a list of Integers. - * - * @param pKey The key to search for. - * @return The list. Empty if the entry does not exist. - */ - TQValueList readIntListEntry( const char *pKey ) const; - - /** - * Reads a path. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a path. This means, dollar expansion is activated - * for this value, so that e.g. $HOME gets expanded. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. Can be TQString::null if aDefault is null. - */ - TQString readPathEntry( const TQString& pKey, const TQString & aDefault = TQString::null ) const; - - /** - * Reads a path. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a path. This means, dollar expansion is activated - * for this value, so that e.g. $HOME gets expanded. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. Can be TQString::null if aDefault is null. - */ - TQString readPathEntry( const char *pKey, const TQString & aDefault = TQString::null ) const; - - /** - * Reads a list of string paths. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a list of paths. This means, dollar expansion is activated - * for this value, so that e.g. $HOME gets expanded. - * - * @param pKey The key to search for. - * @param sep The list separator (default is ","). - * @return The list. Empty if the entry does not exist. - * @since 3.1.3 - */ - TQStringList readPathListEntry( const TQString& pKey, char sep = ',' ) const; - - /** - * Reads a list of string paths. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a list of paths. This means, dollar expansion is activated - * for this value, so that e.g. $HOME gets expanded. - * - * @param pKey The key to search for. - * @param sep The list separator (default is ","). - * @return The list. Empty if the entry does not exist. - * @since 3.1.3 - */ - TQStringList readPathListEntry( const char *pKey, char sep = ',' ) const; - - - /** - * Reads a numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - int readNumEntry( const TQString& pKey, int nDefault = 0 ) const; - - /** - * Reads a numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - int readNumEntry( const char *pKey, int nDefault = 0 ) const; - - /** - * Reads an unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - unsigned int readUnsignedNumEntry( const TQString& pKey, unsigned int nDefault = 0 ) const; - - /** - * Reads an unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - unsigned int readUnsignedNumEntry( const char *pKey, unsigned int nDefault = 0 ) const; - - - /** - * Reads a numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - long readLongNumEntry( const TQString& pKey, long nDefault = 0 ) const; - - /** - * Reads a numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - long readLongNumEntry( const char *pKey, long nDefault = 0 ) const; - - /** - * Read an unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - unsigned long readUnsignedLongNumEntry( const TQString& pKey, unsigned long nDefault = 0 ) const; - - /** - * Read an unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - unsigned long readUnsignedLongNumEntry( const char *pKey, unsigned long nDefault = 0 ) const; - - /** - * Reads a 64-bit numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - TQ_INT64 readNum64Entry( const TQString& pKey, TQ_INT64 nDefault = 0 ) const; - - /** - * Reads a 64-bit numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - TQ_INT64 readNum64Entry( const char *pKey, TQ_INT64 nDefault = 0 ) const; - - /** - * Read an 64-bit unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - TQ_UINT64 readUnsignedNum64Entry( const TQString& pKey, TQ_UINT64 nDefault = 0 ) const; - - /** - * Read an 64-bit unsigned numerical value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - TQ_UINT64 readUnsignedNum64Entry( const char *pKey, TQ_UINT64 nDefault = 0 ) const; - - /** - * Reads a floating point value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - double readDoubleNumEntry( const TQString& pKey, double nDefault = 0.0 ) const; - - /** - * Reads a floating point value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it numerically. - * - * @param pKey The key to search for. - * @param nDefault A default value returned if the key was not found or if - * the read value cannot be interpreted. - * @return The value for this key. - */ - double readDoubleNumEntry( const char *pKey, double nDefault = 0.0 ) const; - - /** - * Reads a TQFont value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a font object. - * - * @param pKey The key to search for. - * @param pDefault A default value (null TQFont by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQFont readFontEntry( const TQString& pKey, const TQFont* pDefault = 0L ) const; - - /** - * Reads a TQFont value. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a font object. - * - * @param pKey The key to search for. - * @param pDefault A default value (null TQFont by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQFont readFontEntry( const char *pKey, const TQFont* pDefault = 0L ) const; - - /** - * Reads a boolean entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a boolean value. Currently "on", "yes", "1" and - * "true" are accepted as true, everything else if false. - * - * @param pKey The key to search for - * @param bDefault A default value returned if the key was not found. - * @return The value for this key. - */ - bool readBoolEntry( const TQString& pKey, bool bDefault = false ) const; - - /** - * Reads a boolean entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a boolean value. Currently "on", "yes", "1" and - * "true" are accepted as true, everything else if false. - * - * @param pKey The key to search for - * @param bDefault A default value returned if the key was not found. - * @return The value for this key. - */ - bool readBoolEntry( const char *pKey, bool bDefault = false ) const; - - /** - * Reads a TQRect entry. - * - * Read the value of an entry specified by pKey in the current group - * and interpret it as a TQRect object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQRect by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQRect readRectEntry( const TQString& pKey, const TQRect* pDefault = 0L ) const; - - /** - * Reads a TQRect entry. - * - * Read the value of an entry specified by pKey in the current group - * and interpret it as a TQRect object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQRect by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQRect readRectEntry( const char *pKey, const TQRect* pDefault = 0L ) const; - - /** - * Reads a TQPoint entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a TQPoint object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQPoint by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQPoint readPointEntry( const TQString& pKey, const TQPoint* pDefault = 0L ) const; - - /** - * Reads a TQPoint entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a TQPoint object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQPoint by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQPoint readPointEntry( const char *pKey, const TQPoint* pDefault = 0L ) const; - - /** - * Reads a TQSize entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a TQSize object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQSize by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQSize readSizeEntry( const TQString& pKey, const TQSize* pDefault = 0L ) const; - - /** - * Reads a TQSize entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a TQSize object. - * - * @param pKey The key to search for - * @param pDefault A default value (null TQSize by default) returned if the - * key was not found or if the read value cannot be interpreted. - * @return The value for this key. - */ - TQSize readSizeEntry( const char *pKey, const TQSize* pDefault = 0L ) const; - - - /** - * Reads a TQColor entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a color. - * - * @param pKey The key to search for. - * @param pDefault A default value (null TQColor by default) returned if the - * key was not found or if the value cannot be interpreted. - * @return The value for this key. - */ - TQColor readColorEntry( const TQString& pKey, const TQColor* pDefault = 0L ) const; - - /** - * Reads a TQColor entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a color. - * - * @param pKey The key to search for. - * @param pDefault A default value (null TQColor by default) returned if the - * key was not found or if the value cannot be interpreted. - * @return The value for this key. - */ - TQColor readColorEntry( const char *pKey, const TQColor* pDefault = 0L ) const; - - /** - * Reads a TQDateTime entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a date and time. - * - * @param pKey The key to search for. - * @param pDefault A default value ( currentDateTime() by default) - * returned if the key was not found or if the read value cannot be - * interpreted. - * @return The value for this key. - */ - TQDateTime readDateTimeEntry( const TQString& pKey, const TQDateTime* pDefault = 0L ) const; - - /** - * Reads a TQDateTime entry. - * - * Read the value of an entry specified by @p pKey in the current group - * and interpret it as a date and time. - * - * @param pKey The key to search for. - * @param pDefault A default value ( currentDateTime() by default) - * returned if the key was not found or if the read value cannot be - * interpreted. - * @return The value for this key. - */ - TQDateTime readDateTimeEntry( const char *pKey, const TQDateTime* pDefault = 0L ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The untranslated entry is returned, you normally do not need this. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. - */ - TQString readEntryUntranslated( const TQString& pKey, - const TQString& aDefault = TQString::null ) const; - - /** - * Reads the value of an entry specified by @p pKey in the current group. - * The untranslated entry is returned, you normally do not need this. - * - * @param pKey The key to search for. - * @param aDefault A default value returned if the key was not found. - * @return The value for this key. - */ - TQString readEntryUntranslated( const char *pKey, - const TQString& aDefault = TQString::null ) const; - - /** - * Writes a key/value pair. - * - * This is stored in the most specific config file when destroying the - * config object or when calling sync(). - * - * If you want to write a path, please use writePathEntry(). - * - * @param pKey The key to write. - * @param pValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will - * not be written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQString& pValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a key/value pair. - * - * This is stored in the most specific config file when destroying the - * config object or when calling sync(). - * - * @param pKey The key to write. - * @param pValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will - * not be written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQString& pValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * writeEntry() Overridden to accept a property. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The property to write - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const TQString& pKey, const TQVariant& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * writeEntry() Overridden to accept a property. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The property to write - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const char *pKey, const TQVariant& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * writeEntry() overridden to accept a list of strings. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const TQString& pKey, const TQStrList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - /** - * writeEntry() overridden to accept a list of strings. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const char *pKey, const TQStrList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - - /** - * writeEntry() overridden to accept a list of strings. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const TQString& pKey, const TQStringList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - /** - * writeEntry() overridden to accept a list of strings. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const char *pKey, const TQStringList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - - - /** - * writeEntry() overridden to accept a list of Integers. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const TQString& pKey, const TQValueList& rValue, - bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - /** - * writeEntry() overridden to accept a list of Integers. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write - * @param rValue The list to write - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writeEntry() - */ - void writeEntry( const char *pKey, const TQValueList& rValue, - bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - - /** - * Write a (key/value) pair. - * - * This is stored to the most specific config file when destroying the - * config object or when calling sync(). - * - * @param pKey The key to write. - * @param pValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will - * not be written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const char *pValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ) - { writeEntry(pKey, TQString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); } - /** - * Write a (key/value) pair. - * - * This is stored to the most specific config file when destroying the - * config object or when calling sync(). - * - * @param pKey The key to write. - * @param pValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will - * not be written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const char *pValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ) - { writeEntry(pKey, TQString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); } - - /** - * Write a (key/value) pair. - * Same as above, but writes a numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, int nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Write a (key/value) pair. - * Same as above, but writes a numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, int nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, unsigned int nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, unsigned int nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but write a long numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, long nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but write a long numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, long nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned long numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, unsigned long nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned long numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, unsigned long nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but write a 64-bit numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, TQ_INT64 nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but write a long numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, TQ_INT64 nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned 64-bit numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, TQ_UINT64 nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes an unsigned 64-bit numerical value. - * - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, TQ_UINT64 nValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a floating-point value. - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param format @p format determines the format to which the value - * is converted. Default is 'g'. - * @param precision @p precision sets the precision with which the - * value is converted. Default is 6 as in TQString. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, double nValue, - bool bPersistent = true, bool bGlobal = false, - char format = 'g', int precision = 6, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a floating-point value. - * @param pKey The key to write. - * @param nValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param format @p format determines the format to which the value - * is converted. Default is 'g'. - * @param precision @p precision sets the precision with which the - * value is converted. Default is 6 as in TQString. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, double nValue, - bool bPersistent = true, bool bGlobal = false, - char format = 'g', int precision = 6, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a boolean value. - * - * @param pKey The key to write. - * @param bValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, bool bValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a boolean value. - * - * @param pKey The key to write. - * @param bValue The value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, bool bValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a font value. - * - * @param pKey The key to write. - * @param rFont The font value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQFont& rFont, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a font value. - * - * @param pKey The key to write. - * @param rFont The font value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQFont& rFont, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but write a color entry. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rColor The color value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQColor& rColor, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but write a color entry. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rColor The color value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQColor& rColor, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a date and time entry. - * - * Note: Unlike the other writeEntry() functions, the old value is - * @em not returned here! - * - * @param pKey The key to write. - * @param rDateTime The date and time value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQDateTime& rDateTime, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a date and time entry. - * - * Note: Unlike the other writeEntry() functions, the old value is - * @em not returned here! - * - * @param pKey The key to write. - * @param rDateTime The date and time value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQDateTime& rDateTime, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - - /** - * Writes a (key/value) pair. - * Same as above, but writes a rectangle. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The rectangle value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQRect& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a rectangle. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The rectangle value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQRect& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a point. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The point value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQPoint& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a point. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The point value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQPoint& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a (key/value) pair. - * Same as above, but writes a size. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The size value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const TQString& pKey, const TQSize& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a (key/value) pair. - * Same as above, but writes a size. - * - * Note: Unlike the other writeEntry() functions, the old value is - * _not_ returned here! - * - * @param pKey The key to write. - * @param rValue The size value to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writeEntry( const char *pKey, const TQSize& rValue, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * Writes a file path. - * - * It is checked whether the path is located under $HOME. If so the - * path is written out with the user's home-directory replaced with - * $HOME. The path should be read back with readPathEntry() - * - * @param pKey The key to write. - * @param path The path to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writePathEntry( const TQString& pKey, const TQString & path, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - /** - * Writes a file path. - * - * It is checked whether the path is located under $HOME. If so the - * path is written out with the user's home-directory replaced with - * $HOME. The path should be read back with readPathEntry() - * - * @param pKey The key to write. - * @param path The path to write. - * @param bPersistent If @p bPersistent is false, the entry's dirty - * flag will not be set and thus the entry will not be written to - * disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - */ - void writePathEntry( const char *pKey, const TQString & path, - bool bPersistent = true, bool bGlobal = false, - bool bNLS = false ); - - /** - * writePathEntry() overridden to accept a list of paths (strings). - * - * It is checked whether the paths are located under $HOME. If so each of - * the paths are written out with the user's home-directory replaced with - * $HOME. The paths should be read back with readPathListEntry() - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writePathEntry() - * @see readPathListEntry() - * @since 3.1.3 - */ - void writePathEntry( const TQString& pKey, const TQStringList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - /** - * writePathEntry() overridden to accept a list of paths (strings). - * - * It is checked whether the paths are located under $HOME. If so each of - * the paths are written out with the user's home-directory replaced with - * $HOME. The paths should be read back with readPathListEntry() - * - * @param pKey The key to write - * @param rValue The list to write - * @param sep The list separator (default is ","). - * @param bPersistent If @p bPersistent is false, the entry's dirty flag - * will not be set and thus the entry will not be - * written to disk at deletion time. - * @param bGlobal If @p bGlobal is true, the pair is not saved to the - * application specific config file, but to the - * global KDE config file. - * @param bNLS If @p bNLS is true, the locale tag is added to the key - * when writing it back. - * - * @see writePathEntry() - * @see readPathListEntry() - * @since 3.1.3 - */ - void writePathEntry( const char *pKey, const TQStringList &rValue, - char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); - - - /** - * Deletes the entry specified by @p pKey in the current group. - * - * @param pKey The key to delete. - * @param bGlobal If @p bGlobal is true, the pair is not removed from the - * application specific config file, but to the global KDE config file. - * @param bNLS If @p bNLS is true, the key with the locale tag is removed. - */ - void deleteEntry( const TQString& pKey, - bool bNLS = false, bool bGlobal = false); - /** - * Deletes the entry specified by @p pKey in the current group. - * - * @param pKey The key to delete. - * @param bGlobal If @p bGlobal is true, the pair is not removed from the - * application specific config file, but from the global KDE config file. - * @param bNLS If @p bNLS is true, the key with the locale tag is removed. - */ - void deleteEntry( const char *pKey, - bool bNLS = false, bool bGlobal = false); - - /** - * Deletes a configuration entry group - * - * If the group is not empty and bDeep is false, nothing gets - * deleted and false is returned. - * If this group is the current group and it is deleted, the - * current group is undefined and should be set with setGroup() - * before the next operation on the configuration object. - * - * @param group The name of the group - * @param bDeep Specify whether non-empty groups should be completely - * deleted (including their entries). - * @param bGlobal If @p bGlobal is true, the group is not removed from the - * application specific config file, but from the global KDE config file. - * @return If the group is not empty and bDeep is false, - * deleteGroup returns false. - */ - bool deleteGroup( const TQString& group, bool bDeep = true, bool bGlobal = false ); - - - /** - * Turns on or off "dollar expansion" (see TDEConfigBase introduction) - * when reading config entries. - * Dollar sign expansion is initially OFF. - * - * @param _bExpand Tf true, dollar expansion is turned on. - */ - void setDollarExpansion( bool _bExpand = true ) { bExpand = _bExpand; } - - /** - * Returns whether dollar expansion is on or off. It is initially OFF. - * - * @return true if dollar expansion is on. - */ - bool isDollarExpansion() const { return bExpand; } - - /** - * Mark the config object as "clean," i.e. don't write dirty entries - * at destruction time. If @p bDeep is false, only the global dirty - * flag of the TDEConfig object gets cleared. If you then call - * writeEntry() again, the global dirty flag is set again and all - * dirty entries will be written at a subsequent sync() call. - * - * Classes that derive from TDEConfigBase should override this - * method and implement storage-specific behavior, as well as - * calling the TDEConfigBase::rollback() explicitly in the initializer. - * - * @param bDeep If true, the dirty flags of all entries are cleared, - * as well as the global dirty flag. - */ - virtual void rollback( bool bDeep = true ); - - /** - * Flushes all changes that currently reside only in memory - * back to disk / permanent storage. Dirty configuration entries are - * written to the most specific file available. - * - * Asks the back end to flush out all pending writes, and then calls - * rollback(). No changes are made if the object has @p readOnly - * status. - * - * You should call this from your destructor in derivative classes. - * - * @see rollback(), #isReadOnly() - */ - virtual void sync(); - - /** - * Checks whether the config file has any dirty (modified) entries. - * @return true if the config file has any dirty (modified) entries. - */ - bool isDirty() const { return bDirty; } - - /** - * Sets the config object's read-only status. - * - * @param _ro If true, the config object will not write out any - * changes to disk even if it is destroyed or sync() is called. - * - */ - virtual void setReadOnly(bool _ro) { bReadOnly = _ro; } - - /** - * Returns the read-only status of the config object. - * - * @return The read-only status. - */ - bool isReadOnly() const { return bReadOnly; } - - /** - * Checks whether the key has an entry in the currently active group. - * Use this to determine whether a key is not specified for the current - * group (hasKey() returns false). Keys with null data are considered - * nonexistent. - * - * @param key The key to search for. - * @return If true, the key is available. - */ - bool hasKey( const TQString& key ) const; - - /** - * Returns a map (tree) of entries for all entries in a particular - * group. Only the actual entry string is returned, none of the - * other internal data should be included. - * - * @param group A group to get keys from. - * @return A map of entries in the group specified, indexed by key. - * The returned map may be empty if the group is not found. - * @see QMap - */ - virtual TQMap entryMap(const TQString &group) const = 0; - - /** - * Reparses all configuration files. This is useful for programs - * that use stand alone graphical configuration tools. The base - * method implemented here only clears the group list and then - * appends the default group. - * - * Derivative classes should clear any internal data structures and - * then simply call parseConfigFiles() when implementing this - * method. - * - * @see parseConfigFiles() - */ - virtual void reparseConfiguration() = 0; - - /** - * Checks whether this configuration file can be modified. - * @return whether changes may be made to this configuration file. - */ - bool isImmutable() const; - - /** - * Checks whether it is possible to change the given group. - * @param group the group to check - * @return whether changes may be made to @p group in this configuration - * file. - */ - bool groupIsImmutable(const TQString &group) const; - - /** - * Checks whether it is possible to change the given entry. - * @param key the key to check - * @return whether the entry @p key may be changed in the current group - * in this configuration file. - */ - bool entryIsImmutable(const TQString &key) const; - - /** - * Possible return values for getConfigState(). - * - * @see getConfigState() - */ - enum ConfigState { NoAccess, ReadOnly, ReadWrite }; - - /** - * Returns the state of the app-config object. - * - * Possible return values - * are NoAccess (the application-specific config file could not be - * opened neither read-write nor read-only), ReadOnly (the - * application-specific config file is opened read-only, but not - * read-write) and ReadWrite (the application-specific config - * file is opened read-write). - * - * @see ConfigState() - * @return the state of the app-config object - */ - ConfigState getConfigState() const; - - /** - * Check whether the config files are writable. - * @param warnUser Warn the user if the configuration files are not writable. - * @return Indicates that all of the configuration files used are writable. - * @since 3.2 - */ - bool checkConfigFilesWritable(bool warnUser); - - /** - * When set, all readEntry and readXXXEntry calls return the system - * wide (default) values instead of the user's preference. - * This is off by default. - * @since 3.2 - */ - void setReadDefaults(bool b); - - /** - * @returns true if all readEntry and readXXXEntry calls return the system - * wide (default) values instead of the user's preference. - * @since 3.2 - */ - bool readDefaults() const; - - /** - * Reverts the entry with key @p key in the current group in the - * application specific config file to either the system wide (default) - * value or the value specified in the global KDE config file. - * - * To revert entries in the global KDE config file, the global KDE config - * file should be opened explicitly in a separate config object. - * - * @param key The key of the entry to revert. - * @since 3.2 - */ - void revertToDefault(const TQString &key); - - /** - * Returns whether a default is specified for an entry in either the - * system wide configuration file or the global KDE config file. - * - * If an application computes a default value at runtime for - * a certain entry, e.g. like: - * \code - * TQColor computedDefault = kapp->palette().color(TQPalette::Active, TQColorGroup::Text) - * TQColor color = config->readEntry(key, computedDefault); - * \encode - * - * Then it may wish to make the following check before - * writing back changes: - * \code - * if ( (value == computedDefault) && !config->hasDefault(key) ) - * config->revertToDefault(key) - * else - * config->writeEntry(key, value) - * \endcode - * - * This ensures that as long as the entry is not modified to differ from - * the computed default, the application will keep using the computed default - * and will follow changes the computed default makes over time. - * @param key The key of the entry to check. - * @since 3.2 - */ - bool hasDefault(const TQString &key) const; - -protected: - /** - * Reads the locale and put in the configuration data struct. - * Note that this should be done in the constructor, but this is not - * possible due to some mutual dependencies in TDEApplication::init() - */ - void setLocale(); - - /** - * Sets the global dirty flag of the config object - * - * @param _bDirty How to mark the object's dirty status - */ - virtual void setDirty(bool _bDirty = true) { bDirty = _bDirty; } - - /** - * Parses all configuration files for a configuration object. - * - * The actual parsing is done by the associated TDEConfigBackEnd. - */ - virtual void parseConfigFiles(); - - /** - * Returns a map (tree) of the entries in the specified group. - * This may or may not return all entries that belong to the - * config object. The only guarantee that you are given is that - * any entries that are dirty (i.e. modified and not yet written back - * to the disk) will be contained in the map. Some derivative - * classes may choose to return everything. - * - * Do not use this function, the implementation / return type are - * subject to change. - * - * @param pGroup The group to provide a KEntryMap for. - * @return The map of the entries in the group. - * @internal - */ - virtual KEntryMap internalEntryMap( const TQString& pGroup ) const = 0; - - /** - * Returns a map (tree) of the entries in the tree. - * - * Do not use this function, the implementation / return type are - * subject to change. - * - * @return A map of the entries in the tree. - * - * @internal - * - */ - virtual KEntryMap internalEntryMap() const = 0; - - /** - * Inserts a (key/value) pair into the internal storage mechanism of - * the configuration object. Classes that derive from TDEConfigBase - * will need to implement this method in a storage-specific manner. - * - * Do not use this function, the implementation / return type are - * subject to change. - * - * @param _key The key to insert. It contains information both on - * the group of the key and the key itself. If the key already - * exists, the old value will be replaced. - * @param _data the KEntry that is to be stored. - * @param _checkGroup When false, assume that the group already exists. - * @internal - */ - virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup = true) = 0; - - /** - * Looks up an entry in the config object's internal structure. - * Classes that derive from TDEConfigBase will need to implement this - * method in a storage-specific manner. - * - * Do not use this function, the implementation and return type are - * subject to change. - * - * @param _key The key to look up It contains information both on - * the group of the key and the entry's key itself. - * @return The KEntry value (data) found for the key. @p KEntry.aValue - * will be the null string if nothing was located. - * @internal - */ - virtual KEntry lookupData(const KEntryKey &_key) const = 0; - - virtual bool internalHasGroup(const TQCString &group) const = 0; - - /** - * A back end for loading/saving to disk in a particular format. - */ - TDEConfigBackEnd *backEnd; -public: - /** - * Overloaded public methods: - */ - void setGroup( const TQCString &pGroup ); - void setGroup( const char *pGroup ); - bool hasGroup(const TQCString &_pGroup) const; - bool hasGroup(const char *_pGroup) const; - bool hasKey( const char *pKey ) const; - -protected: - TQCString readEntryUtf8( const char *pKey) const; - bool hasTranslatedKey( const char *pKey ) const; - - /** - * The currently selected group. */ - TQCString mGroup; - - /** - * The locale to retrieve keys under if possible, i.e en_US or fr. */ - TQCString aLocaleString; - - /** - * Indicates whether there are any dirty entries in the config object - * that need to be written back to disk. */ - bool bDirty; - - bool bLocaleInitialized; - bool bReadOnly; // currently only used by KSimpleConfig - mutable bool bExpand; // whether dollar expansion is used - -protected: - virtual void virtual_hook( int id, void* data ); -private: - class TDEConfigBasePrivate; - TDEConfigBasePrivate *d; - - void writeEntry( const char *pKey, const TQString &rValue, - bool bPersistent, bool bGlobal, bool bNLS, bool bExpand ); - void writeEntry( const char *pKey, const TQStringList &rValue, - char sep, bool bPersistent, bool bGlobal, bool bNLS, bool bExpand ); - -}; - -class TDEConfigGroupSaverPrivate; - -/** - * Helper class to facilitate working with TDEConfig / KSimpleConfig - * groups. - * - * Careful programmers always set the group of a - * TDEConfig KSimpleConfig object to the group they want to read from - * and set it back to the old one of afterwards. This is usually - * written as: - * \code - * - * TQString oldgroup config->group(); - * config->setGroup( "TheGroupThatIWant" ); - * ... - * config->writeEntry( "Blah", "Blubb" ); - * - * config->setGroup( oldgroup ); - * \endcode - * - * In order to facilitate this task, you can use - * TDEConfigGroupSaver. Simply construct such an object ON THE STACK - * when you want to switch to a new group. Then, when the object goes - * out of scope, the group will automatically be restored. If you - * want to use several different groups within a function or method, - * you can still use TDEConfigGroupSaver: Simply enclose all work with - * one group (including the creation of the TDEConfigGroupSaver object) - * in one block. - * - * @deprecated This class is deprecated and will be removed in KDE 4. - * TDEConfigGroup provides similar functionality in a more object oriented - * way. - * - * @author Matthias Kalle Dalheimer - * @see TDEConfigBase, TDEConfig, KSimpleConfig, TDEConfigGroup - * @short Helper class for easier use of TDEConfig/KSimpleConfig groups - */ - -class TDECORE_EXPORT TDEConfigGroupSaver // KDE4 remove -{ -public: - /** - * Constructor. You pass a pointer to the TDEConfigBase-derived - * object you want to work with and a string indicating the _new_ - * group. - * - * @param config The TDEConfigBase-derived object this - * TDEConfigGroupSaver works on. - * @param group The new group that the config object should switch to. - */ - TDEConfigGroupSaver( TDEConfigBase* config, TQString group ) - /* KDE 4 : make the second parameter const TQString & */ - : _config(config), _oldgroup(config->group()) - { _config->setGroup( group ); } - - TDEConfigGroupSaver( TDEConfigBase* config, const char *group ) - : _config(config), _oldgroup(config->group()) - { _config->setGroup( group ); } - - TDEConfigGroupSaver( TDEConfigBase* config, const TQCString &group ) - : _config(config), _oldgroup(config->group()) - { _config->setGroup( group ); } - - ~TDEConfigGroupSaver() { _config->setGroup( _oldgroup ); } - - TDEConfigBase* config() { return _config; }; - -private: - TDEConfigBase* _config; - TQString _oldgroup; - - TDEConfigGroupSaver(const TDEConfigGroupSaver&); - TDEConfigGroupSaver& operator=(const TDEConfigGroupSaver&); - - TDEConfigGroupSaverPrivate *d; -}; - -class TDEConfigGroupPrivate; - -/** - * A TDEConfigBase derived class for one specific group in a TDEConfig object. - */ -class TDECORE_EXPORT TDEConfigGroup: public TDEConfigBase -{ -public: - /** - * Construct a config group corresponding to @p group in @p master. - * @p group is the group name encoded in UTF-8. - */ - TDEConfigGroup(TDEConfigBase *master, const TQCString &group); - /** - * This is an overloaded constructor provided for convenience. - * It behaves essentially like the above function. - * - * Construct a config group corresponding to @p group in @p master - */ - TDEConfigGroup(TDEConfigBase *master, const TQString &group); - /** - * This is an overloaded constructor provided for convenience. - * It behaves essentially like the above function. - * - * Construct a config group corresponding to @p group in @p master - * @p group is the group name encoded in UTF-8. - */ - TDEConfigGroup(TDEConfigBase *master, const char * group); - - /** - * Delete all entries in the entire group - * @param bGlobal If @p bGlobal is true, the entries are not removed - * from the application specific config file, but from the global - * KDE config file. - */ - void deleteGroup(bool bGlobal = false); - - /** - * Checks whether it is possible to change this group. - * @return whether changes may be made to this group in this configuration - * file. - * @since 3.4 - */ - bool groupIsImmutable() const; - - // The following functions are reimplemented: - virtual void setDirty(bool _bDirty); - virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup = true); - virtual KEntry lookupData(const KEntryKey &_key) const; - virtual void sync(); - -private: - // Hide the following members: - void setGroup() { } - void setDesktopGroup() { } - void group() { } - void hasGroup() { } - void setReadOnly(bool) { } - void isDirty() { } - - // The following members are not used. - virtual TQStringList groupList() const { return TQStringList(); } - virtual void rollback(bool) { } - virtual void reparseConfiguration() { } - virtual TQMap entryMap(const TQString &) const - { return TQMap(); } - virtual KEntryMap internalEntryMap( const TQString&) const - { return KEntryMap(); } - virtual KEntryMap internalEntryMap() const - { return KEntryMap(); } - virtual bool internalHasGroup(const TQCString &) const - { return false; } - - void getConfigState() { } - - TDEConfigBase *mMaster; -protected: - virtual void virtual_hook( int id, void* data ); -private: - TDEConfigGroupPrivate* d; -}; - -#endif diff --git a/tdecore/kconfigdata.h b/tdecore/kconfigdata.h deleted file mode 100644 index f99f72c08..000000000 --- a/tdecore/kconfigdata.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 1999-2000 Preston Brown - Copyright (C) 1996-2000 Matthias Kalle Dalheimer - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef _KCONFIGDATA_H -#define _KCONFIGDATA_H - -#include // generic red-black tree class -#include "tdelibs_export.h" - -/** - * map/dict/list config node entry. - * @internal - */ -struct TDECORE_EXPORT KEntry -{ - KEntry() - : mValue(0), bDirty(false), bNLS(false), - bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false) {} - TQCString mValue; - /** - * Must the entry be written back to disk? - */ - bool bDirty :1; - /** - * Entry should be written with locale tag - */ - bool bNLS :1; - /** - * Entry should be written to the global config file - */ - bool bGlobal:1; - /** - * Entry can not be modified. - */ - bool bImmutable:1; - /** - * Entry has been deleted. - */ - bool bDeleted:1; - /** - * Whether to apply dollar expansion or not. - */ - bool bExpand:1; -}; - -/** - * key structure holding both the actual key and the the group - * to which it belongs. - * @internal - */ -struct TDECORE_EXPORT KEntryKey -{ - KEntryKey(const TQCString& _group = 0, - const TQCString& _key = 0) - : mGroup(_group), mKey(_key), bLocal(false), bDefault(false), - c_key(_key.data()) {} - /** - * The "group" to which this EntryKey belongs - */ - TQCString mGroup; - /** - * The _actual_ key of the entry in question - */ - TQCString mKey; - /** - * Entry is localised or not - */ - bool bLocal :1; - /** - * Entry indicates if this is a default value. - */ - bool bDefault:1; - - const char *c_key; -}; - -/** - * compares two KEntryKeys (needed for TQMap). - * @internal - */ -inline bool operator <(const KEntryKey &k1, const KEntryKey &k2) -{ - //saves one strcmp on each call - int result=qstrcmp(k1.mGroup.data(),k2.mGroup.data()); - if (result!=0) - return (result<0); - - if (!k1.c_key && k2.c_key) - return true; - - result = 0; - if (k1.c_key && k2.c_key) - result = strcmp(k1.c_key, k2.c_key); - if (result != 0) - return result < 0; - if (!k1.bLocal && k2.bLocal) - return true; - if (k1.bLocal && !k2.bLocal) - return false; - return (!k1.bDefault && k2.bDefault); -} - -/** - * \relates KEntry - * type specifying a map of entries (key,value pairs). - * The keys are actually a key in a particular config file group together - * with the group name. - * @internal - */ -typedef TQMap KEntryMap; - -/** - * \relates KEntry - * type for iterating over keys in a KEntryMap in sorted order. - * @internal - */ -typedef TQMap::Iterator KEntryMapIterator; - -/** - * \relates KEntry - * type for iterating over keys in a KEntryMap in sorted order. - * It is const, thus you cannot change the entries in the iterator, - * only examine them. - * @internal - */ -typedef TQMap::ConstIterator KEntryMapConstIterator; - -#endif diff --git a/tdecore/kconfigdialogmanager.cpp b/tdecore/kconfigdialogmanager.cpp deleted file mode 100644 index dfb81853b..000000000 --- a/tdecore/kconfigdialogmanager.cpp +++ /dev/null @@ -1,398 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2003 Benjamin C Meyer (ben+tdelibs at meyerhome dot net) - * Copyright (C) 2003 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "kconfigdialogmanager.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -class TDEConfigDialogManager::Private { - -public: - Private() : insideGroupBox(false) { } - -public: - TQDict knownWidget; - TQDict buddyWidget; - bool insideGroupBox; -}; - -TDEConfigDialogManager::TDEConfigDialogManager(TQWidget *parent, TDEConfigSkeleton *conf, const char *name) - : TQObject(parent, name), m_conf(conf), m_dialog(parent) -{ - d = new Private(); - - kapp->installKDEPropertyMap(); - propertyMap = TQSqlPropertyMap::defaultMap(); - - init(true); -} - -TDEConfigDialogManager::~TDEConfigDialogManager() -{ - delete d; -} - -void TDEConfigDialogManager::init(bool trackChanges) -{ - if(trackChanges) - { - // QT - changedMap.insert(TQBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); - changedMap.insert(TQCHECKBOX_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); - changedMap.insert(TQPUSHBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); - changedMap.insert(TQRADIOBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); - // We can only store one thing, so you can't have - // a ButtonGroup that is checkable. - changedMap.insert(TQBUTTONGROUP_OBJECT_NAME_STRING, TQT_SIGNAL(clicked(int))); - changedMap.insert(TQGROUPBOX_OBJECT_NAME_STRING, TQT_SIGNAL(toggled(bool))); - changedMap.insert(TQCOMBOBOX_OBJECT_NAME_STRING, TQT_SIGNAL(activated (int))); - //qsqlproperty map doesn't store the text, but the value! - //changedMap.insert(TQCOMBOBOX_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged(const TQString &))); - changedMap.insert(TQDATEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(const TQDate &))); - changedMap.insert(TQDATETIMEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(const TQDateTime &))); - changedMap.insert(TQDIAL_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged (int))); - changedMap.insert(TQLINEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged(const TQString &))); - changedMap.insert(TQSLIDER_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(int))); - changedMap.insert(TQSPINBOX_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(int))); - changedMap.insert(TQTIMEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(const TQTime &))); - changedMap.insert(TQTEXTEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged())); - changedMap.insert(TQTEXTBROWSER_OBJECT_NAME_STRING, TQT_SIGNAL(sourceChanged(const TQString &))); - changedMap.insert(TQMULTILINEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged())); - changedMap.insert(TQLISTBOX_OBJECT_NAME_STRING, TQT_SIGNAL(selectionChanged())); - changedMap.insert(TQTABWIDGET_OBJECT_NAME_STRING, TQT_SIGNAL(currentChanged(TQWidget *))); - - // KDE - changedMap.insert( "KComboBox", TQT_SIGNAL(activated (int))); - changedMap.insert( "KFontCombo", TQT_SIGNAL(activated (int))); - changedMap.insert( "KFontRequester", TQT_SIGNAL(fontSelected(const TQFont &))); - changedMap.insert( "KFontChooser", TQT_SIGNAL(fontSelected(const TQFont &))); - changedMap.insert( "KHistoryCombo", TQT_SIGNAL(activated (int))); - - changedMap.insert( "KColorButton", TQT_SIGNAL(changed(const TQColor &))); - changedMap.insert( "KDatePicker", TQT_SIGNAL(dateSelected (TQDate))); - changedMap.insert( "KDateWidget", TQT_SIGNAL(changed (TQDate))); - changedMap.insert( "KDateTimeWidget", TQT_SIGNAL(valueChanged (const TQDateTime &))); - changedMap.insert( "KEditListBox", TQT_SIGNAL(changed())); - changedMap.insert( "KListBox", TQT_SIGNAL(selectionChanged())); - changedMap.insert( "KLineEdit", TQT_SIGNAL(textChanged(const TQString &))); - changedMap.insert( "KPasswordEdit", TQT_SIGNAL(textChanged(const TQString &))); - changedMap.insert( "KRestrictedLine", TQT_SIGNAL(textChanged(const TQString &))); - changedMap.insert( "KTextBrowser", TQT_SIGNAL(sourceChanged(const TQString &))); - changedMap.insert( "KTextEdit", TQT_SIGNAL(textChanged())); - changedMap.insert( "KURLRequester", TQT_SIGNAL(textChanged (const TQString& ))); - changedMap.insert( "KIntNumInput", TQT_SIGNAL(valueChanged (int))); - changedMap.insert( "KIntSpinBox", TQT_SIGNAL(valueChanged (int))); - changedMap.insert( "KDoubleNumInput", TQT_SIGNAL(valueChanged (double))); - } - - // Go through all of the children of the widgets and find all known widgets - (void) parseChildren(m_dialog, trackChanges); -} - -void TDEConfigDialogManager::addWidget(TQWidget *widget) -{ - (void) parseChildren(widget, true); -} - -void TDEConfigDialogManager::setupWidget(TQWidget *widget, TDEConfigSkeletonItem *item) -{ - TQVariant minValue = item->minValue(); - if (minValue.isValid()) - { - if (widget->metaObject()->findProperty("minValue", true) != -1) - widget->setProperty("minValue", minValue); - } - TQVariant maxValue = item->maxValue(); - if (maxValue.isValid()) - { - if (widget->metaObject()->findProperty("maxValue", true) != -1) - widget->setProperty("maxValue", maxValue); - } - if (TQWhatsThis::textFor( widget ).isEmpty()) - { - TQString whatsThis = item->whatsThis(); - if ( !whatsThis.isEmpty() ) - { - TQWhatsThis::add( widget, whatsThis ); - } - } -} - -bool TDEConfigDialogManager::parseChildren(const TQWidget *widget, bool trackChanges) -{ - bool valueChanged = false; - const TQObjectList listOfChildren = widget->childrenListObject(); - if(listOfChildren.isEmpty()) - return valueChanged; - - TQObject *object; - for( TQObjectListIterator it( listOfChildren ); - (object = it.current()); ++it ) - { - if(!object->isWidgetType()) - continue; // Skip non-widgets - - TQWidget *childWidget = (TQWidget *)object; - - const char *widgetName = childWidget->name(0); - bool bParseChildren = true; - bool bSaveInsideGroupBox = d->insideGroupBox; - - if (widgetName && (strncmp(widgetName, "kcfg_", 5) == 0)) - { - // This is one of our widgets! - TQString configId = widgetName+5; - TDEConfigSkeletonItem *item = m_conf->findItem(configId); - if (item) - { - d->knownWidget.insert(configId, childWidget); - - setupWidget(childWidget, item); - - TQMap::const_iterator changedIt = changedMap.find(childWidget->className()); - - if (changedIt == changedMap.end()) - { - // If the class name of the widget wasn't in the monitored widgets map, then look for - // it again using the super class name. This fixes a problem with using QtRuby/Korundum - // widgets with TDEConfigXT where 'Qt::Widget' wasn't being seen a the real deal, even - // though it was a 'QWidget'. - changedIt = changedMap.find(childWidget->metaObject()->superClassName()); - } - - if (changedIt == changedMap.end()) - { - kdWarning(178) << "Don't know how to monitor widget '" << childWidget->className() << "' for changes!" << endl; - } - else - { - connect(childWidget, *changedIt, - this, TQT_SIGNAL(widgetModified())); - - TQGroupBox *gb = dynamic_cast(childWidget); - if (!gb) - bParseChildren = false; - else - d->insideGroupBox = true; - - TQComboBox *cb = dynamic_cast(childWidget); - if (cb && cb->editable()) - connect(cb, TQT_SIGNAL(textChanged(const TQString &)), - this, TQT_SIGNAL(widgetModified())); - } - } - else - { - kdWarning(178) << "A widget named '" << widgetName << "' was found but there is no setting named '" << configId << "'" << endl; - } - } - else if (childWidget->inherits(TQLABEL_OBJECT_NAME_STRING)) - { - TQLabel *label = static_cast(childWidget); - TQWidget *buddy = label->buddy(); - if (!buddy) - continue; - const char *buddyName = buddy->name(0); - if (buddyName && (strncmp(buddyName, "kcfg_", 5) == 0)) - { - // This is one of our widgets! - TQString configId = buddyName+5; - d->buddyWidget.insert(configId, childWidget); - } - } -#ifndef NDEBUG - else if (widgetName) - { - TQMap::const_iterator changedIt = changedMap.find(childWidget->className()); - if (changedIt != changedMap.end()) - { - if ((!d->insideGroupBox || !childWidget->inherits(TQRADIOBUTTON_OBJECT_NAME_STRING)) && - !childWidget->inherits(TQGROUPBOX_OBJECT_NAME_STRING)) - kdDebug(178) << "Widget '" << widgetName << "' (" << childWidget->className() << ") remains unmanaged." << endl; - } - } -#endif - - if(bParseChildren) - { - // this widget is not known as something we can store. - // Maybe we can store one of its children. - valueChanged |= parseChildren(childWidget, trackChanges); - } - d->insideGroupBox = bSaveInsideGroupBox; - } - return valueChanged; -} - -void TDEConfigDialogManager::updateWidgets() -{ - bool changed = false; - bool bSignalsBlocked = signalsBlocked(); - blockSignals(true); - - TQWidget *widget; - for( TQDictIterator it( d->knownWidget ); - (widget = it.current()); ++it ) - { - TDEConfigSkeletonItem *item = m_conf->findItem(it.currentKey()); - if (!item) - { - kdWarning(178) << "The setting '" << it.currentKey() << "' has disappeared!" << endl; - continue; - } - - TQVariant p = item->property(); - if (p != property(widget)) - { - setProperty(widget, p); -// kdDebug(178) << "The setting '" << it.currentKey() << "' [" << widget->className() << "] has changed" << endl; - changed = true; - } - if (item->isImmutable()) - { - widget->setEnabled(false); - TQWidget *buddy = d->buddyWidget.find(it.currentKey()); - if (buddy) - buddy->setEnabled(false); - } - } - blockSignals(bSignalsBlocked); - - if (changed) - TQTimer::singleShot(0, this, TQT_SIGNAL(widgetModified())); -} - -void TDEConfigDialogManager::updateWidgetsDefault() -{ - bool bUseDefaults = m_conf->useDefaults(true); - updateWidgets(); - m_conf->useDefaults(bUseDefaults); -} - -void TDEConfigDialogManager::updateSettings() -{ - bool changed = false; - - TQWidget *widget; - for( TQDictIterator it( d->knownWidget ); - (widget = it.current()); ++it ) - { - TDEConfigSkeletonItem *item = m_conf->findItem(it.currentKey()); - if (!item) - { - kdWarning(178) << "The setting '" << it.currentKey() << "' has disappeared!" << endl; - continue; - } - - TQVariant p = property(widget); - if (p != item->property()) - { - item->setProperty(p); - changed = true; - } - } - if (changed) - { - m_conf->writeConfig(); - emit settingsChanged(); - } -} - -void TDEConfigDialogManager::setProperty(TQWidget *w, const TQVariant &v) -{ - TQButtonGroup *bg = dynamic_cast(w); - if (bg) - { - bg->setButton(v.toInt()); - return; - } - - TQComboBox *cb = dynamic_cast(w); - if (cb && cb->editable()) - { - cb->setCurrentText(v.toString()); - return; - } - - propertyMap->setProperty(w, v); -} - -TQVariant TDEConfigDialogManager::property(TQWidget *w) -{ - TQButtonGroup *bg = dynamic_cast(w); - if (bg) - return TQVariant(bg->selectedId()); - - TQComboBox *cb = dynamic_cast(w); - if (cb && cb->editable()) - return TQVariant(cb->currentText()); - - return propertyMap->property(w); -} - -bool TDEConfigDialogManager::hasChanged() -{ - - TQWidget *widget; - for( TQDictIterator it( d->knownWidget ); - (widget = it.current()); ++it ) - { - TDEConfigSkeletonItem *item = m_conf->findItem(it.currentKey()); - if (!item) - { - kdWarning(178) << "The setting '" << it.currentKey() << "' has disappeared!" << endl; - continue; - } - - TQVariant p = property(widget); - if (p != item->property()) - { -// kdDebug(178) << "Widget for '" << it.currentKey() << "' has changed." << endl; - return true; - } - } - return false; -} - -bool TDEConfigDialogManager::isDefault() -{ - bool bUseDefaults = m_conf->useDefaults(true); - bool result = !hasChanged(); - m_conf->useDefaults(bUseDefaults); - return result; -} - -#include "kconfigdialogmanager.moc" - diff --git a/tdecore/kconfigdialogmanager.h b/tdecore/kconfigdialogmanager.h deleted file mode 100644 index 1b82e9eda..000000000 --- a/tdecore/kconfigdialogmanager.h +++ /dev/null @@ -1,236 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (C) 2003 Benjamin C Meyer (ben+tdelibs at meyerhome dot net) - * Copyright (C) 2003 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ -#ifndef KCONFIGDIALOGMANAGER_H -#define KCONFIGDIALOGMANAGER_H - -#include -#include -#include "tdelibs_export.h" - -class TDEConfigSkeleton; -class TDEConfigSkeletonItem; -class TQWidget; -class TQSqlPropertyMap; - -/** - * @short Provides a means of automatically retrieving, - * saving and resetting TDEConfigSkeleton based settings in a dialog. - * - * The TDEConfigDialogManager class provides a means of automatically - * retrieving, saving and resetting basic settings. - * It also can emit signals when settings have been changed - * (settings were saved) or modified (the user changes a checkbox - * from on to off). - * - * The names of the widgets to be managed have to correspond to the names of the - * configuration entries in the TDEConfigSkeleton object plus an additional - * "kcfg_" prefix. For example a widget named "kcfg_MyOption" would be - * associated to the configuration entry "MyOption". - * - * TDEConfigDialogManager uses the TQSqlPropertyMap class to determine if it can do - * anything to a widget. Note that TDEConfigDialogManager doesn't require a - * database, it simply uses the functionality that is built into the - * TQSqlPropertyMap class. New widgets can be added to the map using - * TQSqlPropertyMap::installDefaultMap(). Note that you can't just add any - * class. The class must have a matching TQ_PROPERTY(...) macro defined. - * - * For example (note that KColorButton is already added and it doesn't need to - * manually added): - * - * kcolorbutton.h defines the following property: - * \code - * TQ_PROPERTY( TQColor color READ color WRITE setColor ) - * \endcode - * - * To add KColorButton the following code would be inserted in the main. - * - * \code - * kapp->installKDEPropertyMap(); - * TQSqlPropertyMap *map = TQSqlPropertyMap::defaultMap(); - * map->insert("KColorButton", "color"); - * \endcode - * - * If you add a new widget to the TQSqlPropertyMap and wish to be notified when - * it is modified you should add its signal using addWidgetChangedSignal(). - - * @since 3.2 - * @author Benjamin C Meyer - * @author Waldo Bastian - */ -class TDECORE_EXPORT TDEConfigDialogManager : public TQObject { - -Q_OBJECT - -signals: - /** - * One or more of the settings have been saved (such as when the user - * clicks on the Apply button). This is only emitted by updateSettings() - * whenever one or more setting were changed and consequently saved. - */ - void settingsChanged(); - - /** - * TODO: Verify - * One or more of the settings have been changed. - * @param widget - The widget group (pass in via addWidget()) that - * contains the one or more modified setting. - * @see settingsChanged() - */ - void settingsChanged( TQWidget *widget ); - - /** - * If retrieveSettings() was told to track changes then if - * any known setting was changed this signal will be emitted. Note - * that a settings can be modified several times and might go back to the - * original saved state. hasChanged() will tell you if anything has - * actually changed from the saved values. - */ - void widgetModified(); - - -public: - - /** - * Constructor. - * @param parent Dialog widget to manage - * @param conf Object that contains settings - * @param name - Object name. - */ - TDEConfigDialogManager(TQWidget *parent, TDEConfigSkeleton *conf, const char *name=0); - - /** - * Destructor. - */ - ~TDEConfigDialogManager(); - - /** - * Add additional widgets to manage - * @param widget Additional widget to manage, inlcuding all its children - */ - void addWidget(TQWidget *widget); - - /** - * Returns whether the current state of the known widgets are - * different from the state in the config object. - */ - bool hasChanged(); - - /** - * Returns whether the current state of the known widgets are - * the same as the default state in the config object. - */ - bool isDefault(); - -public slots: - /** - * Traverse the specified widgets, saving the settings of all known - * widgets in the settings object. - * - * Example use: User clicks Ok or Apply button in a configure dialog. - */ - void updateSettings(); - - /** - * Traverse the specified widgets, sets the state of all known - * widgets according to the state in the settings object. - * - * Example use: Initialisation of dialog. - * Example use: User clicks Reset button in a configure dialog. - */ - void updateWidgets(); - - /** - * Traverse the specified widgets, sets the state of all known - * widgets according to the default state in the settings object. - * - * Example use: User clicks Defaults button in a configure dialog. - */ - void updateWidgetsDefault(); - -protected: - - /** - * @param trackChanges - If any changes by the widgets should be tracked - * set true. This causes the emitting the modified() signal when - * something changes. - * TODO: @return bool - True if any setting was changed from the default. - */ - void init(bool trackChanges); - - /** - * Recursive function that finds all known children. - * Goes through the children of widget and if any are known and not being - * ignored, stores them in currentGroup. Also checks if the widget - * should be disabled because it is set immutable. - * @param widget - Parent of the children to look at. - * @param trackChanges - If true then tracks any changes to the children of - * widget that are known. - * @return bool - If a widget was set to something other then its default. - */ - bool parseChildren(const TQWidget *widget, bool trackChanges); - - /** - * Set a property - */ - void setProperty(TQWidget *w, const TQVariant &v); - - /** - * Retrieve a property - */ - TQVariant property(TQWidget *w); - - /** - * Setup secondary widget properties - */ - void setupWidget(TQWidget *widget, TDEConfigSkeletonItem *item); - -protected: - /** - * TDEConfigSkeleton object used to store settings - */ - TDEConfigSkeleton *m_conf; - - /** - * Dialog being managed - */ - TQWidget *m_dialog; - - /** - * Pointer to the property map for easy access. - */ - TQSqlPropertyMap *propertyMap; - - /** - * Map of the classes and the signals that they emit when changed. - */ - TQMap changedMap; - -private: - class Private; - /** - * TDEConfigDialogManager Private class. - */ - Private *d; - -}; - -#endif // KCONFIGDIALOGMANAGER_H - diff --git a/tdecore/kconfigskeleton.cpp b/tdecore/kconfigskeleton.cpp deleted file mode 100644 index afc45bb87..000000000 --- a/tdecore/kconfigskeleton.cpp +++ /dev/null @@ -1,1207 +0,0 @@ -/* - This file is part of KOrganizer. - Copyright (c) 2000,2001 Cornelius Schumacher - Copyright (c) 2003 Waldo Bastian - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include -#include -#include -#include -#include - -#include "kstringhandler.h" - -#include "kconfigskeleton.h" - -void TDEConfigSkeletonItem::readImmutability( TDEConfig *config ) -{ - mIsImmutable = config->entryIsImmutable( mKey ); -} - - -TDEConfigSkeleton::ItemString::ItemString( const TQString &group, const TQString &key, - TQString &reference, - const TQString &defaultValue, - Type type ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ), - mType( type ) -{ -} - -void TDEConfigSkeleton::ItemString::writeConfig( TDEConfig *config ) -{ - if ( mReference != mLoadedValue ) // WABA: Is this test needed? - { - config->setGroup( mGroup ); - if ((mDefault == mReference) && !config->hasDefault( mKey)) - config->revertToDefault( mKey ); - else if ( mType == Path ) - config->writePathEntry( mKey, mReference ); - else if ( mType == Password ) - config->writeEntry( mKey, KStringHandler::obscure( mReference ) ); - else - config->writeEntry( mKey, mReference ); - } -} - - -void TDEConfigSkeleton::ItemString::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - - if ( mType == Path ) - { - mReference = config->readPathEntry( mKey, mDefault ); - } - else if ( mType == Password ) - { - TQString value = config->readEntry( mKey, - KStringHandler::obscure( mDefault ) ); - mReference = KStringHandler::obscure( value ); - } - else - { - mReference = config->readEntry( mKey, mDefault ); - } - - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemString::setProperty(const TQVariant & p) -{ - mReference = p.toString(); -} - -TQVariant TDEConfigSkeleton::ItemString::property() const -{ - return TQVariant(mReference); -} - -TDEConfigSkeleton::ItemPassword::ItemPassword( const TQString &group, const TQString &key, - TQString &reference, - const TQString &defaultValue) - : ItemString( group, key, reference, defaultValue, Password ) -{ -} - -TDEConfigSkeleton::ItemPath::ItemPath( const TQString &group, const TQString &key, - TQString &reference, - const TQString &defaultValue) - : ItemString( group, key, reference, defaultValue, Path ) -{ -} - -TDEConfigSkeleton::ItemProperty::ItemProperty( const TQString &group, - const TQString &key, - TQVariant &reference, - TQVariant defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) -{ -} - -void TDEConfigSkeleton::ItemProperty::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readPropertyEntry( mKey, mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemProperty::setProperty(const TQVariant & p) -{ - mReference = p; -} - -TQVariant TDEConfigSkeleton::ItemProperty::property() const -{ - return mReference; -} - -TDEConfigSkeleton::ItemBool::ItemBool( const TQString &group, const TQString &key, - bool &reference, bool defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) -{ -} - -void TDEConfigSkeleton::ItemBool::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readBoolEntry( mKey, mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemBool::setProperty(const TQVariant & p) -{ - mReference = p.toBool(); -} - -TQVariant TDEConfigSkeleton::ItemBool::property() const -{ - return TQVariant( mReference, 42 /* dummy */ ); -} - - -TDEConfigSkeleton::ItemInt::ItemInt( const TQString &group, const TQString &key, - int &reference, int defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void TDEConfigSkeleton::ItemInt::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readNumEntry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemInt::setProperty(const TQVariant & p) -{ - mReference = p.toInt(); -} - -TQVariant TDEConfigSkeleton::ItemInt::property() const -{ - return TQVariant(mReference); -} - -TQVariant TDEConfigSkeleton::ItemInt::minValue() const -{ - if (mHasMin) - return TQVariant(mMin); - return TQVariant(); -} - -TQVariant TDEConfigSkeleton::ItemInt::maxValue() const -{ - if (mHasMax) - return TQVariant(mMax); - return TQVariant(); -} - -void TDEConfigSkeleton::ItemInt::setMinValue(int v) -{ - mHasMin = true; - mMin = v; -} - -void TDEConfigSkeleton::ItemInt::setMaxValue(int v) -{ - mHasMax = true; - mMax = v; -} - - -TDEConfigSkeleton::ItemInt64::ItemInt64( const TQString &group, const TQString &key, - TQ_INT64 &reference, TQ_INT64 defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void TDEConfigSkeleton::ItemInt64::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readNum64Entry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemInt64::setProperty(const TQVariant & p) -{ - mReference = p.toLongLong(); -} - -TQVariant TDEConfigSkeleton::ItemInt64::property() const -{ - return TQVariant(mReference); -} - -TQVariant TDEConfigSkeleton::ItemInt64::minValue() const -{ - if (mHasMin) - return TQVariant(mMin); - return TQVariant(); -} - -TQVariant TDEConfigSkeleton::ItemInt64::maxValue() const -{ - if (mHasMax) - return TQVariant(mMax); - return TQVariant(); -} - -void TDEConfigSkeleton::ItemInt64::setMinValue(TQ_INT64 v) -{ - mHasMin = true; - mMin = v; -} - -void TDEConfigSkeleton::ItemInt64::setMaxValue(TQ_INT64 v) -{ - mHasMax = true; - mMax = v; -} - -TDEConfigSkeleton::ItemEnum::ItemEnum( const TQString &group, const TQString &key, - int &reference, - const TQValueList &choices, - int defaultValue ) - : ItemInt( group, key, reference, defaultValue ), mChoices( choices ) -{ -} - -void TDEConfigSkeleton::ItemEnum::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - if (!config->hasKey(mKey)) - { - mReference = mDefault; - } - else - { - int i = 0; - mReference = -1; - TQString tmp = config->readEntry( mKey ).lower(); - for(TQValueList::ConstIterator it = mChoices.begin(); - it != mChoices.end(); ++it, ++i) - { - if ((*it).name.lower() == tmp) - { - mReference = i; - break; - } - } - if (mReference == -1) - mReference = config->readNumEntry( mKey, mDefault ); - } - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemEnum::writeConfig( TDEConfig *config ) -{ - if ( mReference != mLoadedValue ) // WABA: Is this test needed? - { - config->setGroup( mGroup ); - if ((mDefault == mReference) && !config->hasDefault( mKey)) - config->revertToDefault( mKey ); - else if ((mReference >= 0) && (mReference < (int) mChoices.count())) - config->writeEntry( mKey, mChoices[mReference].name ); - else - config->writeEntry( mKey, mReference ); - } -} - -TQValueList TDEConfigSkeleton::ItemEnum::choices() const -{ - return mChoices; -} - - -TDEConfigSkeleton::ItemUInt::ItemUInt( const TQString &group, const TQString &key, - unsigned int &reference, - unsigned int defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void TDEConfigSkeleton::ItemUInt::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readUnsignedNumEntry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemUInt::setProperty(const TQVariant & p) -{ - mReference = p.toUInt(); -} - -TQVariant TDEConfigSkeleton::ItemUInt::property() const -{ - return TQVariant(mReference); -} - -TQVariant TDEConfigSkeleton::ItemUInt::minValue() const -{ - if (mHasMin) - return TQVariant(mMin); - return TQVariant(); -} - -TQVariant TDEConfigSkeleton::ItemUInt::maxValue() const -{ - if (mHasMax) - return TQVariant(mMax); - return TQVariant(); -} - -void TDEConfigSkeleton::ItemUInt::setMinValue(unsigned int v) -{ - mHasMin = true; - mMin = v; -} - -void TDEConfigSkeleton::ItemUInt::setMaxValue(unsigned int v) -{ - mHasMax = true; - mMax = v; -} - - -TDEConfigSkeleton::ItemUInt64::ItemUInt64( const TQString &group, const TQString &key, - TQ_UINT64 &reference, TQ_UINT64 defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void TDEConfigSkeleton::ItemUInt64::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readUnsignedNum64Entry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemUInt64::setProperty(const TQVariant & p) -{ - mReference = p.toULongLong(); -} - -TQVariant TDEConfigSkeleton::ItemUInt64::property() const -{ - return TQVariant(mReference); -} - -TQVariant TDEConfigSkeleton::ItemUInt64::minValue() const -{ - if (mHasMin) - return TQVariant(mMin); - return TQVariant(); -} - -TQVariant TDEConfigSkeleton::ItemUInt64::maxValue() const -{ - if (mHasMax) - return TQVariant(mMax); - return TQVariant(); -} - -void TDEConfigSkeleton::ItemUInt64::setMinValue(TQ_UINT64 v) -{ - mHasMin = true; - mMin = v; -} - -void TDEConfigSkeleton::ItemUInt64::setMaxValue(TQ_UINT64 v) -{ - mHasMax = true; - mMax = v; -} - -TDEConfigSkeleton::ItemLong::ItemLong( const TQString &group, const TQString &key, - long &reference, long defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void TDEConfigSkeleton::ItemLong::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readLongNumEntry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemLong::setProperty(const TQVariant & p) -{ - mReference = p.toLongLong(); -} - -TQVariant TDEConfigSkeleton::ItemLong::property() const -{ - return TQVariant((TQ_LLONG) mReference); -} - -TQVariant TDEConfigSkeleton::ItemLong::minValue() const -{ - if (mHasMin) - return TQVariant((TQ_LLONG) mMin); - return TQVariant(); -} - -TQVariant TDEConfigSkeleton::ItemLong::maxValue() const -{ - if (mHasMax) - return TQVariant((TQ_LLONG) mMax); - return TQVariant(); -} - -void TDEConfigSkeleton::ItemLong::setMinValue(long v) -{ - mHasMin = true; - mMin = v; -} - -void TDEConfigSkeleton::ItemLong::setMaxValue(long v) -{ - mHasMax = true; - mMax = v; -} - - -TDEConfigSkeleton::ItemULong::ItemULong( const TQString &group, const TQString &key, - unsigned long &reference, - unsigned long defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void TDEConfigSkeleton::ItemULong::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readUnsignedLongNumEntry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemULong::setProperty(const TQVariant & p) -{ - mReference = p.toULongLong(); -} - -TQVariant TDEConfigSkeleton::ItemULong::property() const -{ - return TQVariant((TQ_ULLONG) mReference); -} - -TQVariant TDEConfigSkeleton::ItemULong::minValue() const -{ - if (mHasMin) - return TQVariant((TQ_ULLONG) mMin); - return TQVariant(); -} - -TQVariant TDEConfigSkeleton::ItemULong::maxValue() const -{ - if (mHasMax) - return TQVariant((TQ_ULLONG) mMax); - return TQVariant(); -} - -void TDEConfigSkeleton::ItemULong::setMinValue(unsigned long v) -{ - mHasMin = true; - mMin = v; -} - -void TDEConfigSkeleton::ItemULong::setMaxValue(unsigned long v) -{ - mHasMax = true; - mMax = v; -} - - -TDEConfigSkeleton::ItemDouble::ItemDouble( const TQString &group, const TQString &key, - double &reference, double defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) - ,mHasMin(false), mHasMax(false) -{ -} - -void TDEConfigSkeleton::ItemDouble::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readDoubleNumEntry( mKey, mDefault ); - if (mHasMin) - mReference = QMAX(mReference, mMin); - if (mHasMax) - mReference = QMIN(mReference, mMax); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemDouble::setProperty(const TQVariant & p) -{ - mReference = p.toDouble(); -} - -TQVariant TDEConfigSkeleton::ItemDouble::property() const -{ - return TQVariant(mReference); -} - -TQVariant TDEConfigSkeleton::ItemDouble::minValue() const -{ - if (mHasMin) - return TQVariant(mMin); - return TQVariant(); -} - -TQVariant TDEConfigSkeleton::ItemDouble::maxValue() const -{ - if (mHasMax) - return TQVariant(mMax); - return TQVariant(); -} - -void TDEConfigSkeleton::ItemDouble::setMinValue(double v) -{ - mHasMin = true; - mMin = v; -} - -void TDEConfigSkeleton::ItemDouble::setMaxValue(double v) -{ - mHasMax = true; - mMax = v; -} - - -TDEConfigSkeleton::ItemColor::ItemColor( const TQString &group, const TQString &key, - TQColor &reference, - const TQColor &defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) -{ -} - -void TDEConfigSkeleton::ItemColor::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readColorEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemColor::setProperty(const TQVariant & p) -{ - mReference = p.toColor(); -} - -TQVariant TDEConfigSkeleton::ItemColor::property() const -{ - return TQVariant(mReference); -} - - -TDEConfigSkeleton::ItemFont::ItemFont( const TQString &group, const TQString &key, - TQFont &reference, - const TQFont &defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) -{ -} - -void TDEConfigSkeleton::ItemFont::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readFontEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemFont::setProperty(const TQVariant & p) -{ - mReference = p.toFont(); -} - -TQVariant TDEConfigSkeleton::ItemFont::property() const -{ - return TQVariant(mReference); -} - - -TDEConfigSkeleton::ItemRect::ItemRect( const TQString &group, const TQString &key, - TQRect &reference, - const TQRect &defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) -{ -} - -void TDEConfigSkeleton::ItemRect::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readRectEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemRect::setProperty(const TQVariant & p) -{ - mReference = p.toRect(); -} - -TQVariant TDEConfigSkeleton::ItemRect::property() const -{ - return TQVariant(mReference); -} - - -TDEConfigSkeleton::ItemPoint::ItemPoint( const TQString &group, const TQString &key, - TQPoint &reference, - const TQPoint &defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) -{ -} - -void TDEConfigSkeleton::ItemPoint::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readPointEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemPoint::setProperty(const TQVariant & p) -{ - mReference = p.toPoint(); -} - -TQVariant TDEConfigSkeleton::ItemPoint::property() const -{ - return TQVariant(mReference); -} - - -TDEConfigSkeleton::ItemSize::ItemSize( const TQString &group, const TQString &key, - TQSize &reference, - const TQSize &defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) -{ -} - -void TDEConfigSkeleton::ItemSize::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readSizeEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemSize::setProperty(const TQVariant & p) -{ - mReference = p.toSize(); -} - -TQVariant TDEConfigSkeleton::ItemSize::property() const -{ - return TQVariant(mReference); -} - - -TDEConfigSkeleton::ItemDateTime::ItemDateTime( const TQString &group, const TQString &key, - TQDateTime &reference, - const TQDateTime &defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) -{ -} - -void TDEConfigSkeleton::ItemDateTime::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - mReference = config->readDateTimeEntry( mKey, &mDefault ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemDateTime::setProperty(const TQVariant & p) -{ - mReference = p.toDateTime(); -} - -TQVariant TDEConfigSkeleton::ItemDateTime::property() const -{ - return TQVariant(mReference); -} - - -TDEConfigSkeleton::ItemStringList::ItemStringList( const TQString &group, const TQString &key, - TQStringList &reference, - const TQStringList &defaultValue ) - : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) -{ -} - -void TDEConfigSkeleton::ItemStringList::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - if ( !config->hasKey( mKey ) ) - mReference = mDefault; - else - mReference = config->readListEntry( mKey ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemStringList::setProperty(const TQVariant & p) -{ - mReference = p.toStringList(); -} - -TQVariant TDEConfigSkeleton::ItemStringList::property() const -{ - return TQVariant(mReference); -} - - -TDEConfigSkeleton::ItemPathList::ItemPathList( const TQString &group, const TQString &key, - TQStringList &reference, - const TQStringList &defaultValue ) - : ItemStringList( group, key, reference, defaultValue ) -{ -} - -void TDEConfigSkeleton::ItemPathList::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - if ( !config->hasKey( mKey ) ) - mReference = mDefault; - else - mReference = config->readPathListEntry( mKey ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemPathList::writeConfig( TDEConfig *config ) -{ - if ( mReference != mLoadedValue ) // WABA: Is this test needed? - { - config->setGroup( mGroup ); - if ((mDefault == mReference) && !config->hasDefault( mKey)) - config->revertToDefault( mKey ); - else { - TQStringList sl = mReference; - config->writePathEntry( mKey, sl ); - } - } -} - - -TDEConfigSkeleton::ItemIntList::ItemIntList( const TQString &group, const TQString &key, - TQValueList &reference, - const TQValueList &defaultValue ) - : TDEConfigSkeletonGenericItem >( group, key, reference, defaultValue ) -{ -} - -void TDEConfigSkeleton::ItemIntList::readConfig( TDEConfig *config ) -{ - config->setGroup( mGroup ); - if ( !config->hasKey( mKey ) ) - mReference = mDefault; - else - mReference = config->readIntListEntry( mKey ); - mLoadedValue = mReference; - - readImmutability( config ); -} - -void TDEConfigSkeleton::ItemIntList::setProperty(const TQVariant &) -{ - // TODO: Not yet supported -} - -TQVariant TDEConfigSkeleton::ItemIntList::property() const -{ - // TODO: Not yet supported - return TQVariant(); -} - - -TDEConfigSkeleton::TDEConfigSkeleton( const TQString &configname ) - : mCurrentGroup( "No Group" ), mUseDefaults(false) -{ - kdDebug(177) << "Creating TDEConfigSkeleton (" << (void *)this << ")" << endl; - - if ( !configname.isEmpty() ) - { - mConfig = KSharedConfig::openConfig( configname ); - } - else - { - mConfig = TDEGlobal::sharedConfig(); - } -} - -TDEConfigSkeleton::TDEConfigSkeleton(KSharedConfig::Ptr config) - : mCurrentGroup( "No Group" ), mUseDefaults(false) -{ - kdDebug(177) << "Creating TDEConfigSkeleton (" << (void *)this << ")" << endl; - mConfig = config; -} - - -TDEConfigSkeleton::~TDEConfigSkeleton() -{ - TDEConfigSkeletonItem::List::ConstIterator it; - for( it = mItems.begin(); it != mItems.end(); ++it ) - { - delete *it; - } -} - -void TDEConfigSkeleton::setCurrentGroup( const TQString &group ) -{ - mCurrentGroup = group; -} - -TDEConfig *TDEConfigSkeleton::config() const -{ - return mConfig; -} - -bool TDEConfigSkeleton::useDefaults(bool b) -{ - if (b == mUseDefaults) - return mUseDefaults; - - mUseDefaults = b; - TDEConfigSkeletonItem::List::ConstIterator it; - for( it = mItems.begin(); it != mItems.end(); ++it ) - { - (*it)->swapDefault(); - } - - usrUseDefaults(b); - return !mUseDefaults; -} - -void TDEConfigSkeleton::setDefaults() -{ - TDEConfigSkeletonItem::List::ConstIterator it; - for( it = mItems.begin(); it != mItems.end(); ++it ) { - (*it)->setDefault(); - } - - usrSetDefaults(); -} - -void TDEConfigSkeleton::readConfig() -{ - kdDebug(177) << "TDEConfigSkeleton::readConfig()" << endl; - - TQString origGroup = mConfig->group(); - - mConfig->reparseConfiguration(); - TDEConfigSkeletonItem::List::ConstIterator it; - for( it = mItems.begin(); it != mItems.end(); ++it ) - { - (*it)->readConfig( mConfig ); - } - - usrReadConfig(); - - mConfig->setGroup(origGroup); -} - -void TDEConfigSkeleton::writeConfig() -{ - kdDebug(177) << "TDEConfigSkeleton::writeConfig()" << endl; - - TQString origGroup = mConfig->group(); - - TDEConfigSkeletonItem::List::ConstIterator it; - for( it = mItems.begin(); it != mItems.end(); ++it ) - { - (*it)->writeConfig( mConfig ); - } - - usrWriteConfig(); - - mConfig->sync(); - - readConfig(); - - mConfig->setGroup(origGroup); -} - -void TDEConfigSkeleton::addItem( TDEConfigSkeletonItem *item, const TQString &name ) -{ - item->setName( name.isEmpty() ? item->key() : name ); - mItems.append( item ); - mItemDict.insert( item->name(), item ); - item->readDefault( mConfig ); - item->readConfig( mConfig ); -} - -TDEConfigSkeleton::ItemString *TDEConfigSkeleton::addItemString( const TQString &name, TQString &reference, - const TQString &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemString *item; - item = new TDEConfigSkeleton::ItemString( mCurrentGroup, key.isEmpty() ? name : key, - reference, defaultValue, - TDEConfigSkeleton::ItemString::Normal ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemPassword *TDEConfigSkeleton::addItemPassword( const TQString &name, TQString &reference, - const TQString &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemPassword *item; - item = new TDEConfigSkeleton::ItemPassword( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemPath *TDEConfigSkeleton::addItemPath( const TQString &name, TQString &reference, - const TQString &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemPath *item; - item = new TDEConfigSkeleton::ItemPath( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemProperty *TDEConfigSkeleton::addItemProperty( const TQString &name, TQVariant &reference, - const TQVariant &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemProperty *item; - item = new TDEConfigSkeleton::ItemProperty( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemBool *TDEConfigSkeleton::addItemBool( const TQString &name, bool &reference, - bool defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemBool *item; - item = new TDEConfigSkeleton::ItemBool( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemInt *TDEConfigSkeleton::addItemInt( const TQString &name, int &reference, - int defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemInt *item; - item = new TDEConfigSkeleton::ItemInt( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemUInt *TDEConfigSkeleton::addItemUInt( const TQString &name, unsigned int &reference, - unsigned int defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemUInt *item; - item = new TDEConfigSkeleton::ItemUInt( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemInt64 *TDEConfigSkeleton::addItemInt64( const TQString &name, TQ_INT64 &reference, - TQ_INT64 defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemInt64 *item; - item = new TDEConfigSkeleton::ItemInt64( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemUInt64 *TDEConfigSkeleton::addItemUInt64( const TQString &name, TQ_UINT64 &reference, - TQ_UINT64 defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemUInt64 *item; - item = new TDEConfigSkeleton::ItemUInt64( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemLong *TDEConfigSkeleton::addItemLong( const TQString &name, long &reference, - long defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemLong *item; - item = new TDEConfigSkeleton::ItemLong( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemULong *TDEConfigSkeleton::addItemULong( const TQString &name, unsigned long &reference, - unsigned long defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemULong *item; - item = new TDEConfigSkeleton::ItemULong( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemDouble *TDEConfigSkeleton::addItemDouble( const TQString &name, double &reference, - double defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemDouble *item; - item = new TDEConfigSkeleton::ItemDouble( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemColor *TDEConfigSkeleton::addItemColor( const TQString &name, TQColor &reference, - const TQColor &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemColor *item; - item = new TDEConfigSkeleton::ItemColor( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemFont *TDEConfigSkeleton::addItemFont( const TQString &name, TQFont &reference, - const TQFont &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemFont *item; - item = new TDEConfigSkeleton::ItemFont( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemRect *TDEConfigSkeleton::addItemRect( const TQString &name, TQRect &reference, - const TQRect &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemRect *item; - item = new TDEConfigSkeleton::ItemRect( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemPoint *TDEConfigSkeleton::addItemPoint( const TQString &name, TQPoint &reference, - const TQPoint &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemPoint *item; - item = new TDEConfigSkeleton::ItemPoint( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemSize *TDEConfigSkeleton::addItemSize( const TQString &name, TQSize &reference, - const TQSize &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemSize *item; - item = new TDEConfigSkeleton::ItemSize( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemDateTime *TDEConfigSkeleton::addItemDateTime( const TQString &name, TQDateTime &reference, - const TQDateTime &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemDateTime *item; - item = new TDEConfigSkeleton::ItemDateTime( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemStringList *TDEConfigSkeleton::addItemStringList( const TQString &name, TQStringList &reference, - const TQStringList &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemStringList *item; - item = new TDEConfigSkeleton::ItemStringList( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -TDEConfigSkeleton::ItemIntList *TDEConfigSkeleton::addItemIntList( const TQString &name, TQValueList &reference, - const TQValueList &defaultValue, const TQString &key ) -{ - TDEConfigSkeleton::ItemIntList *item; - item = new TDEConfigSkeleton::ItemIntList( mCurrentGroup, key.isNull() ? name : key, - reference, defaultValue ); - addItem( item, name ); - return item; -} - -bool TDEConfigSkeleton::isImmutable(const TQString &name) -{ - TDEConfigSkeletonItem *item = findItem(name); - return !item || item->isImmutable(); -} - -TDEConfigSkeletonItem *TDEConfigSkeleton::findItem(const TQString &name) -{ - return mItemDict.find(name); -} diff --git a/tdecore/kconfigskeleton.h b/tdecore/kconfigskeleton.h deleted file mode 100644 index 30dc98841..000000000 --- a/tdecore/kconfigskeleton.h +++ /dev/null @@ -1,1230 +0,0 @@ -/* - * This file is part of KDE. - * - * Copyright (c) 2001,2002,2003 Cornelius Schumacher - * Copyright (c) 2003 Waldo Bastian - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _KCONFIGSKELETON_H -#define _KCONFIGSKELETON_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - /** - * @short Class for storing a preferences setting - * @author Cornelius Schumacher - * @see TDEConfigSkeleton - * - * This class represents one preferences setting as used by @ref TDEConfigSkeleton. - * Subclasses of TDEConfigSkeletonItem implement storage functions for a certain type of - * setting. Normally you don't have to use this class directly. Use the special - * addItem() functions of TDEConfigSkeleton instead. If you subclass this class you will - * have to register instances with the function TDEConfigSkeleton::addItem(). - */ - class TDECORE_EXPORT TDEConfigSkeletonItem - { - public: - typedef TQValueList < TDEConfigSkeletonItem * >List; - typedef TQDict < TDEConfigSkeletonItem > Dict; - typedef TQDictIterator < TDEConfigSkeletonItem > DictIterator; - - /** - * Constructor. - * - * @param group Config file group. - * @param key Config file key. - */ - TDEConfigSkeletonItem(const TQString & group, const TQString & key) - :mGroup(group),mKey(key), mIsImmutable(true) - { - } - - /** - * Destructor. - */ - virtual ~TDEConfigSkeletonItem() - { - } - - /** - * Set config file group. - */ - void setGroup( const TQString &group ) - { - mGroup = group; - } - - /** - * Return config file group. - */ - TQString group() const - { - return mGroup; - } - - /** - * Set config file key. - */ - void setKey( const TQString &key ) - { - mKey = key; - } - - /** - * Return config file key. - */ - TQString key() const - { - return mKey; - } - - /** - * Set internal name of entry. - */ - void setName(const TQString &name) - { - mName = name; - } - - /** - * Return internal name of entry. - */ - TQString name() const - { - return mName; - } - - /** - Set label providing a translated one-line description of the item. - */ - void setLabel( const TQString &l ) - { - mLabel = l; - } - - /** - Return label of item. See setLabel(). - */ - TQString label() const - { - return mLabel; - } - - /** - Set WhatsThis description og item. - */ - void setWhatsThis( const TQString &w ) - { - mWhatsThis = w; - } - - /** - Return WhatsThis description of item. See setWhatsThis(). - */ - TQString whatsThis() const - { - return mWhatsThis; - } - - /** - * This function is called by @ref TDEConfigSkeleton to read the value for this setting - * from a config file. - * value. - */ - virtual void readConfig(TDEConfig *) = 0; - - /** - * This function is called by @ref TDEConfigSkeleton to write the value of this setting - * to a config file. - */ - virtual void writeConfig(TDEConfig *) = 0; - - /** - * Read global default value. - */ - virtual void readDefault(TDEConfig *) = 0; - - /** - * Set item to @p p - */ - virtual void setProperty(const TQVariant &p) = 0; - - /** - * Return item as property - */ - virtual TQVariant property() const = 0; - - /** - * Return minimum value of item or invalid if not specified - */ - virtual TQVariant minValue() const { return TQVariant(); } - - /** - * Return maximum value of item or invalid if not specified - */ - virtual TQVariant maxValue() const { return TQVariant(); } - - /** - Sets the current value to the default value. - */ - virtual void setDefault() = 0; - - /** - * Exchanges the current value with the default value - * Used by TDEConfigSkeleton::useDefaults(bool); - */ - virtual void swapDefault() = 0; - - /** - * Return if the entry can be modified. - */ - bool isImmutable() const - { - return mIsImmutable; - } - - protected: - /** - * sets mIsImmutable to true if mKey in config is immutable - * @param config TDEConfig to check if mKey is immutable in - */ - void readImmutability(TDEConfig *config); - - TQString mGroup; - TQString mKey; - TQString mName; - - private: - bool mIsImmutable; - - TQString mLabel; - TQString mWhatsThis; - }; - - -template < typename T > class TDEConfigSkeletonGenericItem:public TDEConfigSkeletonItem - { - public: - TDEConfigSkeletonGenericItem(const TQString & group, const TQString & key, T & reference, - T defaultValue) - : TDEConfigSkeletonItem(group, key), mReference(reference), - mDefault(defaultValue), mLoadedValue(defaultValue) - { - } - - /** - * Set value of this TDEConfigSkeletonItem. - */ - void setValue(const T & v) - { - mReference = v; - } - - /** - * Return value of this TDEConfigSkeletonItem. - */ - T & value() - { - return mReference; - } - - /** - * Return const value of this TDEConfigSkeletonItem. - */ - const T & value() const - { - return mReference; - } - - /** - Set default value for this item. - */ - virtual void setDefaultValue( const T &v ) - { - mDefault = v; - } - - virtual void setDefault() - { - mReference = mDefault; - } - - virtual void writeConfig(TDEConfig * config) - { - if ( mReference != mLoadedValue ) // Is this needed? - { - config->setGroup(mGroup); - if ((mDefault == mReference) && !config->hasDefault( mKey)) - config->revertToDefault( mKey ); - else - config->writeEntry(mKey, mReference); - } - } - - void readDefault(TDEConfig * config) - { - config->setReadDefaults(true); - readConfig(config); - config->setReadDefaults(false); - mDefault = mReference; - } - - void swapDefault() - { - T tmp = mReference; - mReference = mDefault; - mDefault = tmp; - } - - protected: - T & mReference; - T mDefault; - T mLoadedValue; - }; - - /** - * @short Class for handling preferences settings for an application. - * @author Cornelius Schumacher - * @see TDEConfigSkeletonItem - * - * This class provides an interface to preferences settings. Preferences items - * can be registered by the addItem() function corresponding to the data type of - * the seetting. TDEConfigSkeleton then handles reading and writing of config files and - * setting of default values. - * - * Normally you will subclass TDEConfigSkeleton, add data members for the preferences - * settings and register the members in the constructor of the subclass. - * - * Example: - * \code - * class MyPrefs : public TDEConfigSkeleton - * { - * public: - * MyPrefs() - * { - * setCurrentGroup("MyGroup"); - * addItemBool("MySetting1",mMyBool,false); - * addItemColor("MySetting2",mMyColor,TQColor(1,2,3)); - * - * setCurrentGroup("MyOtherGroup"); - * addItemFont("MySetting3",mMyFont,TQFont("helvetica",12)); - * } - * - * bool mMyBool; - * TQColor mMyColor; - * TQFont mMyFont; - * } - * \endcode - * - * It might be convenient in many cases to make this subclass of TDEConfigSkeleton a - * singleton for global access from all over the application without passing - * references to the TDEConfigSkeleton object around. - * - * You can write the data to the configuration file by calling @ref writeConfig() - * and read the data from the configuration file by calling @ref readConfig(). - * - * If you have items, which are not covered by the existing addItem() functions - * you can add customized code for reading, writing and default setting by - * implementing the functions @ref usrUseDefaults(), @ref usrReadConfig() and - * @ref usrWriteConfig(). - * - * Internally preferences settings are stored in instances of subclasses of - * @ref TDEConfigSkeletonItem. You can also add TDEConfigSkeletonItem subclasses - * for your own types and call the generic @ref addItem() to register them. - * - * In many cases you don't have to write the specific TDEConfigSkeleton - * subclasses yourself, but you can use \ref kconfig_compiler to automatically - * generate the C++ code from an XML description of the configuration options. - */ -class TDECORE_EXPORT TDEConfigSkeleton -{ -public: - - /** - * Class for handling a string preferences item. - */ - class TDECORE_EXPORT ItemString:public TDEConfigSkeletonGenericItem < TQString > - { - public: - enum Type { Normal, Password, Path }; - - ItemString(const TQString & group, const TQString & key, - TQString & reference, - const TQString & defaultValue = TQString::fromLatin1(""), // NOT TQString::null !! - Type type = Normal); - - void writeConfig(TDEConfig * config); - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - - private: - Type mType; - }; - - /** - * Class for handling a password preferences item. - */ - class TDECORE_EXPORT ItemPassword:public ItemString - { - public: - ItemPassword(const TQString & group, const TQString & key, - TQString & reference, - const TQString & defaultValue = TQString::fromLatin1("")); // NOT TQString::null !! - }; - - /** - * Class for handling a path preferences item. - */ - class TDECORE_EXPORT ItemPath:public ItemString - { - public: - ItemPath(const TQString & group, const TQString & key, - TQString & reference, - const TQString & defaultValue = TQString::null); - }; - - - /** - * Class for handling a TQVariant preferences item. - */ - class TDECORE_EXPORT ItemProperty:public TDEConfigSkeletonGenericItem < TQVariant > - { - public: - ItemProperty(const TQString & group, const TQString & key, - TQVariant & reference, TQVariant defaultValue = 0); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a bool preferences item. - */ - class TDECORE_EXPORT ItemBool:public TDEConfigSkeletonGenericItem < bool > - { - public: - ItemBool(const TQString & group, const TQString & key, bool & reference, - bool defaultValue = true); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling an integer preferences item. - */ - class TDECORE_EXPORT ItemInt:public TDEConfigSkeletonGenericItem < int > - { - public: - ItemInt(const TQString & group, const TQString & key, int &reference, - int defaultValue = 0); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(int); - void setMaxValue(int); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - int mMin; - int mMax; - }; - - /** - * Class for handling an 64-bit integer preferences item. - */ - class TDECORE_EXPORT ItemInt64:public TDEConfigSkeletonGenericItem < TQ_INT64 > - { - public: - ItemInt64(const TQString & group, const TQString & key, TQ_INT64 &reference, - TQ_INT64 defaultValue = 0); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(TQ_INT64); - void setMaxValue(TQ_INT64); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - TQ_INT64 mMin; - TQ_INT64 mMax; - }; - - /** - * Class for handling enums. - */ - class TDECORE_EXPORT ItemEnum:public ItemInt - { - public: - struct Choice - { - TQString name; - TQString label; - TQString whatsThis; - }; - - ItemEnum(const TQString & group, const TQString & key, int &reference, - const TQValueList &choices, int defaultValue = 0); - - TQValueList choices() const; - - void readConfig(TDEConfig * config); - void writeConfig(TDEConfig * config); - - private: - TQValueList mChoices; - }; - - - /** - * Class for handling an unsingend integer preferences item. - */ - class TDECORE_EXPORT ItemUInt:public TDEConfigSkeletonGenericItem < unsigned int > - { - public: - ItemUInt(const TQString & group, const TQString & key, - unsigned int &reference, unsigned int defaultValue = 0); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(unsigned int); - void setMaxValue(unsigned int); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - unsigned int mMin; - unsigned int mMax; - }; - - - /** - * Class for hanlding a long integer preferences item. - */ - class TDECORE_EXPORT ItemLong:public TDEConfigSkeletonGenericItem < long > - { - public: - ItemLong(const TQString & group, const TQString & key, long &reference, - long defaultValue = 0); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(long); - void setMaxValue(long); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - long mMin; - long mMax; - }; - - - /** - * Class for handling an unsigned long integer preferences item. - */ - class TDECORE_EXPORT ItemULong:public TDEConfigSkeletonGenericItem < unsigned long > - { - public: - ItemULong(const TQString & group, const TQString & key, - unsigned long &reference, unsigned long defaultValue = 0); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(unsigned long); - void setMaxValue(unsigned long); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - unsigned long mMin; - unsigned long mMax; - }; - - /** - * Class for handling unsigned 64-bit integer preferences item. - */ - class TDECORE_EXPORT ItemUInt64:public TDEConfigSkeletonGenericItem < TQ_UINT64 > - { - public: - ItemUInt64(const TQString & group, const TQString & key, TQ_UINT64 &reference, - TQ_UINT64 defaultValue = 0); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(TQ_UINT64); - void setMaxValue(TQ_UINT64); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - TQ_UINT64 mMin; - TQ_UINT64 mMax; - }; - - /** - * Class for handling a floating point preference item. - */ - class TDECORE_EXPORT ItemDouble:public TDEConfigSkeletonGenericItem < double > - { - public: - ItemDouble(const TQString & group, const TQString & key, - double &reference, double defaultValue = 0); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - TQVariant minValue() const; - TQVariant maxValue() const; - - void setMinValue(double); - void setMaxValue(double); - - private: - bool mHasMin : 1; - bool mHasMax : 1; - double mMin; - double mMax; - }; - - - /** - * Class for handling a color preferences item. - */ - class TDECORE_EXPORT ItemColor:public TDEConfigSkeletonGenericItem < TQColor > - { - public: - ItemColor(const TQString & group, const TQString & key, - TQColor & reference, - const TQColor & defaultValue = TQColor(128, 128, 128)); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a font preferences item. - */ - class TDECORE_EXPORT ItemFont:public TDEConfigSkeletonGenericItem < TQFont > - { - public: - ItemFont(const TQString & group, const TQString & key, TQFont & reference, - const TQFont & defaultValue = TDEGlobalSettings::generalFont()); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a TQRect preferences item. - */ - class TDECORE_EXPORT ItemRect:public TDEConfigSkeletonGenericItem < TQRect > - { - public: - ItemRect(const TQString & group, const TQString & key, TQRect & reference, - const TQRect & defaultValue = TQRect()); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a TQPoint preferences item. - */ - class TDECORE_EXPORT ItemPoint:public TDEConfigSkeletonGenericItem < TQPoint > - { - public: - ItemPoint(const TQString & group, const TQString & key, TQPoint & reference, - const TQPoint & defaultValue = TQPoint()); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a TQSize preferences item. - */ - class TDECORE_EXPORT ItemSize:public TDEConfigSkeletonGenericItem < TQSize > - { - public: - ItemSize(const TQString & group, const TQString & key, TQSize & reference, - const TQSize & defaultValue = TQSize()); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a TQDateTime preferences item. - */ - class TDECORE_EXPORT ItemDateTime:public TDEConfigSkeletonGenericItem < TQDateTime > - { - public: - ItemDateTime(const TQString & group, const TQString & key, - TQDateTime & reference, - const TQDateTime & defaultValue = TQDateTime()); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a string list preferences item. - */ - class TDECORE_EXPORT ItemStringList:public TDEConfigSkeletonGenericItem < TQStringList > - { - public: - ItemStringList(const TQString & group, const TQString & key, - TQStringList & reference, - const TQStringList & defaultValue = TQStringList()); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - - /** - * Class for handling a path list preferences item. - */ - class TDECORE_EXPORT ItemPathList:public ItemStringList - { - public: - ItemPathList(const TQString & group, const TQString & key, - TQStringList & reference, - const TQStringList & defaultValue = TQStringList()); - - void readConfig(TDEConfig * config); - void writeConfig(TDEConfig * config); - }; - - - /** - * Class for handling an integer list preferences item. - */ - class TDECORE_EXPORT ItemIntList:public TDEConfigSkeletonGenericItem < TQValueList < int > > - { - public: - ItemIntList(const TQString & group, const TQString & key, - TQValueList < int >&reference, - const TQValueList < int >&defaultValue = TQValueList < int >()); - - void readConfig(TDEConfig * config); - void setProperty(const TQVariant & p); - TQVariant property() const; - }; - - -public: - /** - * Constructor. - * - * @param configname name of config file. If no name is given, the default - * config file as returned by kapp()->config() is used. - */ - TDEConfigSkeleton(const TQString & configname = TQString::null); - - /** - * Constructor. - * - * @param config configuration object to use. - */ - TDEConfigSkeleton(KSharedConfig::Ptr config); - - /** - * Destructor - */ - virtual ~ TDEConfigSkeleton(); - - /** - Set all registered items to their default values. - */ - void setDefaults(); - - /** - * Read preferences from config file. All registered items are set to the - * values read from disk. - */ - void readConfig(); - - /** - * Write preferences to config file. The values of all registered items are - * written to disk. - */ - void writeConfig(); - - /** - * Set the config file group for subsequent addItem() calls. It is valid - * until setCurrentGroup() is called with a new argument. Call this before - * you add any items. The default value is "No Group". - */ - void setCurrentGroup(const TQString & group); - - /** - * Returns the current group used for addItem() calls. - */ - TQString currentGroup() // ### KDE 4.0: make const - { - return mCurrentGroup; - } - - /** - * Register a custom @ref TDEConfigSkeletonItem with a given name. If the name - * parameter is null, take the name from TDEConfigSkeletonItem::key(). - * Note that all names must be unique but that multiple entries can have - * the same key if they reside in different groups. - */ - void addItem(TDEConfigSkeletonItem *, const TQString & name = TQString::null ); - - /** - * Register an item of type TQString. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemString *addItemString(const TQString & name, TQString & reference, - const TQString & defaultValue = TQString::fromLatin1(""), // NOT TQString::null !! - const TQString & key = TQString::null); - - /** - * Register a password item of type TQString. The string value is written - * encrypted to the config file. Note that the current encryption scheme - * is very weak. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemPassword *addItemPassword(const TQString & name, TQString & reference, - const TQString & defaultValue = TQString::fromLatin1(""), - const TQString & key = TQString::null); - - /** - * Register a path item of type TQString. The string value is interpreted - * as a path. This means, dollar expension is activated for this value, so - * that e.g. $HOME gets expanded. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemPath *addItemPath(const TQString & name, TQString & reference, - const TQString & defaultValue = TQString::fromLatin1(""), - const TQString & key = TQString::null); - - /** - * Register a property item of type TQVariant. Note that only the following - * TQVariant types are allowed: String, StringList, Font, Point, Rect, Size, - * Color, Int, UInt, Bool, Double, DateTime and Date. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemProperty *addItemProperty(const TQString & name, TQVariant & reference, - const TQVariant & defaultValue = TQVariant(), - const TQString & key = TQString::null); - /** - * Register an item of type bool. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemBool *addItemBool(const TQString & name, bool & reference, - bool defaultValue = false, - const TQString & key = TQString::null); - - /** - * Register an item of type int. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemInt *addItemInt(const TQString & name, int &reference, int defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type unsigned int. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemUInt *addItemUInt(const TQString & name, unsigned int &reference, - unsigned int defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type long. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemLong *addItemLong(const TQString & name, long &reference, - long defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type unsigned long. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemULong *addItemULong(const TQString & name, unsigned long &reference, - unsigned long defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type TQ_INT64. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemInt64 *addItemInt64(const TQString & name, TQ_INT64 &reference, - TQ_INT64 defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type TQ_UINT64 - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemUInt64 *addItemUInt64(const TQString & name, TQ_UINT64 &reference, - TQ_UINT64 defaultValue = 0, - const TQString & key = TQString::null); - - /** - * Register an item of type double. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemDouble *addItemDouble(const TQString & name, double &reference, - double defaultValue = 0.0, - const TQString & key = TQString::null); - - /** - * Register an item of type TQColor. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemColor *addItemColor(const TQString & name, TQColor & reference, - const TQColor & defaultValue = TQColor(128, 128, 128), - const TQString & key = TQString::null); - - /** - * Register an item of type TQFont. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemFont *addItemFont(const TQString & name, TQFont & reference, - const TQFont & defaultValue = - TDEGlobalSettings::generalFont(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQRect. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemRect *addItemRect(const TQString & name, TQRect & reference, - const TQRect & defaultValue = TQRect(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQPoint. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemPoint *addItemPoint(const TQString & name, TQPoint & reference, - const TQPoint & defaultValue = TQPoint(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQSize. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemSize *addItemSize(const TQString & name, TQSize & reference, - const TQSize & defaultValue = TQSize(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQDateTime. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemDateTime *addItemDateTime(const TQString & name, TQDateTime & reference, - const TQDateTime & defaultValue = TQDateTime(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQStringList. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemStringList *addItemStringList(const TQString & name, TQStringList & reference, - const TQStringList & defaultValue = TQStringList(), - const TQString & key = TQString::null); - - /** - * Register an item of type TQValueList. - * - * @param name Name used to indentify this setting. Names must be unique. - * @param reference Pointer to the variable, which is set by readConfig() - * calls and read by writeConfig() calls. - * @param defaultValue Default value, which is used when the config file - * does not yet contain the key of this item. - * @param key Key used in config file. If key is null, name is used as key. - * @return The created item - */ - ItemIntList *addItemIntList(const TQString & name, TQValueList < int >&reference, - const TQValueList < int >&defaultValue = - TQValueList < int >(), - const TQString & key = TQString::null); - - /** - * Return the @ref TDEConfig object used for reading and writing the settings. - */ - TDEConfig *config() const; - - /** - * Return list of items managed by this TDEConfigSkeleton object. - */ - TDEConfigSkeletonItem::List items() const - { - return mItems; - } - - /** - * Return whether a certain item is immutable - */ - bool isImmutable(const TQString & name); - - /** - * Lookup item by name - */ - TDEConfigSkeletonItem * findItem(const TQString & name); - - /** - * Indicate whether this object should reflect the actual - * values or the default values. - * @param b If true this object reflects the default values. - * @return The state prior to this call - */ - bool useDefaults(bool b); - -protected: - /** - * Implemented by subclasses that use special defaults. - * It should replace the default values with the actual - * values and vice versa. - */ - virtual void usrUseDefaults(bool) - { - } - - virtual void usrSetDefaults() - { - } - - /** - * Implemented by subclasses that read special config values. - */ - virtual void usrReadConfig() - { - } - - /** - * Implemented by subclasses that write special config values. - */ - virtual void usrWriteConfig() - { - } - -private: - TQString mCurrentGroup; - - KSharedConfig::Ptr mConfig; // pointer to TDEConfig object - - TDEConfigSkeletonItem::List mItems; - TDEConfigSkeletonItem::Dict mItemDict; - - bool mUseDefaults; - - class Private; - Private *d; - -}; - -#endif diff --git a/tdecore/kcrash.cpp b/tdecore/kcrash.cpp index ae767ffb2..420ff177c 100644 --- a/tdecore/kcrash.cpp +++ b/tdecore/kcrash.cpp @@ -51,7 +51,7 @@ #include #include -#include <../kinit/klauncher_cmds.h> +#include <../kinit/tdelauncher_cmds.h> #if defined Q_WS_X11 #include @@ -262,7 +262,7 @@ void KCrash::startDrKonqi( const char* argv[], int argc ) startDirectly( argv, argc ); return; } - klauncher_header header; + tdelauncher_header header; header.cmd = LAUNCHER_EXEC_NEW; const int BUFSIZE = 8192; // make sure this is big enough char buffer[ BUFSIZE + 10 ]; diff --git a/tdecore/kdebug.areas b/tdecore/kdebug.areas index f2da61c43..d714c6535 100644 --- a/tdecore/kdebug.areas +++ b/tdecore/kdebug.areas @@ -29,7 +29,7 @@ 220 tdeui (KToolBar) 230 tdeui (KCommand) 240 tdeui (tdelibs) -250 kfile (tdelibs) +250 tdefile (tdelibs) 264 tdecore (KIconLoader) 265 tdecore (KIconEffect) 270 tdeui (KRootPixmap) @@ -58,7 +58,7 @@ 713 tdeutils (TDECModuleContainer) 750 tdespell (tdelibs) 760 tdemdi -780 kcmshell (tdelibs) +780 tdecmshell (tdelibs) 790 tdeimproxy (tdelibs) 800 kabapi (tdelibs) 900 tdesu (tdelibs) @@ -87,8 +87,8 @@ 1216 twin (client errors) 1217 khotkeys 1218 ksmserver -1219 media kioslave -1220 remote kioslave +1219 media tdeioslave +1220 remote tdeioslave 1400 khelpcenter (tdebase) 1401 kcmhelpcenter @@ -220,7 +220,7 @@ 6201 tdehtml (caret table) 6210 tdehtml (editor) -# libkio +# libtdeio 7000 kio 7001 kio (KDirWatch) 7002 kio (Slave) @@ -239,9 +239,9 @@ 7016 kio (KLauncher) 7017 kio (KIOConnection) 7018 kio (KMimeMagic) -7019 kio (kioslave) +7019 kio (tdeioslave) 7020 kded -7021 kbuildsycoca +7021 tdebuildsycoca 7022 kurifilter 7023 kurifilter (plugins) 7024 kio (UIServer) @@ -260,7 +260,7 @@ 7042 KAr 7043 kio (bookmarks) -# 71xx are for kioslaves +# 71xx are for tdeioslaves 7101 kio_file 7102 kio_ftp 7103 kio_http @@ -427,8 +427,8 @@ 20011 KDB (Connection) 20012 KDB (plugin) -#kfilereplace -23000 KFileReplace (kfilereplacepart) +#tdefilereplace +23000 KFileReplace (tdefilereplacepart) #klinkstatus 23100 KLinkStatus diff --git a/tdecore/kdebug.cpp b/tdecore/kdebug.cpp index e484a3711..27dcf1418 100644 --- a/tdecore/kdebug.cpp +++ b/tdecore/kdebug.cpp @@ -55,7 +55,7 @@ #include #include #include -#include +#include #include "kstaticdeleter.h" #include diff --git a/tdecore/kdesktopfile.cpp b/tdecore/kdesktopfile.cpp index 1b9a49890..a30b2046b 100644 --- a/tdecore/kdesktopfile.cpp +++ b/tdecore/kdesktopfile.cpp @@ -30,7 +30,7 @@ #include #include "kurl.h" -#include "kconfigbackend.h" +#include "tdeconfigbackend.h" #include "kapplication.h" #include "kstandarddirs.h" #include "kmountpoint.h" diff --git a/tdecore/kdesktopfile.h b/tdecore/kdesktopfile.h index 28db47842..60e9fc096 100644 --- a/tdecore/kdesktopfile.h +++ b/tdecore/kdesktopfile.h @@ -19,7 +19,7 @@ #ifndef _KDESKTOPFILE_H #define _KDESKTOPFILE_H -#include "kconfig.h" +#include "tdeconfig.h" #include "tdelibs_export.h" class KDesktopFilePrivate; diff --git a/tdecore/kdetcompmgr.cpp b/tdecore/kdetcompmgr.cpp index 2047a7707..e34554073 100644 --- a/tdecore/kdetcompmgr.cpp +++ b/tdecore/kdetcompmgr.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include diff --git a/tdecore/kglobal.cpp b/tdecore/kglobal.cpp index 9759edbcf..d26bbb678 100644 --- a/tdecore/kglobal.cpp +++ b/tdecore/kglobal.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/tdecore/kglobalsettings.cpp b/tdecore/kglobalsettings.cpp index 8e617b06a..dbd751eea 100644 --- a/tdecore/kglobalsettings.cpp +++ b/tdecore/kglobalsettings.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include diff --git a/tdecore/kiconeffect.cpp b/tdecore/kiconeffect.cpp index 4fd16a49a..ae33d744d 100644 --- a/tdecore/kiconeffect.cpp +++ b/tdecore/kiconeffect.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include "kiconeffect.h" diff --git a/tdecore/kiconloader.cpp b/tdecore/kiconloader.cpp index 127f8eaba..e63f09d0f 100644 --- a/tdecore/kiconloader.cpp +++ b/tdecore/kiconloader.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include diff --git a/tdecore/kicontheme.cpp b/tdecore/kicontheme.cpp index 853c0ab78..abced574e 100644 --- a/tdecore/kicontheme.cpp +++ b/tdecore/kicontheme.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include diff --git a/tdecore/kinstance.cpp b/tdecore/kinstance.cpp index 9b4b7c2c7..cef932fa1 100644 --- a/tdecore/kinstance.cpp +++ b/tdecore/kinstance.cpp @@ -20,7 +20,7 @@ #include #include -#include "kconfig.h" +#include "tdeconfig.h" #include "klocale.h" #include "kcharsets.h" #include "kiconloader.h" diff --git a/tdecore/kkeyserver_x11.cpp b/tdecore/kkeyserver_x11.cpp index e7673debb..69acd0d5e 100644 --- a/tdecore/kkeyserver_x11.cpp +++ b/tdecore/kkeyserver_x11.cpp @@ -31,7 +31,7 @@ #include "kkeynative.h" #include "kshortcut.h" -#include +#include #include #include #include diff --git a/tdecore/klocale.cpp b/tdecore/klocale.cpp index 4c60bed43..f7a3cf77a 100644 --- a/tdecore/klocale.cpp +++ b/tdecore/klocale.cpp @@ -37,7 +37,7 @@ #include "kstandarddirs.h" #include "ksimpleconfig.h" #include "kinstance.h" -#include "kconfig.h" +#include "tdeconfig.h" #include "kdebug.h" #include "kcalendarsystem.h" #include "kcalendarsystemfactory.h" @@ -672,7 +672,7 @@ void KLocale::updateCatalogues( ) } // now iterate over all languages and all wanted catalog names and append or create them in the right order - // the sequence must be e.g. nds/appname nds/tdelibs nds/kio de/appname de/tdelibs de/kio etc. + // the sequence must be e.g. nds/appname nds/tdelibs nds/tdeio de/appname de/tdelibs de/tdeio etc. // and not nds/appname de/appname nds/tdelibs de/tdelibs etc. Otherwise we would be in trouble with a language // sequende nds,en_US, de. In this case en_US must hide everything below in the language list. for ( TQStringList::ConstIterator itLangs = d->languageList.begin(); diff --git a/tdecore/kmdcodec_compat.h b/tdecore/kmdcodec_compat.h index f2ed3b580..80da5356b 100644 --- a/tdecore/kmdcodec_compat.h +++ b/tdecore/kmdcodec_compat.h @@ -1,4 +1,4 @@ #ifdef __GNUC__ -#warning #include is deprecated, use #include instead. +#warning #include is deprecated, use #include instead. #endif #include "../kmdcodec.h" diff --git a/tdecore/knotifyclient.cpp b/tdecore/knotifyclient.cpp index e5d088dcb..309be40f0 100644 --- a/tdecore/knotifyclient.cpp +++ b/tdecore/knotifyclient.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/tdecore/kprotocolinfo_tdecore.cpp b/tdecore/kprotocolinfo_tdecore.cpp index de16f0128..02976616e 100644 --- a/tdecore/kprotocolinfo_tdecore.cpp +++ b/tdecore/kprotocolinfo_tdecore.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include class KProtocolInfo::KProtocolInfoPrivate @@ -555,7 +555,7 @@ TQDataStream& operator<<( TQDataStream& s, const KProtocolInfo::ExtraField& fiel return s; } -// KURL based static functions are implemented in ../kio/kio/kprotocolinfo.cpp +// KURL based static functions are implemented in ../tdeio/tdeio/kprotocolinfo.cpp void KProtocolInfo::virtual_hook( int id, void* data ) { KSycocaEntry::virtual_hook( id, data ); } diff --git a/tdecore/kprotocolinfofactory.h b/tdecore/kprotocolinfofactory.h index 04883bde0..89ba330a9 100644 --- a/tdecore/kprotocolinfofactory.h +++ b/tdecore/kprotocolinfofactory.h @@ -20,7 +20,7 @@ #ifndef __kprotocolinfofactory_h__ #define __kprotocolinfofactory_h__ -#include "../kio/kio/kprotocolinfo.h" +#include "../tdeio/tdeio/kprotocolinfo.h" #include #include diff --git a/tdecore/kshortcutlist.cpp b/tdecore/kshortcutlist.cpp index fcfc48b48..dd171062e 100644 --- a/tdecore/kshortcutlist.cpp +++ b/tdecore/kshortcutlist.cpp @@ -3,7 +3,7 @@ #include #include "kaccelaction.h" -#include +#include #include #include #include diff --git a/tdecore/ksimpleconfig.cpp b/tdecore/ksimpleconfig.cpp index 5c0203a9f..55cf7485b 100644 --- a/tdecore/ksimpleconfig.cpp +++ b/tdecore/ksimpleconfig.cpp @@ -33,7 +33,7 @@ #include "kglobal.h" #include "kstandarddirs.h" -#include "kconfigbackend.h" +#include "tdeconfigbackend.h" #include "ksimpleconfig.h" diff --git a/tdecore/ksimpleconfig.h b/tdecore/ksimpleconfig.h index 326fc8094..541117500 100644 --- a/tdecore/ksimpleconfig.h +++ b/tdecore/ksimpleconfig.h @@ -21,7 +21,7 @@ #ifndef _KSIMPLECONFIG_H #define _KSIMPLECONFIG_H -#include "kconfig.h" +#include "tdeconfig.h" class KSimpleConfigPrivate; diff --git a/tdecore/ksimpledirwatch.cpp b/tdecore/ksimpledirwatch.cpp index 08d686beb..d961d4657 100644 --- a/tdecore/ksimpledirwatch.cpp +++ b/tdecore/ksimpledirwatch.cpp @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include #include @@ -184,7 +184,7 @@ void KSimpleDirWatchPrivate::dnotify_sigio_handler(int sig, siginfo_t *si, void * are supported: * - Polling: All files to be watched are polled regularly * using stat (more precise: TQFileInfo.lastModified()). - * The polling frequency is determined from global kconfig + * The polling frequency is determined from global tdeconfig * settings, defaulting to 500 ms for local directories * and 5000 ms for remote mounts * - FAM (File Alternation Monitor): first used on IRIX, SGI diff --git a/tdecore/ksocks.cpp b/tdecore/ksocks.cpp index eb00b1cec..cc0cde8ca 100644 --- a/tdecore/ksocks.cpp +++ b/tdecore/ksocks.cpp @@ -29,7 +29,7 @@ #include #include #include "klibloader.h" -#include +#include #include #include diff --git a/tdecore/kstandarddirs.cpp b/tdecore/kstandarddirs.cpp index c902cd6f1..c44f60458 100644 --- a/tdecore/kstandarddirs.cpp +++ b/tdecore/kstandarddirs.cpp @@ -47,7 +47,7 @@ #include #include "kstandarddirs.h" -#include "kconfig.h" +#include "tdeconfig.h" #include "kinstance.h" #include "kshell.h" #include "ksimpleconfig.h" diff --git a/tdecore/kstdaccel.cpp b/tdecore/kstdaccel.cpp index 5bda8ebf5..afc49aac4 100644 --- a/tdecore/kstdaccel.cpp +++ b/tdecore/kstdaccel.cpp @@ -23,7 +23,7 @@ #include "kaccelaction.h" #include "kaccelbase.h" -#include +#include #include #include #include diff --git a/tdecore/kuniqueapplication.cpp b/tdecore/kuniqueapplication.cpp index d8b69eade..422b39a1b 100644 --- a/tdecore/kuniqueapplication.cpp +++ b/tdecore/kuniqueapplication.cpp @@ -43,7 +43,7 @@ #include #endif -#include +#include #include "kdebug.h" #include "kuniqueapplication.h" diff --git a/tdecore/networkbackends/network-manager/network-manager.cpp b/tdecore/networkbackends/network-manager/network-manager.cpp index 206e75737..d747b61ae 100644 --- a/tdecore/networkbackends/network-manager/network-manager.cpp +++ b/tdecore/networkbackends/network-manager/network-manager.cpp @@ -20,7 +20,7 @@ #include -#include "kconfig.h" +#include "tdeconfig.h" #include "tdehardwaredevices.h" #include "network-manager.h" @@ -4828,10 +4828,10 @@ TDENetworkVPNTypeList TDENetworkConnectionManager_BackendNM::availableVPNTypes() // read in all available Services for (TQStringList::Iterator i = services.begin (); i != services.end (); ++i) { TQString service = NM_PLUGIN_SERVICE_DIR + TQString ("/") + *i; - TDEConfig* kconfig = new TDEConfig (service, true, true, "config"); - kconfig->setGroup ("VPN Connection"); + TDEConfig* tdeconfig = new TDEConfig (service, true, true, "config"); + tdeconfig->setGroup ("VPN Connection"); - TQString serviceName = kconfig->readEntry("name", TQString()); + TQString serviceName = tdeconfig->readEntry("name", TQString()); serviceName = serviceName.lower(); if (serviceName == "openvpn") { @@ -4847,7 +4847,7 @@ TDENetworkVPNTypeList TDENetworkConnectionManager_BackendNM::availableVPNTypes() ret.append(TDENetworkVPNType::VPNC); } - delete kconfig; + delete tdeconfig; } } diff --git a/tdecore/tdeconfig.cpp b/tdecore/tdeconfig.cpp new file mode 100644 index 000000000..62464b81f --- /dev/null +++ b/tdecore/tdeconfig.cpp @@ -0,0 +1,367 @@ +/* + This file is part of the KDE libraries + Copyright (c) 1999 Preston Brown + Copyright (C) 1997-1999 Matthias Kalle Dalheimer (kalle@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +// $Id$ + +#include + +#ifdef HAVE_SYS_STAT_H +#include +#endif + +#include +#include + +#include + +#include +#include "tdeconfigbackend.h" + +#include "tdeconfig.h" +#include "kglobal.h" +#include "kstandarddirs.h" +#include "kstaticdeleter.h" +#include + +TDEConfig::TDEConfig( const TQString& fileName, + bool bReadOnly, bool bUseKderc, const char *resType ) + : TDEConfigBase(), bGroupImmutable(false), bFileImmutable(false), + bForceGlobal(false) +{ + // set the object's read-only status. + setReadOnly(bReadOnly); + + // for right now we will hardcode that we are using the INI + // back end driver. In the future this should be converted over to + // a object factory of some sorts. + TDEConfigINIBackEnd *aBackEnd = new TDEConfigINIBackEnd(this, + fileName, + resType, + bUseKderc); + + // set the object's back end pointer to this new backend + backEnd = aBackEnd; + + // read initial information off disk + reparseConfiguration(); + + // we let KStandardDirs add custom user config files. It will do + // this only once. So only the first call ever to this constructor + // will anything else than return here We have to reparse here as + // configuration files may appear after customized directories have + // been added. and the info they contain needs to be inserted into the + // config object. + // Since this makes only sense for config directories, addCustomized + // returns true only if new config directories appeared. + if (TDEGlobal::dirs()->addCustomized(this)) + reparseConfiguration(); +} + +TDEConfig::TDEConfig(TDEConfigBackEnd *aBackEnd, bool bReadOnly) + : bGroupImmutable(false), bFileImmutable(false), + bForceGlobal(false) +{ + setReadOnly(bReadOnly); + backEnd = aBackEnd; + reparseConfiguration(); +} + +TDEConfig::~TDEConfig() +{ + sync(); + + delete backEnd; +} + +void TDEConfig::rollback(bool bDeep) +{ + TDEConfigBase::rollback(bDeep); + + if (!bDeep) + return; // object's bDeep flag is set in TDEConfigBase method + + // clear any dirty flags that entries might have set + for (KEntryMapIterator aIt = aEntryMap.begin(); + aIt != aEntryMap.end(); ++aIt) + (*aIt).bDirty = false; +} + +TQStringList TDEConfig::groupList() const +{ + TQStringList retList; + + KEntryMapConstIterator aIt = aEntryMap.begin(); + KEntryMapConstIterator aEnd = aEntryMap.end(); + for (; aIt != aEnd; ++aIt) + { + while(aIt.key().mKey.isEmpty()) + { + TQCString group = aIt.key().mGroup; + ++aIt; + while (true) + { + if (aIt == aEnd) + return retList; // done + + if (aIt.key().mKey.isEmpty()) + break; // Group is empty, next group + + if (!aIt.key().bDefault && !(*aIt).bDeleted) + { + if (group != "$Version") // Special case! + retList.append(TQString::fromUtf8(group)); + break; // Group is non-empty, added, next group + } + ++aIt; + } + } + } + + return retList; +} + +TQMap TDEConfig::entryMap(const TQString &pGroup) const +{ + TQCString pGroup_utf = pGroup.utf8(); + KEntryKey groupKey( pGroup_utf, 0 ); + TQMap tmpMap; + + KEntryMapConstIterator aIt = aEntryMap.find(groupKey); + if (aIt == aEntryMap.end()) + return tmpMap; + ++aIt; // advance past special group entry marker + for (; aIt.key().mGroup == pGroup_utf && aIt != aEntryMap.end(); ++aIt) + { + // Leave the default values out && leave deleted entries out + if (!aIt.key().bDefault && !(*aIt).bDeleted) + tmpMap.insert(TQString::fromUtf8(aIt.key().mKey), TQString::fromUtf8((*aIt).mValue.data(), (*aIt).mValue.length())); + } + + return tmpMap; +} + +void TDEConfig::reparseConfiguration() +{ + // Don't lose pending changes + if (!isReadOnly() && backEnd && bDirty) + backEnd->sync(); + + aEntryMap.clear(); + + // add the "default group" marker to the map + KEntryKey groupKey("", 0); + aEntryMap.insert(groupKey, KEntry()); + + bFileImmutable = false; + parseConfigFiles(); + bFileImmutable = bReadOnly; +} + +KEntryMap TDEConfig::internalEntryMap(const TQString &pGroup) const +{ + TQCString pGroup_utf = pGroup.utf8(); + KEntry aEntry; + KEntryMapConstIterator aIt; + KEntryKey aKey(pGroup_utf, 0); + KEntryMap tmpEntryMap; + + aIt = aEntryMap.find(aKey); + if (aIt == aEntryMap.end()) { + // the special group key is not in the map, + // so it must be an invalid group. Return + // an empty map. + return tmpEntryMap; + } + // we now have a pointer to the nodes we want to copy. + for (; aIt.key().mGroup == pGroup_utf && aIt != aEntryMap.end(); ++aIt) + { + tmpEntryMap.insert(aIt.key(), *aIt); + } + + return tmpEntryMap; +} + +void TDEConfig::putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup) +{ + if (bFileImmutable && !_key.bDefault) + return; + + // check to see if the special group key is present, + // and if not, put it in. + if (_checkGroup) + { + KEntryKey groupKey( _key.mGroup, 0); + KEntry &entry = aEntryMap[groupKey]; + bGroupImmutable = entry.bImmutable; + } + if (bGroupImmutable && !_key.bDefault) + return; + + // now either add or replace the data + KEntry &entry = aEntryMap[_key]; + bool immutable = entry.bImmutable; + if (immutable && !_key.bDefault) + return; + + entry = _data; + entry.bImmutable |= immutable; + entry.bGlobal |= bForceGlobal; // force to kdeglobals + + if (_key.bDefault) + { + // We have added the data as default value, + // add it as normal value as well. + KEntryKey key(_key); + key.bDefault = false; + aEntryMap[key] = _data; + } +} + +KEntry TDEConfig::lookupData(const KEntryKey &_key) const +{ + KEntryMapConstIterator aIt = aEntryMap.find(_key); + if (aIt != aEntryMap.end()) + { + const KEntry &entry = *aIt; + if (entry.bDeleted) + return KEntry(); + else + return entry; + } + else { + return KEntry(); + } +} + +bool TDEConfig::internalHasGroup(const TQCString &group) const +{ + KEntryKey groupKey( group, 0); + + KEntryMapConstIterator aIt = aEntryMap.find(groupKey); + KEntryMapConstIterator aEnd = aEntryMap.end(); + + if (aIt == aEnd) + return false; + ++aIt; + for(; (aIt != aEnd); ++aIt) + { + if (aIt.key().mKey.isEmpty()) + break; + + if (!aIt.key().bDefault && !(*aIt).bDeleted) + return true; + } + return false; +} + +void TDEConfig::setFileWriteMode(int mode) +{ + backEnd->setFileWriteMode(mode); +} + +KLockFile::Ptr TDEConfig::lockFile(bool bGlobal) +{ + TDEConfigINIBackEnd *aBackEnd = dynamic_cast(backEnd); + if (!aBackEnd) return 0; + return aBackEnd->lockFile(bGlobal); +} + +void TDEConfig::checkUpdate(const TQString &id, const TQString &updateFile) +{ + TQString oldGroup = group(); + setGroup("$Version"); + TQString cfg_id = updateFile+":"+id; + TQStringList ids = readListEntry("update_info"); + if (!ids.contains(cfg_id)) + { + TQStringList args; + args << "--check" << updateFile; + TDEApplication::tdeinitExecWait("tdeconf_update", args); + reparseConfiguration(); + } + setGroup(oldGroup); +} + +TDEConfig* TDEConfig::copyTo(const TQString &file, TDEConfig *config) const +{ + if (!config) + config = new TDEConfig(TQString::null, false, false); + config->backEnd->changeFileName(file, "config", false); + config->setReadOnly(false); + config->bFileImmutable = false; + config->backEnd->mConfigState = ReadWrite; + + TQStringList groups = groupList(); + for(TQStringList::ConstIterator it = groups.begin(); + it != groups.end(); ++it) + { + TQMap map = entryMap(*it); + config->setGroup(*it); + for (TQMap::Iterator it2 = map.begin(); + it2 != map.end(); ++it2) + { + config->writeEntry(it2.key(), it2.data()); + } + + } + return config; +} + +void TDEConfig::virtual_hook( int id, void* data ) +{ TDEConfigBase::virtual_hook( id, data ); } + +static KStaticDeleter< TQValueList > sd; +TQValueList *KSharedConfig::s_list = 0; + +KSharedConfig::Ptr KSharedConfig::openConfig(const TQString& fileName, bool readOnly, bool useKDEGlobals ) +{ + if (s_list) + { + for(TQValueList::ConstIterator it = s_list->begin(); + it != s_list->end(); ++it) + { + if ((*it)->backEnd->fileName() == fileName && + (*it)->bReadOnly == readOnly && + (*it)->backEnd->useKDEGlobals == useKDEGlobals ) + return (*it); + } + } + return new KSharedConfig(fileName, readOnly, useKDEGlobals); +} + +KSharedConfig::KSharedConfig( const TQString& fileName, bool readonly, bool usekdeglobals) + : TDEConfig(fileName, readonly, usekdeglobals) +{ + if (!s_list) + { + sd.setObject(s_list, new TQValueList); + } + + s_list->append(this); +} + +KSharedConfig::~KSharedConfig() +{ + if ( s_list ) + s_list->remove(this); +} + +#include "tdeconfig.moc" diff --git a/tdecore/tdeconfig.h b/tdecore/tdeconfig.h new file mode 100644 index 000000000..77a009efa --- /dev/null +++ b/tdecore/tdeconfig.h @@ -0,0 +1,296 @@ +/* + This file is part of the KDE libraries + Copyright (c) 1999 Preston Brown + Copyright (C) 1997 Matthias Kalle Dalheimer + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _KCONFIG_H +#define _KCONFIG_H + +class TQTimer; + +#include + +#include "tdeconfigbase.h" +#include "klockfile.h" + +class TDEConfigPrivate; + +/** +* Access KDE Configuration entries. +* +* This class implements KDE's default configuration system. +* +* @author Kalle Dalheimer , Preston Brown +* @see TDEGlobal::config(), TDEConfigBase, KSimpleConfig +* @short KDE Configuration Management class +*/ +class TDECORE_EXPORT TDEConfig : public TDEConfigBase +{ + Q_OBJECT + +public: + + /** + * Constructs a TDEConfig object. + * + * @param fileName A file to parse in addition to the + * system-wide file(s). If it is not provided, only global + * KDE configuration data will be read (depending on the value of + * @p bUseKDEGlobals). + * @param bReadOnly Set the config object's read-only status. Note that the + * object will automatically become read-only if either the user does not have + * write permission to @p fileName or if no file was specified. + * @param bUseKDEGlobals Toggle reading the global KDE configuration file. + * @param resType the place to look in (config, data, etc) See KStandardDirs. + */ + TDEConfig( const TQString& fileName = TQString::null, + bool bReadOnly = false, bool bUseKDEGlobals = true, const char *resType="config"); + + TDEConfig(TDEConfigBackEnd *backEnd, bool bReadOnly = false); + + /** + * Destructs the TDEConfig object. + * + * Writes back any dirty configuration entries, and destroys + * dynamically created objects. + */ + virtual ~TDEConfig(); + + /** + * Clears all entries out of the @p dirtyEntryMap, so the + * values will not be written to disk on a later call to + * sync(). + * + * @param bDeep If true, the dirty map is actually emptied. + * otherwise, the config object's global dirty flag is set to + * false, but the dirty entries remain in the dirty entry + * map. + * + * @see TDEConfigBase::rollback + */ + virtual void rollback(bool bDeep = true); + + + /** + * Returns a list of groups that are known. + * @return a list of of groups + */ + virtual TQStringList groupList() const; + + /** + * Returns a map (tree) of entries for all entries in a particular + * group. + * + * Only the actual entry string is returned, none of the + * other internal data should be included. + * + * @param pGroup A group to get keys from. + * @return A map of entries in the group specified, indexed by key. + * The returned map may be empty if the group is not found. + */ + virtual TQMap entryMap(const TQString &pGroup) const; + + /** + * Clears all internal data structures and then reread + * configuration information from disk. + */ + virtual void reparseConfiguration(); + + /** + * Set the file mode for newly created files. + * + * @param mode the mode for new files as described in chmod(2) + * @see man:chmod(2) for a description of @p mode + */ + void setFileWriteMode(int mode); + + /** + * Forces all following write-operations being performed on kdeglobals, + * independent of the bGlobal flag in writeEntry(). + * @param force true to force writing in kdeglobals + * @see forceGlobal + */ + void setForceGlobal( bool force ) { bForceGlobal = force; } + + /** + * Returns true if all entries are being written into kdeglobals. + * @return true if all entries are being written into kdeglobals + * @see setForceGlobal + */ + bool forceGlobal() const { return bForceGlobal; } + + /** + * Checks whether the config file contains the update @p id + * as contained in @p updateFile. If not, it runs tdeconf_update + * to update the config file. + * + * If you install config update files with critical fixes + * you may wish to use this method to verify that a critical + * update has indeed been performed to catch the case where + * a user restores an old config file from backup that has + * not been updated yet. + * @param id the update to check + * @param updateFile the file containing the update + * @since 3.1 + */ + void checkUpdate(const TQString &id, const TQString &updateFile); + + /** + * Copies all entries from this config object to a new config + * object that will save itself to @p file. + * + * Actual saving to @p file happens when the returned object is + * destructed or when sync() is called upon it. + * + * @param file the new config object will save itself to. + * @param config optional config object to reuse + * @since 3.2 + */ + TDEConfig* copyTo(const TQString &file, TDEConfig *config=0) const; + + /** + * Returns a lock file object for the configuration file or 0 if + * the backend does not support locking. + * @param bGlobal if true, return the lock file for the global config file + * + * NOTE: TDEConfig::sync() requires a lock on both the normal and global + * config file. When calling TDEConfig::sync() while having a lock on the + * global config file, the normal config file MUST be locked AS WELL and the + * normal config file MUST be locked BEFORE the global config file! + * Otherwise there is a risk of deadlock. + * @since 3.3 + */ + KLockFile::Ptr lockFile( bool bGlobal=false ); + +protected: + + /** + * Returns true if the specified group is known. + * + * @param group The group to search for. + * @returns true if the group exists. + */ + virtual bool internalHasGroup(const TQCString &group) const; + + /** + * @internal + * Returns a map (tree) of the entries in the specified group. + * + * Do not use this function, the implementation / return type are + * subject to change. + * + * @param pGroup the group to provide a KEntryMap for. + * @return The map of the entries in the group. + */ + virtual KEntryMap internalEntryMap(const TQString &pGroup) const; + + /** + * @internal + * Returns a copy of the internal map used to hold all entries. + * + * Do not use this function, the implementation / return type are + * subject to change. + * + * @return The map of the entries in the group. + */ + virtual KEntryMap internalEntryMap() const { return aEntryMap; } + + /** + * Inserts a (key, value) pair into the internal storage mechanism of + * the configuration object. + * + * @param _key The key to insert. It contains information both on + * the group of the key and the key itself. If the key already + * exists, the old value will be replaced. + * @param _data the KEntry that is to be stored. + * @param _checkGroup When false, assume that the group already exists. + */ + virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup=true); + + /** + * Looks up an entry in the config object's internal structure. + * + * @param _key The key to look up It contains information both on + * the group of the key and the entry's key itself. + * @return the KEntry value (data) found for the key. KEntry.aValue + * will be the null string if nothing was located. + */ + virtual KEntry lookupData(const KEntryKey &_key) const; + + /** + * Contains all key,value entries, as well as some "special" + * keys which indicate the start of a group of entries. + * + * These special keys will have the .key portion of their KEntryKey + * set to TQString::null. + */ + KEntryMap aEntryMap; + +private: + /** + * @internal + * copy-construction and assignment are not allowed + */ + TDEConfig( const TDEConfig& ); + /** + * @internal + * copy-construction and assignment are not allowed + */ + TDEConfig& operator= ( const TDEConfig& rConfig ); + +private: + bool bGroupImmutable : 1; // Current group is immutable. + bool bFileImmutable : 1; // Current file is immutable. + bool bForceGlobal : 1; // Apply everything to kdeglobals. +protected: + virtual void virtual_hook( int id, void* data ); +private: + TDEConfigPrivate *d; +}; + +/** + * TDEConfig variant using shared memory + * + * KSharedConfig provides a reference counted, shared memory variant + * of TDEConfig. + */ +class TDECORE_EXPORT KSharedConfig : public TDEConfig, public KShared +{ + friend class TQValueList; +public: + typedef KSharedPtr Ptr; + +public: + /** + * Returns a ref-counted pointer to a shared read-write config object. + * @param fileName the name of the file to use for the configuration + * @param readOnly set the config object's read-only status + * @param bUseKDEGlobals Toggle reading the global KDE configuration file. + */ + static KSharedConfig::Ptr openConfig(const TQString& fileName, bool readOnly = false, + bool bUseKDEGlobals = true); + +private: + KSharedConfig( const TQString& fileName, bool readOnly, bool useKDEGlobals ); + ~KSharedConfig(); + + static TQValueList *s_list; +}; + +#endif diff --git a/tdecore/tdeconfig_compiler/CMakeLists.txt b/tdecore/tdeconfig_compiler/CMakeLists.txt new file mode 100644 index 000000000..a4f24c43e --- /dev/null +++ b/tdecore/tdeconfig_compiler/CMakeLists.txt @@ -0,0 +1,29 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${TQT_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdecore +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### tdeconfig_compiler ########################## + +tde_add_executable( tdeconfig_compiler + SOURCES tdeconfig_compiler.cpp + LINK tdecore-shared + DESTINATION ${BIN_INSTALL_DIR} +) diff --git a/tdecore/tdeconfig_compiler/Makefile.am b/tdecore/tdeconfig_compiler/Makefile.am new file mode 100644 index 000000000..d5141f102 --- /dev/null +++ b/tdecore/tdeconfig_compiler/Makefile.am @@ -0,0 +1,18 @@ +SUBDIRS = example tests + +AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir) $(all_includes) + +bin_PROGRAMS = tdeconfig_compiler + +tdeconfig_compiler_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +tdeconfig_compiler_LDADD = $(LIB_TDECORE) +tdeconfig_compiler_SOURCES = tdeconfig_compiler.cpp + +TESTFILES = test1.kcfg test2.kcfg test3.kcfg test4.kcfg test_dpointer.kcfg + +check-local: + for i in $(TESTFILES); \ + do xmllint --noout --schema $(srcdir)/kcfg.xsd $(srcdir)/tests/$$i; \ + perl $(top_srcdir)/tdecore/tdeconfig_compiler/checkkcfg.pl \ + $(top_srcdir)/tdecore/tdeconfig_compiler/tests/$$i; done + diff --git a/tdecore/tdeconfig_compiler/README.dox b/tdecore/tdeconfig_compiler/README.dox new file mode 100644 index 000000000..1b4926e96 --- /dev/null +++ b/tdecore/tdeconfig_compiler/README.dox @@ -0,0 +1,255 @@ +/** +\page tdeconfig_compiler The KDE Configuration Compiler + +tdeconfig_compiler generates C++ source code from an XML file containing +information about configuration options (.kcfg) and a file that provides +the code generation options (.kcfgc) The generated class is based on +TDEConfigSkeleton and provides an API for the application to access its +configuration data. + +

XML description of the configuration options

+ +The structure of the .kcfg file is described by its DTD kcfg.dtd. + +The \ tag contains the name of the configuration file described. +Omitting the name will make the generated class use the default configuration +file ("rc"). + +The \ tags are optional and may contain C++ header files that +are needed to compile the code needed to compute default values. + +The remaining entries in the XML file are grouped by the tag \ +which describes the corresponding group in the configuration file. + +The individual entries must have at least a name or a key. The name is used to +create accessor and modifier functions. It's also used as the key in the config +file. If \ is given, but not \, the name is constructed by removing +all spaces from \. + +An entry must also have a type. The list of allowable types is +specified in the DTD and loosely follows the list of types supported +by the QVariant with exception of the clearly binary types +(e.g. Pixmap, Image...) which are not supported. Besides those basic +type the following special types are supported: + +- Path This is a string that is specially treated as a file-path. + In particular paths in the home directory are prefixed with $HOME in + when being stored in the configuration file. + +- Enum This indicates an enumeration. The possible enum values should + be provided via the \ tag. Enum values are accessed as integers + by the application but stored as string in the configuration file. This + makes it possible to add more values at a later date without breaking + compatibility. + +- IntList This indicates a list of integers. This information is provided + to the application as QValueList. Useful for storing QSplitter + geometries. + +An entry can optionally have a default value which is used as default when +the value isn't specified in any config file. Default values are interpreted +as literal constant values. If a default value needs to be computed +or if it needs to be obtained from a function call, the \ tag +should contain the code="true" attribute. The contents of the \ +tag is then considered to be a C++ expression. Note that in this case you +might have to add an \ tag as described above so that the code +which computes the default value can be compiled. + +Additional code for computing default values can be provided via +the \ tag. The contents of the \ tag is inserted as-is. A +typical use for this is to compute a common default value which can +then be referenced by multiple entries that follow. + +

Code generation options

+ +The options for generating the C++ sources are read from the file with the +extension .kcfgc. To generate a class add the corresponding kcfgc file to the +SOURCES line in the Makefile.am. + +The following options are read from the kcfgc file: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
Filestringprogramname.kcfgName of kcfg file containing the options the class is generated for
NameSpacestring-Optional namespace for generated class
ClassNamestring-Name of generated class (required)
InheritsstringTDEConfigSkeletonClass the generated class inherits from. This class must inherit + TDEConfigSkeleton.
Visibilitystring-Inserts visibility directive (for example KDE_EXPORT) between "class" keyword and class + name in header file
SingletonboolfalseGenerated class is a singleton.
CustomAdditionsbool-
MemberVariablesstring: public|protected|privateprivateC++ access modifier used for memeber variables holding the configuration + valuse
IncludeFilescomma separated list of strings-Names of files to be included in the header of the generated class
Mutatorstrue, false or a comma seperated list of options-If true, mutator functions for all configuration options are generated. + If false, no mutator functions are generated. If a list is provided, + mutator functions are generated for the options that are listed.
ItemAccessorsboolfalseGenerate accessor functions for the TDEConfigSkeletonItem objects + corresponding to the configuration options. If SetUserTexts is set, + ItemAccessors also has to be set.
SetUserTextsboolfalseSet the label and whatthis texts of the items from the kcfg file.If + SetUserTexts is set, ItemAccessors also has to be set.
GlobalEnumsboolfalseIf set to true all choices of Enum items will be created in the global + scope of the generated class. If set to false, each Enum item will get an own + namespace for its choices.
+ + +

Advanced options

+ +There are several possibilities to parameterize entries. + +- Parameterized entries + +An entry can be parameterized using a fixed range parameter specified with +the \ tag. Such parameter can either be an Enum or an int. An Enum +parameter should specify the possible enumeration values with the \ +tag. An int parameter should specify its maximum value. Its minimum value +is always 0. + +A parameterized entry is expanded to a number of entries, one for each +value in the parameter range. The name and key should contain a reference +to the parameter in the form of $(parameter-name). When expanding the entries +the $(parameter-name) part is replaced with the value of the parameter. +In the case of an Enum parameter it is replaced with the name of the +enumuration value. In the case of an int parameter it is replaced with +the numeric value of the parameter. + +Parameterized entries all share the same default value unless different +default values have been specified for specific parameter values. +This can be done with the param= attribute of the \. When a +param attribute is specified the default value only applies to that +particular parameter value. + +Example 1: +\verbatim + + + #ff0000 + #00ff00 + #0000ff + #ffff00 + +\endverbatim + +The above describes 4 color configuration entries with the following defaults: + +\verbatim +color_0=#ff0000 +color_1=#00ff00 +color_2=#0000ff +color_3=#ffff00 +\endverbatim + +The configuration options will be accessible to the application via +a QColor color(int ColorIndex) and a +void setColor(int ColorIndex, const QColor &v) function. + +Example 2: +\verbatim + + + + Explosion + Crash + Missile + + + boom.wav + crash.wav + missile.wav + +\endverbatim + +The above describes 3 string configuration entries with the following defaults: + +sound_Explosion=boom.wav +sound_Crash=crash.wav +sound_Missile=missile.wav + +The configuration options will be accessible to the application via +a QString sound(int SoundEvent) and a +void setSound(int SoundEvent, const QString &v) function. + +- Parameterized groups + +...STILL TODO... + + + + + +If you have questions or comments please contact Cornelius Schumacher + or Waldo Bastian +*/ diff --git a/tdecore/tdeconfig_compiler/TODO b/tdecore/tdeconfig_compiler/TODO new file mode 100644 index 000000000..e69de29bb diff --git a/tdecore/tdeconfig_compiler/checkkcfg.pl b/tdecore/tdeconfig_compiler/checkkcfg.pl new file mode 100755 index 000000000..26b12bad2 --- /dev/null +++ b/tdecore/tdeconfig_compiler/checkkcfg.pl @@ -0,0 +1,83 @@ +#!/usr/bin/perl + +if ( @ARGV != 1 ) { + print STDERR "Missing arg: filename\n"; + exit 1; +} + +$file = $ARGV[0]; + +$file =~ /^(.*)\.[^\.]*$/; +$filebase = $1; + +$file_h = "$filebase.h"; +$file_cpp = "$filebase.cpp"; + +$kcfgc = $file . "c"; + +$cmd = "./tdeconfig_compiler $file $kcfgc"; + +#print "CMD $cmd\n"; + +if ( system( $cmd ) != 0 ) { + print STDERR "Unable to run tdeconfig_compiler\n"; + exit 1; +} + +chectdefile( $file_h ); +chectdefile( $file_cpp ); + +exit 0; + +sub chectdefile() +{ + my $file = shift; + + $file =~ /\/([^\/]*)$/; + my $filename = $1; + + print "Checking '$filename':\n"; + + my @ref; + if ( !open( REF, "$file.ref" ) ) { + print STDERR "Unable to open $file.ref\n"; + exit 1; + } + while( ) { + push @ref, $_; + } + close REF; + + if ( !open( READ, $filename ) ) { + print STDERR "Unable to open $filename\n"; + exit 1; + } + + $error = 0; + $i = 0; + $line = 1; + while( ) { + $out = $_; + $ref = @ref[$i++]; + + if ( $out ne $ref ) { + $error++; + print " Line $line: Expected : $ref"; + print " Line $line: Compiler output : $out"; + } + + $line++; + } + + close READ; + + if ( $error > 0 ) { + print "\n FAILED: $error errors found.\n"; + if ( $error > 5 ) { + system( "diff -u $file.ref $filename" ); + } + exit 1; + } else { + print " OK\n"; + } +} diff --git a/tdecore/tdeconfig_compiler/example/Makefile.am b/tdecore/tdeconfig_compiler/example/Makefile.am new file mode 100644 index 000000000..612788f6b --- /dev/null +++ b/tdecore/tdeconfig_compiler/example/Makefile.am @@ -0,0 +1,27 @@ +AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir) $(all_includes) + +check_PROGRAMS = example # autoexample +EXTRA_PROGRAMS = autoexample + +example_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +example_LDADD = $(LIB_TDECORE) +example_SOURCES = example.cpp exampleprefs_base.cpp + +autoexample_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +autoexample_LDADD = $(LIB_TDECORE) $(LIB_TDEUI) +autoexample_SOURCES = exampleprefs_base.cpp general_base.ui myoptions_base.ui \ + autoexample.cpp + +example.o exampleprefs_base.o: exampleprefs_base.h +# avoid running the below command in parallel +exampleprefs_base.cpp: exampleprefs_base.h +exampleprefs_base.cpp exampleprefs_base.h: $(srcdir)/example.kcfg ../tdeconfig_compiler $(srcdir)/exampleprefs_base.kcfgc + ../tdeconfig_compiler $(srcdir)/example.kcfg $(srcdir)/exampleprefs_base.kcfgc + +METASOURCES = AUTO + +CLEANFILES = exampleprefs_base.h exampleprefs_base.cpp + +## The example's messages should not go into tdelibs.pot +messages: rc.cpp + true diff --git a/tdecore/tdeconfig_compiler/example/autoexample.cpp b/tdecore/tdeconfig_compiler/example/autoexample.cpp new file mode 100644 index 000000000..6ed89d75f --- /dev/null +++ b/tdecore/tdeconfig_compiler/example/autoexample.cpp @@ -0,0 +1,64 @@ +/* + This file is part of KDE. + + Copyright (c) 2003 Cornelius Schumacher + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "general_base.h" +#include "myoptions_base.h" + +#include "exampleprefs_base.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +int main( int argc, char **argv ) +{ + TDEAboutData aboutData( "example", I18N_NOOP("autoconfig example"), "0.1" ); + aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); + + TDECmdLineArgs::init( argc, argv, &aboutData ); + + TDEApplication app; + + ExamplePrefsBase configSkeleton( "dummy1", "dummy2" ); + configSkeleton.readConfig(); + + TDEConfigDialog *dialog = new TDEConfigDialog( 0, "settings", &configSkeleton ); + + GeneralBase *general = new GeneralBase( 0 ); + dialog->addPage( general, i18n("General"), "General", "" ); + + MyOptionsBase *myOptions = new MyOptionsBase( 0 ); + dialog->addPage( myOptions, i18n("MyOptions"), "MyOptions", "" ); + + app.setMainWidget( dialog ); + + dialog->show(); + + return app.exec(); +} diff --git a/tdecore/tdeconfig_compiler/example/example.cpp b/tdecore/tdeconfig_compiler/example/example.cpp new file mode 100644 index 000000000..6788d1ee0 --- /dev/null +++ b/tdecore/tdeconfig_compiler/example/example.cpp @@ -0,0 +1,52 @@ +/* + This file is part of KDE. + + Copyright (c) 2003 Cornelius Schumacher + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "exampleprefs_base.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +int main( int argc, char **argv ) +{ + TDEAboutData aboutData( "example", I18N_NOOP("cfgc example"), "0.1" ); + aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); + + TDECmdLineArgs::init( argc, argv, &aboutData ); + + TDEApplication app; + + ExamplePrefsBase *prefs = new ExamplePrefsBase("Trans1", "Folder2"); + + prefs->readConfig(); + + prefs->setAnotherOption(17); + + kdWarning() << "Another Option = " << prefs->anotherOption() << endl; + kdWarning() << "Another Option2 = " << prefs->anotherOption2() << endl; + kdWarning() << "MyPaths = " << prefs->myPaths() << endl; + kdWarning() << "MyPaths2 = " << prefs->myPaths2() << endl; +} diff --git a/tdecore/tdeconfig_compiler/example/example.kcfg b/tdecore/tdeconfig_compiler/example/example.kcfg new file mode 100644 index 000000000..076bfb644 --- /dev/null +++ b/tdecore/tdeconfig_compiler/example/example.kcfg @@ -0,0 +1,63 @@ + + + qdir.h + + + + + + + + true + + + + 5 + + + + And this is a longer description of this option. Just wondering, how will the translations of those be handled? + + + + + + One + + + + + + Default String + + + + QDir::homeDirPath()+QString::fromLatin1(".hidden_file") + + + + /home,~ + + + + QStringList(QDir::homeDirPath()) + + + + 10 + + + up,down + + + + + 1 + + + diff --git a/tdecore/tdeconfig_compiler/example/exampleprefs_base.kcfgc b/tdecore/tdeconfig_compiler/example/exampleprefs_base.kcfgc new file mode 100644 index 000000000..9b72fdb07 --- /dev/null +++ b/tdecore/tdeconfig_compiler/example/exampleprefs_base.kcfgc @@ -0,0 +1,18 @@ +# Code generation options for tdeconfig_compiler +ClassName=ExamplePrefsBase +# +# Singleton=false +# +# Inherits=TDEConfigSkeleton +# +# IncludeFiles=libtdepim/kpimprefs.h +# +# MemberVariables=public +# +### The following line includes the file exampleprefs_base_addon.h +### It can be used to add extra functions and variables to the +### class. +# CustomAdditions=true +# +### Provide setFooBar(int) style functions +Mutators=true diff --git a/tdecore/tdeconfig_compiler/example/general_base.ui b/tdecore/tdeconfig_compiler/example/general_base.ui new file mode 100644 index 000000000..9b41370c7 --- /dev/null +++ b/tdecore/tdeconfig_compiler/example/general_base.ui @@ -0,0 +1,46 @@ + +GeneralBase + + + GeneralBase + + + + 0 + 0 + 600 + 486 + + + + AutoExampleDialog + + + + unnamed + + + + kcfg_OneOption + + + OneOption + + + + + kcfg_AnotherOption2 + + + + + textLabel1 + + + AnotherOption: + + + + + + diff --git a/tdecore/tdeconfig_compiler/example/myoptions_base.ui b/tdecore/tdeconfig_compiler/example/myoptions_base.ui new file mode 100644 index 000000000..3c0c2e6cb --- /dev/null +++ b/tdecore/tdeconfig_compiler/example/myoptions_base.ui @@ -0,0 +1,35 @@ + +MyOptionsBase + + + MyOptionsBase + + + + 0 + 0 + 600 + 486 + + + + + unnamed + + + + textLabel1 + + + MyString: + + + + + kcfg_MyString + + + + + + diff --git a/tdecore/tdeconfig_compiler/kcfg.xsd b/tdecore/tdeconfig_compiler/kcfg.xsd new file mode 100644 index 000000000..9eb18a068 --- /dev/null +++ b/tdecore/tdeconfig_compiler/kcfg.xsd @@ -0,0 +1,192 @@ + + + + + + + + Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2003 Waldo Bastian <bastian@kde.org> + Copyright (c) 2003 Zack Rusin <zack@kde.org> + Copyright (c) 2004 Frans Englich <frans.englich@telia.com> + + Permission to use, copy, modify and distribute this DTD + and its accompanying documentation for any purpose and without fee + is hereby granted in perpetuity, provided that the above copyright + notice and this paragraph appear in all copies. The copyright + holders make no representation about the suitability of the DTD for + any purpose. It is provided "as is" without expressed or implied + warranty. + + + + + + + A Schema for KDE's TDEConfigXT XML format. It is similar to the DTD + found at: + + http://www.kde.org/standards/kcfg/1.0/kcfg.dtd + + Documents valid against the Schema version are backwards compatible + to the DTD. Validating against the Schema instead of the DTD is + recommended, since the former provides better validation. + + A document instance of this Schema should have a declaration + looking like this: + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tdecore/tdeconfig_compiler/tdeconfig_compiler.cpp b/tdecore/tdeconfig_compiler/tdeconfig_compiler.cpp new file mode 100644 index 000000000..c7f2fd7bd --- /dev/null +++ b/tdecore/tdeconfig_compiler/tdeconfig_compiler.cpp @@ -0,0 +1,1700 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*- +/* + This file is part of KDE. + + Copyright (c) 2003 Cornelius Schumacher + Copyright (c) 2003 Waldo Bastian + Copyright (c) 2003 Zack Rusin + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static const KCmdLineOptions options[] = +{ + { "d", 0, 0 }, + { "directory ", I18N_NOOP("Directory to generate files in"), "." }, + { "+file.kcfg", I18N_NOOP("Input kcfg XML file"), 0 }, + { "+file.kcfgc", I18N_NOOP("Code generation options file"), 0 }, + KCmdLineLastOption +}; + + +bool globalEnums; +bool itemAccessors; +bool dpointer; +TQStringList allNames; +TQRegExp *validNameRegexp; +TQString This; +TQString Const; + +class CfgEntry +{ + public: + struct Choice + { + TQString name; + TQString label; + TQString whatsThis; + }; + + CfgEntry( const TQString &group, const TQString &type, const TQString &key, + const TQString &name, const TQString &label, + const TQString &whatsThis, const TQString &code, + const TQString &defaultValue, const TQValueList &choices, + bool hidden ) + : mGroup( group ), mType( type ), mKey( key ), mName( name ), + mLabel( label ), mWhatsThis( whatsThis ), mCode( code ), + mDefaultValue( defaultValue ), + mChoices( choices ), mHidden( hidden ) + { + } + + void setGroup( const TQString &group ) { mGroup = group; } + TQString group() const { return mGroup; } + + void setType( const TQString &type ) { mType = type; } + TQString type() const { return mType; } + + void setKey( const TQString &key ) { mKey = key; } + TQString key() const { return mKey; } + + void setName( const TQString &name ) { mName = name; } + TQString name() const { return mName; } + + void setLabel( const TQString &label ) { mLabel = label; } + TQString label() const { return mLabel; } + + void setWhatsThis( const TQString &whatsThis ) { mWhatsThis = whatsThis; } + TQString whatsThis() const { return mWhatsThis; } + + void setDefaultValue( const TQString &d ) { mDefaultValue = d; } + TQString defaultValue() const { return mDefaultValue; } + + void setCode( const TQString &d ) { mCode = d; } + TQString code() const { return mCode; } + + void setMinValue( const TQString &d ) { mMin = d; } + TQString minValue() const { return mMin; } + + void setMaxValue( const TQString &d ) { mMax = d; } + TQString maxValue() const { return mMax; } + + void setParam( const TQString &d ) { mParam = d; } + TQString param() const { return mParam; } + + void setParamName( const TQString &d ) { mParamName = d; } + TQString paramName() const { return mParamName; } + + void setParamType( const TQString &d ) { mParamType = d; } + TQString paramType() const { return mParamType; } + + void setChoices( const TQValueList &d ) { mChoices = d; } + TQValueList choices() const { return mChoices; } + + void setParamValues( const TQStringList &d ) { mParamValues = d; } + TQStringList paramValues() const { return mParamValues; } + + void setParamDefaultValues( const TQStringList &d ) { mParamDefaultValues = d; } + TQString paramDefaultValue(int i) const { return mParamDefaultValues[i]; } + + void setParamMax( int d ) { mParamMax = d; } + int paramMax() const { return mParamMax; } + + bool hidden() const { return mHidden; } + + void dump() const + { + kdDebug() << "" << endl; + kdDebug() << " group: " << mGroup << endl; + kdDebug() << " type: " << mType << endl; + kdDebug() << " key: " << mKey << endl; + kdDebug() << " name: " << mName << endl; + kdDebug() << " label: " << mLabel << endl; +// whatsthis + kdDebug() << " code: " << mCode << endl; +// kdDebug() << " values: " << mValues.join(":") << endl; + + if (!param().isEmpty()) + { + kdDebug() << " param name: "<< mParamName << endl; + kdDebug() << " param type: "<< mParamType << endl; + kdDebug() << " paramvalues: " << mParamValues.join(":") << endl; + } + kdDebug() << " default: " << mDefaultValue << endl; + kdDebug() << " hidden: " << mHidden << endl; + kdDebug() << " min: " << mMin << endl; + kdDebug() << " max: " << mMax << endl; + kdDebug() << "" << endl; + } + + private: + TQString mGroup; + TQString mType; + TQString mKey; + TQString mName; + TQString mLabel; + TQString mWhatsThis; + TQString mCode; + TQString mDefaultValue; + TQString mParam; + TQString mParamName; + TQString mParamType; + TQValueList mChoices; + TQStringList mParamValues; + TQStringList mParamDefaultValues; + int mParamMax; + bool mHidden; + TQString mMin; + TQString mMax; +}; + +class Param { +public: + TQString name; + TQString type; +}; + +// returns the name of an member variable +// use itemPath to know the full path +// like using d-> in case of dpointer +static TQString varName(const TQString &n) +{ + TQString result; + if ( !dpointer ) { + result = "m"+n; + result[1] = result[1].upper(); + } + else { + result = n; + result[0] = result[0].lower(); + } + return result; +} + +static TQString varPath(const TQString &n) +{ + TQString result; + if ( dpointer ) { + result = "d->"+varName(n); + } + else { + result = varName(n); + } + return result; +} + +static TQString enumName(const TQString &n) +{ + TQString result = "Enum"+n; + result[4] = result[4].upper(); + return result; +} + +static TQString setFunction(const TQString &n, const TQString &className = TQString()) +{ + TQString result = "set"+n; + result[3] = result[3].upper(); + + if ( !className.isEmpty() ) + result = className + "::" + result; + return result; +} + + +static TQString getFunction(const TQString &n, const TQString &className = TQString()) +{ + TQString result = n; + result[0] = result[0].lower(); + + if ( !className.isEmpty() ) + result = className + "::" + result; + return result; +} + + +static void addQuotes( TQString &s ) +{ + if ( s.left( 1 ) != "\"" ) s.prepend( "\"" ); + if ( s.right( 1 ) != "\"" ) s.append( "\"" ); +} + +static TQString quoteString( const TQString &s ) +{ + TQString r = s; + r.replace( "\\", "\\\\" ); + r.replace( "\"", "\\\"" ); + r.replace( "\r", "" ); + r.replace( "\n", "\\n\"\n\"" ); + return "\"" + r + "\""; +} + +static TQString literalString( const TQString &s ) +{ + bool isAscii = true; + for(int i = s.length(); i--;) + if (s[i].unicode() > 127) isAscii = false; + + if (isAscii) + return "TQString::fromLatin1( " + quoteString(s) + " )"; + else + return "TQString::fromUtf8( " + quoteString(s) + " )"; +} + +static TQString dumpNode(const TQDomNode &node) +{ + TQString msg; + TQTextStream s(&msg, IO_WriteOnly ); + node.save(s, 0); + + msg = msg.simplifyWhiteSpace(); + if (msg.length() > 40) + return msg.left(37)+"..."; + return msg; +} + +static TQString filenameOnly(TQString path) +{ + int i = path.findRev('/'); + if (i >= 0) + return path.mid(i+1); + return path; +} + +static void preProcessDefault( TQString &defaultValue, const TQString &name, + const TQString &type, + const TQValueList &choices, + TQString &code ) +{ + if ( type == "String" && !defaultValue.isEmpty() ) { + defaultValue = literalString(defaultValue); + + } else if ( type == "Path" && !defaultValue.isEmpty() ) { + defaultValue = literalString( defaultValue ); + + } else if ( (type == "StringList" || type == "PathList") && !defaultValue.isEmpty() ) { + TQTextStream cpp( &code, IO_WriteOnly | IO_Append ); + if (!code.isEmpty()) + cpp << endl; + + cpp << " TQStringList default" << name << ";" << endl; + TQStringList defaults = TQStringList::split( ",", defaultValue ); + TQStringList::ConstIterator it; + for( it = defaults.begin(); it != defaults.end(); ++it ) { + cpp << " default" << name << ".append( TQString::fromUtf8( \"" << *it << "\" ) );" + << endl; + } + defaultValue = "default" + name; + + } else if ( type == "Color" && !defaultValue.isEmpty() ) { + TQRegExp colorRe("\\d+,\\s*\\d+,\\s*\\d+"); + if (colorRe.exactMatch(defaultValue)) + { + defaultValue = "TQColor( " + defaultValue + " )"; + } + else + { + defaultValue = "TQColor( \"" + defaultValue + "\" )"; + } + + } else if ( type == "Enum" ) { + if ( !globalEnums ) { + TQValueList::ConstIterator it; + for( it = choices.begin(); it != choices.end(); ++it ) { + if ( (*it).name == defaultValue ) { + defaultValue.prepend( enumName(name) + "::"); + break; + } + } + } + + } else if ( type == "IntList" ) { + TQTextStream cpp( &code, IO_WriteOnly | IO_Append ); + if (!code.isEmpty()) + cpp << endl; + + cpp << " TQValueList default" << name << ";" << endl; + TQStringList defaults = TQStringList::split( ",", defaultValue ); + TQStringList::ConstIterator it; + for( it = defaults.begin(); it != defaults.end(); ++it ) { + cpp << " default" << name << ".append( " << *it << " );" + << endl; + } + defaultValue = "default" + name; + } +} + + +CfgEntry *parseEntry( const TQString &group, const TQDomElement &element ) +{ + bool defaultCode = false; + TQString type = element.attribute( "type" ); + TQString name = element.attribute( "name" ); + TQString key = element.attribute( "key" ); + TQString hidden = element.attribute( "hidden" ); + TQString label; + TQString whatsThis; + TQString defaultValue; + TQString code; + TQString param; + TQString paramName; + TQString paramType; + TQValueList choices; + TQStringList paramValues; + TQStringList paramDefaultValues; + TQString minValue; + TQString maxValue; + int paramMax = 0; + + TQDomNode n; + for ( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { + TQDomElement e = n.toElement(); + TQString tag = e.tagName(); + if ( tag == "label" ) label = e.text(); + else if ( tag == "whatsthis" ) whatsThis = e.text(); + else if ( tag == "min" ) minValue = e.text(); + else if ( tag == "max" ) maxValue = e.text(); + else if ( tag == "code" ) code = e.text(); + else if ( tag == "parameter" ) + { + param = e.attribute( "name" ); + paramType = e.attribute( "type" ); + if ( param.isEmpty() ) { + kdError() << "Parameter must have a name: " << dumpNode(e) << endl; + return 0; + } + if ( paramType.isEmpty() ) { + kdError() << "Parameter must have a type: " << dumpNode(e) << endl; + return 0; + } + if ((paramType == "Int") || (paramType == "UInt")) + { + bool ok; + paramMax = e.attribute("max").toInt(&ok); + if (!ok) + { + kdError() << "Integer parameter must have a maximum (e.g. max=\"0\"): " << dumpNode(e) << endl; + return 0; + } + } + else if (paramType == "Enum") + { + TQDomNode n2; + for ( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { + TQDomElement e2 = n2.toElement(); + if (e2.tagName() == "values") + { + TQDomNode n3; + for ( n3 = e2.firstChild(); !n3.isNull(); n3 = n3.nextSibling() ) { + TQDomElement e3 = n3.toElement(); + if (e3.tagName() == "value") + { + paramValues.append( e3.text() ); + } + } + break; + } + } + if (paramValues.isEmpty()) + { + kdError() << "No values specified for parameter '" << param << "'." << endl; + return 0; + } + paramMax = paramValues.count()-1; + } + else + { + kdError() << "Parameter '" << param << "' has type " << paramType << " but must be of type int, uint or Enum." << endl; + return 0; + } + } + else if ( tag == "default" ) + { + if (e.attribute("param").isEmpty()) + { + defaultValue = e.text(); + if (e.attribute( "code" ) == "true") + defaultCode = true; + } + } + else if ( tag == "choices" ) { + TQDomNode n2; + for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { + TQDomElement e2 = n2.toElement(); + if ( e2.tagName() == "choice" ) { + TQDomNode n3; + CfgEntry::Choice choice; + choice.name = e2.attribute( "name" ); + if ( choice.name.isEmpty() ) { + kdError() << "Tag requires attribute 'name'." << endl; + } + for( n3 = e2.firstChild(); !n3.isNull(); n3 = n3.nextSibling() ) { + TQDomElement e3 = n3.toElement(); + if ( e3.tagName() == "label" ) choice.label = e3.text(); + if ( e3.tagName() == "whatsthis" ) choice.whatsThis = e3.text(); + } + choices.append( choice ); + } + } + } + } + + bool nameIsEmpty = name.isEmpty(); + if ( nameIsEmpty && key.isEmpty() ) { + kdError() << "Entry must have a name or a key: " << dumpNode(element) << endl; + return 0; + } + + if ( key.isEmpty() ) { + key = name; + } + + if ( nameIsEmpty ) { + name = key; + name.replace( " ", TQString() ); + } else if ( name.contains( ' ' ) ) { + kdWarning()<<"Entry '"< elements can't contain speces!"< paramMax)) + { + kdError() << "Index '" << i << "' for default value is out of range [0, "<< paramMax<<"]." << endl; + return 0; + } + + TQString tmpDefaultValue = e.text(); + + if (e.attribute( "code" ) != "true") + preProcessDefault(tmpDefaultValue, name, type, choices, code); + + paramDefaultValues[i] = tmpDefaultValue; + } + } + } + + if (!validNameRegexp->exactMatch(name)) + { + if (nameIsEmpty) + kdError() << "The key '" << key << "' can not be used as name for the entry because " + "it is not a valid name. You need to specify a valid name for this entry." << endl; + else + kdError() << "The name '" << name << "' is not a valid name for an entry." << endl; + return 0; + } + + if (allNames.contains(name)) + { + if (nameIsEmpty) + kdError() << "The key '" << key << "' can not be used as name for the entry because " + "it does not result in a unique name. You need to specify a unique name for this entry." << endl; + else + kdError() << "The name '" << name << "' is not unique." << endl; + return 0; + } + allNames.append(name); + + if (!defaultCode) + { + preProcessDefault(defaultValue, name, type, choices, code); + } + + CfgEntry *result = new CfgEntry( group, type, key, name, label, whatsThis, + code, defaultValue, choices, + hidden == "true" ); + if (!param.isEmpty()) + { + result->setParam(param); + result->setParamName(paramName); + result->setParamType(paramType); + result->setParamValues(paramValues); + result->setParamDefaultValues(paramDefaultValues); + result->setParamMax(paramMax); + } + result->setMinValue(minValue); + result->setMaxValue(maxValue); + + return result; +} + +/** + Return parameter declaration for given type. +*/ +TQString param( const TQString &type ) +{ + if ( type == "String" ) return "const TQString &"; + else if ( type == "StringList" ) return "const TQStringList &"; + else if ( type == "Font" ) return "const TQFont &"; + else if ( type == "Rect" ) return "const TQRect &"; + else if ( type == "Size" ) return "const TQSize &"; + else if ( type == "Color" ) return "const TQColor &"; + else if ( type == "Point" ) return "const TQPoint &"; + else if ( type == "Int" ) return "int"; + else if ( type == "UInt" ) return "uint"; + else if ( type == "Bool" ) return "bool"; + else if ( type == "Double" ) return "double"; + else if ( type == "DateTime" ) return "const TQDateTime &"; + else if ( type == "Int64" ) return "TQ_INT64"; + else if ( type == "UInt64" ) return "TQ_UINT64"; + else if ( type == "IntList" ) return "const TQValueList &"; + else if ( type == "Enum" ) return "int"; + else if ( type == "Path" ) return "const TQString &"; + else if ( type == "PathList" ) return "const TQStringList &"; + else if ( type == "Password" ) return "const TQString &"; + else { + kdError() <<"tdeconfig_compiler does not support type \""<< type <<"\""<"; + else if ( type == "Enum" ) return "int"; + else if ( type == "Path" ) return TQSTRING_OBJECT_NAME_STRING; + else if ( type == "PathList" ) return TQSTRINGLIST_OBJECT_NAME_STRING; + else if ( type == "Password" ) return TQSTRING_OBJECT_NAME_STRING; + else { + kdError()<<"tdeconfig_compiler does not support type \""<< type <<"\""<()"; + else if ( type == "Enum" ) return "0"; + else if ( type == "Path" ) return "\"\""; // Use empty string, not null string! + else if ( type == "PathList" ) return "TQStringList()"; + else if ( type == "Password" ) return "\"\""; // Use empty string, not null string! + else { + kdWarning()<<"Error, tdeconfig_compiler doesn't support the \""<< type <<"\" type!"<name(); + fCap[0] = fCap[0].upper(); + return " TDEConfigSkeleton::Item"+itemType( e->type() ) + + " *item" + fCap + + ( (!e->param().isEmpty())?(TQString("[%1]").arg(e->paramMax()+1)) : TQString()) + + ";\n"; +} + +// returns the name of an item variable +// use itemPath to know the full path +// like using d-> in case of dpointer +static TQString itemVar(const CfgEntry *e) +{ + TQString result; + if (itemAccessors) + { + if ( !dpointer ) + { + result = "m" + e->name() + "Item"; + result[1] = result[1].upper(); + } + else + { + result = e->name() + "Item"; + result[0] = result[0].lower(); + } + } + else + { + result = "item" + e->name(); + result[4] = result[4].upper(); + } + return result; +} + +static TQString itemPath(const CfgEntry *e) +{ + TQString result; + if ( dpointer ) { + result = "d->"+itemVar(e); + } + else { + result = itemVar(e); + } + return result; +} + +TQString newItem( const TQString &type, const TQString &name, const TQString &key, + const TQString &defaultValue, const TQString ¶m = TQString()) +{ + TQString t = "new TDEConfigSkeleton::Item" + itemType( type ) + + "( currentGroup(), " + key + ", " + varPath( name ) + param; + if ( type == "Enum" ) t += ", values" + name; + if ( !defaultValue.isEmpty() ) { + t += ", "; + if ( type == "String" ) t += defaultValue; + else t+= defaultValue; + } + t += " );"; + + return t; +} + +TQString paramString(const TQString &s, const CfgEntry *e, int i) +{ + TQString result = s; + TQString needle = "$("+e->param()+")"; + if (result.contains(needle)) + { + TQString tmp; + if (e->paramType() == "Enum") + { + tmp = e->paramValues()[i]; + } + else + { + tmp = TQString::number(i); + } + + result.replace(needle, tmp); + } + return result; +} + +TQString paramString(const TQString &group, const TQValueList ¶meters) +{ + TQString paramString = group; + TQString arguments; + int i = 1; + for (TQValueList::ConstIterator it = parameters.begin(); + it != parameters.end(); ++it) + { + if (paramString.contains("$("+(*it).name+")")) + { + TQString tmp; + tmp.sprintf("%%%d", i++); + paramString.replace("$("+(*it).name+")", tmp); + arguments += ".arg( mParam"+(*it).name+" )"; + } + } + if (arguments.isEmpty()) + return "TQString::fromLatin1( \""+group+"\" )"; + + return "TQString::fromLatin1( \""+paramString+"\" )"+arguments; +} + +/* int i is the value of the parameter */ +TQString userTextsFunctions( CfgEntry *e, TQString itemVarStr=TQString(), TQString i=TQString() ) +{ + TQString txt; + if (itemVarStr.isNull()) itemVarStr=itemPath(e); + if ( !e->label().isEmpty() ) { + txt += " " + itemVarStr + "->setLabel( i18n("; + if ( !e->param().isEmpty() ) + txt += quoteString(e->label().replace("$("+e->param()+")", i)); + else + txt+= quoteString(e->label()); + txt+= ") );\n"; + } + if ( !e->whatsThis().isEmpty() ) { + txt += " " + itemVarStr + "->setWhatsThis( i18n("; + if ( !e->param().isEmpty() ) + txt += quoteString(e->whatsThis().replace("$("+e->param()+")", i)); + else + txt+= quoteString(e->whatsThis()); + txt+=") );\n"; + } + return txt; +} + +// returns the member accesor implementation +// which should go in the h file if inline +// or the cpp file if not inline +TQString memberAccessorBody( CfgEntry *e ) +{ + TQString result; + TQTextStream out(&result, IO_WriteOnly); + TQString n = e->name(); + TQString t = e->type(); + + out << "return " << This << varPath(n); + if (!e->param().isEmpty()) out << "[i]"; + out << ";" << endl; + + return result; +} + +// returns the member mutator implementation +// which should go in the h file if inline +// or the cpp file if not inline +TQString memberMutatorBody( CfgEntry *e ) +{ + TQString result; + TQTextStream out(&result, IO_WriteOnly); + TQString n = e->name(); + TQString t = e->type(); + + if (!e->minValue().isEmpty()) + { + out << "if (v < " << e->minValue() << ")" << endl; + out << "{" << endl; + out << " kdDebug() << \"" << setFunction(n); + out << ": value \" << v << \" is less than the minimum value of "; + out << e->minValue()<< "\" << endl;" << endl; + out << " v = " << e->minValue() << ";" << endl; + out << "}" << endl; + } + + if (!e->maxValue().isEmpty()) + { + out << endl << "if (v > " << e->maxValue() << ")" << endl; + out << "{" << endl; + out << " kdDebug() << \"" << setFunction(n); + out << ": value \" << v << \" is greater than the maximum value of "; + out << e->maxValue()<< "\" << endl;" << endl; + out << " v = " << e->maxValue() << ";" << endl; + out << "}" << endl << endl; + } + + out << "if (!" << This << "isImmutable( TQString::fromLatin1( \""; + if (!e->param().isEmpty()) + { + out << e->paramName().replace("$("+e->param()+")", "%1") << "\" ).arg( "; + if ( e->paramType() == "Enum" ) { + out << "TQString::fromLatin1( "; + + if (globalEnums) + out << enumName(e->param()) << "ToString[i]"; + else + out << enumName(e->param()) << "::enumToString[i]"; + + out << " )"; + } + else + { + out << "i"; + } + out << " )"; + } + else + { + out << n << "\" )"; + } + out << " ))" << endl; + out << " " << This << varPath(n); + if (!e->param().isEmpty()) + out << "[i]"; + out << " = v;" << endl; + + return result; +} + +// returns the item accesor implementation +// which should go in the h file if inline +// or the cpp file if not inline +TQString itemAccessorBody( CfgEntry *e ) +{ + TQString result; + TQTextStream out(&result, IO_WriteOnly); + + out << "return " << itemPath(e); + if (!e->param().isEmpty()) out << "[i]"; + out << ";" << endl; + + return result; +} + +//indents text adding X spaces per line +TQString indent(TQString text, int spaces) +{ + TQString result; + TQTextStream out(&result, IO_WriteOnly); + TQTextStream in(&text, IO_ReadOnly); + TQString currLine; + while ( !in.atEnd() ) + { + currLine = in.readLine(); + if (!currLine.isEmpty()) + for (int i=0; i < spaces; i++) + out << " "; + out << currLine << endl; + } + return result; +} + + +int main( int argc, char **argv ) +{ + TDEAboutData aboutData( "tdeconfig_compiler", I18N_NOOP("TDE .kcfg compiler"), "0.3", + I18N_NOOP("TDEConfig Compiler") , TDEAboutData::License_LGPL ); + aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" ); + aboutData.addAuthor( "Waldo Bastian", 0, "bastian@kde.org" ); + aboutData.addAuthor( "Zack Rusin", 0, "zack@kde.org" ); + aboutData.addCredit( "Reinhold Kainhofer", "Fix for parametrized entries", + "reinhold@kainhofer.com", "http://reinhold.kainhofer.com" ); + aboutData.addCredit( "Duncan Mac-Vicar P.", "dpointer support", + "duncan@kde.org", "http://www.mac-vicar.com/~duncan" ); + + TDECmdLineArgs::init( argc, argv, &aboutData ); + TDECmdLineArgs::addCmdLineOptions( options ); + + TDEInstance app( &aboutData ); + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + + if ( args->count() < 2 ) { + kdError() << "Too few arguments." << endl; + return 1; + } + if ( args->count() > 2 ) { + kdError() << "Too many arguments." << endl; + return 1; + } + + validNameRegexp = new TQRegExp("[a-zA-Z_][a-zA-Z0-9_]*"); + + TQString baseDir = TQFile::decodeName(args->getOption("directory")); + if (!baseDir.endsWith("/")) + baseDir.append("/"); + + TQString inputFilename = args->url( 0 ).path(); + TQString codegenFilename = args->url( 1 ).path(); + + if (!codegenFilename.endsWith(".kcfgc")) + { + kdError() << "Codegen options file must have extension .kcfgc" << endl; + return 1; + } + TQString baseName = args->url( 1 ).fileName(); + baseName = baseName.left(baseName.length() - 6); + + KSimpleConfig codegenConfig( codegenFilename, true ); + + TQString nameSpace = codegenConfig.readEntry("NameSpace"); + TQString className = codegenConfig.readEntry("ClassName"); + TQString inherits = codegenConfig.readEntry("Inherits"); + TQString visibility = codegenConfig.readEntry("Visibility"); + if (!visibility.isEmpty()) visibility+=" "; + bool singleton = codegenConfig.readBoolEntry("Singleton", false); + bool staticAccessors = singleton; + //bool useDPointer = codegenConfig.readBoolEntry("DPointer", false); + bool customAddons = codegenConfig.readBoolEntry("CustomAdditions"); + TQString memberVariables = codegenConfig.readEntry("MemberVariables"); + TQStringList headerIncludes = codegenConfig.readListEntry("IncludeFiles"); + TQStringList mutators = codegenConfig.readListEntry("Mutators"); + bool allMutators = false; + if ((mutators.count() == 1) && (mutators[0].lower() == "true")) + allMutators = true; + itemAccessors = codegenConfig.readBoolEntry( "ItemAccessors", false ); + bool setUserTexts = codegenConfig.readBoolEntry( "SetUserTexts", false ); + + globalEnums = codegenConfig.readBoolEntry( "GlobalEnums", false ); + + dpointer = (memberVariables == "dpointer"); + + TQFile input( inputFilename ); + + TQDomDocument doc; + TQString errorMsg; + int errorRow; + int errorCol; + if ( !doc.setContent( &input, &errorMsg, &errorRow, &errorCol ) ) { + kdError() << "Unable to load document." << endl; + kdError() << "Parse error in " << args->url( 0 ).fileName() << ", line " << errorRow << ", col " << errorCol << ": " << errorMsg << endl; + return 1; + } + + TQDomElement cfgElement = doc.documentElement(); + + if ( cfgElement.isNull() ) { + kdError() << "No document in kcfg file" << endl; + return 1; + } + + TQString cfgFileName; + bool cfgFileNameArg = false; + TQValueList parameters; + TQStringList includes; + + TQPtrList entries; + entries.setAutoDelete( true ); + + TQDomNode n; + for ( n = cfgElement.firstChild(); !n.isNull(); n = n.nextSibling() ) { + TQDomElement e = n.toElement(); + + TQString tag = e.tagName(); + + if ( tag == "include" ) { + TQString includeFile = e.text(); + if (!includeFile.isEmpty()) + includes.append(includeFile); + + } else if ( tag == "kcfgfile" ) { + cfgFileName = e.attribute( "name" ); + cfgFileNameArg = e.attribute( "arg" ).lower() == "true"; + TQDomNode n2; + for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { + TQDomElement e2 = n2.toElement(); + if ( e2.tagName() == "parameter" ) { + Param p; + p.name = e2.attribute( "name" ); + p.type = e2.attribute( "type" ); + if (p.type.isEmpty()) + p.type = "String"; + parameters.append( p ); + } + } + + } else if ( tag == "group" ) { + TQString group = e.attribute( "name" ); + if ( group.isEmpty() ) { + kdError() << "Group without name" << endl; + return 1; + } + TQDomNode n2; + for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { + TQDomElement e2 = n2.toElement(); + if ( e2.tagName() != "entry" ) continue; + CfgEntry *entry = parseEntry( group, e2 ); + if ( entry ) entries.append( entry ); + else { + kdError() << "Can't parse entry." << endl; + return 1; + } + } + } + } + + if ( inherits.isEmpty() ) inherits = "TDEConfigSkeleton"; + + if ( className.isEmpty() ) { + kdError() << "Class name missing" << endl; + return 1; + } + + if ( singleton && !parameters.isEmpty() ) { + kdError() << "Singleton class can not have parameters" << endl; + return 1; + } + + if ( !cfgFileName.isEmpty() && cfgFileNameArg) + { + kdError() << "Having both a fixed filename and a filename as argument is not possible." << endl; + return 1; + } + + if ( entries.isEmpty() ) { + kdWarning() << "No entries." << endl; + } + +#if 0 + CfgEntry *cfg; + for( cfg = entries.first(); cfg; cfg = entries.next() ) { + cfg->dump(); + } +#endif + + TQString headerFileName = baseName + ".h"; + TQString implementationFileName = baseName + ".cpp"; + TQString cppPreamble; // code to be inserted at the beginnin of the cpp file, e.g. initialization of static values + + TQFile header( baseDir + headerFileName ); + if ( !header.open( IO_WriteOnly ) ) { + kdError() << "Can't open '" << headerFileName << "' for writing." << endl; + return 1; + } + + TQTextStream h( &header ); + + h << "// This file is generated by tdeconfig_compiler from " << args->url(0).fileName() << "." << endl; + h << "// All changes you do to this file will be lost." << endl; + + h << "#ifndef " << ( !nameSpace.isEmpty() ? nameSpace.upper() + "_" : "" ) + << className.upper() << "_H" << endl; + h << "#define " << ( !nameSpace.isEmpty() ? nameSpace.upper() + "_" : "" ) + << className.upper() << "_H" << endl << endl; + + // Includes + TQStringList::ConstIterator it; + for( it = headerIncludes.begin(); it != headerIncludes.end(); ++it ) { + h << "#include <" << *it << ">" << endl; + } + + if ( headerIncludes.count() > 0 ) h << endl; + + if ( !singleton && cfgFileNameArg && parameters.isEmpty() ) + h << "#include " << endl; + + h << "#include " << endl; + h << "#include " << endl << endl; + + // Includes + for( it = includes.begin(); it != includes.end(); ++it ) { + h << "#include <" << *it << ">" << endl; + } + + + if ( !nameSpace.isEmpty() ) + h << "namespace " << nameSpace << " {" << endl << endl; + + // Private class declaration + if ( dpointer ) + h << "class " << className << "Private;" << endl << endl; + + // Class declaration header + h << "class " << visibility << className << " : public " << inherits << endl; + h << "{" << endl; + h << " public:" << endl; + + // enums + CfgEntry *e; + for( e = entries.first(); e; e = entries.next() ) { + TQValueList choices = e->choices(); + if ( !choices.isEmpty() ) { + TQStringList values; + TQValueList::ConstIterator itChoice; + for( itChoice = choices.begin(); itChoice != choices.end(); ++itChoice ) { + values.append( (*itChoice).name ); + } + if ( globalEnums ) { + h << " enum { " << values.join( ", " ) << " };" << endl; + } else { + h << " class " << enumName(e->name()) << endl; + h << " {" << endl; + h << " public:" << endl; + h << " enum type { " << values.join( ", " ) << ", COUNT };" << endl; + h << " };" << endl; + } + } + TQStringList values = e->paramValues(); + if ( !values.isEmpty() ) { + if ( globalEnums ) { + h << " enum { " << values.join( ", " ) << " };" << endl; + h << " static const char* const " << enumName(e->param()) << "ToString[];" << endl; + cppPreamble += "const char* const " + className + "::" + enumName(e->param()) + "ToString[] = " + + "{ \"" + values.join( "\", \"" ) + "\" };\n"; + } else { + h << " class " << enumName(e->param()) << endl; + h << " {" << endl; + h << " public:" << endl; + h << " enum type { " << values.join( ", " ) << ", COUNT };" << endl; + h << " static const char* const enumToString[];" << endl; + h << " };" << endl; + cppPreamble += "const char* const " + className + "::" + enumName(e->param()) + "::enumToString[] = " + + "{ \"" + values.join( "\", \"" ) + "\" };\n"; + } + } + } + + h << endl; + + // Constructor or singleton accessor + if ( !singleton ) { + h << " " << className << "("; + if (cfgFileNameArg) + h << " KSharedConfig::Ptr config" << (parameters.isEmpty() ? " = TDEGlobal::sharedConfig()" : ", "); + for (TQValueList::ConstIterator it = parameters.begin(); + it != parameters.end(); ++it) + { + if (it != parameters.begin()) + h << ","; + h << " " << param((*it).type) << " " << (*it).name; + } + h << " );" << endl; + } else { + h << " static " << className << " *self();" << endl; + if (cfgFileNameArg) + h << " static void instance(const char * cfgfilename);" << endl; + } + + // Destructor + h << " ~" << className << "();" << endl << endl; + + // global variables + if (staticAccessors) + This = "self()->"; + else + Const = " const"; + + for( e = entries.first(); e; e = entries.next() ) { + TQString n = e->name(); + TQString t = e->type(); + + // Manipulator + if (allMutators || mutators.contains(n)) + { + h << " /**" << endl; + h << " Set " << e->label() << endl; + h << " */" << endl; + if (staticAccessors) + h << " static" << endl; + h << " void " << setFunction(n) << "( "; + if (!e->param().isEmpty()) + h << cppType(e->paramType()) << " i, "; + h << param( t ) << " v )"; + // function body inline only if not using dpointer + // for BC mode + if ( !dpointer ) + { + h << endl << " {" << endl; + h << indent(memberMutatorBody(e), 6 ); + h << " }" << endl; + } + else + { + h << ";" << endl; + } + } + h << endl; + // Accessor + h << " /**" << endl; + h << " Get " << e->label() << endl; + h << " */" << endl; + if (staticAccessors) + h << " static" << endl; + h << " " << cppType(t) << " " << getFunction(n) << "("; + if (!e->param().isEmpty()) + h << " " << cppType(e->paramType()) <<" i "; + h << ")" << Const; + // function body inline only if not using dpointer + // for BC mode + if ( !dpointer ) + { + h << endl << " {" << endl; + h << indent(memberAccessorBody(e), 6 ); + h << " }" << endl; + } + else + { + h << ";" << endl; + } + + // Item accessor + if ( itemAccessors ) { + h << endl; + h << " /**" << endl; + h << " Get Item object corresponding to " << n << "()" + << endl; + h << " */" << endl; + h << " Item" << itemType( e->type() ) << " *" + << getFunction( n ) << "Item("; + if (!e->param().isEmpty()) { + h << " " << cppType(e->paramType()) << " i "; + } + h << ")"; + if (! dpointer ) + { + h << endl << " {" << endl; + h << indent( itemAccessorBody(e), 6); + h << " }" << endl; + } + else + { + h << ";" << endl; + } + } + + h << endl; + } + + // Static writeConfig method for singleton + if ( singleton ) { + h << " static" << endl; + h << " void writeConfig()" << endl; + h << " {" << endl; + h << " static_cast(self())->writeConfig();" << endl; + h << " }" << endl; + } + + h << " protected:" << endl; + + // Private constructor for singleton + if ( singleton ) { + h << " " << className << "("; + if ( cfgFileNameArg ) + h << "const char *arg"; + h << ");" << endl; + h << " static " << className << " *mSelf;" << endl << endl; + } + + // Member variables + if ( !memberVariables.isEmpty() && memberVariables != "private" && memberVariables != "dpointer") { + h << " " << memberVariables << ":" << endl; + } + + // Class Parameters + for (TQValueList::ConstIterator it = parameters.begin(); + it != parameters.end(); ++it) + { + h << " " << cppType((*it).type) << " mParam" << (*it).name << ";" << endl; + } + + if ( memberVariables != "dpointer" ) + { + TQString group; + for( e = entries.first(); e; e = entries.next() ) { + if ( e->group() != group ) { + group = e->group(); + h << endl; + h << " // " << group << endl; + } + h << " " << cppType(e->type()) << " " << varName(e->name()); + if (!e->param().isEmpty()) + { + h << TQString("[%1]").arg(e->paramMax()+1); + } + h << ";" << endl; + } + + h << endl << " private:" << endl; + if ( itemAccessors ) { + for( e = entries.first(); e; e = entries.next() ) { + h << " Item" << itemType( e->type() ) << " *" << itemVar( e ); + if (!e->param().isEmpty() ) h << TQString("[%1]").arg( e->paramMax()+1 ); + h << ";" << endl; + } + } + + } + else + { + // use a private class for both member variables and items + h << " private:" << endl; + h << " " + className + "Private *d;" << endl; + } + + if (customAddons) + { + h << " // Include custom additions" << endl; + h << " #include \"" << filenameOnly(baseName) << "_addons.h\"" <url(0).fileName() << "." << endl; + cpp << "// All changes you do to this file will be lost." << endl << endl; + + cpp << "#include \"" << headerFileName << "\"" << endl << endl; + + if ( setUserTexts ) cpp << "#include " << endl << endl; + + // Header required by singleton implementation + if ( singleton ) + cpp << "#include " << endl << endl; + if ( singleton && cfgFileNameArg ) + cpp << "#include " << endl << endl; + + if ( !nameSpace.isEmpty() ) + cpp << "using namespace " << nameSpace << ";" << endl << endl; + + TQString group; + + // private class implementation + if ( dpointer ) + { + cpp << "class " << className << "Private" << endl; + cpp << "{" << endl; + cpp << " public:" << endl; + for( e = entries.first(); e; e = entries.next() ) { + if ( e->group() != group ) { + group = e->group(); + cpp << endl; + cpp << " // " << group << endl; + } + cpp << " " << cppType(e->type()) << " " << varName(e->name()); + if (!e->param().isEmpty()) + { + cpp << TQString("[%1]").arg(e->paramMax()+1); + } + cpp << ";" << endl; + } + cpp << endl << " // items" << endl; + for( e = entries.first(); e; e = entries.next() ) { + cpp << " TDEConfigSkeleton::Item" << itemType( e->type() ) << " *" << itemVar( e ); + if (!e->param().isEmpty() ) cpp << TQString("[%1]").arg( e->paramMax()+1 ); + cpp << ";" << endl; + } + + cpp << "};" << endl << endl; + } + + // Singleton implementation + if ( singleton ) { + cpp << className << " *" << className << "::mSelf = 0;" << endl; + cpp << "static KStaticDeleter<" << className << "> static" << className << "Deleter;" << endl << endl; + + cpp << className << " *" << className << "::self()" << endl; + cpp << "{" << endl; + if ( cfgFileNameArg ) { + cpp << " if (!mSelf)" << endl; + cpp << " kdFatal() << \"you need to call " << className << "::instance before using\" << endl;" << endl; + } else { + cpp << " if ( !mSelf ) {" << endl; + cpp << " static" << className << "Deleter.setObject( mSelf, new " << className << "() );" << endl; + cpp << " mSelf->readConfig();" << endl; + cpp << " }" << endl << endl; + } + cpp << " return mSelf;" << endl; + cpp << "}" << endl << endl; + + if ( cfgFileNameArg ) { + cpp << "void " << className << "::instance(const char *cfgfilename)" << endl; + cpp << "{" << endl; + cpp << " if (mSelf) {" << endl; + cpp << " kdError() << \"" << className << "::instance called after the first use - ignoring\" << endl;" << endl; + cpp << " return;" << endl; + cpp << " }" << endl; + cpp << " static" << className << "Deleter.setObject( mSelf, new " << className << "(cfgfilename) );" << endl; + cpp << " mSelf->readConfig();" << endl; + cpp << "}" << endl << endl; + } + } + + if ( !cppPreamble.isEmpty() ) + cpp << cppPreamble << endl; + + // Constructor + cpp << className << "::" << className << "( "; + if ( cfgFileNameArg ) { + if ( !singleton ) + cpp << " KSharedConfig::Ptr config"; + else + cpp << " const char *config"; + cpp << (parameters.isEmpty() ? " " : ", "); + } + + for (TQValueList::ConstIterator it = parameters.begin(); + it != parameters.end(); ++it) + { + if (it != parameters.begin()) + cpp << ","; + cpp << " " << param((*it).type) << " " << (*it).name; + } + cpp << " )" << endl; + + cpp << " : " << inherits << "("; + if ( !cfgFileName.isEmpty() ) cpp << " TQString::fromLatin1( \"" << cfgFileName << "\" "; + if ( cfgFileNameArg ) cpp << " config "; + if ( !cfgFileName.isEmpty() ) cpp << ") "; + cpp << ")" << endl; + + // Store parameters + for (TQValueList::ConstIterator it = parameters.begin(); + it != parameters.end(); ++it) + { + cpp << " , mParam" << (*it).name << "(" << (*it).name << ")" << endl; + } + + cpp << "{" << endl; + + if (dpointer) + cpp << " d = new " + className + "Private;" << endl; + // Needed in case the singleton class is used as baseclass for + // another singleton. + if ( singleton ) + cpp << " mSelf = this;" << endl; + + group = TQString(); + for( e = entries.first(); e; e = entries.next() ) { + if ( e->group() != group ) { + if ( !group.isEmpty() ) cpp << endl; + group = e->group(); + cpp << " setCurrentGroup( " << paramString(group, parameters) << " );" << endl << endl; + } + + TQString key = paramString(e->key(), parameters); + if ( !e->code().isEmpty()) + { + cpp << e->code() << endl; + } + if ( e->type() == "Enum" ) { + cpp << " TQValueList values" + << e->name() << ";" << endl; + TQValueList choices = e->choices(); + TQValueList::ConstIterator it; + for( it = choices.begin(); it != choices.end(); ++it ) { + cpp << " {" << endl; + cpp << " TDEConfigSkeleton::ItemEnum::Choice choice;" << endl; + cpp << " choice.name = TQString::fromLatin1( \"" << (*it).name << "\" );" << endl; + if ( setUserTexts ) { + if ( !(*it).label.isEmpty() ) + cpp << " choice.label = i18n(" << quoteString((*it).label) << ");" << endl; + if ( !(*it).whatsThis.isEmpty() ) + cpp << " choice.whatsThis = i18n(" << quoteString((*it).whatsThis) << ");" << endl; + } + cpp << " values" << e->name() << ".append( choice );" << endl; + cpp << " }" << endl; + } + } + + if (!dpointer) + cpp << itemDeclaration(e); + + if (e->param().isEmpty()) + { + // Normal case + cpp << " " << itemPath(e) << " = " + << newItem( e->type(), e->name(), key, e->defaultValue() ) << endl; + + if ( !e->minValue().isEmpty() ) + cpp << " " << itemPath(e) << "->setMinValue(" << e->minValue() << ");" << endl; + if ( !e->maxValue().isEmpty() ) + cpp << " " << itemPath(e) << "->setMaxValue(" << e->maxValue() << ");" << endl; + + if ( setUserTexts ) + cpp << userTextsFunctions( e ); + + cpp << " addItem( " << itemPath(e); + TQString quotedName = e->name(); + addQuotes( quotedName ); + if ( quotedName != key ) cpp << ", TQString::fromLatin1( \"" << e->name() << "\" )"; + cpp << " );" << endl; + } + else + { + // Indexed + for(int i = 0; i <= e->paramMax(); i++) + { + TQString defaultStr; + TQString itemVarStr(itemPath(e)+TQString("[%1]").arg(i)); + + if ( !e->paramDefaultValue(i).isEmpty() ) + defaultStr = e->paramDefaultValue(i); + else if ( !e->defaultValue().isEmpty() ) + defaultStr = paramString(e->defaultValue(), e, i); + else + defaultStr = defaultValue( e->type() ); + + cpp << " " << itemVarStr << " = " + << newItem( e->type(), e->name(), paramString(key, e, i), defaultStr, TQString("[%1]").arg(i) ) + << endl; + + if ( setUserTexts ) + cpp << userTextsFunctions( e, itemVarStr, e->paramName() ); + + // Make mutators for enum parameters work by adding them with $(..) replaced by the + // param name. The check for isImmutable in the set* functions doesn't have the param + // name available, just the corresponding enum value (int), so we need to store the + // param names in a separate static list!. + cpp << " addItem( " << itemVarStr << ", TQString::fromLatin1( \""; + if ( e->paramType()=="Enum" ) + cpp << e->paramName().replace( "$("+e->param()+")", "%1").arg(e->paramValues()[i] ); + else + cpp << e->paramName().replace( "$("+e->param()+")", "%1").arg(i); + cpp << "\" ) );" << endl; + } + } + } + + cpp << "}" << endl << endl; + + if (dpointer) + { + // setters and getters go in Cpp if in dpointer mode + for( e = entries.first(); e; e = entries.next() ) + { + TQString n = e->name(); + TQString t = e->type(); + + // Manipulator + if (allMutators || mutators.contains(n)) + { + cpp << "void " << setFunction(n, className) << "( "; + if (!e->param().isEmpty()) + cpp << cppType(e->paramType()) << " i, "; + cpp << param( t ) << " v )" << endl; + // function body inline only if not using dpointer + // for BC mode + cpp << "{" << endl; + cpp << indent(memberMutatorBody(e), 6); + cpp << "}" << endl << endl; + } + + // Accessor + cpp << cppType(t) << " " << getFunction(n, className) << "("; + if (!e->param().isEmpty()) + cpp << " " << cppType(e->paramType()) <<" i "; + cpp << ")" << Const << endl; + // function body inline only if not using dpointer + // for BC mode + cpp << "{" << endl; + cpp << indent(memberAccessorBody(e), 2); + cpp << "}" << endl << endl; + + // Item accessor + if ( itemAccessors ) + { + cpp << endl; + cpp << "TDEConfigSkeleton::Item" << itemType( e->type() ) << " *" + << getFunction( n, className ) << "Item("; + if (!e->param().isEmpty()) { + cpp << " " << cppType(e->paramType()) << " i "; + } + cpp << ")" << endl; + cpp << "{" << endl; + cpp << indent(itemAccessorBody(e), 2); + cpp << "}" << endl; + } + + cpp << endl; + } + } + + // Destructor + cpp << className << "::~" << className << "()" << endl; + cpp << "{" << endl; + if ( singleton ) { + if ( dpointer ) + cpp << " delete d;" << endl; + cpp << " if ( mSelf == this )" << endl; + cpp << " static" << className << "Deleter.setObject( mSelf, 0, false );" << endl; + } + cpp << "}" << endl << endl; + + implementation.close(); +} diff --git a/tdecore/tdeconfig_compiler/tests/Makefile.am b/tdecore/tdeconfig_compiler/tests/Makefile.am new file mode 100644 index 000000000..fa88f0b4b --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/Makefile.am @@ -0,0 +1,134 @@ +AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir)/tdeunittest $(all_includes) -DQT_NO_CAST_ASCII -DSRCDIR=\"$(srcdir)\" + +check_PROGRAMS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test_dpointer + +CLEANFILES = test1.cpp test1.h \ + test2.cpp test2.h \ + test3.cpp test3.h \ + test4.cpp test4.h \ + test5.cpp test5.h \ + test6.cpp test6.h \ + test7.cpp test7.h \ + test8a.cpp test8a.h test8b.cpp test8b.h \ + test9.cpp test9.h \ + test_dpointer.cpp test_dpointer.h \ + md5sums + +test1_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +test1_LDADD = $(LIB_TDECORE) +test1_SOURCES = test1main.cpp test1.cpp + +test2_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +test2_LDADD = $(LIB_TDECORE) +test2_SOURCES = test2main.cpp test2.cpp + +test3_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +test3_LDADD = $(LIB_TDECORE) +test3_SOURCES = test3main.cpp test3.cpp + +test4_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +test4_LDADD = $(LIB_TDECORE) +test4_SOURCES = test4main.cpp test4.cpp + +test5_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +test5_LDADD = $(LIB_TDECORE) +test5_SOURCES = test5main.cpp test5.cpp + +test6_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +test6_LDADD = $(LIB_TDECORE) +test6_SOURCES = test6main.cpp test6.cpp + +test7_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +test7_LDADD = $(LIB_TDECORE) +test7_SOURCES = test7main.cpp test7.cpp + +test8_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +test8_LDADD = $(LIB_TDECORE) +test8_SOURCES = test8main.cpp test8a.cpp test8b.cpp + +test9_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +test9_LDADD = $(LIB_TDECORE) +test9_SOURCES = test9main.cpp test9.cpp + +test_dpointer_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +test_dpointer_LDADD = $(LIB_TDECORE) +test_dpointer_SOURCES = test_dpointer_main.cpp test_dpointer.cpp + +check_LTLIBRARIES = tdeunittest_tdeconfigcompiler_test.la + +tdeunittest_tdeconfigcompiler_test_la_SOURCES = tdeconfigcompiler_test.cpp +tdeunittest_tdeconfigcompiler_test_la_LIBADD = \ + $(top_builddir)/tdeunittest/libtdeunittest.la +tdeunittest_tdeconfigcompiler_test_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) \ + $(all_libraries) + + +test1main.o test1.o: test1.h +# avoid running the below command in parallel +test1.cpp: test1.h +test1.cpp test1.h: $(srcdir)/test1.kcfg ../tdeconfig_compiler $(srcdir)/test1.kcfgc + ../tdeconfig_compiler $(srcdir)/test1.kcfg $(srcdir)/test1.kcfgc + +test2main.o test2.o: test2.h +# avoid running the below command in parallel +test2.cpp: test2.h +test2.cpp test2.h: $(srcdir)/test2.kcfg ../tdeconfig_compiler $(srcdir)/test2.kcfgc + ../tdeconfig_compiler $(srcdir)/test2.kcfg $(srcdir)/test2.kcfgc + +test3main.o test3.o: test3.h +# avoid running the below command in parallel +test3.cpp: test3.h +test3.cpp test3.h: $(srcdir)/test3.kcfg ../tdeconfig_compiler $(srcdir)/test3.kcfgc + ../tdeconfig_compiler $(srcdir)/test3.kcfg $(srcdir)/test3.kcfgc + +test4main.o test4.o: test4.h +# avoid running the below command in parallel +test4.cpp: test4.h +test4.cpp test4.h: $(srcdir)/test4.kcfg ../tdeconfig_compiler $(srcdir)/test4.kcfgc + ../tdeconfig_compiler $(srcdir)/test4.kcfg $(srcdir)/test4.kcfgc + +test5main.o test5.o: test5.h +# avoid running the below command in parallel +test5.cpp: test5.h +test5.cpp test5.h: $(srcdir)/test5.kcfg ../tdeconfig_compiler $(srcdir)/test5.kcfgc + ../tdeconfig_compiler $(srcdir)/test5.kcfg $(srcdir)/test5.kcfgc + +test6main.o test6.o: test6.h +# avoid running the below command in parallel +test6.cpp: test6.h +test6.cpp test6.h: $(srcdir)/test6.kcfg ../tdeconfig_compiler $(srcdir)/test6.kcfgc + ../tdeconfig_compiler $(srcdir)/test6.kcfg $(srcdir)/test6.kcfgc + +test7main.o test7.o: test7.h +# avoid running the below command in parallel +test7.cpp: test7.h +test7.cpp test7.h: $(srcdir)/test7.kcfg ../tdeconfig_compiler $(srcdir)/test7.kcfgc + ../tdeconfig_compiler $(srcdir)/test7.kcfg $(srcdir)/test7.kcfgc + +test8main.o test8a.o test8b.o: test8a.h test8b.h +# avoid running the below command in parallel +test8a.cpp: test8a.h +test8a.cpp test8a.h: $(srcdir)/test8a.kcfg ../tdeconfig_compiler $(srcdir)/test8a.kcfgc + ../tdeconfig_compiler $(srcdir)/test8a.kcfg $(srcdir)/test8a.kcfgc +test8b.cpp: test8b.h +test8b.cpp test8b.h: $(srcdir)/test8b.kcfg ../tdeconfig_compiler $(srcdir)/test8b.kcfgc + ../tdeconfig_compiler $(srcdir)/test8b.kcfg $(srcdir)/test8b.kcfgc + +test9main.o test9.o: test9.h +# avoid running the below command in parallel +test9.cpp: test9.h +test9.cpp test9.h: $(srcdir)/test9.kcfg ../tdeconfig_compiler $(srcdir)/test9.kcfgc + ../tdeconfig_compiler $(srcdir)/test9.kcfg $(srcdir)/test9.kcfgc + +test_dpointer_main.o test_dpointer.o: test_dpointer.h +# avoid running the below command in parallel +test_dpointer.cpp: test_dpointer.h +test_dpointer.cpp test_dpointer.h: $(srcdir)/test_dpointer.kcfg ../tdeconfig_compiler $(srcdir)/test_dpointer.kcfgc + ../tdeconfig_compiler $(srcdir)/test_dpointer.kcfg $(srcdir)/test_dpointer.kcfgc + +md5sums: + $(MD5SUM) $(srcdir)/test*.ref | sed -e "s,$(srcdir)/,,; s,\.ref$$,," > md5sums + +md5check: test1.cpp test2.cpp test3.cpp test4.cpp test5.cpp test6.cpp test7.cpp test8a.cpp test8b.cpp test9.cpp md5sums + $(MD5SUM) -c md5sums + diff --git a/tdecore/tdeconfig_compiler/tests/myprefs.h b/tdecore/tdeconfig_compiler/tests/myprefs.h new file mode 100644 index 000000000..99ea62ec1 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/myprefs.h @@ -0,0 +1,7 @@ +#include + +class MyPrefs : public TDEConfigSkeleton +{ + public: + MyPrefs( const TQString &a ) : TDEConfigSkeleton( a ) {} +}; diff --git a/tdecore/tdeconfig_compiler/tests/tdeconfigcompiler_test.cpp b/tdecore/tdeconfig_compiler/tests/tdeconfigcompiler_test.cpp new file mode 100644 index 000000000..e5bb3dcea --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/tdeconfigcompiler_test.cpp @@ -0,0 +1,96 @@ +/* + Tests for TDEConfig Compiler + + Copyright (c) 2005 by Duncan Mac-Vicar + + ************************************************************************* + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + ************************************************************************* +*/ + +#include +#include +#include +#include +#include "tdeconfigcompiler_test.h" + +using namespace KUnitTest; + +KUNITTEST_MODULE( tdeunittest_tdeconfigcompiler_test, "TDEConfigXT") +KUNITTEST_MODULE_REGISTER_TESTER( TDEConfigCompiler_Test ) + +typedef const char * CompilerTestSet[]; + +static CompilerTestSet testCases = +{ + "test1.cpp", "test1.h", + "test2.cpp", "test2.h", + "test3.cpp", "test3.h", + "test4.cpp", "test4.h", + "test5.cpp", "test5.h", + "test6.cpp", "test6.h", + "test7.cpp", "test7.h", + "test8a.cpp", "test8a.h", + "test8b.cpp", "test8b.h", + "test9.h", "test9.cpp", + "test_dpointer.cpp", "test_dpointer.h", + NULL +}; + +static CompilerTestSet willFailCases = +{ + // where is that TQDir comming from? + //"test9.cpp", NULL + NULL +}; + + +void TDEConfigCompiler_Test::allTests() +{ + testExpectedOutput(); +} + +void TDEConfigCompiler_Test::testExpectedOutput() +{ + uint i = 0; + // Known to pass test cases + while (testCases[ i ]) + { + performCompare(TQString::fromLatin1(testCases[ i ])); + ++i; + } + + // broken test cases + i= 0; + while (willFailCases[ i ]) + { + performCompare(TQString::fromLatin1(willFailCases[ i ]), true); + ++i; + } +} + +void TDEConfigCompiler_Test::performCompare(const TQString &fileName, bool fail) +{ + TQFile file(fileName); + TQFile fileRef(TQString::fromLatin1(SRCDIR) + TQString::fromLatin1("/") + fileName + TQString::fromLatin1(".ref")); + + if ( file.open(IO_ReadOnly) && fileRef.open(IO_ReadOnly) ) + { + TQString content = file.readAll(); + TQString contentRef = fileRef.readAll(); + + if (!fail) + CHECK( content, contentRef); + else + XFAIL( content, contentRef); + } + else + { + SKIP("Can't open file for comparision"); + } +} diff --git a/tdecore/tdeconfig_compiler/tests/tdeconfigcompiler_test.h b/tdecore/tdeconfig_compiler/tests/tdeconfigcompiler_test.h new file mode 100644 index 000000000..df3f4cf37 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/tdeconfigcompiler_test.h @@ -0,0 +1,35 @@ +/* + Tests for TDEConfig Compiler + + Copyright (c) 2005 by Duncan Mac-Vicar + + ************************************************************************* + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + ************************************************************************* +*/ + +#ifndef KCONFIGCOMPILER_TEST_H +#define KCONFIGCOMPILER_TEST_H + +#include + +class TQString; + +// change to SlotTester when it works +class TDEConfigCompiler_Test : public KUnitTest::Tester +{ +public: + void allTests(); +public slots: + void testExpectedOutput(); +private: + void performCompare(const TQString &fileName, bool fail=false); +}; + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test1.cpp.ref b/tdecore/tdeconfig_compiler/tests/test1.cpp.ref new file mode 100644 index 000000000..50f084874 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test1.cpp.ref @@ -0,0 +1,72 @@ +// This file is generated by tdeconfig_compiler from test1.kcfg. +// All changes you do to this file will be lost. + +#include "test1.h" + +Test1::Test1( const TQString & transport, const TQString & folder ) + : TDEConfigSkeleton( TQString::fromLatin1( "examplerc" ) ) + , mParamtransport(transport) + , mParamfolder(folder) +{ + setCurrentGroup( TQString::fromLatin1( "General-%1" ).arg( mParamfolder ) ); + + TDEConfigSkeleton::ItemBool *itemOneOption; + itemOneOption = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "OneOption" ), mOneOption, true ); + addItem( itemOneOption, TQString::fromLatin1( "OneOption" ) ); + TDEConfigSkeleton::ItemInt *itemAnotherOption; + itemAnotherOption = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Another Option" ), mAnotherOption, 5 ); + addItem( itemAnotherOption, TQString::fromLatin1( "AnotherOption" ) ); + TQValueList valuesListOption; + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "One" ); + valuesListOption.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "Two" ); + valuesListOption.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "Three" ); + valuesListOption.append( choice ); + } + TDEConfigSkeleton::ItemEnum *itemListOption; + itemListOption = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "ListOption" ), mListOption, valuesListOption, EnumListOption::One ); + addItem( itemListOption, TQString::fromLatin1( "ListOption" ) ); + + setCurrentGroup( TQString::fromLatin1( "MyOptions" ) ); + + TDEConfigSkeleton::ItemString *itemMyString; + itemMyString = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "MyString" ), mMyString, TQString::fromLatin1( "Default String" ) ); + addItem( itemMyString, TQString::fromLatin1( "MyString" ) ); + TDEConfigSkeleton::ItemPath *itemMyPath; + itemMyPath = new TDEConfigSkeleton::ItemPath( currentGroup(), TQString::fromLatin1( "MyPath" ), mMyPath, TQDir::homeDirPath()+TQString::fromLatin1(".hidden_file") ); + addItem( itemMyPath, TQString::fromLatin1( "MyPath" ) ); + TDEConfigSkeleton::ItemInt *itemAnotherOption2; + itemAnotherOption2 = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Another Option" ), mAnotherOption2, 10 ); + addItem( itemAnotherOption2, TQString::fromLatin1( "AnotherOption2" ) ); + TQStringList defaultMyStringList; + defaultMyStringList.append( TQString::fromUtf8( "up" ) ); + defaultMyStringList.append( TQString::fromUtf8( "down" ) ); + + TDEConfigSkeleton::ItemStringList *itemMyStringList; + itemMyStringList = new TDEConfigSkeleton::ItemStringList( currentGroup(), TQString::fromLatin1( "MyStringList" ), mMyStringList, defaultMyStringList ); + addItem( itemMyStringList, TQString::fromLatin1( "MyStringList" ) ); + TQStringList defaultMyStringListHidden; + defaultMyStringListHidden.append( TQString::fromUtf8( "up" ) ); + defaultMyStringListHidden.append( TQString::fromUtf8( "down" ) ); + + TDEConfigSkeleton::ItemStringList *itemMyStringListHidden; + itemMyStringListHidden = new TDEConfigSkeleton::ItemStringList( currentGroup(), TQString::fromLatin1( "MyStringListHidden" ), mMyStringListHidden, defaultMyStringListHidden ); + addItem( itemMyStringListHidden, TQString::fromLatin1( "MyStringListHidden" ) ); + TDEConfigSkeleton::ItemInt *itemMyNumber; + itemMyNumber = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "List-%1-%2" ).arg( mParamtransport ).arg( mParamfolder ), mMyNumber, 1 ); + addItem( itemMyNumber, TQString::fromLatin1( "MyNumber" ) ); +} + +Test1::~Test1() +{ +} + diff --git a/tdecore/tdeconfig_compiler/tests/test1.h.ref b/tdecore/tdeconfig_compiler/tests/test1.h.ref new file mode 100644 index 000000000..bb74038a5 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test1.h.ref @@ -0,0 +1,196 @@ +// This file is generated by tdeconfig_compiler from test1.kcfg. +// All changes you do to this file will be lost. +#ifndef TEST1_H +#define TEST1_H + +#include +#include + +#include +class Test1 : public TDEConfigSkeleton +{ + public: + class EnumListOption + { + public: + enum type { One, Two, Three, COUNT }; + }; + + Test1( const TQString & transport, const TQString & folder ); + ~Test1(); + + /** + Set One option + */ + void setOneOption( bool v ) + { + if (!isImmutable( TQString::fromLatin1( "OneOption" ) )) + mOneOption = v; + } + + /** + Get One option + */ + bool oneOption() const + { + return mOneOption; + } + + /** + Set Another option + */ + void setAnotherOption( int v ) + { + if (!isImmutable( TQString::fromLatin1( "AnotherOption" ) )) + mAnotherOption = v; + } + + /** + Get Another option + */ + int anotherOption() const + { + return mAnotherOption; + } + + /** + Set This is some funky option + */ + void setListOption( int v ) + { + if (!isImmutable( TQString::fromLatin1( "ListOption" ) )) + mListOption = v; + } + + /** + Get This is some funky option + */ + int listOption() const + { + return mListOption; + } + + /** + Set This is a string + */ + void setMyString( const TQString & v ) + { + if (!isImmutable( TQString::fromLatin1( "MyString" ) )) + mMyString = v; + } + + /** + Get This is a string + */ + TQString myString() const + { + return mMyString; + } + + /** + Set This is a path + */ + void setMyPath( const TQString & v ) + { + if (!isImmutable( TQString::fromLatin1( "MyPath" ) )) + mMyPath = v; + } + + /** + Get This is a path + */ + TQString myPath() const + { + return mMyPath; + } + + /** + Set Another option + */ + void setAnotherOption2( int v ) + { + if (!isImmutable( TQString::fromLatin1( "AnotherOption2" ) )) + mAnotherOption2 = v; + } + + /** + Get Another option + */ + int anotherOption2() const + { + return mAnotherOption2; + } + + /** + Set MyStringList + */ + void setMyStringList( const TQStringList & v ) + { + if (!isImmutable( TQString::fromLatin1( "MyStringList" ) )) + mMyStringList = v; + } + + /** + Get MyStringList + */ + TQStringList myStringList() const + { + return mMyStringList; + } + + /** + Set MyStringListHidden + */ + void setMyStringListHidden( const TQStringList & v ) + { + if (!isImmutable( TQString::fromLatin1( "MyStringListHidden" ) )) + mMyStringListHidden = v; + } + + /** + Get MyStringListHidden + */ + TQStringList myStringListHidden() const + { + return mMyStringListHidden; + } + + /** + Set List Number + */ + void setMyNumber( int v ) + { + if (!isImmutable( TQString::fromLatin1( "MyNumber" ) )) + mMyNumber = v; + } + + /** + Get List Number + */ + int myNumber() const + { + return mMyNumber; + } + + protected: + TQString mParamtransport; + TQString mParamfolder; + + // General-$(folder) + bool mOneOption; + int mAnotherOption; + int mListOption; + + // MyOptions + TQString mMyString; + TQString mMyPath; + int mAnotherOption2; + TQStringList mMyStringList; + TQStringList mMyStringListHidden; + int mMyNumber; + + private: +}; + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test1.kcfg b/tdecore/tdeconfig_compiler/tests/test1.kcfg new file mode 100644 index 000000000..ce42aebfb --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test1.kcfg @@ -0,0 +1,55 @@ + + + qdir.h + + + + + + + + true + + + + 5 + + + + And this is a longer description of this option. Just wondering, how will the translations of those be handled? + + + + + + One + + + + + + Default String + + + + QDir::homeDirPath()+QString::fromLatin1(".hidden_file") + + + + 10 + + + up,down + + + + + 1 + + + diff --git a/tdecore/tdeconfig_compiler/tests/test1.kcfgc b/tdecore/tdeconfig_compiler/tests/test1.kcfgc new file mode 100644 index 000000000..dd086cdda --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test1.kcfgc @@ -0,0 +1,18 @@ +# Code generation options for tdeconfig_compiler +ClassName=Test1 +# +# Singleton=false +# +# Inherits=TDEConfigSkeleton +# +# IncludeFiles=libtdepim/kpimprefs.h +# +# MemberVariables=public +# +### The following line includes the file exampleprefs_base_addon.h +### It can be used to add extra functions and variables to the +### class. +# CustomAdditions=true +# +### Provide setFooBar(int) style functions +Mutators=true diff --git a/tdecore/tdeconfig_compiler/tests/test1main.cpp b/tdecore/tdeconfig_compiler/tests/test1main.cpp new file mode 100644 index 000000000..79546639f --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test1main.cpp @@ -0,0 +1,29 @@ +/* +Copyright (c) 2003 Cornelius Schumacher + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#include "test1.h" +#include "kinstance.h" + +int main( int, char*[] ) +{ + TDEInstance i("test"); + Test1 *t = new Test1( TQString::null, TQString::null ); + delete t; +} diff --git a/tdecore/tdeconfig_compiler/tests/test2.cpp.ref b/tdecore/tdeconfig_compiler/tests/test2.cpp.ref new file mode 100644 index 000000000..cc3f67b5e --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test2.cpp.ref @@ -0,0 +1,98 @@ +// This file is generated by tdeconfig_compiler from test2.kcfg. +// All changes you do to this file will be lost. + +#include "test2.h" + +#include + +Test2::Test2( ) + : MyPrefs( TQString::fromLatin1( "korganizerrc" ) ) +{ + setCurrentGroup( TQString::fromLatin1( "General" ) ); + + mAutoSaveItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "Auto Save" ), mAutoSave, false ); + mAutoSaveItem->setLabel( i18n("Enable automatic saving of calendar") ); + mAutoSaveItem->setWhatsThis( i18n("WhatsThis text for AutoSave option") ); + addItem( mAutoSaveItem, TQString::fromLatin1( "AutoSave" ) ); + mAutoSaveIntervalItem = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Auto Save Interval" ), mAutoSaveInterval, 10 ); + mAutoSaveIntervalItem->setLabel( i18n("Auto Save Interval") ); + addItem( mAutoSaveIntervalItem, TQString::fromLatin1( "AutoSaveInterval" ) ); + mConfirmItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "Confirm Deletes" ), mConfirm, true ); + mConfirmItem->setLabel( i18n("Confirm deletes") ); + addItem( mConfirmItem, TQString::fromLatin1( "Confirm" ) ); + mArchiveFileItem = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "Archive File" ), mArchiveFile ); + mArchiveFileItem->setLabel( i18n("Archive File") ); + addItem( mArchiveFileItem, TQString::fromLatin1( "ArchiveFile" ) ); + TQValueList valuesDestination; + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "standardDestination" ); + valuesDestination.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "askDestination" ); + valuesDestination.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "argl1" ); + choice.label = i18n("Argl1 Label"); + valuesDestination.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "argl2" ); + choice.whatsThis = i18n("Argl2 Whatsthis"); + valuesDestination.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "argl3" ); + choice.label = i18n("Argl3 Label"); + choice.whatsThis = i18n("Argl3 Whatsthis"); + valuesDestination.append( choice ); + } + mDestinationItem = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "Destination" ), mDestination, valuesDestination, standardDestination ); + mDestinationItem->setLabel( i18n("New Events/Todos Should") ); + addItem( mDestinationItem, TQString::fromLatin1( "Destination" ) ); + + setCurrentGroup( TQString::fromLatin1( "Views" ) ); + + mHourSizeItem = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Hour Size" ), mHourSize, 10 ); + mHourSizeItem->setLabel( i18n("Hour Size") ); + addItem( mHourSizeItem, TQString::fromLatin1( "HourSize" ) ); + mSelectionStartsEditorItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "SelectionStartsEditor" ), mSelectionStartsEditor, false ); + mSelectionStartsEditorItem->setLabel( i18n("Time range selection in agenda view starts event editor") ); + addItem( mSelectionStartsEditorItem, TQString::fromLatin1( "SelectionStartsEditor" ) ); + + setCurrentGroup( TQString::fromLatin1( "KOrganizer Plugins" ) ); + + TQStringList defaultSelectedPlugins; + defaultSelectedPlugins.append( TQString::fromUtf8( "holidays" ) ); + defaultSelectedPlugins.append( TQString::fromUtf8( "webexport" ) ); + + mSelectedPluginsItem = new TDEConfigSkeleton::ItemStringList( currentGroup(), TQString::fromLatin1( "SelectedPlugins" ), mSelectedPlugins, defaultSelectedPlugins ); + mSelectedPluginsItem->setLabel( i18n("SelectedPlugins") ); + addItem( mSelectedPluginsItem, TQString::fromLatin1( "SelectedPlugins" ) ); + + setCurrentGroup( TQString::fromLatin1( "Colors" ) ); + + mHighlightColorItem = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "Highlight Color" ), mHighlightColor, TQColor( 100, 100, 255 ) ); + mHighlightColorItem->setLabel( i18n("Highlight color") ); + addItem( mHighlightColorItem, TQString::fromLatin1( "HighlightColor" ) ); + mAgendaBgColorItem = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "Agenda Background Color" ), mAgendaBgColor, TQColor( 255, 255, 255 ) ); + mAgendaBgColorItem->setLabel( i18n("Agenda view background color") ); + addItem( mAgendaBgColorItem, TQString::fromLatin1( "AgendaBgColor" ) ); + + setCurrentGroup( TQString::fromLatin1( "Fonts" ) ); + + mTimeBarFontItem = new TDEConfigSkeleton::ItemFont( currentGroup(), TQString::fromLatin1( "TimeBar Font" ), mTimeBarFont ); + mTimeBarFontItem->setLabel( i18n("Time bar") ); + addItem( mTimeBarFontItem, TQString::fromLatin1( "TimeBarFont" ) ); +} + +Test2::~Test2() +{ +} + diff --git a/tdecore/tdeconfig_compiler/tests/test2.h.ref b/tdecore/tdeconfig_compiler/tests/test2.h.ref new file mode 100644 index 000000000..47895ccaf --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test2.h.ref @@ -0,0 +1,333 @@ +// This file is generated by tdeconfig_compiler from test2.kcfg. +// All changes you do to this file will be lost. +#ifndef TEST2_H +#define TEST2_H + +#include + +#include +#include + +class Test2 : public MyPrefs +{ + public: + enum { standardDestination, askDestination, argl1, argl2, argl3 }; + + Test2( ); + ~Test2(); + + /** + Set Enable automatic saving of calendar + */ + void setAutoSave( bool v ) + { + if (!isImmutable( TQString::fromLatin1( "AutoSave" ) )) + mAutoSave = v; + } + + /** + Get Enable automatic saving of calendar + */ + bool autoSave() const + { + return mAutoSave; + } + + /** + Get Item object corresponding to AutoSave() + */ + ItemBool *autoSaveItem() + { + return mAutoSaveItem; + } + + /** + Set Auto Save Interval + */ + void setAutoSaveInterval( int v ) + { + if (!isImmutable( TQString::fromLatin1( "AutoSaveInterval" ) )) + mAutoSaveInterval = v; + } + + /** + Get Auto Save Interval + */ + int autoSaveInterval() const + { + return mAutoSaveInterval; + } + + /** + Get Item object corresponding to AutoSaveInterval() + */ + ItemInt *autoSaveIntervalItem() + { + return mAutoSaveIntervalItem; + } + + /** + Set Confirm deletes + */ + void setConfirm( bool v ) + { + if (!isImmutable( TQString::fromLatin1( "Confirm" ) )) + mConfirm = v; + } + + /** + Get Confirm deletes + */ + bool confirm() const + { + return mConfirm; + } + + /** + Get Item object corresponding to Confirm() + */ + ItemBool *confirmItem() + { + return mConfirmItem; + } + + /** + Set Archive File + */ + void setArchiveFile( const TQString & v ) + { + if (!isImmutable( TQString::fromLatin1( "ArchiveFile" ) )) + mArchiveFile = v; + } + + /** + Get Archive File + */ + TQString archiveFile() const + { + return mArchiveFile; + } + + /** + Get Item object corresponding to ArchiveFile() + */ + ItemString *archiveFileItem() + { + return mArchiveFileItem; + } + + /** + Set New Events/Todos Should + */ + void setDestination( int v ) + { + if (!isImmutable( TQString::fromLatin1( "Destination" ) )) + mDestination = v; + } + + /** + Get New Events/Todos Should + */ + int destination() const + { + return mDestination; + } + + /** + Get Item object corresponding to Destination() + */ + ItemEnum *destinationItem() + { + return mDestinationItem; + } + + /** + Set Hour Size + */ + void setHourSize( int v ) + { + if (!isImmutable( TQString::fromLatin1( "HourSize" ) )) + mHourSize = v; + } + + /** + Get Hour Size + */ + int hourSize() const + { + return mHourSize; + } + + /** + Get Item object corresponding to HourSize() + */ + ItemInt *hourSizeItem() + { + return mHourSizeItem; + } + + /** + Set Time range selection in agenda view starts event editor + */ + void setSelectionStartsEditor( bool v ) + { + if (!isImmutable( TQString::fromLatin1( "SelectionStartsEditor" ) )) + mSelectionStartsEditor = v; + } + + /** + Get Time range selection in agenda view starts event editor + */ + bool selectionStartsEditor() const + { + return mSelectionStartsEditor; + } + + /** + Get Item object corresponding to SelectionStartsEditor() + */ + ItemBool *selectionStartsEditorItem() + { + return mSelectionStartsEditorItem; + } + + /** + Set SelectedPlugins + */ + void setSelectedPlugins( const TQStringList & v ) + { + if (!isImmutable( TQString::fromLatin1( "SelectedPlugins" ) )) + mSelectedPlugins = v; + } + + /** + Get SelectedPlugins + */ + TQStringList selectedPlugins() const + { + return mSelectedPlugins; + } + + /** + Get Item object corresponding to SelectedPlugins() + */ + ItemStringList *selectedPluginsItem() + { + return mSelectedPluginsItem; + } + + /** + Set Highlight color + */ + void setHighlightColor( const TQColor & v ) + { + if (!isImmutable( TQString::fromLatin1( "HighlightColor" ) )) + mHighlightColor = v; + } + + /** + Get Highlight color + */ + TQColor highlightColor() const + { + return mHighlightColor; + } + + /** + Get Item object corresponding to HighlightColor() + */ + ItemColor *highlightColorItem() + { + return mHighlightColorItem; + } + + /** + Set Agenda view background color + */ + void setAgendaBgColor( const TQColor & v ) + { + if (!isImmutable( TQString::fromLatin1( "AgendaBgColor" ) )) + mAgendaBgColor = v; + } + + /** + Get Agenda view background color + */ + TQColor agendaBgColor() const + { + return mAgendaBgColor; + } + + /** + Get Item object corresponding to AgendaBgColor() + */ + ItemColor *agendaBgColorItem() + { + return mAgendaBgColorItem; + } + + /** + Set Time bar + */ + void setTimeBarFont( const TQFont & v ) + { + if (!isImmutable( TQString::fromLatin1( "TimeBarFont" ) )) + mTimeBarFont = v; + } + + /** + Get Time bar + */ + TQFont timeBarFont() const + { + return mTimeBarFont; + } + + /** + Get Item object corresponding to TimeBarFont() + */ + ItemFont *timeBarFontItem() + { + return mTimeBarFontItem; + } + + protected: + public: + + // General + bool mAutoSave; + int mAutoSaveInterval; + bool mConfirm; + TQString mArchiveFile; + int mDestination; + + // Views + int mHourSize; + bool mSelectionStartsEditor; + + // KOrganizer Plugins + TQStringList mSelectedPlugins; + + // Colors + TQColor mHighlightColor; + TQColor mAgendaBgColor; + + // Fonts + TQFont mTimeBarFont; + + private: + ItemBool *mAutoSaveItem; + ItemInt *mAutoSaveIntervalItem; + ItemBool *mConfirmItem; + ItemString *mArchiveFileItem; + ItemEnum *mDestinationItem; + ItemInt *mHourSizeItem; + ItemBool *mSelectionStartsEditorItem; + ItemStringList *mSelectedPluginsItem; + ItemColor *mHighlightColorItem; + ItemColor *mAgendaBgColorItem; + ItemFont *mTimeBarFontItem; +}; + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test2.kcfg b/tdecore/tdeconfig_compiler/tests/test2.kcfg new file mode 100644 index 000000000..3b19e270e --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test2.kcfg @@ -0,0 +1,78 @@ + + + + + + + + WhatsThis text for AutoSave option + false + + + 10 + + + + true + + + + + + + + + + + + + + + Argl2 Whatsthis + + + + Argl3 Whatsthis + + + standardDestination + + + + + + 10 + + + + false + + + + + + holidays,webexport + + + + + + + 100, 100, 255 + + + + 255, 255, 255 + + + + + + + + + + diff --git a/tdecore/tdeconfig_compiler/tests/test2.kcfgc b/tdecore/tdeconfig_compiler/tests/test2.kcfgc new file mode 100644 index 000000000..e29040686 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test2.kcfgc @@ -0,0 +1,11 @@ +# Code generation options for tdeconfig_compiler +File=test2.kcfg +ClassName=Test2 +Singleton=false +Mutators=true +Inherits=MyPrefs +IncludeFiles=myprefs.h +MemberVariables=public +GlobalEnums=true +ItemAccessors=true +SetUserTexts=true diff --git a/tdecore/tdeconfig_compiler/tests/test2main.cpp b/tdecore/tdeconfig_compiler/tests/test2main.cpp new file mode 100644 index 000000000..5970bf03d --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test2main.cpp @@ -0,0 +1,29 @@ +/* +Copyright (c) 2003 Cornelius Schumacher + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#include "test2.h" +#include "kinstance.h" + +int main( int, char*[] ) +{ + TDEInstance i("test"); + Test2 *t = new Test2(); + delete t; +} diff --git a/tdecore/tdeconfig_compiler/tests/test3.cpp.ref b/tdecore/tdeconfig_compiler/tests/test3.cpp.ref new file mode 100644 index 000000000..be3e5c6c1 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test3.cpp.ref @@ -0,0 +1,29 @@ +// This file is generated by tdeconfig_compiler from test3.kcfg. +// All changes you do to this file will be lost. + +#include "test3.h" + +using namespace TestNameSpace; + +Test3::Test3( ) + : TDEConfigSkeleton( TQString::fromLatin1( "test3rc" ) ) +{ + setCurrentGroup( TQString::fromLatin1( "General" ) ); + + mAutoSaveItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "Auto Save" ), mAutoSave, false ); + addItem( mAutoSaveItem, TQString::fromLatin1( "AutoSave" ) ); + + setCurrentGroup( TQString::fromLatin1( "Blah" ) ); + + mBlubbItem = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Blubb" ), mBlubb, 10 ); + addItem( mBlubbItem, TQString::fromLatin1( "Blubb" ) ); + mBlahBlahItem = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "BlahBlah" ), mBlahBlah, TQString::fromLatin1( "a string" ) ); + addItem( mBlahBlahItem, TQString::fromLatin1( "BlahBlah" ) ); + mMyPasswordItem = new TDEConfigSkeleton::ItemPassword( currentGroup(), TQString::fromLatin1( "MyPassword" ), mMyPassword ); + addItem( mMyPasswordItem, TQString::fromLatin1( "MyPassword" ) ); +} + +Test3::~Test3() +{ +} + diff --git a/tdecore/tdeconfig_compiler/tests/test3.h.ref b/tdecore/tdeconfig_compiler/tests/test3.h.ref new file mode 100644 index 000000000..596e154e4 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test3.h.ref @@ -0,0 +1,138 @@ +// This file is generated by tdeconfig_compiler from test3.kcfg. +// All changes you do to this file will be lost. +#ifndef TESTNAMESPACE_TEST3_H +#define TESTNAMESPACE_TEST3_H + +#include +#include + +namespace TestNameSpace { + +class Test3 : public TDEConfigSkeleton +{ + public: + + Test3( ); + ~Test3(); + + /** + Set Enable automatic saving of calendar + */ + void setAutoSave( bool v ) + { + if (!isImmutable( TQString::fromLatin1( "AutoSave" ) )) + mAutoSave = v; + } + + /** + Get Enable automatic saving of calendar + */ + bool autoSave() const + { + return mAutoSave; + } + + /** + Get Item object corresponding to AutoSave() + */ + ItemBool *autoSaveItem() + { + return mAutoSaveItem; + } + + /** + Set Blubb + */ + void setBlubb( int v ) + { + if (!isImmutable( TQString::fromLatin1( "Blubb" ) )) + mBlubb = v; + } + + /** + Get Blubb + */ + int blubb() const + { + return mBlubb; + } + + /** + Get Item object corresponding to Blubb() + */ + ItemInt *blubbItem() + { + return mBlubbItem; + } + + /** + Set BlahBlah + */ + void setBlahBlah( const TQString & v ) + { + if (!isImmutable( TQString::fromLatin1( "BlahBlah" ) )) + mBlahBlah = v; + } + + /** + Get BlahBlah + */ + TQString blahBlah() const + { + return mBlahBlah; + } + + /** + Get Item object corresponding to BlahBlah() + */ + ItemString *blahBlahItem() + { + return mBlahBlahItem; + } + + /** + Set MyPassword + */ + void setMyPassword( const TQString & v ) + { + if (!isImmutable( TQString::fromLatin1( "MyPassword" ) )) + mMyPassword = v; + } + + /** + Get MyPassword + */ + TQString myPassword() const + { + return mMyPassword; + } + + /** + Get Item object corresponding to MyPassword() + */ + ItemPassword *myPasswordItem() + { + return mMyPasswordItem; + } + + protected: + + // General + bool mAutoSave; + + // Blah + int mBlubb; + TQString mBlahBlah; + TQString mMyPassword; + + private: + ItemBool *mAutoSaveItem; + ItemInt *mBlubbItem; + ItemString *mBlahBlahItem; + ItemPassword *mMyPasswordItem; +}; + +} + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test3.kcfg b/tdecore/tdeconfig_compiler/tests/test3.kcfg new file mode 100644 index 000000000..77916da40 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test3.kcfg @@ -0,0 +1,26 @@ + + + + + + + + WhatsThis text for AutoSave option + false + + + + + + 10 + + + a string + + + + + diff --git a/tdecore/tdeconfig_compiler/tests/test3.kcfgc b/tdecore/tdeconfig_compiler/tests/test3.kcfgc new file mode 100644 index 000000000..d699810d0 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test3.kcfgc @@ -0,0 +1,12 @@ +# Code generation options for tdeconfig_compiler +File=test3.kcfg +NameSpace=TestNameSpace +ClassName=Test3 +#Singleton=false +Mutators=true +#Inherits=MyPrefs +#IncludeFiles=myprefs.h +#MemberVariables=public +GlobalEnums=true +ItemAccessors=true +#SetUserTexts=true diff --git a/tdecore/tdeconfig_compiler/tests/test3main.cpp b/tdecore/tdeconfig_compiler/tests/test3main.cpp new file mode 100644 index 000000000..f73ae38e3 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test3main.cpp @@ -0,0 +1,29 @@ +/* +Copyright (c) 2003 Cornelius Schumacher + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#include "test3.h" +#include "kinstance.h" + +int main( int, char*[] ) +{ + TDEInstance i("test"); + TestNameSpace::Test3 *t = new TestNameSpace::Test3(); + delete t; +} diff --git a/tdecore/tdeconfig_compiler/tests/test4.cpp.ref b/tdecore/tdeconfig_compiler/tests/test4.cpp.ref new file mode 100644 index 000000000..c68437969 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test4.cpp.ref @@ -0,0 +1,82 @@ +// This file is generated by tdeconfig_compiler from test4.kcfg. +// All changes you do to this file will be lost. + +#include "test4.h" + +#include + +Test4 *Test4::mSelf = 0; +static KStaticDeleter staticTest4Deleter; + +Test4 *Test4::self() +{ + if ( !mSelf ) { + staticTest4Deleter.setObject( mSelf, new Test4() ); + mSelf->readConfig(); + } + + return mSelf; +} + +const char* const Test4::EnumButton::enumToString[] = { "right", "mid", "left" }; + +Test4::Test4( ) + : TDEConfigSkeleton( TQString::fromLatin1( "test4rc" ) ) +{ + mSelf = this; + setCurrentGroup( TQString::fromLatin1( "Foo" ) ); + +TQColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; + TDEConfigSkeleton::ItemColor *itemColor[4]; + itemColor[0] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #0" ), mColor[0], defaultColor[0] ); + addItem( itemColor[0], TQString::fromLatin1( "Color0" ) ); + itemColor[1] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #1" ), mColor[1], defaultColor[1] ); + addItem( itemColor[1], TQString::fromLatin1( "Color1" ) ); + itemColor[2] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #2" ), mColor[2], defaultColor[2] ); + addItem( itemColor[2], TQString::fromLatin1( "Color2" ) ); + itemColor[3] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #3" ), mColor[3], defaultColor[3] ); + addItem( itemColor[3], TQString::fromLatin1( "Color3" ) ); + TQValueList valuesMouseAction; + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "Encrypt" ); + valuesMouseAction.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "Decrypt" ); + valuesMouseAction.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "CrashNBurn" ); + valuesMouseAction.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "PumpNDump" ); + valuesMouseAction.append( choice ); + } + TDEConfigSkeleton::ItemEnum *itemMouseAction[3]; + itemMouseAction[0] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "right_mouse_action" ), mMouseAction[0], valuesMouseAction, EnumMouseAction::Decrypt ); + addItem( itemMouseAction[0], TQString::fromLatin1( "MouseActionright" ) ); + itemMouseAction[1] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "mid_mouse_action" ), mMouseAction[1], valuesMouseAction, EnumMouseAction::Encrypt ); + addItem( itemMouseAction[1], TQString::fromLatin1( "MouseActionmid" ) ); + itemMouseAction[2] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "left_mouse_action" ), mMouseAction[2], valuesMouseAction, EnumMouseAction::PumpNDump ); + addItem( itemMouseAction[2], TQString::fromLatin1( "MouseActionleft" ) ); + TDEConfigSkeleton::ItemString *itemFooBar; + itemFooBar = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "foo bar" ), mFooBar ); + addItem( itemFooBar, TQString::fromLatin1( "FooBar" ) ); + TDEConfigSkeleton::ItemInt *itemAge; + itemAge = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Age" ), mAge, 35 ); + itemAge->setMinValue(8); + itemAge->setMaxValue(88); + addItem( itemAge, TQString::fromLatin1( "Age" ) ); +} + +Test4::~Test4() +{ + if ( mSelf == this ) + staticTest4Deleter.setObject( mSelf, 0, false ); +} + diff --git a/tdecore/tdeconfig_compiler/tests/test4.h.ref b/tdecore/tdeconfig_compiler/tests/test4.h.ref new file mode 100644 index 000000000..9901a4208 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test4.h.ref @@ -0,0 +1,135 @@ +// This file is generated by tdeconfig_compiler from test4.kcfg. +// All changes you do to this file will be lost. +#ifndef TEST4_H +#define TEST4_H + +#include +#include + +class Test4 : public TDEConfigSkeleton +{ + public: + class EnumMouseAction + { + public: + enum type { Encrypt, Decrypt, CrashNBurn, PumpNDump, COUNT }; + }; + class EnumButton + { + public: + enum type { right, mid, left, COUNT }; + static const char* const enumToString[]; + }; + + static Test4 *self(); + ~Test4(); + + /** + Set Block colors. + */ + static + void setColor( int i, const TQColor & v ) + { + if (!self()->isImmutable( TQString::fromLatin1( "Color%1" ).arg( i ) )) + self()->mColor[i] = v; + } + + /** + Get Block colors. + */ + static + TQColor color( int i ) + { + return self()->mColor[i]; + } + + /** + Set Mouse actions. + */ + static + void setMouseAction( int i, int v ) + { + if (!self()->isImmutable( TQString::fromLatin1( "MouseAction%1" ).arg( TQString::fromLatin1( EnumButton::enumToString[i] ) ) )) + self()->mMouseAction[i] = v; + } + + /** + Get Mouse actions. + */ + static + int mouseAction( int i ) + { + return self()->mMouseAction[i]; + } + + /** + Set foo bar + */ + static + void setFooBar( const TQString & v ) + { + if (!self()->isImmutable( TQString::fromLatin1( "FooBar" ) )) + self()->mFooBar = v; + } + + /** + Get foo bar + */ + static + TQString fooBar() + { + return self()->mFooBar; + } + + /** + Set Age + */ + static + void setAge( int v ) + { + if (v < 8) + { + kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; + v = 8; + } + + if (v > 88) + { + kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; + v = 88; + } + + if (!self()->isImmutable( TQString::fromLatin1( "Age" ) )) + self()->mAge = v; + } + + /** + Get Age + */ + static + int age() + { + return self()->mAge; + } + + static + void writeConfig() + { + static_cast(self())->writeConfig(); + } + protected: + Test4(); + static Test4 *mSelf; + + + // Foo + TQColor mColor[4]; + int mMouseAction[3]; + TQString mFooBar; + int mAge; + + private: +}; + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test4.kcfg b/tdecore/tdeconfig_compiler/tests/test4.kcfg new file mode 100644 index 000000000..d8ef2bfae --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test4.kcfg @@ -0,0 +1,42 @@ + + + + + + + + + QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; + defaultColor[$(Number)] + + + + + right + mid + left + + + + + + + + + + Decrypt + Encrypt + PumpNDump + + + + 35 + 8 + 88 + + + + diff --git a/tdecore/tdeconfig_compiler/tests/test4.kcfgc b/tdecore/tdeconfig_compiler/tests/test4.kcfgc new file mode 100644 index 000000000..a81655b6c --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test4.kcfgc @@ -0,0 +1,11 @@ +# Code generation options for tdeconfig_compiler +File=test4.kcfg +ClassName=Test4 +Singleton=true +Mutators=true +#Inherits=MyPrefs +#IncludeFiles=myprefs.h +#MemberVariables=public +GlobalEnums=false +ItemAccessors=false +#SetUserTexts=true diff --git a/tdecore/tdeconfig_compiler/tests/test4main.cpp b/tdecore/tdeconfig_compiler/tests/test4main.cpp new file mode 100644 index 000000000..5229d8a87 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test4main.cpp @@ -0,0 +1,30 @@ +/* +Copyright (c) 2003,2004 Waldo Bastian + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "test4.h" +#include "kinstance.h" + +int main( int, char*[] ) +{ + TDEInstance i("test"); + Test4 *t = Test4::self(); + delete t; +} diff --git a/tdecore/tdeconfig_compiler/tests/test5.cpp.ref b/tdecore/tdeconfig_compiler/tests/test5.cpp.ref new file mode 100644 index 000000000..17965999b --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test5.cpp.ref @@ -0,0 +1,82 @@ +// This file is generated by tdeconfig_compiler from test5.kcfg. +// All changes you do to this file will be lost. + +#include "test5.h" + +#include + +Test5 *Test5::mSelf = 0; +static KStaticDeleter staticTest5Deleter; + +Test5 *Test5::self() +{ + if ( !mSelf ) { + staticTest5Deleter.setObject( mSelf, new Test5() ); + mSelf->readConfig(); + } + + return mSelf; +} + +const char* const Test5::EnumButtonToString[] = { "right", "mid", "left" }; + +Test5::Test5( ) + : TDEConfigSkeleton( TQString::fromLatin1( "test4rc" ) ) +{ + mSelf = this; + setCurrentGroup( TQString::fromLatin1( "Foo" ) ); + +TQColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; + TDEConfigSkeleton::ItemColor *itemColor[4]; + itemColor[0] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #0" ), mColor[0], defaultColor[0] ); + addItem( itemColor[0], TQString::fromLatin1( "Color0" ) ); + itemColor[1] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #1" ), mColor[1], defaultColor[1] ); + addItem( itemColor[1], TQString::fromLatin1( "Color1" ) ); + itemColor[2] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #2" ), mColor[2], defaultColor[2] ); + addItem( itemColor[2], TQString::fromLatin1( "Color2" ) ); + itemColor[3] = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #3" ), mColor[3], defaultColor[3] ); + addItem( itemColor[3], TQString::fromLatin1( "Color3" ) ); + TQValueList valuesMouseAction; + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "Encrypt" ); + valuesMouseAction.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "Decrypt" ); + valuesMouseAction.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "CrashNBurn" ); + valuesMouseAction.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "PumpNDump" ); + valuesMouseAction.append( choice ); + } + TDEConfigSkeleton::ItemEnum *itemMouseAction[3]; + itemMouseAction[0] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "right_mouse_action" ), mMouseAction[0], valuesMouseAction, Decrypt ); + addItem( itemMouseAction[0], TQString::fromLatin1( "MouseActionright" ) ); + itemMouseAction[1] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "mid_mouse_action" ), mMouseAction[1], valuesMouseAction, Encrypt ); + addItem( itemMouseAction[1], TQString::fromLatin1( "MouseActionmid" ) ); + itemMouseAction[2] = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "left_mouse_action" ), mMouseAction[2], valuesMouseAction, PumpNDump ); + addItem( itemMouseAction[2], TQString::fromLatin1( "MouseActionleft" ) ); + TDEConfigSkeleton::ItemString *itemFooBar; + itemFooBar = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "foo bar" ), mFooBar ); + addItem( itemFooBar, TQString::fromLatin1( "FooBar" ) ); + TDEConfigSkeleton::ItemInt *itemAge; + itemAge = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Age" ), mAge, 35 ); + itemAge->setMinValue(8); + itemAge->setMaxValue(88); + addItem( itemAge, TQString::fromLatin1( "Age" ) ); +} + +Test5::~Test5() +{ + if ( mSelf == this ) + staticTest5Deleter.setObject( mSelf, 0, false ); +} + diff --git a/tdecore/tdeconfig_compiler/tests/test5.h.ref b/tdecore/tdeconfig_compiler/tests/test5.h.ref new file mode 100644 index 000000000..e2f1f8118 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test5.h.ref @@ -0,0 +1,127 @@ +// This file is generated by tdeconfig_compiler from test5.kcfg. +// All changes you do to this file will be lost. +#ifndef TEST5_H +#define TEST5_H + +#include +#include + +class Test5 : public TDEConfigSkeleton +{ + public: + enum { Encrypt, Decrypt, CrashNBurn, PumpNDump }; + enum { right, mid, left }; + static const char* const EnumButtonToString[]; + + static Test5 *self(); + ~Test5(); + + /** + Set Block colors. + */ + static + void setColor( int i, const TQColor & v ) + { + if (!self()->isImmutable( TQString::fromLatin1( "Color%1" ).arg( i ) )) + self()->mColor[i] = v; + } + + /** + Get Block colors. + */ + static + TQColor color( int i ) + { + return self()->mColor[i]; + } + + /** + Set Mouse actions. + */ + static + void setMouseAction( int i, int v ) + { + if (!self()->isImmutable( TQString::fromLatin1( "MouseAction%1" ).arg( TQString::fromLatin1( EnumButtonToString[i] ) ) )) + self()->mMouseAction[i] = v; + } + + /** + Get Mouse actions. + */ + static + int mouseAction( int i ) + { + return self()->mMouseAction[i]; + } + + /** + Set foo bar + */ + static + void setFooBar( const TQString & v ) + { + if (!self()->isImmutable( TQString::fromLatin1( "FooBar" ) )) + self()->mFooBar = v; + } + + /** + Get foo bar + */ + static + TQString fooBar() + { + return self()->mFooBar; + } + + /** + Set Age + */ + static + void setAge( int v ) + { + if (v < 8) + { + kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; + v = 8; + } + + if (v > 88) + { + kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; + v = 88; + } + + if (!self()->isImmutable( TQString::fromLatin1( "Age" ) )) + self()->mAge = v; + } + + /** + Get Age + */ + static + int age() + { + return self()->mAge; + } + + static + void writeConfig() + { + static_cast(self())->writeConfig(); + } + protected: + Test5(); + static Test5 *mSelf; + + + // Foo + TQColor mColor[4]; + int mMouseAction[3]; + TQString mFooBar; + int mAge; + + private: +}; + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test5.kcfg b/tdecore/tdeconfig_compiler/tests/test5.kcfg new file mode 100644 index 000000000..d8ef2bfae --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test5.kcfg @@ -0,0 +1,42 @@ + + + + + + + + + QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black }; + defaultColor[$(Number)] + + + + + right + mid + left + + + + + + + + + + Decrypt + Encrypt + PumpNDump + + + + 35 + 8 + 88 + + + + diff --git a/tdecore/tdeconfig_compiler/tests/test5.kcfgc b/tdecore/tdeconfig_compiler/tests/test5.kcfgc new file mode 100644 index 000000000..dbc5603a0 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test5.kcfgc @@ -0,0 +1,11 @@ +# Code generation options for tdeconfig_compiler +File=test5.kcfg +ClassName=Test5 +Singleton=true +Mutators=true +#Inherits=MyPrefs +#IncludeFiles=myprefs.h +#MemberVariables=public +GlobalEnums=true +ItemAccessors=false +#SetUserTexts=true diff --git a/tdecore/tdeconfig_compiler/tests/test5main.cpp b/tdecore/tdeconfig_compiler/tests/test5main.cpp new file mode 100644 index 000000000..89f28587f --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test5main.cpp @@ -0,0 +1,30 @@ +/* +Copyright (c) 2004 Waldo Bastian + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "test5.h" +#include "kinstance.h" + +int main( int, char*[] ) +{ + TDEInstance i("test"); + Test5 *t = Test5::self(); + delete t; +} diff --git a/tdecore/tdeconfig_compiler/tests/test6.cpp.ref b/tdecore/tdeconfig_compiler/tests/test6.cpp.ref new file mode 100644 index 000000000..36717a7c8 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test6.cpp.ref @@ -0,0 +1,31 @@ +// This file is generated by tdeconfig_compiler from test6.kcfg. +// All changes you do to this file will be lost. + +#include "test6.h" + +Test6::Test6( const TQString & Number ) + : TDEConfigSkeleton( TQString::fromLatin1( "test4rc" ) ) + , mParamNumber(Number) +{ + setCurrentGroup( TQString::fromLatin1( "Foo" ) ); + + TDEConfigSkeleton::ItemColor *itemColor; + itemColor = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #%1" ).arg( mParamNumber ), mColor, TQColor( "red" ) ); + addItem( itemColor, TQString::fromLatin1( "Color" ) ); + + setCurrentGroup( TQString::fromLatin1( "Bar%1" ).arg( mParamNumber ) ); + + TDEConfigSkeleton::ItemString *itemFooBar; + itemFooBar = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "foo bar" ), mFooBar ); + addItem( itemFooBar, TQString::fromLatin1( "FooBar" ) ); + TDEConfigSkeleton::ItemInt *itemAge; + itemAge = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Age" ), mAge, 35 ); + itemAge->setMinValue(8); + itemAge->setMaxValue(88); + addItem( itemAge, TQString::fromLatin1( "Age" ) ); +} + +Test6::~Test6() +{ +} + diff --git a/tdecore/tdeconfig_compiler/tests/test6.h.ref b/tdecore/tdeconfig_compiler/tests/test6.h.ref new file mode 100644 index 000000000..da83c90c4 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test6.h.ref @@ -0,0 +1,93 @@ +// This file is generated by tdeconfig_compiler from test6.kcfg. +// All changes you do to this file will be lost. +#ifndef TEST6_H +#define TEST6_H + +#include +#include + +class Test6 : public TDEConfigSkeleton +{ + public: + + Test6( const TQString & Number ); + ~Test6(); + + /** + Set Block colors. + */ + void setColor( const TQColor & v ) + { + if (!isImmutable( TQString::fromLatin1( "Color" ) )) + mColor = v; + } + + /** + Get Block colors. + */ + TQColor color() const + { + return mColor; + } + + /** + Set foo bar + */ + void setFooBar( const TQString & v ) + { + if (!isImmutable( TQString::fromLatin1( "FooBar" ) )) + mFooBar = v; + } + + /** + Get foo bar + */ + TQString fooBar() const + { + return mFooBar; + } + + /** + Set Age + */ + void setAge( int v ) + { + if (v < 8) + { + kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; + v = 8; + } + + if (v > 88) + { + kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; + v = 88; + } + + if (!isImmutable( TQString::fromLatin1( "Age" ) )) + mAge = v; + } + + /** + Get Age + */ + int age() const + { + return mAge; + } + + protected: + TQString mParamNumber; + + // Foo + TQColor mColor; + + // Bar$(Number) + TQString mFooBar; + int mAge; + + private: +}; + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test6.kcfg b/tdecore/tdeconfig_compiler/tests/test6.kcfg new file mode 100644 index 000000000..e59fa88f3 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test6.kcfg @@ -0,0 +1,25 @@ + + + + + + + + + + red + + + + + + 35 + 8 + 88 + + + + diff --git a/tdecore/tdeconfig_compiler/tests/test6.kcfgc b/tdecore/tdeconfig_compiler/tests/test6.kcfgc new file mode 100644 index 000000000..4c395ac08 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test6.kcfgc @@ -0,0 +1,11 @@ +# Code generation options for tdeconfig_compiler +File=test6.kcfg +ClassName=Test6 +Singleton=false +Mutators=true +#Inherits=MyPrefs +#IncludeFiles=myprefs.h +#MemberVariables=public +GlobalEnums=true +ItemAccessors=false +#SetUserTexts=true diff --git a/tdecore/tdeconfig_compiler/tests/test6main.cpp b/tdecore/tdeconfig_compiler/tests/test6main.cpp new file mode 100644 index 000000000..9b1b7503e --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test6main.cpp @@ -0,0 +1,30 @@ +/* +Copyright (c) 2004 Waldo Bastian + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "test6.h" +#include "kinstance.h" + +int main( int, char*[] ) +{ + TDEInstance i("test"); + Test6 *t = new Test6(TQString::null); + delete t; +} diff --git a/tdecore/tdeconfig_compiler/tests/test7.cpp.ref b/tdecore/tdeconfig_compiler/tests/test7.cpp.ref new file mode 100644 index 000000000..e4b5f08f9 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test7.cpp.ref @@ -0,0 +1,31 @@ +// This file is generated by tdeconfig_compiler from test7.kcfg. +// All changes you do to this file will be lost. + +#include "test7.h" + +Test7::Test7( int Number ) + : TDEConfigSkeleton( TQString::fromLatin1( "test7rc" ) ) + , mParamNumber(Number) +{ + setCurrentGroup( TQString::fromLatin1( "Foo" ) ); + + TDEConfigSkeleton::ItemColor *itemColor; + itemColor = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "color #%1" ).arg( mParamNumber ), mColor, TQColor( "red" ) ); + addItem( itemColor, TQString::fromLatin1( "Color" ) ); + + setCurrentGroup( TQString::fromLatin1( "Bar%1" ).arg( mParamNumber ) ); + + TDEConfigSkeleton::ItemString *itemFooBar; + itemFooBar = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "foo bar" ), mFooBar ); + addItem( itemFooBar, TQString::fromLatin1( "FooBar" ) ); + TDEConfigSkeleton::ItemInt *itemAge; + itemAge = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Age" ), mAge, 35 ); + itemAge->setMinValue(8); + itemAge->setMaxValue(88); + addItem( itemAge, TQString::fromLatin1( "Age" ) ); +} + +Test7::~Test7() +{ +} + diff --git a/tdecore/tdeconfig_compiler/tests/test7.h.ref b/tdecore/tdeconfig_compiler/tests/test7.h.ref new file mode 100644 index 000000000..8bd22ae97 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test7.h.ref @@ -0,0 +1,93 @@ +// This file is generated by tdeconfig_compiler from test7.kcfg. +// All changes you do to this file will be lost. +#ifndef TEST7_H +#define TEST7_H + +#include +#include + +class Test7 : public TDEConfigSkeleton +{ + public: + + Test7( int Number ); + ~Test7(); + + /** + Set Block colors. + */ + void setColor( const TQColor & v ) + { + if (!isImmutable( TQString::fromLatin1( "Color" ) )) + mColor = v; + } + + /** + Get Block colors. + */ + TQColor color() const + { + return mColor; + } + + /** + Set foo bar + */ + void setFooBar( const TQString & v ) + { + if (!isImmutable( TQString::fromLatin1( "FooBar" ) )) + mFooBar = v; + } + + /** + Get foo bar + */ + TQString fooBar() const + { + return mFooBar; + } + + /** + Set Age + */ + void setAge( int v ) + { + if (v < 8) + { + kdDebug() << "setAge: value " << v << " is less than the minimum value of 8" << endl; + v = 8; + } + + if (v > 88) + { + kdDebug() << "setAge: value " << v << " is greater than the maximum value of 88" << endl; + v = 88; + } + + if (!isImmutable( TQString::fromLatin1( "Age" ) )) + mAge = v; + } + + /** + Get Age + */ + int age() const + { + return mAge; + } + + protected: + int mParamNumber; + + // Foo + TQColor mColor; + + // Bar$(Number) + TQString mFooBar; + int mAge; + + private: +}; + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test7.kcfg b/tdecore/tdeconfig_compiler/tests/test7.kcfg new file mode 100644 index 000000000..0a7fd3272 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test7.kcfg @@ -0,0 +1,25 @@ + + + + + + + + + + red + + + + + + 35 + 8 + 88 + + + + diff --git a/tdecore/tdeconfig_compiler/tests/test7.kcfgc b/tdecore/tdeconfig_compiler/tests/test7.kcfgc new file mode 100644 index 000000000..c50aac7e3 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test7.kcfgc @@ -0,0 +1,11 @@ +# Code generation options for tdeconfig_compiler +File=test7.kcfg +ClassName=Test7 +Singleton=false +Mutators=true +#Inherits=MyPrefs +#IncludeFiles=myprefs.h +#MemberVariables=public +GlobalEnums=true +ItemAccessors=false +#SetUserTexts=true diff --git a/tdecore/tdeconfig_compiler/tests/test7main.cpp b/tdecore/tdeconfig_compiler/tests/test7main.cpp new file mode 100644 index 000000000..81cca0184 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test7main.cpp @@ -0,0 +1,30 @@ +/* +Copyright (c) 2004 Waldo Bastian + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "test7.h" +#include "kinstance.h" + +int main( int, char*[] ) +{ + TDEInstance i("test"); + Test7 *t = new Test7(42); + delete t; +} diff --git a/tdecore/tdeconfig_compiler/tests/test8a.cpp.ref b/tdecore/tdeconfig_compiler/tests/test8a.cpp.ref new file mode 100644 index 000000000..c0a9ddda5 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test8a.cpp.ref @@ -0,0 +1,22 @@ +// This file is generated by tdeconfig_compiler from test8a.kcfg. +// All changes you do to this file will be lost. + +#include "test8a.h" + +Test8a::Test8a( KSharedConfig::Ptr config ) + : TDEConfigSkeleton( config ) +{ + setCurrentGroup( TQString::fromLatin1( "Group" ) ); + + TDEConfigSkeleton::ItemFont *itemFont; + itemFont = new TDEConfigSkeleton::ItemFont( currentGroup(), TQString::fromLatin1( "Font" ), mFont, TDEGlobalSettings::generalFont() ); + addItem( itemFont, TQString::fromLatin1( "Font" ) ); + TDEConfigSkeleton::ItemFont *itemTitleFont; + itemTitleFont = new TDEConfigSkeleton::ItemFont( currentGroup(), TQString::fromLatin1( "TitleFont" ), mTitleFont, TDEGlobalSettings::windowTitleFont() ); + addItem( itemTitleFont, TQString::fromLatin1( "TitleFont" ) ); +} + +Test8a::~Test8a() +{ +} + diff --git a/tdecore/tdeconfig_compiler/tests/test8a.h.ref b/tdecore/tdeconfig_compiler/tests/test8a.h.ref new file mode 100644 index 000000000..9913cfc49 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test8a.h.ref @@ -0,0 +1,61 @@ +// This file is generated by tdeconfig_compiler from test8a.kcfg. +// All changes you do to this file will be lost. +#ifndef TEST8A_H +#define TEST8A_H + +#include +#include +#include + +class Test8a : public TDEConfigSkeleton +{ + public: + + Test8a( KSharedConfig::Ptr config = TDEGlobal::sharedConfig() ); + ~Test8a(); + + /** + Set Font + */ + void setFont( const TQFont & v ) + { + if (!isImmutable( TQString::fromLatin1( "Font" ) )) + mFont = v; + } + + /** + Get Font + */ + TQFont font() const + { + return mFont; + } + + /** + Set TitleFont + */ + void setTitleFont( const TQFont & v ) + { + if (!isImmutable( TQString::fromLatin1( "TitleFont" ) )) + mTitleFont = v; + } + + /** + Get TitleFont + */ + TQFont titleFont() const + { + return mTitleFont; + } + + protected: + + // Group + TQFont mFont; + TQFont mTitleFont; + + private: +}; + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test8a.kcfg b/tdecore/tdeconfig_compiler/tests/test8a.kcfg new file mode 100644 index 000000000..53448b624 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test8a.kcfg @@ -0,0 +1,17 @@ + + + + + + + TDEGlobalSettings::generalFont() + + + + TDEGlobalSettings::windowTitleFont() + + + diff --git a/tdecore/tdeconfig_compiler/tests/test8a.kcfgc b/tdecore/tdeconfig_compiler/tests/test8a.kcfgc new file mode 100644 index 000000000..5f63c31c2 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test8a.kcfgc @@ -0,0 +1,3 @@ +File=test8a.kcfg +ClassName=Test8a +Mutators=true diff --git a/tdecore/tdeconfig_compiler/tests/test8b.cpp.ref b/tdecore/tdeconfig_compiler/tests/test8b.cpp.ref new file mode 100644 index 000000000..288faeb12 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test8b.cpp.ref @@ -0,0 +1,46 @@ +// This file is generated by tdeconfig_compiler from test8b.kcfg. +// All changes you do to this file will be lost. + +#include "test8b.h" + +#include + +Test8b *Test8b::mSelf = 0; +static KStaticDeleter staticTest8bDeleter; + +Test8b *Test8b::self() +{ + if ( !mSelf ) { + staticTest8bDeleter.setObject( mSelf, new Test8b() ); + mSelf->readConfig(); + } + + return mSelf; +} + +Test8b::Test8b( ) + : Test8a() +{ + mSelf = this; + setCurrentGroup( TQString::fromLatin1( "Group8b1" ) ); + + TDEConfigSkeleton::ItemUInt *itemSomething; + itemSomething = new TDEConfigSkeleton::ItemUInt( currentGroup(), TQString::fromLatin1( "Something" ), mSomething, 60 ); + addItem( itemSomething, TQString::fromLatin1( "Something" ) ); + + setCurrentGroup( TQString::fromLatin1( "Group8b2" ) ); + + TDEConfigSkeleton::ItemBool *itemFooBoo; + itemFooBoo = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "FooBoo" ), mFooBoo, false ); + addItem( itemFooBoo, TQString::fromLatin1( "FooBoo" ) ); + TDEConfigSkeleton::ItemUInt *itemPort; + itemPort = new TDEConfigSkeleton::ItemUInt( currentGroup(), TQString::fromLatin1( "Port" ), mPort, 1000 ); + addItem( itemPort, TQString::fromLatin1( "Port" ) ); +} + +Test8b::~Test8b() +{ + if ( mSelf == this ) + staticTest8bDeleter.setObject( mSelf, 0, false ); +} + diff --git a/tdecore/tdeconfig_compiler/tests/test8b.h.ref b/tdecore/tdeconfig_compiler/tests/test8b.h.ref new file mode 100644 index 000000000..82ab5d92b --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test8b.h.ref @@ -0,0 +1,96 @@ +// This file is generated by tdeconfig_compiler from test8b.kcfg. +// All changes you do to this file will be lost. +#ifndef TEST8B_H +#define TEST8B_H + +#include + +#include +#include + +class Test8b : public Test8a +{ + public: + + static Test8b *self(); + ~Test8b(); + + /** + Set Something + */ + static + void setSomething( uint v ) + { + if (!self()->isImmutable( TQString::fromLatin1( "Something" ) )) + self()->mSomething = v; + } + + /** + Get Something + */ + static + uint something() + { + return self()->mSomething; + } + + /** + Set FooBoo + */ + static + void setFooBoo( bool v ) + { + if (!self()->isImmutable( TQString::fromLatin1( "FooBoo" ) )) + self()->mFooBoo = v; + } + + /** + Get FooBoo + */ + static + bool fooBoo() + { + return self()->mFooBoo; + } + + /** + Set Port + */ + static + void setPort( uint v ) + { + if (!self()->isImmutable( TQString::fromLatin1( "Port" ) )) + self()->mPort = v; + } + + /** + Get Port + */ + static + uint port() + { + return self()->mPort; + } + + static + void writeConfig() + { + static_cast(self())->writeConfig(); + } + protected: + Test8b(); + static Test8b *mSelf; + + + // Group8b1 + uint mSomething; + + // Group8b2 + bool mFooBoo; + uint mPort; + + private: +}; + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test8b.kcfg b/tdecore/tdeconfig_compiler/tests/test8b.kcfg new file mode 100644 index 000000000..3e203a155 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test8b.kcfg @@ -0,0 +1,21 @@ + + + + + 60 + + + + + + false + + + + 1000 + + + diff --git a/tdecore/tdeconfig_compiler/tests/test8b.kcfgc b/tdecore/tdeconfig_compiler/tests/test8b.kcfgc new file mode 100644 index 000000000..7be055203 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test8b.kcfgc @@ -0,0 +1,6 @@ +File=test8b.kcfg +ClassName=Test8b +Mutators=true +Singleton=true +IncludeFiles=test8a.h +Inherits=Test8a diff --git a/tdecore/tdeconfig_compiler/tests/test8main.cpp b/tdecore/tdeconfig_compiler/tests/test8main.cpp new file mode 100644 index 000000000..04864a95c --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test8main.cpp @@ -0,0 +1,34 @@ +/* +Copyright (c) 2005 Michael Brade + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "test8a.h" +#include "test8b.h" +#include "kinstance.h" + +int main( int, char*[] ) +{ + TDEInstance i("test"); + Test8a *config1 = new Test8a( KSharedConfig::openConfig( TQString::null ) ); + Test8a *config2 = new Test8a(); + Test8b::self(); + delete config1; + delete config2; +} diff --git a/tdecore/tdeconfig_compiler/tests/test9.cpp.ref b/tdecore/tdeconfig_compiler/tests/test9.cpp.ref new file mode 100644 index 000000000..a5ee144aa --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test9.cpp.ref @@ -0,0 +1,35 @@ +// This file is generated by tdeconfig_compiler from test9.kcfg. +// All changes you do to this file will be lost. + +#include "test9.h" + +Test9::Test9( const TQString & transport, const TQString & folder ) + : TDEConfigSkeleton( TQString::fromLatin1( "examplerc" ) ) + , mParamtransport(transport) + , mParamfolder(folder) +{ + setCurrentGroup( TQString::fromLatin1( "MyOptionsXX" ) ); + + TQStringList defaultMyStringList; + defaultMyStringList.append( TQString::fromUtf8( "up" ) ); + defaultMyStringList.append( TQString::fromUtf8( "down" ) ); + + TDEConfigSkeleton::ItemStringList *itemMyStringList; + itemMyStringList = new TDEConfigSkeleton::ItemStringList( currentGroup(), TQString::fromLatin1( "MyStringList" ), mMyStringList, defaultMyStringList ); + addItem( itemMyStringList, TQString::fromLatin1( "MyStringList" ) ); + TQStringList defaultMyPathList; + defaultMyPathList.append( TQString::fromUtf8( "/home" ) ); + defaultMyPathList.append( TQString::fromUtf8( "~" ) ); + + TDEConfigSkeleton::ItemPathList *itemMyPathList; + itemMyPathList = new TDEConfigSkeleton::ItemPathList( currentGroup(), TQString::fromLatin1( "MyPathList" ), mMyPathList, defaultMyPathList ); + addItem( itemMyPathList, TQString::fromLatin1( "MyPathList" ) ); + TDEConfigSkeleton::ItemPathList *itemMyPathsList2; + itemMyPathsList2 = new TDEConfigSkeleton::ItemPathList( currentGroup(), TQString::fromLatin1( "MyPathsList2" ), mMyPathsList2, TQStringList(TQString::fromLatin1("/usr/bin")) += TQDir::homeDirPath() ); + addItem( itemMyPathsList2, TQString::fromLatin1( "MyPathsList2" ) ); +} + +Test9::~Test9() +{ +} + diff --git a/tdecore/tdeconfig_compiler/tests/test9.h.ref b/tdecore/tdeconfig_compiler/tests/test9.h.ref new file mode 100644 index 000000000..23755f411 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test9.h.ref @@ -0,0 +1,82 @@ +// This file is generated by tdeconfig_compiler from test9.kcfg. +// All changes you do to this file will be lost. +#ifndef TEST9_H +#define TEST9_H + +#include +#include + +#include +class Test9 : public TDEConfigSkeleton +{ + public: + + Test9( const TQString & transport, const TQString & folder ); + ~Test9(); + + /** + Set MyStringList + */ + void setMyStringList( const TQStringList & v ) + { + if (!isImmutable( TQString::fromLatin1( "MyStringList" ) )) + mMyStringList = v; + } + + /** + Get MyStringList + */ + TQStringList myStringList() const + { + return mMyStringList; + } + + /** + Set This is a list of paths + */ + void setMyPathList( const TQStringList & v ) + { + if (!isImmutable( TQString::fromLatin1( "MyPathList" ) )) + mMyPathList = v; + } + + /** + Get This is a list of paths + */ + TQStringList myPathList() const + { + return mMyPathList; + } + + /** + Set This is an additional test for PathList + */ + void setMyPathsList2( const TQStringList & v ) + { + if (!isImmutable( TQString::fromLatin1( "MyPathsList2" ) )) + mMyPathsList2 = v; + } + + /** + Get This is an additional test for PathList + */ + TQStringList myPathsList2() const + { + return mMyPathsList2; + } + + protected: + public: + TQString mParamtransport; + TQString mParamfolder; + + // MyOptionsXX + TQStringList mMyStringList; + TQStringList mMyPathList; + TQStringList mMyPathsList2; + + private: +}; + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test9.kcfg b/tdecore/tdeconfig_compiler/tests/test9.kcfg new file mode 100644 index 000000000..b7495e2b6 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test9.kcfg @@ -0,0 +1,24 @@ + + + qdir.h + + + + + + + up,down + + + + /home,~ + + + + QStringList(QString::fromLatin1("/usr/bin")) += QDir::homeDirPath() + + + diff --git a/tdecore/tdeconfig_compiler/tests/test9.kcfgc b/tdecore/tdeconfig_compiler/tests/test9.kcfgc new file mode 100644 index 000000000..47f5e5f43 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test9.kcfgc @@ -0,0 +1,18 @@ +# Code generation options for tdeconfig_compiler +ClassName=Test9 +# +# Singleton=false +# +# Inherits=TDEConfigSkeleton +# +# IncludeFiles=libtdepim/kpimprefs.h +# +MemberVariables=public +# +### The following line includes the file exampleprefs_base_addon.h +### It can be used to add extra functions and variables to the +### class. +# CustomAdditions=true +# +### Provide setFooBar(int) style functions +Mutators=true diff --git a/tdecore/tdeconfig_compiler/tests/test9main.cpp b/tdecore/tdeconfig_compiler/tests/test9main.cpp new file mode 100644 index 000000000..8668d8d8c --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test9main.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2005 Helge Deller + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#include "test9.h" +#include "kinstance.h" +#include +#include + +int main( int, char*[] ) +{ + TDEInstance i("test"); + Test9 *t = new Test9( TQString::null, TQString::null ); + + TQStringList myPathsList2 = t->myPathsList2(); + kdWarning() << myPathsList2 << endl; + + // add another path + TQStringList newlist = TQDir::homeDirPath() + TQString::fromLatin1("/.trinity"); + myPathsList2 = myPathsList2 + newlist; + kdWarning() << myPathsList2 << endl; + + t->setMyPathsList2(myPathsList2); + kdWarning() << t->myPathsList2() << endl; + + delete t; +} diff --git a/tdecore/tdeconfig_compiler/tests/test_dpointer.cpp.ref b/tdecore/tdeconfig_compiler/tests/test_dpointer.cpp.ref new file mode 100644 index 000000000..5aad12fe8 --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test_dpointer.cpp.ref @@ -0,0 +1,344 @@ +// This file is generated by tdeconfig_compiler from test_dpointer.kcfg. +// All changes you do to this file will be lost. + +#include "test_dpointer.h" + +#include + +#include + +class TestDPointerPrivate +{ + public: + + // General + bool autoSave; + int autoSaveInterval; + bool confirm; + TQString archiveFile; + int destination; + + // Views + int hourSize; + bool selectionStartsEditor; + + // KOrganizer Plugins + TQStringList selectedPlugins; + + // Colors + TQColor highlightColor; + TQColor agendaBgColor; + + // Fonts + TQFont timeBarFont; + + // items + TDEConfigSkeleton::ItemBool *autoSaveItem; + TDEConfigSkeleton::ItemInt *autoSaveIntervalItem; + TDEConfigSkeleton::ItemBool *confirmItem; + TDEConfigSkeleton::ItemString *archiveFileItem; + TDEConfigSkeleton::ItemEnum *destinationItem; + TDEConfigSkeleton::ItemInt *hourSizeItem; + TDEConfigSkeleton::ItemBool *selectionStartsEditorItem; + TDEConfigSkeleton::ItemStringList *selectedPluginsItem; + TDEConfigSkeleton::ItemColor *highlightColorItem; + TDEConfigSkeleton::ItemColor *agendaBgColorItem; + TDEConfigSkeleton::ItemFont *timeBarFontItem; +}; + +TestDPointer *TestDPointer::mSelf = 0; +static KStaticDeleter staticTestDPointerDeleter; + +TestDPointer *TestDPointer::self() +{ + if ( !mSelf ) { + staticTestDPointerDeleter.setObject( mSelf, new TestDPointer() ); + mSelf->readConfig(); + } + + return mSelf; +} + +TestDPointer::TestDPointer( ) + : TDEConfigSkeleton( TQString::fromLatin1( "korganizerrc" ) ) +{ + d = new TestDPointerPrivate; + mSelf = this; + setCurrentGroup( TQString::fromLatin1( "General" ) ); + + d->autoSaveItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "Auto Save" ), d->autoSave, false ); + d->autoSaveItem->setLabel( i18n("Enable automatic saving of calendar") ); + d->autoSaveItem->setWhatsThis( i18n("WhatsThis text for AutoSave option") ); + addItem( d->autoSaveItem, TQString::fromLatin1( "AutoSave" ) ); + d->autoSaveIntervalItem = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Auto Save Interval" ), d->autoSaveInterval, 10 ); + d->autoSaveIntervalItem->setLabel( i18n("Auto Save Interval") ); + addItem( d->autoSaveIntervalItem, TQString::fromLatin1( "AutoSaveInterval" ) ); + d->confirmItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "Confirm Deletes" ), d->confirm, true ); + d->confirmItem->setLabel( i18n("Confirm deletes") ); + addItem( d->confirmItem, TQString::fromLatin1( "Confirm" ) ); + d->archiveFileItem = new TDEConfigSkeleton::ItemString( currentGroup(), TQString::fromLatin1( "Archive File" ), d->archiveFile ); + d->archiveFileItem->setLabel( i18n("Archive File") ); + addItem( d->archiveFileItem, TQString::fromLatin1( "ArchiveFile" ) ); + TQValueList valuesDestination; + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "standardDestination" ); + valuesDestination.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "askDestination" ); + valuesDestination.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "argl1" ); + choice.label = i18n("Argl1 Label"); + valuesDestination.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "argl2" ); + choice.whatsThis = i18n("Argl2 Whatsthis"); + valuesDestination.append( choice ); + } + { + TDEConfigSkeleton::ItemEnum::Choice choice; + choice.name = TQString::fromLatin1( "argl3" ); + choice.label = i18n("Argl3 Label"); + choice.whatsThis = i18n("Argl3 Whatsthis"); + valuesDestination.append( choice ); + } + d->destinationItem = new TDEConfigSkeleton::ItemEnum( currentGroup(), TQString::fromLatin1( "Destination" ), d->destination, valuesDestination, EnumDestination::standardDestination ); + d->destinationItem->setLabel( i18n("New Events/Todos Should") ); + addItem( d->destinationItem, TQString::fromLatin1( "Destination" ) ); + + setCurrentGroup( TQString::fromLatin1( "Views" ) ); + + d->hourSizeItem = new TDEConfigSkeleton::ItemInt( currentGroup(), TQString::fromLatin1( "Hour Size" ), d->hourSize, 10 ); + d->hourSizeItem->setLabel( i18n("Hour Size") ); + addItem( d->hourSizeItem, TQString::fromLatin1( "HourSize" ) ); + d->selectionStartsEditorItem = new TDEConfigSkeleton::ItemBool( currentGroup(), TQString::fromLatin1( "SelectionStartsEditor" ), d->selectionStartsEditor, false ); + d->selectionStartsEditorItem->setLabel( i18n("Time range selection in agenda view starts event editor") ); + addItem( d->selectionStartsEditorItem, TQString::fromLatin1( "SelectionStartsEditor" ) ); + + setCurrentGroup( TQString::fromLatin1( "KOrganizer Plugins" ) ); + + TQStringList defaultSelectedPlugins; + defaultSelectedPlugins.append( TQString::fromUtf8( "holidays" ) ); + defaultSelectedPlugins.append( TQString::fromUtf8( "webexport" ) ); + + d->selectedPluginsItem = new TDEConfigSkeleton::ItemStringList( currentGroup(), TQString::fromLatin1( "SelectedPlugins" ), d->selectedPlugins, defaultSelectedPlugins ); + d->selectedPluginsItem->setLabel( i18n("SelectedPlugins") ); + addItem( d->selectedPluginsItem, TQString::fromLatin1( "SelectedPlugins" ) ); + + setCurrentGroup( TQString::fromLatin1( "Colors" ) ); + + d->highlightColorItem = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "Highlight Color" ), d->highlightColor, TQColor( 100, 100, 255 ) ); + d->highlightColorItem->setLabel( i18n("Highlight color") ); + addItem( d->highlightColorItem, TQString::fromLatin1( "HighlightColor" ) ); + d->agendaBgColorItem = new TDEConfigSkeleton::ItemColor( currentGroup(), TQString::fromLatin1( "Agenda Background Color" ), d->agendaBgColor, TQColor( 255, 255, 255 ) ); + d->agendaBgColorItem->setLabel( i18n("Agenda view background color") ); + addItem( d->agendaBgColorItem, TQString::fromLatin1( "AgendaBgColor" ) ); + + setCurrentGroup( TQString::fromLatin1( "Fonts" ) ); + + d->timeBarFontItem = new TDEConfigSkeleton::ItemFont( currentGroup(), TQString::fromLatin1( "TimeBar Font" ), d->timeBarFont ); + d->timeBarFontItem->setLabel( i18n("Time bar") ); + addItem( d->timeBarFontItem, TQString::fromLatin1( "TimeBarFont" ) ); +} + +void TestDPointer::setAutoSave( bool v ) +{ + if (!self()->isImmutable( TQString::fromLatin1( "AutoSave" ) )) + self()->d->autoSave = v; +} + +bool TestDPointer::autoSave() +{ + return self()->d->autoSave; +} + + +TDEConfigSkeleton::ItemBool *TestDPointer::autoSaveItem() +{ + return d->autoSaveItem; +} + +void TestDPointer::setAutoSaveInterval( int v ) +{ + if (!self()->isImmutable( TQString::fromLatin1( "AutoSaveInterval" ) )) + self()->d->autoSaveInterval = v; +} + +int TestDPointer::autoSaveInterval() +{ + return self()->d->autoSaveInterval; +} + + +TDEConfigSkeleton::ItemInt *TestDPointer::autoSaveIntervalItem() +{ + return d->autoSaveIntervalItem; +} + +void TestDPointer::setConfirm( bool v ) +{ + if (!self()->isImmutable( TQString::fromLatin1( "Confirm" ) )) + self()->d->confirm = v; +} + +bool TestDPointer::confirm() +{ + return self()->d->confirm; +} + + +TDEConfigSkeleton::ItemBool *TestDPointer::confirmItem() +{ + return d->confirmItem; +} + +void TestDPointer::setArchiveFile( const TQString & v ) +{ + if (!self()->isImmutable( TQString::fromLatin1( "ArchiveFile" ) )) + self()->d->archiveFile = v; +} + +TQString TestDPointer::archiveFile() +{ + return self()->d->archiveFile; +} + + +TDEConfigSkeleton::ItemString *TestDPointer::archiveFileItem() +{ + return d->archiveFileItem; +} + +void TestDPointer::setDestination( int v ) +{ + if (!self()->isImmutable( TQString::fromLatin1( "Destination" ) )) + self()->d->destination = v; +} + +int TestDPointer::destination() +{ + return self()->d->destination; +} + + +TDEConfigSkeleton::ItemEnum *TestDPointer::destinationItem() +{ + return d->destinationItem; +} + +void TestDPointer::setHourSize( int v ) +{ + if (!self()->isImmutable( TQString::fromLatin1( "HourSize" ) )) + self()->d->hourSize = v; +} + +int TestDPointer::hourSize() +{ + return self()->d->hourSize; +} + + +TDEConfigSkeleton::ItemInt *TestDPointer::hourSizeItem() +{ + return d->hourSizeItem; +} + +void TestDPointer::setSelectionStartsEditor( bool v ) +{ + if (!self()->isImmutable( TQString::fromLatin1( "SelectionStartsEditor" ) )) + self()->d->selectionStartsEditor = v; +} + +bool TestDPointer::selectionStartsEditor() +{ + return self()->d->selectionStartsEditor; +} + + +TDEConfigSkeleton::ItemBool *TestDPointer::selectionStartsEditorItem() +{ + return d->selectionStartsEditorItem; +} + +void TestDPointer::setSelectedPlugins( const TQStringList & v ) +{ + if (!self()->isImmutable( TQString::fromLatin1( "SelectedPlugins" ) )) + self()->d->selectedPlugins = v; +} + +TQStringList TestDPointer::selectedPlugins() +{ + return self()->d->selectedPlugins; +} + + +TDEConfigSkeleton::ItemStringList *TestDPointer::selectedPluginsItem() +{ + return d->selectedPluginsItem; +} + +void TestDPointer::setHighlightColor( const TQColor & v ) +{ + if (!self()->isImmutable( TQString::fromLatin1( "HighlightColor" ) )) + self()->d->highlightColor = v; +} + +TQColor TestDPointer::highlightColor() +{ + return self()->d->highlightColor; +} + + +TDEConfigSkeleton::ItemColor *TestDPointer::highlightColorItem() +{ + return d->highlightColorItem; +} + +void TestDPointer::setAgendaBgColor( const TQColor & v ) +{ + if (!self()->isImmutable( TQString::fromLatin1( "AgendaBgColor" ) )) + self()->d->agendaBgColor = v; +} + +TQColor TestDPointer::agendaBgColor() +{ + return self()->d->agendaBgColor; +} + + +TDEConfigSkeleton::ItemColor *TestDPointer::agendaBgColorItem() +{ + return d->agendaBgColorItem; +} + +void TestDPointer::setTimeBarFont( const TQFont & v ) +{ + if (!self()->isImmutable( TQString::fromLatin1( "TimeBarFont" ) )) + self()->d->timeBarFont = v; +} + +TQFont TestDPointer::timeBarFont() +{ + return self()->d->timeBarFont; +} + + +TDEConfigSkeleton::ItemFont *TestDPointer::timeBarFontItem() +{ + return d->timeBarFontItem; +} + +TestDPointer::~TestDPointer() +{ + delete d; + if ( mSelf == this ) + staticTestDPointerDeleter.setObject( mSelf, 0, false ); +} + diff --git a/tdecore/tdeconfig_compiler/tests/test_dpointer.h.ref b/tdecore/tdeconfig_compiler/tests/test_dpointer.h.ref new file mode 100644 index 000000000..0bd7e771e --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test_dpointer.h.ref @@ -0,0 +1,224 @@ +// This file is generated by tdeconfig_compiler from test_dpointer.kcfg. +// All changes you do to this file will be lost. +#ifndef TESTDPOINTER_H +#define TESTDPOINTER_H + +#include +#include + +class TestDPointerPrivate; + +class TestDPointer : public TDEConfigSkeleton +{ + public: + class EnumDestination + { + public: + enum type { standardDestination, askDestination, argl1, argl2, argl3, COUNT }; + }; + + static TestDPointer *self(); + ~TestDPointer(); + + /** + Set Enable automatic saving of calendar + */ + static + void setAutoSave( bool v ); + + /** + Get Enable automatic saving of calendar + */ + static + bool autoSave(); + + /** + Get Item object corresponding to AutoSave() + */ + ItemBool *autoSaveItem(); + + /** + Set Auto Save Interval + */ + static + void setAutoSaveInterval( int v ); + + /** + Get Auto Save Interval + */ + static + int autoSaveInterval(); + + /** + Get Item object corresponding to AutoSaveInterval() + */ + ItemInt *autoSaveIntervalItem(); + + /** + Set Confirm deletes + */ + static + void setConfirm( bool v ); + + /** + Get Confirm deletes + */ + static + bool confirm(); + + /** + Get Item object corresponding to Confirm() + */ + ItemBool *confirmItem(); + + /** + Set Archive File + */ + static + void setArchiveFile( const TQString & v ); + + /** + Get Archive File + */ + static + TQString archiveFile(); + + /** + Get Item object corresponding to ArchiveFile() + */ + ItemString *archiveFileItem(); + + /** + Set New Events/Todos Should + */ + static + void setDestination( int v ); + + /** + Get New Events/Todos Should + */ + static + int destination(); + + /** + Get Item object corresponding to Destination() + */ + ItemEnum *destinationItem(); + + /** + Set Hour Size + */ + static + void setHourSize( int v ); + + /** + Get Hour Size + */ + static + int hourSize(); + + /** + Get Item object corresponding to HourSize() + */ + ItemInt *hourSizeItem(); + + /** + Set Time range selection in agenda view starts event editor + */ + static + void setSelectionStartsEditor( bool v ); + + /** + Get Time range selection in agenda view starts event editor + */ + static + bool selectionStartsEditor(); + + /** + Get Item object corresponding to SelectionStartsEditor() + */ + ItemBool *selectionStartsEditorItem(); + + /** + Set SelectedPlugins + */ + static + void setSelectedPlugins( const TQStringList & v ); + + /** + Get SelectedPlugins + */ + static + TQStringList selectedPlugins(); + + /** + Get Item object corresponding to SelectedPlugins() + */ + ItemStringList *selectedPluginsItem(); + + /** + Set Highlight color + */ + static + void setHighlightColor( const TQColor & v ); + + /** + Get Highlight color + */ + static + TQColor highlightColor(); + + /** + Get Item object corresponding to HighlightColor() + */ + ItemColor *highlightColorItem(); + + /** + Set Agenda view background color + */ + static + void setAgendaBgColor( const TQColor & v ); + + /** + Get Agenda view background color + */ + static + TQColor agendaBgColor(); + + /** + Get Item object corresponding to AgendaBgColor() + */ + ItemColor *agendaBgColorItem(); + + /** + Set Time bar + */ + static + void setTimeBarFont( const TQFont & v ); + + /** + Get Time bar + */ + static + TQFont timeBarFont(); + + /** + Get Item object corresponding to TimeBarFont() + */ + ItemFont *timeBarFontItem(); + + static + void writeConfig() + { + static_cast(self())->writeConfig(); + } + protected: + TestDPointer(); + static TestDPointer *mSelf; + + private: + TestDPointerPrivate *d; +}; + +#endif + diff --git a/tdecore/tdeconfig_compiler/tests/test_dpointer.kcfg b/tdecore/tdeconfig_compiler/tests/test_dpointer.kcfg new file mode 100644 index 000000000..3b19e270e --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test_dpointer.kcfg @@ -0,0 +1,78 @@ + + + + + + + + WhatsThis text for AutoSave option + false + + + 10 + + + + true + + + + + + + + + + + + + + + Argl2 Whatsthis + + + + Argl3 Whatsthis + + + standardDestination + + + + + + 10 + + + + false + + + + + + holidays,webexport + + + + + + + 100, 100, 255 + + + + 255, 255, 255 + + + + + + + + + + diff --git a/tdecore/tdeconfig_compiler/tests/test_dpointer.kcfgc b/tdecore/tdeconfig_compiler/tests/test_dpointer.kcfgc new file mode 100644 index 000000000..83f4bce3b --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test_dpointer.kcfgc @@ -0,0 +1,11 @@ +# Code generation options for tdeconfig_compiler +File=test_dpointer.kcfg +ClassName=TestDPointer +Singleton=true +Mutators=true +#Inherits=MyPrefs +#IncludeFiles=myprefs.h +MemberVariables=dpointer +#GlobalEnums=true +ItemAccessors=true +SetUserTexts=true diff --git a/tdecore/tdeconfig_compiler/tests/test_dpointer_main.cpp b/tdecore/tdeconfig_compiler/tests/test_dpointer_main.cpp new file mode 100644 index 000000000..b62ee17af --- /dev/null +++ b/tdecore/tdeconfig_compiler/tests/test_dpointer_main.cpp @@ -0,0 +1,30 @@ +/* +Copyright (c) 2005 Duncan Mac-Vicar P. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "test_dpointer.h" +#include "kinstance.h" + +int main( int, char*[] ) +{ + TDEInstance i("test"); + TestDPointer *t = TestDPointer::self(); + delete t; +} diff --git a/tdecore/tdeconfigbackend.cpp b/tdecore/tdeconfigbackend.cpp new file mode 100644 index 000000000..5074f8d22 --- /dev/null +++ b/tdecore/tdeconfigbackend.cpp @@ -0,0 +1,1190 @@ +/* + This file is part of the KDE libraries + Copyright (c) 1999 Preston Brown + Copyright (c) 1997-1999 Matthias Kalle Dalheimer + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include + +#include +#include +#ifdef HAVE_SYS_MMAN_H +#include +#endif +#include +#ifdef HAVE_SYS_STAT_H +#include +#endif +#include +#include +#include + +#include +#include +#include +#include + +#include "tdeconfigbackend.h" +#include "tdeconfigbase.h" +#include +#include +#include +#include +#include +#include +#include +#include + +extern bool checkAccess(const TQString& pathname, int mode); +/* translate escaped escape sequences to their actual values. */ +static TQCString printableToString(const char *str, int l) +{ + // Strip leading white-space. + while((l>0) && + ((*str == ' ') || (*str == '\t') || (*str == '\r'))) + { + str++; l--; + } + + // Strip trailing white-space. + while((l>0) && + ((str[l-1] == ' ') || (str[l-1] == '\t') || (str[l-1] == '\r'))) + { + l--; + } + + TQCString result(l + 1); + char *r = result.data(); + + for(int i = 0; i < l;i++, str++) + { + if (*str == '\\') + { + i++, str++; + if (i >= l) // End of line. (Line ends with single slash) + { + *r++ = '\\'; + break; + } + switch(*str) + { + case 's': + *r++ = ' '; + break; + case 't': + *r++ = '\t'; + break; + case 'n': + *r++ = '\n'; + break; + case 'r': + *r++ = '\r'; + break; + case '\\': + *r++ = '\\'; + break; + default: + *r++ = '\\'; + *r++ = *str; + } + } + else + { + *r++ = *str; + } + } + result.truncate(r-result.data()); + return result; +} + +static TQCString stringToPrintable(const TQCString& str){ + TQCString result(str.length()*2); // Maximum 2x as long as source string + register char *r = const_cast(result).data(); + register char *s = const_cast(str).data(); + + if (!s) return TQCString(""); + + // Escape leading space + if (*s == ' ') + { + *r++ = '\\'; *r++ = 's'; + s++; + } + + if (*s) + { + while(*s) + { + if (*s == '\n') + { + *r++ = '\\'; *r++ = 'n'; + } + else if (*s == '\t') + { + *r++ = '\\'; *r++ = 't'; + } + else if (*s == '\r') + { + *r++ = '\\'; *r++ = 'r'; + } + else if (*s == '\\') + { + *r++ = '\\'; *r++ = '\\'; + } + else + { + *r++ = *s; + } + s++; + } + // Escape trailing space + if (*(r-1) == ' ') + { + *(r-1) = '\\'; *r++ = 's'; + } + } + + result.truncate(r - result.data()); + return result; +} + +static TQCString decodeGroup(const char*s, int l) +{ + TQCString result(l); + register char *r = result.data(); + + l--; // Correct for trailing \0 + while(l) + { + if ((*s == '[') && (l > 1)) + { + if ((*(s+1) == '[')) + { + l--; + s++; + } + } + if ((*s == ']') && (l > 1)) + { + if ((*(s+1) == ']')) + { + l--; + s++; + } + } + *r++ = *s++; + l--; + } + result.truncate(r - result.data()); + return result; +} + +static TQCString encodeGroup(const TQCString &str) +{ + int l = str.length(); + TQCString result(l*2+1); + register char *r = const_cast(result).data(); + register char *s = const_cast(str).data(); + while(l) + { + if ((*s == '[') || (*s == ']')) + *r++ = *s; + *r++ = *s++; + l--; + } + result.truncate(r - result.data()); + return result; +} + +static TQCString encodeKey(const char* key) +{ + TQCString newKey(key); + + newKey.replace('[', "%5b"); + newKey.replace(']', "%5d"); + + return newKey; +} + +static TQCString decodeKey(const char* key) +{ + TQCString newKey(key); + + newKey.replace("%5b", "["); + newKey.replace("%5d", "]"); + + return newKey; +} + +class TDEConfigBackEnd::TDEConfigBackEndPrivate +{ +public: + TQDateTime localLastModified; + uint localLastSize; + KLockFile::Ptr localLockFile; + KLockFile::Ptr globalLockFile; +}; + +void TDEConfigBackEnd::changeFileName(const TQString &_fileName, + const char * _resType, + bool _useKDEGlobals) +{ + mfileName = _fileName; + resType = _resType; + useKDEGlobals = _useKDEGlobals; + if (mfileName.isEmpty()) { + mLocalFileName = TQString::null; + } + else if (!TQDir::isRelativePath(mfileName)) { + mLocalFileName = mfileName; + } + else { + mLocalFileName = TDEGlobal::dirs()->saveLocation(resType, TQString(), false) + mfileName; + } + + if (useKDEGlobals) { + mGlobalFileName = TDEGlobal::dirs()->saveLocation("config", TQString(), false) + TQString::fromLatin1("kdeglobals"); + } + else { + mGlobalFileName = TQString::null; + } + + d->localLastModified = TQDateTime(); + d->localLastSize = 0; + d->localLockFile = 0; + d->globalLockFile = 0; +} + +KLockFile::Ptr TDEConfigBackEnd::lockFile(bool bGlobal) +{ + if (bGlobal) + { + if (d->globalLockFile) + return d->globalLockFile; + + if (!mGlobalFileName.isEmpty()) + { + d->globalLockFile = new KLockFile(mGlobalFileName+".lock"); + return d->globalLockFile; + } + } + else + { + if (d->localLockFile) + return d->localLockFile; + + if (!mLocalFileName.isEmpty()) + { + d->localLockFile = new KLockFile(mLocalFileName+".lock"); + return d->localLockFile; + } + } + return 0; +} + +TDEConfigBackEnd::TDEConfigBackEnd(TDEConfigBase *_config, + const TQString &_fileName, + const char * _resType, + bool _useKDEGlobals) + : pConfig(_config), bFileImmutable(false), mConfigState(TDEConfigBase::NoAccess), mFileMode(-1) +{ + d = new TDEConfigBackEndPrivate; + changeFileName(_fileName, _resType, _useKDEGlobals); +} + +TDEConfigBackEnd::~TDEConfigBackEnd() +{ + delete d; +} + +void TDEConfigBackEnd::setFileWriteMode(int mode) +{ + mFileMode = mode; +} + +bool TDEConfigINIBackEnd::parseConfigFiles() +{ + // Check if we can write to the local file. + mConfigState = TDEConfigBase::ReadOnly; + if (!mLocalFileName.isEmpty() && !pConfig->isReadOnly()) + { + if (checkAccess(mLocalFileName, W_OK)) + { + mConfigState = TDEConfigBase::ReadWrite; + } + else + { + // Create the containing dir, maybe it wasn't there + KURL path; + path.setPath(mLocalFileName); + TQString dir=path.directory(); + KStandardDirs::makeDir(dir); + + if (checkAccess(mLocalFileName, W_OK)) + { + mConfigState = TDEConfigBase::ReadWrite; + } + } + TQFileInfo info(mLocalFileName); + d->localLastModified = info.lastModified(); + d->localLastSize = info.size(); + } + + // Parse all desired files from the least to the most specific. + bFileImmutable = false; + + // Parse the general config files + if (useKDEGlobals) { + TQStringList kdercs = TDEGlobal::dirs()-> + findAllResources("config", TQString::fromLatin1("kdeglobals")); + +#ifdef Q_WS_WIN + TQString etc_kderc = TQFile::decodeName( TQCString(getenv("WINDIR")) + "\\kderc" ); +#else + TQString etc_kderc = TQString::fromLatin1("/etc/kderc"); +#endif + + if (checkAccess(etc_kderc, R_OK)) + kdercs += etc_kderc; + + kdercs += TDEGlobal::dirs()-> + findAllResources("config", TQString::fromLatin1("system.kdeglobals")); + + TQStringList::ConstIterator it; + + for (it = kdercs.fromLast(); it != kdercs.end(); --it) { + + TQFile aConfigFile( *it ); + if (!aConfigFile.open( IO_ReadOnly )) + continue; + parseSingleConfigFile( aConfigFile, 0L, true, (*it != mGlobalFileName) ); + aConfigFile.close(); + if (bFileImmutable) + break; + } + } + + bool bReadFile = !mfileName.isEmpty(); + while(bReadFile) { + bReadFile = false; + TQString bootLanguage; + if (useKDEGlobals && localeString.isEmpty() && !TDEGlobal::_locale) { + // Boot strap language + bootLanguage = KLocale::_initLanguage(pConfig); + setLocaleString(bootLanguage.utf8()); + } + + bFileImmutable = false; + TQStringList list; + if ( !TQDir::isRelativePath(mfileName) ) + list << mfileName; + else + list = TDEGlobal::dirs()->findAllResources(resType, mfileName); + + TQStringList::ConstIterator it; + + for (it = list.fromLast(); it != list.end(); --it) { + + TQFile aConfigFile( *it ); + // we can already be sure that this file exists + bool bIsLocal = (*it == mLocalFileName); + if (aConfigFile.open( IO_ReadOnly )) { + parseSingleConfigFile( aConfigFile, 0L, false, !bIsLocal ); + aConfigFile.close(); + if (bFileImmutable) + break; + } + } + if (TDEGlobal::dirs()->isRestrictedResource(resType, mfileName)) + bFileImmutable = true; + TQString currentLanguage; + if (!bootLanguage.isEmpty()) + { + currentLanguage = KLocale::_initLanguage(pConfig); + // If the file changed the language, we need to read the file again + // with the new language setting. + if (bootLanguage != currentLanguage) + { + bReadFile = true; + setLocaleString(currentLanguage.utf8()); + } + } + } + if (bFileImmutable) + mConfigState = TDEConfigBase::ReadOnly; + + return true; +} + +#ifdef HAVE_MMAP +#ifdef SIGBUS +static sigjmp_buf mmap_jmpbuf; +struct sigaction mmap_old_sigact; + +extern "C" { + static void mmap_sigbus_handler(int) + { + siglongjmp (mmap_jmpbuf, 1); + } +} +#endif +#endif + +extern bool kde_kiosk_exception; + +void TDEConfigINIBackEnd::parseSingleConfigFile(TQFile &rFile, + KEntryMap *pWriteBackMap, + bool bGlobal, bool bDefault) +{ + const char *s; // May get clobbered by sigsetjump, but we don't use them afterwards. + const char *eof; // May get clobbered by sigsetjump, but we don't use them afterwards. + TQByteArray data; + + if (!rFile.isOpen()) // come back, if you have real work for us ;-> + return; + + //using kdDebug() here leads to an infinite loop + //remove this for the release, aleXXX + //tqWarning("Parsing %s, global = %s default = %s", + // rFile.name().latin1(), bGlobal ? "true" : "false", bDefault ? "true" : "false"); + + TQCString aCurrentGroup(""); + + unsigned int ll = localeString.length(); + +#ifdef HAVE_MMAP + static volatile const char *map; + map = ( const char* ) mmap(0, rFile.size(), PROT_READ, MAP_PRIVATE, + rFile.handle(), 0); + + if ( map != MAP_FAILED ) + { + s = (const char*) map; + eof = s + rFile.size(); + +#ifdef SIGBUS + struct sigaction act; + act.sa_handler = mmap_sigbus_handler; + sigemptyset( &act.sa_mask ); +#ifdef SA_ONESHOT + act.sa_flags = SA_ONESHOT; +#else + act.sa_flags = SA_RESETHAND; +#endif + sigaction( SIGBUS, &act, &mmap_old_sigact ); + + if (sigsetjmp (mmap_jmpbuf, 1)) + { +tqWarning("SIGBUS while reading %s", rFile.name().latin1()); + munmap(( char* )map, rFile.size()); + sigaction (SIGBUS, &mmap_old_sigact, 0); + return; + } +#endif + } + else +#endif + { + rFile.at(0); + data = rFile.readAll(); + s = data.data(); + eof = s + data.size(); + } + + bool fileOptionImmutable = false; + bool groupOptionImmutable = false; + bool groupSkip = false; + bool foundGettextDomain = false; + TQCString gettextDomain; + + int line = 0; + for(; s < eof; s++) + { + line++; + + while((s < eof) && isspace(*s) && (*s != '\n')) + s++; //skip leading whitespace, shouldn't happen too often + + //skip empty lines, lines starting with # + if ((s < eof) && ((*s == '\n') || (*s == '#'))) + { + sktoeol: //skip till end-of-line + while ((s < eof) && (*s != '\n')) + s++; + continue; // Empty or comment or no keyword + } + const char *startLine = s; + + if (*s == '[') //group + { + // In a group [[ and ]] have a special meaning + while ((s < eof) && (*s != '\n')) + { + if (*s == ']') + { + if ((s+1 < eof) && (*(s+1) == ']')) + s++; // Skip "]]" + else + break; + } + + s++; // Search till end of group + } + const char *e = s; + while ((s < eof) && (*s != '\n')) s++; // Search till end of line / end of file + if ((e >= eof) || (*e != ']')) + { + fprintf(stderr, "Invalid group header at %s:%d\n", rFile.name().latin1(), line); + continue; + } + // group found; get the group name by taking everything in + // between the brackets + if ((e-startLine == 3) && + (startLine[1] == '$') && + (startLine[2] == 'i')) + { + if (!kde_kiosk_exception) + fileOptionImmutable = true; + continue; + } + + aCurrentGroup = decodeGroup(startLine + 1, e - startLine); + //cout<<"found group ["<lookupData(groupKey); + groupSkip = entry.bImmutable; + + if (groupSkip && !bDefault) + continue; + + entry.bImmutable |= groupOptionImmutable; + pConfig->putData(groupKey, entry, false); + + if (pWriteBackMap) + { + // add the special group key indicator + (*pWriteBackMap)[groupKey] = entry; + } + + continue; + } + if (groupSkip && !bDefault) + goto sktoeol; // Skip entry + + + bool optionImmutable = groupOptionImmutable; + bool optionDeleted = false; + bool optionExpand = false; + const char *endOfKey = 0, *locale = 0, *elocale = 0; + for (; (s < eof) && (*s != '\n'); s++) + { + if (*s == '=') //find the equal sign + { + if (!endOfKey) + endOfKey = s; + goto haveeq; + } + if (*s == '[') //find the locale or options. + { + const char *option; + const char *eoption; + endOfKey = s; + option = ++s; + for (;; s++) + { + if ((s >= eof) || (*s == '\n') || (*s == '=')) { + fprintf(stderr, "Invalid entry (missing ']') at %s:%d\n", rFile.name().latin1(), line); + goto sktoeol; + } + if (*s == ']') + break; + } + eoption = s; + if (*option != '$') + { + // Locale + if (locale) { + fprintf(stderr, "Invalid entry (second locale!?) at %s:%d\n", rFile.name().latin1(), line); + goto sktoeol; + } + locale = option; + elocale = eoption; + } + else + { + // Option + while (option < eoption) + { + option++; + if ((*option == 'i') && !kde_kiosk_exception) + optionImmutable = true; + else if (*option == 'e') + optionExpand = true; + else if (*option == 'd') + { + optionDeleted = true; + goto haveeq; + } + else if (*option == ']') + break; + } + } + } + } + fprintf(stderr, "Invalid entry (missing '=') at %s:%d\n", rFile.name().latin1(), line); + continue; + + haveeq: + for (endOfKey--; ; endOfKey--) + { + if (endOfKey < startLine) + { + fprintf(stderr, "Invalid entry (empty key) at %s:%d\n", rFile.name().latin1(), line); + goto sktoeol; + } + if (!isspace(*endOfKey)) + break; + } + + const char *st = ++s; + while ((s < eof) && (*s != '\n')) s++; // Search till end of line / end of file + + if (locale) { + unsigned int cl = static_cast(elocale - locale); + if ((ll != cl) || memcmp(locale, localeString.data(), ll)) + { + // backward compatibility. C == en_US + if ( cl != 1 || ll != 5 || *locale != 'C' || memcmp(localeString.data(), "en_US", 5)) { + //cout<<"mismatched locale '"<insert(aEntryKey, aEntry); + } else { + // directly insert value into config object + // no need to specify localization; if the key we just + // retrieved was localized already, no need to localize it again. + pConfig->putData(aEntryKey, aEntry, false); + } + } + // Look up translations using KLocale + // https://launchpad.net/distros/ubuntu/+spec/langpacks-desktopfiles-kde + // This calls KLocale up to 10 times for each config file (and each TDEConfig has up to 4 files) + // so I'll see how much of a performance hit it is + // it also only acts on the last group in a file + // Ideas: only translate most important fields, only translate "Desktop Entry" files, + // do translation per TDEConfig not per single file + if (!pWriteBackMap) { + TQFile file("file.txt"); + if (foundGettextDomain) { + + KLocale locale(gettextDomain); + + TQString language = locale.language(); + translateKey(locale, aCurrentGroup, TQCString("Name")); + translateKey(locale, aCurrentGroup, TQCString("Comment")); + translateKey(locale, aCurrentGroup, TQCString("Language")); + translateKey(locale, aCurrentGroup, TQCString("Keywords")); + translateKey(locale, aCurrentGroup, TQCString("About")); + translateKey(locale, aCurrentGroup, TQCString("Description")); + translateKey(locale, aCurrentGroup, TQCString("GenericName")); + translateKey(locale, aCurrentGroup, TQCString("Query")); + translateKey(locale, aCurrentGroup, TQCString("ExtraNames")); + translateKey(locale, aCurrentGroup, TQCString("X-TDE-Submenu")); + } + } + + + if (fileOptionImmutable) + bFileImmutable = true; + +#ifdef HAVE_MMAP + if (map) + { + munmap(( char* )map, rFile.size()); +#ifdef SIGBUS + sigaction (SIGBUS, &mmap_old_sigact, 0); +#endif + } +#endif +} + +void TDEConfigINIBackEnd::translateKey(KLocale& locale, TQCString currentGroup, TQCString key) { + KEntryKey entryKey = KEntryKey(currentGroup, key); + KEntry entry = pConfig->lookupData(entryKey); + if (TQString(entry.mValue) != "") { + TQString orig = key + "=" + entry.mValue; + TQString translate = locale.translate(key + "=" + entry.mValue); + if (TQString::compare(orig, translate) != 0) { + translate = translate.mid(key.length() + 1); + entry.mValue = translate.utf8(); + entryKey.bLocal = true; + entry.bNLS = true; + pConfig->putData(entryKey, entry, false); + } + } +} + +void TDEConfigINIBackEnd::sync(bool bMerge) +{ + // write-sync is only necessary if there are dirty entries + if (!pConfig->isDirty()) + return; + + bool bEntriesLeft = true; + + // find out the file to write to (most specific writable file) + // try local app-specific file first + + if (!mfileName.isEmpty()) { + // Create the containing dir if needed + if ((resType!="config") && !TQDir::isRelativePath(mLocalFileName)) + { + KURL path; + path.setPath(mLocalFileName); + TQString dir=path.directory(); + KStandardDirs::makeDir(dir); + } + + // Can we allow the write? We can, if the program + // doesn't run SUID. But if it runs SUID, we must + // check if the user would be allowed to write if + // it wasn't SUID. + if (checkAccess(mLocalFileName, W_OK)) { + // File is writable + KLockFile::Ptr lf; + + bool mergeLocalFile = bMerge; + // Check if the file has been updated since. + if (mergeLocalFile) + { + lf = lockFile(false); // Lock file for local file + if (lf && lf->isLocked()) + lf = 0; // Already locked, we don't need to lock/unlock again + + if (lf) + { + lf->lock( KLockFile::LockForce ); + // But what if the locking failed? Ignore it for now... + } + + TQFileInfo info(mLocalFileName); + if ((d->localLastSize == info.size()) && + (d->localLastModified == info.lastModified())) + { + // Not changed, don't merge. + mergeLocalFile = false; + } + else + { + // Changed... + d->localLastModified = TQDateTime(); + d->localLastSize = 0; + } + } + + bEntriesLeft = writeConfigFile( mLocalFileName, false, mergeLocalFile ); + + // Only if we didn't have to merge anything can we use our in-memory state + // the next time around. Otherwise the config-file may contain entries + // that are different from our in-memory state which means we will have to + // do a merge from then on. + // We do not automatically update the in-memory state with the on-disk + // state when writing the config to disk. We only do so when + // KCOnfig::reparseConfiguration() is called. + // For KDE 4.0 we may wish to reconsider that. + if (!mergeLocalFile) + { + TQFileInfo info(mLocalFileName); + d->localLastModified = info.lastModified(); + d->localLastSize = info.size(); + } + if (lf) lf->unlock(); + } + } + + // only write out entries to the kdeglobals file if there are any + // entries marked global (indicated by bEntriesLeft) and + // the useKDEGlobals flag is set. + if (bEntriesLeft && useKDEGlobals) { + + // can we allow the write? (see above) + if (checkAccess ( mGlobalFileName, W_OK )) { + KLockFile::Ptr lf = lockFile(true); // Lock file for global file + if (lf && lf->isLocked()) + lf = 0; // Already locked, we don't need to lock/unlock again + + if (lf) + { + lf->lock( KLockFile::LockForce ); + // But what if the locking failed? Ignore it for now... + } + writeConfigFile( mGlobalFileName, true, bMerge ); // Always merge + if (lf) lf->unlock(); + } + } + +} + +static void writeEntries(FILE *pStream, const KEntryMap& entryMap, bool defaultGroup, bool &firstEntry, const TQCString &localeString) +{ + // now write out all other groups. + TQCString currentGroup; + for (KEntryMapConstIterator aIt = entryMap.begin(); + aIt != entryMap.end(); ++aIt) + { + const KEntryKey &key = aIt.key(); + + // Either proces the default group or all others + if ((key.mGroup != "") == defaultGroup) + continue; // Skip + + // Skip default values and group headers. + if ((key.bDefault) || key.mKey.isEmpty()) + continue; // Skip + + const KEntry ¤tEntry = *aIt; + + KEntryMapConstIterator aTestIt = aIt; + ++aTestIt; + bool hasDefault = (aTestIt != entryMap.end()); + if (hasDefault) + { + const KEntryKey &defaultKey = aTestIt.key(); + if ((!defaultKey.bDefault) || + (defaultKey.mKey != key.mKey) || + (defaultKey.mGroup != key.mGroup) || + (defaultKey.bLocal != key.bLocal)) + hasDefault = false; + } + + + if (hasDefault) + { + // Entry had a default value + if ((currentEntry.mValue == (*aTestIt).mValue) && + (currentEntry.bDeleted == (*aTestIt).bDeleted)) + continue; // Same as default, don't write. + } + else + { + // Entry had no default value. + if (currentEntry.bDeleted) + continue; // Don't write deleted entries if there is no default. + } + + if (!defaultGroup && (currentGroup != key.mGroup)) { + if (!firstEntry) + fprintf(pStream, "\n"); + currentGroup = key.mGroup; + fprintf(pStream, "[%s]\n", encodeGroup(currentGroup).data()); + } + + firstEntry = false; + // it is data for a group + fputs(encodeKey(key.mKey.data()), pStream); // Key + + if ( currentEntry.bNLS ) + { + fputc('[', pStream); + fputs(localeString.data(), pStream); + fputc(']', pStream); + } + + if (currentEntry.bDeleted) + { + fputs("[$d]\n", pStream); // Deleted + } + else + { + if (currentEntry.bImmutable || currentEntry.bExpand) + { + fputc('[', pStream); + fputc('$', pStream); + if (currentEntry.bImmutable) + fputc('i', pStream); + if (currentEntry.bExpand) + fputc('e', pStream); + + fputc(']', pStream); + } + fputc('=', pStream); + fputs(stringToPrintable(currentEntry.mValue).data(), pStream); + fputc('\n', pStream); + } + } // for loop +} + +bool TDEConfigINIBackEnd::getEntryMap(KEntryMap &aTempMap, bool bGlobal, + TQFile *mergeFile) +{ + bool bEntriesLeft = false; + bFileImmutable = false; + + // Read entries from disk + if (mergeFile && mergeFile->open(IO_ReadOnly)) + { + // fill the temporary structure with entries from the file + parseSingleConfigFile(*mergeFile, &aTempMap, bGlobal, false ); + + if (bFileImmutable) // File has become immutable on disk + return bEntriesLeft; + } + + KEntryMap aMap = pConfig->internalEntryMap(); + + // augment this structure with the dirty entries from the config object + for (KEntryMapIterator aIt = aMap.begin(); + aIt != aMap.end(); ++aIt) + { + const KEntry ¤tEntry = *aIt; + if(aIt.key().bDefault) + { + aTempMap.replace(aIt.key(), currentEntry); + continue; + } + + if (mergeFile && !currentEntry.bDirty) + continue; + + // only write back entries that have the same + // "globality" as the file + if (currentEntry.bGlobal != bGlobal) + { + // wrong "globality" - might have to be saved later + bEntriesLeft = true; + continue; + } + + // put this entry from the config object into the + // temporary map, possibly replacing an existing entry + KEntryMapIterator aIt2 = aTempMap.find(aIt.key()); + if (aIt2 != aTempMap.end() && (*aIt2).bImmutable) + continue; // Bail out if the on-disk entry is immutable + + aTempMap.insert(aIt.key(), currentEntry, true); + } // loop + + return bEntriesLeft; +} + +/* antlarr: KDE 4.0: make the first parameter "const TQString &" */ +bool TDEConfigINIBackEnd::writeConfigFile(TQString filename, bool bGlobal, + bool bMerge) +{ + // is the config object read-only? + if (pConfig->isReadOnly()) + return true; // pretend we wrote it + + KEntryMap aTempMap; + TQFile *mergeFile = (bMerge ? new TQFile(filename) : 0); + bool bEntriesLeft = getEntryMap(aTempMap, bGlobal, mergeFile); + delete mergeFile; + if (bFileImmutable) + return true; // pretend we wrote it + + // OK now the temporary map should be full of ALL entries. + // write it out to disk. + + // Check if file exists: + int fileMode = -1; + bool createNew = true; + + KDE_struct_stat buf; + if (KDE_stat(TQFile::encodeName(filename), &buf) == 0) + { + if (buf.st_uid == getuid()) + { + // Preserve file mode if file exists and is owned by user. + fileMode = buf.st_mode & 0777; + } + else + { + // File is not owned by user: + // Don't create new file but write to existing file instead. + createNew = false; + } + } + + KSaveFile *pConfigFile = 0; + FILE *pStream = 0; + + if (createNew) + { + pConfigFile = new KSaveFile( filename, 0600 ); + + if (pConfigFile->status() != 0) + { + delete pConfigFile; + return bEntriesLeft; + } + + if (!bGlobal && (fileMode == -1)) + fileMode = mFileMode; + + if (fileMode != -1) + { + fchmod(pConfigFile->handle(), fileMode); + } + + pStream = pConfigFile->fstream(); + } + else + { + // Open existing file. + // We use open() to ensure that we call without O_CREAT. + int fd = KDE_open( TQFile::encodeName(filename), O_WRONLY | O_TRUNC ); + if (fd < 0) + { + return bEntriesLeft; + } + pStream = KDE_fdopen( fd, "w"); + if (!pStream) + { + close(fd); + return bEntriesLeft; + } + } + + writeEntries(pStream, aTempMap); + + if (pConfigFile) + { + bool bEmptyFile = (ftell(pStream) == 0); + if ( bEmptyFile && ((fileMode == -1) || (fileMode == 0600)) ) + { + // File is empty and doesn't have special permissions: delete it. + ::unlink(TQFile::encodeName(filename)); + pConfigFile->abort(); + } + else + { + // Normal case: Close the file + pConfigFile->close(); + } + delete pConfigFile; + } + else + { + fclose(pStream); + } + + return bEntriesLeft; +} + +void TDEConfigINIBackEnd::writeEntries(FILE *pStream, const KEntryMap &aTempMap) +{ + bool firstEntry = true; + + // Write default group + ::writeEntries(pStream, aTempMap, true, firstEntry, localeString); + + // Write all other groups + ::writeEntries(pStream, aTempMap, false, firstEntry, localeString); +} + +void TDEConfigBackEnd::virtual_hook( int, void* ) +{ /*BASE::virtual_hook( id, data );*/ } + +void TDEConfigINIBackEnd::virtual_hook( int id, void* data ) +{ TDEConfigBackEnd::virtual_hook( id, data ); } + +bool TDEConfigBackEnd::checkConfigFilesWritable(bool warnUser) +{ + // WARNING: Do NOT use the event loop as it may not exist at this time. + bool allWritable = true; + TQString errorMsg; + if ( !mLocalFileName.isEmpty() && !bFileImmutable && !checkAccess(mLocalFileName,W_OK) ) + { + errorMsg = i18n("Will not save configuration.\n"); + allWritable = false; + errorMsg += i18n("Configuration file \"%1\" not writable.\n").arg(mLocalFileName); + } + // We do not have an immutability flag for kdeglobals. However, making kdeglobals mutable while making + // the local config file immutable is senseless. + if ( !mGlobalFileName.isEmpty() && useKDEGlobals && !bFileImmutable && !checkAccess(mGlobalFileName,W_OK) ) + { + if ( errorMsg.isEmpty() ) + errorMsg = i18n("Will not save configuration.\n"); + errorMsg += i18n("Configuration file \"%1\" not writable.\n").arg(mGlobalFileName); + allWritable = false; + } + + if (warnUser && !allWritable) + { + // Note: We don't ask the user if we should not ask this question again because we can't save the answer. + errorMsg += i18n("Please contact your system administrator."); + TQString cmdToExec = KStandardDirs::findExe(TQString("kdialog")); + TDEApplication *app = kapp; + if (!cmdToExec.isEmpty() && app) + { + TDEProcess lprocess; + lprocess << cmdToExec << "--title" << app->instanceName() << "--msgbox" << TQCString(errorMsg.local8Bit()); + lprocess.start( TDEProcess::Block ); + } + } + return allWritable; +} diff --git a/tdecore/tdeconfigbackend.h b/tdecore/tdeconfigbackend.h new file mode 100644 index 000000000..c1092364c --- /dev/null +++ b/tdecore/tdeconfigbackend.h @@ -0,0 +1,299 @@ +/* + This file is part of the KDE libraries + Copyright (c) 1999 Preston Brown + Portions copyright (c) 1997 Matthias Kalle Dalheimer + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _KCONFIGBACKEND_H +#define _KCONFIGBACKEND_H + +#include "tdeconfigdata.h" +#include +#include +#include +#include "tdelibs_export.h" + +class TQFile; +class TDEConfigBackEndPrivate; + +/** + * Abstract base class for KDE configuration file loading/saving. + * + * This class forms the base for all classes that implement some + * manner of loading/saving to configuration files. It is an + * abstract base class, meaning that you cannot directly instantiate + * objects of this class. As of right now, the only back end available + * is one to read/write to INI-style files, but in the future, other + * formats may be available, such as XML or a database. + * + * @author Preston Brown , + * Matthias Kalle Dalheimer + * @short KDE Configuration file loading/saving abstract base class + */ +class TDECORE_EXPORT TDEConfigBackEnd +{ + friend class TDEConfig; + friend class KSharedConfig; +public: + /** + * Constructs a configuration back end. + * + * @param _config Specifies the configuration object which values + * will be passed to as they are read, or from where values + * to be written to will be obtained from. + * @param _fileName The name of the file in which config + * data is stored. All registered configuration directories + * will be looked in in order of decreasing relevance. + * @param _resType the resource type of the fileName specified, _if_ + * it is not an absolute path (otherwise this parameter is ignored). + * @param _useKDEGlobals If true, the user's system-wide kdeglobals file + * will be imported into the config object. If false, only + * the filename specified will be dealt with. + */ + TDEConfigBackEnd(TDEConfigBase *_config, const TQString &_fileName, + const char * _resType, bool _useKDEGlobals); + + /** + * Destructs the configuration backend. + */ + virtual ~TDEConfigBackEnd(); + + /** + * Parses all configuration files for a configuration object. This + * method must be reimplemented by the derived classes. + * + * @returns Whether or not parsing was successful. + */ + virtual bool parseConfigFiles() = 0; + + /** + * Writes configuration data to file(s). This method must be + * reimplemented by the derived classes. + * + * @param bMerge Specifies whether the old config file already + * on disk should be merged in with the data in memory. If true, + * data is read off the disk and merged. If false, the on-disk + * file is removed and only in-memory data is written out. + */ + virtual void sync(bool bMerge = true) = 0; + + /** + * Changes the filenames associated with this back end. You should + * probably reparse your config info after doing this. + * + * @param _fileName the new filename to use + * @param _resType the resource type of the fileName specified, _if_ + * it is not an absolute path (otherwise this parameter is ignored). + * @param _useKDEGlobals specifies whether or not to also parse the + * global KDE configuration files. + */ + void changeFileName(const TQString &_fileName, const char * _resType, + bool _useKDEGlobals); + + /** + * Returns the state of the app-config object. + * + * @see TDEConfig::getConfigState + */ + virtual TDEConfigBase::ConfigState getConfigState() const + { return mConfigState; } + + /** + * Returns the filename as passed to the constructor. + * @return the filename as passed to the constructor. + */ + TQString fileName() const { return mfileName; } + + /** + * Returns the resource type as passed to the constructor. + * @return the resource type as passed to the constructor. + */ + const char * resource() const { return resType; } + + /** + * Set the locale string that defines the current language. + * @param _localeString the identifier of the language + * @see KLocale + */ + void setLocaleString(const TQCString &_localeString) { localeString = _localeString; } + + /** + * Set the file mode for newly created files. + * @param mode the filemode (as in chmod) + */ + void setFileWriteMode(int mode); + + /** + * Check whether the config files are writable. + * @param warnUser Warn the user if the configuration files are not writable. + * @return Indicates that all of the configuration files used are writable. + * @since 3.2 + */ + bool checkConfigFilesWritable(bool warnUser); + + /** + * Returns a lock file object for the configuration file + * @param bGlobal If true, returns a lock file object for kdeglobals + * @since 3.3 + */ + KLockFile::Ptr lockFile( bool bGlobal = false ); + +#ifdef KDE_NO_COMPAT +private: +#endif + /** + * @deprecated Use fileName() instead + */ + KDE_DEPRECATED TQString filename() const { return mfileName; } + +protected: + TDEConfigBase *pConfig; + + TQString mfileName; + TQCString resType; + bool useKDEGlobals : 1; + bool bFileImmutable : 1; + TQCString localeString; + TQString mLocalFileName; + TQString mGlobalFileName; + TDEConfigBase::ConfigState mConfigState; + int mFileMode; + +protected: + virtual void virtual_hook( int id, void* data ); +protected: + class TDEConfigBackEndPrivate; + TDEConfigBackEndPrivate *d; +}; + + +/** + * Class for KDE INI-style configuration file loading/saving. + * + * @author Preston Brown , + * Matthias Kalle Dalheimer + */ +class TDECORE_EXPORT TDEConfigINIBackEnd : public TDEConfigBackEnd +{ + +public: + /** + * Constructs an ini-style configuration back end. + * + * @param _config Specifies the configuration object which values + * will be passed to as they are read, or from where values + * to be written to will be obtained from. + * @param _fileName The name of the file in which config + * data is stored. All registered configuration directories + * will be looked in in order of decreasing relevance. + * @param _resType the resource type of the fileName specified, _if_ + * it is not an absolute path (otherwise this parameter is ignored). + * @param _useKDEGlobals If true, the user's system-wide kdeglobals file + * will be imported into the config object. If false, only + * the filename specified will be dealt with. + */ + TDEConfigINIBackEnd(TDEConfigBase *_config, const TQString &_fileName, + const char * _resType, bool _useKDEGlobals = true) + : TDEConfigBackEnd(_config, _fileName, _resType, _useKDEGlobals) {} + + /** + * Destructs the configuration backend. + */ + virtual ~TDEConfigINIBackEnd() {} + + /** + * Parses all INI-style configuration files for a config object. + * + * @returns Whether or not parsing was successful. + */ + bool parseConfigFiles(); + + /** + * Writes configuration data to file(s). + * @param bMerge Specifies whether the old config file already + * on disk should be merged in with the data in memory. If true, + * data is read off the disk and merged. If false, the on-disk + * file is removed and only in-memory data is written out. + */ + virtual void sync(bool bMerge = true); + +protected: + /** + * Parses one configuration file. + * + * @param rFile The configuration file to parse + * @param pWriteBackMap If specified, points to a KEntryMap where + * the data read from the file should be stored, instead of + * inserting them directly into the configuration object. + * Use this area as a "scratchpad" when you need to know what is + * on disk but don't want to effect the configuration object. + * @param bGlobal Specifies whether entries should be marked as + * belonging to the global KDE configuration file rather + * than the application-specific KDE configuration file(s). + * @param bDefault Specifies whether entries should be marked as + * being default values. + */ + void parseSingleConfigFile(TQFile& rFile, KEntryMap *pWriteBackMap = 0L, + bool bGlobal = false, bool bDefault = false); + + // Kubuntu patch, 2006-08-03 + // looks up a key in with KLocale + // see https://launchpad.net/distros/ubuntu/+spec/langpacks-desktopfiles-kde + void translateKey(KLocale& locale, TQCString currentGroup, TQCString key); + + /** + * Writes configuration file back. + * + * @param filename The name of the file to write. + * @param bGlobal Specifies whether to write only entries which + * are marked as belonging to the global KDE config file. + * If this is false, it skips those entries. + * @param bMerge Specifies whether the old config file already + * on disk should be merged in with the data in memory. If true, + * data is read off the disk and merged. If false, the on-disk + * file is removed and only in-memory data is written out. + * @return Whether some entries are left to be written to other + * files. + */ + bool writeConfigFile(TQString filename, bool bGlobal = false, bool bMerge = true); + + /** Get the entry map. + * + * @param map the entries will be stored in this object. + * @param bGlobal Specifies whether to get only entries which + * are marked as belonging to the global KDE config file. + * If this is false, it skips those entries. + * @param mergeFile if not null, the dirty entries for this file will + * be merged. + * + * @return Whether there will be some entries left for writing to other + * files. + */ + bool getEntryMap(KEntryMap &map, bool bGlobal, TQFile *mergeFile); + + /** Write the entries in @e aTempMap to the file stream.*/ + void writeEntries(FILE *pStream, const KEntryMap &aTempMap); + +protected: + virtual void virtual_hook( int id, void* data ); +private: + class TDEConfigINIBackEndPrivate; + TDEConfigINIBackEndPrivate *not_d; +}; + +#endif diff --git a/tdecore/tdeconfigbase.cpp b/tdecore/tdeconfigbase.cpp new file mode 100644 index 000000000..b00430f27 --- /dev/null +++ b/tdecore/tdeconfigbase.cpp @@ -0,0 +1,1937 @@ +// -*- c-basic-offset: 2 -*- +/* + This file is part of the KDE libraries + Copyright (c) 1999 Preston Brown + Copyright (c) 1997 Matthias Kalle Dalheimer + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include "tdeconfigbase.h" +#include "tdeconfigbackend.h" +#include "kdebug.h" +#include "kstandarddirs.h" +#include "kstringhandler.h" + +class TDEConfigBase::TDEConfigBasePrivate +{ +public: + TDEConfigBasePrivate() : readDefaults(false) { }; + +public: + bool readDefaults; +}; + +TDEConfigBase::TDEConfigBase() + : backEnd(0L), bDirty(false), bLocaleInitialized(false), + bReadOnly(false), bExpand(false), d(0) +{ + setGroup(TQString::null); +} + +TDEConfigBase::~TDEConfigBase() +{ + delete d; +} + +void TDEConfigBase::setLocale() +{ + bLocaleInitialized = true; + + if (TDEGlobal::locale()) + aLocaleString = TDEGlobal::locale()->language().utf8(); + else + aLocaleString = KLocale::defaultLanguage().utf8(); + if (backEnd) + backEnd->setLocaleString(aLocaleString); +} + +TQString TDEConfigBase::locale() const +{ + return TQString::fromUtf8(aLocaleString); +} + +void TDEConfigBase::setGroup( const TQString& group ) +{ + if ( group.isEmpty() ) + mGroup = ""; + else + mGroup = group.utf8(); +} + +void TDEConfigBase::setGroup( const char *pGroup ) +{ + setGroup(TQCString(pGroup)); +} + +void TDEConfigBase::setGroup( const TQCString &group ) +{ + if ( group.isEmpty() ) + mGroup = ""; + else + mGroup = group; +} + +TQString TDEConfigBase::group() const { + return TQString::fromUtf8(mGroup); +} + +void TDEConfigBase::setDesktopGroup() +{ + mGroup = "Desktop Entry"; +} + +bool TDEConfigBase::hasKey(const TQString &key) const +{ + return hasKey(key.utf8().data()); +} + +bool TDEConfigBase::hasKey(const char *pKey) const +{ + KEntryKey aEntryKey(mGroup, 0); + aEntryKey.c_key = pKey; + aEntryKey.bDefault = readDefaults(); + + if (!locale().isNull()) { + // try the localized key first + aEntryKey.bLocal = true; + KEntry entry = lookupData(aEntryKey); + if (!entry.mValue.isNull()) + return true; + aEntryKey.bLocal = false; + } + + // try the non-localized version + KEntry entry = lookupData(aEntryKey); + return !entry.mValue.isNull(); +} + +bool TDEConfigBase::hasTranslatedKey(const char* pKey) const +{ + KEntryKey aEntryKey(mGroup, 0); + aEntryKey.c_key = pKey; + aEntryKey.bDefault = readDefaults(); + + if (!locale().isNull()) { + // try the localized key first + aEntryKey.bLocal = true; + KEntry entry = lookupData(aEntryKey); + if (!entry.mValue.isNull()) + return true; + aEntryKey.bLocal = false; + } + + return false; +} + +bool TDEConfigBase::hasGroup(const TQString &group) const +{ + return internalHasGroup( group.utf8()); +} + +bool TDEConfigBase::hasGroup(const char *_pGroup) const +{ + return internalHasGroup( TQCString(_pGroup)); +} + +bool TDEConfigBase::hasGroup(const TQCString &_pGroup) const +{ + return internalHasGroup( _pGroup); +} + +bool TDEConfigBase::isImmutable() const +{ + return (getConfigState() != ReadWrite); +} + +bool TDEConfigBase::groupIsImmutable(const TQString &group) const +{ + if (getConfigState() != ReadWrite) + return true; + + KEntryKey groupKey(group.utf8(), 0); + KEntry entry = lookupData(groupKey); + return entry.bImmutable; +} + +bool TDEConfigBase::entryIsImmutable(const TQString &key) const +{ + if (getConfigState() != ReadWrite) + return true; + + KEntryKey entryKey(mGroup, 0); + KEntry aEntryData = lookupData(entryKey); // Group + if (aEntryData.bImmutable) + return true; + + TQCString utf8_key = key.utf8(); + entryKey.c_key = utf8_key.data(); + aEntryData = lookupData(entryKey); // Normal entry + if (aEntryData.bImmutable) + return true; + + entryKey.bLocal = true; + aEntryData = lookupData(entryKey); // Localized entry + return aEntryData.bImmutable; +} + + +TQString TDEConfigBase::readEntryUntranslated( const TQString& pKey, + const TQString& aDefault ) const +{ + return TDEConfigBase::readEntryUntranslated(pKey.utf8().data(), aDefault); +} + + +TQString TDEConfigBase::readEntryUntranslated( const char *pKey, + const TQString& aDefault ) const +{ + TQCString result = readEntryUtf8(pKey); + if (result.isNull()) + return aDefault; + return TQString::fromUtf8(result); +} + + +TQString TDEConfigBase::readEntry( const TQString& pKey, + const TQString& aDefault ) const +{ + return TDEConfigBase::readEntry(pKey.utf8().data(), aDefault); +} + +TQString TDEConfigBase::readEntry( const char *pKey, + const TQString& aDefault ) const +{ + // we need to access _locale instead of the method locale() + // because calling locale() will create a locale object if it + // doesn't exist, which requires TDEConfig, which will create a infinite + // loop, and nobody likes those. + if (!bLocaleInitialized && TDEGlobal::_locale) { + // get around const'ness. + TDEConfigBase *that = const_cast(this); + that->setLocale(); + } + + TQString aValue; + + bool expand = false; + // construct a localized version of the key + // try the localized key first + KEntry aEntryData; + KEntryKey entryKey(mGroup, 0); + entryKey.c_key = pKey; + entryKey.bDefault = readDefaults(); + entryKey.bLocal = true; + aEntryData = lookupData(entryKey); + if (!aEntryData.mValue.isNull()) { + // for GNOME .desktop + aValue = KStringHandler::from8Bit( aEntryData.mValue.data() ); + expand = aEntryData.bExpand; + } else { + entryKey.bLocal = false; + aEntryData = lookupData(entryKey); + if (!aEntryData.mValue.isNull()) { + aValue = TQString::fromUtf8(aEntryData.mValue.data()); + if (aValue.isNull()) + { + static const TQString &emptyString = TDEGlobal::staticQString(""); + aValue = emptyString; + } + expand = aEntryData.bExpand; + } else { + aValue = aDefault; + } + } + + // only do dollar expansion if so desired + if( expand || bExpand ) + { + // check for environment variables and make necessary translations + int nDollarPos = aValue.find( '$' ); + + while( nDollarPos != -1 && nDollarPos+1 < static_cast(aValue.length())) { + // there is at least one $ + if( (aValue)[nDollarPos+1] == '(' ) { + uint nEndPos = nDollarPos+1; + // the next character is no $ + while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!=')') ) + nEndPos++; + nEndPos++; + TQString cmd = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); + + TQString result; + FILE *fs = popen(TQFile::encodeName(cmd).data(), "r"); + if (fs) + { + { + TQTextStream ts(fs, IO_ReadOnly); + result = ts.read().stripWhiteSpace(); + } + pclose(fs); + } + aValue.replace( nDollarPos, nEndPos-nDollarPos, result ); + } else if( (aValue)[nDollarPos+1] != '$' ) { + uint nEndPos = nDollarPos+1; + // the next character is no $ + TQString aVarName; + if (aValue[nEndPos]=='{') + { + while ( (nEndPos <= aValue.length()) && (aValue[nEndPos]!='}') ) + nEndPos++; + nEndPos++; + aVarName = aValue.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); + } + else + { + while ( nEndPos <= aValue.length() && (aValue[nEndPos].isNumber() + || aValue[nEndPos].isLetter() || aValue[nEndPos]=='_' ) ) + nEndPos++; + aVarName = aValue.mid( nDollarPos+1, nEndPos-nDollarPos-1 ); + } + const char* pEnv = 0; + if (!aVarName.isEmpty()) + pEnv = getenv( aVarName.ascii() ); + if( pEnv ) { + // !!! Sergey A. Sukiyazov !!! + // A environment variables may contain values in 8bit + // locale cpecified encoding or in UTF8 encoding. + aValue.replace( nDollarPos, nEndPos-nDollarPos, KStringHandler::from8Bit( pEnv ) ); + } else + aValue.remove( nDollarPos, nEndPos-nDollarPos ); + } else { + // remove one of the dollar signs + aValue.remove( nDollarPos, 1 ); + nDollarPos++; + } + nDollarPos = aValue.find( '$', nDollarPos ); + } + } + + return aValue; +} + +TQCString TDEConfigBase::readEntryUtf8( const char *pKey) const +{ + // We don't try the localized key + KEntryKey entryKey(mGroup, 0); + entryKey.bDefault = readDefaults(); + entryKey.c_key = pKey; + KEntry aEntryData = lookupData(entryKey); + if (aEntryData.bExpand) + { + // We need to do fancy, take the slow route. + return readEntry(pKey, TQString::null).utf8(); + } + return aEntryData.mValue; +} + +TQVariant TDEConfigBase::readPropertyEntry( const TQString& pKey, + TQVariant::Type type ) const +{ + return readPropertyEntry(pKey.utf8().data(), type); +} + +TQVariant TDEConfigBase::readPropertyEntry( const char *pKey, + TQVariant::Type type ) const +{ + TQVariant va; + if ( !hasKey( pKey ) ) return va; + (void)va.cast(type); + return readPropertyEntry(pKey, va); +} + +TQVariant TDEConfigBase::readPropertyEntry( const TQString& pKey, + const TQVariant &aDefault ) const +{ + return readPropertyEntry(pKey.utf8().data(), aDefault); +} + +TQVariant TDEConfigBase::readPropertyEntry( const char *pKey, + const TQVariant &aDefault ) const +{ + if ( !hasKey( pKey ) ) return aDefault; + + TQVariant tmp = aDefault; + + switch( aDefault.type() ) + { + case TQVariant::Invalid: + return TQVariant(); + case TQVariant::String: + return TQVariant( readEntry( pKey, aDefault.toString() ) ); + case TQVariant::StringList: + return TQVariant( readListEntry( pKey ) ); + case TQVariant::List: { + TQStringList strList = readListEntry( pKey ); + TQStringList::ConstIterator it = strList.begin(); + TQStringList::ConstIterator end = strList.end(); + TQValueList list; + + for (; it != end; ++it ) { + tmp = *it; + list.append( tmp ); + } + return TQVariant( list ); + } + case TQVariant::Font: + return TQVariant( readFontEntry( pKey, &tmp.asFont() ) ); + case TQVariant::Point: + return TQVariant( readPointEntry( pKey, &tmp.asPoint() ) ); + case TQVariant::Rect: + return TQVariant( readRectEntry( pKey, &tmp.asRect() ) ); + case TQVariant::Size: + return TQVariant( readSizeEntry( pKey, &tmp.asSize() ) ); + case TQVariant::Color: + return TQVariant( readColorEntry( pKey, &tmp.asColor() ) ); + case TQVariant::Int: + return TQVariant( readNumEntry( pKey, aDefault.toInt() ) ); + case TQVariant::UInt: + return TQVariant( readUnsignedNumEntry( pKey, aDefault.toUInt() ) ); + case TQVariant::LongLong: + return TQVariant( readNum64Entry( pKey, aDefault.toLongLong() ) ); + case TQVariant::ULongLong: + return TQVariant( readUnsignedNum64Entry( pKey, aDefault.toULongLong() ) ); + case TQVariant::Bool: + return TQVariant( readBoolEntry( pKey, aDefault.toBool() ), 0 ); + case TQVariant::Double: + return TQVariant( readDoubleNumEntry( pKey, aDefault.toDouble() ) ); + case TQVariant::DateTime: + return TQVariant( readDateTimeEntry( pKey, &tmp.asDateTime() ) ); + case TQVariant::Date: + return TQVariant(TQT_TQDATE_OBJECT(readDateTimeEntry( pKey, &tmp.asDateTime() ).date())); + + case TQVariant::Pixmap: + case TQVariant::Image: + case TQVariant::Brush: + case TQVariant::Palette: + case TQVariant::ColorGroup: + case TQVariant::Map: + case TQVariant::IconSet: + case TQVariant::CString: + case TQVariant::PointArray: + case TQVariant::Region: + case TQVariant::Bitmap: + case TQVariant::Cursor: + case TQVariant::SizePolicy: + case TQVariant::Time: +#ifdef USE_QT3 + case TQVariant::ByteArray: +#endif // USE_QT3 + case TQVariant::BitArray: + case TQVariant::KeySequence: + case TQVariant::Pen: +#ifdef USE_QT4 + case TQVariant::Char: + case TQVariant::Url: + case TQVariant::Locale: + case TQVariant::RectF: + case TQVariant::SizeF: + case TQVariant::Line: + case TQVariant::LineF: + case TQVariant::PointF: + case TQVariant::RegExp: + case TQVariant::Hash: + case TQVariant::TextLength: + case QVariant::TextFormat: + case TQVariant::Matrix: + case TQVariant::Transform: + case TQVariant::Matrix4x4: + case TQVariant::Vector2D: + case TQVariant::Vector3D: + case TQVariant::Vector4D: + case TQVariant::Quaternion: + case TQVariant::UserType: +#endif // USE_QT4 + break; + } + + Q_ASSERT( 0 ); + return TQVariant(); +} + +int TDEConfigBase::readListEntry( const TQString& pKey, + TQStrList &list, char sep ) const +{ + return readListEntry(pKey.utf8().data(), list, sep); +} + +int TDEConfigBase::readListEntry( const char *pKey, + TQStrList &list, char sep ) const +{ + if( !hasKey( pKey ) ) + return 0; + + TQCString str_list = readEntryUtf8( pKey ); + if (str_list.isEmpty()) + return 0; + + list.clear(); + TQCString value = ""; + int len = str_list.length(); + + for (int i = 0; i < len; i++) { + if (str_list[i] != sep && str_list[i] != '\\') { + value += str_list[i]; + continue; + } + if (str_list[i] == '\\') { + i++; + if ( i < len ) + value += str_list[i]; + continue; + } + // if we fell through to here, we are at a separator. Append + // contents of value to the list + // !!! Sergey A. Sukiyazov !!! + // A TQStrList may contain values in 8bit locale cpecified + // encoding + list.append( value ); + value.truncate(0); + } + + if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] == '\\' ) ) + list.append( value ); + return list.count(); +} + +TQStringList TDEConfigBase::readListEntry( const TQString& pKey, char sep ) const +{ + return readListEntry(pKey.utf8().data(), sep); +} + +TQStringList TDEConfigBase::readListEntry( const char *pKey, char sep ) const +{ + static const TQString& emptyString = TDEGlobal::staticQString(""); + + TQStringList list; + if( !hasKey( pKey ) ) + return list; + TQString str_list = readEntry( pKey ); + if( str_list.isEmpty() ) + return list; + TQString value(emptyString); + int len = str_list.length(); + // obviously too big, but faster than letting each += resize the string. + value.reserve( len ); + for( int i = 0; i < len; i++ ) + { + if( str_list[i] != sep && str_list[i] != '\\' ) + { + value += str_list[i]; + continue; + } + if( str_list[i] == '\\' ) + { + i++; + if ( i < len ) + value += str_list[i]; + continue; + } + TQString finalvalue( value ); + finalvalue.squeeze(); + list.append( finalvalue ); + value.truncate( 0 ); + } + if ( str_list[len-1] != sep || ( len > 1 && str_list[len-2] == '\\' ) ) + { + value.squeeze(); + list.append( value ); + } + return list; +} + +TQStringList TDEConfigBase::readListEntry( const char* pKey, const TQStringList& aDefault, + char sep ) const +{ + if ( !hasKey( pKey ) ) + return aDefault; + else + return readListEntry( pKey, sep ); +} + +TQValueList TDEConfigBase::readIntListEntry( const TQString& pKey ) const +{ + return readIntListEntry(pKey.utf8().data()); +} + +TQValueList TDEConfigBase::readIntListEntry( const char *pKey ) const +{ + TQStringList strlist = readListEntry(pKey); + TQValueList list; + TQStringList::ConstIterator end(strlist.end()); + for (TQStringList::ConstIterator it = strlist.begin(); it != end; ++it) + // I do not check if the toInt failed because I consider the number of items + // more important than their value + list << (*it).toInt(); + + return list; +} + +TQString TDEConfigBase::readPathEntry( const TQString& pKey, const TQString& pDefault ) const +{ + return readPathEntry(pKey.utf8().data(), pDefault); +} + +TQString TDEConfigBase::readPathEntry( const char *pKey, const TQString& pDefault ) const +{ + const bool bExpandSave = bExpand; + bExpand = true; + TQString aValue = readEntry( pKey, pDefault ); + bExpand = bExpandSave; + return aValue; +} + +TQStringList TDEConfigBase::readPathListEntry( const TQString& pKey, char sep ) const +{ + return readPathListEntry(pKey.utf8().data(), sep); +} + +TQStringList TDEConfigBase::readPathListEntry( const char *pKey, char sep ) const +{ + const bool bExpandSave = bExpand; + bExpand = true; + TQStringList aValue = readListEntry( pKey, sep ); + bExpand = bExpandSave; + return aValue; +} + +int TDEConfigBase::readNumEntry( const TQString& pKey, int nDefault) const +{ + return readNumEntry(pKey.utf8().data(), nDefault); +} + +int TDEConfigBase::readNumEntry( const char *pKey, int nDefault) const +{ + TQCString aValue = readEntryUtf8( pKey ); + if( aValue.isNull() ) + return nDefault; + else if( aValue == "true" || aValue == "on" || aValue == "yes" ) + return 1; + else + { + bool ok; + int rc = aValue.toInt( &ok ); + return( ok ? rc : nDefault ); + } +} + + +unsigned int TDEConfigBase::readUnsignedNumEntry( const TQString& pKey, unsigned int nDefault) const +{ + return readUnsignedNumEntry(pKey.utf8().data(), nDefault); +} + +unsigned int TDEConfigBase::readUnsignedNumEntry( const char *pKey, unsigned int nDefault) const +{ + TQCString aValue = readEntryUtf8( pKey ); + if( aValue.isNull() ) + return nDefault; + else + { + bool ok; + unsigned int rc = aValue.toUInt( &ok ); + return( ok ? rc : nDefault ); + } +} + + +long TDEConfigBase::readLongNumEntry( const TQString& pKey, long nDefault) const +{ + return readLongNumEntry(pKey.utf8().data(), nDefault); +} + +long TDEConfigBase::readLongNumEntry( const char *pKey, long nDefault) const +{ + TQCString aValue = readEntryUtf8( pKey ); + if( aValue.isNull() ) + return nDefault; + else + { + bool ok; + long rc = aValue.toLong( &ok ); + return( ok ? rc : nDefault ); + } +} + + +unsigned long TDEConfigBase::readUnsignedLongNumEntry( const TQString& pKey, unsigned long nDefault) const +{ + return readUnsignedLongNumEntry(pKey.utf8().data(), nDefault); +} + +unsigned long TDEConfigBase::readUnsignedLongNumEntry( const char *pKey, unsigned long nDefault) const +{ + TQCString aValue = readEntryUtf8( pKey ); + if( aValue.isNull() ) + return nDefault; + else + { + bool ok; + unsigned long rc = aValue.toULong( &ok ); + return( ok ? rc : nDefault ); + } +} + +TQ_INT64 TDEConfigBase::readNum64Entry( const TQString& pKey, TQ_INT64 nDefault) const +{ + return readNum64Entry(pKey.utf8().data(), nDefault); +} + +TQ_INT64 TDEConfigBase::readNum64Entry( const char *pKey, TQ_INT64 nDefault) const +{ + // Note that TQCString::toLongLong() is missing, we muse use a TQString instead. + TQString aValue = readEntry( pKey ); + if( aValue.isNull() ) + return nDefault; + else + { + bool ok; + TQ_INT64 rc = aValue.toLongLong( &ok ); + return( ok ? rc : nDefault ); + } +} + + +TQ_UINT64 TDEConfigBase::readUnsignedNum64Entry( const TQString& pKey, TQ_UINT64 nDefault) const +{ + return readUnsignedNum64Entry(pKey.utf8().data(), nDefault); +} + +TQ_UINT64 TDEConfigBase::readUnsignedNum64Entry( const char *pKey, TQ_UINT64 nDefault) const +{ + // Note that TQCString::toULongLong() is missing, we muse use a TQString instead. + TQString aValue = readEntry( pKey ); + if( aValue.isNull() ) + return nDefault; + else + { + bool ok; + TQ_UINT64 rc = aValue.toULongLong( &ok ); + return( ok ? rc : nDefault ); + } +} + +double TDEConfigBase::readDoubleNumEntry( const TQString& pKey, double nDefault) const +{ + return readDoubleNumEntry(pKey.utf8().data(), nDefault); +} + +double TDEConfigBase::readDoubleNumEntry( const char *pKey, double nDefault) const +{ + TQCString aValue = readEntryUtf8( pKey ); + if( aValue.isNull() ) + return nDefault; + else + { + bool ok; + double rc = aValue.toDouble( &ok ); + return( ok ? rc : nDefault ); + } +} + + +bool TDEConfigBase::readBoolEntry( const TQString& pKey, bool bDefault ) const +{ + return readBoolEntry(pKey.utf8().data(), bDefault); +} + +bool TDEConfigBase::readBoolEntry( const char *pKey, bool bDefault ) const +{ + TQCString aValue = readEntryUtf8( pKey ); + + if( aValue.isNull() ) + return bDefault; + else + { + if( aValue == "true" || aValue == "on" || aValue == "yes" || aValue == "1" ) + return true; + else + { + bool bOK; + int val = aValue.toInt( &bOK ); + if( bOK && val != 0 ) + return true; + else + return false; + } + } +} + +TQFont TDEConfigBase::readFontEntry( const TQString& pKey, const TQFont* pDefault ) const +{ + return readFontEntry(pKey.utf8().data(), pDefault); +} + +TQFont TDEConfigBase::readFontEntry( const char *pKey, const TQFont* pDefault ) const +{ + TQFont aRetFont; + + TQString aValue = readEntry( pKey ); + if( !aValue.isNull() ) { + if ( aValue.contains( ',' ) > 5 ) { + // KDE3 and upwards entry + if ( !aRetFont.fromString( aValue ) && pDefault ) + aRetFont = *pDefault; + } + else { + // backward compatibility with older font formats + // ### remove KDE 3.1 ? + // find first part (font family) + int nIndex = aValue.find( ',' ); + if( nIndex == -1 ){ + if( pDefault ) + aRetFont = *pDefault; + return aRetFont; + } + aRetFont.setFamily( aValue.left( nIndex ) ); + + // find second part (point size) + int nOldIndex = nIndex; + nIndex = aValue.find( ',', nOldIndex+1 ); + if( nIndex == -1 ){ + if( pDefault ) + aRetFont = *pDefault; + return aRetFont; + } + + aRetFont.setPointSize( aValue.mid( nOldIndex+1, + nIndex-nOldIndex-1 ).toInt() ); + + // find third part (style hint) + nOldIndex = nIndex; + nIndex = aValue.find( ',', nOldIndex+1 ); + + if( nIndex == -1 ){ + if( pDefault ) + aRetFont = *pDefault; + return aRetFont; + } + + aRetFont.setStyleHint( (TQFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() ); + + // find fourth part (char set) + nOldIndex = nIndex; + nIndex = aValue.find( ',', nOldIndex+1 ); + + if( nIndex == -1 ){ + if( pDefault ) + aRetFont = *pDefault; + return aRetFont; + } + + TQString chStr=aValue.mid( nOldIndex+1, + nIndex-nOldIndex-1 ); + // find fifth part (weight) + nOldIndex = nIndex; + nIndex = aValue.find( ',', nOldIndex+1 ); + + if( nIndex == -1 ){ + if( pDefault ) + aRetFont = *pDefault; + return aRetFont; + } + + aRetFont.setWeight( aValue.mid( nOldIndex+1, + nIndex-nOldIndex-1 ).toUInt() ); + + // find sixth part (font bits) + uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt(); + + aRetFont.setItalic( nFontBits & 0x01 ); + aRetFont.setUnderline( nFontBits & 0x02 ); + aRetFont.setStrikeOut( nFontBits & 0x04 ); + aRetFont.setFixedPitch( nFontBits & 0x08 ); + aRetFont.setRawMode( nFontBits & 0x20 ); + } + } + else + { + if( pDefault ) + aRetFont = *pDefault; + } + + return aRetFont; +} + + +TQRect TDEConfigBase::readRectEntry( const TQString& pKey, const TQRect* pDefault ) const +{ + return readRectEntry(pKey.utf8().data(), pDefault); +} + +TQRect TDEConfigBase::readRectEntry( const char *pKey, const TQRect* pDefault ) const +{ + TQCString aValue = readEntryUtf8(pKey); + + if (!aValue.isEmpty()) + { + int left, top, width, height; + + if (sscanf(aValue.data(), "%d,%d,%d,%d", &left, &top, &width, &height) == 4) + { + return TQRect(left, top, width, height); + } + } + if (pDefault) + return *pDefault; + return TQRect(); +} + + +TQPoint TDEConfigBase::readPointEntry( const TQString& pKey, + const TQPoint* pDefault ) const +{ + return readPointEntry(pKey.utf8().data(), pDefault); +} + +TQPoint TDEConfigBase::readPointEntry( const char *pKey, + const TQPoint* pDefault ) const +{ + TQCString aValue = readEntryUtf8(pKey); + + if (!aValue.isEmpty()) + { + int x,y; + + if (sscanf(aValue.data(), "%d,%d", &x, &y) == 2) + { + return TQPoint(x,y); + } + } + if (pDefault) + return *pDefault; + return TQPoint(); +} + +TQSize TDEConfigBase::readSizeEntry( const TQString& pKey, + const TQSize* pDefault ) const +{ + return readSizeEntry(pKey.utf8().data(), pDefault); +} + +TQSize TDEConfigBase::readSizeEntry( const char *pKey, + const TQSize* pDefault ) const +{ + TQCString aValue = readEntryUtf8(pKey); + + if (!aValue.isEmpty()) + { + int width,height; + + if (sscanf(aValue.data(), "%d,%d", &width, &height) == 2) + { + return TQSize(width, height); + } + } + if (pDefault) + return *pDefault; + return TQSize(); +} + + +TQColor TDEConfigBase::readColorEntry( const TQString& pKey, + const TQColor* pDefault ) const +{ + return readColorEntry(pKey.utf8().data(), pDefault); +} + +TQColor TDEConfigBase::readColorEntry( const char *pKey, + const TQColor* pDefault ) const +{ + TQColor aRetColor; + int nRed = 0, nGreen = 0, nBlue = 0; + + TQString aValue = readEntry( pKey ); + if( !aValue.isEmpty() ) + { + if ( aValue.at(0) == (QChar)'#' ) + { + aRetColor.setNamedColor(aValue); + } + else + { + + bool bOK; + + // find first part (red) + int nIndex = aValue.find( ',' ); + + if( nIndex == -1 ){ + // return a sensible default -- Bernd + if( pDefault ) + aRetColor = *pDefault; + return aRetColor; + } + + nRed = aValue.left( nIndex ).toInt( &bOK ); + + // find second part (green) + int nOldIndex = nIndex; + nIndex = aValue.find( ',', nOldIndex+1 ); + + if( nIndex == -1 ){ + // return a sensible default -- Bernd + if( pDefault ) + aRetColor = *pDefault; + return aRetColor; + } + nGreen = aValue.mid( nOldIndex+1, + nIndex-nOldIndex-1 ).toInt( &bOK ); + + // find third part (blue) + nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK ); + + aRetColor.setRgb( nRed, nGreen, nBlue ); + } + } + else { + + if( pDefault ) + aRetColor = *pDefault; + } + + return aRetColor; +} + + +TQDateTime TDEConfigBase::readDateTimeEntry( const TQString& pKey, + const TQDateTime* pDefault ) const +{ + return readDateTimeEntry(pKey.utf8().data(), pDefault); +} + +// ### currentDateTime() as fallback ? (Harri) +TQDateTime TDEConfigBase::readDateTimeEntry( const char *pKey, + const TQDateTime* pDefault ) const +{ + if( !hasKey( pKey ) ) + { + if( pDefault ) + return *pDefault; + else + return TQDateTime::currentDateTime(); + } + + TQStrList list; + int count = readListEntry( pKey, list, ',' ); + if( count == 6 ) { + TQDate date( atoi( list.at( 0 ) ), atoi( list.at( 1 ) ), + atoi( list.at( 2 ) ) ); + TQTime time( atoi( list.at( 3 ) ), atoi( list.at( 4 ) ), + atoi( list.at( 5 ) ) ); + + return TQDateTime( date, time ); + } + + return TQDateTime::currentDateTime(); +} + +void TDEConfigBase::writeEntry( const TQString& pKey, const TQString& value, + bool bPersistent, + bool bGlobal, + bool bNLS ) +{ + writeEntry(pKey.utf8().data(), value, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry( const char *pKey, const TQString& value, + bool bPersistent, + bool bGlobal, + bool bNLS ) +{ + writeEntry(pKey, value, bPersistent, bGlobal, bNLS, false); +} + +void TDEConfigBase::writeEntry( const char *pKey, const TQString& value, + bool bPersistent, + bool bGlobal, + bool bNLS, + bool bExpand ) +{ + // the TDEConfig object is dirty now + // set this before any IO takes place so that if any derivative + // classes do caching, they won't try and flush the cache out + // from under us before we read. A race condition is still + // possible but minimized. + if( bPersistent ) + setDirty(true); + + if (!bLocaleInitialized && TDEGlobal::locale()) + setLocale(); + + KEntryKey entryKey(mGroup, pKey); + entryKey.bLocal = bNLS; + + KEntry aEntryData; + aEntryData.mValue = value.utf8(); // set new value + aEntryData.bGlobal = bGlobal; + aEntryData.bNLS = bNLS; + aEntryData.bExpand = bExpand; + + if (bPersistent) + aEntryData.bDirty = true; + + // rewrite the new value + putData(entryKey, aEntryData, true); +} + +void TDEConfigBase::writePathEntry( const TQString& pKey, const TQString & path, + bool bPersistent, bool bGlobal, + bool bNLS) +{ + writePathEntry(pKey.utf8().data(), path, bPersistent, bGlobal, bNLS); +} + + +static bool cleanHomeDirPath( TQString &path, const TQString &homeDir ) +{ +#ifdef Q_WS_WIN //safer + if (!TQDir::convertSeparators(path).startsWith(TQDir::convertSeparators(homeDir))) + return false; +#else + if (!path.startsWith(homeDir)) + return false; +#endif + + unsigned int len = homeDir.length(); + // replace by "$HOME" if possible + if (len && (path.length() == len || path[len] == '/')) { + path.replace(0, len, TQString::fromLatin1("$HOME")); + return true; + } else + return false; +} + +static TQString translatePath( TQString path ) +{ + if (path.isEmpty()) + return path; + + // only "our" $HOME should be interpreted + path.replace('$', "$$"); + + bool startsWithFile = path.startsWith("file:", false); + + // return original path, if it refers to another type of URL (e.g. http:/), or + // if the path is already relative to another directory + if (((!startsWithFile) && (path[0] != '/')) || (startsWithFile && (path[5] != '/'))) { + return path; + } + + if (startsWithFile) { + path.remove(0,5); // strip leading "file:/" off the string + } + + // keep only one single '/' at the beginning - needed for cleanHomeDirPath() + while (path[0] == '/' && path[1] == '/') { + path.remove(0,1); + } + + // we can not use TDEGlobal::dirs()->relativeLocation("home", path) here, + // since it would not recognize paths without a trailing '/'. + // All of the 3 following functions to return the user's home directory + // can return different paths. We have to test all them. + TQString homeDir0 = TQFile::decodeName(getenv("HOME")); + TQString homeDir1 = TQDir::homeDirPath(); + TQString homeDir2 = TQDir(homeDir1).canonicalPath(); + if (cleanHomeDirPath(path, homeDir0) || + cleanHomeDirPath(path, homeDir1) || + cleanHomeDirPath(path, homeDir2) ) { + // kdDebug() << "Path was replaced\n"; + } + + if (startsWithFile) + path.prepend( "file://" ); + + return path; +} + +void TDEConfigBase::writePathEntry( const char *pKey, const TQString & path, + bool bPersistent, bool bGlobal, + bool bNLS) +{ + writeEntry(pKey, translatePath(path), bPersistent, bGlobal, bNLS, true); +} + +void TDEConfigBase::writePathEntry ( const TQString& pKey, const TQStringList &list, + char sep , bool bPersistent, + bool bGlobal, bool bNLS ) +{ + writePathEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writePathEntry ( const char *pKey, const TQStringList &list, + char sep , bool bPersistent, + bool bGlobal, bool bNLS ) +{ + if( list.isEmpty() ) + { + writeEntry( pKey, TQString::fromLatin1(""), bPersistent ); + return; + } + TQStringList new_list; + TQStringList::ConstIterator it = list.begin(); + for( ; it != list.end(); ++it ) + { + TQString value = *it; + new_list.append( translatePath(value) ); + } + writeEntry( pKey, new_list, sep, bPersistent, bGlobal, bNLS, true ); +} + +void TDEConfigBase::deleteEntry( const TQString& pKey, + bool bNLS, + bool bGlobal) +{ + deleteEntry(pKey.utf8().data(), bNLS, bGlobal); +} + +void TDEConfigBase::deleteEntry( const char *pKey, + bool bNLS, + bool bGlobal) +{ + // the TDEConfig object is dirty now + // set this before any IO takes place so that if any derivative + // classes do caching, they won't try and flush the cache out + // from under us before we read. A race condition is still + // possible but minimized. + setDirty(true); + + if (!bLocaleInitialized && TDEGlobal::locale()) + setLocale(); + + KEntryKey entryKey(mGroup, pKey); + KEntry aEntryData; + + aEntryData.bGlobal = bGlobal; + aEntryData.bNLS = bNLS; + aEntryData.bDirty = true; + aEntryData.bDeleted = true; + + // rewrite the new value + putData(entryKey, aEntryData, true); +} + +bool TDEConfigBase::deleteGroup( const TQString& group, bool bDeep, bool bGlobal ) +{ + KEntryMap aEntryMap = internalEntryMap(group); + + if (!bDeep) { + // Check if it empty + return aEntryMap.isEmpty(); + } + + bool dirty = false; + bool checkGroup = true; + // we want to remove all entries in the group + KEntryMapIterator aIt; + for (aIt = aEntryMap.begin(); aIt != aEntryMap.end(); ++aIt) + { + if (!aIt.key().mKey.isEmpty() && !aIt.key().bDefault && !(*aIt).bDeleted) + { + (*aIt).bDeleted = true; + (*aIt).bDirty = true; + (*aIt).bGlobal = bGlobal; + (*aIt).mValue = 0; + putData(aIt.key(), *aIt, checkGroup); + checkGroup = false; + dirty = true; + } + } + if (dirty) + setDirty(true); + return true; +} + +void TDEConfigBase::writeEntry ( const TQString& pKey, const TQVariant &prop, + bool bPersistent, + bool bGlobal, bool bNLS ) +{ + writeEntry(pKey.utf8().data(), prop, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry ( const char *pKey, const TQVariant &prop, + bool bPersistent, + bool bGlobal, bool bNLS ) +{ + switch( prop.type() ) + { + case TQVariant::Invalid: + writeEntry( pKey, "", bPersistent, bGlobal, bNLS ); + return; + case TQVariant::String: + writeEntry( pKey, prop.toString(), bPersistent, bGlobal, bNLS ); + return; + case TQVariant::StringList: + writeEntry( pKey, prop.toStringList(), ',', bPersistent, bGlobal, bNLS ); + return; + case TQVariant::List: { + TQValueList list = prop.toList(); + TQValueList::ConstIterator it = list.begin(); + TQValueList::ConstIterator end = list.end(); + TQStringList strList; + + for (; it != end; ++it ) + strList.append( (*it).toString() ); + + writeEntry( pKey, strList, ',', bPersistent, bGlobal, bNLS ); + + return; + } + case TQVariant::Font: + writeEntry( pKey, prop.toFont(), bPersistent, bGlobal, bNLS ); + return; + case TQVariant::Point: + writeEntry( pKey, prop.toPoint(), bPersistent, bGlobal, bNLS ); + return; + case TQVariant::Rect: + writeEntry( pKey, prop.toRect(), bPersistent, bGlobal, bNLS ); + return; + case TQVariant::Size: + writeEntry( pKey, prop.toSize(), bPersistent, bGlobal, bNLS ); + return; + case TQVariant::Color: + writeEntry( pKey, prop.toColor(), bPersistent, bGlobal, bNLS ); + return; + case TQVariant::Int: + writeEntry( pKey, prop.toInt(), bPersistent, bGlobal, bNLS ); + return; + case TQVariant::UInt: + writeEntry( pKey, prop.toUInt(), bPersistent, bGlobal, bNLS ); + return; + case TQVariant::LongLong: + writeEntry( pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS ); + return; + case TQVariant::ULongLong: + writeEntry( pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS ); + return; + case TQVariant::Bool: + writeEntry( pKey, prop.toBool(), bPersistent, bGlobal, bNLS ); + return; + case TQVariant::Double: + writeEntry( pKey, prop.toDouble(), bPersistent, bGlobal, 'g', 6, bNLS ); + return; + case TQVariant::DateTime: + writeEntry( pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS); + return; + case TQVariant::Date: + writeEntry( pKey, TQDateTime(prop.toDate()), bPersistent, bGlobal, bNLS); + return; + + case TQVariant::Pixmap: + case TQVariant::Image: + case TQVariant::Brush: + case TQVariant::Palette: + case TQVariant::ColorGroup: + case TQVariant::Map: + case TQVariant::IconSet: + case TQVariant::CString: + case TQVariant::PointArray: + case TQVariant::Region: + case TQVariant::Bitmap: + case TQVariant::Cursor: + case TQVariant::SizePolicy: + case TQVariant::Time: +#ifdef USE_QT3 + case TQVariant::ByteArray: +#endif // USE_QT3 + case TQVariant::BitArray: + case TQVariant::KeySequence: + case TQVariant::Pen: +#ifdef USE_QT4 + case TQVariant::Char: + case TQVariant::Url: + case TQVariant::Locale: + case TQVariant::RectF: + case TQVariant::SizeF: + case TQVariant::Line: + case TQVariant::LineF: + case TQVariant::PointF: + case TQVariant::RegExp: + case TQVariant::Hash: + case TQVariant::TextLength: + case QVariant::TextFormat: + case TQVariant::Matrix: + case TQVariant::Transform: + case TQVariant::Matrix4x4: + case TQVariant::Vector2D: + case TQVariant::Vector3D: + case TQVariant::Vector4D: + case TQVariant::Quaternion: + case TQVariant::UserType: +#endif // USE_QT4 + break; + } + + Q_ASSERT( 0 ); +} + +void TDEConfigBase::writeEntry ( const TQString& pKey, const TQStrList &list, + char sep , bool bPersistent, + bool bGlobal, bool bNLS ) +{ + writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry ( const char *pKey, const TQStrList &list, + char sep , bool bPersistent, + bool bGlobal, bool bNLS ) +{ + if( list.isEmpty() ) + { + writeEntry( pKey, TQString::fromLatin1(""), bPersistent ); + return; + } + TQString str_list; + TQStrListIterator it( list ); + for( ; it.current(); ++it ) + { + uint i; + TQString value; + // !!! Sergey A. Sukiyazov !!! + // A TQStrList may contain values in 8bit locale cpecified + // encoding or in UTF8 encoding. + value = KStringHandler::from8Bit(it.current()); + uint strLengh(value.length()); + for( i = 0; i < strLengh; i++ ) + { + if( value[i] == sep || value[i] == '\\' ) + str_list += '\\'; + str_list += value[i]; + } + str_list += sep; + } + if( str_list.at(str_list.length() - 1) == (QChar)sep ) + str_list.truncate( str_list.length() -1 ); + writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry ( const TQString& pKey, const TQStringList &list, + char sep , bool bPersistent, + bool bGlobal, bool bNLS ) +{ + writeEntry(pKey.utf8().data(), list, sep, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry ( const char *pKey, const TQStringList &list, + char sep , bool bPersistent, + bool bGlobal, bool bNLS ) +{ + writeEntry(pKey, list, sep, bPersistent, bGlobal, bNLS, false); +} + +void TDEConfigBase::writeEntry ( const char *pKey, const TQStringList &list, + char sep, bool bPersistent, + bool bGlobal, bool bNLS, bool bExpand ) +{ + if( list.isEmpty() ) + { + writeEntry( pKey, TQString::fromLatin1(""), bPersistent ); + return; + } + TQString str_list; + str_list.reserve( 4096 ); + TQStringList::ConstIterator it = list.begin(); + for( ; it != list.end(); ++it ) + { + TQString value = *it; + uint i; + uint strLength(value.length()); + for( i = 0; i < strLength; i++ ) + { + if( value[i] == sep || value[i] == '\\' ) + str_list += '\\'; + str_list += value[i]; + } + str_list += sep; + } + if( str_list.at(str_list.length() - 1) == (QChar)sep ) + str_list.truncate( str_list.length() -1 ); + writeEntry( pKey, str_list, bPersistent, bGlobal, bNLS, bExpand ); +} + +void TDEConfigBase::writeEntry ( const TQString& pKey, const TQValueList &list, + bool bPersistent, bool bGlobal, bool bNLS ) +{ + writeEntry(pKey.utf8().data(), list, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry ( const char *pKey, const TQValueList &list, + bool bPersistent, bool bGlobal, bool bNLS ) +{ + TQStringList strlist; + TQValueList::ConstIterator end = list.end(); + for (TQValueList::ConstIterator it = list.begin(); it != end; it++) + strlist << TQString::number(*it); + writeEntry(pKey, strlist, ',', bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const TQString& pKey, int nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const char *pKey, int nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + + +void TDEConfigBase::writeEntry( const TQString& pKey, unsigned int nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const char *pKey, unsigned int nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + + +void TDEConfigBase::writeEntry( const TQString& pKey, long nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const char *pKey, long nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + + +void TDEConfigBase::writeEntry( const TQString& pKey, unsigned long nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const char *pKey, unsigned long nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const TQString& pKey, TQ_INT64 nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const char *pKey, TQ_INT64 nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + + +void TDEConfigBase::writeEntry( const TQString& pKey, TQ_UINT64 nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const char *pKey, TQ_UINT64 nValue, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue), bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const TQString& pKey, double nValue, + bool bPersistent, bool bGlobal, + char format, int precision, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue, format, precision), + bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const char *pKey, double nValue, + bool bPersistent, bool bGlobal, + char format, int precision, + bool bNLS ) +{ + writeEntry( pKey, TQString::number(nValue, format, precision), + bPersistent, bGlobal, bNLS ); +} + + +void TDEConfigBase::writeEntry( const TQString& pKey, bool bValue, + bool bPersistent, + bool bGlobal, + bool bNLS ) +{ + writeEntry(pKey.utf8().data(), bValue, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry( const char *pKey, bool bValue, + bool bPersistent, + bool bGlobal, + bool bNLS ) +{ + TQString aValue; + + if( bValue ) + aValue = "true"; + else + aValue = "false"; + + writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS ); +} + + +void TDEConfigBase::writeEntry( const TQString& pKey, const TQFont& rFont, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry(pKey.utf8().data(), rFont, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry( const char *pKey, const TQFont& rFont, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey, TQString(rFont.toString()), bPersistent, bGlobal, bNLS ); +} + + +void TDEConfigBase::writeEntry( const TQString& pKey, const TQRect& rRect, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry(pKey.utf8().data(), rRect, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry( const char *pKey, const TQRect& rRect, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + TQStrList list; + TQCString tempstr; + list.insert( 0, tempstr.setNum( rRect.left() ) ); + list.insert( 1, tempstr.setNum( rRect.top() ) ); + list.insert( 2, tempstr.setNum( rRect.width() ) ); + list.insert( 3, tempstr.setNum( rRect.height() ) ); + + writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); +} + + +void TDEConfigBase::writeEntry( const TQString& pKey, const TQPoint& rPoint, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry(pKey.utf8().data(), rPoint, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry( const char *pKey, const TQPoint& rPoint, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + TQStrList list; + TQCString tempstr; + list.insert( 0, tempstr.setNum( rPoint.x() ) ); + list.insert( 1, tempstr.setNum( rPoint.y() ) ); + + writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); +} + + +void TDEConfigBase::writeEntry( const TQString& pKey, const TQSize& rSize, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry(pKey.utf8().data(), rSize, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry( const char *pKey, const TQSize& rSize, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + TQStrList list; + TQCString tempstr; + list.insert( 0, tempstr.setNum( rSize.width() ) ); + list.insert( 1, tempstr.setNum( rSize.height() ) ); + + writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const TQString& pKey, const TQColor& rColor, + bool bPersistent, + bool bGlobal, + bool bNLS ) +{ + writeEntry( pKey.utf8().data(), rColor, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry( const char *pKey, const TQColor& rColor, + bool bPersistent, + bool bGlobal, + bool bNLS ) +{ + TQString aValue; + if (rColor.isValid()) + aValue.sprintf( "%d,%d,%d", rColor.red(), rColor.green(), rColor.blue() ); + else + aValue = "invalid"; + + writeEntry( pKey, aValue, bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::writeEntry( const TQString& pKey, const TQDateTime& rDateTime, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + writeEntry(pKey.utf8().data(), rDateTime, bPersistent, bGlobal, bNLS); +} + +void TDEConfigBase::writeEntry( const char *pKey, const TQDateTime& rDateTime, + bool bPersistent, bool bGlobal, + bool bNLS ) +{ + TQStrList list; + TQCString tempstr; + + TQTime time = TQT_TQTIME_OBJECT(rDateTime.time()); + TQDate date = TQT_TQDATE_OBJECT(rDateTime.date()); + + list.insert( 0, tempstr.setNum( date.year() ) ); + list.insert( 1, tempstr.setNum( date.month() ) ); + list.insert( 2, tempstr.setNum( date.day() ) ); + + list.insert( 3, tempstr.setNum( time.hour() ) ); + list.insert( 4, tempstr.setNum( time.minute() ) ); + list.insert( 5, tempstr.setNum( time.second() ) ); + + writeEntry( pKey, list, ',', bPersistent, bGlobal, bNLS ); +} + +void TDEConfigBase::parseConfigFiles() +{ + if (!bLocaleInitialized && TDEGlobal::_locale) { + setLocale(); + } + if (backEnd) + { + backEnd->parseConfigFiles(); + bReadOnly = (backEnd->getConfigState() == ReadOnly); + } +} + +void TDEConfigBase::sync() +{ + if (isReadOnly()) + return; + + if (backEnd) + backEnd->sync(); + if (bDirty) + rollback(); +} + +TDEConfigBase::ConfigState TDEConfigBase::getConfigState() const { + if (backEnd) + return backEnd->getConfigState(); + return ReadOnly; +} + +void TDEConfigBase::rollback( bool /*bDeep = true*/ ) +{ + bDirty = false; +} + + +void TDEConfigBase::setReadDefaults(bool b) +{ + if (!d) + { + if (!b) return; + d = new TDEConfigBasePrivate(); + } + + d->readDefaults = b; +} + +bool TDEConfigBase::readDefaults() const +{ + return (d && d->readDefaults); +} + +void TDEConfigBase::revertToDefault(const TQString &key) +{ + setDirty(true); + + KEntryKey aEntryKey(mGroup, key.utf8()); + aEntryKey.bDefault = true; + + if (!locale().isNull()) { + // try the localized key first + aEntryKey.bLocal = true; + KEntry entry = lookupData(aEntryKey); + if (entry.mValue.isNull()) + entry.bDeleted = true; + + entry.bDirty = true; + putData(aEntryKey, entry, true); // Revert + aEntryKey.bLocal = false; + } + + // try the non-localized version + KEntry entry = lookupData(aEntryKey); + if (entry.mValue.isNull()) + entry.bDeleted = true; + entry.bDirty = true; + putData(aEntryKey, entry, true); // Revert +} + +bool TDEConfigBase::hasDefault(const TQString &key) const +{ + KEntryKey aEntryKey(mGroup, key.utf8()); + aEntryKey.bDefault = true; + + if (!locale().isNull()) { + // try the localized key first + aEntryKey.bLocal = true; + KEntry entry = lookupData(aEntryKey); + if (!entry.mValue.isNull()) + return true; + + aEntryKey.bLocal = false; + } + + // try the non-localized version + KEntry entry = lookupData(aEntryKey); + if (!entry.mValue.isNull()) + return true; + + return false; +} + + + +TDEConfigGroup::TDEConfigGroup(TDEConfigBase *master, const TQString &group) +{ + mMaster = master; + backEnd = mMaster->backEnd; // Needed for getConfigState() + bLocaleInitialized = true; + bReadOnly = mMaster->bReadOnly; + bExpand = false; + bDirty = false; // Not used + mGroup = group.utf8(); + aLocaleString = mMaster->aLocaleString; + setReadDefaults(mMaster->readDefaults()); +} + +TDEConfigGroup::TDEConfigGroup(TDEConfigBase *master, const TQCString &group) +{ + mMaster = master; + backEnd = mMaster->backEnd; // Needed for getConfigState() + bLocaleInitialized = true; + bReadOnly = mMaster->bReadOnly; + bExpand = false; + bDirty = false; // Not used + mGroup = group; + aLocaleString = mMaster->aLocaleString; + setReadDefaults(mMaster->readDefaults()); +} + +TDEConfigGroup::TDEConfigGroup(TDEConfigBase *master, const char * group) +{ + mMaster = master; + backEnd = mMaster->backEnd; // Needed for getConfigState() + bLocaleInitialized = true; + bReadOnly = mMaster->bReadOnly; + bExpand = false; + bDirty = false; // Not used + mGroup = group; + aLocaleString = mMaster->aLocaleString; + setReadDefaults(mMaster->readDefaults()); +} + +void TDEConfigGroup::deleteGroup(bool bGlobal) +{ + mMaster->deleteGroup(TDEConfigBase::group(), true, bGlobal); +} + +bool TDEConfigGroup::groupIsImmutable() const +{ + return mMaster->groupIsImmutable(TDEConfigBase::group()); +} + +void TDEConfigGroup::setDirty(bool _bDirty) +{ + mMaster->setDirty(_bDirty); +} + +void TDEConfigGroup::putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup) +{ + mMaster->putData(_key, _data, _checkGroup); +} + +KEntry TDEConfigGroup::lookupData(const KEntryKey &_key) const +{ + return mMaster->lookupData(_key); +} + +void TDEConfigGroup::sync() +{ + mMaster->sync(); +} + +void TDEConfigBase::virtual_hook( int, void* ) +{ /*BASE::virtual_hook( id, data );*/ } + +void TDEConfigGroup::virtual_hook( int id, void* data ) +{ TDEConfigBase::virtual_hook( id, data ); } + +bool TDEConfigBase::checkConfigFilesWritable(bool warnUser) +{ + if (backEnd) + return backEnd->checkConfigFilesWritable(warnUser); + else + return false; +} + +#include "tdeconfigbase.moc" diff --git a/tdecore/tdeconfigbase.h b/tdecore/tdeconfigbase.h new file mode 100644 index 000000000..b9522dcb6 --- /dev/null +++ b/tdecore/tdeconfigbase.h @@ -0,0 +1,2180 @@ +/* + This file is part of the KDE libraries + Copyright (c) 1999 Preston Brown + Copyright (c) 1997 Matthias Kalle Dalheimer + Copyright (c) 2001 Waldo Bastian + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _KCONFIGBASE_H +#define _KCONFIGBASE_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tdeconfigdata.h" +#include "tdelibs_export.h" + +class TDEConfigBackEnd; +class TDEConfigBasePrivate; +class TDEConfigGroup; + +/** + * @short KDE Configuration Management abstract base class + * + * This class forms the base for all %KDE configuration. It is an + * abstract base class, meaning that you cannot directly instantiate + * objects of this class. Either use TDEConfig (for usual %KDE + * configuration) or KSimpleConfig (for special needs as in ksamba), or + * even KSharedConfig (stores values in shared memory). + * + * All configuration entries are key, value pairs. Each entry also + * belongs to a specific group of related entries. All configuration + * entries that do not explicitly specify which group they are in are + * in a special group called the default group. + * + * If there is a $ character in an entry, TDEConfigBase tries to expand + * environment variable and uses its value instead of its name. You + * can avoid this feature by having two consecutive $ characters in + * your config file which get expanded to one. + * + * \note the '=' char is not allowed in keys and the ']' char is not allowed in + * a group name. + * + * @author Kalle Dalheimer , Preston Brown + * @see TDEGlobal#config() + * @see TDEConfig + * @see KSimpleConfig + * @see KSharedConfig + */ +class TDECORE_EXPORT TDEConfigBase : public TQObject +{ + Q_OBJECT + + + friend class TDEConfigBackEnd; + friend class TDEConfigINIBackEnd; + friend class TDEConfigGroup; + +public: + /** + * Construct a TDEConfigBase object. + */ + TDEConfigBase(); + + /** + * Destructs the TDEConfigBase object. + */ + virtual ~TDEConfigBase(); + + /** + * Specifies the group in which keys will be read and written. + * + * Subsequent + * calls to readEntry() and writeEntry() will be applied only in the + * activated group. + * + * Switch back to the default group by passing a null string. + * @param group The name of the new group. + */ + void setGroup( const TQString& group ); + + /** + * Sets the group to the "Desktop Entry" group used for + * desktop configuration files for applications, mime types, etc. + */ + void setDesktopGroup(); + + /** + * Returns the name of the group in which we are + * searching for keys and from which we are retrieving entries. + * + * @return The current group. + */ + TQString group() const; + + /** + * Returns true if the specified group is known about. + * + * @param group The group to search for. + * @return true if the group exists. + */ + bool hasGroup(const TQString &group) const; + + /** + * Returns a list of groups that are known about. + * + * @return The list of groups. + **/ + virtual TQStringList groupList() const = 0; + + /** + * Returns a the current locale. + * + * @return A string representing the current locale. + */ + TQString locale() const; + + /** + * Reads the value of an entry specified by @p pKey in the current group. + * If you want to read a path, please use readPathEntry(). + * + * @param pKey The key to search for. + * @param aDefault A default value returned if the key was not found. + * @return The value for this key. Can be TQString::null if aDefault is null. + */ + TQString readEntry(const TQString& pKey, + const TQString& aDefault = TQString::null ) const; + + /** + * Reads the value of an entry specified by @p pKey in the current group. + * + * @param pKey The key to search for. + * @param aDefault A default value returned if the key was not found. + * @return The value for this key. Can be TQString::null if aDefault is null. + */ + TQString readEntry(const char *pKey, + const TQString& aDefault = TQString::null ) const; + + /** + * Reads the value of an entry specified by @p pKey in the current group. + * The value is treated as if it is of the given type. + * + * Note that only the following TQVariant types are allowed : String, + * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, + * Double, DateTime and Date. + * @deprecated + * + * @param pKey The key to search for. + * @return An invalid TQVariant if the key was not found or if the + * read value cannot be converted to the given TQVariant::Type. + */ + TQVariant readPropertyEntry( const TQString& pKey, TQVariant::Type ) const; + + /** + * Reads the value of an entry specified by @p pKey in the current group. + * The value is treated as if it is of the given type. + * + * Note that only the following TQVariant types are allowed : String, + * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, + * Double, DateTime and Date. + * + * @deprecated + * + * @param pKey The key to search for. + * @return An invalid TQVariant if the key was not found or if the + * read value cannot be converted to the given TQVariant::Type. + */ + TQVariant readPropertyEntry( const char *pKey, TQVariant::Type ) const; + + /** + * Reads the value of an entry specified by @p pKey in the current group. + * The value is treated as if it is of the type of the given default value. + * + * Note that only the following TQVariant types are allowed : String, + * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, + * Double, DateTime and Date. + * + * @param pKey The key to search for. + * @param aDefault A default value returned if the key was not found or + * if the read value cannot be converted to the TQVariant::Type. + * @return The value for the key or the default value if the key was not + * found. + */ + TQVariant readPropertyEntry( const TQString& pKey, + const TQVariant &aDefault) const; + + /** + * Reads the value of an entry specified by @p pKey in the current group. + * The value is treated as if it is of the type of the given default value. + * + * Note that only the following TQVariant types are allowed : String, + * StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, + * Double, DateTime and Date. + * + * @param pKey The key to search for. + * @param aDefault A default value returned if the key was not found or + * if the read value cannot be converted to the TQVariant::Type. + * @return The value for the key or the default value if the key was not + * found. + */ + TQVariant readPropertyEntry( const char *pKey, + const TQVariant &aDefault) const; + + /** + * Reads a list of strings. + * + * @deprecated + * + * @param pKey The key to search for + * @param list In this object, the read list will be returned. + * @param sep The list separator (default ",") + * @return The number of entries in the list. + */ + int readListEntry( const TQString& pKey, TQStrList &list, char sep = ',' ) const; + + /** + * Reads a list of strings. + * + * @deprecated + * + * @param pKey The key to search for + * @param list In this object, the read list will be returned. + * @param sep The list separator (default ",") + * @return The number of entries in the list. + */ + int readListEntry( const char *pKey, TQStrList &list, char sep = ',' ) const; + + /** + * Reads a list of strings. + * + * @param pKey The key to search for. + * @param sep The list separator (default is ","). + * @return The list. Empty if the entry does not exist. + */ + TQStringList readListEntry( const TQString& pKey, char sep = ',' ) const; + + /** + * Reads a list of strings. + * + * @param pKey The key to search for. + * @param sep The list separator (default is ","). + * @return The list. Empty if the entry does not exist. + */ + TQStringList readListEntry( const char *pKey, char sep = ',' ) const; + + /** + * Reads a list of strings, but returns a default if the key + * did not exist. + * @param pKey The key to search for. + * @param aDefault The default value to use if the key does not exist. + * @param sep The list separator (default is ","). + * @return The list. Contains @p aDefault if the Key does not exist. + * @since 3.3 + */ + TQStringList readListEntry( const char* pKey, const TQStringList& aDefault, + char sep = ',' ) const; + + /** + * Reads a list of Integers. + * + * @param pKey The key to search for. + * @return The list. Empty if the entry does not exist. + */ + TQValueList readIntListEntry( const TQString& pKey ) const; + + /** + * Reads a list of Integers. + * + * @param pKey The key to search for. + * @return The list. Empty if the entry does not exist. + */ + TQValueList readIntListEntry( const char *pKey ) const; + + /** + * Reads a path. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a path. This means, dollar expansion is activated + * for this value, so that e.g. $HOME gets expanded. + * + * @param pKey The key to search for. + * @param aDefault A default value returned if the key was not found. + * @return The value for this key. Can be TQString::null if aDefault is null. + */ + TQString readPathEntry( const TQString& pKey, const TQString & aDefault = TQString::null ) const; + + /** + * Reads a path. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a path. This means, dollar expansion is activated + * for this value, so that e.g. $HOME gets expanded. + * + * @param pKey The key to search for. + * @param aDefault A default value returned if the key was not found. + * @return The value for this key. Can be TQString::null if aDefault is null. + */ + TQString readPathEntry( const char *pKey, const TQString & aDefault = TQString::null ) const; + + /** + * Reads a list of string paths. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a list of paths. This means, dollar expansion is activated + * for this value, so that e.g. $HOME gets expanded. + * + * @param pKey The key to search for. + * @param sep The list separator (default is ","). + * @return The list. Empty if the entry does not exist. + * @since 3.1.3 + */ + TQStringList readPathListEntry( const TQString& pKey, char sep = ',' ) const; + + /** + * Reads a list of string paths. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a list of paths. This means, dollar expansion is activated + * for this value, so that e.g. $HOME gets expanded. + * + * @param pKey The key to search for. + * @param sep The list separator (default is ","). + * @return The list. Empty if the entry does not exist. + * @since 3.1.3 + */ + TQStringList readPathListEntry( const char *pKey, char sep = ',' ) const; + + + /** + * Reads a numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + int readNumEntry( const TQString& pKey, int nDefault = 0 ) const; + + /** + * Reads a numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + int readNumEntry( const char *pKey, int nDefault = 0 ) const; + + /** + * Reads an unsigned numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + unsigned int readUnsignedNumEntry( const TQString& pKey, unsigned int nDefault = 0 ) const; + + /** + * Reads an unsigned numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + unsigned int readUnsignedNumEntry( const char *pKey, unsigned int nDefault = 0 ) const; + + + /** + * Reads a numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + long readLongNumEntry( const TQString& pKey, long nDefault = 0 ) const; + + /** + * Reads a numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + long readLongNumEntry( const char *pKey, long nDefault = 0 ) const; + + /** + * Read an unsigned numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + unsigned long readUnsignedLongNumEntry( const TQString& pKey, unsigned long nDefault = 0 ) const; + + /** + * Read an unsigned numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + unsigned long readUnsignedLongNumEntry( const char *pKey, unsigned long nDefault = 0 ) const; + + /** + * Reads a 64-bit numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + TQ_INT64 readNum64Entry( const TQString& pKey, TQ_INT64 nDefault = 0 ) const; + + /** + * Reads a 64-bit numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + TQ_INT64 readNum64Entry( const char *pKey, TQ_INT64 nDefault = 0 ) const; + + /** + * Read an 64-bit unsigned numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + TQ_UINT64 readUnsignedNum64Entry( const TQString& pKey, TQ_UINT64 nDefault = 0 ) const; + + /** + * Read an 64-bit unsigned numerical value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + TQ_UINT64 readUnsignedNum64Entry( const char *pKey, TQ_UINT64 nDefault = 0 ) const; + + /** + * Reads a floating point value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + double readDoubleNumEntry( const TQString& pKey, double nDefault = 0.0 ) const; + + /** + * Reads a floating point value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it numerically. + * + * @param pKey The key to search for. + * @param nDefault A default value returned if the key was not found or if + * the read value cannot be interpreted. + * @return The value for this key. + */ + double readDoubleNumEntry( const char *pKey, double nDefault = 0.0 ) const; + + /** + * Reads a TQFont value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a font object. + * + * @param pKey The key to search for. + * @param pDefault A default value (null TQFont by default) returned if the + * key was not found or if the read value cannot be interpreted. + * @return The value for this key. + */ + TQFont readFontEntry( const TQString& pKey, const TQFont* pDefault = 0L ) const; + + /** + * Reads a TQFont value. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a font object. + * + * @param pKey The key to search for. + * @param pDefault A default value (null TQFont by default) returned if the + * key was not found or if the read value cannot be interpreted. + * @return The value for this key. + */ + TQFont readFontEntry( const char *pKey, const TQFont* pDefault = 0L ) const; + + /** + * Reads a boolean entry. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a boolean value. Currently "on", "yes", "1" and + * "true" are accepted as true, everything else if false. + * + * @param pKey The key to search for + * @param bDefault A default value returned if the key was not found. + * @return The value for this key. + */ + bool readBoolEntry( const TQString& pKey, bool bDefault = false ) const; + + /** + * Reads a boolean entry. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a boolean value. Currently "on", "yes", "1" and + * "true" are accepted as true, everything else if false. + * + * @param pKey The key to search for + * @param bDefault A default value returned if the key was not found. + * @return The value for this key. + */ + bool readBoolEntry( const char *pKey, bool bDefault = false ) const; + + /** + * Reads a TQRect entry. + * + * Read the value of an entry specified by pKey in the current group + * and interpret it as a TQRect object. + * + * @param pKey The key to search for + * @param pDefault A default value (null TQRect by default) returned if the + * key was not found or if the read value cannot be interpreted. + * @return The value for this key. + */ + TQRect readRectEntry( const TQString& pKey, const TQRect* pDefault = 0L ) const; + + /** + * Reads a TQRect entry. + * + * Read the value of an entry specified by pKey in the current group + * and interpret it as a TQRect object. + * + * @param pKey The key to search for + * @param pDefault A default value (null TQRect by default) returned if the + * key was not found or if the read value cannot be interpreted. + * @return The value for this key. + */ + TQRect readRectEntry( const char *pKey, const TQRect* pDefault = 0L ) const; + + /** + * Reads a TQPoint entry. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a TQPoint object. + * + * @param pKey The key to search for + * @param pDefault A default value (null TQPoint by default) returned if the + * key was not found or if the read value cannot be interpreted. + * @return The value for this key. + */ + TQPoint readPointEntry( const TQString& pKey, const TQPoint* pDefault = 0L ) const; + + /** + * Reads a TQPoint entry. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a TQPoint object. + * + * @param pKey The key to search for + * @param pDefault A default value (null TQPoint by default) returned if the + * key was not found or if the read value cannot be interpreted. + * @return The value for this key. + */ + TQPoint readPointEntry( const char *pKey, const TQPoint* pDefault = 0L ) const; + + /** + * Reads a TQSize entry. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a TQSize object. + * + * @param pKey The key to search for + * @param pDefault A default value (null TQSize by default) returned if the + * key was not found or if the read value cannot be interpreted. + * @return The value for this key. + */ + TQSize readSizeEntry( const TQString& pKey, const TQSize* pDefault = 0L ) const; + + /** + * Reads a TQSize entry. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a TQSize object. + * + * @param pKey The key to search for + * @param pDefault A default value (null TQSize by default) returned if the + * key was not found or if the read value cannot be interpreted. + * @return The value for this key. + */ + TQSize readSizeEntry( const char *pKey, const TQSize* pDefault = 0L ) const; + + + /** + * Reads a TQColor entry. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a color. + * + * @param pKey The key to search for. + * @param pDefault A default value (null TQColor by default) returned if the + * key was not found or if the value cannot be interpreted. + * @return The value for this key. + */ + TQColor readColorEntry( const TQString& pKey, const TQColor* pDefault = 0L ) const; + + /** + * Reads a TQColor entry. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a color. + * + * @param pKey The key to search for. + * @param pDefault A default value (null TQColor by default) returned if the + * key was not found or if the value cannot be interpreted. + * @return The value for this key. + */ + TQColor readColorEntry( const char *pKey, const TQColor* pDefault = 0L ) const; + + /** + * Reads a TQDateTime entry. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a date and time. + * + * @param pKey The key to search for. + * @param pDefault A default value ( currentDateTime() by default) + * returned if the key was not found or if the read value cannot be + * interpreted. + * @return The value for this key. + */ + TQDateTime readDateTimeEntry( const TQString& pKey, const TQDateTime* pDefault = 0L ) const; + + /** + * Reads a TQDateTime entry. + * + * Read the value of an entry specified by @p pKey in the current group + * and interpret it as a date and time. + * + * @param pKey The key to search for. + * @param pDefault A default value ( currentDateTime() by default) + * returned if the key was not found or if the read value cannot be + * interpreted. + * @return The value for this key. + */ + TQDateTime readDateTimeEntry( const char *pKey, const TQDateTime* pDefault = 0L ) const; + + /** + * Reads the value of an entry specified by @p pKey in the current group. + * The untranslated entry is returned, you normally do not need this. + * + * @param pKey The key to search for. + * @param aDefault A default value returned if the key was not found. + * @return The value for this key. + */ + TQString readEntryUntranslated( const TQString& pKey, + const TQString& aDefault = TQString::null ) const; + + /** + * Reads the value of an entry specified by @p pKey in the current group. + * The untranslated entry is returned, you normally do not need this. + * + * @param pKey The key to search for. + * @param aDefault A default value returned if the key was not found. + * @return The value for this key. + */ + TQString readEntryUntranslated( const char *pKey, + const TQString& aDefault = TQString::null ) const; + + /** + * Writes a key/value pair. + * + * This is stored in the most specific config file when destroying the + * config object or when calling sync(). + * + * If you want to write a path, please use writePathEntry(). + * + * @param pKey The key to write. + * @param pValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will + * not be written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, const TQString& pValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a key/value pair. + * + * This is stored in the most specific config file when destroying the + * config object or when calling sync(). + * + * @param pKey The key to write. + * @param pValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will + * not be written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, const TQString& pValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * writeEntry() Overridden to accept a property. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write + * @param rValue The property to write + * @param bPersistent If @p bPersistent is false, the entry's dirty flag + * will not be set and thus the entry will not be + * written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + * + * @see writeEntry() + */ + void writeEntry( const TQString& pKey, const TQVariant& rValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * writeEntry() Overridden to accept a property. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write + * @param rValue The property to write + * @param bPersistent If @p bPersistent is false, the entry's dirty flag + * will not be set and thus the entry will not be + * written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + * + * @see writeEntry() + */ + void writeEntry( const char *pKey, const TQVariant& rValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * writeEntry() overridden to accept a list of strings. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write + * @param rValue The list to write + * @param sep The list separator (default is ","). + * @param bPersistent If @p bPersistent is false, the entry's dirty flag + * will not be set and thus the entry will not be + * written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + * + * @see writeEntry() + */ + void writeEntry( const TQString& pKey, const TQStrList &rValue, + char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); + /** + * writeEntry() overridden to accept a list of strings. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write + * @param rValue The list to write + * @param sep The list separator (default is ","). + * @param bPersistent If @p bPersistent is false, the entry's dirty flag + * will not be set and thus the entry will not be + * written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + * + * @see writeEntry() + */ + void writeEntry( const char *pKey, const TQStrList &rValue, + char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); + + /** + * writeEntry() overridden to accept a list of strings. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write + * @param rValue The list to write + * @param sep The list separator (default is ","). + * @param bPersistent If @p bPersistent is false, the entry's dirty flag + * will not be set and thus the entry will not be + * written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + * + * @see writeEntry() + */ + void writeEntry( const TQString& pKey, const TQStringList &rValue, + char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); + /** + * writeEntry() overridden to accept a list of strings. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write + * @param rValue The list to write + * @param sep The list separator (default is ","). + * @param bPersistent If @p bPersistent is false, the entry's dirty flag + * will not be set and thus the entry will not be + * written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + * + * @see writeEntry() + */ + void writeEntry( const char *pKey, const TQStringList &rValue, + char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); + + + /** + * writeEntry() overridden to accept a list of Integers. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write + * @param rValue The list to write + * @param bPersistent If @p bPersistent is false, the entry's dirty flag + * will not be set and thus the entry will not be + * written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + * + * @see writeEntry() + */ + void writeEntry( const TQString& pKey, const TQValueList& rValue, + bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); + /** + * writeEntry() overridden to accept a list of Integers. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write + * @param rValue The list to write + * @param bPersistent If @p bPersistent is false, the entry's dirty flag + * will not be set and thus the entry will not be + * written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + * + * @see writeEntry() + */ + void writeEntry( const char *pKey, const TQValueList& rValue, + bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); + + /** + * Write a (key/value) pair. + * + * This is stored to the most specific config file when destroying the + * config object or when calling sync(). + * + * @param pKey The key to write. + * @param pValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will + * not be written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, const char *pValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ) + { writeEntry(pKey, TQString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); } + /** + * Write a (key/value) pair. + * + * This is stored to the most specific config file when destroying the + * config object or when calling sync(). + * + * @param pKey The key to write. + * @param pValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will + * not be written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, const char *pValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ) + { writeEntry(pKey, TQString::fromLatin1(pValue), bPersistent, bGlobal, bNLS); } + + /** + * Write a (key/value) pair. + * Same as above, but writes a numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, int nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Write a (key/value) pair. + * Same as above, but writes a numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, int nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but writes an unsigned numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, unsigned int nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but writes an unsigned numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, unsigned int nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but write a long numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, long nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but write a long numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, long nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but writes an unsigned long numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, unsigned long nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but writes an unsigned long numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, unsigned long nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but write a 64-bit numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, TQ_INT64 nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but write a long numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, TQ_INT64 nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but writes an unsigned 64-bit numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, TQ_UINT64 nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but writes an unsigned 64-bit numerical value. + * + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, TQ_UINT64 nValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but writes a floating-point value. + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param format @p format determines the format to which the value + * is converted. Default is 'g'. + * @param precision @p precision sets the precision with which the + * value is converted. Default is 6 as in TQString. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, double nValue, + bool bPersistent = true, bool bGlobal = false, + char format = 'g', int precision = 6, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but writes a floating-point value. + * @param pKey The key to write. + * @param nValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param format @p format determines the format to which the value + * is converted. Default is 'g'. + * @param precision @p precision sets the precision with which the + * value is converted. Default is 6 as in TQString. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, double nValue, + bool bPersistent = true, bool bGlobal = false, + char format = 'g', int precision = 6, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but writes a boolean value. + * + * @param pKey The key to write. + * @param bValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, bool bValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but writes a boolean value. + * + * @param pKey The key to write. + * @param bValue The value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, bool bValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but writes a font value. + * + * @param pKey The key to write. + * @param rFont The font value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, const TQFont& rFont, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but writes a font value. + * + * @param pKey The key to write. + * @param rFont The font value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, const TQFont& rFont, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but write a color entry. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write. + * @param rColor The color value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, const TQColor& rColor, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but write a color entry. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write. + * @param rColor The color value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, const TQColor& rColor, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but writes a date and time entry. + * + * Note: Unlike the other writeEntry() functions, the old value is + * @em not returned here! + * + * @param pKey The key to write. + * @param rDateTime The date and time value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, const TQDateTime& rDateTime, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but writes a date and time entry. + * + * Note: Unlike the other writeEntry() functions, the old value is + * @em not returned here! + * + * @param pKey The key to write. + * @param rDateTime The date and time value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, const TQDateTime& rDateTime, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + + /** + * Writes a (key/value) pair. + * Same as above, but writes a rectangle. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write. + * @param rValue The rectangle value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, const TQRect& rValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but writes a rectangle. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write. + * @param rValue The rectangle value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, const TQRect& rValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but writes a point. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write. + * @param rValue The point value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, const TQPoint& rValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but writes a point. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write. + * @param rValue The point value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, const TQPoint& rValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a (key/value) pair. + * Same as above, but writes a size. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write. + * @param rValue The size value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const TQString& pKey, const TQSize& rValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a (key/value) pair. + * Same as above, but writes a size. + * + * Note: Unlike the other writeEntry() functions, the old value is + * _not_ returned here! + * + * @param pKey The key to write. + * @param rValue The size value to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writeEntry( const char *pKey, const TQSize& rValue, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * Writes a file path. + * + * It is checked whether the path is located under $HOME. If so the + * path is written out with the user's home-directory replaced with + * $HOME. The path should be read back with readPathEntry() + * + * @param pKey The key to write. + * @param path The path to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writePathEntry( const TQString& pKey, const TQString & path, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + /** + * Writes a file path. + * + * It is checked whether the path is located under $HOME. If so the + * path is written out with the user's home-directory replaced with + * $HOME. The path should be read back with readPathEntry() + * + * @param pKey The key to write. + * @param path The path to write. + * @param bPersistent If @p bPersistent is false, the entry's dirty + * flag will not be set and thus the entry will not be written to + * disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + */ + void writePathEntry( const char *pKey, const TQString & path, + bool bPersistent = true, bool bGlobal = false, + bool bNLS = false ); + + /** + * writePathEntry() overridden to accept a list of paths (strings). + * + * It is checked whether the paths are located under $HOME. If so each of + * the paths are written out with the user's home-directory replaced with + * $HOME. The paths should be read back with readPathListEntry() + * + * @param pKey The key to write + * @param rValue The list to write + * @param sep The list separator (default is ","). + * @param bPersistent If @p bPersistent is false, the entry's dirty flag + * will not be set and thus the entry will not be + * written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + * + * @see writePathEntry() + * @see readPathListEntry() + * @since 3.1.3 + */ + void writePathEntry( const TQString& pKey, const TQStringList &rValue, + char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); + /** + * writePathEntry() overridden to accept a list of paths (strings). + * + * It is checked whether the paths are located under $HOME. If so each of + * the paths are written out with the user's home-directory replaced with + * $HOME. The paths should be read back with readPathListEntry() + * + * @param pKey The key to write + * @param rValue The list to write + * @param sep The list separator (default is ","). + * @param bPersistent If @p bPersistent is false, the entry's dirty flag + * will not be set and thus the entry will not be + * written to disk at deletion time. + * @param bGlobal If @p bGlobal is true, the pair is not saved to the + * application specific config file, but to the + * global KDE config file. + * @param bNLS If @p bNLS is true, the locale tag is added to the key + * when writing it back. + * + * @see writePathEntry() + * @see readPathListEntry() + * @since 3.1.3 + */ + void writePathEntry( const char *pKey, const TQStringList &rValue, + char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false ); + + + /** + * Deletes the entry specified by @p pKey in the current group. + * + * @param pKey The key to delete. + * @param bGlobal If @p bGlobal is true, the pair is not removed from the + * application specific config file, but to the global KDE config file. + * @param bNLS If @p bNLS is true, the key with the locale tag is removed. + */ + void deleteEntry( const TQString& pKey, + bool bNLS = false, bool bGlobal = false); + /** + * Deletes the entry specified by @p pKey in the current group. + * + * @param pKey The key to delete. + * @param bGlobal If @p bGlobal is true, the pair is not removed from the + * application specific config file, but from the global KDE config file. + * @param bNLS If @p bNLS is true, the key with the locale tag is removed. + */ + void deleteEntry( const char *pKey, + bool bNLS = false, bool bGlobal = false); + + /** + * Deletes a configuration entry group + * + * If the group is not empty and bDeep is false, nothing gets + * deleted and false is returned. + * If this group is the current group and it is deleted, the + * current group is undefined and should be set with setGroup() + * before the next operation on the configuration object. + * + * @param group The name of the group + * @param bDeep Specify whether non-empty groups should be completely + * deleted (including their entries). + * @param bGlobal If @p bGlobal is true, the group is not removed from the + * application specific config file, but from the global KDE config file. + * @return If the group is not empty and bDeep is false, + * deleteGroup returns false. + */ + bool deleteGroup( const TQString& group, bool bDeep = true, bool bGlobal = false ); + + + /** + * Turns on or off "dollar expansion" (see TDEConfigBase introduction) + * when reading config entries. + * Dollar sign expansion is initially OFF. + * + * @param _bExpand Tf true, dollar expansion is turned on. + */ + void setDollarExpansion( bool _bExpand = true ) { bExpand = _bExpand; } + + /** + * Returns whether dollar expansion is on or off. It is initially OFF. + * + * @return true if dollar expansion is on. + */ + bool isDollarExpansion() const { return bExpand; } + + /** + * Mark the config object as "clean," i.e. don't write dirty entries + * at destruction time. If @p bDeep is false, only the global dirty + * flag of the TDEConfig object gets cleared. If you then call + * writeEntry() again, the global dirty flag is set again and all + * dirty entries will be written at a subsequent sync() call. + * + * Classes that derive from TDEConfigBase should override this + * method and implement storage-specific behavior, as well as + * calling the TDEConfigBase::rollback() explicitly in the initializer. + * + * @param bDeep If true, the dirty flags of all entries are cleared, + * as well as the global dirty flag. + */ + virtual void rollback( bool bDeep = true ); + + /** + * Flushes all changes that currently reside only in memory + * back to disk / permanent storage. Dirty configuration entries are + * written to the most specific file available. + * + * Asks the back end to flush out all pending writes, and then calls + * rollback(). No changes are made if the object has @p readOnly + * status. + * + * You should call this from your destructor in derivative classes. + * + * @see rollback(), #isReadOnly() + */ + virtual void sync(); + + /** + * Checks whether the config file has any dirty (modified) entries. + * @return true if the config file has any dirty (modified) entries. + */ + bool isDirty() const { return bDirty; } + + /** + * Sets the config object's read-only status. + * + * @param _ro If true, the config object will not write out any + * changes to disk even if it is destroyed or sync() is called. + * + */ + virtual void setReadOnly(bool _ro) { bReadOnly = _ro; } + + /** + * Returns the read-only status of the config object. + * + * @return The read-only status. + */ + bool isReadOnly() const { return bReadOnly; } + + /** + * Checks whether the key has an entry in the currently active group. + * Use this to determine whether a key is not specified for the current + * group (hasKey() returns false). Keys with null data are considered + * nonexistent. + * + * @param key The key to search for. + * @return If true, the key is available. + */ + bool hasKey( const TQString& key ) const; + + /** + * Returns a map (tree) of entries for all entries in a particular + * group. Only the actual entry string is returned, none of the + * other internal data should be included. + * + * @param group A group to get keys from. + * @return A map of entries in the group specified, indexed by key. + * The returned map may be empty if the group is not found. + * @see QMap + */ + virtual TQMap entryMap(const TQString &group) const = 0; + + /** + * Reparses all configuration files. This is useful for programs + * that use stand alone graphical configuration tools. The base + * method implemented here only clears the group list and then + * appends the default group. + * + * Derivative classes should clear any internal data structures and + * then simply call parseConfigFiles() when implementing this + * method. + * + * @see parseConfigFiles() + */ + virtual void reparseConfiguration() = 0; + + /** + * Checks whether this configuration file can be modified. + * @return whether changes may be made to this configuration file. + */ + bool isImmutable() const; + + /** + * Checks whether it is possible to change the given group. + * @param group the group to check + * @return whether changes may be made to @p group in this configuration + * file. + */ + bool groupIsImmutable(const TQString &group) const; + + /** + * Checks whether it is possible to change the given entry. + * @param key the key to check + * @return whether the entry @p key may be changed in the current group + * in this configuration file. + */ + bool entryIsImmutable(const TQString &key) const; + + /** + * Possible return values for getConfigState(). + * + * @see getConfigState() + */ + enum ConfigState { NoAccess, ReadOnly, ReadWrite }; + + /** + * Returns the state of the app-config object. + * + * Possible return values + * are NoAccess (the application-specific config file could not be + * opened neither read-write nor read-only), ReadOnly (the + * application-specific config file is opened read-only, but not + * read-write) and ReadWrite (the application-specific config + * file is opened read-write). + * + * @see ConfigState() + * @return the state of the app-config object + */ + ConfigState getConfigState() const; + + /** + * Check whether the config files are writable. + * @param warnUser Warn the user if the configuration files are not writable. + * @return Indicates that all of the configuration files used are writable. + * @since 3.2 + */ + bool checkConfigFilesWritable(bool warnUser); + + /** + * When set, all readEntry and readXXXEntry calls return the system + * wide (default) values instead of the user's preference. + * This is off by default. + * @since 3.2 + */ + void setReadDefaults(bool b); + + /** + * @returns true if all readEntry and readXXXEntry calls return the system + * wide (default) values instead of the user's preference. + * @since 3.2 + */ + bool readDefaults() const; + + /** + * Reverts the entry with key @p key in the current group in the + * application specific config file to either the system wide (default) + * value or the value specified in the global KDE config file. + * + * To revert entries in the global KDE config file, the global KDE config + * file should be opened explicitly in a separate config object. + * + * @param key The key of the entry to revert. + * @since 3.2 + */ + void revertToDefault(const TQString &key); + + /** + * Returns whether a default is specified for an entry in either the + * system wide configuration file or the global KDE config file. + * + * If an application computes a default value at runtime for + * a certain entry, e.g. like: + * \code + * TQColor computedDefault = kapp->palette().color(TQPalette::Active, TQColorGroup::Text) + * TQColor color = config->readEntry(key, computedDefault); + * \encode + * + * Then it may wish to make the following check before + * writing back changes: + * \code + * if ( (value == computedDefault) && !config->hasDefault(key) ) + * config->revertToDefault(key) + * else + * config->writeEntry(key, value) + * \endcode + * + * This ensures that as long as the entry is not modified to differ from + * the computed default, the application will keep using the computed default + * and will follow changes the computed default makes over time. + * @param key The key of the entry to check. + * @since 3.2 + */ + bool hasDefault(const TQString &key) const; + +protected: + /** + * Reads the locale and put in the configuration data struct. + * Note that this should be done in the constructor, but this is not + * possible due to some mutual dependencies in TDEApplication::init() + */ + void setLocale(); + + /** + * Sets the global dirty flag of the config object + * + * @param _bDirty How to mark the object's dirty status + */ + virtual void setDirty(bool _bDirty = true) { bDirty = _bDirty; } + + /** + * Parses all configuration files for a configuration object. + * + * The actual parsing is done by the associated TDEConfigBackEnd. + */ + virtual void parseConfigFiles(); + + /** + * Returns a map (tree) of the entries in the specified group. + * This may or may not return all entries that belong to the + * config object. The only guarantee that you are given is that + * any entries that are dirty (i.e. modified and not yet written back + * to the disk) will be contained in the map. Some derivative + * classes may choose to return everything. + * + * Do not use this function, the implementation / return type are + * subject to change. + * + * @param pGroup The group to provide a KEntryMap for. + * @return The map of the entries in the group. + * @internal + */ + virtual KEntryMap internalEntryMap( const TQString& pGroup ) const = 0; + + /** + * Returns a map (tree) of the entries in the tree. + * + * Do not use this function, the implementation / return type are + * subject to change. + * + * @return A map of the entries in the tree. + * + * @internal + * + */ + virtual KEntryMap internalEntryMap() const = 0; + + /** + * Inserts a (key/value) pair into the internal storage mechanism of + * the configuration object. Classes that derive from TDEConfigBase + * will need to implement this method in a storage-specific manner. + * + * Do not use this function, the implementation / return type are + * subject to change. + * + * @param _key The key to insert. It contains information both on + * the group of the key and the key itself. If the key already + * exists, the old value will be replaced. + * @param _data the KEntry that is to be stored. + * @param _checkGroup When false, assume that the group already exists. + * @internal + */ + virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup = true) = 0; + + /** + * Looks up an entry in the config object's internal structure. + * Classes that derive from TDEConfigBase will need to implement this + * method in a storage-specific manner. + * + * Do not use this function, the implementation and return type are + * subject to change. + * + * @param _key The key to look up It contains information both on + * the group of the key and the entry's key itself. + * @return The KEntry value (data) found for the key. @p KEntry.aValue + * will be the null string if nothing was located. + * @internal + */ + virtual KEntry lookupData(const KEntryKey &_key) const = 0; + + virtual bool internalHasGroup(const TQCString &group) const = 0; + + /** + * A back end for loading/saving to disk in a particular format. + */ + TDEConfigBackEnd *backEnd; +public: + /** + * Overloaded public methods: + */ + void setGroup( const TQCString &pGroup ); + void setGroup( const char *pGroup ); + bool hasGroup(const TQCString &_pGroup) const; + bool hasGroup(const char *_pGroup) const; + bool hasKey( const char *pKey ) const; + +protected: + TQCString readEntryUtf8( const char *pKey) const; + bool hasTranslatedKey( const char *pKey ) const; + + /** + * The currently selected group. */ + TQCString mGroup; + + /** + * The locale to retrieve keys under if possible, i.e en_US or fr. */ + TQCString aLocaleString; + + /** + * Indicates whether there are any dirty entries in the config object + * that need to be written back to disk. */ + bool bDirty; + + bool bLocaleInitialized; + bool bReadOnly; // currently only used by KSimpleConfig + mutable bool bExpand; // whether dollar expansion is used + +protected: + virtual void virtual_hook( int id, void* data ); +private: + class TDEConfigBasePrivate; + TDEConfigBasePrivate *d; + + void writeEntry( const char *pKey, const TQString &rValue, + bool bPersistent, bool bGlobal, bool bNLS, bool bExpand ); + void writeEntry( const char *pKey, const TQStringList &rValue, + char sep, bool bPersistent, bool bGlobal, bool bNLS, bool bExpand ); + +}; + +class TDEConfigGroupSaverPrivate; + +/** + * Helper class to facilitate working with TDEConfig / KSimpleConfig + * groups. + * + * Careful programmers always set the group of a + * TDEConfig KSimpleConfig object to the group they want to read from + * and set it back to the old one of afterwards. This is usually + * written as: + * \code + * + * TQString oldgroup config->group(); + * config->setGroup( "TheGroupThatIWant" ); + * ... + * config->writeEntry( "Blah", "Blubb" ); + * + * config->setGroup( oldgroup ); + * \endcode + * + * In order to facilitate this task, you can use + * TDEConfigGroupSaver. Simply construct such an object ON THE STACK + * when you want to switch to a new group. Then, when the object goes + * out of scope, the group will automatically be restored. If you + * want to use several different groups within a function or method, + * you can still use TDEConfigGroupSaver: Simply enclose all work with + * one group (including the creation of the TDEConfigGroupSaver object) + * in one block. + * + * @deprecated This class is deprecated and will be removed in KDE 4. + * TDEConfigGroup provides similar functionality in a more object oriented + * way. + * + * @author Matthias Kalle Dalheimer + * @see TDEConfigBase, TDEConfig, KSimpleConfig, TDEConfigGroup + * @short Helper class for easier use of TDEConfig/KSimpleConfig groups + */ + +class TDECORE_EXPORT TDEConfigGroupSaver // KDE4 remove +{ +public: + /** + * Constructor. You pass a pointer to the TDEConfigBase-derived + * object you want to work with and a string indicating the _new_ + * group. + * + * @param config The TDEConfigBase-derived object this + * TDEConfigGroupSaver works on. + * @param group The new group that the config object should switch to. + */ + TDEConfigGroupSaver( TDEConfigBase* config, TQString group ) + /* KDE 4 : make the second parameter const TQString & */ + : _config(config), _oldgroup(config->group()) + { _config->setGroup( group ); } + + TDEConfigGroupSaver( TDEConfigBase* config, const char *group ) + : _config(config), _oldgroup(config->group()) + { _config->setGroup( group ); } + + TDEConfigGroupSaver( TDEConfigBase* config, const TQCString &group ) + : _config(config), _oldgroup(config->group()) + { _config->setGroup( group ); } + + ~TDEConfigGroupSaver() { _config->setGroup( _oldgroup ); } + + TDEConfigBase* config() { return _config; }; + +private: + TDEConfigBase* _config; + TQString _oldgroup; + + TDEConfigGroupSaver(const TDEConfigGroupSaver&); + TDEConfigGroupSaver& operator=(const TDEConfigGroupSaver&); + + TDEConfigGroupSaverPrivate *d; +}; + +class TDEConfigGroupPrivate; + +/** + * A TDEConfigBase derived class for one specific group in a TDEConfig object. + */ +class TDECORE_EXPORT TDEConfigGroup: public TDEConfigBase +{ +public: + /** + * Construct a config group corresponding to @p group in @p master. + * @p group is the group name encoded in UTF-8. + */ + TDEConfigGroup(TDEConfigBase *master, const TQCString &group); + /** + * This is an overloaded constructor provided for convenience. + * It behaves essentially like the above function. + * + * Construct a config group corresponding to @p group in @p master + */ + TDEConfigGroup(TDEConfigBase *master, const TQString &group); + /** + * This is an overloaded constructor provided for convenience. + * It behaves essentially like the above function. + * + * Construct a config group corresponding to @p group in @p master + * @p group is the group name encoded in UTF-8. + */ + TDEConfigGroup(TDEConfigBase *master, const char * group); + + /** + * Delete all entries in the entire group + * @param bGlobal If @p bGlobal is true, the entries are not removed + * from the application specific config file, but from the global + * KDE config file. + */ + void deleteGroup(bool bGlobal = false); + + /** + * Checks whether it is possible to change this group. + * @return whether changes may be made to this group in this configuration + * file. + * @since 3.4 + */ + bool groupIsImmutable() const; + + // The following functions are reimplemented: + virtual void setDirty(bool _bDirty); + virtual void putData(const KEntryKey &_key, const KEntry &_data, bool _checkGroup = true); + virtual KEntry lookupData(const KEntryKey &_key) const; + virtual void sync(); + +private: + // Hide the following members: + void setGroup() { } + void setDesktopGroup() { } + void group() { } + void hasGroup() { } + void setReadOnly(bool) { } + void isDirty() { } + + // The following members are not used. + virtual TQStringList groupList() const { return TQStringList(); } + virtual void rollback(bool) { } + virtual void reparseConfiguration() { } + virtual TQMap entryMap(const TQString &) const + { return TQMap(); } + virtual KEntryMap internalEntryMap( const TQString&) const + { return KEntryMap(); } + virtual KEntryMap internalEntryMap() const + { return KEntryMap(); } + virtual bool internalHasGroup(const TQCString &) const + { return false; } + + void getConfigState() { } + + TDEConfigBase *mMaster; +protected: + virtual void virtual_hook( int id, void* data ); +private: + TDEConfigGroupPrivate* d; +}; + +#endif diff --git a/tdecore/tdeconfigdata.h b/tdecore/tdeconfigdata.h new file mode 100644 index 000000000..f99f72c08 --- /dev/null +++ b/tdecore/tdeconfigdata.h @@ -0,0 +1,146 @@ +/* + This file is part of the KDE libraries + Copyright (c) 1999-2000 Preston Brown + Copyright (C) 1996-2000 Matthias Kalle Dalheimer + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _KCONFIGDATA_H +#define _KCONFIGDATA_H + +#include // generic red-black tree class +#include "tdelibs_export.h" + +/** + * map/dict/list config node entry. + * @internal + */ +struct TDECORE_EXPORT KEntry +{ + KEntry() + : mValue(0), bDirty(false), bNLS(false), + bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false) {} + TQCString mValue; + /** + * Must the entry be written back to disk? + */ + bool bDirty :1; + /** + * Entry should be written with locale tag + */ + bool bNLS :1; + /** + * Entry should be written to the global config file + */ + bool bGlobal:1; + /** + * Entry can not be modified. + */ + bool bImmutable:1; + /** + * Entry has been deleted. + */ + bool bDeleted:1; + /** + * Whether to apply dollar expansion or not. + */ + bool bExpand:1; +}; + +/** + * key structure holding both the actual key and the the group + * to which it belongs. + * @internal + */ +struct TDECORE_EXPORT KEntryKey +{ + KEntryKey(const TQCString& _group = 0, + const TQCString& _key = 0) + : mGroup(_group), mKey(_key), bLocal(false), bDefault(false), + c_key(_key.data()) {} + /** + * The "group" to which this EntryKey belongs + */ + TQCString mGroup; + /** + * The _actual_ key of the entry in question + */ + TQCString mKey; + /** + * Entry is localised or not + */ + bool bLocal :1; + /** + * Entry indicates if this is a default value. + */ + bool bDefault:1; + + const char *c_key; +}; + +/** + * compares two KEntryKeys (needed for TQMap). + * @internal + */ +inline bool operator <(const KEntryKey &k1, const KEntryKey &k2) +{ + //saves one strcmp on each call + int result=qstrcmp(k1.mGroup.data(),k2.mGroup.data()); + if (result!=0) + return (result<0); + + if (!k1.c_key && k2.c_key) + return true; + + result = 0; + if (k1.c_key && k2.c_key) + result = strcmp(k1.c_key, k2.c_key); + if (result != 0) + return result < 0; + if (!k1.bLocal && k2.bLocal) + return true; + if (k1.bLocal && !k2.bLocal) + return false; + return (!k1.bDefault && k2.bDefault); +} + +/** + * \relates KEntry + * type specifying a map of entries (key,value pairs). + * The keys are actually a key in a particular config file group together + * with the group name. + * @internal + */ +typedef TQMap KEntryMap; + +/** + * \relates KEntry + * type for iterating over keys in a KEntryMap in sorted order. + * @internal + */ +typedef TQMap::Iterator KEntryMapIterator; + +/** + * \relates KEntry + * type for iterating over keys in a KEntryMap in sorted order. + * It is const, thus you cannot change the entries in the iterator, + * only examine them. + * @internal + */ +typedef TQMap::ConstIterator KEntryMapConstIterator; + +#endif diff --git a/tdecore/tdeconfigdialogmanager.cpp b/tdecore/tdeconfigdialogmanager.cpp new file mode 100644 index 000000000..c488e43cb --- /dev/null +++ b/tdecore/tdeconfigdialogmanager.cpp @@ -0,0 +1,398 @@ +/* + * This file is part of the KDE libraries + * Copyright (C) 2003 Benjamin C Meyer (ben+tdelibs at meyerhome dot net) + * Copyright (C) 2003 Waldo Bastian + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "tdeconfigdialogmanager.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +class TDEConfigDialogManager::Private { + +public: + Private() : insideGroupBox(false) { } + +public: + TQDict knownWidget; + TQDict buddyWidget; + bool insideGroupBox; +}; + +TDEConfigDialogManager::TDEConfigDialogManager(TQWidget *parent, TDEConfigSkeleton *conf, const char *name) + : TQObject(parent, name), m_conf(conf), m_dialog(parent) +{ + d = new Private(); + + kapp->installKDEPropertyMap(); + propertyMap = TQSqlPropertyMap::defaultMap(); + + init(true); +} + +TDEConfigDialogManager::~TDEConfigDialogManager() +{ + delete d; +} + +void TDEConfigDialogManager::init(bool trackChanges) +{ + if(trackChanges) + { + // QT + changedMap.insert(TQBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); + changedMap.insert(TQCHECKBOX_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); + changedMap.insert(TQPUSHBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); + changedMap.insert(TQRADIOBUTTON_OBJECT_NAME_STRING, TQT_SIGNAL(stateChanged(int))); + // We can only store one thing, so you can't have + // a ButtonGroup that is checkable. + changedMap.insert(TQBUTTONGROUP_OBJECT_NAME_STRING, TQT_SIGNAL(clicked(int))); + changedMap.insert(TQGROUPBOX_OBJECT_NAME_STRING, TQT_SIGNAL(toggled(bool))); + changedMap.insert(TQCOMBOBOX_OBJECT_NAME_STRING, TQT_SIGNAL(activated (int))); + //qsqlproperty map doesn't store the text, but the value! + //changedMap.insert(TQCOMBOBOX_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged(const TQString &))); + changedMap.insert(TQDATEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(const TQDate &))); + changedMap.insert(TQDATETIMEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(const TQDateTime &))); + changedMap.insert(TQDIAL_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged (int))); + changedMap.insert(TQLINEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged(const TQString &))); + changedMap.insert(TQSLIDER_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(int))); + changedMap.insert(TQSPINBOX_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(int))); + changedMap.insert(TQTIMEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(valueChanged(const TQTime &))); + changedMap.insert(TQTEXTEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged())); + changedMap.insert(TQTEXTBROWSER_OBJECT_NAME_STRING, TQT_SIGNAL(sourceChanged(const TQString &))); + changedMap.insert(TQMULTILINEEDIT_OBJECT_NAME_STRING, TQT_SIGNAL(textChanged())); + changedMap.insert(TQLISTBOX_OBJECT_NAME_STRING, TQT_SIGNAL(selectionChanged())); + changedMap.insert(TQTABWIDGET_OBJECT_NAME_STRING, TQT_SIGNAL(currentChanged(TQWidget *))); + + // KDE + changedMap.insert( "KComboBox", TQT_SIGNAL(activated (int))); + changedMap.insert( "KFontCombo", TQT_SIGNAL(activated (int))); + changedMap.insert( "KFontRequester", TQT_SIGNAL(fontSelected(const TQFont &))); + changedMap.insert( "KFontChooser", TQT_SIGNAL(fontSelected(const TQFont &))); + changedMap.insert( "KHistoryCombo", TQT_SIGNAL(activated (int))); + + changedMap.insert( "KColorButton", TQT_SIGNAL(changed(const TQColor &))); + changedMap.insert( "KDatePicker", TQT_SIGNAL(dateSelected (TQDate))); + changedMap.insert( "KDateWidget", TQT_SIGNAL(changed (TQDate))); + changedMap.insert( "KDateTimeWidget", TQT_SIGNAL(valueChanged (const TQDateTime &))); + changedMap.insert( "KEditListBox", TQT_SIGNAL(changed())); + changedMap.insert( "KListBox", TQT_SIGNAL(selectionChanged())); + changedMap.insert( "KLineEdit", TQT_SIGNAL(textChanged(const TQString &))); + changedMap.insert( "KPasswordEdit", TQT_SIGNAL(textChanged(const TQString &))); + changedMap.insert( "KRestrictedLine", TQT_SIGNAL(textChanged(const TQString &))); + changedMap.insert( "KTextBrowser", TQT_SIGNAL(sourceChanged(const TQString &))); + changedMap.insert( "KTextEdit", TQT_SIGNAL(textChanged())); + changedMap.insert( "KURLRequester", TQT_SIGNAL(textChanged (const TQString& ))); + changedMap.insert( "KIntNumInput", TQT_SIGNAL(valueChanged (int))); + changedMap.insert( "KIntSpinBox", TQT_SIGNAL(valueChanged (int))); + changedMap.insert( "KDoubleNumInput", TQT_SIGNAL(valueChanged (double))); + } + + // Go through all of the children of the widgets and find all known widgets + (void) parseChildren(m_dialog, trackChanges); +} + +void TDEConfigDialogManager::addWidget(TQWidget *widget) +{ + (void) parseChildren(widget, true); +} + +void TDEConfigDialogManager::setupWidget(TQWidget *widget, TDEConfigSkeletonItem *item) +{ + TQVariant minValue = item->minValue(); + if (minValue.isValid()) + { + if (widget->metaObject()->findProperty("minValue", true) != -1) + widget->setProperty("minValue", minValue); + } + TQVariant maxValue = item->maxValue(); + if (maxValue.isValid()) + { + if (widget->metaObject()->findProperty("maxValue", true) != -1) + widget->setProperty("maxValue", maxValue); + } + if (TQWhatsThis::textFor( widget ).isEmpty()) + { + TQString whatsThis = item->whatsThis(); + if ( !whatsThis.isEmpty() ) + { + TQWhatsThis::add( widget, whatsThis ); + } + } +} + +bool TDEConfigDialogManager::parseChildren(const TQWidget *widget, bool trackChanges) +{ + bool valueChanged = false; + const TQObjectList listOfChildren = widget->childrenListObject(); + if(listOfChildren.isEmpty()) + return valueChanged; + + TQObject *object; + for( TQObjectListIterator it( listOfChildren ); + (object = it.current()); ++it ) + { + if(!object->isWidgetType()) + continue; // Skip non-widgets + + TQWidget *childWidget = (TQWidget *)object; + + const char *widgetName = childWidget->name(0); + bool bParseChildren = true; + bool bSaveInsideGroupBox = d->insideGroupBox; + + if (widgetName && (strncmp(widgetName, "kcfg_", 5) == 0)) + { + // This is one of our widgets! + TQString configId = widgetName+5; + TDEConfigSkeletonItem *item = m_conf->findItem(configId); + if (item) + { + d->knownWidget.insert(configId, childWidget); + + setupWidget(childWidget, item); + + TQMap::const_iterator changedIt = changedMap.find(childWidget->className()); + + if (changedIt == changedMap.end()) + { + // If the class name of the widget wasn't in the monitored widgets map, then look for + // it again using the super class name. This fixes a problem with using QtRuby/Korundum + // widgets with TDEConfigXT where 'Qt::Widget' wasn't being seen a the real deal, even + // though it was a 'QWidget'. + changedIt = changedMap.find(childWidget->metaObject()->superClassName()); + } + + if (changedIt == changedMap.end()) + { + kdWarning(178) << "Don't know how to monitor widget '" << childWidget->className() << "' for changes!" << endl; + } + else + { + connect(childWidget, *changedIt, + this, TQT_SIGNAL(widgetModified())); + + TQGroupBox *gb = dynamic_cast(childWidget); + if (!gb) + bParseChildren = false; + else + d->insideGroupBox = true; + + TQComboBox *cb = dynamic_cast(childWidget); + if (cb && cb->editable()) + connect(cb, TQT_SIGNAL(textChanged(const TQString &)), + this, TQT_SIGNAL(widgetModified())); + } + } + else + { + kdWarning(178) << "A widget named '" << widgetName << "' was found but there is no setting named '" << configId << "'" << endl; + } + } + else if (childWidget->inherits(TQLABEL_OBJECT_NAME_STRING)) + { + TQLabel *label = static_cast(childWidget); + TQWidget *buddy = label->buddy(); + if (!buddy) + continue; + const char *buddyName = buddy->name(0); + if (buddyName && (strncmp(buddyName, "kcfg_", 5) == 0)) + { + // This is one of our widgets! + TQString configId = buddyName+5; + d->buddyWidget.insert(configId, childWidget); + } + } +#ifndef NDEBUG + else if (widgetName) + { + TQMap::const_iterator changedIt = changedMap.find(childWidget->className()); + if (changedIt != changedMap.end()) + { + if ((!d->insideGroupBox || !childWidget->inherits(TQRADIOBUTTON_OBJECT_NAME_STRING)) && + !childWidget->inherits(TQGROUPBOX_OBJECT_NAME_STRING)) + kdDebug(178) << "Widget '" << widgetName << "' (" << childWidget->className() << ") remains unmanaged." << endl; + } + } +#endif + + if(bParseChildren) + { + // this widget is not known as something we can store. + // Maybe we can store one of its children. + valueChanged |= parseChildren(childWidget, trackChanges); + } + d->insideGroupBox = bSaveInsideGroupBox; + } + return valueChanged; +} + +void TDEConfigDialogManager::updateWidgets() +{ + bool changed = false; + bool bSignalsBlocked = signalsBlocked(); + blockSignals(true); + + TQWidget *widget; + for( TQDictIterator it( d->knownWidget ); + (widget = it.current()); ++it ) + { + TDEConfigSkeletonItem *item = m_conf->findItem(it.currentKey()); + if (!item) + { + kdWarning(178) << "The setting '" << it.currentKey() << "' has disappeared!" << endl; + continue; + } + + TQVariant p = item->property(); + if (p != property(widget)) + { + setProperty(widget, p); +// kdDebug(178) << "The setting '" << it.currentKey() << "' [" << widget->className() << "] has changed" << endl; + changed = true; + } + if (item->isImmutable()) + { + widget->setEnabled(false); + TQWidget *buddy = d->buddyWidget.find(it.currentKey()); + if (buddy) + buddy->setEnabled(false); + } + } + blockSignals(bSignalsBlocked); + + if (changed) + TQTimer::singleShot(0, this, TQT_SIGNAL(widgetModified())); +} + +void TDEConfigDialogManager::updateWidgetsDefault() +{ + bool bUseDefaults = m_conf->useDefaults(true); + updateWidgets(); + m_conf->useDefaults(bUseDefaults); +} + +void TDEConfigDialogManager::updateSettings() +{ + bool changed = false; + + TQWidget *widget; + for( TQDictIterator it( d->knownWidget ); + (widget = it.current()); ++it ) + { + TDEConfigSkeletonItem *item = m_conf->findItem(it.currentKey()); + if (!item) + { + kdWarning(178) << "The setting '" << it.currentKey() << "' has disappeared!" << endl; + continue; + } + + TQVariant p = property(widget); + if (p != item->property()) + { + item->setProperty(p); + changed = true; + } + } + if (changed) + { + m_conf->writeConfig(); + emit settingsChanged(); + } +} + +void TDEConfigDialogManager::setProperty(TQWidget *w, const TQVariant &v) +{ + TQButtonGroup *bg = dynamic_cast(w); + if (bg) + { + bg->setButton(v.toInt()); + return; + } + + TQComboBox *cb = dynamic_cast(w); + if (cb && cb->editable()) + { + cb->setCurrentText(v.toString()); + return; + } + + propertyMap->setProperty(w, v); +} + +TQVariant TDEConfigDialogManager::property(TQWidget *w) +{ + TQButtonGroup *bg = dynamic_cast(w); + if (bg) + return TQVariant(bg->selectedId()); + + TQComboBox *cb = dynamic_cast(w); + if (cb && cb->editable()) + return TQVariant(cb->currentText()); + + return propertyMap->property(w); +} + +bool TDEConfigDialogManager::hasChanged() +{ + + TQWidget *widget; + for( TQDictIterator it( d->knownWidget ); + (widget = it.current()); ++it ) + { + TDEConfigSkeletonItem *item = m_conf->findItem(it.currentKey()); + if (!item) + { + kdWarning(178) << "The setting '" << it.currentKey() << "' has disappeared!" << endl; + continue; + } + + TQVariant p = property(widget); + if (p != item->property()) + { +// kdDebug(178) << "Widget for '" << it.currentKey() << "' has changed." << endl; + return true; + } + } + return false; +} + +bool TDEConfigDialogManager::isDefault() +{ + bool bUseDefaults = m_conf->useDefaults(true); + bool result = !hasChanged(); + m_conf->useDefaults(bUseDefaults); + return result; +} + +#include "tdeconfigdialogmanager.moc" + diff --git a/tdecore/tdeconfigdialogmanager.h b/tdecore/tdeconfigdialogmanager.h new file mode 100644 index 000000000..1b82e9eda --- /dev/null +++ b/tdecore/tdeconfigdialogmanager.h @@ -0,0 +1,236 @@ +/* + * This file is part of the KDE libraries + * Copyright (C) 2003 Benjamin C Meyer (ben+tdelibs at meyerhome dot net) + * Copyright (C) 2003 Waldo Bastian + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +#ifndef KCONFIGDIALOGMANAGER_H +#define KCONFIGDIALOGMANAGER_H + +#include +#include +#include "tdelibs_export.h" + +class TDEConfigSkeleton; +class TDEConfigSkeletonItem; +class TQWidget; +class TQSqlPropertyMap; + +/** + * @short Provides a means of automatically retrieving, + * saving and resetting TDEConfigSkeleton based settings in a dialog. + * + * The TDEConfigDialogManager class provides a means of automatically + * retrieving, saving and resetting basic settings. + * It also can emit signals when settings have been changed + * (settings were saved) or modified (the user changes a checkbox + * from on to off). + * + * The names of the widgets to be managed have to correspond to the names of the + * configuration entries in the TDEConfigSkeleton object plus an additional + * "kcfg_" prefix. For example a widget named "kcfg_MyOption" would be + * associated to the configuration entry "MyOption". + * + * TDEConfigDialogManager uses the TQSqlPropertyMap class to determine if it can do + * anything to a widget. Note that TDEConfigDialogManager doesn't require a + * database, it simply uses the functionality that is built into the + * TQSqlPropertyMap class. New widgets can be added to the map using + * TQSqlPropertyMap::installDefaultMap(). Note that you can't just add any + * class. The class must have a matching TQ_PROPERTY(...) macro defined. + * + * For example (note that KColorButton is already added and it doesn't need to + * manually added): + * + * kcolorbutton.h defines the following property: + * \code + * TQ_PROPERTY( TQColor color READ color WRITE setColor ) + * \endcode + * + * To add KColorButton the following code would be inserted in the main. + * + * \code + * kapp->installKDEPropertyMap(); + * TQSqlPropertyMap *map = TQSqlPropertyMap::defaultMap(); + * map->insert("KColorButton", "color"); + * \endcode + * + * If you add a new widget to the TQSqlPropertyMap and wish to be notified when + * it is modified you should add its signal using addWidgetChangedSignal(). + + * @since 3.2 + * @author Benjamin C Meyer + * @author Waldo Bastian + */ +class TDECORE_EXPORT TDEConfigDialogManager : public TQObject { + +Q_OBJECT + +signals: + /** + * One or more of the settings have been saved (such as when the user + * clicks on the Apply button). This is only emitted by updateSettings() + * whenever one or more setting were changed and consequently saved. + */ + void settingsChanged(); + + /** + * TODO: Verify + * One or more of the settings have been changed. + * @param widget - The widget group (pass in via addWidget()) that + * contains the one or more modified setting. + * @see settingsChanged() + */ + void settingsChanged( TQWidget *widget ); + + /** + * If retrieveSettings() was told to track changes then if + * any known setting was changed this signal will be emitted. Note + * that a settings can be modified several times and might go back to the + * original saved state. hasChanged() will tell you if anything has + * actually changed from the saved values. + */ + void widgetModified(); + + +public: + + /** + * Constructor. + * @param parent Dialog widget to manage + * @param conf Object that contains settings + * @param name - Object name. + */ + TDEConfigDialogManager(TQWidget *parent, TDEConfigSkeleton *conf, const char *name=0); + + /** + * Destructor. + */ + ~TDEConfigDialogManager(); + + /** + * Add additional widgets to manage + * @param widget Additional widget to manage, inlcuding all its children + */ + void addWidget(TQWidget *widget); + + /** + * Returns whether the current state of the known widgets are + * different from the state in the config object. + */ + bool hasChanged(); + + /** + * Returns whether the current state of the known widgets are + * the same as the default state in the config object. + */ + bool isDefault(); + +public slots: + /** + * Traverse the specified widgets, saving the settings of all known + * widgets in the settings object. + * + * Example use: User clicks Ok or Apply button in a configure dialog. + */ + void updateSettings(); + + /** + * Traverse the specified widgets, sets the state of all known + * widgets according to the state in the settings object. + * + * Example use: Initialisation of dialog. + * Example use: User clicks Reset button in a configure dialog. + */ + void updateWidgets(); + + /** + * Traverse the specified widgets, sets the state of all known + * widgets according to the default state in the settings object. + * + * Example use: User clicks Defaults button in a configure dialog. + */ + void updateWidgetsDefault(); + +protected: + + /** + * @param trackChanges - If any changes by the widgets should be tracked + * set true. This causes the emitting the modified() signal when + * something changes. + * TODO: @return bool - True if any setting was changed from the default. + */ + void init(bool trackChanges); + + /** + * Recursive function that finds all known children. + * Goes through the children of widget and if any are known and not being + * ignored, stores them in currentGroup. Also checks if the widget + * should be disabled because it is set immutable. + * @param widget - Parent of the children to look at. + * @param trackChanges - If true then tracks any changes to the children of + * widget that are known. + * @return bool - If a widget was set to something other then its default. + */ + bool parseChildren(const TQWidget *widget, bool trackChanges); + + /** + * Set a property + */ + void setProperty(TQWidget *w, const TQVariant &v); + + /** + * Retrieve a property + */ + TQVariant property(TQWidget *w); + + /** + * Setup secondary widget properties + */ + void setupWidget(TQWidget *widget, TDEConfigSkeletonItem *item); + +protected: + /** + * TDEConfigSkeleton object used to store settings + */ + TDEConfigSkeleton *m_conf; + + /** + * Dialog being managed + */ + TQWidget *m_dialog; + + /** + * Pointer to the property map for easy access. + */ + TQSqlPropertyMap *propertyMap; + + /** + * Map of the classes and the signals that they emit when changed. + */ + TQMap changedMap; + +private: + class Private; + /** + * TDEConfigDialogManager Private class. + */ + Private *d; + +}; + +#endif // KCONFIGDIALOGMANAGER_H + diff --git a/tdecore/tdeconfigskeleton.cpp b/tdecore/tdeconfigskeleton.cpp new file mode 100644 index 000000000..0990949d0 --- /dev/null +++ b/tdecore/tdeconfigskeleton.cpp @@ -0,0 +1,1207 @@ +/* + This file is part of KOrganizer. + Copyright (c) 2000,2001 Cornelius Schumacher + Copyright (c) 2003 Waldo Bastian + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include + +#include +#include +#include +#include +#include + +#include "kstringhandler.h" + +#include "tdeconfigskeleton.h" + +void TDEConfigSkeletonItem::readImmutability( TDEConfig *config ) +{ + mIsImmutable = config->entryIsImmutable( mKey ); +} + + +TDEConfigSkeleton::ItemString::ItemString( const TQString &group, const TQString &key, + TQString &reference, + const TQString &defaultValue, + Type type ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ), + mType( type ) +{ +} + +void TDEConfigSkeleton::ItemString::writeConfig( TDEConfig *config ) +{ + if ( mReference != mLoadedValue ) // WABA: Is this test needed? + { + config->setGroup( mGroup ); + if ((mDefault == mReference) && !config->hasDefault( mKey)) + config->revertToDefault( mKey ); + else if ( mType == Path ) + config->writePathEntry( mKey, mReference ); + else if ( mType == Password ) + config->writeEntry( mKey, KStringHandler::obscure( mReference ) ); + else + config->writeEntry( mKey, mReference ); + } +} + + +void TDEConfigSkeleton::ItemString::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + + if ( mType == Path ) + { + mReference = config->readPathEntry( mKey, mDefault ); + } + else if ( mType == Password ) + { + TQString value = config->readEntry( mKey, + KStringHandler::obscure( mDefault ) ); + mReference = KStringHandler::obscure( value ); + } + else + { + mReference = config->readEntry( mKey, mDefault ); + } + + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemString::setProperty(const TQVariant & p) +{ + mReference = p.toString(); +} + +TQVariant TDEConfigSkeleton::ItemString::property() const +{ + return TQVariant(mReference); +} + +TDEConfigSkeleton::ItemPassword::ItemPassword( const TQString &group, const TQString &key, + TQString &reference, + const TQString &defaultValue) + : ItemString( group, key, reference, defaultValue, Password ) +{ +} + +TDEConfigSkeleton::ItemPath::ItemPath( const TQString &group, const TQString &key, + TQString &reference, + const TQString &defaultValue) + : ItemString( group, key, reference, defaultValue, Path ) +{ +} + +TDEConfigSkeleton::ItemProperty::ItemProperty( const TQString &group, + const TQString &key, + TQVariant &reference, + TQVariant defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) +{ +} + +void TDEConfigSkeleton::ItemProperty::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readPropertyEntry( mKey, mDefault ); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemProperty::setProperty(const TQVariant & p) +{ + mReference = p; +} + +TQVariant TDEConfigSkeleton::ItemProperty::property() const +{ + return mReference; +} + +TDEConfigSkeleton::ItemBool::ItemBool( const TQString &group, const TQString &key, + bool &reference, bool defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) +{ +} + +void TDEConfigSkeleton::ItemBool::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readBoolEntry( mKey, mDefault ); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemBool::setProperty(const TQVariant & p) +{ + mReference = p.toBool(); +} + +TQVariant TDEConfigSkeleton::ItemBool::property() const +{ + return TQVariant( mReference, 42 /* dummy */ ); +} + + +TDEConfigSkeleton::ItemInt::ItemInt( const TQString &group, const TQString &key, + int &reference, int defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) + ,mHasMin(false), mHasMax(false) +{ +} + +void TDEConfigSkeleton::ItemInt::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readNumEntry( mKey, mDefault ); + if (mHasMin) + mReference = QMAX(mReference, mMin); + if (mHasMax) + mReference = QMIN(mReference, mMax); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemInt::setProperty(const TQVariant & p) +{ + mReference = p.toInt(); +} + +TQVariant TDEConfigSkeleton::ItemInt::property() const +{ + return TQVariant(mReference); +} + +TQVariant TDEConfigSkeleton::ItemInt::minValue() const +{ + if (mHasMin) + return TQVariant(mMin); + return TQVariant(); +} + +TQVariant TDEConfigSkeleton::ItemInt::maxValue() const +{ + if (mHasMax) + return TQVariant(mMax); + return TQVariant(); +} + +void TDEConfigSkeleton::ItemInt::setMinValue(int v) +{ + mHasMin = true; + mMin = v; +} + +void TDEConfigSkeleton::ItemInt::setMaxValue(int v) +{ + mHasMax = true; + mMax = v; +} + + +TDEConfigSkeleton::ItemInt64::ItemInt64( const TQString &group, const TQString &key, + TQ_INT64 &reference, TQ_INT64 defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) + ,mHasMin(false), mHasMax(false) +{ +} + +void TDEConfigSkeleton::ItemInt64::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readNum64Entry( mKey, mDefault ); + if (mHasMin) + mReference = QMAX(mReference, mMin); + if (mHasMax) + mReference = QMIN(mReference, mMax); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemInt64::setProperty(const TQVariant & p) +{ + mReference = p.toLongLong(); +} + +TQVariant TDEConfigSkeleton::ItemInt64::property() const +{ + return TQVariant(mReference); +} + +TQVariant TDEConfigSkeleton::ItemInt64::minValue() const +{ + if (mHasMin) + return TQVariant(mMin); + return TQVariant(); +} + +TQVariant TDEConfigSkeleton::ItemInt64::maxValue() const +{ + if (mHasMax) + return TQVariant(mMax); + return TQVariant(); +} + +void TDEConfigSkeleton::ItemInt64::setMinValue(TQ_INT64 v) +{ + mHasMin = true; + mMin = v; +} + +void TDEConfigSkeleton::ItemInt64::setMaxValue(TQ_INT64 v) +{ + mHasMax = true; + mMax = v; +} + +TDEConfigSkeleton::ItemEnum::ItemEnum( const TQString &group, const TQString &key, + int &reference, + const TQValueList &choices, + int defaultValue ) + : ItemInt( group, key, reference, defaultValue ), mChoices( choices ) +{ +} + +void TDEConfigSkeleton::ItemEnum::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + if (!config->hasKey(mKey)) + { + mReference = mDefault; + } + else + { + int i = 0; + mReference = -1; + TQString tmp = config->readEntry( mKey ).lower(); + for(TQValueList::ConstIterator it = mChoices.begin(); + it != mChoices.end(); ++it, ++i) + { + if ((*it).name.lower() == tmp) + { + mReference = i; + break; + } + } + if (mReference == -1) + mReference = config->readNumEntry( mKey, mDefault ); + } + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemEnum::writeConfig( TDEConfig *config ) +{ + if ( mReference != mLoadedValue ) // WABA: Is this test needed? + { + config->setGroup( mGroup ); + if ((mDefault == mReference) && !config->hasDefault( mKey)) + config->revertToDefault( mKey ); + else if ((mReference >= 0) && (mReference < (int) mChoices.count())) + config->writeEntry( mKey, mChoices[mReference].name ); + else + config->writeEntry( mKey, mReference ); + } +} + +TQValueList TDEConfigSkeleton::ItemEnum::choices() const +{ + return mChoices; +} + + +TDEConfigSkeleton::ItemUInt::ItemUInt( const TQString &group, const TQString &key, + unsigned int &reference, + unsigned int defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) + ,mHasMin(false), mHasMax(false) +{ +} + +void TDEConfigSkeleton::ItemUInt::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readUnsignedNumEntry( mKey, mDefault ); + if (mHasMin) + mReference = QMAX(mReference, mMin); + if (mHasMax) + mReference = QMIN(mReference, mMax); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemUInt::setProperty(const TQVariant & p) +{ + mReference = p.toUInt(); +} + +TQVariant TDEConfigSkeleton::ItemUInt::property() const +{ + return TQVariant(mReference); +} + +TQVariant TDEConfigSkeleton::ItemUInt::minValue() const +{ + if (mHasMin) + return TQVariant(mMin); + return TQVariant(); +} + +TQVariant TDEConfigSkeleton::ItemUInt::maxValue() const +{ + if (mHasMax) + return TQVariant(mMax); + return TQVariant(); +} + +void TDEConfigSkeleton::ItemUInt::setMinValue(unsigned int v) +{ + mHasMin = true; + mMin = v; +} + +void TDEConfigSkeleton::ItemUInt::setMaxValue(unsigned int v) +{ + mHasMax = true; + mMax = v; +} + + +TDEConfigSkeleton::ItemUInt64::ItemUInt64( const TQString &group, const TQString &key, + TQ_UINT64 &reference, TQ_UINT64 defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) + ,mHasMin(false), mHasMax(false) +{ +} + +void TDEConfigSkeleton::ItemUInt64::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readUnsignedNum64Entry( mKey, mDefault ); + if (mHasMin) + mReference = QMAX(mReference, mMin); + if (mHasMax) + mReference = QMIN(mReference, mMax); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemUInt64::setProperty(const TQVariant & p) +{ + mReference = p.toULongLong(); +} + +TQVariant TDEConfigSkeleton::ItemUInt64::property() const +{ + return TQVariant(mReference); +} + +TQVariant TDEConfigSkeleton::ItemUInt64::minValue() const +{ + if (mHasMin) + return TQVariant(mMin); + return TQVariant(); +} + +TQVariant TDEConfigSkeleton::ItemUInt64::maxValue() const +{ + if (mHasMax) + return TQVariant(mMax); + return TQVariant(); +} + +void TDEConfigSkeleton::ItemUInt64::setMinValue(TQ_UINT64 v) +{ + mHasMin = true; + mMin = v; +} + +void TDEConfigSkeleton::ItemUInt64::setMaxValue(TQ_UINT64 v) +{ + mHasMax = true; + mMax = v; +} + +TDEConfigSkeleton::ItemLong::ItemLong( const TQString &group, const TQString &key, + long &reference, long defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) + ,mHasMin(false), mHasMax(false) +{ +} + +void TDEConfigSkeleton::ItemLong::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readLongNumEntry( mKey, mDefault ); + if (mHasMin) + mReference = QMAX(mReference, mMin); + if (mHasMax) + mReference = QMIN(mReference, mMax); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemLong::setProperty(const TQVariant & p) +{ + mReference = p.toLongLong(); +} + +TQVariant TDEConfigSkeleton::ItemLong::property() const +{ + return TQVariant((TQ_LLONG) mReference); +} + +TQVariant TDEConfigSkeleton::ItemLong::minValue() const +{ + if (mHasMin) + return TQVariant((TQ_LLONG) mMin); + return TQVariant(); +} + +TQVariant TDEConfigSkeleton::ItemLong::maxValue() const +{ + if (mHasMax) + return TQVariant((TQ_LLONG) mMax); + return TQVariant(); +} + +void TDEConfigSkeleton::ItemLong::setMinValue(long v) +{ + mHasMin = true; + mMin = v; +} + +void TDEConfigSkeleton::ItemLong::setMaxValue(long v) +{ + mHasMax = true; + mMax = v; +} + + +TDEConfigSkeleton::ItemULong::ItemULong( const TQString &group, const TQString &key, + unsigned long &reference, + unsigned long defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) + ,mHasMin(false), mHasMax(false) +{ +} + +void TDEConfigSkeleton::ItemULong::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readUnsignedLongNumEntry( mKey, mDefault ); + if (mHasMin) + mReference = QMAX(mReference, mMin); + if (mHasMax) + mReference = QMIN(mReference, mMax); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemULong::setProperty(const TQVariant & p) +{ + mReference = p.toULongLong(); +} + +TQVariant TDEConfigSkeleton::ItemULong::property() const +{ + return TQVariant((TQ_ULLONG) mReference); +} + +TQVariant TDEConfigSkeleton::ItemULong::minValue() const +{ + if (mHasMin) + return TQVariant((TQ_ULLONG) mMin); + return TQVariant(); +} + +TQVariant TDEConfigSkeleton::ItemULong::maxValue() const +{ + if (mHasMax) + return TQVariant((TQ_ULLONG) mMax); + return TQVariant(); +} + +void TDEConfigSkeleton::ItemULong::setMinValue(unsigned long v) +{ + mHasMin = true; + mMin = v; +} + +void TDEConfigSkeleton::ItemULong::setMaxValue(unsigned long v) +{ + mHasMax = true; + mMax = v; +} + + +TDEConfigSkeleton::ItemDouble::ItemDouble( const TQString &group, const TQString &key, + double &reference, double defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) + ,mHasMin(false), mHasMax(false) +{ +} + +void TDEConfigSkeleton::ItemDouble::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readDoubleNumEntry( mKey, mDefault ); + if (mHasMin) + mReference = QMAX(mReference, mMin); + if (mHasMax) + mReference = QMIN(mReference, mMax); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemDouble::setProperty(const TQVariant & p) +{ + mReference = p.toDouble(); +} + +TQVariant TDEConfigSkeleton::ItemDouble::property() const +{ + return TQVariant(mReference); +} + +TQVariant TDEConfigSkeleton::ItemDouble::minValue() const +{ + if (mHasMin) + return TQVariant(mMin); + return TQVariant(); +} + +TQVariant TDEConfigSkeleton::ItemDouble::maxValue() const +{ + if (mHasMax) + return TQVariant(mMax); + return TQVariant(); +} + +void TDEConfigSkeleton::ItemDouble::setMinValue(double v) +{ + mHasMin = true; + mMin = v; +} + +void TDEConfigSkeleton::ItemDouble::setMaxValue(double v) +{ + mHasMax = true; + mMax = v; +} + + +TDEConfigSkeleton::ItemColor::ItemColor( const TQString &group, const TQString &key, + TQColor &reference, + const TQColor &defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) +{ +} + +void TDEConfigSkeleton::ItemColor::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readColorEntry( mKey, &mDefault ); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemColor::setProperty(const TQVariant & p) +{ + mReference = p.toColor(); +} + +TQVariant TDEConfigSkeleton::ItemColor::property() const +{ + return TQVariant(mReference); +} + + +TDEConfigSkeleton::ItemFont::ItemFont( const TQString &group, const TQString &key, + TQFont &reference, + const TQFont &defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) +{ +} + +void TDEConfigSkeleton::ItemFont::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readFontEntry( mKey, &mDefault ); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemFont::setProperty(const TQVariant & p) +{ + mReference = p.toFont(); +} + +TQVariant TDEConfigSkeleton::ItemFont::property() const +{ + return TQVariant(mReference); +} + + +TDEConfigSkeleton::ItemRect::ItemRect( const TQString &group, const TQString &key, + TQRect &reference, + const TQRect &defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) +{ +} + +void TDEConfigSkeleton::ItemRect::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readRectEntry( mKey, &mDefault ); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemRect::setProperty(const TQVariant & p) +{ + mReference = p.toRect(); +} + +TQVariant TDEConfigSkeleton::ItemRect::property() const +{ + return TQVariant(mReference); +} + + +TDEConfigSkeleton::ItemPoint::ItemPoint( const TQString &group, const TQString &key, + TQPoint &reference, + const TQPoint &defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) +{ +} + +void TDEConfigSkeleton::ItemPoint::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readPointEntry( mKey, &mDefault ); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemPoint::setProperty(const TQVariant & p) +{ + mReference = p.toPoint(); +} + +TQVariant TDEConfigSkeleton::ItemPoint::property() const +{ + return TQVariant(mReference); +} + + +TDEConfigSkeleton::ItemSize::ItemSize( const TQString &group, const TQString &key, + TQSize &reference, + const TQSize &defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) +{ +} + +void TDEConfigSkeleton::ItemSize::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readSizeEntry( mKey, &mDefault ); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemSize::setProperty(const TQVariant & p) +{ + mReference = p.toSize(); +} + +TQVariant TDEConfigSkeleton::ItemSize::property() const +{ + return TQVariant(mReference); +} + + +TDEConfigSkeleton::ItemDateTime::ItemDateTime( const TQString &group, const TQString &key, + TQDateTime &reference, + const TQDateTime &defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) +{ +} + +void TDEConfigSkeleton::ItemDateTime::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + mReference = config->readDateTimeEntry( mKey, &mDefault ); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemDateTime::setProperty(const TQVariant & p) +{ + mReference = p.toDateTime(); +} + +TQVariant TDEConfigSkeleton::ItemDateTime::property() const +{ + return TQVariant(mReference); +} + + +TDEConfigSkeleton::ItemStringList::ItemStringList( const TQString &group, const TQString &key, + TQStringList &reference, + const TQStringList &defaultValue ) + : TDEConfigSkeletonGenericItem( group, key, reference, defaultValue ) +{ +} + +void TDEConfigSkeleton::ItemStringList::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + if ( !config->hasKey( mKey ) ) + mReference = mDefault; + else + mReference = config->readListEntry( mKey ); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemStringList::setProperty(const TQVariant & p) +{ + mReference = p.toStringList(); +} + +TQVariant TDEConfigSkeleton::ItemStringList::property() const +{ + return TQVariant(mReference); +} + + +TDEConfigSkeleton::ItemPathList::ItemPathList( const TQString &group, const TQString &key, + TQStringList &reference, + const TQStringList &defaultValue ) + : ItemStringList( group, key, reference, defaultValue ) +{ +} + +void TDEConfigSkeleton::ItemPathList::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + if ( !config->hasKey( mKey ) ) + mReference = mDefault; + else + mReference = config->readPathListEntry( mKey ); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemPathList::writeConfig( TDEConfig *config ) +{ + if ( mReference != mLoadedValue ) // WABA: Is this test needed? + { + config->setGroup( mGroup ); + if ((mDefault == mReference) && !config->hasDefault( mKey)) + config->revertToDefault( mKey ); + else { + TQStringList sl = mReference; + config->writePathEntry( mKey, sl ); + } + } +} + + +TDEConfigSkeleton::ItemIntList::ItemIntList( const TQString &group, const TQString &key, + TQValueList &reference, + const TQValueList &defaultValue ) + : TDEConfigSkeletonGenericItem >( group, key, reference, defaultValue ) +{ +} + +void TDEConfigSkeleton::ItemIntList::readConfig( TDEConfig *config ) +{ + config->setGroup( mGroup ); + if ( !config->hasKey( mKey ) ) + mReference = mDefault; + else + mReference = config->readIntListEntry( mKey ); + mLoadedValue = mReference; + + readImmutability( config ); +} + +void TDEConfigSkeleton::ItemIntList::setProperty(const TQVariant &) +{ + // TODO: Not yet supported +} + +TQVariant TDEConfigSkeleton::ItemIntList::property() const +{ + // TODO: Not yet supported + return TQVariant(); +} + + +TDEConfigSkeleton::TDEConfigSkeleton( const TQString &configname ) + : mCurrentGroup( "No Group" ), mUseDefaults(false) +{ + kdDebug(177) << "Creating TDEConfigSkeleton (" << (void *)this << ")" << endl; + + if ( !configname.isEmpty() ) + { + mConfig = KSharedConfig::openConfig( configname ); + } + else + { + mConfig = TDEGlobal::sharedConfig(); + } +} + +TDEConfigSkeleton::TDEConfigSkeleton(KSharedConfig::Ptr config) + : mCurrentGroup( "No Group" ), mUseDefaults(false) +{ + kdDebug(177) << "Creating TDEConfigSkeleton (" << (void *)this << ")" << endl; + mConfig = config; +} + + +TDEConfigSkeleton::~TDEConfigSkeleton() +{ + TDEConfigSkeletonItem::List::ConstIterator it; + for( it = mItems.begin(); it != mItems.end(); ++it ) + { + delete *it; + } +} + +void TDEConfigSkeleton::setCurrentGroup( const TQString &group ) +{ + mCurrentGroup = group; +} + +TDEConfig *TDEConfigSkeleton::config() const +{ + return mConfig; +} + +bool TDEConfigSkeleton::useDefaults(bool b) +{ + if (b == mUseDefaults) + return mUseDefaults; + + mUseDefaults = b; + TDEConfigSkeletonItem::List::ConstIterator it; + for( it = mItems.begin(); it != mItems.end(); ++it ) + { + (*it)->swapDefault(); + } + + usrUseDefaults(b); + return !mUseDefaults; +} + +void TDEConfigSkeleton::setDefaults() +{ + TDEConfigSkeletonItem::List::ConstIterator it; + for( it = mItems.begin(); it != mItems.end(); ++it ) { + (*it)->setDefault(); + } + + usrSetDefaults(); +} + +void TDEConfigSkeleton::readConfig() +{ + kdDebug(177) << "TDEConfigSkeleton::readConfig()" << endl; + + TQString origGroup = mConfig->group(); + + mConfig->reparseConfiguration(); + TDEConfigSkeletonItem::List::ConstIterator it; + for( it = mItems.begin(); it != mItems.end(); ++it ) + { + (*it)->readConfig( mConfig ); + } + + usrReadConfig(); + + mConfig->setGroup(origGroup); +} + +void TDEConfigSkeleton::writeConfig() +{ + kdDebug(177) << "TDEConfigSkeleton::writeConfig()" << endl; + + TQString origGroup = mConfig->group(); + + TDEConfigSkeletonItem::List::ConstIterator it; + for( it = mItems.begin(); it != mItems.end(); ++it ) + { + (*it)->writeConfig( mConfig ); + } + + usrWriteConfig(); + + mConfig->sync(); + + readConfig(); + + mConfig->setGroup(origGroup); +} + +void TDEConfigSkeleton::addItem( TDEConfigSkeletonItem *item, const TQString &name ) +{ + item->setName( name.isEmpty() ? item->key() : name ); + mItems.append( item ); + mItemDict.insert( item->name(), item ); + item->readDefault( mConfig ); + item->readConfig( mConfig ); +} + +TDEConfigSkeleton::ItemString *TDEConfigSkeleton::addItemString( const TQString &name, TQString &reference, + const TQString &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemString *item; + item = new TDEConfigSkeleton::ItemString( mCurrentGroup, key.isEmpty() ? name : key, + reference, defaultValue, + TDEConfigSkeleton::ItemString::Normal ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemPassword *TDEConfigSkeleton::addItemPassword( const TQString &name, TQString &reference, + const TQString &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemPassword *item; + item = new TDEConfigSkeleton::ItemPassword( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemPath *TDEConfigSkeleton::addItemPath( const TQString &name, TQString &reference, + const TQString &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemPath *item; + item = new TDEConfigSkeleton::ItemPath( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemProperty *TDEConfigSkeleton::addItemProperty( const TQString &name, TQVariant &reference, + const TQVariant &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemProperty *item; + item = new TDEConfigSkeleton::ItemProperty( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemBool *TDEConfigSkeleton::addItemBool( const TQString &name, bool &reference, + bool defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemBool *item; + item = new TDEConfigSkeleton::ItemBool( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemInt *TDEConfigSkeleton::addItemInt( const TQString &name, int &reference, + int defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemInt *item; + item = new TDEConfigSkeleton::ItemInt( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemUInt *TDEConfigSkeleton::addItemUInt( const TQString &name, unsigned int &reference, + unsigned int defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemUInt *item; + item = new TDEConfigSkeleton::ItemUInt( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemInt64 *TDEConfigSkeleton::addItemInt64( const TQString &name, TQ_INT64 &reference, + TQ_INT64 defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemInt64 *item; + item = new TDEConfigSkeleton::ItemInt64( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemUInt64 *TDEConfigSkeleton::addItemUInt64( const TQString &name, TQ_UINT64 &reference, + TQ_UINT64 defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemUInt64 *item; + item = new TDEConfigSkeleton::ItemUInt64( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemLong *TDEConfigSkeleton::addItemLong( const TQString &name, long &reference, + long defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemLong *item; + item = new TDEConfigSkeleton::ItemLong( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemULong *TDEConfigSkeleton::addItemULong( const TQString &name, unsigned long &reference, + unsigned long defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemULong *item; + item = new TDEConfigSkeleton::ItemULong( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemDouble *TDEConfigSkeleton::addItemDouble( const TQString &name, double &reference, + double defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemDouble *item; + item = new TDEConfigSkeleton::ItemDouble( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemColor *TDEConfigSkeleton::addItemColor( const TQString &name, TQColor &reference, + const TQColor &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemColor *item; + item = new TDEConfigSkeleton::ItemColor( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemFont *TDEConfigSkeleton::addItemFont( const TQString &name, TQFont &reference, + const TQFont &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemFont *item; + item = new TDEConfigSkeleton::ItemFont( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemRect *TDEConfigSkeleton::addItemRect( const TQString &name, TQRect &reference, + const TQRect &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemRect *item; + item = new TDEConfigSkeleton::ItemRect( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemPoint *TDEConfigSkeleton::addItemPoint( const TQString &name, TQPoint &reference, + const TQPoint &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemPoint *item; + item = new TDEConfigSkeleton::ItemPoint( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemSize *TDEConfigSkeleton::addItemSize( const TQString &name, TQSize &reference, + const TQSize &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemSize *item; + item = new TDEConfigSkeleton::ItemSize( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemDateTime *TDEConfigSkeleton::addItemDateTime( const TQString &name, TQDateTime &reference, + const TQDateTime &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemDateTime *item; + item = new TDEConfigSkeleton::ItemDateTime( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemStringList *TDEConfigSkeleton::addItemStringList( const TQString &name, TQStringList &reference, + const TQStringList &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemStringList *item; + item = new TDEConfigSkeleton::ItemStringList( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +TDEConfigSkeleton::ItemIntList *TDEConfigSkeleton::addItemIntList( const TQString &name, TQValueList &reference, + const TQValueList &defaultValue, const TQString &key ) +{ + TDEConfigSkeleton::ItemIntList *item; + item = new TDEConfigSkeleton::ItemIntList( mCurrentGroup, key.isNull() ? name : key, + reference, defaultValue ); + addItem( item, name ); + return item; +} + +bool TDEConfigSkeleton::isImmutable(const TQString &name) +{ + TDEConfigSkeletonItem *item = findItem(name); + return !item || item->isImmutable(); +} + +TDEConfigSkeletonItem *TDEConfigSkeleton::findItem(const TQString &name) +{ + return mItemDict.find(name); +} diff --git a/tdecore/tdeconfigskeleton.h b/tdecore/tdeconfigskeleton.h new file mode 100644 index 000000000..d9424e9df --- /dev/null +++ b/tdecore/tdeconfigskeleton.h @@ -0,0 +1,1230 @@ +/* + * This file is part of KDE. + * + * Copyright (c) 2001,2002,2003 Cornelius Schumacher + * Copyright (c) 2003 Waldo Bastian + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _KCONFIGSKELETON_H +#define _KCONFIGSKELETON_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + /** + * @short Class for storing a preferences setting + * @author Cornelius Schumacher + * @see TDEConfigSkeleton + * + * This class represents one preferences setting as used by @ref TDEConfigSkeleton. + * Subclasses of TDEConfigSkeletonItem implement storage functions for a certain type of + * setting. Normally you don't have to use this class directly. Use the special + * addItem() functions of TDEConfigSkeleton instead. If you subclass this class you will + * have to register instances with the function TDEConfigSkeleton::addItem(). + */ + class TDECORE_EXPORT TDEConfigSkeletonItem + { + public: + typedef TQValueList < TDEConfigSkeletonItem * >List; + typedef TQDict < TDEConfigSkeletonItem > Dict; + typedef TQDictIterator < TDEConfigSkeletonItem > DictIterator; + + /** + * Constructor. + * + * @param group Config file group. + * @param key Config file key. + */ + TDEConfigSkeletonItem(const TQString & group, const TQString & key) + :mGroup(group),mKey(key), mIsImmutable(true) + { + } + + /** + * Destructor. + */ + virtual ~TDEConfigSkeletonItem() + { + } + + /** + * Set config file group. + */ + void setGroup( const TQString &group ) + { + mGroup = group; + } + + /** + * Return config file group. + */ + TQString group() const + { + return mGroup; + } + + /** + * Set config file key. + */ + void setKey( const TQString &key ) + { + mKey = key; + } + + /** + * Return config file key. + */ + TQString key() const + { + return mKey; + } + + /** + * Set internal name of entry. + */ + void setName(const TQString &name) + { + mName = name; + } + + /** + * Return internal name of entry. + */ + TQString name() const + { + return mName; + } + + /** + Set label providing a translated one-line description of the item. + */ + void setLabel( const TQString &l ) + { + mLabel = l; + } + + /** + Return label of item. See setLabel(). + */ + TQString label() const + { + return mLabel; + } + + /** + Set WhatsThis description og item. + */ + void setWhatsThis( const TQString &w ) + { + mWhatsThis = w; + } + + /** + Return WhatsThis description of item. See setWhatsThis(). + */ + TQString whatsThis() const + { + return mWhatsThis; + } + + /** + * This function is called by @ref TDEConfigSkeleton to read the value for this setting + * from a config file. + * value. + */ + virtual void readConfig(TDEConfig *) = 0; + + /** + * This function is called by @ref TDEConfigSkeleton to write the value of this setting + * to a config file. + */ + virtual void writeConfig(TDEConfig *) = 0; + + /** + * Read global default value. + */ + virtual void readDefault(TDEConfig *) = 0; + + /** + * Set item to @p p + */ + virtual void setProperty(const TQVariant &p) = 0; + + /** + * Return item as property + */ + virtual TQVariant property() const = 0; + + /** + * Return minimum value of item or invalid if not specified + */ + virtual TQVariant minValue() const { return TQVariant(); } + + /** + * Return maximum value of item or invalid if not specified + */ + virtual TQVariant maxValue() const { return TQVariant(); } + + /** + Sets the current value to the default value. + */ + virtual void setDefault() = 0; + + /** + * Exchanges the current value with the default value + * Used by TDEConfigSkeleton::useDefaults(bool); + */ + virtual void swapDefault() = 0; + + /** + * Return if the entry can be modified. + */ + bool isImmutable() const + { + return mIsImmutable; + } + + protected: + /** + * sets mIsImmutable to true if mKey in config is immutable + * @param config TDEConfig to check if mKey is immutable in + */ + void readImmutability(TDEConfig *config); + + TQString mGroup; + TQString mKey; + TQString mName; + + private: + bool mIsImmutable; + + TQString mLabel; + TQString mWhatsThis; + }; + + +template < typename T > class TDEConfigSkeletonGenericItem:public TDEConfigSkeletonItem + { + public: + TDEConfigSkeletonGenericItem(const TQString & group, const TQString & key, T & reference, + T defaultValue) + : TDEConfigSkeletonItem(group, key), mReference(reference), + mDefault(defaultValue), mLoadedValue(defaultValue) + { + } + + /** + * Set value of this TDEConfigSkeletonItem. + */ + void setValue(const T & v) + { + mReference = v; + } + + /** + * Return value of this TDEConfigSkeletonItem. + */ + T & value() + { + return mReference; + } + + /** + * Return const value of this TDEConfigSkeletonItem. + */ + const T & value() const + { + return mReference; + } + + /** + Set default value for this item. + */ + virtual void setDefaultValue( const T &v ) + { + mDefault = v; + } + + virtual void setDefault() + { + mReference = mDefault; + } + + virtual void writeConfig(TDEConfig * config) + { + if ( mReference != mLoadedValue ) // Is this needed? + { + config->setGroup(mGroup); + if ((mDefault == mReference) && !config->hasDefault( mKey)) + config->revertToDefault( mKey ); + else + config->writeEntry(mKey, mReference); + } + } + + void readDefault(TDEConfig * config) + { + config->setReadDefaults(true); + readConfig(config); + config->setReadDefaults(false); + mDefault = mReference; + } + + void swapDefault() + { + T tmp = mReference; + mReference = mDefault; + mDefault = tmp; + } + + protected: + T & mReference; + T mDefault; + T mLoadedValue; + }; + + /** + * @short Class for handling preferences settings for an application. + * @author Cornelius Schumacher + * @see TDEConfigSkeletonItem + * + * This class provides an interface to preferences settings. Preferences items + * can be registered by the addItem() function corresponding to the data type of + * the seetting. TDEConfigSkeleton then handles reading and writing of config files and + * setting of default values. + * + * Normally you will subclass TDEConfigSkeleton, add data members for the preferences + * settings and register the members in the constructor of the subclass. + * + * Example: + * \code + * class MyPrefs : public TDEConfigSkeleton + * { + * public: + * MyPrefs() + * { + * setCurrentGroup("MyGroup"); + * addItemBool("MySetting1",mMyBool,false); + * addItemColor("MySetting2",mMyColor,TQColor(1,2,3)); + * + * setCurrentGroup("MyOtherGroup"); + * addItemFont("MySetting3",mMyFont,TQFont("helvetica",12)); + * } + * + * bool mMyBool; + * TQColor mMyColor; + * TQFont mMyFont; + * } + * \endcode + * + * It might be convenient in many cases to make this subclass of TDEConfigSkeleton a + * singleton for global access from all over the application without passing + * references to the TDEConfigSkeleton object around. + * + * You can write the data to the configuration file by calling @ref writeConfig() + * and read the data from the configuration file by calling @ref readConfig(). + * + * If you have items, which are not covered by the existing addItem() functions + * you can add customized code for reading, writing and default setting by + * implementing the functions @ref usrUseDefaults(), @ref usrReadConfig() and + * @ref usrWriteConfig(). + * + * Internally preferences settings are stored in instances of subclasses of + * @ref TDEConfigSkeletonItem. You can also add TDEConfigSkeletonItem subclasses + * for your own types and call the generic @ref addItem() to register them. + * + * In many cases you don't have to write the specific TDEConfigSkeleton + * subclasses yourself, but you can use \ref tdeconfig_compiler to automatically + * generate the C++ code from an XML description of the configuration options. + */ +class TDECORE_EXPORT TDEConfigSkeleton +{ +public: + + /** + * Class for handling a string preferences item. + */ + class TDECORE_EXPORT ItemString:public TDEConfigSkeletonGenericItem < TQString > + { + public: + enum Type { Normal, Password, Path }; + + ItemString(const TQString & group, const TQString & key, + TQString & reference, + const TQString & defaultValue = TQString::fromLatin1(""), // NOT TQString::null !! + Type type = Normal); + + void writeConfig(TDEConfig * config); + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + + private: + Type mType; + }; + + /** + * Class for handling a password preferences item. + */ + class TDECORE_EXPORT ItemPassword:public ItemString + { + public: + ItemPassword(const TQString & group, const TQString & key, + TQString & reference, + const TQString & defaultValue = TQString::fromLatin1("")); // NOT TQString::null !! + }; + + /** + * Class for handling a path preferences item. + */ + class TDECORE_EXPORT ItemPath:public ItemString + { + public: + ItemPath(const TQString & group, const TQString & key, + TQString & reference, + const TQString & defaultValue = TQString::null); + }; + + + /** + * Class for handling a TQVariant preferences item. + */ + class TDECORE_EXPORT ItemProperty:public TDEConfigSkeletonGenericItem < TQVariant > + { + public: + ItemProperty(const TQString & group, const TQString & key, + TQVariant & reference, TQVariant defaultValue = 0); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + }; + + + /** + * Class for handling a bool preferences item. + */ + class TDECORE_EXPORT ItemBool:public TDEConfigSkeletonGenericItem < bool > + { + public: + ItemBool(const TQString & group, const TQString & key, bool & reference, + bool defaultValue = true); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + }; + + + /** + * Class for handling an integer preferences item. + */ + class TDECORE_EXPORT ItemInt:public TDEConfigSkeletonGenericItem < int > + { + public: + ItemInt(const TQString & group, const TQString & key, int &reference, + int defaultValue = 0); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + TQVariant minValue() const; + TQVariant maxValue() const; + + void setMinValue(int); + void setMaxValue(int); + + private: + bool mHasMin : 1; + bool mHasMax : 1; + int mMin; + int mMax; + }; + + /** + * Class for handling an 64-bit integer preferences item. + */ + class TDECORE_EXPORT ItemInt64:public TDEConfigSkeletonGenericItem < TQ_INT64 > + { + public: + ItemInt64(const TQString & group, const TQString & key, TQ_INT64 &reference, + TQ_INT64 defaultValue = 0); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + + TQVariant minValue() const; + TQVariant maxValue() const; + + void setMinValue(TQ_INT64); + void setMaxValue(TQ_INT64); + + private: + bool mHasMin : 1; + bool mHasMax : 1; + TQ_INT64 mMin; + TQ_INT64 mMax; + }; + + /** + * Class for handling enums. + */ + class TDECORE_EXPORT ItemEnum:public ItemInt + { + public: + struct Choice + { + TQString name; + TQString label; + TQString whatsThis; + }; + + ItemEnum(const TQString & group, const TQString & key, int &reference, + const TQValueList &choices, int defaultValue = 0); + + TQValueList choices() const; + + void readConfig(TDEConfig * config); + void writeConfig(TDEConfig * config); + + private: + TQValueList mChoices; + }; + + + /** + * Class for handling an unsingend integer preferences item. + */ + class TDECORE_EXPORT ItemUInt:public TDEConfigSkeletonGenericItem < unsigned int > + { + public: + ItemUInt(const TQString & group, const TQString & key, + unsigned int &reference, unsigned int defaultValue = 0); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + TQVariant minValue() const; + TQVariant maxValue() const; + + void setMinValue(unsigned int); + void setMaxValue(unsigned int); + + private: + bool mHasMin : 1; + bool mHasMax : 1; + unsigned int mMin; + unsigned int mMax; + }; + + + /** + * Class for hanlding a long integer preferences item. + */ + class TDECORE_EXPORT ItemLong:public TDEConfigSkeletonGenericItem < long > + { + public: + ItemLong(const TQString & group, const TQString & key, long &reference, + long defaultValue = 0); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + TQVariant minValue() const; + TQVariant maxValue() const; + + void setMinValue(long); + void setMaxValue(long); + + private: + bool mHasMin : 1; + bool mHasMax : 1; + long mMin; + long mMax; + }; + + + /** + * Class for handling an unsigned long integer preferences item. + */ + class TDECORE_EXPORT ItemULong:public TDEConfigSkeletonGenericItem < unsigned long > + { + public: + ItemULong(const TQString & group, const TQString & key, + unsigned long &reference, unsigned long defaultValue = 0); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + TQVariant minValue() const; + TQVariant maxValue() const; + + void setMinValue(unsigned long); + void setMaxValue(unsigned long); + + private: + bool mHasMin : 1; + bool mHasMax : 1; + unsigned long mMin; + unsigned long mMax; + }; + + /** + * Class for handling unsigned 64-bit integer preferences item. + */ + class TDECORE_EXPORT ItemUInt64:public TDEConfigSkeletonGenericItem < TQ_UINT64 > + { + public: + ItemUInt64(const TQString & group, const TQString & key, TQ_UINT64 &reference, + TQ_UINT64 defaultValue = 0); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + + TQVariant minValue() const; + TQVariant maxValue() const; + + void setMinValue(TQ_UINT64); + void setMaxValue(TQ_UINT64); + + private: + bool mHasMin : 1; + bool mHasMax : 1; + TQ_UINT64 mMin; + TQ_UINT64 mMax; + }; + + /** + * Class for handling a floating point preference item. + */ + class TDECORE_EXPORT ItemDouble:public TDEConfigSkeletonGenericItem < double > + { + public: + ItemDouble(const TQString & group, const TQString & key, + double &reference, double defaultValue = 0); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + TQVariant minValue() const; + TQVariant maxValue() const; + + void setMinValue(double); + void setMaxValue(double); + + private: + bool mHasMin : 1; + bool mHasMax : 1; + double mMin; + double mMax; + }; + + + /** + * Class for handling a color preferences item. + */ + class TDECORE_EXPORT ItemColor:public TDEConfigSkeletonGenericItem < TQColor > + { + public: + ItemColor(const TQString & group, const TQString & key, + TQColor & reference, + const TQColor & defaultValue = TQColor(128, 128, 128)); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + }; + + + /** + * Class for handling a font preferences item. + */ + class TDECORE_EXPORT ItemFont:public TDEConfigSkeletonGenericItem < TQFont > + { + public: + ItemFont(const TQString & group, const TQString & key, TQFont & reference, + const TQFont & defaultValue = TDEGlobalSettings::generalFont()); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + }; + + + /** + * Class for handling a TQRect preferences item. + */ + class TDECORE_EXPORT ItemRect:public TDEConfigSkeletonGenericItem < TQRect > + { + public: + ItemRect(const TQString & group, const TQString & key, TQRect & reference, + const TQRect & defaultValue = TQRect()); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + }; + + + /** + * Class for handling a TQPoint preferences item. + */ + class TDECORE_EXPORT ItemPoint:public TDEConfigSkeletonGenericItem < TQPoint > + { + public: + ItemPoint(const TQString & group, const TQString & key, TQPoint & reference, + const TQPoint & defaultValue = TQPoint()); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + }; + + + /** + * Class for handling a TQSize preferences item. + */ + class TDECORE_EXPORT ItemSize:public TDEConfigSkeletonGenericItem < TQSize > + { + public: + ItemSize(const TQString & group, const TQString & key, TQSize & reference, + const TQSize & defaultValue = TQSize()); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + }; + + + /** + * Class for handling a TQDateTime preferences item. + */ + class TDECORE_EXPORT ItemDateTime:public TDEConfigSkeletonGenericItem < TQDateTime > + { + public: + ItemDateTime(const TQString & group, const TQString & key, + TQDateTime & reference, + const TQDateTime & defaultValue = TQDateTime()); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + }; + + + /** + * Class for handling a string list preferences item. + */ + class TDECORE_EXPORT ItemStringList:public TDEConfigSkeletonGenericItem < TQStringList > + { + public: + ItemStringList(const TQString & group, const TQString & key, + TQStringList & reference, + const TQStringList & defaultValue = TQStringList()); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + }; + + + /** + * Class for handling a path list preferences item. + */ + class TDECORE_EXPORT ItemPathList:public ItemStringList + { + public: + ItemPathList(const TQString & group, const TQString & key, + TQStringList & reference, + const TQStringList & defaultValue = TQStringList()); + + void readConfig(TDEConfig * config); + void writeConfig(TDEConfig * config); + }; + + + /** + * Class for handling an integer list preferences item. + */ + class TDECORE_EXPORT ItemIntList:public TDEConfigSkeletonGenericItem < TQValueList < int > > + { + public: + ItemIntList(const TQString & group, const TQString & key, + TQValueList < int >&reference, + const TQValueList < int >&defaultValue = TQValueList < int >()); + + void readConfig(TDEConfig * config); + void setProperty(const TQVariant & p); + TQVariant property() const; + }; + + +public: + /** + * Constructor. + * + * @param configname name of config file. If no name is given, the default + * config file as returned by kapp()->config() is used. + */ + TDEConfigSkeleton(const TQString & configname = TQString::null); + + /** + * Constructor. + * + * @param config configuration object to use. + */ + TDEConfigSkeleton(KSharedConfig::Ptr config); + + /** + * Destructor + */ + virtual ~ TDEConfigSkeleton(); + + /** + Set all registered items to their default values. + */ + void setDefaults(); + + /** + * Read preferences from config file. All registered items are set to the + * values read from disk. + */ + void readConfig(); + + /** + * Write preferences to config file. The values of all registered items are + * written to disk. + */ + void writeConfig(); + + /** + * Set the config file group for subsequent addItem() calls. It is valid + * until setCurrentGroup() is called with a new argument. Call this before + * you add any items. The default value is "No Group". + */ + void setCurrentGroup(const TQString & group); + + /** + * Returns the current group used for addItem() calls. + */ + TQString currentGroup() // ### KDE 4.0: make const + { + return mCurrentGroup; + } + + /** + * Register a custom @ref TDEConfigSkeletonItem with a given name. If the name + * parameter is null, take the name from TDEConfigSkeletonItem::key(). + * Note that all names must be unique but that multiple entries can have + * the same key if they reside in different groups. + */ + void addItem(TDEConfigSkeletonItem *, const TQString & name = TQString::null ); + + /** + * Register an item of type TQString. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemString *addItemString(const TQString & name, TQString & reference, + const TQString & defaultValue = TQString::fromLatin1(""), // NOT TQString::null !! + const TQString & key = TQString::null); + + /** + * Register a password item of type TQString. The string value is written + * encrypted to the config file. Note that the current encryption scheme + * is very weak. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemPassword *addItemPassword(const TQString & name, TQString & reference, + const TQString & defaultValue = TQString::fromLatin1(""), + const TQString & key = TQString::null); + + /** + * Register a path item of type TQString. The string value is interpreted + * as a path. This means, dollar expension is activated for this value, so + * that e.g. $HOME gets expanded. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemPath *addItemPath(const TQString & name, TQString & reference, + const TQString & defaultValue = TQString::fromLatin1(""), + const TQString & key = TQString::null); + + /** + * Register a property item of type TQVariant. Note that only the following + * TQVariant types are allowed: String, StringList, Font, Point, Rect, Size, + * Color, Int, UInt, Bool, Double, DateTime and Date. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemProperty *addItemProperty(const TQString & name, TQVariant & reference, + const TQVariant & defaultValue = TQVariant(), + const TQString & key = TQString::null); + /** + * Register an item of type bool. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemBool *addItemBool(const TQString & name, bool & reference, + bool defaultValue = false, + const TQString & key = TQString::null); + + /** + * Register an item of type int. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemInt *addItemInt(const TQString & name, int &reference, int defaultValue = 0, + const TQString & key = TQString::null); + + /** + * Register an item of type unsigned int. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemUInt *addItemUInt(const TQString & name, unsigned int &reference, + unsigned int defaultValue = 0, + const TQString & key = TQString::null); + + /** + * Register an item of type long. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemLong *addItemLong(const TQString & name, long &reference, + long defaultValue = 0, + const TQString & key = TQString::null); + + /** + * Register an item of type unsigned long. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemULong *addItemULong(const TQString & name, unsigned long &reference, + unsigned long defaultValue = 0, + const TQString & key = TQString::null); + + /** + * Register an item of type TQ_INT64. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemInt64 *addItemInt64(const TQString & name, TQ_INT64 &reference, + TQ_INT64 defaultValue = 0, + const TQString & key = TQString::null); + + /** + * Register an item of type TQ_UINT64 + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemUInt64 *addItemUInt64(const TQString & name, TQ_UINT64 &reference, + TQ_UINT64 defaultValue = 0, + const TQString & key = TQString::null); + + /** + * Register an item of type double. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemDouble *addItemDouble(const TQString & name, double &reference, + double defaultValue = 0.0, + const TQString & key = TQString::null); + + /** + * Register an item of type TQColor. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemColor *addItemColor(const TQString & name, TQColor & reference, + const TQColor & defaultValue = TQColor(128, 128, 128), + const TQString & key = TQString::null); + + /** + * Register an item of type TQFont. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemFont *addItemFont(const TQString & name, TQFont & reference, + const TQFont & defaultValue = + TDEGlobalSettings::generalFont(), + const TQString & key = TQString::null); + + /** + * Register an item of type TQRect. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemRect *addItemRect(const TQString & name, TQRect & reference, + const TQRect & defaultValue = TQRect(), + const TQString & key = TQString::null); + + /** + * Register an item of type TQPoint. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemPoint *addItemPoint(const TQString & name, TQPoint & reference, + const TQPoint & defaultValue = TQPoint(), + const TQString & key = TQString::null); + + /** + * Register an item of type TQSize. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemSize *addItemSize(const TQString & name, TQSize & reference, + const TQSize & defaultValue = TQSize(), + const TQString & key = TQString::null); + + /** + * Register an item of type TQDateTime. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemDateTime *addItemDateTime(const TQString & name, TQDateTime & reference, + const TQDateTime & defaultValue = TQDateTime(), + const TQString & key = TQString::null); + + /** + * Register an item of type TQStringList. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemStringList *addItemStringList(const TQString & name, TQStringList & reference, + const TQStringList & defaultValue = TQStringList(), + const TQString & key = TQString::null); + + /** + * Register an item of type TQValueList. + * + * @param name Name used to indentify this setting. Names must be unique. + * @param reference Pointer to the variable, which is set by readConfig() + * calls and read by writeConfig() calls. + * @param defaultValue Default value, which is used when the config file + * does not yet contain the key of this item. + * @param key Key used in config file. If key is null, name is used as key. + * @return The created item + */ + ItemIntList *addItemIntList(const TQString & name, TQValueList < int >&reference, + const TQValueList < int >&defaultValue = + TQValueList < int >(), + const TQString & key = TQString::null); + + /** + * Return the @ref TDEConfig object used for reading and writing the settings. + */ + TDEConfig *config() const; + + /** + * Return list of items managed by this TDEConfigSkeleton object. + */ + TDEConfigSkeletonItem::List items() const + { + return mItems; + } + + /** + * Return whether a certain item is immutable + */ + bool isImmutable(const TQString & name); + + /** + * Lookup item by name + */ + TDEConfigSkeletonItem * findItem(const TQString & name); + + /** + * Indicate whether this object should reflect the actual + * values or the default values. + * @param b If true this object reflects the default values. + * @return The state prior to this call + */ + bool useDefaults(bool b); + +protected: + /** + * Implemented by subclasses that use special defaults. + * It should replace the default values with the actual + * values and vice versa. + */ + virtual void usrUseDefaults(bool) + { + } + + virtual void usrSetDefaults() + { + } + + /** + * Implemented by subclasses that read special config values. + */ + virtual void usrReadConfig() + { + } + + /** + * Implemented by subclasses that write special config values. + */ + virtual void usrWriteConfig() + { + } + +private: + TQString mCurrentGroup; + + KSharedConfig::Ptr mConfig; // pointer to TDEConfig object + + TDEConfigSkeletonItem::List mItems; + TDEConfigSkeletonItem::Dict mItemDict; + + bool mUseDefaults; + + class Private; + Private *d; + +}; + +#endif diff --git a/tdecore/tdehardwaredevices.cpp b/tdecore/tdehardwaredevices.cpp index d012c64aa..5044aab8e 100644 --- a/tdecore/tdehardwaredevices.cpp +++ b/tdecore/tdehardwaredevices.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/tdecore/tdesycoca.cpp b/tdecore/tdesycoca.cpp index f433510d6..31da8b741 100644 --- a/tdecore/tdesycoca.cpp +++ b/tdecore/tdesycoca.cpp @@ -450,7 +450,7 @@ void KSycoca::flagError() return; _self->d->readError = true; if (_self->d->autoRebuild) - if(system("kbuildsycoca") < 0) // Rebuild the damned thing. + if(system("tdebuildsycoca") < 0) // Rebuild the damned thing. tqWarning("ERROR: Running KSycoca failed."); } } diff --git a/tdecore/tdesycoca.h b/tdecore/tdesycoca.h index 1b3355de3..bf41da415 100644 --- a/tdecore/tdesycoca.h +++ b/tdecore/tdesycoca.h @@ -124,7 +124,7 @@ public: virtual bool isBuilding() { return false; } /** - * @internal - disables launching of kbuildsycoca + * @internal - disables launching of tdebuildsycoca */ void disableAutoRebuild(); @@ -152,7 +152,7 @@ public: k_dcop: /** - * internal function for receiving kded/kbuildsycoca's signal, when the sycoca file changes + * internal function for receiving kded/tdebuildsycoca's signal, when the sycoca file changes */ void notifyDatabaseChanged(const TQStringList &); diff --git a/tdecore/tests/Makefile.am b/tdecore/tests/Makefile.am index 9d2c5259c..90ba46051 100644 --- a/tdecore/tests/Makefile.am +++ b/tdecore/tests/Makefile.am @@ -21,7 +21,7 @@ INCLUDES = -I$(top_srcdir)/tdecore $(all_includes) AM_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS) $(KDE_RPATH) -check_PROGRAMS = kconfigtestgui klocaletest kprocesstest ksimpleconfigtest \ +check_PROGRAMS = tdeconfigtestgui klocaletest kprocesstest ksimpleconfigtest \ kstddirstest kurltest kuniqueapptest ktempfiletest krandomsequencetest \ kdebugtest ksocktest kstringhandlertest kcmdlineargstest kapptest \ kmemtest kidlservertest kidlclienttest dcopkonqtest kipctest \ @@ -38,7 +38,7 @@ noinst_HEADERS = klocaletest.h kprocesstest.h KIDLTest.h \ METASOURCES = AUTO LDADD = ../libtdecore.la -kconfigtestgui_SOURCES = kconfigtestgui.cpp +tdeconfigtestgui_SOURCES = tdeconfigtestgui.cpp kdebugtest_SOURCES = kdebugtest.cpp klocaletest_SOURCES = klocaletest.cpp #klocaletest2_SOURCES = klocaletest2.cpp klocale.cpp libintl.cpp kcatalogue.cpp @@ -79,8 +79,8 @@ kstdacceltest_SOURCES = kstdacceltest.cpp kglobaltest_SOURCES = kglobaltest.cpp ktimezonestest_SOURCES = ktimezonestest.cpp -check_LTLIBRARIES = tdeunittest_kconfig.la +check_LTLIBRARIES = tdeunittest_tdeconfig.la -tdeunittest_kconfig_la_SOURCES = kconfigtest.cpp -tdeunittest_kconfig_la_LIBADD = $(LIB_KUNITTEST) -tdeunittest_kconfig_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) +tdeunittest_tdeconfig_la_SOURCES = tdeconfigtest.cpp +tdeunittest_tdeconfig_la_LIBADD = $(LIB_KUNITTEST) +tdeunittest_tdeconfig_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) diff --git a/tdecore/tests/kconfigtest.cpp b/tdecore/tests/kconfigtest.cpp deleted file mode 100644 index d3421a3d8..000000000 --- a/tdecore/tests/kconfigtest.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include - -class TDEConfigTest : public KUnitTest::Tester -{ -public: - void allTests(); -private: - void writeConfigFile(); - void revertEntries(); -}; - -KUNITTEST_MODULE( tdeunittest_kconfig, "TDEConfigTest" ) -KUNITTEST_MODULE_REGISTER_TESTER( TDEConfigTest ) - -// test data -#define BOOLENTRY1 true -#define BOOLENTRY2 false -#define STRINGENTRY1 "hello" -#define STRINGENTRY2 " hello" -#define STRINGENTRY3 "hello " -#define STRINGENTRY4 " hello " -#define STRINGENTRY5 " " -#define STRINGENTRY6 "" -#define LOCAL8BITENTRY "Hello äöü" -#define POINTENTRY TQPoint( 4351, 1235 ) -#define SIZEENTRY TQSize( 10, 20 ) -#define RECTENTRY TQRect( 10, 23, 5321, 13 ) -#define DATETIMEENTRY TQDateTime( TQDate( 2002, 06, 23 ), TQTime( 12, 55, 40 ) ) -#define STRINGLISTENTRY TQStringList( "Hello," ) - -void TDEConfigTest::writeConfigFile() -{ - TDEConfig sc( "kconfigtest" ); - - sc.setGroup("AAA"); - sc.writeEntry("stringEntry1", STRINGENTRY1, true, true); - sc.deleteEntry("stringEntry2", false, true); - - sc.setGroup("Hello"); - sc.writeEntry( "boolEntry1", BOOLENTRY1 ); - sc.writeEntry( "boolEntry2", BOOLENTRY2 ); - - sc.writeEntry( "Test", TQString::fromLocal8Bit( LOCAL8BITENTRY ) ); - sc.writeEntry( "Test2", ""); - sc.writeEntry( "stringEntry1", STRINGENTRY1 ); - sc.writeEntry( "stringEntry2", STRINGENTRY2 ); - sc.writeEntry( "stringEntry3", STRINGENTRY3 ); - sc.writeEntry( "stringEntry4", STRINGENTRY4 ); - sc.writeEntry( "stringEntry5", STRINGENTRY5 ); -// sc.writeEntry( "stringEntry6", STRINGENTRY6 ); - sc.writeEntry( "keywith=equalsign", STRINGENTRY1 ); - sc.deleteEntry( "stringEntry5" ); - sc.deleteEntry( "stringEntry6" ); - - sc.deleteGroup("deleteMe", true); - - sc.setGroup("Bye"); - sc.writeEntry( "rectEntry", RECTENTRY ); - sc.writeEntry( "pointEntry", POINTENTRY ); - sc.writeEntry( "sizeEntry", SIZEENTRY ); - sc.writeEntry( "dateTimeEntry", DATETIMEENTRY ); - sc.writeEntry( "stringListEntry", STRINGLISTENTRY ); - sc.sync(); -} - -// ### TODO: call this, and test the state of things afterwards -void TDEConfigTest::revertEntries() -{ - tqWarning("Reverting entries"); - TDEConfig sc( "kconfigtest" ); - - sc.setGroup("Hello"); - sc.revertToDefault( "boolEntry1"); - sc.revertToDefault( "boolEntry2"); - - sc.revertToDefault( "Test" ); - sc.revertToDefault( "Test2" ); - sc.revertToDefault( "stringEntry1" ); - sc.revertToDefault( "stringEntry2" ); - sc.revertToDefault( "stringEntry3" ); - sc.revertToDefault( "stringEntry4" ); - sc.revertToDefault( "stringEntry5" ); - sc.sync(); -} - -void TDEConfigTest::allTests() -{ - writeConfigFile(); - - TDEConfig sc2( "kconfigtest" ); - - TDEConfigGroup sc3( &sc2, "AAA"); - bool bImmutable = sc3.entryIsImmutable("stringEntry1"); - - CHECK( bImmutable, false ); - //tqWarning("sc3.entryIsImmutable() 1: %s", bImmutable ? "true" : "false"); - - sc2.setGroup("AAA"); - CHECK( sc2.hasKey( "stringEntry1" ), true ); - CHECK( sc2.readEntry( "stringEntry1" ), TQString( STRINGENTRY1 ) ); - CHECK( sc2.entryIsImmutable("stringEntry1"), bImmutable ); - CHECK( sc2.hasKey( "stringEntry2" ), false ); - CHECK( sc2.readEntry( "stringEntry2", "bla" ), TQString( "bla" ) ); - - CHECK( sc2.hasDefault( "stringEntry1" ), false ); - - sc2.setGroup("Hello"); - CHECK( sc2.readEntry( "Test" ), TQString::fromLocal8Bit( LOCAL8BITENTRY ) ); - CHECK( sc2.readEntry("Test2", "Fietsbel").isEmpty(), true ); - CHECK( sc2.readEntry( "stringEntry1" ), TQString( STRINGENTRY1 ) ); - CHECK( sc2.readEntry( "stringEntry2" ), TQString( STRINGENTRY2 ) ); - CHECK( sc2.readEntry( "stringEntry3" ), TQString( STRINGENTRY3 ) ); - CHECK( sc2.readEntry( "stringEntry4" ), TQString( STRINGENTRY4 ) ); - CHECK( sc2.hasKey( "stringEntry5" ), false); - CHECK( sc2.readEntry( "stringEntry5", "test" ), TQString( "test" ) ); - CHECK( sc2.hasKey( "stringEntry6" ), false); - CHECK( sc2.readEntry( "stringEntry6", "foo" ), TQString( "foo" ) ); - CHECK( sc2.readBoolEntry( "boolEntry1" ), BOOLENTRY1 ); - CHECK( sc2.readBoolEntry( "boolEntry2" ), BOOLENTRY2 ); - -#if 0 - TQString s; - s = sc2.readEntry( "keywith=equalsign" ); - fprintf(stderr, "comparing keywith=equalsign %s with %s -> ", STRINGENTRY1, s.latin1()); - if (s == STRINGENTRY1) - fprintf(stderr, "OK\n"); - else { - fprintf(stderr, "not OK\n"); - exit(-1); - } -#endif - - sc2.setGroup("Bye"); - - CHECK( sc2.readPointEntry( "pointEntry" ), POINTENTRY ); - CHECK( sc2.readSizeEntry( "sizeEntry" ), SIZEENTRY); - CHECK( sc2.readRectEntry( "rectEntry" ), RECTENTRY ); - CHECK( sc2.readDateTimeEntry( "dateTimeEntry" ).toString(), DATETIMEENTRY.toString() ); - CHECK( sc2.readListEntry( "stringListEntry").join( "," ), STRINGLISTENTRY.join( "," ) ); -} diff --git a/tdecore/tests/kconfigtestgui.cpp b/tdecore/tests/kconfigtestgui.cpp deleted file mode 100644 index 776082bfb..000000000 --- a/tdecore/tests/kconfigtestgui.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kconfigtestgui.h" -#include "kconfigtestgui.moc" - -// -// configtest.cpp: libKDEcore example -// -// demonstrates use of TDEConfig class -// -// adapted from Qt widgets demo - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Standard Qt widgets - -#include -#include -#include - -// KDE includes -#include - -#ifdef HAVE_PATHS_H -#include -#endif - -#ifndef _PATH_TMP -#define _PATH_TMP "/tmp/" -#endif - -// -// Construct the TDEConfigTestView with buttons -// - -TDEConfigTestView::TDEConfigTestView( TQWidget *parent, const char *name ) - : TQDialog( parent, name ), - pConfig( 0L ), - pFile( 0L ), - pStream( 0L ) -{ - // Set the window caption/title - - setCaption( "TDEConfig test" ); - - // Label and edit for the app config file - pAppFileLabel = new TQLabel( this, "appconfiglabel" ); - pAppFileLabel->setText( "Application config file:" ); - pAppFileLabel->setGeometry( 20, 20, 200, 20 ); - - pAppFileEdit = new TQLineEdit( this, "appconfigedit" ); - pAppFileEdit->setGeometry( 240, 20, 160, 20 ); - connect( pAppFileEdit, TQT_SIGNAL(returnPressed()), - TQT_SLOT(appConfigEditReturnPressed())); - - // Label and edit for the group - pGroupLabel = new TQLabel( this, "grouplabel" ); - pGroupLabel->setText( "Group:" ); - pGroupLabel->setGeometry( 20, 60, 80, 20 ); - - pGroupEdit = new TQLineEdit( this, "groupedit" ); - pGroupEdit->setGeometry( 120, 60, 100, 20 ); - connect( pGroupEdit, TQT_SIGNAL(returnPressed()), - TQT_SLOT(groupEditReturnPressed())); - - // Edit and label for the key/value pair - pKeyEdit = new TQLineEdit( this, "keyedit" ); - pKeyEdit->setGeometry( 20, 100, 80, 20 ); - connect( pKeyEdit, TQT_SIGNAL( returnPressed()), - TQT_SLOT(keyEditReturnPressed())); - - pEqualsLabel = new TQLabel( this, "equalslabel" ); - pEqualsLabel->setGeometry( 105, 100, 20, 20 ); - pEqualsLabel->setText( "=" ); - - pValueEdit = new TQLineEdit( this, "valueedit" ); - pValueEdit->setGeometry( 120, 100, 100, 20 ); - pValueEdit->setText( "---" ); - - pWriteButton = new TQPushButton( this, "writebutton" ); - pWriteButton->setGeometry( 20,140, 80, 20 ); - pWriteButton->setText( "Write entry" ); - connect( pWriteButton, TQT_SIGNAL(clicked()), TQT_SLOT( writeButtonClicked() ) ); - - // Labels for the info line - pInfoLabel1 = new TQLabel( this, "infolabel1" ); - pInfoLabel1->setGeometry( 20, 200, 60, 20 ); - pInfoLabel1->setText( "Info:" ); - - pInfoLabel2 = new TQLabel( this, "infolabel2" ); - pInfoLabel2->setGeometry( 100, 200, 300, 20 ); - pInfoLabel2->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); - - // Quit button - pQuitButton = new TQPushButton( this, "quitbutton" ); - pQuitButton->setText( "Quit" ); - pQuitButton->setGeometry( 340, 60, 60, 60 ); - connect( pQuitButton, TQT_SIGNAL(clicked()), tqApp, TQT_SLOT(quit()) ); - - // create a default TDEConfig object in order to be able to start right away - pConfig = new TDEConfig( TQString::null ); -} - -TDEConfigTestView::~TDEConfigTestView() -{ - delete pConfig; - delete pFile; - delete pStream; -} - -void TDEConfigTestView::appConfigEditReturnPressed() -{ - // if there already was a config object, delete it and its associated data - delete pConfig; - pConfig = 0L; - delete pFile; - pFile = 0L; - delete pStream; - pStream = 0L; - - // create a new config object - if( !pAppFileEdit->text().isEmpty() ) - pConfig = new TDEConfig( pAppFileEdit->text() ); - - pInfoLabel2->setText( "New config object created." ); -} - -void TDEConfigTestView::groupEditReturnPressed() -{ - pConfig->setGroup( pGroupEdit->text() ); - // according to the Qt doc, this is begging for trouble, but for a - // test program this will do - TQString aText; - aText.sprintf( "Group set to %s", TQString( pConfig->group() ).isEmpty() ? - TQString("").ascii() : pConfig->group().ascii() ); - pInfoLabel2->setText( aText ); -} - -void TDEConfigTestView::keyEditReturnPressed() -{ - TQString aValue = pConfig->readEntry( pKeyEdit->text() ); - // just checking aValue.isNull() would be easier here, but this is - // to demonstrate the HasKey()-method. Besides, it is better data - // encapsulation because we do not make any assumption about coding - // non-values here. - if( !pConfig->hasKey( pKeyEdit->text() ) ) - { - pInfoLabel2->setText( "Key not found!" ); - pValueEdit->setText( "---" ); - } - else - { - pInfoLabel2->setText( "Key found!" ); - pValueEdit->setText( aValue ); - } -} - -void TDEConfigTestView::writeButtonClicked() -{ - pConfig->writeEntry( pKeyEdit->text(), TQString( pValueEdit->text() ) ); - pInfoLabel2->setText( "Entry written" ); - - kdDebug() << "Entry written: " << 27 << endl; -} - - -int main( int argc, char **argv ) -{ - TDEApplication a( argc, argv, "bla" ); - - TDEConfigTestView *w = new TDEConfigTestView(); - a.setMainWidget( w ); - return w->exec(); -} diff --git a/tdecore/tests/kconfigtestgui.h b/tdecore/tests/kconfigtestgui.h deleted file mode 100644 index f5bbfd659..000000000 --- a/tdecore/tests/kconfigtestgui.h +++ /dev/null @@ -1,72 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -#ifndef _KCONFIG_TEST_H -#define _KCONFIG_TEST_H - -#include -#include -#include -#include -#include -#include -#include - -// Standard Qt widgets - -#include -#include -#include - -#include - -// -// TDEConfigTestView contains lots of Qt widgets. -// - -class TDEConfigTestView : public TQDialog -{ - Q_OBJECT -public: - TDEConfigTestView( TQWidget *parent=0, const char *name=0 ); - ~TDEConfigTestView(); - -private slots: - void appConfigEditReturnPressed(); - void groupEditReturnPressed(); - void keyEditReturnPressed(); - void writeButtonClicked(); - -private: - TQLabel* pAppFileLabel; - TQLineEdit* pAppFileEdit; - TQLabel* pGroupLabel; - TQLineEdit* pGroupEdit; - TQLineEdit* pKeyEdit; - TQLabel* pEqualsLabel; - TQLineEdit* pValueEdit; - TQPushButton* pWriteButton; - TQLabel* pInfoLabel1, *pInfoLabel2; - TQPushButton* pQuitButton; - - TDEConfig* pConfig; - TQFile* pFile; - TQTextStream* pStream; -}; - -#endif diff --git a/tdecore/tests/ksimpleconfigtest.cpp b/tdecore/tests/ksimpleconfigtest.cpp index f9fbffa65..85193f40b 100644 --- a/tdecore/tests/ksimpleconfigtest.cpp +++ b/tdecore/tests/ksimpleconfigtest.cpp @@ -20,7 +20,7 @@ int main( int argc, char **argv ) { - TDEApplication a( argc, argv, "kconfigtest" ); + TDEApplication a( argc, argv, "tdeconfigtest" ); KSimpleConfig aConfig( _PATH_TMP"/simpleconfig.cfg" ); diff --git a/tdecore/tests/kstddirstest.cpp b/tdecore/tests/kstddirstest.cpp index fa7191cce..399282f14 100644 --- a/tdecore/tests/kstddirstest.cpp +++ b/tdecore/tests/kstddirstest.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include int main(int argc, char **argv) { diff --git a/tdecore/tests/kurltest.cpp b/tdecore/tests/kurltest.cpp index f1284d394..178aec6d5 100644 --- a/tdecore/tests/kurltest.cpp +++ b/tdecore/tests/kurltest.cpp @@ -125,8 +125,8 @@ int main(int argc, char *argv[]) baseURL = "http://www.foo.bar/top//test2/file2.html"; check( "KURL::url()", baseURL.url(), "http://www.foo.bar/top//test2/file2.html" ); - baseURL = "file:/usr/local/src/kde2/////tdelibs/kio"; - check( "KURL::url()", baseURL.url(), "file:///usr/local/src/kde2/////tdelibs/kio" ); + baseURL = "file:/usr/local/src/kde2/////tdelibs/tdeio"; + check( "KURL::url()", baseURL.url(), "file:///usr/local/src/kde2/////tdelibs/tdeio" ); baseURL = "http://www.foo.bar"; KURL rel_url2( baseURL, "mailto:bastian@kde.org" ); @@ -135,7 +135,7 @@ int main(int argc, char *argv[]) baseURL = "mailto:bastian@kde.org?subject=hello"; check( "KURL::url()", baseURL.url(), "mailto:bastian@kde.org?subject=hello" ); - baseURL = "file:/usr/local/src/kde2/tdelibs/kio/"; + baseURL = "file:/usr/local/src/kde2/tdelibs/tdeio/"; KURL url2( baseURL, "../../////tdebase/konqueror" ); check( "KURL::url()", url2.url(), "file:///usr/local/src/kde2/////tdebase/konqueror" ); @@ -318,8 +318,8 @@ int main(int argc, char *argv[]) "http://www.google.com/foo%20%20%20%20%20%20 bar/"); KURL carsten; - carsten.setPath("/home/gis/src/kde/tdelibs/kfile/.#kfiledetailview.cpp.1.18"); - check("KURL::path()", carsten.path(), "/home/gis/src/kde/tdelibs/kfile/.#kfiledetailview.cpp.1.18"); + carsten.setPath("/home/gis/src/kde/tdelibs/tdefile/.#tdefiledetailview.cpp.1.18"); + check("KURL::path()", carsten.path(), "/home/gis/src/kde/tdelibs/tdefile/.#tdefiledetailview.cpp.1.18"); KURL charles; charles.setPath( "/home/charles/foo%20moo" ); diff --git a/tdecore/tests/tdeconfigtest.cpp b/tdecore/tests/tdeconfigtest.cpp new file mode 100644 index 000000000..d9c89d6d4 --- /dev/null +++ b/tdecore/tests/tdeconfigtest.cpp @@ -0,0 +1,162 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include + +#include + +class TDEConfigTest : public KUnitTest::Tester +{ +public: + void allTests(); +private: + void writeConfigFile(); + void revertEntries(); +}; + +KUNITTEST_MODULE( tdeunittest_tdeconfig, "TDEConfigTest" ) +KUNITTEST_MODULE_REGISTER_TESTER( TDEConfigTest ) + +// test data +#define BOOLENTRY1 true +#define BOOLENTRY2 false +#define STRINGENTRY1 "hello" +#define STRINGENTRY2 " hello" +#define STRINGENTRY3 "hello " +#define STRINGENTRY4 " hello " +#define STRINGENTRY5 " " +#define STRINGENTRY6 "" +#define LOCAL8BITENTRY "Hello äöü" +#define POINTENTRY TQPoint( 4351, 1235 ) +#define SIZEENTRY TQSize( 10, 20 ) +#define RECTENTRY TQRect( 10, 23, 5321, 13 ) +#define DATETIMEENTRY TQDateTime( TQDate( 2002, 06, 23 ), TQTime( 12, 55, 40 ) ) +#define STRINGLISTENTRY TQStringList( "Hello," ) + +void TDEConfigTest::writeConfigFile() +{ + TDEConfig sc( "tdeconfigtest" ); + + sc.setGroup("AAA"); + sc.writeEntry("stringEntry1", STRINGENTRY1, true, true); + sc.deleteEntry("stringEntry2", false, true); + + sc.setGroup("Hello"); + sc.writeEntry( "boolEntry1", BOOLENTRY1 ); + sc.writeEntry( "boolEntry2", BOOLENTRY2 ); + + sc.writeEntry( "Test", TQString::fromLocal8Bit( LOCAL8BITENTRY ) ); + sc.writeEntry( "Test2", ""); + sc.writeEntry( "stringEntry1", STRINGENTRY1 ); + sc.writeEntry( "stringEntry2", STRINGENTRY2 ); + sc.writeEntry( "stringEntry3", STRINGENTRY3 ); + sc.writeEntry( "stringEntry4", STRINGENTRY4 ); + sc.writeEntry( "stringEntry5", STRINGENTRY5 ); +// sc.writeEntry( "stringEntry6", STRINGENTRY6 ); + sc.writeEntry( "keywith=equalsign", STRINGENTRY1 ); + sc.deleteEntry( "stringEntry5" ); + sc.deleteEntry( "stringEntry6" ); + + sc.deleteGroup("deleteMe", true); + + sc.setGroup("Bye"); + sc.writeEntry( "rectEntry", RECTENTRY ); + sc.writeEntry( "pointEntry", POINTENTRY ); + sc.writeEntry( "sizeEntry", SIZEENTRY ); + sc.writeEntry( "dateTimeEntry", DATETIMEENTRY ); + sc.writeEntry( "stringListEntry", STRINGLISTENTRY ); + sc.sync(); +} + +// ### TODO: call this, and test the state of things afterwards +void TDEConfigTest::revertEntries() +{ + tqWarning("Reverting entries"); + TDEConfig sc( "tdeconfigtest" ); + + sc.setGroup("Hello"); + sc.revertToDefault( "boolEntry1"); + sc.revertToDefault( "boolEntry2"); + + sc.revertToDefault( "Test" ); + sc.revertToDefault( "Test2" ); + sc.revertToDefault( "stringEntry1" ); + sc.revertToDefault( "stringEntry2" ); + sc.revertToDefault( "stringEntry3" ); + sc.revertToDefault( "stringEntry4" ); + sc.revertToDefault( "stringEntry5" ); + sc.sync(); +} + +void TDEConfigTest::allTests() +{ + writeConfigFile(); + + TDEConfig sc2( "tdeconfigtest" ); + + TDEConfigGroup sc3( &sc2, "AAA"); + bool bImmutable = sc3.entryIsImmutable("stringEntry1"); + + CHECK( bImmutable, false ); + //tqWarning("sc3.entryIsImmutable() 1: %s", bImmutable ? "true" : "false"); + + sc2.setGroup("AAA"); + CHECK( sc2.hasKey( "stringEntry1" ), true ); + CHECK( sc2.readEntry( "stringEntry1" ), TQString( STRINGENTRY1 ) ); + CHECK( sc2.entryIsImmutable("stringEntry1"), bImmutable ); + CHECK( sc2.hasKey( "stringEntry2" ), false ); + CHECK( sc2.readEntry( "stringEntry2", "bla" ), TQString( "bla" ) ); + + CHECK( sc2.hasDefault( "stringEntry1" ), false ); + + sc2.setGroup("Hello"); + CHECK( sc2.readEntry( "Test" ), TQString::fromLocal8Bit( LOCAL8BITENTRY ) ); + CHECK( sc2.readEntry("Test2", "Fietsbel").isEmpty(), true ); + CHECK( sc2.readEntry( "stringEntry1" ), TQString( STRINGENTRY1 ) ); + CHECK( sc2.readEntry( "stringEntry2" ), TQString( STRINGENTRY2 ) ); + CHECK( sc2.readEntry( "stringEntry3" ), TQString( STRINGENTRY3 ) ); + CHECK( sc2.readEntry( "stringEntry4" ), TQString( STRINGENTRY4 ) ); + CHECK( sc2.hasKey( "stringEntry5" ), false); + CHECK( sc2.readEntry( "stringEntry5", "test" ), TQString( "test" ) ); + CHECK( sc2.hasKey( "stringEntry6" ), false); + CHECK( sc2.readEntry( "stringEntry6", "foo" ), TQString( "foo" ) ); + CHECK( sc2.readBoolEntry( "boolEntry1" ), BOOLENTRY1 ); + CHECK( sc2.readBoolEntry( "boolEntry2" ), BOOLENTRY2 ); + +#if 0 + TQString s; + s = sc2.readEntry( "keywith=equalsign" ); + fprintf(stderr, "comparing keywith=equalsign %s with %s -> ", STRINGENTRY1, s.latin1()); + if (s == STRINGENTRY1) + fprintf(stderr, "OK\n"); + else { + fprintf(stderr, "not OK\n"); + exit(-1); + } +#endif + + sc2.setGroup("Bye"); + + CHECK( sc2.readPointEntry( "pointEntry" ), POINTENTRY ); + CHECK( sc2.readSizeEntry( "sizeEntry" ), SIZEENTRY); + CHECK( sc2.readRectEntry( "rectEntry" ), RECTENTRY ); + CHECK( sc2.readDateTimeEntry( "dateTimeEntry" ).toString(), DATETIMEENTRY.toString() ); + CHECK( sc2.readListEntry( "stringListEntry").join( "," ), STRINGLISTENTRY.join( "," ) ); +} diff --git a/tdecore/tests/tdeconfigtestgui.cpp b/tdecore/tests/tdeconfigtestgui.cpp new file mode 100644 index 000000000..5ae85d26d --- /dev/null +++ b/tdecore/tests/tdeconfigtestgui.cpp @@ -0,0 +1,200 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "tdeconfigtestgui.h" +#include "tdeconfigtestgui.moc" + +// +// configtest.cpp: libKDEcore example +// +// demonstrates use of TDEConfig class +// +// adapted from Qt widgets demo + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Standard Qt widgets + +#include +#include +#include + +// KDE includes +#include + +#ifdef HAVE_PATHS_H +#include +#endif + +#ifndef _PATH_TMP +#define _PATH_TMP "/tmp/" +#endif + +// +// Construct the TDEConfigTestView with buttons +// + +TDEConfigTestView::TDEConfigTestView( TQWidget *parent, const char *name ) + : TQDialog( parent, name ), + pConfig( 0L ), + pFile( 0L ), + pStream( 0L ) +{ + // Set the window caption/title + + setCaption( "TDEConfig test" ); + + // Label and edit for the app config file + pAppFileLabel = new TQLabel( this, "appconfiglabel" ); + pAppFileLabel->setText( "Application config file:" ); + pAppFileLabel->setGeometry( 20, 20, 200, 20 ); + + pAppFileEdit = new TQLineEdit( this, "appconfigedit" ); + pAppFileEdit->setGeometry( 240, 20, 160, 20 ); + connect( pAppFileEdit, TQT_SIGNAL(returnPressed()), + TQT_SLOT(appConfigEditReturnPressed())); + + // Label and edit for the group + pGroupLabel = new TQLabel( this, "grouplabel" ); + pGroupLabel->setText( "Group:" ); + pGroupLabel->setGeometry( 20, 60, 80, 20 ); + + pGroupEdit = new TQLineEdit( this, "groupedit" ); + pGroupEdit->setGeometry( 120, 60, 100, 20 ); + connect( pGroupEdit, TQT_SIGNAL(returnPressed()), + TQT_SLOT(groupEditReturnPressed())); + + // Edit and label for the key/value pair + pKeyEdit = new TQLineEdit( this, "keyedit" ); + pKeyEdit->setGeometry( 20, 100, 80, 20 ); + connect( pKeyEdit, TQT_SIGNAL( returnPressed()), + TQT_SLOT(keyEditReturnPressed())); + + pEqualsLabel = new TQLabel( this, "equalslabel" ); + pEqualsLabel->setGeometry( 105, 100, 20, 20 ); + pEqualsLabel->setText( "=" ); + + pValueEdit = new TQLineEdit( this, "valueedit" ); + pValueEdit->setGeometry( 120, 100, 100, 20 ); + pValueEdit->setText( "---" ); + + pWriteButton = new TQPushButton( this, "writebutton" ); + pWriteButton->setGeometry( 20,140, 80, 20 ); + pWriteButton->setText( "Write entry" ); + connect( pWriteButton, TQT_SIGNAL(clicked()), TQT_SLOT( writeButtonClicked() ) ); + + // Labels for the info line + pInfoLabel1 = new TQLabel( this, "infolabel1" ); + pInfoLabel1->setGeometry( 20, 200, 60, 20 ); + pInfoLabel1->setText( "Info:" ); + + pInfoLabel2 = new TQLabel( this, "infolabel2" ); + pInfoLabel2->setGeometry( 100, 200, 300, 20 ); + pInfoLabel2->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); + + // Quit button + pQuitButton = new TQPushButton( this, "quitbutton" ); + pQuitButton->setText( "Quit" ); + pQuitButton->setGeometry( 340, 60, 60, 60 ); + connect( pQuitButton, TQT_SIGNAL(clicked()), tqApp, TQT_SLOT(quit()) ); + + // create a default TDEConfig object in order to be able to start right away + pConfig = new TDEConfig( TQString::null ); +} + +TDEConfigTestView::~TDEConfigTestView() +{ + delete pConfig; + delete pFile; + delete pStream; +} + +void TDEConfigTestView::appConfigEditReturnPressed() +{ + // if there already was a config object, delete it and its associated data + delete pConfig; + pConfig = 0L; + delete pFile; + pFile = 0L; + delete pStream; + pStream = 0L; + + // create a new config object + if( !pAppFileEdit->text().isEmpty() ) + pConfig = new TDEConfig( pAppFileEdit->text() ); + + pInfoLabel2->setText( "New config object created." ); +} + +void TDEConfigTestView::groupEditReturnPressed() +{ + pConfig->setGroup( pGroupEdit->text() ); + // according to the Qt doc, this is begging for trouble, but for a + // test program this will do + TQString aText; + aText.sprintf( "Group set to %s", TQString( pConfig->group() ).isEmpty() ? + TQString("").ascii() : pConfig->group().ascii() ); + pInfoLabel2->setText( aText ); +} + +void TDEConfigTestView::keyEditReturnPressed() +{ + TQString aValue = pConfig->readEntry( pKeyEdit->text() ); + // just checking aValue.isNull() would be easier here, but this is + // to demonstrate the HasKey()-method. Besides, it is better data + // encapsulation because we do not make any assumption about coding + // non-values here. + if( !pConfig->hasKey( pKeyEdit->text() ) ) + { + pInfoLabel2->setText( "Key not found!" ); + pValueEdit->setText( "---" ); + } + else + { + pInfoLabel2->setText( "Key found!" ); + pValueEdit->setText( aValue ); + } +} + +void TDEConfigTestView::writeButtonClicked() +{ + pConfig->writeEntry( pKeyEdit->text(), TQString( pValueEdit->text() ) ); + pInfoLabel2->setText( "Entry written" ); + + kdDebug() << "Entry written: " << 27 << endl; +} + + +int main( int argc, char **argv ) +{ + TDEApplication a( argc, argv, "bla" ); + + TDEConfigTestView *w = new TDEConfigTestView(); + a.setMainWidget( w ); + return w->exec(); +} diff --git a/tdecore/tests/tdeconfigtestgui.h b/tdecore/tests/tdeconfigtestgui.h new file mode 100644 index 000000000..347a9c81d --- /dev/null +++ b/tdecore/tests/tdeconfigtestgui.h @@ -0,0 +1,72 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef _KCONFIG_TEST_H +#define _KCONFIG_TEST_H + +#include +#include +#include +#include +#include +#include +#include + +// Standard Qt widgets + +#include +#include +#include + +#include + +// +// TDEConfigTestView contains lots of Qt widgets. +// + +class TDEConfigTestView : public TQDialog +{ + Q_OBJECT +public: + TDEConfigTestView( TQWidget *parent=0, const char *name=0 ); + ~TDEConfigTestView(); + +private slots: + void appConfigEditReturnPressed(); + void groupEditReturnPressed(); + void keyEditReturnPressed(); + void writeButtonClicked(); + +private: + TQLabel* pAppFileLabel; + TQLineEdit* pAppFileEdit; + TQLabel* pGroupLabel; + TQLineEdit* pGroupEdit; + TQLineEdit* pKeyEdit; + TQLabel* pEqualsLabel; + TQLineEdit* pValueEdit; + TQPushButton* pWriteButton; + TQLabel* pInfoLabel1, *pInfoLabel2; + TQPushButton* pQuitButton; + + TDEConfig* pConfig; + TQFile* pFile; + TQTextStream* pStream; +}; + +#endif -- cgit v1.2.1