summaryrefslogtreecommitdiffstats
path: root/kdecore/kconfig_compiler
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kdecore/kconfig_compiler
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdecore/kconfig_compiler')
-rw-r--r--kdecore/kconfig_compiler/Makefile.am18
-rw-r--r--kdecore/kconfig_compiler/README.dox255
-rw-r--r--kdecore/kconfig_compiler/TODO0
-rwxr-xr-xkdecore/kconfig_compiler/checkkcfg.pl83
-rw-r--r--kdecore/kconfig_compiler/example/Makefile.am27
-rw-r--r--kdecore/kconfig_compiler/example/autoexample.cpp64
-rw-r--r--kdecore/kconfig_compiler/example/example.cpp52
-rw-r--r--kdecore/kconfig_compiler/example/example.kcfg63
-rw-r--r--kdecore/kconfig_compiler/example/exampleprefs_base.kcfgc18
-rw-r--r--kdecore/kconfig_compiler/example/general_base.ui46
-rw-r--r--kdecore/kconfig_compiler/example/myoptions_base.ui35
-rw-r--r--kdecore/kconfig_compiler/kcfg.xsd192
-rw-r--r--kdecore/kconfig_compiler/kconfig_compiler.cpp1700
-rw-r--r--kdecore/kconfig_compiler/tests/Makefile.am134
-rw-r--r--kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp96
-rw-r--r--kdecore/kconfig_compiler/tests/kconfigcompiler_test.h35
-rw-r--r--kdecore/kconfig_compiler/tests/myprefs.h7
-rw-r--r--kdecore/kconfig_compiler/tests/test1.cpp.ref72
-rw-r--r--kdecore/kconfig_compiler/tests/test1.h.ref196
-rw-r--r--kdecore/kconfig_compiler/tests/test1.kcfg55
-rw-r--r--kdecore/kconfig_compiler/tests/test1.kcfgc18
-rw-r--r--kdecore/kconfig_compiler/tests/test1main.cpp29
-rw-r--r--kdecore/kconfig_compiler/tests/test2.cpp.ref98
-rw-r--r--kdecore/kconfig_compiler/tests/test2.h.ref333
-rw-r--r--kdecore/kconfig_compiler/tests/test2.kcfg78
-rw-r--r--kdecore/kconfig_compiler/tests/test2.kcfgc11
-rw-r--r--kdecore/kconfig_compiler/tests/test2main.cpp29
-rw-r--r--kdecore/kconfig_compiler/tests/test3.cpp.ref29
-rw-r--r--kdecore/kconfig_compiler/tests/test3.h.ref138
-rw-r--r--kdecore/kconfig_compiler/tests/test3.kcfg26
-rw-r--r--kdecore/kconfig_compiler/tests/test3.kcfgc12
-rw-r--r--kdecore/kconfig_compiler/tests/test3main.cpp29
-rw-r--r--kdecore/kconfig_compiler/tests/test4.cpp.ref82
-rw-r--r--kdecore/kconfig_compiler/tests/test4.h.ref135
-rw-r--r--kdecore/kconfig_compiler/tests/test4.kcfg42
-rw-r--r--kdecore/kconfig_compiler/tests/test4.kcfgc11
-rw-r--r--kdecore/kconfig_compiler/tests/test4main.cpp30
-rw-r--r--kdecore/kconfig_compiler/tests/test5.cpp.ref82
-rw-r--r--kdecore/kconfig_compiler/tests/test5.h.ref127
-rw-r--r--kdecore/kconfig_compiler/tests/test5.kcfg42
-rw-r--r--kdecore/kconfig_compiler/tests/test5.kcfgc11
-rw-r--r--kdecore/kconfig_compiler/tests/test5main.cpp30
-rw-r--r--kdecore/kconfig_compiler/tests/test6.cpp.ref31
-rw-r--r--kdecore/kconfig_compiler/tests/test6.h.ref93
-rw-r--r--kdecore/kconfig_compiler/tests/test6.kcfg25
-rw-r--r--kdecore/kconfig_compiler/tests/test6.kcfgc11
-rw-r--r--kdecore/kconfig_compiler/tests/test6main.cpp30
-rw-r--r--kdecore/kconfig_compiler/tests/test7.cpp.ref31
-rw-r--r--kdecore/kconfig_compiler/tests/test7.h.ref93
-rw-r--r--kdecore/kconfig_compiler/tests/test7.kcfg25
-rw-r--r--kdecore/kconfig_compiler/tests/test7.kcfgc11
-rw-r--r--kdecore/kconfig_compiler/tests/test7main.cpp30
-rw-r--r--kdecore/kconfig_compiler/tests/test8a.cpp.ref22
-rw-r--r--kdecore/kconfig_compiler/tests/test8a.h.ref61
-rw-r--r--kdecore/kconfig_compiler/tests/test8a.kcfg17
-rw-r--r--kdecore/kconfig_compiler/tests/test8a.kcfgc3
-rw-r--r--kdecore/kconfig_compiler/tests/test8b.cpp.ref46
-rw-r--r--kdecore/kconfig_compiler/tests/test8b.h.ref96
-rw-r--r--kdecore/kconfig_compiler/tests/test8b.kcfg21
-rw-r--r--kdecore/kconfig_compiler/tests/test8b.kcfgc6
-rw-r--r--kdecore/kconfig_compiler/tests/test8main.cpp34
-rw-r--r--kdecore/kconfig_compiler/tests/test9.cpp.ref35
-rw-r--r--kdecore/kconfig_compiler/tests/test9.h.ref82
-rw-r--r--kdecore/kconfig_compiler/tests/test9.kcfg24
-rw-r--r--kdecore/kconfig_compiler/tests/test9.kcfgc18
-rw-r--r--kdecore/kconfig_compiler/tests/test9main.cpp43
-rw-r--r--kdecore/kconfig_compiler/tests/test_dpointer.cpp.ref344
-rw-r--r--kdecore/kconfig_compiler/tests/test_dpointer.h.ref224
-rw-r--r--kdecore/kconfig_compiler/tests/test_dpointer.kcfg78
-rw-r--r--kdecore/kconfig_compiler/tests/test_dpointer.kcfgc11
-rw-r--r--kdecore/kconfig_compiler/tests/test_dpointer_main.cpp30
71 files changed, 6145 insertions, 0 deletions
diff --git a/kdecore/kconfig_compiler/Makefile.am b/kdecore/kconfig_compiler/Makefile.am
new file mode 100644
index 000000000..cfecd8408
--- /dev/null
+++ b/kdecore/kconfig_compiler/Makefile.am
@@ -0,0 +1,18 @@
+SUBDIRS = example tests
+
+AM_CPPFLAGS = -I$(top_srcdir)/kdecore -I$(top_srcdir) $(all_includes)
+
+bin_PROGRAMS = kconfig_compiler
+
+kconfig_compiler_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+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)/kdecore/kconfig_compiler/checkkcfg.pl \
+ $(top_srcdir)/kdecore/kconfig_compiler/tests/$$i; done
+
diff --git a/kdecore/kconfig_compiler/README.dox b/kdecore/kconfig_compiler/README.dox
new file mode 100644
index 000000000..36d9f988b
--- /dev/null
+++ b/kdecore/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
+<schumacher@kde.org> or Waldo Bastian <bastian@kde.org>
+*/
diff --git a/kdecore/kconfig_compiler/TODO b/kdecore/kconfig_compiler/TODO
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/kdecore/kconfig_compiler/TODO
diff --git a/kdecore/kconfig_compiler/checkkcfg.pl b/kdecore/kconfig_compiler/checkkcfg.pl
new file mode 100755
index 000000000..2eddbeee6
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/example/Makefile.am b/kdecore/kconfig_compiler/example/Makefile.am
new file mode 100644
index 000000000..730f7fcc3
--- /dev/null
+++ b/kdecore/kconfig_compiler/example/Makefile.am
@@ -0,0 +1,27 @@
+AM_CPPFLAGS = -I$(top_srcdir)/kdecore -I$(top_srcdir) $(all_includes)
+
+check_PROGRAMS = example # autoexample
+EXTRA_PROGRAMS = autoexample
+
+example_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+example_LDADD = $(LIB_KDECORE)
+example_SOURCES = example.cpp exampleprefs_base.cpp
+
+autoexample_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+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/kdecore/kconfig_compiler/example/autoexample.cpp b/kdecore/kconfig_compiler/example/autoexample.cpp
new file mode 100644
index 000000000..528c12457
--- /dev/null
+++ b/kdecore/kconfig_compiler/example/autoexample.cpp
@@ -0,0 +1,64 @@
+/*
+ This file is part of KDE.
+
+ Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "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 <qlabel.h>
+
+int main( int argc, char **argv )
+{
+ KAboutData aboutData( "example", I18N_NOOP("autoconfig example"), "0.1" );
+ aboutData.addAuthor( "Cornelius Schumacher", 0, "schumacher@kde.org" );
+
+ 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/kdecore/kconfig_compiler/example/example.cpp b/kdecore/kconfig_compiler/example/example.cpp
new file mode 100644
index 000000000..146d2460f
--- /dev/null
+++ b/kdecore/kconfig_compiler/example/example.cpp
@@ -0,0 +1,52 @@
+/*
+ This file is part of KDE.
+
+ Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "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, "schumacher@kde.org" );
+
+ 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/kdecore/kconfig_compiler/example/example.kcfg b/kdecore/kconfig_compiler/example/example.kcfg
new file mode 100644
index 000000000..076bfb644
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/example/exampleprefs_base.kcfgc b/kdecore/kconfig_compiler/example/exampleprefs_base.kcfgc
new file mode 100644
index 000000000..957ed9123
--- /dev/null
+++ b/kdecore/kconfig_compiler/example/exampleprefs_base.kcfgc
@@ -0,0 +1,18 @@
+# Code generation options for kconfig_compiler
+ClassName=ExamplePrefsBase
+#
+# Singleton=false
+#
+# Inherits=KConfigSkeleton
+#
+# IncludeFiles=libkdepim/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/kdecore/kconfig_compiler/example/general_base.ui b/kdecore/kconfig_compiler/example/general_base.ui
new file mode 100644
index 000000000..9b41370c7
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/example/myoptions_base.ui b/kdecore/kconfig_compiler/example/myoptions_base.ui
new file mode 100644
index 000000000..3c0c2e6cb
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/kcfg.xsd b/kdecore/kconfig_compiler/kcfg.xsd
new file mode 100644
index 000000000..97f716d62
--- /dev/null
+++ b/kdecore/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;schumacher@kde.org&gt;
+ Copyright (c) 2003 Waldo Bastian &lt;bastian@kde.org&gt;
+ Copyright (c) 2003 Zack Rusin &lt;zack@kde.org&gt;
+ Copyright (c) 2004 Frans Englich &lt;frans.englich@telia.com&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/kdecore/kconfig_compiler/kconfig_compiler.cpp b/kdecore/kconfig_compiler/kconfig_compiler.cpp
new file mode 100644
index 000000000..9c245e319
--- /dev/null
+++ b/kdecore/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 <schumacher@kde.org>
+ Copyright (c) 2003 Waldo Bastian <bastian@kde.org>
+ Copyright (c) 2003 Zack Rusin <zack@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qdom.h>
+#include <qregexp.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;
+QStringList allNames;
+QRegExp *validNameRegexp;
+QString This;
+QString Const;
+
+class CfgEntry
+{
+ public:
+ struct Choice
+ {
+ QString name;
+ QString label;
+ QString whatsThis;
+ };
+
+ CfgEntry( const QString &group, const QString &type, const QString &key,
+ const QString &name, const QString &label,
+ const QString &whatsThis, const QString &code,
+ const QString &defaultValue, const QValueList<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 QString &group ) { mGroup = group; }
+ QString group() const { return mGroup; }
+
+ void setType( const QString &type ) { mType = type; }
+ QString type() const { return mType; }
+
+ void setKey( const QString &key ) { mKey = key; }
+ QString key() const { return mKey; }
+
+ void setName( const QString &name ) { mName = name; }
+ QString name() const { return mName; }
+
+ void setLabel( const QString &label ) { mLabel = label; }
+ QString label() const { return mLabel; }
+
+ void setWhatsThis( const QString &whatsThis ) { mWhatsThis = whatsThis; }
+ QString whatsThis() const { return mWhatsThis; }
+
+ void setDefaultValue( const QString &d ) { mDefaultValue = d; }
+ QString defaultValue() const { return mDefaultValue; }
+
+ void setCode( const QString &d ) { mCode = d; }
+ QString code() const { return mCode; }
+
+ void setMinValue( const QString &d ) { mMin = d; }
+ QString minValue() const { return mMin; }
+
+ void setMaxValue( const QString &d ) { mMax = d; }
+ QString maxValue() const { return mMax; }
+
+ void setParam( const QString &d ) { mParam = d; }
+ QString param() const { return mParam; }
+
+ void setParamName( const QString &d ) { mParamName = d; }
+ QString paramName() const { return mParamName; }
+
+ void setParamType( const QString &d ) { mParamType = d; }
+ QString paramType() const { return mParamType; }
+
+ void setChoices( const QValueList<Choice> &d ) { mChoices = d; }
+ QValueList<Choice> choices() const { return mChoices; }
+
+ void setParamValues( const QStringList &d ) { mParamValues = d; }
+ QStringList paramValues() const { return mParamValues; }
+
+ void setParamDefaultValues( const QStringList &d ) { mParamDefaultValues = d; }
+ QString 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:
+ QString mGroup;
+ QString mType;
+ QString mKey;
+ QString mName;
+ QString mLabel;
+ QString mWhatsThis;
+ QString mCode;
+ QString mDefaultValue;
+ QString mParam;
+ QString mParamName;
+ QString mParamType;
+ QValueList<Choice> mChoices;
+ QStringList mParamValues;
+ QStringList mParamDefaultValues;
+ int mParamMax;
+ bool mHidden;
+ QString mMin;
+ QString mMax;
+};
+
+class Param {
+public:
+ QString name;
+ QString type;
+};
+
+// returns the name of an member variable
+// use itemPath to know the full path
+// like using d-> in case of dpointer
+static QString varName(const QString &n)
+{
+ QString result;
+ if ( !dpointer ) {
+ result = "m"+n;
+ result[1] = result[1].upper();
+ }
+ else {
+ result = n;
+ result[0] = result[0].lower();
+ }
+ return result;
+}
+
+static QString varPath(const QString &n)
+{
+ QString result;
+ if ( dpointer ) {
+ result = "d->"+varName(n);
+ }
+ else {
+ result = varName(n);
+ }
+ return result;
+}
+
+static QString enumName(const QString &n)
+{
+ QString result = "Enum"+n;
+ result[4] = result[4].upper();
+ return result;
+}
+
+static QString setFunction(const QString &n, const QString &className = QString::null)
+{
+ QString result = "set"+n;
+ result[3] = result[3].upper();
+
+ if ( !className.isEmpty() )
+ result = className + "::" + result;
+ return result;
+}
+
+
+static QString getFunction(const QString &n, const QString &className = QString::null)
+{
+ QString result = n;
+ result[0] = result[0].lower();
+
+ if ( !className.isEmpty() )
+ result = className + "::" + result;
+ return result;
+}
+
+
+static void addQuotes( QString &s )
+{
+ if ( s.left( 1 ) != "\"" ) s.prepend( "\"" );
+ if ( s.right( 1 ) != "\"" ) s.append( "\"" );
+}
+
+static QString quoteString( const QString &s )
+{
+ QString r = s;
+ r.replace( "\\", "\\\\" );
+ r.replace( "\"", "\\\"" );
+ r.replace( "\r", "" );
+ r.replace( "\n", "\\n\"\n\"" );
+ return "\"" + r + "\"";
+}
+
+static QString literalString( const QString &s )
+{
+ bool isAscii = true;
+ for(int i = s.length(); i--;)
+ if (s[i].unicode() > 127) isAscii = false;
+
+ if (isAscii)
+ return "QString::fromLatin1( " + quoteString(s) + " )";
+ else
+ return "QString::fromUtf8( " + quoteString(s) + " )";
+}
+
+static QString dumpNode(const QDomNode &node)
+{
+ QString msg;
+ QTextStream s(&msg, IO_WriteOnly );
+ node.save(s, 0);
+
+ msg = msg.simplifyWhiteSpace();
+ if (msg.length() > 40)
+ return msg.left(37)+"...";
+ return msg;
+}
+
+static QString filenameOnly(QString path)
+{
+ int i = path.findRev('/');
+ if (i >= 0)
+ return path.mid(i+1);
+ return path;
+}
+
+static void preProcessDefault( QString &defaultValue, const QString &name,
+ const QString &type,
+ const QValueList<CfgEntry::Choice> &choices,
+ QString &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() ) {
+ QTextStream cpp( &code, IO_WriteOnly | IO_Append );
+ if (!code.isEmpty())
+ cpp << endl;
+
+ cpp << " QStringList default" << name << ";" << endl;
+ QStringList defaults = QStringList::split( ",", defaultValue );
+ QStringList::ConstIterator it;
+ for( it = defaults.begin(); it != defaults.end(); ++it ) {
+ cpp << " default" << name << ".append( QString::fromUtf8( \"" << *it << "\" ) );"
+ << endl;
+ }
+ defaultValue = "default" + name;
+
+ } else if ( type == "Color" && !defaultValue.isEmpty() ) {
+ QRegExp colorRe("\\d+,\\s*\\d+,\\s*\\d+");
+ if (colorRe.exactMatch(defaultValue))
+ {
+ defaultValue = "QColor( " + defaultValue + " )";
+ }
+ else
+ {
+ defaultValue = "QColor( \"" + defaultValue + "\" )";
+ }
+
+ } else if ( type == "Enum" ) {
+ if ( !globalEnums ) {
+ QValueList<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" ) {
+ QTextStream cpp( &code, IO_WriteOnly | IO_Append );
+ if (!code.isEmpty())
+ cpp << endl;
+
+ cpp << " QValueList<int> default" << name << ";" << endl;
+ QStringList defaults = QStringList::split( ",", defaultValue );
+ QStringList::ConstIterator it;
+ for( it = defaults.begin(); it != defaults.end(); ++it ) {
+ cpp << " default" << name << ".append( " << *it << " );"
+ << endl;
+ }
+ defaultValue = "default" + name;
+ }
+}
+
+
+CfgEntry *parseEntry( const QString &group, const QDomElement &element )
+{
+ bool defaultCode = false;
+ QString type = element.attribute( "type" );
+ QString name = element.attribute( "name" );
+ QString key = element.attribute( "key" );
+ QString hidden = element.attribute( "hidden" );
+ QString label;
+ QString whatsThis;
+ QString defaultValue;
+ QString code;
+ QString param;
+ QString paramName;
+ QString paramType;
+ QValueList<CfgEntry::Choice> choices;
+ QStringList paramValues;
+ QStringList paramDefaultValues;
+ QString minValue;
+ QString maxValue;
+ int paramMax = 0;
+
+ QDomNode n;
+ for ( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) {
+ QDomElement e = n.toElement();
+ QString 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")
+ {
+ QDomNode n2;
+ for ( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) {
+ QDomElement e2 = n2.toElement();
+ if (e2.tagName() == "values")
+ {
+ QDomNode n3;
+ for ( n3 = e2.firstChild(); !n3.isNull(); n3 = n3.nextSibling() ) {
+ QDomElement 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" ) {
+ QDomNode n2;
+ for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) {
+ QDomElement e2 = n2.toElement();
+ if ( e2.tagName() == "choice" ) {
+ QDomNode 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() ) {
+ QDomElement 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( " ", QString::null );
+ } 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+")", QString::null);
+ // Lookup defaults for indexed entries
+ for(int i = 0; i <= paramMax; i++)
+ {
+ paramDefaultValues.append(QString::null);
+ }
+
+ QDomNode n;
+ for ( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) {
+ QDomElement e = n.toElement();
+ QString tag = e.tagName();
+ if ( tag == "default" )
+ {
+ QString 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;
+ }
+
+ QString 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.
+*/
+QString param( const QString &type )
+{
+ if ( type == "String" ) return "const QString &";
+ else if ( type == "StringList" ) return "const QStringList &";
+ else if ( type == "Font" ) return "const QFont &";
+ else if ( type == "Rect" ) return "const QRect &";
+ else if ( type == "Size" ) return "const QSize &";
+ else if ( type == "Color" ) return "const QColor &";
+ else if ( type == "Point" ) return "const QPoint &";
+ 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 QDateTime &";
+ else if ( type == "Int64" ) return "Q_INT64";
+ else if ( type == "UInt64" ) return "Q_UINT64";
+ else if ( type == "IntList" ) return "const QValueList<int> &";
+ else if ( type == "Enum" ) return "int";
+ else if ( type == "Path" ) return "const QString &";
+ else if ( type == "PathList" ) return "const QStringList &";
+ else if ( type == "Password" ) return "const QString &";
+ else {
+ kdError() <<"kconfig_compiler does not support type \""<< type <<"\""<<endl;
+ return "QString"; //For now, but an assert would be better
+ }
+}
+
+/**
+ Actual C++ storage type for given type.
+*/
+QString cppType( const QString &type )
+{
+ if ( type == "String" ) return "QString";
+ else if ( type == "StringList" ) return "QStringList";
+ else if ( type == "Font" ) return "QFont";
+ else if ( type == "Rect" ) return "QRect";
+ else if ( type == "Size" ) return "QSize";
+ else if ( type == "Color" ) return "QColor";
+ else if ( type == "Point" ) return "QPoint";
+ 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 "QDateTime";
+ else if ( type == "Int64" ) return "Q_INT64";
+ else if ( type == "UInt64" ) return "Q_UINT64";
+ else if ( type == "IntList" ) return "QValueList<int>";
+ else if ( type == "Enum" ) return "int";
+ else if ( type == "Path" ) return "QString";
+ else if ( type == "PathList" ) return "QStringList";
+ else if ( type == "Password" ) return "QString";
+ else {
+ kdError()<<"kconfig_compiler does not support type \""<< type <<"\""<<endl;
+ return "QString"; //For now, but an assert would be better
+ }
+}
+
+QString defaultValue( const QString &type )
+{
+ if ( type == "String" ) return "\"\""; // Use empty string, not null string!
+ else if ( type == "StringList" ) return "QStringList()";
+ else if ( type == "Font" ) return "KGlobalSettings::generalFont()";
+ else if ( type == "Rect" ) return "QRect()";
+ else if ( type == "Size" ) return "QSize()";
+ else if ( type == "Color" ) return "QColor(128, 128, 128)";
+ else if ( type == "Point" ) return "QPoint()";
+ 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 "QDateTime()";
+ else if ( type == "Int64" ) return "0";
+ else if ( type == "UInt64" ) return "0";
+ else if ( type == "IntList" ) return "QValueList<int>()";
+ else if ( type == "Enum" ) return "0";
+ else if ( type == "Path" ) return "\"\""; // Use empty string, not null string!
+ else if ( type == "PathList" ) return "QStringList()";
+ else if ( type == "Password" ) return "\"\""; // Use empty string, not null string!
+ else {
+ kdWarning()<<"Error, kconfig_compiler doesn't support the \""<< type <<"\" type!"<<endl;
+ return "QString"; //For now, but an assert would be better
+ }
+}
+
+QString itemType( const QString &type )
+{
+ QString t;
+
+ t = type;
+ t.replace( 0, 1, t.left( 1 ).upper() );
+
+ return t;
+}
+
+static QString itemDeclaration(const CfgEntry *e)
+{
+ if (itemAccessors)
+ return QString::null;
+
+ QString fCap = e->name();
+ fCap[0] = fCap[0].upper();
+ return " KConfigSkeleton::Item"+itemType( e->type() ) +
+ " *item" + fCap +
+ ( (!e->param().isEmpty())?(QString("[%1]").arg(e->paramMax()+1)) : QString::null) +
+ ";\n";
+}
+
+// returns the name of an item variable
+// use itemPath to know the full path
+// like using d-> in case of dpointer
+static QString itemVar(const CfgEntry *e)
+{
+ QString 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 QString itemPath(const CfgEntry *e)
+{
+ QString result;
+ if ( dpointer ) {
+ result = "d->"+itemVar(e);
+ }
+ else {
+ result = itemVar(e);
+ }
+ return result;
+}
+
+QString newItem( const QString &type, const QString &name, const QString &key,
+ const QString &defaultValue, const QString &param = QString::null)
+{
+ QString 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;
+}
+
+QString paramString(const QString &s, const CfgEntry *e, int i)
+{
+ QString result = s;
+ QString needle = "$("+e->param()+")";
+ if (result.contains(needle))
+ {
+ QString tmp;
+ if (e->paramType() == "Enum")
+ {
+ tmp = e->paramValues()[i];
+ }
+ else
+ {
+ tmp = QString::number(i);
+ }
+
+ result.replace(needle, tmp);
+ }
+ return result;
+}
+
+QString paramString(const QString &group, const QValueList<Param> &parameters)
+{
+ QString paramString = group;
+ QString arguments;
+ int i = 1;
+ for (QValueList<Param>::ConstIterator it = parameters.begin();
+ it != parameters.end(); ++it)
+ {
+ if (paramString.contains("$("+(*it).name+")"))
+ {
+ QString tmp;
+ tmp.sprintf("%%%d", i++);
+ paramString.replace("$("+(*it).name+")", tmp);
+ arguments += ".arg( mParam"+(*it).name+" )";
+ }
+ }
+ if (arguments.isEmpty())
+ return "QString::fromLatin1( \""+group+"\" )";
+
+ return "QString::fromLatin1( \""+paramString+"\" )"+arguments;
+}
+
+/* int i is the value of the parameter */
+QString userTextsFunctions( CfgEntry *e, QString itemVarStr=QString::null, QString i=QString::null )
+{
+ QString 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
+QString memberAccessorBody( CfgEntry *e )
+{
+ QString result;
+ QTextStream out(&result, IO_WriteOnly);
+ QString n = e->name();
+ QString 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
+QString memberMutatorBody( CfgEntry *e )
+{
+ QString result;
+ QTextStream out(&result, IO_WriteOnly);
+ QString n = e->name();
+ QString 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( QString::fromLatin1( \"";
+ if (!e->param().isEmpty())
+ {
+ out << e->paramName().replace("$("+e->param()+")", "%1") << "\" ).arg( ";
+ if ( e->paramType() == "Enum" ) {
+ out << "QString::fromLatin1( ";
+
+ if (globalEnums)
+ out << enumName(e->param()) << "ToString[i]";
+ else
+ out << enumName(e->param()) << "::enumToString[i]";
+
+ out << " )";
+ }
+ else
+ {
+ out << "i";
+ }
+ out << " )";
+ }
+ else
+ {
+ out << n << "\" )";
+ }
+ out << " ))" << endl;
+ out << " " << This << varPath(n);
+ if (!e->param().isEmpty())
+ out << "[i]";
+ out << " = v;" << endl;
+
+ return result;
+}
+
+// returns the item accesor implementation
+// which should go in the h file if inline
+// or the cpp file if not inline
+QString itemAccessorBody( CfgEntry *e )
+{
+ QString result;
+ QTextStream 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
+QString indent(QString text, int spaces)
+{
+ QString result;
+ QTextStream out(&result, IO_WriteOnly);
+ QTextStream in(&text, IO_ReadOnly);
+ QString 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, "schumacher@kde.org" );
+ aboutData.addAuthor( "Waldo Bastian", 0, "bastian@kde.org" );
+ aboutData.addAuthor( "Zack Rusin", 0, "zack@kde.org" );
+ aboutData.addCredit( "Reinhold Kainhofer", "Fix for parametrized entries",
+ "reinhold@kainhofer.com", "http://reinhold.kainhofer.com" );
+ aboutData.addCredit( "Duncan Mac-Vicar P.", "dpointer support",
+ "duncan@kde.org", "http://www.mac-vicar.com/~duncan" );
+
+ 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 QRegExp("[a-zA-Z_][a-zA-Z0-9_]*");
+
+ QString baseDir = QFile::decodeName(args->getOption("directory"));
+ if (!baseDir.endsWith("/"))
+ baseDir.append("/");
+
+ QString inputFilename = args->url( 0 ).path();
+ QString codegenFilename = args->url( 1 ).path();
+
+ if (!codegenFilename.endsWith(".kcfgc"))
+ {
+ kdError() << "Codegen options file must have extension .kcfgc" << endl;
+ return 1;
+ }
+ QString baseName = args->url( 1 ).fileName();
+ baseName = baseName.left(baseName.length() - 6);
+
+ KSimpleConfig codegenConfig( codegenFilename, true );
+
+ QString nameSpace = codegenConfig.readEntry("NameSpace");
+ QString className = codegenConfig.readEntry("ClassName");
+ QString inherits = codegenConfig.readEntry("Inherits");
+ QString 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");
+ QString memberVariables = codegenConfig.readEntry("MemberVariables");
+ QStringList headerIncludes = codegenConfig.readListEntry("IncludeFiles");
+ QStringList 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");
+
+ QFile input( inputFilename );
+
+ QDomDocument doc;
+ QString 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;
+ }
+
+ QDomElement cfgElement = doc.documentElement();
+
+ if ( cfgElement.isNull() ) {
+ kdError() << "No document in kcfg file" << endl;
+ return 1;
+ }
+
+ QString cfgFileName;
+ bool cfgFileNameArg = false;
+ QValueList<Param> parameters;
+ QStringList includes;
+
+ QPtrList<CfgEntry> entries;
+ entries.setAutoDelete( true );
+
+ QDomNode n;
+ for ( n = cfgElement.firstChild(); !n.isNull(); n = n.nextSibling() ) {
+ QDomElement e = n.toElement();
+
+ QString tag = e.tagName();
+
+ if ( tag == "include" ) {
+ QString includeFile = e.text();
+ if (!includeFile.isEmpty())
+ includes.append(includeFile);
+
+ } else if ( tag == "kcfgfile" ) {
+ cfgFileName = e.attribute( "name" );
+ cfgFileNameArg = e.attribute( "arg" ).lower() == "true";
+ QDomNode n2;
+ for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) {
+ QDomElement 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" ) {
+ QString group = e.attribute( "name" );
+ if ( group.isEmpty() ) {
+ kdError() << "Group without name" << endl;
+ return 1;
+ }
+ QDomNode n2;
+ for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) {
+ QDomElement 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
+
+ QString headerFileName = baseName + ".h";
+ QString implementationFileName = baseName + ".cpp";
+ QString cppPreamble; // code to be inserted at the beginnin of the cpp file, e.g. initialization of static values
+
+ QFile header( baseDir + headerFileName );
+ if ( !header.open( IO_WriteOnly ) ) {
+ kdError() << "Can't open '" << headerFileName << "' for writing." << endl;
+ return 1;
+ }
+
+ QTextStream 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
+ QStringList::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() ) {
+ QValueList<CfgEntry::Choice> choices = e->choices();
+ if ( !choices.isEmpty() ) {
+ QStringList values;
+ QValueList<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;
+ }
+ }
+ QStringList 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 (QValueList<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() ) {
+ QString n = e->name();
+ QString 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 (QValueList<Param>::ConstIterator it = parameters.begin();
+ it != parameters.end(); ++it)
+ {
+ h << " " << cppType((*it).type) << " mParam" << (*it).name << ";" << endl;
+ }
+
+ if ( memberVariables != "dpointer" )
+ {
+ QString 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 << QString("[%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 << QString("[%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();
+
+ QFile implementation( baseDir + implementationFileName );
+ if ( !implementation.open( IO_WriteOnly ) ) {
+ kdError() << "Can't open '" << implementationFileName << "' for writing."
+ << endl;
+ return 1;
+ }
+
+ QTextStream 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;
+
+ QString 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 << QString("[%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 << QString("[%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 (QValueList<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 << " QString::fromLatin1( \"" << cfgFileName << "\" ";
+ if ( cfgFileNameArg ) cpp << " config ";
+ if ( !cfgFileName.isEmpty() ) cpp << ") ";
+ cpp << ")" << endl;
+
+ // Store parameters
+ for (QValueList<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 = QString::null;
+ 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;
+ }
+
+ QString key = paramString(e->key(), parameters);
+ if ( !e->code().isEmpty())
+ {
+ cpp << e->code() << endl;
+ }
+ if ( e->type() == "Enum" ) {
+ cpp << " QValueList<KConfigSkeleton::ItemEnum::Choice> values"
+ << e->name() << ";" << endl;
+ QValueList<CfgEntry::Choice> choices = e->choices();
+ QValueList<CfgEntry::Choice>::ConstIterator it;
+ for( it = choices.begin(); it != choices.end(); ++it ) {
+ cpp << " {" << endl;
+ cpp << " KConfigSkeleton::ItemEnum::Choice choice;" << endl;
+ cpp << " choice.name = QString::fromLatin1( \"" << (*it).name << "\" );" << endl;
+ if ( setUserTexts ) {
+ if ( !(*it).label.isEmpty() )
+ cpp << " choice.label = i18n(" << quoteString((*it).label) << ");" << endl;
+ if ( !(*it).whatsThis.isEmpty() )
+ cpp << " choice.whatsThis = i18n(" << quoteString((*it).whatsThis) << ");" << endl;
+ }
+ cpp << " values" << e->name() << ".append( choice );" << endl;
+ cpp << " }" << endl;
+ }
+ }
+
+ if (!dpointer)
+ cpp << itemDeclaration(e);
+
+ if (e->param().isEmpty())
+ {
+ // Normal case
+ cpp << " " << itemPath(e) << " = "
+ << newItem( e->type(), e->name(), key, e->defaultValue() ) << endl;
+
+ if ( !e->minValue().isEmpty() )
+ cpp << " " << itemPath(e) << "->setMinValue(" << e->minValue() << ");" << endl;
+ if ( !e->maxValue().isEmpty() )
+ cpp << " " << itemPath(e) << "->setMaxValue(" << e->maxValue() << ");" << endl;
+
+ if ( setUserTexts )
+ cpp << userTextsFunctions( e );
+
+ cpp << " addItem( " << itemPath(e);
+ QString quotedName = e->name();
+ addQuotes( quotedName );
+ if ( quotedName != key ) cpp << ", QString::fromLatin1( \"" << e->name() << "\" )";
+ cpp << " );" << endl;
+ }
+ else
+ {
+ // Indexed
+ for(int i = 0; i <= e->paramMax(); i++)
+ {
+ QString defaultStr;
+ QString itemVarStr(itemPath(e)+QString("[%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, QString("[%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 << ", QString::fromLatin1( \"";
+ if ( e->paramType()=="Enum" )
+ cpp << e->paramName().replace( "$("+e->param()+")", "%1").arg(e->paramValues()[i] );
+ else
+ cpp << e->paramName().replace( "$("+e->param()+")", "%1").arg(i);
+ cpp << "\" ) );" << endl;
+ }
+ }
+ }
+
+ cpp << "}" << endl << endl;
+
+ if (dpointer)
+ {
+ // setters and getters go in Cpp if in dpointer mode
+ for( e = entries.first(); e; e = entries.next() )
+ {
+ QString n = e->name();
+ QString 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/kdecore/kconfig_compiler/tests/Makefile.am b/kdecore/kconfig_compiler/tests/Makefile.am
new file mode 100644
index 000000000..cb538783c
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/Makefile.am
@@ -0,0 +1,134 @@
+AM_CPPFLAGS = -I$(top_srcdir)/kdecore -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)
+test1_LDADD = $(LIB_KDECORE)
+test1_SOURCES = test1main.cpp test1.cpp
+
+test2_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+test2_LDADD = $(LIB_KDECORE)
+test2_SOURCES = test2main.cpp test2.cpp
+
+test3_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+test3_LDADD = $(LIB_KDECORE)
+test3_SOURCES = test3main.cpp test3.cpp
+
+test4_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+test4_LDADD = $(LIB_KDECORE)
+test4_SOURCES = test4main.cpp test4.cpp
+
+test5_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+test5_LDADD = $(LIB_KDECORE)
+test5_SOURCES = test5main.cpp test5.cpp
+
+test6_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+test6_LDADD = $(LIB_KDECORE)
+test6_SOURCES = test6main.cpp test6.cpp
+
+test7_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+test7_LDADD = $(LIB_KDECORE)
+test7_SOURCES = test7main.cpp test7.cpp
+
+test8_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+test8_LDADD = $(LIB_KDECORE)
+test8_SOURCES = test8main.cpp test8a.cpp test8b.cpp
+
+test9_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+test9_LDADD = $(LIB_KDECORE)
+test9_SOURCES = test9main.cpp test9.cpp
+
+test_dpointer_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+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/kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp b/kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp
new file mode 100644
index 000000000..31f3f5ee9
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp
@@ -0,0 +1,96 @@
+/*
+ Tests for KConfig Compiler
+
+ Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+
+ *************************************************************************
+ * *
+ * 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 <qfile.h>
+#include <qstring.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 QDir 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(QString::fromLatin1(testCases[ i ]));
+ ++i;
+ }
+
+ // broken test cases
+ i= 0;
+ while (willFailCases[ i ])
+ {
+ performCompare(QString::fromLatin1(willFailCases[ i ]), true);
+ ++i;
+ }
+}
+
+void KConfigCompiler_Test::performCompare(const QString &fileName, bool fail)
+{
+ QFile file(fileName);
+ QFile fileRef(QString::fromLatin1(SRCDIR) + QString::fromLatin1("/") + fileName + QString::fromLatin1(".ref"));
+
+ if ( file.open(IO_ReadOnly) && fileRef.open(IO_ReadOnly) )
+ {
+ QString content = file.readAll();
+ QString contentRef = fileRef.readAll();
+
+ if (!fail)
+ CHECK( content, contentRef);
+ else
+ XFAIL( content, contentRef);
+ }
+ else
+ {
+ SKIP("Can't open file for comparision");
+ }
+}
diff --git a/kdecore/kconfig_compiler/tests/kconfigcompiler_test.h b/kdecore/kconfig_compiler/tests/kconfigcompiler_test.h
new file mode 100644
index 000000000..8ccea83fa
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/kconfigcompiler_test.h
@@ -0,0 +1,35 @@
+/*
+ Tests for KConfig Compiler
+
+ Copyright (c) 2005 by Duncan Mac-Vicar <duncan@kde.org>
+
+ *************************************************************************
+ * *
+ * 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 QString;
+
+// change to SlotTester when it works
+class KConfigCompiler_Test : public KUnitTest::Tester
+{
+public:
+ void allTests();
+public slots:
+ void testExpectedOutput();
+private:
+ void performCompare(const QString &fileName, bool fail=false);
+};
+
+#endif
+
diff --git a/kdecore/kconfig_compiler/tests/myprefs.h b/kdecore/kconfig_compiler/tests/myprefs.h
new file mode 100644
index 000000000..263c409d2
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/myprefs.h
@@ -0,0 +1,7 @@
+#include <kconfigskeleton.h>
+
+class MyPrefs : public KConfigSkeleton
+{
+ public:
+ MyPrefs( const QString &a ) : KConfigSkeleton( a ) {}
+};
diff --git a/kdecore/kconfig_compiler/tests/test1.cpp.ref b/kdecore/kconfig_compiler/tests/test1.cpp.ref
new file mode 100644
index 000000000..e4c9f86d8
--- /dev/null
+++ b/kdecore/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 QString & transport, const QString & folder )
+ : KConfigSkeleton( QString::fromLatin1( "examplerc" ) )
+ , mParamtransport(transport)
+ , mParamfolder(folder)
+{
+ setCurrentGroup( QString::fromLatin1( "General-%1" ).arg( mParamfolder ) );
+
+ KConfigSkeleton::ItemBool *itemOneOption;
+ itemOneOption = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "OneOption" ), mOneOption, true );
+ addItem( itemOneOption, QString::fromLatin1( "OneOption" ) );
+ KConfigSkeleton::ItemInt *itemAnotherOption;
+ itemAnotherOption = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "Another Option" ), mAnotherOption, 5 );
+ addItem( itemAnotherOption, QString::fromLatin1( "AnotherOption" ) );
+ QValueList<KConfigSkeleton::ItemEnum::Choice> valuesListOption;
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "One" );
+ valuesListOption.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "Two" );
+ valuesListOption.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "Three" );
+ valuesListOption.append( choice );
+ }
+ KConfigSkeleton::ItemEnum *itemListOption;
+ itemListOption = new KConfigSkeleton::ItemEnum( currentGroup(), QString::fromLatin1( "ListOption" ), mListOption, valuesListOption, EnumListOption::One );
+ addItem( itemListOption, QString::fromLatin1( "ListOption" ) );
+
+ setCurrentGroup( QString::fromLatin1( "MyOptions" ) );
+
+ KConfigSkeleton::ItemString *itemMyString;
+ itemMyString = new KConfigSkeleton::ItemString( currentGroup(), QString::fromLatin1( "MyString" ), mMyString, QString::fromLatin1( "Default String" ) );
+ addItem( itemMyString, QString::fromLatin1( "MyString" ) );
+ KConfigSkeleton::ItemPath *itemMyPath;
+ itemMyPath = new KConfigSkeleton::ItemPath( currentGroup(), QString::fromLatin1( "MyPath" ), mMyPath, QDir::homeDirPath()+QString::fromLatin1(".hidden_file") );
+ addItem( itemMyPath, QString::fromLatin1( "MyPath" ) );
+ KConfigSkeleton::ItemInt *itemAnotherOption2;
+ itemAnotherOption2 = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "Another Option" ), mAnotherOption2, 10 );
+ addItem( itemAnotherOption2, QString::fromLatin1( "AnotherOption2" ) );
+ QStringList defaultMyStringList;
+ defaultMyStringList.append( QString::fromUtf8( "up" ) );
+ defaultMyStringList.append( QString::fromUtf8( "down" ) );
+
+ KConfigSkeleton::ItemStringList *itemMyStringList;
+ itemMyStringList = new KConfigSkeleton::ItemStringList( currentGroup(), QString::fromLatin1( "MyStringList" ), mMyStringList, defaultMyStringList );
+ addItem( itemMyStringList, QString::fromLatin1( "MyStringList" ) );
+ QStringList defaultMyStringListHidden;
+ defaultMyStringListHidden.append( QString::fromUtf8( "up" ) );
+ defaultMyStringListHidden.append( QString::fromUtf8( "down" ) );
+
+ KConfigSkeleton::ItemStringList *itemMyStringListHidden;
+ itemMyStringListHidden = new KConfigSkeleton::ItemStringList( currentGroup(), QString::fromLatin1( "MyStringListHidden" ), mMyStringListHidden, defaultMyStringListHidden );
+ addItem( itemMyStringListHidden, QString::fromLatin1( "MyStringListHidden" ) );
+ KConfigSkeleton::ItemInt *itemMyNumber;
+ itemMyNumber = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "List-%1-%2" ).arg( mParamtransport ).arg( mParamfolder ), mMyNumber, 1 );
+ addItem( itemMyNumber, QString::fromLatin1( "MyNumber" ) );
+}
+
+Test1::~Test1()
+{
+}
+
diff --git a/kdecore/kconfig_compiler/tests/test1.h.ref b/kdecore/kconfig_compiler/tests/test1.h.ref
new file mode 100644
index 000000000..e08ccee8a
--- /dev/null
+++ b/kdecore/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 <qdir.h>
+class Test1 : public KConfigSkeleton
+{
+ public:
+ class EnumListOption
+ {
+ public:
+ enum type { One, Two, Three, COUNT };
+ };
+
+ Test1( const QString & transport, const QString & folder );
+ ~Test1();
+
+ /**
+ Set One option
+ */
+ void setOneOption( bool v )
+ {
+ if (!isImmutable( QString::fromLatin1( "OneOption" ) ))
+ mOneOption = v;
+ }
+
+ /**
+ Get One option
+ */
+ bool oneOption() const
+ {
+ return mOneOption;
+ }
+
+ /**
+ Set Another option
+ */
+ void setAnotherOption( int v )
+ {
+ if (!isImmutable( QString::fromLatin1( "AnotherOption" ) ))
+ mAnotherOption = v;
+ }
+
+ /**
+ Get Another option
+ */
+ int anotherOption() const
+ {
+ return mAnotherOption;
+ }
+
+ /**
+ Set This is some funky option
+ */
+ void setListOption( int v )
+ {
+ if (!isImmutable( QString::fromLatin1( "ListOption" ) ))
+ mListOption = v;
+ }
+
+ /**
+ Get This is some funky option
+ */
+ int listOption() const
+ {
+ return mListOption;
+ }
+
+ /**
+ Set This is a string
+ */
+ void setMyString( const QString & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "MyString" ) ))
+ mMyString = v;
+ }
+
+ /**
+ Get This is a string
+ */
+ QString myString() const
+ {
+ return mMyString;
+ }
+
+ /**
+ Set This is a path
+ */
+ void setMyPath( const QString & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "MyPath" ) ))
+ mMyPath = v;
+ }
+
+ /**
+ Get This is a path
+ */
+ QString myPath() const
+ {
+ return mMyPath;
+ }
+
+ /**
+ Set Another option
+ */
+ void setAnotherOption2( int v )
+ {
+ if (!isImmutable( QString::fromLatin1( "AnotherOption2" ) ))
+ mAnotherOption2 = v;
+ }
+
+ /**
+ Get Another option
+ */
+ int anotherOption2() const
+ {
+ return mAnotherOption2;
+ }
+
+ /**
+ Set MyStringList
+ */
+ void setMyStringList( const QStringList & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "MyStringList" ) ))
+ mMyStringList = v;
+ }
+
+ /**
+ Get MyStringList
+ */
+ QStringList myStringList() const
+ {
+ return mMyStringList;
+ }
+
+ /**
+ Set MyStringListHidden
+ */
+ void setMyStringListHidden( const QStringList & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "MyStringListHidden" ) ))
+ mMyStringListHidden = v;
+ }
+
+ /**
+ Get MyStringListHidden
+ */
+ QStringList myStringListHidden() const
+ {
+ return mMyStringListHidden;
+ }
+
+ /**
+ Set List Number
+ */
+ void setMyNumber( int v )
+ {
+ if (!isImmutable( QString::fromLatin1( "MyNumber" ) ))
+ mMyNumber = v;
+ }
+
+ /**
+ Get List Number
+ */
+ int myNumber() const
+ {
+ return mMyNumber;
+ }
+
+ protected:
+ QString mParamtransport;
+ QString mParamfolder;
+
+ // General-$(folder)
+ bool mOneOption;
+ int mAnotherOption;
+ int mListOption;
+
+ // MyOptions
+ QString mMyString;
+ QString mMyPath;
+ int mAnotherOption2;
+ QStringList mMyStringList;
+ QStringList mMyStringListHidden;
+ int mMyNumber;
+
+ private:
+};
+
+#endif
+
diff --git a/kdecore/kconfig_compiler/tests/test1.kcfg b/kdecore/kconfig_compiler/tests/test1.kcfg
new file mode 100644
index 000000000..ce42aebfb
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test1.kcfgc b/kdecore/kconfig_compiler/tests/test1.kcfgc
new file mode 100644
index 000000000..6e0edd366
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test1.kcfgc
@@ -0,0 +1,18 @@
+# Code generation options for kconfig_compiler
+ClassName=Test1
+#
+# Singleton=false
+#
+# Inherits=KConfigSkeleton
+#
+# IncludeFiles=libkdepim/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/kdecore/kconfig_compiler/tests/test1main.cpp b/kdecore/kconfig_compiler/tests/test1main.cpp
new file mode 100644
index 000000000..f55f54195
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test1main.cpp
@@ -0,0 +1,29 @@
+/*
+Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
+
+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( QString::null, QString::null );
+ delete t;
+}
diff --git a/kdecore/kconfig_compiler/tests/test2.cpp.ref b/kdecore/kconfig_compiler/tests/test2.cpp.ref
new file mode 100644
index 000000000..d2197856e
--- /dev/null
+++ b/kdecore/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( QString::fromLatin1( "korganizerrc" ) )
+{
+ setCurrentGroup( QString::fromLatin1( "General" ) );
+
+ mAutoSaveItem = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "Auto Save" ), mAutoSave, false );
+ mAutoSaveItem->setLabel( i18n("Enable automatic saving of calendar") );
+ mAutoSaveItem->setWhatsThis( i18n("WhatsThis text for AutoSave option") );
+ addItem( mAutoSaveItem, QString::fromLatin1( "AutoSave" ) );
+ mAutoSaveIntervalItem = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "Auto Save Interval" ), mAutoSaveInterval, 10 );
+ mAutoSaveIntervalItem->setLabel( i18n("Auto Save Interval") );
+ addItem( mAutoSaveIntervalItem, QString::fromLatin1( "AutoSaveInterval" ) );
+ mConfirmItem = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "Confirm Deletes" ), mConfirm, true );
+ mConfirmItem->setLabel( i18n("Confirm deletes") );
+ addItem( mConfirmItem, QString::fromLatin1( "Confirm" ) );
+ mArchiveFileItem = new KConfigSkeleton::ItemString( currentGroup(), QString::fromLatin1( "Archive File" ), mArchiveFile );
+ mArchiveFileItem->setLabel( i18n("Archive File") );
+ addItem( mArchiveFileItem, QString::fromLatin1( "ArchiveFile" ) );
+ QValueList<KConfigSkeleton::ItemEnum::Choice> valuesDestination;
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "standardDestination" );
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "askDestination" );
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "argl1" );
+ choice.label = i18n("Argl1 Label");
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "argl2" );
+ choice.whatsThis = i18n("Argl2 Whatsthis");
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "argl3" );
+ choice.label = i18n("Argl3 Label");
+ choice.whatsThis = i18n("Argl3 Whatsthis");
+ valuesDestination.append( choice );
+ }
+ mDestinationItem = new KConfigSkeleton::ItemEnum( currentGroup(), QString::fromLatin1( "Destination" ), mDestination, valuesDestination, standardDestination );
+ mDestinationItem->setLabel( i18n("New Events/Todos Should") );
+ addItem( mDestinationItem, QString::fromLatin1( "Destination" ) );
+
+ setCurrentGroup( QString::fromLatin1( "Views" ) );
+
+ mHourSizeItem = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "Hour Size" ), mHourSize, 10 );
+ mHourSizeItem->setLabel( i18n("Hour Size") );
+ addItem( mHourSizeItem, QString::fromLatin1( "HourSize" ) );
+ mSelectionStartsEditorItem = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "SelectionStartsEditor" ), mSelectionStartsEditor, false );
+ mSelectionStartsEditorItem->setLabel( i18n("Time range selection in agenda view starts event editor") );
+ addItem( mSelectionStartsEditorItem, QString::fromLatin1( "SelectionStartsEditor" ) );
+
+ setCurrentGroup( QString::fromLatin1( "KOrganizer Plugins" ) );
+
+ QStringList defaultSelectedPlugins;
+ defaultSelectedPlugins.append( QString::fromUtf8( "holidays" ) );
+ defaultSelectedPlugins.append( QString::fromUtf8( "webexport" ) );
+
+ mSelectedPluginsItem = new KConfigSkeleton::ItemStringList( currentGroup(), QString::fromLatin1( "SelectedPlugins" ), mSelectedPlugins, defaultSelectedPlugins );
+ mSelectedPluginsItem->setLabel( i18n("SelectedPlugins") );
+ addItem( mSelectedPluginsItem, QString::fromLatin1( "SelectedPlugins" ) );
+
+ setCurrentGroup( QString::fromLatin1( "Colors" ) );
+
+ mHighlightColorItem = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "Highlight Color" ), mHighlightColor, QColor( 100, 100, 255 ) );
+ mHighlightColorItem->setLabel( i18n("Highlight color") );
+ addItem( mHighlightColorItem, QString::fromLatin1( "HighlightColor" ) );
+ mAgendaBgColorItem = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "Agenda Background Color" ), mAgendaBgColor, QColor( 255, 255, 255 ) );
+ mAgendaBgColorItem->setLabel( i18n("Agenda view background color") );
+ addItem( mAgendaBgColorItem, QString::fromLatin1( "AgendaBgColor" ) );
+
+ setCurrentGroup( QString::fromLatin1( "Fonts" ) );
+
+ mTimeBarFontItem = new KConfigSkeleton::ItemFont( currentGroup(), QString::fromLatin1( "TimeBar Font" ), mTimeBarFont );
+ mTimeBarFontItem->setLabel( i18n("Time bar") );
+ addItem( mTimeBarFontItem, QString::fromLatin1( "TimeBarFont" ) );
+}
+
+Test2::~Test2()
+{
+}
+
diff --git a/kdecore/kconfig_compiler/tests/test2.h.ref b/kdecore/kconfig_compiler/tests/test2.h.ref
new file mode 100644
index 000000000..4e8b5ec1f
--- /dev/null
+++ b/kdecore/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( QString::fromLatin1( "AutoSave" ) ))
+ mAutoSave = v;
+ }
+
+ /**
+ Get Enable automatic saving of calendar
+ */
+ bool autoSave() const
+ {
+ return mAutoSave;
+ }
+
+ /**
+ Get Item object corresponding to AutoSave()
+ */
+ ItemBool *autoSaveItem()
+ {
+ return mAutoSaveItem;
+ }
+
+ /**
+ Set Auto Save Interval
+ */
+ void setAutoSaveInterval( int v )
+ {
+ if (!isImmutable( QString::fromLatin1( "AutoSaveInterval" ) ))
+ mAutoSaveInterval = v;
+ }
+
+ /**
+ Get Auto Save Interval
+ */
+ int autoSaveInterval() const
+ {
+ return mAutoSaveInterval;
+ }
+
+ /**
+ Get Item object corresponding to AutoSaveInterval()
+ */
+ ItemInt *autoSaveIntervalItem()
+ {
+ return mAutoSaveIntervalItem;
+ }
+
+ /**
+ Set Confirm deletes
+ */
+ void setConfirm( bool v )
+ {
+ if (!isImmutable( QString::fromLatin1( "Confirm" ) ))
+ mConfirm = v;
+ }
+
+ /**
+ Get Confirm deletes
+ */
+ bool confirm() const
+ {
+ return mConfirm;
+ }
+
+ /**
+ Get Item object corresponding to Confirm()
+ */
+ ItemBool *confirmItem()
+ {
+ return mConfirmItem;
+ }
+
+ /**
+ Set Archive File
+ */
+ void setArchiveFile( const QString & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "ArchiveFile" ) ))
+ mArchiveFile = v;
+ }
+
+ /**
+ Get Archive File
+ */
+ QString 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( QString::fromLatin1( "Destination" ) ))
+ mDestination = v;
+ }
+
+ /**
+ Get New Events/Todos Should
+ */
+ int destination() const
+ {
+ return mDestination;
+ }
+
+ /**
+ Get Item object corresponding to Destination()
+ */
+ ItemEnum *destinationItem()
+ {
+ return mDestinationItem;
+ }
+
+ /**
+ Set Hour Size
+ */
+ void setHourSize( int v )
+ {
+ if (!isImmutable( QString::fromLatin1( "HourSize" ) ))
+ mHourSize = v;
+ }
+
+ /**
+ Get Hour Size
+ */
+ int hourSize() const
+ {
+ return mHourSize;
+ }
+
+ /**
+ Get Item object corresponding to HourSize()
+ */
+ ItemInt *hourSizeItem()
+ {
+ return mHourSizeItem;
+ }
+
+ /**
+ Set Time range selection in agenda view starts event editor
+ */
+ void setSelectionStartsEditor( bool v )
+ {
+ if (!isImmutable( QString::fromLatin1( "SelectionStartsEditor" ) ))
+ mSelectionStartsEditor = v;
+ }
+
+ /**
+ Get Time range selection in agenda view starts event editor
+ */
+ bool selectionStartsEditor() const
+ {
+ return mSelectionStartsEditor;
+ }
+
+ /**
+ Get Item object corresponding to SelectionStartsEditor()
+ */
+ ItemBool *selectionStartsEditorItem()
+ {
+ return mSelectionStartsEditorItem;
+ }
+
+ /**
+ Set SelectedPlugins
+ */
+ void setSelectedPlugins( const QStringList & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "SelectedPlugins" ) ))
+ mSelectedPlugins = v;
+ }
+
+ /**
+ Get SelectedPlugins
+ */
+ QStringList selectedPlugins() const
+ {
+ return mSelectedPlugins;
+ }
+
+ /**
+ Get Item object corresponding to SelectedPlugins()
+ */
+ ItemStringList *selectedPluginsItem()
+ {
+ return mSelectedPluginsItem;
+ }
+
+ /**
+ Set Highlight color
+ */
+ void setHighlightColor( const QColor & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "HighlightColor" ) ))
+ mHighlightColor = v;
+ }
+
+ /**
+ Get Highlight color
+ */
+ QColor highlightColor() const
+ {
+ return mHighlightColor;
+ }
+
+ /**
+ Get Item object corresponding to HighlightColor()
+ */
+ ItemColor *highlightColorItem()
+ {
+ return mHighlightColorItem;
+ }
+
+ /**
+ Set Agenda view background color
+ */
+ void setAgendaBgColor( const QColor & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "AgendaBgColor" ) ))
+ mAgendaBgColor = v;
+ }
+
+ /**
+ Get Agenda view background color
+ */
+ QColor agendaBgColor() const
+ {
+ return mAgendaBgColor;
+ }
+
+ /**
+ Get Item object corresponding to AgendaBgColor()
+ */
+ ItemColor *agendaBgColorItem()
+ {
+ return mAgendaBgColorItem;
+ }
+
+ /**
+ Set Time bar
+ */
+ void setTimeBarFont( const QFont & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "TimeBarFont" ) ))
+ mTimeBarFont = v;
+ }
+
+ /**
+ Get Time bar
+ */
+ QFont timeBarFont() const
+ {
+ return mTimeBarFont;
+ }
+
+ /**
+ Get Item object corresponding to TimeBarFont()
+ */
+ ItemFont *timeBarFontItem()
+ {
+ return mTimeBarFontItem;
+ }
+
+ protected:
+ public:
+
+ // General
+ bool mAutoSave;
+ int mAutoSaveInterval;
+ bool mConfirm;
+ QString mArchiveFile;
+ int mDestination;
+
+ // Views
+ int mHourSize;
+ bool mSelectionStartsEditor;
+
+ // KOrganizer Plugins
+ QStringList mSelectedPlugins;
+
+ // Colors
+ QColor mHighlightColor;
+ QColor mAgendaBgColor;
+
+ // Fonts
+ QFont 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/kdecore/kconfig_compiler/tests/test2.kcfg b/kdecore/kconfig_compiler/tests/test2.kcfg
new file mode 100644
index 000000000..3b19e270e
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test2.kcfgc b/kdecore/kconfig_compiler/tests/test2.kcfgc
new file mode 100644
index 000000000..56620d2f4
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test2main.cpp b/kdecore/kconfig_compiler/tests/test2main.cpp
new file mode 100644
index 000000000..904c57270
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test2main.cpp
@@ -0,0 +1,29 @@
+/*
+Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
+
+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/kdecore/kconfig_compiler/tests/test3.cpp.ref b/kdecore/kconfig_compiler/tests/test3.cpp.ref
new file mode 100644
index 000000000..a9435f2cf
--- /dev/null
+++ b/kdecore/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( QString::fromLatin1( "test3rc" ) )
+{
+ setCurrentGroup( QString::fromLatin1( "General" ) );
+
+ mAutoSaveItem = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "Auto Save" ), mAutoSave, false );
+ addItem( mAutoSaveItem, QString::fromLatin1( "AutoSave" ) );
+
+ setCurrentGroup( QString::fromLatin1( "Blah" ) );
+
+ mBlubbItem = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "Blubb" ), mBlubb, 10 );
+ addItem( mBlubbItem, QString::fromLatin1( "Blubb" ) );
+ mBlahBlahItem = new KConfigSkeleton::ItemString( currentGroup(), QString::fromLatin1( "BlahBlah" ), mBlahBlah, QString::fromLatin1( "a string" ) );
+ addItem( mBlahBlahItem, QString::fromLatin1( "BlahBlah" ) );
+ mMyPasswordItem = new KConfigSkeleton::ItemPassword( currentGroup(), QString::fromLatin1( "MyPassword" ), mMyPassword );
+ addItem( mMyPasswordItem, QString::fromLatin1( "MyPassword" ) );
+}
+
+Test3::~Test3()
+{
+}
+
diff --git a/kdecore/kconfig_compiler/tests/test3.h.ref b/kdecore/kconfig_compiler/tests/test3.h.ref
new file mode 100644
index 000000000..4742a0ec1
--- /dev/null
+++ b/kdecore/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( QString::fromLatin1( "AutoSave" ) ))
+ mAutoSave = v;
+ }
+
+ /**
+ Get Enable automatic saving of calendar
+ */
+ bool autoSave() const
+ {
+ return mAutoSave;
+ }
+
+ /**
+ Get Item object corresponding to AutoSave()
+ */
+ ItemBool *autoSaveItem()
+ {
+ return mAutoSaveItem;
+ }
+
+ /**
+ Set Blubb
+ */
+ void setBlubb( int v )
+ {
+ if (!isImmutable( QString::fromLatin1( "Blubb" ) ))
+ mBlubb = v;
+ }
+
+ /**
+ Get Blubb
+ */
+ int blubb() const
+ {
+ return mBlubb;
+ }
+
+ /**
+ Get Item object corresponding to Blubb()
+ */
+ ItemInt *blubbItem()
+ {
+ return mBlubbItem;
+ }
+
+ /**
+ Set BlahBlah
+ */
+ void setBlahBlah( const QString & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "BlahBlah" ) ))
+ mBlahBlah = v;
+ }
+
+ /**
+ Get BlahBlah
+ */
+ QString blahBlah() const
+ {
+ return mBlahBlah;
+ }
+
+ /**
+ Get Item object corresponding to BlahBlah()
+ */
+ ItemString *blahBlahItem()
+ {
+ return mBlahBlahItem;
+ }
+
+ /**
+ Set MyPassword
+ */
+ void setMyPassword( const QString & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "MyPassword" ) ))
+ mMyPassword = v;
+ }
+
+ /**
+ Get MyPassword
+ */
+ QString myPassword() const
+ {
+ return mMyPassword;
+ }
+
+ /**
+ Get Item object corresponding to MyPassword()
+ */
+ ItemPassword *myPasswordItem()
+ {
+ return mMyPasswordItem;
+ }
+
+ protected:
+
+ // General
+ bool mAutoSave;
+
+ // Blah
+ int mBlubb;
+ QString mBlahBlah;
+ QString mMyPassword;
+
+ private:
+ ItemBool *mAutoSaveItem;
+ ItemInt *mBlubbItem;
+ ItemString *mBlahBlahItem;
+ ItemPassword *mMyPasswordItem;
+};
+
+}
+
+#endif
+
diff --git a/kdecore/kconfig_compiler/tests/test3.kcfg b/kdecore/kconfig_compiler/tests/test3.kcfg
new file mode 100644
index 000000000..77916da40
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test3.kcfgc b/kdecore/kconfig_compiler/tests/test3.kcfgc
new file mode 100644
index 000000000..ca2c22057
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test3main.cpp b/kdecore/kconfig_compiler/tests/test3main.cpp
new file mode 100644
index 000000000..9789d697d
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test3main.cpp
@@ -0,0 +1,29 @@
+/*
+Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
+
+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/kdecore/kconfig_compiler/tests/test4.cpp.ref b/kdecore/kconfig_compiler/tests/test4.cpp.ref
new file mode 100644
index 000000000..d50c98b26
--- /dev/null
+++ b/kdecore/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( QString::fromLatin1( "test4rc" ) )
+{
+ mSelf = this;
+ setCurrentGroup( QString::fromLatin1( "Foo" ) );
+
+QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black };
+ KConfigSkeleton::ItemColor *itemColor[4];
+ itemColor[0] = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "color #0" ), mColor[0], defaultColor[0] );
+ addItem( itemColor[0], QString::fromLatin1( "Color0" ) );
+ itemColor[1] = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "color #1" ), mColor[1], defaultColor[1] );
+ addItem( itemColor[1], QString::fromLatin1( "Color1" ) );
+ itemColor[2] = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "color #2" ), mColor[2], defaultColor[2] );
+ addItem( itemColor[2], QString::fromLatin1( "Color2" ) );
+ itemColor[3] = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "color #3" ), mColor[3], defaultColor[3] );
+ addItem( itemColor[3], QString::fromLatin1( "Color3" ) );
+ QValueList<KConfigSkeleton::ItemEnum::Choice> valuesMouseAction;
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "Encrypt" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "Decrypt" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "CrashNBurn" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "PumpNDump" );
+ valuesMouseAction.append( choice );
+ }
+ KConfigSkeleton::ItemEnum *itemMouseAction[3];
+ itemMouseAction[0] = new KConfigSkeleton::ItemEnum( currentGroup(), QString::fromLatin1( "right_mouse_action" ), mMouseAction[0], valuesMouseAction, EnumMouseAction::Decrypt );
+ addItem( itemMouseAction[0], QString::fromLatin1( "MouseActionright" ) );
+ itemMouseAction[1] = new KConfigSkeleton::ItemEnum( currentGroup(), QString::fromLatin1( "mid_mouse_action" ), mMouseAction[1], valuesMouseAction, EnumMouseAction::Encrypt );
+ addItem( itemMouseAction[1], QString::fromLatin1( "MouseActionmid" ) );
+ itemMouseAction[2] = new KConfigSkeleton::ItemEnum( currentGroup(), QString::fromLatin1( "left_mouse_action" ), mMouseAction[2], valuesMouseAction, EnumMouseAction::PumpNDump );
+ addItem( itemMouseAction[2], QString::fromLatin1( "MouseActionleft" ) );
+ KConfigSkeleton::ItemString *itemFooBar;
+ itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), QString::fromLatin1( "foo bar" ), mFooBar );
+ addItem( itemFooBar, QString::fromLatin1( "FooBar" ) );
+ KConfigSkeleton::ItemInt *itemAge;
+ itemAge = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "Age" ), mAge, 35 );
+ itemAge->setMinValue(8);
+ itemAge->setMaxValue(88);
+ addItem( itemAge, QString::fromLatin1( "Age" ) );
+}
+
+Test4::~Test4()
+{
+ if ( mSelf == this )
+ staticTest4Deleter.setObject( mSelf, 0, false );
+}
+
diff --git a/kdecore/kconfig_compiler/tests/test4.h.ref b/kdecore/kconfig_compiler/tests/test4.h.ref
new file mode 100644
index 000000000..b7ae85287
--- /dev/null
+++ b/kdecore/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 QColor & v )
+ {
+ if (!self()->isImmutable( QString::fromLatin1( "Color%1" ).arg( i ) ))
+ self()->mColor[i] = v;
+ }
+
+ /**
+ Get Block colors.
+ */
+ static
+ QColor color( int i )
+ {
+ return self()->mColor[i];
+ }
+
+ /**
+ Set Mouse actions.
+ */
+ static
+ void setMouseAction( int i, int v )
+ {
+ if (!self()->isImmutable( QString::fromLatin1( "MouseAction%1" ).arg( QString::fromLatin1( EnumButton::enumToString[i] ) ) ))
+ self()->mMouseAction[i] = v;
+ }
+
+ /**
+ Get Mouse actions.
+ */
+ static
+ int mouseAction( int i )
+ {
+ return self()->mMouseAction[i];
+ }
+
+ /**
+ Set foo bar
+ */
+ static
+ void setFooBar( const QString & v )
+ {
+ if (!self()->isImmutable( QString::fromLatin1( "FooBar" ) ))
+ self()->mFooBar = v;
+ }
+
+ /**
+ Get foo bar
+ */
+ static
+ QString 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( QString::fromLatin1( "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
+ QColor mColor[4];
+ int mMouseAction[3];
+ QString mFooBar;
+ int mAge;
+
+ private:
+};
+
+#endif
+
diff --git a/kdecore/kconfig_compiler/tests/test4.kcfg b/kdecore/kconfig_compiler/tests/test4.kcfg
new file mode 100644
index 000000000..d8ef2bfae
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test4.kcfgc b/kdecore/kconfig_compiler/tests/test4.kcfgc
new file mode 100644
index 000000000..754706dff
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test4main.cpp b/kdecore/kconfig_compiler/tests/test4main.cpp
new file mode 100644
index 000000000..8b38b3dbd
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test4main.cpp
@@ -0,0 +1,30 @@
+/*
+Copyright (c) 2003,2004 Waldo Bastian <bastian@kde.org>
+
+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/kdecore/kconfig_compiler/tests/test5.cpp.ref b/kdecore/kconfig_compiler/tests/test5.cpp.ref
new file mode 100644
index 000000000..e6dc13f85
--- /dev/null
+++ b/kdecore/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( QString::fromLatin1( "test4rc" ) )
+{
+ mSelf = this;
+ setCurrentGroup( QString::fromLatin1( "Foo" ) );
+
+QColor defaultColor[4] = { Qt::red, Qt::blue, Qt::green, Qt::black };
+ KConfigSkeleton::ItemColor *itemColor[4];
+ itemColor[0] = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "color #0" ), mColor[0], defaultColor[0] );
+ addItem( itemColor[0], QString::fromLatin1( "Color0" ) );
+ itemColor[1] = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "color #1" ), mColor[1], defaultColor[1] );
+ addItem( itemColor[1], QString::fromLatin1( "Color1" ) );
+ itemColor[2] = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "color #2" ), mColor[2], defaultColor[2] );
+ addItem( itemColor[2], QString::fromLatin1( "Color2" ) );
+ itemColor[3] = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "color #3" ), mColor[3], defaultColor[3] );
+ addItem( itemColor[3], QString::fromLatin1( "Color3" ) );
+ QValueList<KConfigSkeleton::ItemEnum::Choice> valuesMouseAction;
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "Encrypt" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "Decrypt" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "CrashNBurn" );
+ valuesMouseAction.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "PumpNDump" );
+ valuesMouseAction.append( choice );
+ }
+ KConfigSkeleton::ItemEnum *itemMouseAction[3];
+ itemMouseAction[0] = new KConfigSkeleton::ItemEnum( currentGroup(), QString::fromLatin1( "right_mouse_action" ), mMouseAction[0], valuesMouseAction, Decrypt );
+ addItem( itemMouseAction[0], QString::fromLatin1( "MouseActionright" ) );
+ itemMouseAction[1] = new KConfigSkeleton::ItemEnum( currentGroup(), QString::fromLatin1( "mid_mouse_action" ), mMouseAction[1], valuesMouseAction, Encrypt );
+ addItem( itemMouseAction[1], QString::fromLatin1( "MouseActionmid" ) );
+ itemMouseAction[2] = new KConfigSkeleton::ItemEnum( currentGroup(), QString::fromLatin1( "left_mouse_action" ), mMouseAction[2], valuesMouseAction, PumpNDump );
+ addItem( itemMouseAction[2], QString::fromLatin1( "MouseActionleft" ) );
+ KConfigSkeleton::ItemString *itemFooBar;
+ itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), QString::fromLatin1( "foo bar" ), mFooBar );
+ addItem( itemFooBar, QString::fromLatin1( "FooBar" ) );
+ KConfigSkeleton::ItemInt *itemAge;
+ itemAge = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "Age" ), mAge, 35 );
+ itemAge->setMinValue(8);
+ itemAge->setMaxValue(88);
+ addItem( itemAge, QString::fromLatin1( "Age" ) );
+}
+
+Test5::~Test5()
+{
+ if ( mSelf == this )
+ staticTest5Deleter.setObject( mSelf, 0, false );
+}
+
diff --git a/kdecore/kconfig_compiler/tests/test5.h.ref b/kdecore/kconfig_compiler/tests/test5.h.ref
new file mode 100644
index 000000000..1a61d3913
--- /dev/null
+++ b/kdecore/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 QColor & v )
+ {
+ if (!self()->isImmutable( QString::fromLatin1( "Color%1" ).arg( i ) ))
+ self()->mColor[i] = v;
+ }
+
+ /**
+ Get Block colors.
+ */
+ static
+ QColor color( int i )
+ {
+ return self()->mColor[i];
+ }
+
+ /**
+ Set Mouse actions.
+ */
+ static
+ void setMouseAction( int i, int v )
+ {
+ if (!self()->isImmutable( QString::fromLatin1( "MouseAction%1" ).arg( QString::fromLatin1( EnumButtonToString[i] ) ) ))
+ self()->mMouseAction[i] = v;
+ }
+
+ /**
+ Get Mouse actions.
+ */
+ static
+ int mouseAction( int i )
+ {
+ return self()->mMouseAction[i];
+ }
+
+ /**
+ Set foo bar
+ */
+ static
+ void setFooBar( const QString & v )
+ {
+ if (!self()->isImmutable( QString::fromLatin1( "FooBar" ) ))
+ self()->mFooBar = v;
+ }
+
+ /**
+ Get foo bar
+ */
+ static
+ QString 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( QString::fromLatin1( "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
+ QColor mColor[4];
+ int mMouseAction[3];
+ QString mFooBar;
+ int mAge;
+
+ private:
+};
+
+#endif
+
diff --git a/kdecore/kconfig_compiler/tests/test5.kcfg b/kdecore/kconfig_compiler/tests/test5.kcfg
new file mode 100644
index 000000000..d8ef2bfae
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test5.kcfgc b/kdecore/kconfig_compiler/tests/test5.kcfgc
new file mode 100644
index 000000000..663005e5e
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test5main.cpp b/kdecore/kconfig_compiler/tests/test5main.cpp
new file mode 100644
index 000000000..57ad5189d
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test5main.cpp
@@ -0,0 +1,30 @@
+/*
+Copyright (c) 2004 Waldo Bastian <bastian@kde.org>
+
+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/kdecore/kconfig_compiler/tests/test6.cpp.ref b/kdecore/kconfig_compiler/tests/test6.cpp.ref
new file mode 100644
index 000000000..21fea85f6
--- /dev/null
+++ b/kdecore/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 QString & Number )
+ : KConfigSkeleton( QString::fromLatin1( "test4rc" ) )
+ , mParamNumber(Number)
+{
+ setCurrentGroup( QString::fromLatin1( "Foo" ) );
+
+ KConfigSkeleton::ItemColor *itemColor;
+ itemColor = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "color #%1" ).arg( mParamNumber ), mColor, QColor( "red" ) );
+ addItem( itemColor, QString::fromLatin1( "Color" ) );
+
+ setCurrentGroup( QString::fromLatin1( "Bar%1" ).arg( mParamNumber ) );
+
+ KConfigSkeleton::ItemString *itemFooBar;
+ itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), QString::fromLatin1( "foo bar" ), mFooBar );
+ addItem( itemFooBar, QString::fromLatin1( "FooBar" ) );
+ KConfigSkeleton::ItemInt *itemAge;
+ itemAge = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "Age" ), mAge, 35 );
+ itemAge->setMinValue(8);
+ itemAge->setMaxValue(88);
+ addItem( itemAge, QString::fromLatin1( "Age" ) );
+}
+
+Test6::~Test6()
+{
+}
+
diff --git a/kdecore/kconfig_compiler/tests/test6.h.ref b/kdecore/kconfig_compiler/tests/test6.h.ref
new file mode 100644
index 000000000..75fcfd04f
--- /dev/null
+++ b/kdecore/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 QString & Number );
+ ~Test6();
+
+ /**
+ Set Block colors.
+ */
+ void setColor( const QColor & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "Color" ) ))
+ mColor = v;
+ }
+
+ /**
+ Get Block colors.
+ */
+ QColor color() const
+ {
+ return mColor;
+ }
+
+ /**
+ Set foo bar
+ */
+ void setFooBar( const QString & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "FooBar" ) ))
+ mFooBar = v;
+ }
+
+ /**
+ Get foo bar
+ */
+ QString 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( QString::fromLatin1( "Age" ) ))
+ mAge = v;
+ }
+
+ /**
+ Get Age
+ */
+ int age() const
+ {
+ return mAge;
+ }
+
+ protected:
+ QString mParamNumber;
+
+ // Foo
+ QColor mColor;
+
+ // Bar$(Number)
+ QString mFooBar;
+ int mAge;
+
+ private:
+};
+
+#endif
+
diff --git a/kdecore/kconfig_compiler/tests/test6.kcfg b/kdecore/kconfig_compiler/tests/test6.kcfg
new file mode 100644
index 000000000..e59fa88f3
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test6.kcfgc b/kdecore/kconfig_compiler/tests/test6.kcfgc
new file mode 100644
index 000000000..b69dc152d
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test6main.cpp b/kdecore/kconfig_compiler/tests/test6main.cpp
new file mode 100644
index 000000000..a891c097a
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test6main.cpp
@@ -0,0 +1,30 @@
+/*
+Copyright (c) 2004 Waldo Bastian <bastian@kde.org>
+
+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(QString::null);
+ delete t;
+}
diff --git a/kdecore/kconfig_compiler/tests/test7.cpp.ref b/kdecore/kconfig_compiler/tests/test7.cpp.ref
new file mode 100644
index 000000000..8292e31d1
--- /dev/null
+++ b/kdecore/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( QString::fromLatin1( "test7rc" ) )
+ , mParamNumber(Number)
+{
+ setCurrentGroup( QString::fromLatin1( "Foo" ) );
+
+ KConfigSkeleton::ItemColor *itemColor;
+ itemColor = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "color #%1" ).arg( mParamNumber ), mColor, QColor( "red" ) );
+ addItem( itemColor, QString::fromLatin1( "Color" ) );
+
+ setCurrentGroup( QString::fromLatin1( "Bar%1" ).arg( mParamNumber ) );
+
+ KConfigSkeleton::ItemString *itemFooBar;
+ itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), QString::fromLatin1( "foo bar" ), mFooBar );
+ addItem( itemFooBar, QString::fromLatin1( "FooBar" ) );
+ KConfigSkeleton::ItemInt *itemAge;
+ itemAge = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "Age" ), mAge, 35 );
+ itemAge->setMinValue(8);
+ itemAge->setMaxValue(88);
+ addItem( itemAge, QString::fromLatin1( "Age" ) );
+}
+
+Test7::~Test7()
+{
+}
+
diff --git a/kdecore/kconfig_compiler/tests/test7.h.ref b/kdecore/kconfig_compiler/tests/test7.h.ref
new file mode 100644
index 000000000..e8983907d
--- /dev/null
+++ b/kdecore/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 QColor & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "Color" ) ))
+ mColor = v;
+ }
+
+ /**
+ Get Block colors.
+ */
+ QColor color() const
+ {
+ return mColor;
+ }
+
+ /**
+ Set foo bar
+ */
+ void setFooBar( const QString & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "FooBar" ) ))
+ mFooBar = v;
+ }
+
+ /**
+ Get foo bar
+ */
+ QString 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( QString::fromLatin1( "Age" ) ))
+ mAge = v;
+ }
+
+ /**
+ Get Age
+ */
+ int age() const
+ {
+ return mAge;
+ }
+
+ protected:
+ int mParamNumber;
+
+ // Foo
+ QColor mColor;
+
+ // Bar$(Number)
+ QString mFooBar;
+ int mAge;
+
+ private:
+};
+
+#endif
+
diff --git a/kdecore/kconfig_compiler/tests/test7.kcfg b/kdecore/kconfig_compiler/tests/test7.kcfg
new file mode 100644
index 000000000..0a7fd3272
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test7.kcfgc b/kdecore/kconfig_compiler/tests/test7.kcfgc
new file mode 100644
index 000000000..9a6c40954
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test7main.cpp b/kdecore/kconfig_compiler/tests/test7main.cpp
new file mode 100644
index 000000000..9c1ad1931
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test7main.cpp
@@ -0,0 +1,30 @@
+/*
+Copyright (c) 2004 Waldo Bastian <bastian@kde.org>
+
+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/kdecore/kconfig_compiler/tests/test8a.cpp.ref b/kdecore/kconfig_compiler/tests/test8a.cpp.ref
new file mode 100644
index 000000000..868b63438
--- /dev/null
+++ b/kdecore/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( QString::fromLatin1( "Group" ) );
+
+ KConfigSkeleton::ItemFont *itemFont;
+ itemFont = new KConfigSkeleton::ItemFont( currentGroup(), QString::fromLatin1( "Font" ), mFont, KGlobalSettings::generalFont() );
+ addItem( itemFont, QString::fromLatin1( "Font" ) );
+ KConfigSkeleton::ItemFont *itemTitleFont;
+ itemTitleFont = new KConfigSkeleton::ItemFont( currentGroup(), QString::fromLatin1( "TitleFont" ), mTitleFont, KGlobalSettings::windowTitleFont() );
+ addItem( itemTitleFont, QString::fromLatin1( "TitleFont" ) );
+}
+
+Test8a::~Test8a()
+{
+}
+
diff --git a/kdecore/kconfig_compiler/tests/test8a.h.ref b/kdecore/kconfig_compiler/tests/test8a.h.ref
new file mode 100644
index 000000000..6d4f2a00d
--- /dev/null
+++ b/kdecore/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 QFont & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "Font" ) ))
+ mFont = v;
+ }
+
+ /**
+ Get Font
+ */
+ QFont font() const
+ {
+ return mFont;
+ }
+
+ /**
+ Set TitleFont
+ */
+ void setTitleFont( const QFont & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "TitleFont" ) ))
+ mTitleFont = v;
+ }
+
+ /**
+ Get TitleFont
+ */
+ QFont titleFont() const
+ {
+ return mTitleFont;
+ }
+
+ protected:
+
+ // Group
+ QFont mFont;
+ QFont mTitleFont;
+
+ private:
+};
+
+#endif
+
diff --git a/kdecore/kconfig_compiler/tests/test8a.kcfg b/kdecore/kconfig_compiler/tests/test8a.kcfg
new file mode 100644
index 000000000..5ee87199f
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test8a.kcfgc b/kdecore/kconfig_compiler/tests/test8a.kcfgc
new file mode 100644
index 000000000..5f63c31c2
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test8a.kcfgc
@@ -0,0 +1,3 @@
+File=test8a.kcfg
+ClassName=Test8a
+Mutators=true
diff --git a/kdecore/kconfig_compiler/tests/test8b.cpp.ref b/kdecore/kconfig_compiler/tests/test8b.cpp.ref
new file mode 100644
index 000000000..101f2ab6a
--- /dev/null
+++ b/kdecore/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( QString::fromLatin1( "Group8b1" ) );
+
+ KConfigSkeleton::ItemUInt *itemSomething;
+ itemSomething = new KConfigSkeleton::ItemUInt( currentGroup(), QString::fromLatin1( "Something" ), mSomething, 60 );
+ addItem( itemSomething, QString::fromLatin1( "Something" ) );
+
+ setCurrentGroup( QString::fromLatin1( "Group8b2" ) );
+
+ KConfigSkeleton::ItemBool *itemFooBoo;
+ itemFooBoo = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "FooBoo" ), mFooBoo, false );
+ addItem( itemFooBoo, QString::fromLatin1( "FooBoo" ) );
+ KConfigSkeleton::ItemUInt *itemPort;
+ itemPort = new KConfigSkeleton::ItemUInt( currentGroup(), QString::fromLatin1( "Port" ), mPort, 1000 );
+ addItem( itemPort, QString::fromLatin1( "Port" ) );
+}
+
+Test8b::~Test8b()
+{
+ if ( mSelf == this )
+ staticTest8bDeleter.setObject( mSelf, 0, false );
+}
+
diff --git a/kdecore/kconfig_compiler/tests/test8b.h.ref b/kdecore/kconfig_compiler/tests/test8b.h.ref
new file mode 100644
index 000000000..0ee51e3f8
--- /dev/null
+++ b/kdecore/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( QString::fromLatin1( "Something" ) ))
+ self()->mSomething = v;
+ }
+
+ /**
+ Get Something
+ */
+ static
+ uint something()
+ {
+ return self()->mSomething;
+ }
+
+ /**
+ Set FooBoo
+ */
+ static
+ void setFooBoo( bool v )
+ {
+ if (!self()->isImmutable( QString::fromLatin1( "FooBoo" ) ))
+ self()->mFooBoo = v;
+ }
+
+ /**
+ Get FooBoo
+ */
+ static
+ bool fooBoo()
+ {
+ return self()->mFooBoo;
+ }
+
+ /**
+ Set Port
+ */
+ static
+ void setPort( uint v )
+ {
+ if (!self()->isImmutable( QString::fromLatin1( "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/kdecore/kconfig_compiler/tests/test8b.kcfg b/kdecore/kconfig_compiler/tests/test8b.kcfg
new file mode 100644
index 000000000..3e203a155
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test8b.kcfgc b/kdecore/kconfig_compiler/tests/test8b.kcfgc
new file mode 100644
index 000000000..7be055203
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test8main.cpp b/kdecore/kconfig_compiler/tests/test8main.cpp
new file mode 100644
index 000000000..912631f7a
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test8main.cpp
@@ -0,0 +1,34 @@
+/*
+Copyright (c) 2005 Michael Brade <brade@kde.org>
+
+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( QString::null ) );
+ Test8a *config2 = new Test8a();
+ Test8b::self();
+ delete config1;
+ delete config2;
+}
diff --git a/kdecore/kconfig_compiler/tests/test9.cpp.ref b/kdecore/kconfig_compiler/tests/test9.cpp.ref
new file mode 100644
index 000000000..309c1ddbe
--- /dev/null
+++ b/kdecore/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 QString & transport, const QString & folder )
+ : KConfigSkeleton( QString::fromLatin1( "examplerc" ) )
+ , mParamtransport(transport)
+ , mParamfolder(folder)
+{
+ setCurrentGroup( QString::fromLatin1( "MyOptionsXX" ) );
+
+ QStringList defaultMyStringList;
+ defaultMyStringList.append( QString::fromUtf8( "up" ) );
+ defaultMyStringList.append( QString::fromUtf8( "down" ) );
+
+ KConfigSkeleton::ItemStringList *itemMyStringList;
+ itemMyStringList = new KConfigSkeleton::ItemStringList( currentGroup(), QString::fromLatin1( "MyStringList" ), mMyStringList, defaultMyStringList );
+ addItem( itemMyStringList, QString::fromLatin1( "MyStringList" ) );
+ QStringList defaultMyPathList;
+ defaultMyPathList.append( QString::fromUtf8( "/home" ) );
+ defaultMyPathList.append( QString::fromUtf8( "~" ) );
+
+ KConfigSkeleton::ItemPathList *itemMyPathList;
+ itemMyPathList = new KConfigSkeleton::ItemPathList( currentGroup(), QString::fromLatin1( "MyPathList" ), mMyPathList, defaultMyPathList );
+ addItem( itemMyPathList, QString::fromLatin1( "MyPathList" ) );
+ KConfigSkeleton::ItemPathList *itemMyPathsList2;
+ itemMyPathsList2 = new KConfigSkeleton::ItemPathList( currentGroup(), QString::fromLatin1( "MyPathsList2" ), mMyPathsList2, QStringList(QString::fromLatin1("/usr/bin")) += QDir::homeDirPath() );
+ addItem( itemMyPathsList2, QString::fromLatin1( "MyPathsList2" ) );
+}
+
+Test9::~Test9()
+{
+}
+
diff --git a/kdecore/kconfig_compiler/tests/test9.h.ref b/kdecore/kconfig_compiler/tests/test9.h.ref
new file mode 100644
index 000000000..4f3e241fc
--- /dev/null
+++ b/kdecore/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 <qdir.h>
+class Test9 : public KConfigSkeleton
+{
+ public:
+
+ Test9( const QString & transport, const QString & folder );
+ ~Test9();
+
+ /**
+ Set MyStringList
+ */
+ void setMyStringList( const QStringList & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "MyStringList" ) ))
+ mMyStringList = v;
+ }
+
+ /**
+ Get MyStringList
+ */
+ QStringList myStringList() const
+ {
+ return mMyStringList;
+ }
+
+ /**
+ Set This is a list of paths
+ */
+ void setMyPathList( const QStringList & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "MyPathList" ) ))
+ mMyPathList = v;
+ }
+
+ /**
+ Get This is a list of paths
+ */
+ QStringList myPathList() const
+ {
+ return mMyPathList;
+ }
+
+ /**
+ Set This is an additional test for PathList
+ */
+ void setMyPathsList2( const QStringList & v )
+ {
+ if (!isImmutable( QString::fromLatin1( "MyPathsList2" ) ))
+ mMyPathsList2 = v;
+ }
+
+ /**
+ Get This is an additional test for PathList
+ */
+ QStringList myPathsList2() const
+ {
+ return mMyPathsList2;
+ }
+
+ protected:
+ public:
+ QString mParamtransport;
+ QString mParamfolder;
+
+ // MyOptionsXX
+ QStringList mMyStringList;
+ QStringList mMyPathList;
+ QStringList mMyPathsList2;
+
+ private:
+};
+
+#endif
+
diff --git a/kdecore/kconfig_compiler/tests/test9.kcfg b/kdecore/kconfig_compiler/tests/test9.kcfg
new file mode 100644
index 000000000..b7495e2b6
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test9.kcfgc b/kdecore/kconfig_compiler/tests/test9.kcfgc
new file mode 100644
index 000000000..d44233380
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test9.kcfgc
@@ -0,0 +1,18 @@
+# Code generation options for kconfig_compiler
+ClassName=Test9
+#
+# Singleton=false
+#
+# Inherits=KConfigSkeleton
+#
+# IncludeFiles=libkdepim/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/kdecore/kconfig_compiler/tests/test9main.cpp b/kdecore/kconfig_compiler/tests/test9main.cpp
new file mode 100644
index 000000000..3802cd339
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test9main.cpp
@@ -0,0 +1,43 @@
+/*
+Copyright (c) 2005 Helge Deller <deller@kde.org>
+
+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 <qdir.h>
+
+int main( int, char*[] )
+{
+ KInstance i("test");
+ Test9 *t = new Test9( QString::null, QString::null );
+
+ QStringList myPathsList2 = t->myPathsList2();
+ kdWarning() << myPathsList2 << endl;
+
+ // add another path
+ QStringList newlist = QDir::homeDirPath() + QString::fromLatin1("/.kde");
+ myPathsList2 = myPathsList2 + newlist;
+ kdWarning() << myPathsList2 << endl;
+
+ t->setMyPathsList2(myPathsList2);
+ kdWarning() << t->myPathsList2() << endl;
+
+ delete t;
+}
diff --git a/kdecore/kconfig_compiler/tests/test_dpointer.cpp.ref b/kdecore/kconfig_compiler/tests/test_dpointer.cpp.ref
new file mode 100644
index 000000000..e36c50dd0
--- /dev/null
+++ b/kdecore/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;
+ QString archiveFile;
+ int destination;
+
+ // Views
+ int hourSize;
+ bool selectionStartsEditor;
+
+ // KOrganizer Plugins
+ QStringList selectedPlugins;
+
+ // Colors
+ QColor highlightColor;
+ QColor agendaBgColor;
+
+ // Fonts
+ QFont 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( QString::fromLatin1( "korganizerrc" ) )
+{
+ d = new TestDPointerPrivate;
+ mSelf = this;
+ setCurrentGroup( QString::fromLatin1( "General" ) );
+
+ d->autoSaveItem = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "Auto Save" ), d->autoSave, false );
+ d->autoSaveItem->setLabel( i18n("Enable automatic saving of calendar") );
+ d->autoSaveItem->setWhatsThis( i18n("WhatsThis text for AutoSave option") );
+ addItem( d->autoSaveItem, QString::fromLatin1( "AutoSave" ) );
+ d->autoSaveIntervalItem = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "Auto Save Interval" ), d->autoSaveInterval, 10 );
+ d->autoSaveIntervalItem->setLabel( i18n("Auto Save Interval") );
+ addItem( d->autoSaveIntervalItem, QString::fromLatin1( "AutoSaveInterval" ) );
+ d->confirmItem = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "Confirm Deletes" ), d->confirm, true );
+ d->confirmItem->setLabel( i18n("Confirm deletes") );
+ addItem( d->confirmItem, QString::fromLatin1( "Confirm" ) );
+ d->archiveFileItem = new KConfigSkeleton::ItemString( currentGroup(), QString::fromLatin1( "Archive File" ), d->archiveFile );
+ d->archiveFileItem->setLabel( i18n("Archive File") );
+ addItem( d->archiveFileItem, QString::fromLatin1( "ArchiveFile" ) );
+ QValueList<KConfigSkeleton::ItemEnum::Choice> valuesDestination;
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "standardDestination" );
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "askDestination" );
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "argl1" );
+ choice.label = i18n("Argl1 Label");
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "argl2" );
+ choice.whatsThis = i18n("Argl2 Whatsthis");
+ valuesDestination.append( choice );
+ }
+ {
+ KConfigSkeleton::ItemEnum::Choice choice;
+ choice.name = QString::fromLatin1( "argl3" );
+ choice.label = i18n("Argl3 Label");
+ choice.whatsThis = i18n("Argl3 Whatsthis");
+ valuesDestination.append( choice );
+ }
+ d->destinationItem = new KConfigSkeleton::ItemEnum( currentGroup(), QString::fromLatin1( "Destination" ), d->destination, valuesDestination, EnumDestination::standardDestination );
+ d->destinationItem->setLabel( i18n("New Events/Todos Should") );
+ addItem( d->destinationItem, QString::fromLatin1( "Destination" ) );
+
+ setCurrentGroup( QString::fromLatin1( "Views" ) );
+
+ d->hourSizeItem = new KConfigSkeleton::ItemInt( currentGroup(), QString::fromLatin1( "Hour Size" ), d->hourSize, 10 );
+ d->hourSizeItem->setLabel( i18n("Hour Size") );
+ addItem( d->hourSizeItem, QString::fromLatin1( "HourSize" ) );
+ d->selectionStartsEditorItem = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "SelectionStartsEditor" ), d->selectionStartsEditor, false );
+ d->selectionStartsEditorItem->setLabel( i18n("Time range selection in agenda view starts event editor") );
+ addItem( d->selectionStartsEditorItem, QString::fromLatin1( "SelectionStartsEditor" ) );
+
+ setCurrentGroup( QString::fromLatin1( "KOrganizer Plugins" ) );
+
+ QStringList defaultSelectedPlugins;
+ defaultSelectedPlugins.append( QString::fromUtf8( "holidays" ) );
+ defaultSelectedPlugins.append( QString::fromUtf8( "webexport" ) );
+
+ d->selectedPluginsItem = new KConfigSkeleton::ItemStringList( currentGroup(), QString::fromLatin1( "SelectedPlugins" ), d->selectedPlugins, defaultSelectedPlugins );
+ d->selectedPluginsItem->setLabel( i18n("SelectedPlugins") );
+ addItem( d->selectedPluginsItem, QString::fromLatin1( "SelectedPlugins" ) );
+
+ setCurrentGroup( QString::fromLatin1( "Colors" ) );
+
+ d->highlightColorItem = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "Highlight Color" ), d->highlightColor, QColor( 100, 100, 255 ) );
+ d->highlightColorItem->setLabel( i18n("Highlight color") );
+ addItem( d->highlightColorItem, QString::fromLatin1( "HighlightColor" ) );
+ d->agendaBgColorItem = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "Agenda Background Color" ), d->agendaBgColor, QColor( 255, 255, 255 ) );
+ d->agendaBgColorItem->setLabel( i18n("Agenda view background color") );
+ addItem( d->agendaBgColorItem, QString::fromLatin1( "AgendaBgColor" ) );
+
+ setCurrentGroup( QString::fromLatin1( "Fonts" ) );
+
+ d->timeBarFontItem = new KConfigSkeleton::ItemFont( currentGroup(), QString::fromLatin1( "TimeBar Font" ), d->timeBarFont );
+ d->timeBarFontItem->setLabel( i18n("Time bar") );
+ addItem( d->timeBarFontItem, QString::fromLatin1( "TimeBarFont" ) );
+}
+
+void TestDPointer::setAutoSave( bool v )
+{
+ if (!self()->isImmutable( QString::fromLatin1( "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( QString::fromLatin1( "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( QString::fromLatin1( "Confirm" ) ))
+ self()->d->confirm = v;
+}
+
+bool TestDPointer::confirm()
+{
+ return self()->d->confirm;
+}
+
+
+KConfigSkeleton::ItemBool *TestDPointer::confirmItem()
+{
+ return d->confirmItem;
+}
+
+void TestDPointer::setArchiveFile( const QString & v )
+{
+ if (!self()->isImmutable( QString::fromLatin1( "ArchiveFile" ) ))
+ self()->d->archiveFile = v;
+}
+
+QString TestDPointer::archiveFile()
+{
+ return self()->d->archiveFile;
+}
+
+
+KConfigSkeleton::ItemString *TestDPointer::archiveFileItem()
+{
+ return d->archiveFileItem;
+}
+
+void TestDPointer::setDestination( int v )
+{
+ if (!self()->isImmutable( QString::fromLatin1( "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( QString::fromLatin1( "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( QString::fromLatin1( "SelectionStartsEditor" ) ))
+ self()->d->selectionStartsEditor = v;
+}
+
+bool TestDPointer::selectionStartsEditor()
+{
+ return self()->d->selectionStartsEditor;
+}
+
+
+KConfigSkeleton::ItemBool *TestDPointer::selectionStartsEditorItem()
+{
+ return d->selectionStartsEditorItem;
+}
+
+void TestDPointer::setSelectedPlugins( const QStringList & v )
+{
+ if (!self()->isImmutable( QString::fromLatin1( "SelectedPlugins" ) ))
+ self()->d->selectedPlugins = v;
+}
+
+QStringList TestDPointer::selectedPlugins()
+{
+ return self()->d->selectedPlugins;
+}
+
+
+KConfigSkeleton::ItemStringList *TestDPointer::selectedPluginsItem()
+{
+ return d->selectedPluginsItem;
+}
+
+void TestDPointer::setHighlightColor( const QColor & v )
+{
+ if (!self()->isImmutable( QString::fromLatin1( "HighlightColor" ) ))
+ self()->d->highlightColor = v;
+}
+
+QColor TestDPointer::highlightColor()
+{
+ return self()->d->highlightColor;
+}
+
+
+KConfigSkeleton::ItemColor *TestDPointer::highlightColorItem()
+{
+ return d->highlightColorItem;
+}
+
+void TestDPointer::setAgendaBgColor( const QColor & v )
+{
+ if (!self()->isImmutable( QString::fromLatin1( "AgendaBgColor" ) ))
+ self()->d->agendaBgColor = v;
+}
+
+QColor TestDPointer::agendaBgColor()
+{
+ return self()->d->agendaBgColor;
+}
+
+
+KConfigSkeleton::ItemColor *TestDPointer::agendaBgColorItem()
+{
+ return d->agendaBgColorItem;
+}
+
+void TestDPointer::setTimeBarFont( const QFont & v )
+{
+ if (!self()->isImmutable( QString::fromLatin1( "TimeBarFont" ) ))
+ self()->d->timeBarFont = v;
+}
+
+QFont 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/kdecore/kconfig_compiler/tests/test_dpointer.h.ref b/kdecore/kconfig_compiler/tests/test_dpointer.h.ref
new file mode 100644
index 000000000..a8568fc9b
--- /dev/null
+++ b/kdecore/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 QString & v );
+
+ /**
+ Get Archive File
+ */
+ static
+ QString 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 QStringList & v );
+
+ /**
+ Get SelectedPlugins
+ */
+ static
+ QStringList selectedPlugins();
+
+ /**
+ Get Item object corresponding to SelectedPlugins()
+ */
+ ItemStringList *selectedPluginsItem();
+
+ /**
+ Set Highlight color
+ */
+ static
+ void setHighlightColor( const QColor & v );
+
+ /**
+ Get Highlight color
+ */
+ static
+ QColor highlightColor();
+
+ /**
+ Get Item object corresponding to HighlightColor()
+ */
+ ItemColor *highlightColorItem();
+
+ /**
+ Set Agenda view background color
+ */
+ static
+ void setAgendaBgColor( const QColor & v );
+
+ /**
+ Get Agenda view background color
+ */
+ static
+ QColor agendaBgColor();
+
+ /**
+ Get Item object corresponding to AgendaBgColor()
+ */
+ ItemColor *agendaBgColorItem();
+
+ /**
+ Set Time bar
+ */
+ static
+ void setTimeBarFont( const QFont & v );
+
+ /**
+ Get Time bar
+ */
+ static
+ QFont 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/kdecore/kconfig_compiler/tests/test_dpointer.kcfg b/kdecore/kconfig_compiler/tests/test_dpointer.kcfg
new file mode 100644
index 000000000..3b19e270e
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test_dpointer.kcfgc b/kdecore/kconfig_compiler/tests/test_dpointer.kcfgc
new file mode 100644
index 000000000..48baa376e
--- /dev/null
+++ b/kdecore/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/kdecore/kconfig_compiler/tests/test_dpointer_main.cpp b/kdecore/kconfig_compiler/tests/test_dpointer_main.cpp
new file mode 100644
index 000000000..a6c23c8fe
--- /dev/null
+++ b/kdecore/kconfig_compiler/tests/test_dpointer_main.cpp
@@ -0,0 +1,30 @@
+/*
+Copyright (c) 2005 Duncan Mac-Vicar P. <duncan@kde.org>
+
+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;
+}