summaryrefslogtreecommitdiffstats
path: root/tdecore/kconfig_compiler
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-11-06 15:56:40 -0600
committerTimothy Pearson <[email protected]>2011-11-06 15:56:40 -0600
commite16866e072f94410321d70daedbcb855ea878cac (patch)
treeee3f52eabde7da1a0e6ca845fb9c2813cf1558cf /tdecore/kconfig_compiler
parenta58c20c1a7593631a1b50213c805507ebc16adaf (diff)
downloadtdelibs-e16866e072f94410321d70daedbcb855ea878cac.tar.gz
tdelibs-e16866e072f94410321d70daedbcb855ea878cac.zip
Actually move the kde files that were renamed in the last commit
Diffstat (limited to 'tdecore/kconfig_compiler')
-rw-r--r--tdecore/kconfig_compiler/CMakeLists.txt29
-rw-r--r--tdecore/kconfig_compiler/Makefile.am18
-rw-r--r--tdecore/kconfig_compiler/README.dox255
-rw-r--r--tdecore/kconfig_compiler/TODO0
-rwxr-xr-xtdecore/kconfig_compiler/checkkcfg.pl83
-rw-r--r--tdecore/kconfig_compiler/example/Makefile.am27
-rw-r--r--tdecore/kconfig_compiler/example/autoexample.cpp64
-rw-r--r--tdecore/kconfig_compiler/example/example.cpp52
-rw-r--r--tdecore/kconfig_compiler/example/example.kcfg63
-rw-r--r--tdecore/kconfig_compiler/example/exampleprefs_base.kcfgc18
-rw-r--r--tdecore/kconfig_compiler/example/general_base.ui46
-rw-r--r--tdecore/kconfig_compiler/example/myoptions_base.ui35
-rw-r--r--tdecore/kconfig_compiler/kcfg.xsd192
-rw-r--r--tdecore/kconfig_compiler/kconfig_compiler.cpp1700
-rw-r--r--tdecore/kconfig_compiler/tests/Makefile.am134
-rw-r--r--tdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp96
-rw-r--r--tdecore/kconfig_compiler/tests/kconfigcompiler_test.h35
-rw-r--r--tdecore/kconfig_compiler/tests/myprefs.h7
-rw-r--r--tdecore/kconfig_compiler/tests/test1.cpp.ref72
-rw-r--r--tdecore/kconfig_compiler/tests/test1.h.ref196
-rw-r--r--tdecore/kconfig_compiler/tests/test1.kcfg55
-rw-r--r--tdecore/kconfig_compiler/tests/test1.kcfgc18
-rw-r--r--tdecore/kconfig_compiler/tests/test1main.cpp29
-rw-r--r--tdecore/kconfig_compiler/tests/test2.cpp.ref98
-rw-r--r--tdecore/kconfig_compiler/tests/test2.h.ref333
-rw-r--r--tdecore/kconfig_compiler/tests/test2.kcfg78
-rw-r--r--tdecore/kconfig_compiler/tests/test2.kcfgc11
-rw-r--r--tdecore/kconfig_compiler/tests/test2main.cpp29
-rw-r--r--tdecore/kconfig_compiler/tests/test3.cpp.ref29
-rw-r--r--tdecore/kconfig_compiler/tests/test3.h.ref138
-rw-r--r--tdecore/kconfig_compiler/tests/test3.kcfg26
-rw-r--r--tdecore/kconfig_compiler/tests/test3.kcfgc12
-rw-r--r--tdecore/kconfig_compiler/tests/test3main.cpp29
-rw-r--r--tdecore/kconfig_compiler/tests/test4.cpp.ref82
-rw-r--r--tdecore/kconfig_compiler/tests/test4.h.ref135
-rw-r--r--tdecore/kconfig_compiler/tests/test4.kcfg42
-rw-r--r--tdecore/kconfig_compiler/tests/test4.kcfgc11
-rw-r--r--tdecore/kconfig_compiler/tests/test4main.cpp30
-rw-r--r--tdecore/kconfig_compiler/tests/test5.cpp.ref82
-rw-r--r--tdecore/kconfig_compiler/tests/test5.h.ref127
-rw-r--r--tdecore/kconfig_compiler/tests/test5.kcfg42
-rw-r--r--tdecore/kconfig_compiler/tests/test5.kcfgc11
-rw-r--r--tdecore/kconfig_compiler/tests/test5main.cpp30
-rw-r--r--tdecore/kconfig_compiler/tests/test6.cpp.ref31
-rw-r--r--tdecore/kconfig_compiler/tests/test6.h.ref93
-rw-r--r--tdecore/kconfig_compiler/tests/test6.kcfg25
-rw-r--r--tdecore/kconfig_compiler/tests/test6.kcfgc11
-rw-r--r--tdecore/kconfig_compiler/tests/test6main.cpp30
-rw-r--r--tdecore/kconfig_compiler/tests/test7.cpp.ref31
-rw-r--r--tdecore/kconfig_compiler/tests/test7.h.ref93
-rw-r--r--tdecore/kconfig_compiler/tests/test7.kcfg25
-rw-r--r--tdecore/kconfig_compiler/tests/test7.kcfgc11
-rw-r--r--tdecore/kconfig_compiler/tests/test7main.cpp30
-rw-r--r--tdecore/kconfig_compiler/tests/test8a.cpp.ref22
-rw-r--r--tdecore/kconfig_compiler/tests/test8a.h.ref61
-rw-r--r--tdecore/kconfig_compiler/tests/test8a.kcfg17
-rw-r--r--tdecore/kconfig_compiler/tests/test8a.kcfgc3
-rw-r--r--tdecore/kconfig_compiler/tests/test8b.cpp.ref46
-rw-r--r--tdecore/kconfig_compiler/tests/test8b.h.ref96
-rw-r--r--tdecore/kconfig_compiler/tests/test8b.kcfg21
-rw-r--r--tdecore/kconfig_compiler/tests/test8b.kcfgc6
-rw-r--r--tdecore/kconfig_compiler/tests/test8main.cpp34
-rw-r--r--tdecore/kconfig_compiler/tests/test9.cpp.ref35
-rw-r--r--tdecore/kconfig_compiler/tests/test9.h.ref82
-rw-r--r--tdecore/kconfig_compiler/tests/test9.kcfg24
-rw-r--r--tdecore/kconfig_compiler/tests/test9.kcfgc18
-rw-r--r--tdecore/kconfig_compiler/tests/test9main.cpp43
-rw-r--r--tdecore/kconfig_compiler/tests/test_dpointer.cpp.ref344
-rw-r--r--tdecore/kconfig_compiler/tests/test_dpointer.h.ref224
-rw-r--r--tdecore/kconfig_compiler/tests/test_dpointer.kcfg78
-rw-r--r--tdecore/kconfig_compiler/tests/test_dpointer.kcfgc11
-rw-r--r--tdecore/kconfig_compiler/tests/test_dpointer_main.cpp30
72 files changed, 6174 insertions, 0 deletions
diff --git a/tdecore/kconfig_compiler/CMakeLists.txt b/tdecore/kconfig_compiler/CMakeLists.txt
new file mode 100644
index 000000000..4acc09f51
--- /dev/null
+++ b/tdecore/kconfig_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}
+)
+
+
+##### 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
new file mode 100644
index 000000000..d7b1400a4
--- /dev/null
+++ b/tdecore/kconfig_compiler/Makefile.am
@@ -0,0 +1,18 @@
+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_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+kconfig_compiler_LDADD = $(LIB_KDECORE)
+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
new file mode 100644
index 000000000..36d9f988b
--- /dev/null
+++ b/tdecore/kconfig_compiler/README.dox
@@ -0,0 +1,255 @@
+/**
+\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
+KConfigSkeleton and provides an API for the application to access its
+configuration data.
+
+<h2>XML description of the configuration options</h2>
+
+The structure of the .kcfg file is described by its DTD kcfg.dtd.
+
+The \<kcfgfile\> tag contains the name of the configuration file described.
+Omitting the name will make the generated class use the default configuration
+file ("<appname>rc").
+
+The \<include\> 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 \<group\>
+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 \<key\> is given, but not \<name\>, the name is constructed by removing
+all spaces from \<key\>.
+
+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 \<choices\> 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<int>. 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 \<default\> tag
+should contain the code="true" attribute. The contents of the \<default\>
+tag is then considered to be a C++ expression. Note that in this case you
+might have to add an \<include\> 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 \<code\> tag. The contents of the \<code\> 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.
+
+<h2>Code generation options</h2>
+
+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:
+
+<table>
+<tr>
+ <td><b><i>Name</i></b></td>
+ <td><b><i>Type</i></b></td>
+ <td><b><i>Default</i></b></td>
+ <td><b><i>Description</i></b></td>
+</tr>
+<tr>
+ <td><b>File</b></td>
+ <td>string</td>
+ <td>programname.kcfg</td>
+ <td>Name of kcfg file containing the options the class is generated for</td>
+</tr>
+<tr>
+ <td><b>NameSpace</b></td>
+ <td>string</td>
+ <td>-</td>
+ <td>Optional namespace for generated class</td>
+</tr>
+<tr>
+ <td><b>ClassName</b></td>
+ <td>string</td>
+ <td>-</td>
+ <td>Name of generated class (required)</td>
+</tr>
+<tr>
+ <td><b>Inherits</b></td>
+ <td>string</td>
+ <td>KConfigSkeleton</td>
+ <td>Class the generated class inherits from. This class must inherit
+ KConfigSkeleton.</td>
+</tr>
+<tr>
+ <td><b>Visibility</b></td>
+ <td>string</td>
+ <td>-</td>
+ <td>Inserts visibility directive (for example KDE_EXPORT) between "class" keyword and class
+ name in header file</td>
+</tr>
+<tr>
+ <td><b>Singleton</b></td>
+ <td>bool</td>
+ <td>false</td>
+ <td>Generated class is a singleton.</td>
+</tr>
+<tr>
+ <td><b>CustomAdditions</b></td>
+ <td>bool</td>
+ <td>-</td>
+ <td></td>
+</tr>
+<tr>
+ <td><b>MemberVariables</b></td>
+ <td>string: public|protected|private</td>
+ <td>private</td>
+ <td>C++ access modifier used for memeber variables holding the configuration
+ valuse</td>
+</tr>
+<tr>
+ <td><b>IncludeFiles</b></td>
+ <td>comma separated list of strings</td>
+ <td>-</td>
+ <td>Names of files to be included in the header of the generated class</td>
+</tr>
+<tr>
+ <td><b>Mutators</b></td>
+ <td>true, false or a comma seperated list of options</td>
+ <td>-</td>
+ <td>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.</td>
+</tr>
+<tr>
+ <td><b>ItemAccessors</b></td>
+ <td>bool</td>
+ <td>false</td>
+ <td>Generate accessor functions for the KConfigSkeletonItem objects
+ corresponding to the configuration options. If <b>SetUserTexts</b> is set,
+ <b>ItemAccessors</b> also has to be set.</td>
+</tr>
+<tr>
+ <td><b>SetUserTexts</b></td>
+ <td>bool</td>
+ <td>false</td>
+ <td>Set the label and whatthis texts of the items from the kcfg file.If
+ <b>SetUserTexts</b> is set, <b>ItemAccessors</b> also has to be set.</td>
+</tr>
+<tr>
+ <td><b>GlobalEnums</b></td>
+ <td>bool</td>
+ <td>false</td>
+ <td>If 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.</td>
+</tr>
+</table>
+
+
+<h2>Advanced options</h2>
+
+There are several possibilities to parameterize entries.
+
+- Parameterized entries
+
+An entry can be parameterized using a fixed range parameter specified with
+the \<parameter\> tag. Such parameter can either be an Enum or an int. An Enum
+parameter should specify the possible enumeration values with the \<choices\>
+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 \<default\>. When a
+param attribute is specified the default value only applies to that
+particular parameter value.
+
+Example 1:
+\verbatim
+ <entry name="Color$(ColorIndex)" type="Color" key="color_$(ColorIndex)">
+ <parameter name="ColorIndex" type="Int" max="3"/>
+ <default param="0">#ff0000</default>
+ <default param="1">#00ff00</default>
+ <default param="2">#0000ff</default>
+ <default param="3">#ffff00</default>
+ </entry>
+\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
+ <entry name="Sound$(SoundEvent)" type="String" key="sound_$(SoundEvent)">
+ <parameter name="SoundEvent" type="Enum">
+ <values>
+ <value>Explosion</value>
+ <value>Crash</value>
+ <value>Missile</value>
+ </values>
+ </parameter>
+ <default param="Explosion">boom.wav</default>
+ <default param="Crash">crash.wav</default>
+ <default param="Missile">missile.wav</default>
+ </entry>
+\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
+*/
diff --git a/tdecore/kconfig_compiler/TODO b/tdecore/kconfig_compiler/TODO
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tdecore/kconfig_compiler/TODO
diff --git a/tdecore/kconfig_compiler/checkkcfg.pl b/tdecore/kconfig_compiler/checkkcfg.pl
new file mode 100755
index 000000000..2eddbeee6
--- /dev/null
+++ b/tdecore/kconfig_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 = "./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( <REF> ) {
+ push @ref, $_;
+ }
+ close REF;
+
+ if ( !open( READ, $filename ) ) {
+ print STDERR "Unable to open $filename\n";
+ exit 1;
+ }
+
+ $error = 0;
+ $i = 0;
+ $line = 1;
+ while( <READ> ) {
+ $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
new file mode 100644
index 000000000..9c0454ad8
--- /dev/null
+++ b/tdecore/kconfig_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_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+example_LDADD = $(LIB_KDECORE)
+example_SOURCES = example.cpp exampleprefs_base.cpp
+
+autoexample_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+autoexample_LDADD = $(LIB_KDECORE) $(LIB_KDEUI)
+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 kdelibs.pot
+messages: rc.cpp
+ true
diff --git a/tdecore/kconfig_compiler/example/autoexample.cpp b/tdecore/kconfig_compiler/example/autoexample.cpp
new file mode 100644
index 000000000..2c4e4d442
--- /dev/null
+++ b/tdecore/kconfig_compiler/example/autoexample.cpp
@@ -0,0 +1,64 @@
+/*
+ This file is part of KDE.
+
+ Copyright (c) 2003 Cornelius Schumacher <[email protected]>
+
+ 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 <kaboutdata.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kcmdlineargs.h>
+#include <kglobal.h>
+#include <kconfig.h>
+#include <kstandarddirs.h>
+#include <kconfigdialog.h>
+
+#include <tqlabel.h>
+
+int main( int argc, char **argv )
+{
+ KAboutData aboutData( "example", I18N_NOOP("autoconfig example"), "0.1" );
+ aboutData.addAuthor( "Cornelius Schumacher", 0, "[email protected]" );
+
+ KCmdLineArgs::init( argc, argv, &aboutData );
+
+ KApplication app;
+
+ ExamplePrefsBase configSkeleton( "dummy1", "dummy2" );
+ configSkeleton.readConfig();
+
+ KConfigDialog *dialog = new KConfigDialog( 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
new file mode 100644
index 000000000..146d2460f
--- /dev/null
+++ b/tdecore/kconfig_compiler/example/example.cpp
@@ -0,0 +1,52 @@
+/*
+ This file is part of KDE.
+
+ Copyright (c) 2003 Cornelius Schumacher <[email protected]>
+
+ 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 <kaboutdata.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kcmdlineargs.h>
+#include <kglobal.h>
+#include <kconfig.h>
+#include <kstandarddirs.h>
+
+int main( int argc, char **argv )
+{
+ KAboutData aboutData( "example", I18N_NOOP("cfgc example"), "0.1" );
+ aboutData.addAuthor( "Cornelius Schumacher", 0, "[email protected]" );
+
+ KCmdLineArgs::init( argc, argv, &aboutData );
+
+ KApplication 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
new file mode 100644
index 000000000..076bfb644
--- /dev/null
+++ b/tdecore/kconfig_compiler/example/example.kcfg
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <include>qdir.h</include>
+ <kcfgfile name="examplerc">
+ <parameter name="transport" />
+ <parameter name="folder" />
+ </kcfgfile>
+ <group name="General-$(folder)">
+ <entry name="OneOption" type="Bool">
+ <label>One option</label>
+ <default>true</default>
+ </entry>
+ <entry name="AnotherOption" type="Int" key="Another Option">
+ <label>Another option</label>
+ <default>5</default>
+ </entry>
+ <entry name="ListOption" type="Enum">
+ <label>This is some funky option</label>
+ <whatsthis>And this is a longer description of this option. Just wondering, how will the translations of those be handled?</whatsthis>
+ <choices>
+ <choice name="One"/>
+ <choice name="Two"/>
+ <choice name="Three"/>
+ </choices>
+ <default>One</default>
+ </entry>
+ </group>
+ <group name="MyOptions">
+ <entry name="MyString" type="String">
+ <label>This is a string</label>
+ <default>Default String</default>
+ </entry>
+ <entry name="MyPath" type="Path">
+ <label>This is a path</label>
+ <default code="true">QDir::homeDirPath()+QString::fromLatin1(".hidden_file")</default>
+ </entry>
+ <entry name="MyPaths" type="PathList">
+ <label>This is a list of paths</label>
+ <default>/home,~</default>
+ </entry>
+ <entry name="MyPaths2" type="PathList">
+ <label>This is a list of paths (test2)</label>
+ <default code="true">QStringList(QDir::homeDirPath())</default>
+ </entry>
+ <entry name="AnotherOption2" type="Int" key="Another Option">
+ <label>Another option</label>
+ <default>10</default>
+ </entry>
+ <entry name="MyStringList" type="StringList">
+ <default>up,down</default>
+ </entry>
+ <entry name="MyStringListHidden" hidden="true" type="StringList">
+ <default>up,down</default>
+ </entry>
+ <entry name="MyNumber" type="Int64" key="List-$(transport)-$(folder)">
+ <label>List Number</label>
+ <default>1</default>
+ </entry>
+ </group>
+</kcfg>
diff --git a/tdecore/kconfig_compiler/example/exampleprefs_base.kcfgc b/tdecore/kconfig_compiler/example/exampleprefs_base.kcfgc
new file mode 100644
index 000000000..829ec2e29
--- /dev/null
+++ b/tdecore/kconfig_compiler/example/exampleprefs_base.kcfgc
@@ -0,0 +1,18 @@
+# Code generation options for kconfig_compiler
+ClassName=ExamplePrefsBase
+#
+# Singleton=false
+#
+# Inherits=KConfigSkeleton
+#
+# 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
new file mode 100644
index 000000000..9b41370c7
--- /dev/null
+++ b/tdecore/kconfig_compiler/example/general_base.ui
@@ -0,0 +1,46 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>GeneralBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>GeneralBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>486</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>AutoExampleDialog</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="0" column="1">
+ <property name="name">
+ <cstring>kcfg_OneOption</cstring>
+ </property>
+ <property name="text">
+ <string>OneOption</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="1" column="1">
+ <property name="name">
+ <cstring>kcfg_AnotherOption2</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>AnotherOption:</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/tdecore/kconfig_compiler/example/myoptions_base.ui b/tdecore/kconfig_compiler/example/myoptions_base.ui
new file mode 100644
index 000000000..3c0c2e6cb
--- /dev/null
+++ b/tdecore/kconfig_compiler/example/myoptions_base.ui
@@ -0,0 +1,35 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>MyOptionsBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>MyOptionsBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>486</height>
+ </rect>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>MyString:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>kcfg_MyString</cstring>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/tdecore/kconfig_compiler/kcfg.xsd b/tdecore/kconfig_compiler/kcfg.xsd
new file mode 100644
index 000000000..97f716d62
--- /dev/null
+++ b/tdecore/kconfig_compiler/kcfg.xsd
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- kcfg XSD v1.0 -->
+<xsd:schema
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:kcfg="http://www.kde.org/standards/kcfg/1.0"
+ targetNamespace="http://www.kde.org/standards/kcfg/1.0"
+ version="1.0"
+ elementFormDefault="qualified" >
+
+ <xsd:annotation>
+ <xsd:documentation>
+
+ Copyright (c) 2003 Cornelius Schumacher &lt;[email protected]&gt;
+ Copyright (c) 2003 Waldo Bastian &lt;[email protected]&gt;
+ Copyright (c) 2003 Zack Rusin &lt;[email protected]&gt;
+ Copyright (c) 2004 Frans Englich &lt;[email protected]&gt;
+
+ 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.
+
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:annotation>
+ <xsd:documentation>
+
+ A Schema for KDE's KConfigXT 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:
+
+ <![CDATA[
+
+ <?xml version="1.0" encoding="UTF-8" ?>
+ <kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <!-- the content -->
+ </kcfg>
+
+ ]]>
+
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <xsd:element name="kcfg">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="include" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
+ <xsd:element name="kcfgfile" >
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="parameter" type="kcfg:parameter" minOccurs="0" maxOccurs="unbounded" />
+ <!-- FIXME: Are really unbounded occurances of parameter allowed? -->
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ <xsd:attribute name="arg" type="xsd:boolean" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="group" maxOccurs="unbounded" >
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="entry" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="parameter" minOccurs="0" type="kcfg:parameter"/>
+ <xsd:element name="label" minOccurs="0" type="xsd:string"/>
+ <xsd:element name="whatsthis" minOccurs="0" type="xsd:string"/>
+ <xsd:element name="choices" minOccurs="0">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="choice" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:all>
+ <xsd:element minOccurs="0" name="label" type="xsd:string"/>
+ <xsd:element minOccurs="0" name="whatsthis" type="xsd:string"/>
+ </xsd:all>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="code" minOccurs="0" type="kcfg:code"/>
+
+ <xsd:element name="default" maxOccurs="unbounded" minOccurs="0" >
+ <xsd:complexType>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute use="optional" name="code" type="xsd:boolean"/>
+ <xsd:attribute use="optional" name="param" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="min" minOccurs="0" >
+ <xsd:complexType>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="code" type="xsd:boolean"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="max" minOccurs="0">
+ <xsd:complexType>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="code" type="xsd:boolean"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:choice>
+ <xsd:attribute name="name" use="optional" type="xsd:string"/>
+ <xsd:attribute name="key" use="optional" type="xsd:string"/>
+ <xsd:attribute name="hidden" use="optional" type="xsd:boolean"/>
+ <xsd:attribute name="type" type="kcfg:datatype"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:simpleType name="datatype">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="String"/>
+ <xsd:enumeration value="StringList"/>
+ <xsd:enumeration value="Font"/>
+ <xsd:enumeration value="Rect"/>
+ <xsd:enumeration value="Size"/>
+ <xsd:enumeration value="Color"/>
+ <xsd:enumeration value="Point"/>
+ <xsd:enumeration value="Int"/>
+ <xsd:enumeration value="UInt"/>
+ <xsd:enumeration value="Bool"/>
+ <xsd:enumeration value="Double"/>
+ <xsd:enumeration value="DateTime"/>
+ <xsd:enumeration value="Int64"/>
+ <xsd:enumeration value="UInt64"/>
+ <xsd:enumeration value="IntList"/>
+ <xsd:enumeration value="Enum"/>
+ <xsd:enumeration value="Path"/>
+ <xsd:enumeration value="PathList"/>
+ <xsd:enumeration value="Password"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:complexType name="parameter">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" name="values">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" maxOccurs="unbounded" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="type" use="optional" type="kcfg:datatype" />
+ <xsd:attribute name="max" use="optional" type="xsd:positiveInteger"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="code">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+</xsd:schema>
+
diff --git a/tdecore/kconfig_compiler/kconfig_compiler.cpp b/tdecore/kconfig_compiler/kconfig_compiler.cpp
new file mode 100644
index 000000000..10c91834c
--- /dev/null
+++ b/tdecore/kconfig_compiler/kconfig_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 <[email protected]>
+ Copyright (c) 2003 Waldo Bastian <[email protected]>
+ Copyright (c) 2003 Zack Rusin <[email protected]>
+
+ 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 <tqfile.h>
+#include <tqtextstream.h>
+#include <tqdom.h>
+#include <tqregexp.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kcmdlineargs.h>
+#include <kglobal.h>
+#include <kconfig.h>
+#include <ksimpleconfig.h>
+#include <kstandarddirs.h>
+
+#include <iostream>
+
+static const KCmdLineOptions options[] =
+{
+ { "d", 0, 0 },
+ { "directory <dir>", 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<Choice> &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<Choice> &d ) { mChoices = d; }
+ TQValueList<Choice> 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() << "<entry>" << 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() << "</entry>" << 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<Choice> 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].tqunicode() > 127) isAscii = false;
+
+ if (isAscii)
+ return "TQString::tqfromLatin1( " + 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<CfgEntry::Choice> &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<CfgEntry::Choice>::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<int> 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<CfgEntry::Choice> 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 <choice> 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 '"<<name<<"' contains spaces! <name> elements can't contain speces!"<<endl;
+ name.remove( ' ' );
+ }
+
+ if (name.contains("$("))
+ {
+ if (param.isEmpty())
+ {
+ kdError() << "Name may not be parameterized: " << name << endl;
+ return 0;
+ }
+ }
+ else
+ {
+ if (!param.isEmpty())
+ {
+ kdError() << "Name must contain '$(" << param << ")': " << name << endl;
+ return 0;
+ }
+ }
+
+ if ( label.isEmpty() ) {
+ label = key;
+ }
+
+ if ( type.isEmpty() ) type = "String"; // XXX : implicit type might be bad
+
+ if (!param.isEmpty())
+ {
+ // Adjust name
+ paramName = name;
+ name.replace("$("+param+")", TQString());
+ // Lookup defaults for indexed entries
+ for(int i = 0; i <= paramMax; i++)
+ {
+ paramDefaultValues.append(TQString());
+ }
+
+ TQDomNode n;
+ for ( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) {
+ TQDomElement e = n.toElement();
+ TQString tag = e.tagName();
+ if ( tag == "default" )
+ {
+ TQString index = e.attribute("param");
+ if (index.isEmpty())
+ continue;
+
+ bool ok;
+ int i = index.toInt(&ok);
+ if (!ok)
+ {
+ i = paramValues.findIndex(index);
+ if (i == -1)
+ {
+ kdError() << "Index '" << index << "' for default value is unknown." << endl;
+ return 0;
+ }
+ }
+
+ if ((i < 0) || (i > 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<int> &";
+ 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 <<"\""<<endl;
+ return TQSTRING_OBJECT_NAME_STRING; //For now, but an assert would be better
+ }
+}
+
+/**
+ Actual C++ storage type for given type.
+*/
+TQString cppType( const TQString &type )
+{
+ if ( type == "String" ) return TQSTRING_OBJECT_NAME_STRING;
+ else if ( type == "StringList" ) return TQSTRINGLIST_OBJECT_NAME_STRING;
+ else if ( type == "Font" ) return "TQFont";
+ else if ( type == "Rect" ) return "TQRect";
+ else if ( type == "Size" ) return "TQSize";
+ else if ( type == "Color" ) return "TQColor";
+ else if ( type == "Point" ) return TQPOINT_OBJECT_NAME_STRING;
+ 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 "TQDateTime";
+ else if ( type == "Int64" ) return "TQ_INT64";
+ else if ( type == "UInt64" ) return "TQ_UINT64";
+ else if ( type == "IntList" ) return "TQValueList<int>";
+ 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 <<"\""<<endl;
+ return TQSTRING_OBJECT_NAME_STRING; //For now, but an assert would be better
+ }
+}
+
+TQString defaultValue( const TQString &type )
+{
+ if ( type == "String" ) return "\"\""; // Use empty string, not null string!
+ else if ( type == "StringList" ) return "TQStringList()";
+ else if ( type == "Font" ) return "KGlobalSettings::generalFont()";
+ else if ( type == "Rect" ) return "TQRect()";
+ else if ( type == "Size" ) return "TQSize()";
+ else if ( type == "Color" ) return "TQColor(128, 128, 128)";
+ else if ( type == "Point" ) return "TQPoint()";
+ else if ( type == "Int" ) return "0";
+ else if ( type == "UInt" ) return "0";
+ else if ( type == "Bool" ) return "false";
+ else if ( type == "Double" ) return "0.0";
+ else if ( type == "DateTime" ) return "TQDateTime()";
+ else if ( type == "Int64" ) return "0";
+ else if ( type == "UInt64" ) return "0";
+ else if ( type == "IntList" ) return "TQValueList<int>()";
+ 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!"<<endl;
+ return TQSTRING_OBJECT_NAME_STRING; //For now, but an assert would be better
+ }
+}
+
+TQString itemType( const TQString &type )
+{
+ TQString t;
+
+ t = type;
+ t.replace( 0, 1, t.left( 1 ).upper() );
+
+ return t;
+}
+
+static TQString itemDeclaration(const CfgEntry *e)
+{
+ if (itemAccessors)
+ return TQString();
+
+ TQString fCap = e->name();
+ fCap[0] = fCap[0].upper();
+ return " KConfigSkeleton::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 &param = TQString())
+{
+ TQString t = "new KConfigSkeleton::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<Param> &parameters)
+{
+ TQString paramString = group;
+ TQString arguments;
+ int i = 1;
+ for (TQValueList<Param>::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::tqfromLatin1( \""+group+"\" )";
+
+ return "TQString::tqfromLatin1( \""+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::tqfromLatin1( \"";
+ if (!e->param().isEmpty())
+ {
+ out << e->paramName().replace("$("+e->param()+")", "%1") << "\" ).arg( ";
+ if ( e->paramType() == "Enum" ) {
+ out << "TQString::tqfromLatin1( ";
+
+ 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 )
+{
+ KAboutData aboutData( "kconfig_compiler", I18N_NOOP("KDE .kcfg compiler"), "0.3",
+ I18N_NOOP("KConfig Compiler") , KAboutData::License_LGPL );
+ aboutData.addAuthor( "Cornelius Schumacher", 0, "[email protected]" );
+ aboutData.addAuthor( "Waldo Bastian", 0, "[email protected]" );
+ aboutData.addAuthor( "Zack Rusin", 0, "[email protected]" );
+ aboutData.addCredit( "Reinhold Kainhofer", "Fix for parametrized entries",
+ "[email protected]", "http://reinhold.kainhofer.com" );
+ aboutData.addCredit( "Duncan Mac-Vicar P.", "dpointer support",
+ "[email protected]", "http://www.mac-vicar.com/~duncan" );
+
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KCmdLineArgs::addCmdLineOptions( options );
+
+ KInstance app( &aboutData );
+
+ KCmdLineArgs *args = KCmdLineArgs::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<Param> parameters;
+ TQStringList includes;
+
+ TQPtrList<CfgEntry> 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 = "KConfigSkeleton";
+
+ 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 <kglobal.h>" << endl;
+
+ h << "#include <kconfigskeleton.h>" << endl;
+ h << "#include <kdebug.h>" << 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<CfgEntry::Choice> choices = e->choices();
+ if ( !choices.isEmpty() ) {
+ TQStringList values;
+ TQValueList<CfgEntry::Choice>::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() ? " = KGlobal::sharedConfig()" : ", ");
+ for (TQValueList<Param>::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<KConfigSkeleton*>(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<Param>::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\"" <<endl;
+ }
+
+ h << "};" << endl << endl;
+
+ if ( !nameSpace.isEmpty() ) h << "}" << endl << endl;
+
+ h << "#endif" << endl << endl;
+
+
+ header.close();
+
+ TQFile implementation( baseDir + implementationFileName );
+ if ( !implementation.open( IO_WriteOnly ) ) {
+ kdError() << "Can't open '" << implementationFileName << "' for writing."
+ << endl;
+ return 1;
+ }
+
+ TQTextStream cpp( &implementation );
+
+
+ cpp << "// This file is generated by kconfig_compiler from " << args->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 <klocale.h>" << endl << endl;
+
+ // Header required by singleton implementation
+ if ( singleton )
+ cpp << "#include <kstaticdeleter.h>" << endl << endl;
+ if ( singleton && cfgFileNameArg )
+ cpp << "#include <kdebug.h>" << 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 << " KConfigSkeleton::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<Param>::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::tqfromLatin1( \"" << cfgFileName << "\" ";
+ if ( cfgFileNameArg ) cpp << " config ";
+ if ( !cfgFileName.isEmpty() ) cpp << ") ";
+ cpp << ")" << endl;
+
+ // Store parameters
+ for (TQValueList<Param>::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<KConfigSkeleton::ItemEnum::Choice> values"
+ << e->name() << ";" << endl;
+ TQValueList<CfgEntry::Choice> choices = e->choices();
+ TQValueList<CfgEntry::Choice>::ConstIterator it;
+ for( it = choices.begin(); it != choices.end(); ++it ) {
+ cpp << " {" << endl;
+ cpp << " KConfigSkeleton::ItemEnum::Choice choice;" << endl;
+ cpp << " choice.name = TQString::tqfromLatin1( \"" << (*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::tqfromLatin1( \"" << 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::tqfromLatin1( \"";
+ 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 << "KConfigSkeleton::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
new file mode 100644
index 000000000..0b47449fa
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/Makefile.am
@@ -0,0 +1,134 @@
+AM_CPPFLAGS = -I$(top_srcdir)/tdecore -I$(top_srcdir)/kunittest $(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_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+test1_LDADD = $(LIB_KDECORE)
+test1_SOURCES = test1main.cpp test1.cpp
+
+test2_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+test2_LDADD = $(LIB_KDECORE)
+test2_SOURCES = test2main.cpp test2.cpp
+
+test3_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+test3_LDADD = $(LIB_KDECORE)
+test3_SOURCES = test3main.cpp test3.cpp
+
+test4_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+test4_LDADD = $(LIB_KDECORE)
+test4_SOURCES = test4main.cpp test4.cpp
+
+test5_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+test5_LDADD = $(LIB_KDECORE)
+test5_SOURCES = test5main.cpp test5.cpp
+
+test6_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+test6_LDADD = $(LIB_KDECORE)
+test6_SOURCES = test6main.cpp test6.cpp
+
+test7_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+test7_LDADD = $(LIB_KDECORE)
+test7_SOURCES = test7main.cpp test7.cpp
+
+test8_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+test8_LDADD = $(LIB_KDECORE)
+test8_SOURCES = test8main.cpp test8a.cpp test8b.cpp
+
+test9_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+test9_LDADD = $(LIB_KDECORE)
+test9_SOURCES = test9main.cpp test9.cpp
+
+test_dpointer_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_KDECORE) $(LIB_KDEUI) -ltdefx $(LIB_KIO) -lktexteditor
+test_dpointer_LDADD = $(LIB_KDECORE)
+test_dpointer_SOURCES = test_dpointer_main.cpp test_dpointer.cpp
+
+check_LTLIBRARIES = kunittest_kconfigcompiler_test.la
+
+kunittest_kconfigcompiler_test_la_SOURCES = kconfigcompiler_test.cpp
+kunittest_kconfigcompiler_test_la_LIBADD = \
+ $(top_builddir)/kunittest/libkunittest.la
+kunittest_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
new file mode 100644
index 000000000..3dd197b34
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp
@@ -0,0 +1,96 @@
+/*
+ Tests for KConfig Compiler
+
+ Copyright (c) 2005 by Duncan Mac-Vicar <[email protected]>
+
+ *************************************************************************
+ * *
+ * 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 <tqfile.h>
+#include <tqstring.h>
+#include <kdebug.h>
+#include <kunittest/module.h>
+#include "kconfigcompiler_test.h"
+
+using namespace KUnitTest;
+
+KUNITTEST_MODULE( kunittest_kconfigcompiler_test, "KConfigXT")
+KUNITTEST_MODULE_REGISTER_TESTER( KConfigCompiler_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 KConfigCompiler_Test::allTests()
+{
+ testExpectedOutput();
+}
+
+void KConfigCompiler_Test::testExpectedOutput()
+{
+ uint i = 0;
+ // Known to pass test cases
+ while (testCases[ i ])
+ {
+ performCompare(TQString::tqfromLatin1(testCases[ i ]));
+ ++i;
+ }
+
+ // broken test cases
+ i= 0;
+ while (willFailCases[ i ])
+ {
+ performCompare(TQString::tqfromLatin1(willFailCases[ i ]), true);
+ ++i;
+ }
+}
+
+void KConfigCompiler_Test::performCompare(const TQString &fileName, bool fail)
+{
+ TQFile file(fileName);
+ TQFile fileRef(TQString::tqfromLatin1(SRCDIR) + TQString::tqfromLatin1("/") + fileName + TQString::tqfromLatin1(".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
new file mode 100644
index 000000000..36b33cd47
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/kconfigcompiler_test.h
@@ -0,0 +1,35 @@
+/*
+ Tests for KConfig Compiler
+
+ Copyright (c) 2005 by Duncan Mac-Vicar <[email protected]>
+
+ *************************************************************************
+ * *
+ * 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 <kunittest/tester.h>
+
+class TQString;
+
+// change to SlotTester when it works
+class KConfigCompiler_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
new file mode 100644
index 000000000..ebef89c08
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/myprefs.h
@@ -0,0 +1,7 @@
+#include <kconfigskeleton.h>
+
+class MyPrefs : public KConfigSkeleton
+{
+ public:
+ MyPrefs( const TQString &a ) : KConfigSkeleton( a ) {}
+};
diff --git a/tdecore/kconfig_compiler/tests/test1.cpp.ref b/tdecore/kconfig_compiler/tests/test1.cpp.ref
new file mode 100644
index 000000000..f8c4c1189
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test1.cpp.ref
@@ -0,0 +1,72 @@
+// 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 )
+ : KConfigSkeleton( TQString::tqfromLatin1( "examplerc" ) )
+ , mParamtransport(transport)
+ , mParamfolder(folder)
+{
+ setCurrentGroup( TQString::tqfromLatin1( "General-%1" ).arg( mParamfolder ) );
+
+ KConfigSkeleton::ItemBool *itemOneOption;
+ itemOneOption = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "OneOption" ), mOneOption, true );
+ addItem( itemOneOption, TQString::tqfromLatin1( "OneOption" ) );
+ KConfigSkeleton::ItemInt *itemAnotherOption;
+ itemAnotherOption = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Another Option" ), mAnotherOption, 5 );
+ addItem( itemAnotherOption, TQString::tqfromLatin1( "AnotherOption" ) );
+ TQValueList<KConfigSkeleton::ItemEnum::Choice> valuesListOption;
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "One" );
+ valuesListOption.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "Two" );
+ valuesListOption.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "Three" );
+ valuesListOption.append( choice );
+ }
+ KConfigSkeleton::ItemEnum *itemListOption;
+ itemListOption = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "ListOption" ), mListOption, valuesListOption, EnumListOption::One );
+ addItem( itemListOption, TQString::tqfromLatin1( "ListOption" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "MyOptions" ) );
+
+ KConfigSkeleton::ItemString *itemMyString;
+ itemMyString = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "MyString" ), mMyString, TQString::tqfromLatin1( "Default String" ) );
+ addItem( itemMyString, TQString::tqfromLatin1( "MyString" ) );
+ KConfigSkeleton::ItemPath *itemMyPath;
+ itemMyPath = new KConfigSkeleton::ItemPath( currentGroup(), TQString::tqfromLatin1( "MyPath" ), mMyPath, TQDir::homeDirPath()+TQString::tqfromLatin1(".hidden_file") );
+ addItem( itemMyPath, TQString::tqfromLatin1( "MyPath" ) );
+ KConfigSkeleton::ItemInt *itemAnotherOption2;
+ itemAnotherOption2 = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Another Option" ), mAnotherOption2, 10 );
+ addItem( itemAnotherOption2, TQString::tqfromLatin1( "AnotherOption2" ) );
+ TQStringList defaultMyStringList;
+ defaultMyStringList.append( TQString::fromUtf8( "up" ) );
+ defaultMyStringList.append( TQString::fromUtf8( "down" ) );
+
+ KConfigSkeleton::ItemStringList *itemMyStringList;
+ itemMyStringList = new KConfigSkeleton::ItemStringList( currentGroup(), TQString::tqfromLatin1( "MyStringList" ), mMyStringList, defaultMyStringList );
+ addItem( itemMyStringList, TQString::tqfromLatin1( "MyStringList" ) );
+ TQStringList defaultMyStringListHidden;
+ defaultMyStringListHidden.append( TQString::fromUtf8( "up" ) );
+ defaultMyStringListHidden.append( TQString::fromUtf8( "down" ) );
+
+ KConfigSkeleton::ItemStringList *itemMyStringListHidden;
+ itemMyStringListHidden = new KConfigSkeleton::ItemStringList( currentGroup(), TQString::tqfromLatin1( "MyStringListHidden" ), mMyStringListHidden, defaultMyStringListHidden );
+ addItem( itemMyStringListHidden, TQString::tqfromLatin1( "MyStringListHidden" ) );
+ KConfigSkeleton::ItemInt *itemMyNumber;
+ itemMyNumber = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "List-%1-%2" ).arg( mParamtransport ).arg( mParamfolder ), mMyNumber, 1 );
+ addItem( itemMyNumber, TQString::tqfromLatin1( "MyNumber" ) );
+}
+
+Test1::~Test1()
+{
+}
+
diff --git a/tdecore/kconfig_compiler/tests/test1.h.ref b/tdecore/kconfig_compiler/tests/test1.h.ref
new file mode 100644
index 000000000..b5a66b5cd
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test1.h.ref
@@ -0,0 +1,196 @@
+// 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 <kconfigskeleton.h>
+#include <kdebug.h>
+
+#include <tqdir.h>
+class Test1 : public KConfigSkeleton
+{
+ 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::tqfromLatin1( "OneOption" ) ))
+ mOneOption = v;
+ }
+
+ /**
+ Get One option
+ */
+ bool oneOption() const
+ {
+ return mOneOption;
+ }
+
+ /**
+ Set Another option
+ */
+ void setAnotherOption( int v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "AnotherOption" ) ))
+ mAnotherOption = v;
+ }
+
+ /**
+ Get Another option
+ */
+ int anotherOption() const
+ {
+ return mAnotherOption;
+ }
+
+ /**
+ Set This is some funky option
+ */
+ void setListOption( int v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "MyPath" ) ))
+ mMyPath = v;
+ }
+
+ /**
+ Get This is a path
+ */
+ TQString myPath() const
+ {
+ return mMyPath;
+ }
+
+ /**
+ Set Another option
+ */
+ void setAnotherOption2( int v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "AnotherOption2" ) ))
+ mAnotherOption2 = v;
+ }
+
+ /**
+ Get Another option
+ */
+ int anotherOption2() const
+ {
+ return mAnotherOption2;
+ }
+
+ /**
+ Set MyStringList
+ */
+ void setMyStringList( const TQStringList & v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "MyStringList" ) ))
+ mMyStringList = v;
+ }
+
+ /**
+ Get MyStringList
+ */
+ TQStringList myStringList() const
+ {
+ return mMyStringList;
+ }
+
+ /**
+ Set MyStringListHidden
+ */
+ void setMyStringListHidden( const TQStringList & v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "MyStringListHidden" ) ))
+ mMyStringListHidden = v;
+ }
+
+ /**
+ Get MyStringListHidden
+ */
+ TQStringList myStringListHidden() const
+ {
+ return mMyStringListHidden;
+ }
+
+ /**
+ Set List Number
+ */
+ void setMyNumber( int v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "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
new file mode 100644
index 000000000..ce42aebfb
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test1.kcfg
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <include>qdir.h</include>
+ <kcfgfile name="examplerc">
+ <parameter name="transport" />
+ <parameter name="folder" />
+ </kcfgfile>
+ <group name="General-$(folder)">
+ <entry name="OneOption" type="Bool">
+ <label>One option</label>
+ <default>true</default>
+ </entry>
+ <entry name="AnotherOption" type="Int" key="Another Option">
+ <label>Another option</label>
+ <default>5</default>
+ </entry>
+ <entry name="ListOption" type="Enum">
+ <label>This is some funky option</label>
+ <whatsthis>And this is a longer description of this option. Just wondering, how will the translations of those be handled?</whatsthis>
+ <choices>
+ <choice name="One"/>
+ <choice name="Two"/>
+ <choice name="Three"/>
+ </choices>
+ <default>One</default>
+ </entry>
+ </group>
+ <group name="MyOptions">
+ <entry name="MyString" type="String">
+ <label>This is a string</label>
+ <default>Default String</default>
+ </entry>
+ <entry name="MyPath" type="Path">
+ <label>This is a path</label>
+ <default code="true">QDir::homeDirPath()+QString::fromLatin1(".hidden_file")</default>
+ </entry>
+ <entry name="AnotherOption2" type="Int" key="Another Option">
+ <label>Another option</label>
+ <default>10</default>
+ </entry>
+ <entry name="MyStringList" type="StringList">
+ <default>up,down</default>
+ </entry>
+ <entry name="MyStringListHidden" hidden="true" type="StringList">
+ <default>up,down</default>
+ </entry>
+ <entry name="MyNumber" type="Int" key="List-$(transport)-$(folder)">
+ <label>List Number</label>
+ <default>1</default>
+ </entry>
+ </group>
+</kcfg>
diff --git a/tdecore/kconfig_compiler/tests/test1.kcfgc b/tdecore/kconfig_compiler/tests/test1.kcfgc
new file mode 100644
index 000000000..3b74d7c51
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test1.kcfgc
@@ -0,0 +1,18 @@
+# Code generation options for kconfig_compiler
+ClassName=Test1
+#
+# Singleton=false
+#
+# Inherits=KConfigSkeleton
+#
+# 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
new file mode 100644
index 000000000..976a7bbd6
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test1main.cpp
@@ -0,0 +1,29 @@
+/*
+Copyright (c) 2003 Cornelius Schumacher <[email protected]>
+
+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*[] )
+{
+ KInstance 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
new file mode 100644
index 000000000..af8db588d
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test2.cpp.ref
@@ -0,0 +1,98 @@
+// This file is generated by kconfig_compiler from test2.kcfg.
+// All changes you do to this file will be lost.
+
+#include "test2.h"
+
+#include <klocale.h>
+
+Test2::Test2( )
+ : MyPrefs( TQString::tqfromLatin1( "korganizerrc" ) )
+{
+ setCurrentGroup( TQString::tqfromLatin1( "General" ) );
+
+ mAutoSaveItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "Auto Save" ), mAutoSave, false );
+ mAutoSaveItem->setLabel( i18n("Enable automatic saving of calendar") );
+ mAutoSaveItem->setWhatsThis( i18n("WhatsThis text for AutoSave option") );
+ addItem( mAutoSaveItem, TQString::tqfromLatin1( "AutoSave" ) );
+ mAutoSaveIntervalItem = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Auto Save Interval" ), mAutoSaveInterval, 10 );
+ mAutoSaveIntervalItem->setLabel( i18n("Auto Save Interval") );
+ addItem( mAutoSaveIntervalItem, TQString::tqfromLatin1( "AutoSaveInterval" ) );
+ mConfirmItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "Confirm Deletes" ), mConfirm, true );
+ mConfirmItem->setLabel( i18n("Confirm deletes") );
+ addItem( mConfirmItem, TQString::tqfromLatin1( "Confirm" ) );
+ mArchiveFileItem = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "Archive File" ), mArchiveFile );
+ mArchiveFileItem->setLabel( i18n("Archive File") );
+ addItem( mArchiveFileItem, TQString::tqfromLatin1( "ArchiveFile" ) );
+ TQValueList<KConfigSkeleton::ItemEnum::Choice> valuesDestination;
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "standardDestination" );
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "askDestination" );
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "argl1" );
+ choice.label = i18n("Argl1 Label");
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "argl2" );
+ choice.whatsThis = i18n("Argl2 Whatsthis");
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "argl3" );
+ choice.label = i18n("Argl3 Label");
+ choice.whatsThis = i18n("Argl3 Whatsthis");
+ valuesDestination.append( choice );
+ }
+ mDestinationItem = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "Destination" ), mDestination, valuesDestination, standardDestination );
+ mDestinationItem->setLabel( i18n("New Events/Todos Should") );
+ addItem( mDestinationItem, TQString::tqfromLatin1( "Destination" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "Views" ) );
+
+ mHourSizeItem = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Hour Size" ), mHourSize, 10 );
+ mHourSizeItem->setLabel( i18n("Hour Size") );
+ addItem( mHourSizeItem, TQString::tqfromLatin1( "HourSize" ) );
+ mSelectionStartsEditorItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "SelectionStartsEditor" ), mSelectionStartsEditor, false );
+ mSelectionStartsEditorItem->setLabel( i18n("Time range selection in agenda view starts event editor") );
+ addItem( mSelectionStartsEditorItem, TQString::tqfromLatin1( "SelectionStartsEditor" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "KOrganizer Plugins" ) );
+
+ TQStringList defaultSelectedPlugins;
+ defaultSelectedPlugins.append( TQString::fromUtf8( "holidays" ) );
+ defaultSelectedPlugins.append( TQString::fromUtf8( "webexport" ) );
+
+ mSelectedPluginsItem = new KConfigSkeleton::ItemStringList( currentGroup(), TQString::tqfromLatin1( "SelectedPlugins" ), mSelectedPlugins, defaultSelectedPlugins );
+ mSelectedPluginsItem->setLabel( i18n("SelectedPlugins") );
+ addItem( mSelectedPluginsItem, TQString::tqfromLatin1( "SelectedPlugins" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "Colors" ) );
+
+ mHighlightColorItem = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "Highlight Color" ), mHighlightColor, TQColor( 100, 100, 255 ) );
+ mHighlightColorItem->setLabel( i18n("Highlight color") );
+ addItem( mHighlightColorItem, TQString::tqfromLatin1( "HighlightColor" ) );
+ mAgendaBgColorItem = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "Agenda Background Color" ), mAgendaBgColor, TQColor( 255, 255, 255 ) );
+ mAgendaBgColorItem->setLabel( i18n("Agenda view background color") );
+ addItem( mAgendaBgColorItem, TQString::tqfromLatin1( "AgendaBgColor" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "Fonts" ) );
+
+ mTimeBarFontItem = new KConfigSkeleton::ItemFont( currentGroup(), TQString::tqfromLatin1( "TimeBar Font" ), mTimeBarFont );
+ mTimeBarFontItem->setLabel( i18n("Time bar") );
+ addItem( mTimeBarFontItem, TQString::tqfromLatin1( "TimeBarFont" ) );
+}
+
+Test2::~Test2()
+{
+}
+
diff --git a/tdecore/kconfig_compiler/tests/test2.h.ref b/tdecore/kconfig_compiler/tests/test2.h.ref
new file mode 100644
index 000000000..075f48bde
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test2.h.ref
@@ -0,0 +1,333 @@
+// 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 <myprefs.h>
+
+#include <kconfigskeleton.h>
+#include <kdebug.h>
+
+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::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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
new file mode 100644
index 000000000..3b19e270e
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test2.kcfg
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name="korganizerrc"/>
+
+ <group name="General">
+ <entry type="Bool" key="Auto Save">
+ <label>Enable automatic saving of calendar</label>
+ <whatsthis>WhatsThis text for AutoSave option</whatsthis>
+ <default>false</default>
+ </entry>
+ <entry type="Int" key="Auto Save Interval">
+ <default>10</default>
+ </entry>
+ <entry type="Bool" key="Confirm Deletes" name="Confirm">
+ <label>Confirm deletes</label>
+ <default>true</default>
+ </entry>
+ <entry type="String" key="Archive File">
+ </entry>
+ <entry type="Enum" key="Destination" name="Destination">
+ <label>New Events/Todos Should</label>
+ <choices>
+ <choice name="standardDestination">
+ </choice>
+ <choice name="askDestination">
+ </choice>
+ <choice name="argl1">
+ <label>Argl1 Label</label>
+ </choice>
+ <choice name="argl2">
+ <whatsthis>Argl2 Whatsthis</whatsthis>
+ </choice>
+ <choice name="argl3">
+ <label>Argl3 Label</label>
+ <whatsthis>Argl3 Whatsthis</whatsthis>
+ </choice>
+ </choices>
+ <default>standardDestination</default>
+ </entry>
+ </group>
+
+ <group name="Views">
+ <entry type="Int" key="Hour Size">
+ <default>10</default>
+ </entry>
+ <entry type="Bool" name="SelectionStartsEditor">
+ <label>Time range selection in agenda view starts event editor</label>
+ <default>false</default>
+ </entry>
+ </group>
+
+ <group name="KOrganizer Plugins">
+ <entry type="StringList" name="SelectedPlugins">
+ <default>holidays,webexport</default>
+ </entry>
+ </group>
+
+ <group name="Colors">
+ <entry type="Color" key="Highlight Color">
+ <label>Highlight color</label>
+ <default>100, 100, 255</default>
+ </entry>
+ <entry type="Color" key="Agenda Background Color" name="AgendaBgColor">
+ <label>Agenda view background color</label>
+ <default>255, 255, 255</default>
+ </entry>
+ </group>
+
+ <group name="Fonts">
+ <entry type="Font" key="TimeBar Font">
+ <label>Time bar</label>
+ </entry>
+ </group>
+
+</kcfg>
diff --git a/tdecore/kconfig_compiler/tests/test2.kcfgc b/tdecore/kconfig_compiler/tests/test2.kcfgc
new file mode 100644
index 000000000..56620d2f4
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test2.kcfgc
@@ -0,0 +1,11 @@
+# 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
new file mode 100644
index 000000000..904c57270
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test2main.cpp
@@ -0,0 +1,29 @@
+/*
+Copyright (c) 2003 Cornelius Schumacher <[email protected]>
+
+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*[] )
+{
+ KInstance 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
new file mode 100644
index 000000000..a47fd5213
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test3.cpp.ref
@@ -0,0 +1,29 @@
+// 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( )
+ : KConfigSkeleton( TQString::tqfromLatin1( "test3rc" ) )
+{
+ setCurrentGroup( TQString::tqfromLatin1( "General" ) );
+
+ mAutoSaveItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "Auto Save" ), mAutoSave, false );
+ addItem( mAutoSaveItem, TQString::tqfromLatin1( "AutoSave" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "Blah" ) );
+
+ mBlubbItem = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Blubb" ), mBlubb, 10 );
+ addItem( mBlubbItem, TQString::tqfromLatin1( "Blubb" ) );
+ mBlahBlahItem = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "BlahBlah" ), mBlahBlah, TQString::tqfromLatin1( "a string" ) );
+ addItem( mBlahBlahItem, TQString::tqfromLatin1( "BlahBlah" ) );
+ mMyPasswordItem = new KConfigSkeleton::ItemPassword( currentGroup(), TQString::tqfromLatin1( "MyPassword" ), mMyPassword );
+ addItem( mMyPasswordItem, TQString::tqfromLatin1( "MyPassword" ) );
+}
+
+Test3::~Test3()
+{
+}
+
diff --git a/tdecore/kconfig_compiler/tests/test3.h.ref b/tdecore/kconfig_compiler/tests/test3.h.ref
new file mode 100644
index 000000000..8e86d36b0
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test3.h.ref
@@ -0,0 +1,138 @@
+// 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 <kconfigskeleton.h>
+#include <kdebug.h>
+
+namespace TestNameSpace {
+
+class Test3 : public KConfigSkeleton
+{
+ public:
+
+ Test3( );
+ ~Test3();
+
+ /**
+ Set Enable automatic saving of calendar
+ */
+ void setAutoSave( bool v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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
new file mode 100644
index 000000000..77916da40
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test3.kcfg
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name="test3rc"/>
+
+ <group name="General">
+ <entry type="Bool" key="Auto Save">
+ <label>Enable automatic saving of calendar</label>
+ <whatsthis>WhatsThis text for AutoSave option</whatsthis>
+ <default>false</default>
+ </entry>
+ </group>
+
+ <group name="Blah">
+ <entry type="Int" name="Blubb">
+ <default>10</default>
+ </entry>
+ <entry type="String" name="BlahBlah">
+ <default>a string</default>
+ </entry>
+ <entry type="Password" name="MyPassword"/>
+ </group>
+
+</kcfg>
diff --git a/tdecore/kconfig_compiler/tests/test3.kcfgc b/tdecore/kconfig_compiler/tests/test3.kcfgc
new file mode 100644
index 000000000..ca2c22057
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test3.kcfgc
@@ -0,0 +1,12 @@
+# 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
new file mode 100644
index 000000000..9789d697d
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test3main.cpp
@@ -0,0 +1,29 @@
+/*
+Copyright (c) 2003 Cornelius Schumacher <[email protected]>
+
+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*[] )
+{
+ KInstance 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
new file mode 100644
index 000000000..0eee21488
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test4.cpp.ref
@@ -0,0 +1,82 @@
+// This file is generated by kconfig_compiler from test4.kcfg.
+// All changes you do to this file will be lost.
+
+#include "test4.h"
+
+#include <kstaticdeleter.h>
+
+Test4 *Test4::mSelf = 0;
+static KStaticDeleter<Test4> 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( )
+ : KConfigSkeleton( TQString::tqfromLatin1( "test4rc" ) )
+{
+ mSelf = this;
+ setCurrentGroup( TQString::tqfromLatin1( "Foo" ) );
+
+TQColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black };
+ KConfigSkeleton::ItemColor *itemColor[4];
+ itemColor[0] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #0" ), mColor[0], defaultColor[0] );
+ addItem( itemColor[0], TQString::tqfromLatin1( "Color0" ) );
+ itemColor[1] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #1" ), mColor[1], defaultColor[1] );
+ addItem( itemColor[1], TQString::tqfromLatin1( "Color1" ) );
+ itemColor[2] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #2" ), mColor[2], defaultColor[2] );
+ addItem( itemColor[2], TQString::tqfromLatin1( "Color2" ) );
+ itemColor[3] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #3" ), mColor[3], defaultColor[3] );
+ addItem( itemColor[3], TQString::tqfromLatin1( "Color3" ) );
+ TQValueList<KConfigSkeleton::ItemEnum::Choice> valuesMouseAction;
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "Encrypt" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "Decrypt" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "CrashNBurn" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "PumpNDump" );
+ valuesMouseAction.append( choice );
+ }
+ KConfigSkeleton::ItemEnum *itemMouseAction[3];
+ itemMouseAction[0] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "right_mouse_action" ), mMouseAction[0], valuesMouseAction, EnumMouseAction::Decrypt );
+ addItem( itemMouseAction[0], TQString::tqfromLatin1( "MouseActionright" ) );
+ itemMouseAction[1] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "mid_mouse_action" ), mMouseAction[1], valuesMouseAction, EnumMouseAction::Encrypt );
+ addItem( itemMouseAction[1], TQString::tqfromLatin1( "MouseActionmid" ) );
+ itemMouseAction[2] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "left_mouse_action" ), mMouseAction[2], valuesMouseAction, EnumMouseAction::PumpNDump );
+ addItem( itemMouseAction[2], TQString::tqfromLatin1( "MouseActionleft" ) );
+ KConfigSkeleton::ItemString *itemFooBar;
+ itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "foo bar" ), mFooBar );
+ addItem( itemFooBar, TQString::tqfromLatin1( "FooBar" ) );
+ KConfigSkeleton::ItemInt *itemAge;
+ itemAge = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Age" ), mAge, 35 );
+ itemAge->setMinValue(8);
+ itemAge->setMaxValue(88);
+ addItem( itemAge, TQString::tqfromLatin1( "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
new file mode 100644
index 000000000..dc8691b1f
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test4.h.ref
@@ -0,0 +1,135 @@
+// 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 <kconfigskeleton.h>
+#include <kdebug.h>
+
+class Test4 : public KConfigSkeleton
+{
+ 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::tqfromLatin1( "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::tqfromLatin1( "MouseAction%1" ).arg( TQString::tqfromLatin1( 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::tqfromLatin1( "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::tqfromLatin1( "Age" ) ))
+ self()->mAge = v;
+ }
+
+ /**
+ Get Age
+ */
+ static
+ int age()
+ {
+ return self()->mAge;
+ }
+
+ static
+ void writeConfig()
+ {
+ static_cast<KConfigSkeleton*>(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
new file mode 100644
index 000000000..d8ef2bfae
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test4.kcfg
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name="test4rc"/>
+
+ <group name="Foo">
+ <entry name="Color$(Number)" type="Color" key="color #$(Number)">
+ <parameter name="Number" type="Int" max="3"/>
+ <label>Block colors.</label>
+ <code>QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black };</code>
+ <default code="true">defaultColor[$(Number)]</default>
+ </entry>
+ <entry name="MouseAction$(Button)" type="Enum" key="$(Button)_mouse_action">
+ <parameter name="Button" type="Enum">
+ <values>
+ <value>right</value>
+ <value>mid</value>
+ <value>left</value>
+ </values>
+ </parameter>
+ <label>Mouse actions.</label>
+ <choices>
+ <choice name="Encrypt"/>
+ <choice name="Decrypt"/>
+ <choice name="CrashNBurn"/>
+ <choice name="PumpNDump"/>
+ </choices>
+ <default param="right">Decrypt</default>
+ <default param="mid">Encrypt</default>
+ <default param="left">PumpNDump</default>
+ </entry>
+ <entry name="FooBar" key="foo bar" type="String"/>
+ <entry name="Age" type="Int">
+ <default>35</default>
+ <min>8</min>
+ <max>88</max>
+ </entry>
+ </group>
+
+</kcfg>
diff --git a/tdecore/kconfig_compiler/tests/test4.kcfgc b/tdecore/kconfig_compiler/tests/test4.kcfgc
new file mode 100644
index 000000000..754706dff
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test4.kcfgc
@@ -0,0 +1,11 @@
+# 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
new file mode 100644
index 000000000..8b38b3dbd
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test4main.cpp
@@ -0,0 +1,30 @@
+/*
+Copyright (c) 2003,2004 Waldo Bastian <[email protected]>
+
+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*[] )
+{
+ KInstance 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
new file mode 100644
index 000000000..0fc90b387
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test5.cpp.ref
@@ -0,0 +1,82 @@
+// This file is generated by kconfig_compiler from test5.kcfg.
+// All changes you do to this file will be lost.
+
+#include "test5.h"
+
+#include <kstaticdeleter.h>
+
+Test5 *Test5::mSelf = 0;
+static KStaticDeleter<Test5> 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( )
+ : KConfigSkeleton( TQString::tqfromLatin1( "test4rc" ) )
+{
+ mSelf = this;
+ setCurrentGroup( TQString::tqfromLatin1( "Foo" ) );
+
+TQColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black };
+ KConfigSkeleton::ItemColor *itemColor[4];
+ itemColor[0] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #0" ), mColor[0], defaultColor[0] );
+ addItem( itemColor[0], TQString::tqfromLatin1( "Color0" ) );
+ itemColor[1] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #1" ), mColor[1], defaultColor[1] );
+ addItem( itemColor[1], TQString::tqfromLatin1( "Color1" ) );
+ itemColor[2] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #2" ), mColor[2], defaultColor[2] );
+ addItem( itemColor[2], TQString::tqfromLatin1( "Color2" ) );
+ itemColor[3] = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #3" ), mColor[3], defaultColor[3] );
+ addItem( itemColor[3], TQString::tqfromLatin1( "Color3" ) );
+ TQValueList<KConfigSkeleton::ItemEnum::Choice> valuesMouseAction;
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "Encrypt" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "Decrypt" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "CrashNBurn" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "PumpNDump" );
+ valuesMouseAction.append( choice );
+ }
+ KConfigSkeleton::ItemEnum *itemMouseAction[3];
+ itemMouseAction[0] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "right_mouse_action" ), mMouseAction[0], valuesMouseAction, Decrypt );
+ addItem( itemMouseAction[0], TQString::tqfromLatin1( "MouseActionright" ) );
+ itemMouseAction[1] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "mid_mouse_action" ), mMouseAction[1], valuesMouseAction, Encrypt );
+ addItem( itemMouseAction[1], TQString::tqfromLatin1( "MouseActionmid" ) );
+ itemMouseAction[2] = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "left_mouse_action" ), mMouseAction[2], valuesMouseAction, PumpNDump );
+ addItem( itemMouseAction[2], TQString::tqfromLatin1( "MouseActionleft" ) );
+ KConfigSkeleton::ItemString *itemFooBar;
+ itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "foo bar" ), mFooBar );
+ addItem( itemFooBar, TQString::tqfromLatin1( "FooBar" ) );
+ KConfigSkeleton::ItemInt *itemAge;
+ itemAge = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Age" ), mAge, 35 );
+ itemAge->setMinValue(8);
+ itemAge->setMaxValue(88);
+ addItem( itemAge, TQString::tqfromLatin1( "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
new file mode 100644
index 000000000..9fadbd0ec
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test5.h.ref
@@ -0,0 +1,127 @@
+// 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 <kconfigskeleton.h>
+#include <kdebug.h>
+
+class Test5 : public KConfigSkeleton
+{
+ 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::tqfromLatin1( "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::tqfromLatin1( "MouseAction%1" ).arg( TQString::tqfromLatin1( 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::tqfromLatin1( "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::tqfromLatin1( "Age" ) ))
+ self()->mAge = v;
+ }
+
+ /**
+ Get Age
+ */
+ static
+ int age()
+ {
+ return self()->mAge;
+ }
+
+ static
+ void writeConfig()
+ {
+ static_cast<KConfigSkeleton*>(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
new file mode 100644
index 000000000..d8ef2bfae
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test5.kcfg
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name="test4rc"/>
+
+ <group name="Foo">
+ <entry name="Color$(Number)" type="Color" key="color #$(Number)">
+ <parameter name="Number" type="Int" max="3"/>
+ <label>Block colors.</label>
+ <code>QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black };</code>
+ <default code="true">defaultColor[$(Number)]</default>
+ </entry>
+ <entry name="MouseAction$(Button)" type="Enum" key="$(Button)_mouse_action">
+ <parameter name="Button" type="Enum">
+ <values>
+ <value>right</value>
+ <value>mid</value>
+ <value>left</value>
+ </values>
+ </parameter>
+ <label>Mouse actions.</label>
+ <choices>
+ <choice name="Encrypt"/>
+ <choice name="Decrypt"/>
+ <choice name="CrashNBurn"/>
+ <choice name="PumpNDump"/>
+ </choices>
+ <default param="right">Decrypt</default>
+ <default param="mid">Encrypt</default>
+ <default param="left">PumpNDump</default>
+ </entry>
+ <entry name="FooBar" key="foo bar" type="String"/>
+ <entry name="Age" type="Int">
+ <default>35</default>
+ <min>8</min>
+ <max>88</max>
+ </entry>
+ </group>
+
+</kcfg>
diff --git a/tdecore/kconfig_compiler/tests/test5.kcfgc b/tdecore/kconfig_compiler/tests/test5.kcfgc
new file mode 100644
index 000000000..663005e5e
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test5.kcfgc
@@ -0,0 +1,11 @@
+# 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
new file mode 100644
index 000000000..57ad5189d
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test5main.cpp
@@ -0,0 +1,30 @@
+/*
+Copyright (c) 2004 Waldo Bastian <[email protected]>
+
+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*[] )
+{
+ KInstance 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
new file mode 100644
index 000000000..2b8a71d50
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test6.cpp.ref
@@ -0,0 +1,31 @@
+// 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 )
+ : KConfigSkeleton( TQString::tqfromLatin1( "test4rc" ) )
+ , mParamNumber(Number)
+{
+ setCurrentGroup( TQString::tqfromLatin1( "Foo" ) );
+
+ KConfigSkeleton::ItemColor *itemColor;
+ itemColor = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #%1" ).arg( mParamNumber ), mColor, TQColor( "red" ) );
+ addItem( itemColor, TQString::tqfromLatin1( "Color" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "Bar%1" ).arg( mParamNumber ) );
+
+ KConfigSkeleton::ItemString *itemFooBar;
+ itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "foo bar" ), mFooBar );
+ addItem( itemFooBar, TQString::tqfromLatin1( "FooBar" ) );
+ KConfigSkeleton::ItemInt *itemAge;
+ itemAge = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Age" ), mAge, 35 );
+ itemAge->setMinValue(8);
+ itemAge->setMaxValue(88);
+ addItem( itemAge, TQString::tqfromLatin1( "Age" ) );
+}
+
+Test6::~Test6()
+{
+}
+
diff --git a/tdecore/kconfig_compiler/tests/test6.h.ref b/tdecore/kconfig_compiler/tests/test6.h.ref
new file mode 100644
index 000000000..18615da38
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test6.h.ref
@@ -0,0 +1,93 @@
+// 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 <kconfigskeleton.h>
+#include <kdebug.h>
+
+class Test6 : public KConfigSkeleton
+{
+ public:
+
+ Test6( const TQString & Number );
+ ~Test6();
+
+ /**
+ Set Block colors.
+ */
+ void setColor( const TQColor & v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "Color" ) ))
+ mColor = v;
+ }
+
+ /**
+ Get Block colors.
+ */
+ TQColor color() const
+ {
+ return mColor;
+ }
+
+ /**
+ Set foo bar
+ */
+ void setFooBar( const TQString & v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "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::tqfromLatin1( "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
new file mode 100644
index 000000000..e59fa88f3
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test6.kcfg
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name="test4rc">
+ <parameter name="Number" type="String"/>
+ </kcfgfile>
+
+ <group name="Foo">
+ <entry name="Color" type="Color" key="color #$(Number)">
+ <label>Block colors.</label>
+ <default>red</default>
+ </entry>
+ </group>
+ <group name="Bar$(Number)">
+ <entry name="FooBar" key="foo bar" type="String"/>
+ <entry name="Age" type="Int">
+ <default>35</default>
+ <min>8</min>
+ <max>88</max>
+ </entry>
+ </group>
+
+</kcfg>
diff --git a/tdecore/kconfig_compiler/tests/test6.kcfgc b/tdecore/kconfig_compiler/tests/test6.kcfgc
new file mode 100644
index 000000000..b69dc152d
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test6.kcfgc
@@ -0,0 +1,11 @@
+# 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
new file mode 100644
index 000000000..27dff57ff
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test6main.cpp
@@ -0,0 +1,30 @@
+/*
+Copyright (c) 2004 Waldo Bastian <[email protected]>
+
+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*[] )
+{
+ KInstance 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
new file mode 100644
index 000000000..dab0ae27d
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test7.cpp.ref
@@ -0,0 +1,31 @@
+// 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 )
+ : KConfigSkeleton( TQString::tqfromLatin1( "test7rc" ) )
+ , mParamNumber(Number)
+{
+ setCurrentGroup( TQString::tqfromLatin1( "Foo" ) );
+
+ KConfigSkeleton::ItemColor *itemColor;
+ itemColor = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "color #%1" ).arg( mParamNumber ), mColor, TQColor( "red" ) );
+ addItem( itemColor, TQString::tqfromLatin1( "Color" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "Bar%1" ).arg( mParamNumber ) );
+
+ KConfigSkeleton::ItemString *itemFooBar;
+ itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "foo bar" ), mFooBar );
+ addItem( itemFooBar, TQString::tqfromLatin1( "FooBar" ) );
+ KConfigSkeleton::ItemInt *itemAge;
+ itemAge = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Age" ), mAge, 35 );
+ itemAge->setMinValue(8);
+ itemAge->setMaxValue(88);
+ addItem( itemAge, TQString::tqfromLatin1( "Age" ) );
+}
+
+Test7::~Test7()
+{
+}
+
diff --git a/tdecore/kconfig_compiler/tests/test7.h.ref b/tdecore/kconfig_compiler/tests/test7.h.ref
new file mode 100644
index 000000000..f67bc30cb
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test7.h.ref
@@ -0,0 +1,93 @@
+// 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 <kconfigskeleton.h>
+#include <kdebug.h>
+
+class Test7 : public KConfigSkeleton
+{
+ public:
+
+ Test7( int Number );
+ ~Test7();
+
+ /**
+ Set Block colors.
+ */
+ void setColor( const TQColor & v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "Color" ) ))
+ mColor = v;
+ }
+
+ /**
+ Get Block colors.
+ */
+ TQColor color() const
+ {
+ return mColor;
+ }
+
+ /**
+ Set foo bar
+ */
+ void setFooBar( const TQString & v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "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::tqfromLatin1( "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
new file mode 100644
index 000000000..0a7fd3272
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test7.kcfg
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name="test7rc">
+ <parameter name="Number" type="Int"/>
+ </kcfgfile>
+
+ <group name="Foo">
+ <entry name="Color" type="Color" key="color #$(Number)">
+ <label>Block colors.</label>
+ <default>red</default>
+ </entry>
+ </group>
+ <group name="Bar$(Number)">
+ <entry name="FooBar" key="foo bar" type="String"/>
+ <entry name="Age" type="Int">
+ <default>35</default>
+ <min>8</min>
+ <max>88</max>
+ </entry>
+ </group>
+
+</kcfg>
diff --git a/tdecore/kconfig_compiler/tests/test7.kcfgc b/tdecore/kconfig_compiler/tests/test7.kcfgc
new file mode 100644
index 000000000..9a6c40954
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test7.kcfgc
@@ -0,0 +1,11 @@
+# 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
new file mode 100644
index 000000000..9c1ad1931
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test7main.cpp
@@ -0,0 +1,30 @@
+/*
+Copyright (c) 2004 Waldo Bastian <[email protected]>
+
+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*[] )
+{
+ KInstance 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
new file mode 100644
index 000000000..8d8925c57
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test8a.cpp.ref
@@ -0,0 +1,22 @@
+// 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 )
+ : KConfigSkeleton( config )
+{
+ setCurrentGroup( TQString::tqfromLatin1( "Group" ) );
+
+ KConfigSkeleton::ItemFont *itemFont;
+ itemFont = new KConfigSkeleton::ItemFont( currentGroup(), TQString::tqfromLatin1( "Font" ), mFont, KGlobalSettings::generalFont() );
+ addItem( itemFont, TQString::tqfromLatin1( "Font" ) );
+ KConfigSkeleton::ItemFont *itemTitleFont;
+ itemTitleFont = new KConfigSkeleton::ItemFont( currentGroup(), TQString::tqfromLatin1( "TitleFont" ), mTitleFont, KGlobalSettings::windowTitleFont() );
+ addItem( itemTitleFont, TQString::tqfromLatin1( "TitleFont" ) );
+}
+
+Test8a::~Test8a()
+{
+}
+
diff --git a/tdecore/kconfig_compiler/tests/test8a.h.ref b/tdecore/kconfig_compiler/tests/test8a.h.ref
new file mode 100644
index 000000000..a1ac4de64
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test8a.h.ref
@@ -0,0 +1,61 @@
+// 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 <kglobal.h>
+#include <kconfigskeleton.h>
+#include <kdebug.h>
+
+class Test8a : public KConfigSkeleton
+{
+ public:
+
+ Test8a( KSharedConfig::Ptr config = KGlobal::sharedConfig() );
+ ~Test8a();
+
+ /**
+ Set Font
+ */
+ void setFont( const TQFont & v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "Font" ) ))
+ mFont = v;
+ }
+
+ /**
+ Get Font
+ */
+ TQFont font() const
+ {
+ return mFont;
+ }
+
+ /**
+ Set TitleFont
+ */
+ void setTitleFont( const TQFont & v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "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
new file mode 100644
index 000000000..5ee87199f
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test8a.kcfg
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile arg="true"/>
+
+ <group name="Group">
+ <entry name="Font" type="Font">
+ <default code="true">KGlobalSettings::generalFont()</default>
+ </entry>
+
+ <entry name="TitleFont" type="Font">
+ <default code="true">KGlobalSettings::windowTitleFont()</default>
+ </entry>
+ </group>
+</kcfg>
diff --git a/tdecore/kconfig_compiler/tests/test8a.kcfgc b/tdecore/kconfig_compiler/tests/test8a.kcfgc
new file mode 100644
index 000000000..5f63c31c2
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test8a.kcfgc
@@ -0,0 +1,3 @@
+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
new file mode 100644
index 000000000..566902399
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test8b.cpp.ref
@@ -0,0 +1,46 @@
+// This file is generated by kconfig_compiler from test8b.kcfg.
+// All changes you do to this file will be lost.
+
+#include "test8b.h"
+
+#include <kstaticdeleter.h>
+
+Test8b *Test8b::mSelf = 0;
+static KStaticDeleter<Test8b> staticTest8bDeleter;
+
+Test8b *Test8b::self()
+{
+ if ( !mSelf ) {
+ staticTest8bDeleter.setObject( mSelf, new Test8b() );
+ mSelf->readConfig();
+ }
+
+ return mSelf;
+}
+
+Test8b::Test8b( )
+ : Test8a()
+{
+ mSelf = this;
+ setCurrentGroup( TQString::tqfromLatin1( "Group8b1" ) );
+
+ KConfigSkeleton::ItemUInt *itemSomething;
+ itemSomething = new KConfigSkeleton::ItemUInt( currentGroup(), TQString::tqfromLatin1( "Something" ), mSomething, 60 );
+ addItem( itemSomething, TQString::tqfromLatin1( "Something" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "Group8b2" ) );
+
+ KConfigSkeleton::ItemBool *itemFooBoo;
+ itemFooBoo = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "FooBoo" ), mFooBoo, false );
+ addItem( itemFooBoo, TQString::tqfromLatin1( "FooBoo" ) );
+ KConfigSkeleton::ItemUInt *itemPort;
+ itemPort = new KConfigSkeleton::ItemUInt( currentGroup(), TQString::tqfromLatin1( "Port" ), mPort, 1000 );
+ addItem( itemPort, TQString::tqfromLatin1( "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
new file mode 100644
index 000000000..dfc9089e3
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test8b.h.ref
@@ -0,0 +1,96 @@
+// 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 <test8a.h>
+
+#include <kconfigskeleton.h>
+#include <kdebug.h>
+
+class Test8b : public Test8a
+{
+ public:
+
+ static Test8b *self();
+ ~Test8b();
+
+ /**
+ Set Something
+ */
+ static
+ void setSomething( uint v )
+ {
+ if (!self()->isImmutable( TQString::tqfromLatin1( "Something" ) ))
+ self()->mSomething = v;
+ }
+
+ /**
+ Get Something
+ */
+ static
+ uint something()
+ {
+ return self()->mSomething;
+ }
+
+ /**
+ Set FooBoo
+ */
+ static
+ void setFooBoo( bool v )
+ {
+ if (!self()->isImmutable( TQString::tqfromLatin1( "FooBoo" ) ))
+ self()->mFooBoo = v;
+ }
+
+ /**
+ Get FooBoo
+ */
+ static
+ bool fooBoo()
+ {
+ return self()->mFooBoo;
+ }
+
+ /**
+ Set Port
+ */
+ static
+ void setPort( uint v )
+ {
+ if (!self()->isImmutable( TQString::tqfromLatin1( "Port" ) ))
+ self()->mPort = v;
+ }
+
+ /**
+ Get Port
+ */
+ static
+ uint port()
+ {
+ return self()->mPort;
+ }
+
+ static
+ void writeConfig()
+ {
+ static_cast<KConfigSkeleton*>(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
new file mode 100644
index 000000000..3e203a155
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test8b.kcfg
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <group name="Group8b1">
+ <entry name="Something" type="UInt">
+ <default>60</default>
+ </entry>
+ </group>
+
+ <group name="Group8b2">
+ <entry name="FooBoo" type="Bool">
+ <default>false</default>
+ </entry>
+
+ <entry name="Port" type="UInt">
+ <default>1000</default>
+ </entry>
+ </group>
+</kcfg>
diff --git a/tdecore/kconfig_compiler/tests/test8b.kcfgc b/tdecore/kconfig_compiler/tests/test8b.kcfgc
new file mode 100644
index 000000000..7be055203
--- /dev/null
+++ b/tdecore/kconfig_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/kconfig_compiler/tests/test8main.cpp b/tdecore/kconfig_compiler/tests/test8main.cpp
new file mode 100644
index 000000000..b3c242f68
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test8main.cpp
@@ -0,0 +1,34 @@
+/*
+Copyright (c) 2005 Michael Brade <[email protected]>
+
+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*[] )
+{
+ KInstance 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
new file mode 100644
index 000000000..606f21ed1
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test9.cpp.ref
@@ -0,0 +1,35 @@
+// 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 )
+ : KConfigSkeleton( TQString::tqfromLatin1( "examplerc" ) )
+ , mParamtransport(transport)
+ , mParamfolder(folder)
+{
+ setCurrentGroup( TQString::tqfromLatin1( "MyOptionsXX" ) );
+
+ TQStringList defaultMyStringList;
+ defaultMyStringList.append( TQString::fromUtf8( "up" ) );
+ defaultMyStringList.append( TQString::fromUtf8( "down" ) );
+
+ KConfigSkeleton::ItemStringList *itemMyStringList;
+ itemMyStringList = new KConfigSkeleton::ItemStringList( currentGroup(), TQString::tqfromLatin1( "MyStringList" ), mMyStringList, defaultMyStringList );
+ addItem( itemMyStringList, TQString::tqfromLatin1( "MyStringList" ) );
+ TQStringList defaultMyPathList;
+ defaultMyPathList.append( TQString::fromUtf8( "/home" ) );
+ defaultMyPathList.append( TQString::fromUtf8( "~" ) );
+
+ KConfigSkeleton::ItemPathList *itemMyPathList;
+ itemMyPathList = new KConfigSkeleton::ItemPathList( currentGroup(), TQString::tqfromLatin1( "MyPathList" ), mMyPathList, defaultMyPathList );
+ addItem( itemMyPathList, TQString::tqfromLatin1( "MyPathList" ) );
+ KConfigSkeleton::ItemPathList *itemMyPathsList2;
+ itemMyPathsList2 = new KConfigSkeleton::ItemPathList( currentGroup(), TQString::tqfromLatin1( "MyPathsList2" ), mMyPathsList2, TQStringList(TQString::tqfromLatin1("/usr/bin")) += TQDir::homeDirPath() );
+ addItem( itemMyPathsList2, TQString::tqfromLatin1( "MyPathsList2" ) );
+}
+
+Test9::~Test9()
+{
+}
+
diff --git a/tdecore/kconfig_compiler/tests/test9.h.ref b/tdecore/kconfig_compiler/tests/test9.h.ref
new file mode 100644
index 000000000..0476c8a19
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test9.h.ref
@@ -0,0 +1,82 @@
+// 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 <kconfigskeleton.h>
+#include <kdebug.h>
+
+#include <tqdir.h>
+class Test9 : public KConfigSkeleton
+{
+ public:
+
+ Test9( const TQString & transport, const TQString & folder );
+ ~Test9();
+
+ /**
+ Set MyStringList
+ */
+ void setMyStringList( const TQStringList & v )
+ {
+ if (!isImmutable( TQString::tqfromLatin1( "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::tqfromLatin1( "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::tqfromLatin1( "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
new file mode 100644
index 000000000..b7495e2b6
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test9.kcfg
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <include>qdir.h</include>
+ <kcfgfile name="examplerc">
+ <parameter name="transport" />
+ <parameter name="folder" />
+ </kcfgfile>
+ <group name="MyOptionsXX">
+ <entry name="MyStringList" type="StringList">
+ <default>up,down</default>
+ </entry>
+ <entry name="MyPathList" type="PathList">
+ <label>This is a list of paths</label>
+ <default>/home,~</default>
+ </entry>
+ <entry name="MyPathsList2" type="PathList">
+ <label>This is an additional test for PathList</label>
+ <default code="true">QStringList(QString::fromLatin1("/usr/bin")) += QDir::homeDirPath()</default>
+ </entry>
+ </group>
+</kcfg>
diff --git a/tdecore/kconfig_compiler/tests/test9.kcfgc b/tdecore/kconfig_compiler/tests/test9.kcfgc
new file mode 100644
index 000000000..8f124fc25
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test9.kcfgc
@@ -0,0 +1,18 @@
+# Code generation options for kconfig_compiler
+ClassName=Test9
+#
+# Singleton=false
+#
+# Inherits=KConfigSkeleton
+#
+# 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
new file mode 100644
index 000000000..796ec0001
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test9main.cpp
@@ -0,0 +1,43 @@
+/*
+Copyright (c) 2005 Helge Deller <[email protected]>
+
+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 <kdebug.h>
+#include <tqdir.h>
+
+int main( int, char*[] )
+{
+ KInstance 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::tqfromLatin1("/.kde");
+ 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
new file mode 100644
index 000000000..00e933564
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test_dpointer.cpp.ref
@@ -0,0 +1,344 @@
+// 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 <klocale.h>
+
+#include <kstaticdeleter.h>
+
+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
+ KConfigSkeleton::ItemBool *autoSaveItem;
+ KConfigSkeleton::ItemInt *autoSaveIntervalItem;
+ KConfigSkeleton::ItemBool *confirmItem;
+ KConfigSkeleton::ItemString *archiveFileItem;
+ KConfigSkeleton::ItemEnum *destinationItem;
+ KConfigSkeleton::ItemInt *hourSizeItem;
+ KConfigSkeleton::ItemBool *selectionStartsEditorItem;
+ KConfigSkeleton::ItemStringList *selectedPluginsItem;
+ KConfigSkeleton::ItemColor *highlightColorItem;
+ KConfigSkeleton::ItemColor *agendaBgColorItem;
+ KConfigSkeleton::ItemFont *timeBarFontItem;
+};
+
+TestDPointer *TestDPointer::mSelf = 0;
+static KStaticDeleter<TestDPointer> staticTestDPointerDeleter;
+
+TestDPointer *TestDPointer::self()
+{
+ if ( !mSelf ) {
+ staticTestDPointerDeleter.setObject( mSelf, new TestDPointer() );
+ mSelf->readConfig();
+ }
+
+ return mSelf;
+}
+
+TestDPointer::TestDPointer( )
+ : KConfigSkeleton( TQString::tqfromLatin1( "korganizerrc" ) )
+{
+ d = new TestDPointerPrivate;
+ mSelf = this;
+ setCurrentGroup( TQString::tqfromLatin1( "General" ) );
+
+ d->autoSaveItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "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::tqfromLatin1( "AutoSave" ) );
+ d->autoSaveIntervalItem = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Auto Save Interval" ), d->autoSaveInterval, 10 );
+ d->autoSaveIntervalItem->setLabel( i18n("Auto Save Interval") );
+ addItem( d->autoSaveIntervalItem, TQString::tqfromLatin1( "AutoSaveInterval" ) );
+ d->confirmItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "Confirm Deletes" ), d->confirm, true );
+ d->confirmItem->setLabel( i18n("Confirm deletes") );
+ addItem( d->confirmItem, TQString::tqfromLatin1( "Confirm" ) );
+ d->archiveFileItem = new KConfigSkeleton::ItemString( currentGroup(), TQString::tqfromLatin1( "Archive File" ), d->archiveFile );
+ d->archiveFileItem->setLabel( i18n("Archive File") );
+ addItem( d->archiveFileItem, TQString::tqfromLatin1( "ArchiveFile" ) );
+ TQValueList<KConfigSkeleton::ItemEnum::Choice> valuesDestination;
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "standardDestination" );
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "askDestination" );
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "argl1" );
+ choice.label = i18n("Argl1 Label");
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "argl2" );
+ choice.whatsThis = i18n("Argl2 Whatsthis");
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = TQString::tqfromLatin1( "argl3" );
+ choice.label = i18n("Argl3 Label");
+ choice.whatsThis = i18n("Argl3 Whatsthis");
+ valuesDestination.append( choice );
+ }
+ d->destinationItem = new KConfigSkeleton::ItemEnum( currentGroup(), TQString::tqfromLatin1( "Destination" ), d->destination, valuesDestination, EnumDestination::standardDestination );
+ d->destinationItem->setLabel( i18n("New Events/Todos Should") );
+ addItem( d->destinationItem, TQString::tqfromLatin1( "Destination" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "Views" ) );
+
+ d->hourSizeItem = new KConfigSkeleton::ItemInt( currentGroup(), TQString::tqfromLatin1( "Hour Size" ), d->hourSize, 10 );
+ d->hourSizeItem->setLabel( i18n("Hour Size") );
+ addItem( d->hourSizeItem, TQString::tqfromLatin1( "HourSize" ) );
+ d->selectionStartsEditorItem = new KConfigSkeleton::ItemBool( currentGroup(), TQString::tqfromLatin1( "SelectionStartsEditor" ), d->selectionStartsEditor, false );
+ d->selectionStartsEditorItem->setLabel( i18n("Time range selection in agenda view starts event editor") );
+ addItem( d->selectionStartsEditorItem, TQString::tqfromLatin1( "SelectionStartsEditor" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "KOrganizer Plugins" ) );
+
+ TQStringList defaultSelectedPlugins;
+ defaultSelectedPlugins.append( TQString::fromUtf8( "holidays" ) );
+ defaultSelectedPlugins.append( TQString::fromUtf8( "webexport" ) );
+
+ d->selectedPluginsItem = new KConfigSkeleton::ItemStringList( currentGroup(), TQString::tqfromLatin1( "SelectedPlugins" ), d->selectedPlugins, defaultSelectedPlugins );
+ d->selectedPluginsItem->setLabel( i18n("SelectedPlugins") );
+ addItem( d->selectedPluginsItem, TQString::tqfromLatin1( "SelectedPlugins" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "Colors" ) );
+
+ d->highlightColorItem = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "Highlight Color" ), d->highlightColor, TQColor( 100, 100, 255 ) );
+ d->highlightColorItem->setLabel( i18n("Highlight color") );
+ addItem( d->highlightColorItem, TQString::tqfromLatin1( "HighlightColor" ) );
+ d->agendaBgColorItem = new KConfigSkeleton::ItemColor( currentGroup(), TQString::tqfromLatin1( "Agenda Background Color" ), d->agendaBgColor, TQColor( 255, 255, 255 ) );
+ d->agendaBgColorItem->setLabel( i18n("Agenda view background color") );
+ addItem( d->agendaBgColorItem, TQString::tqfromLatin1( "AgendaBgColor" ) );
+
+ setCurrentGroup( TQString::tqfromLatin1( "Fonts" ) );
+
+ d->timeBarFontItem = new KConfigSkeleton::ItemFont( currentGroup(), TQString::tqfromLatin1( "TimeBar Font" ), d->timeBarFont );
+ d->timeBarFontItem->setLabel( i18n("Time bar") );
+ addItem( d->timeBarFontItem, TQString::tqfromLatin1( "TimeBarFont" ) );
+}
+
+void TestDPointer::setAutoSave( bool v )
+{
+ if (!self()->isImmutable( TQString::tqfromLatin1( "AutoSave" ) ))
+ self()->d->autoSave = v;
+}
+
+bool TestDPointer::autoSave()
+{
+ return self()->d->autoSave;
+}
+
+
+KConfigSkeleton::ItemBool *TestDPointer::autoSaveItem()
+{
+ return d->autoSaveItem;
+}
+
+void TestDPointer::setAutoSaveInterval( int v )
+{
+ if (!self()->isImmutable( TQString::tqfromLatin1( "AutoSaveInterval" ) ))
+ self()->d->autoSaveInterval = v;
+}
+
+int TestDPointer::autoSaveInterval()
+{
+ return self()->d->autoSaveInterval;
+}
+
+
+KConfigSkeleton::ItemInt *TestDPointer::autoSaveIntervalItem()
+{
+ return d->autoSaveIntervalItem;
+}
+
+void TestDPointer::setConfirm( bool v )
+{
+ if (!self()->isImmutable( TQString::tqfromLatin1( "Confirm" ) ))
+ self()->d->confirm = v;
+}
+
+bool TestDPointer::confirm()
+{
+ return self()->d->confirm;
+}
+
+
+KConfigSkeleton::ItemBool *TestDPointer::confirmItem()
+{
+ return d->confirmItem;
+}
+
+void TestDPointer::setArchiveFile( const TQString & v )
+{
+ if (!self()->isImmutable( TQString::tqfromLatin1( "ArchiveFile" ) ))
+ self()->d->archiveFile = v;
+}
+
+TQString TestDPointer::archiveFile()
+{
+ return self()->d->archiveFile;
+}
+
+
+KConfigSkeleton::ItemString *TestDPointer::archiveFileItem()
+{
+ return d->archiveFileItem;
+}
+
+void TestDPointer::setDestination( int v )
+{
+ if (!self()->isImmutable( TQString::tqfromLatin1( "Destination" ) ))
+ self()->d->destination = v;
+}
+
+int TestDPointer::destination()
+{
+ return self()->d->destination;
+}
+
+
+KConfigSkeleton::ItemEnum *TestDPointer::destinationItem()
+{
+ return d->destinationItem;
+}
+
+void TestDPointer::setHourSize( int v )
+{
+ if (!self()->isImmutable( TQString::tqfromLatin1( "HourSize" ) ))
+ self()->d->hourSize = v;
+}
+
+int TestDPointer::hourSize()
+{
+ return self()->d->hourSize;
+}
+
+
+KConfigSkeleton::ItemInt *TestDPointer::hourSizeItem()
+{
+ return d->hourSizeItem;
+}
+
+void TestDPointer::setSelectionStartsEditor( bool v )
+{
+ if (!self()->isImmutable( TQString::tqfromLatin1( "SelectionStartsEditor" ) ))
+ self()->d->selectionStartsEditor = v;
+}
+
+bool TestDPointer::selectionStartsEditor()
+{
+ return self()->d->selectionStartsEditor;
+}
+
+
+KConfigSkeleton::ItemBool *TestDPointer::selectionStartsEditorItem()
+{
+ return d->selectionStartsEditorItem;
+}
+
+void TestDPointer::setSelectedPlugins( const TQStringList & v )
+{
+ if (!self()->isImmutable( TQString::tqfromLatin1( "SelectedPlugins" ) ))
+ self()->d->selectedPlugins = v;
+}
+
+TQStringList TestDPointer::selectedPlugins()
+{
+ return self()->d->selectedPlugins;
+}
+
+
+KConfigSkeleton::ItemStringList *TestDPointer::selectedPluginsItem()
+{
+ return d->selectedPluginsItem;
+}
+
+void TestDPointer::setHighlightColor( const TQColor & v )
+{
+ if (!self()->isImmutable( TQString::tqfromLatin1( "HighlightColor" ) ))
+ self()->d->highlightColor = v;
+}
+
+TQColor TestDPointer::highlightColor()
+{
+ return self()->d->highlightColor;
+}
+
+
+KConfigSkeleton::ItemColor *TestDPointer::highlightColorItem()
+{
+ return d->highlightColorItem;
+}
+
+void TestDPointer::setAgendaBgColor( const TQColor & v )
+{
+ if (!self()->isImmutable( TQString::tqfromLatin1( "AgendaBgColor" ) ))
+ self()->d->agendaBgColor = v;
+}
+
+TQColor TestDPointer::agendaBgColor()
+{
+ return self()->d->agendaBgColor;
+}
+
+
+KConfigSkeleton::ItemColor *TestDPointer::agendaBgColorItem()
+{
+ return d->agendaBgColorItem;
+}
+
+void TestDPointer::setTimeBarFont( const TQFont & v )
+{
+ if (!self()->isImmutable( TQString::tqfromLatin1( "TimeBarFont" ) ))
+ self()->d->timeBarFont = v;
+}
+
+TQFont TestDPointer::timeBarFont()
+{
+ return self()->d->timeBarFont;
+}
+
+
+KConfigSkeleton::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
new file mode 100644
index 000000000..81f281e83
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test_dpointer.h.ref
@@ -0,0 +1,224 @@
+// 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 <kconfigskeleton.h>
+#include <kdebug.h>
+
+class TestDPointerPrivate;
+
+class TestDPointer : public KConfigSkeleton
+{
+ 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<KConfigSkeleton*>(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
new file mode 100644
index 000000000..3b19e270e
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test_dpointer.kcfg
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name="korganizerrc"/>
+
+ <group name="General">
+ <entry type="Bool" key="Auto Save">
+ <label>Enable automatic saving of calendar</label>
+ <whatsthis>WhatsThis text for AutoSave option</whatsthis>
+ <default>false</default>
+ </entry>
+ <entry type="Int" key="Auto Save Interval">
+ <default>10</default>
+ </entry>
+ <entry type="Bool" key="Confirm Deletes" name="Confirm">
+ <label>Confirm deletes</label>
+ <default>true</default>
+ </entry>
+ <entry type="String" key="Archive File">
+ </entry>
+ <entry type="Enum" key="Destination" name="Destination">
+ <label>New Events/Todos Should</label>
+ <choices>
+ <choice name="standardDestination">
+ </choice>
+ <choice name="askDestination">
+ </choice>
+ <choice name="argl1">
+ <label>Argl1 Label</label>
+ </choice>
+ <choice name="argl2">
+ <whatsthis>Argl2 Whatsthis</whatsthis>
+ </choice>
+ <choice name="argl3">
+ <label>Argl3 Label</label>
+ <whatsthis>Argl3 Whatsthis</whatsthis>
+ </choice>
+ </choices>
+ <default>standardDestination</default>
+ </entry>
+ </group>
+
+ <group name="Views">
+ <entry type="Int" key="Hour Size">
+ <default>10</default>
+ </entry>
+ <entry type="Bool" name="SelectionStartsEditor">
+ <label>Time range selection in agenda view starts event editor</label>
+ <default>false</default>
+ </entry>
+ </group>
+
+ <group name="KOrganizer Plugins">
+ <entry type="StringList" name="SelectedPlugins">
+ <default>holidays,webexport</default>
+ </entry>
+ </group>
+
+ <group name="Colors">
+ <entry type="Color" key="Highlight Color">
+ <label>Highlight color</label>
+ <default>100, 100, 255</default>
+ </entry>
+ <entry type="Color" key="Agenda Background Color" name="AgendaBgColor">
+ <label>Agenda view background color</label>
+ <default>255, 255, 255</default>
+ </entry>
+ </group>
+
+ <group name="Fonts">
+ <entry type="Font" key="TimeBar Font">
+ <label>Time bar</label>
+ </entry>
+ </group>
+
+</kcfg>
diff --git a/tdecore/kconfig_compiler/tests/test_dpointer.kcfgc b/tdecore/kconfig_compiler/tests/test_dpointer.kcfgc
new file mode 100644
index 000000000..48baa376e
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test_dpointer.kcfgc
@@ -0,0 +1,11 @@
+# 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
new file mode 100644
index 000000000..a6c23c8fe
--- /dev/null
+++ b/tdecore/kconfig_compiler/tests/test_dpointer_main.cpp
@@ -0,0 +1,30 @@
+/*
+Copyright (c) 2005 Duncan Mac-Vicar P. <[email protected]>
+
+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*[] )
+{
+ KInstance i("test");
+ TestDPointer *t = TestDPointer::self();
+ delete t;
+}