summaryrefslogtreecommitdiffstats
path: root/korundum/rubylib/rbkconfig_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
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /korundum/rubylib/rbkconfig_compiler
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.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/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'korundum/rubylib/rbkconfig_compiler')
-rw-r--r--korundum/rubylib/rbkconfig_compiler/Makefile.am28
-rw-r--r--korundum/rubylib/rbkconfig_compiler/README.dox251
-rw-r--r--korundum/rubylib/rbkconfig_compiler/TODO1
-rw-r--r--korundum/rubylib/rbkconfig_compiler/autoexample.rb49
-rwxr-xr-xkorundum/rubylib/rbkconfig_compiler/checkkcfg.pl83
-rw-r--r--korundum/rubylib/rbkconfig_compiler/example.kcfg55
-rw-r--r--korundum/rubylib/rbkconfig_compiler/example.rb40
-rw-r--r--korundum/rubylib/rbkconfig_compiler/exampleprefs_base.kcfgc18
-rw-r--r--korundum/rubylib/rbkconfig_compiler/general_base.ui46
-rw-r--r--korundum/rubylib/rbkconfig_compiler/kcfg.xsd191
-rw-r--r--korundum/rubylib/rbkconfig_compiler/myoptions_base.ui35
-rw-r--r--korundum/rubylib/rbkconfig_compiler/rbkconfig_compiler.cpp1330
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/Makefile.am40
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/myprefs.rb5
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test1.kcfg55
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test1.kcfgc18
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test1main.rb4
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test2.kcfg78
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test2.kcfgc11
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test2main.rb5
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test3.kcfg26
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test3.kcfgc12
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test3main.rb4
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test4.kcfg42
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test4.kcfgc11
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test4main.rb4
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test5.kcfg42
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test5.kcfgc11
-rw-r--r--korundum/rubylib/rbkconfig_compiler/tests/test5main.rb4
29 files changed, 2499 insertions, 0 deletions
diff --git a/korundum/rubylib/rbkconfig_compiler/Makefile.am b/korundum/rubylib/rbkconfig_compiler/Makefile.am
new file mode 100644
index 00000000..492c6882
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/Makefile.am
@@ -0,0 +1,28 @@
+SUBDIRS = . tests
+
+RBUIC=rbuic
+
+%.rb: %.ui
+ $(RBUIC) -tr ${UIC_TR} -kde $*.ui -o $@
+
+exampleprefs_base.rb: $(srcdir)/example.kcfg rbkconfig_compiler $(srcdir)/exampleprefs_base.kcfgc
+ ./rbkconfig_compiler $(srcdir)/example.kcfg $(srcdir)/exampleprefs_base.kcfgc
+
+AM_CPPFLAGS = -I$(top_srcdir)/kdecore -I$(top_srcdir) $(all_includes)
+
+bin_PROGRAMS = rbkconfig_compiler
+
+rbkconfig_compiler_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+rbkconfig_compiler_LDADD = $(LIB_KDECORE)
+rbkconfig_compiler_SOURCES = rbkconfig_compiler.cpp
+
+METASOURCES = AUTO
+
+TESTFILES = test1.kcfg test2.kcfg test3.kcfg test4.kcfg test5.kcfg
+
+check-local:
+ for i in $(TESTFILES); \
+ do xmllint --noout --schema $(srcdir)/kcfg.xsd $(srcdir)/tests/$$i; \
+ perl $(top_srcdir)/korundum/rubylib/rbkconfig_compiler/checkkcfg.pl \
+ $(top_srcdir)/korundum/rubylib/rbkconfig_compiler/tests/$$i; done
+
diff --git a/korundum/rubylib/rbkconfig_compiler/README.dox b/korundum/rubylib/rbkconfig_compiler/README.dox
new file mode 100644
index 00000000..97da4dc9
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/README.dox
@@ -0,0 +1,251 @@
+/**
+\page rbkconfig_compiler The KDE Configuration Compiler for Ruby
+
+rbkconfig_compiler generates Ruby 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
+KDE::ConfigSkeleton 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 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 Qt::Variant 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 an Array of Integers. Useful for storing Qt::Splitter
+ 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 ruby expression.
+
+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 Ruby 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:
+
+color_0=#ff0000
+color_1=#00ff00
+color_2=#0000ff
+color_3=#ffff00
+
+The configuration options will be accessible to the application via
+a color(colorIndex) and a
+setColor(colorIndex, v) method.
+
+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 sound(soundEvent) and a
+setSound(soundEvent, v) method.
+
+- Parameterized groups
+
+...STILL TODO...
+
+
+
+
+
+If you have questions or comments please contact Cornelius Schumacher
+<schumacher@kde.org> or Waldo Bastian <bastian@kde.org>
+
+For Ruby specific questions please contact Richard Dale
+<Richard_Dale@tipitina.demon.co.uk>
+*/
diff --git a/korundum/rubylib/rbkconfig_compiler/TODO b/korundum/rubylib/rbkconfig_compiler/TODO
new file mode 100644
index 00000000..db4137ed
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/TODO
@@ -0,0 +1 @@
+- Support linebreaks in whasthis texts in the kcfg file.
diff --git a/korundum/rubylib/rbkconfig_compiler/autoexample.rb b/korundum/rubylib/rbkconfig_compiler/autoexample.rb
new file mode 100644
index 00000000..8526c93d
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/autoexample.rb
@@ -0,0 +1,49 @@
+=begin
+ 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.
+=end
+
+require 'Korundum'
+require 'exampleprefs_base.rb'
+require 'general_base.rb'
+require 'myoptions_base.rb'
+
+ aboutData = KDE::AboutData.new( "example", I18N_NOOP("autoconfig example"), "0.1" )
+ aboutData.addAuthor( "Cornelius Schumacher", nil, "schumacher@kde.org" )
+
+ KDE::CmdLineArgs.init( ARGV, aboutData )
+
+ app = KDE::Application.new
+
+ configSkeleton = ExamplePrefsBase.new( "dummy1", "dummy2" )
+ configSkeleton.readConfig()
+
+ dialog = KDE::ConfigDialog.new( nil, "settings", configSkeleton )
+
+ general = GeneralBase.new(nil)
+ dialog.addPage( general, app.i18n("General"), "General", "" )
+
+ myOptions = MyOptionsBase.new( nil )
+ dialog.addPage( myOptions, app.i18n("MyOptions"), "MyOptions", "" )
+
+ app.mainWidget = dialog
+
+ dialog.show()
+
+ app.exec
diff --git a/korundum/rubylib/rbkconfig_compiler/checkkcfg.pl b/korundum/rubylib/rbkconfig_compiler/checkkcfg.pl
new file mode 100755
index 00000000..2eddbeee
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_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/korundum/rubylib/rbkconfig_compiler/example.kcfg b/korundum/rubylib/rbkconfig_compiler/example.kcfg
new file mode 100644
index 00000000..89d1e646
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/example.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">Qt::Dir.homeDirPath()+".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="Int64" key="List-$(transport)-$(folder)">
+ <label>List Number</label>
+ <default>1</default>
+ </entry>
+ </group>
+</kcfg>
diff --git a/korundum/rubylib/rbkconfig_compiler/example.rb b/korundum/rubylib/rbkconfig_compiler/example.rb
new file mode 100644
index 00000000..d7ef38b1
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/example.rb
@@ -0,0 +1,40 @@
+=begin
+ 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.
+=end
+
+require 'Korundum'
+require 'exampleprefs_base.rb'
+
+ aboutData = KDE::AboutData.new( "example", I18N_NOOP("cfgc example"), "0.1" )
+ aboutData.addAuthor( "Cornelius Schumacher", nil, "schumacher@kde.org" )
+
+ KDE::CmdLineArgs.init( ARGV, aboutData )
+
+ app = KDE::Application.new
+
+ prefs = ExamplePrefsBase.new("Trans1", "Folder2")
+
+ prefs.readConfig()
+
+ prefs.setAnotherOption(17)
+
+
+ qWarning("Another Option = %d" % prefs.anotherOption())
+ qWarning("Another Option2 = %d" % prefs.anotherOption2())
diff --git a/korundum/rubylib/rbkconfig_compiler/exampleprefs_base.kcfgc b/korundum/rubylib/rbkconfig_compiler/exampleprefs_base.kcfgc
new file mode 100644
index 00000000..957ed912
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/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/korundum/rubylib/rbkconfig_compiler/general_base.ui b/korundum/rubylib/rbkconfig_compiler/general_base.ui
new file mode 100644
index 00000000..9b41370c
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/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/korundum/rubylib/rbkconfig_compiler/kcfg.xsd b/korundum/rubylib/rbkconfig_compiler/kcfg.xsd
new file mode 100644
index 00000000..61450d25
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/kcfg.xsd
@@ -0,0 +1,191 @@
+<?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="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/korundum/rubylib/rbkconfig_compiler/myoptions_base.ui b/korundum/rubylib/rbkconfig_compiler/myoptions_base.ui
new file mode 100644
index 00000000..3c0c2e6c
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/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/korundum/rubylib/rbkconfig_compiler/rbkconfig_compiler.cpp b/korundum/rubylib/rbkconfig_compiler/rbkconfig_compiler.cpp
new file mode 100644
index 00000000..6274e4bf
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/rbkconfig_compiler.cpp
@@ -0,0 +1,1330 @@
+// -*- 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;
+QStringList allNames;
+QRegExp *validNameRegexp;
+
+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;
+};
+
+
+static QString varName(const QString &n)
+{
+ QString result = "@"+n;
+ result[1] = result[1].lower();
+ return result;
+}
+
+static QString enumName(const QString &n)
+{
+ QString result = "Enum"+n;
+ result[4] = result[4].upper();
+ return result;
+}
+
+static QString enumValue(const QString &n)
+{
+ QString result = n;
+ result[0] = result[0].upper();
+ return result;
+}
+
+static QString setFunction(const QString &n)
+{
+ QString result = "set"+n;
+ result[3] = result[3].upper();
+ return result;
+}
+
+
+static QString getFunction(const QString &n)
+{
+ QString result = n;
+ result[0] = result[0].lower();
+ 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;
+
+ return quoteString(s);
+
+// 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" && !defaultValue.isEmpty() ) {
+ QTextStream rb( &code, IO_WriteOnly | IO_Append );
+ if (!code.isEmpty())
+ rb << endl;
+
+// rb << " QStringList default" << name << ";" << endl;
+ rb << " default" << name << " = []" << endl;
+ QStringList defaults = QStringList::split( ",", defaultValue );
+ QStringList::ConstIterator it;
+ for( it = defaults.begin(); it != defaults.end(); ++it ) {
+ rb << " default" << name << " << \"" << *it << "\""
+ << endl;
+ }
+ defaultValue = "default" + name;
+
+ } else if ( type == "Color" && !defaultValue.isEmpty() ) {
+ QRegExp colorRe("\\d+,\\s*\\d+,\\s*\\d+");
+ if (colorRe.exactMatch(defaultValue))
+ {
+ defaultValue = "Qt::Color.new( " + defaultValue + " )";
+ }
+ else
+ {
+ defaultValue = "Qt::Color.new( \"" + 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 rb( &code, IO_WriteOnly | IO_Append );
+ if (!code.isEmpty())
+ rb << endl;
+
+ rb << " default" << name << " = []" << endl;
+ QStringList defaults = QStringList::split( ",", defaultValue );
+ QStringList::ConstIterator it;
+ for( it = defaults.begin(); it != defaults.end(); ++it ) {
+ rb << " default" << name << " << " << *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 == "Password" ) return "const QString &";
+ else {
+ kdError() <<"rbkconfig_compiler does not support type \""<< type <<"\""<<endl;
+ return "QString"; //For now, but an assert would be better
+ }
+}
+
+/**
+ Actual Ruby initializer value to give a type.
+*/
+QString rbType( const QString &type )
+{
+ if ( type == "String" ) return "\"\"";
+ else if ( type == "StringList" ) return "[]";
+ else if ( type == "Font" ) return "Qt::Font.new";
+ else if ( type == "Rect" ) return "Qt::Rect.new";
+ else if ( type == "Size" ) return "Qt::Size.new";
+ else if ( type == "Color" ) return "Qt::Color.new";
+ else if ( type == "Point" ) return "Qt::Point.new";
+ else if ( type == "Int" ) return "0";
+ else if ( type == "UInt" ) return "0";
+ else if ( type == "Bool" ) return "false, 42";
+ else if ( type == "Double" ) return "0.0";
+ else if ( type == "DateTime" ) return "Qt::DateTime.new";
+ else if ( type == "Int64" ) return "0";
+ else if ( type == "UInt64" ) return "0";
+ else if ( type == "IntList" ) return "[]";
+ else if ( type == "Enum" ) return "0";
+ else if ( type == "Path" ) return "\"\"";
+ else if ( type == "Password" ) return "\"\"";
+ else {
+ kdError()<<"rbkconfig_compiler does not support type \""<< type <<"\""<<endl;
+ return "nil"; //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 "[]";
+ else if ( type == "Font" ) return "KDE::GlobalSettings.generalFont()";
+ else if ( type == "Rect" ) return "Qt::Rect.new()";
+ else if ( type == "Size" ) return "Qt::Size.new()";
+ else if ( type == "Color" ) return "Qt::Color.new(128, 128, 128)";
+ else if ( type == "Point" ) return "Qt::Point.new()";
+ 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 "Qt::DateTime.new()";
+ else if ( type == "Int64" ) return "0";
+ else if ( type == "UInt64" ) return "0";
+ else if ( type == "IntList" ) return "[]";
+ else if ( type == "Enum" ) return "0";
+ else if ( type == "Path" ) return "\"\""; // Use empty string, not null string!
+ else if ( type == "Password" ) return "\"\""; // Use empty string, not null string!
+ else {
+ kdWarning()<<"Error, rbkconfig_compiler doesn't support the \""<< type <<"\" type!"<<endl;
+ return "String"; //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 itemVar(const CfgEntry *e)
+{
+ if (itemAccessors)
+ return varName( e->name() ) + "Item";
+
+ return "item" + e->name();
+
+}
+
+QString newItem( const QString &type, const QString &name, const QString &key,
+ const QString &defaultValue, const QString &param = QString::null)
+{
+ QString t = "Item" + itemType( type ) +
+ ".new( currentGroup(), " + key + ", " + varName( name ) + param;
+ if ( type == "Enum" ) {
+ t += ".toInt";
+ t += ", values" + name;
+ } else if ( type == "Path" ) {
+ t += ".toString";
+ } else if ( type == "Int64" ) {
+ t += ".toLongLong";
+ } else {
+ t += ".to" + itemType( type );
+ }
+ if ( !defaultValue.isEmpty() ) {
+ t += ", ";
+ if ( type == "String" ) t += defaultValue;
+ else t+= defaultValue;
+ }
+ t += " )";
+
+ return t;
+}
+
+QString addItem( const QString &type, const QString &name, const QString &key,
+ const QString &defaultValue, const QString &param = QString::null,
+ const QString &paramName = QString::null )
+{
+ QString t = "addItem" + itemType( type ) +
+ "( " + key + ", " + varName( name ) + param;
+ if ( type == "Enum" ) t += ", values" + name;
+ if ( !defaultValue.isEmpty() ) {
+ t += ", ";
+ if ( type == "String" ) t += defaultValue;
+ else if ( type == "Enum" ) t += enumValue(defaultValue);
+ else t+= defaultValue;
+ }
+
+ if (!paramName.isNull()) {
+ t += ", \"" + paramName + "\"";
+ }
+
+ 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 QStringList &parameters)
+{
+ QString paramString = group;
+ QString arguments;
+ int i = 0;
+ for( QStringList::ConstIterator it = parameters.begin();
+ it != parameters.end(); ++it)
+ {
+ if (paramString.contains("$("+*it+")"))
+ {
+ i++;
+ paramString.replace("$("+*it+")", "%s");
+ if (i > 1) {
+ arguments += ", ";
+ }
+ arguments += " @param"+*it;
+ }
+ }
+ if (arguments.isEmpty())
+ return "\""+group+"\"";
+
+ if (i == 1) {
+ return "\""+paramString+"\" % "+arguments;
+ } else {
+ return "\""+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=itemVar(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;
+}
+
+int main( int argc, char **argv )
+{
+ KAboutData aboutData( "rbkconfig_compiler", I18N_NOOP("KDE .kcfg compiler"), "0.3",
+ I18N_NOOP("Ruby 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( "Richard Dale", "Ruby port",
+ "Richard_Dale@tipitina.demon.co.uk", "" );
+
+ 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 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 );
+
+ 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;
+ QStringList 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" ) {
+ parameters.append( e2.attribute( "name" ) );
+ }
+ }
+
+ } 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 = "KDE::ConfigSkeleton";
+
+ 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 ( singleton && cfgFileNameArg)
+ {
+ kdError() << "Singleton class can not use filename as argument." << 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 implementationFileName = baseName + ".rb";
+
+ QFile implementation( baseDir + implementationFileName );
+ if ( !implementation.open( IO_WriteOnly ) ) {
+ kdError() << "Can't open '" << implementationFileName << "for writing." << endl;
+ return 1;
+ }
+
+ QTextStream rb( &implementation );
+
+ rb << "# This file is generated by rbkconfig_compiler from " << args->url(0).fileName() << "." << endl;
+ rb << "# All changes you do to this file will be lost." << endl;
+ rb << endl << "require 'Korundum'" << endl;
+
+ if (singleton) {
+ rb << "require 'singleton'" << endl;
+ }
+
+ rb << endl;
+
+// rb << "#ifndef " << ( !nameSpace.isEmpty() ? nameSpace.upper() + "_" : "" )
+// << className.upper() << "_H" << endl;
+// rb << "#define " << ( !nameSpace.isEmpty() ? nameSpace.upper() + "_" : "" )
+// << className.upper() << "_H" << endl << endl;
+
+ // Includes
+// QStringList::ConstIterator it;
+// for( it = headerIncludes.begin(); it != headerIncludes.end(); ++it ) {
+// rb << "#include <" << *it << ">" << endl;
+// }
+
+ if ( headerIncludes.count() > 0 ) rb << endl;
+
+// rb << "#include <kconfigskeleton.h>" << endl << endl;
+
+ if ( !nameSpace.isEmpty() )
+ rb << "module " << nameSpace << endl << endl;
+
+ // Class declaration header
+ rb << "class " << className << " < " << inherits << endl;
+
+ if (singleton) {
+ rb << " include Singleton" << endl << 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 ) {
+ if (globalEnums) {
+ values.append( enumValue((*itChoice).name) );
+ } else {
+ values.append( enumName(e->name()) + "_" + (*itChoice).name );
+ }
+ }
+ if (!globalEnums) {
+ values.append( enumName(e->name()) + "_COUNT" );
+ }
+ int count = 0;
+ for ( QStringList::Iterator it = values.begin(); it != values.end(); ++it, count++ ) {
+ rb << " " << *it << " = " << count << endl;
+ }
+ rb << endl;
+ }
+
+ QStringList values = e->paramValues();
+ if ( !values.isEmpty() ) {
+ int count = 0;
+ for ( QStringList::Iterator it = values.begin(); it != values.end(); ++it, count++ ) {
+ if (globalEnums) {
+ rb << " " << enumValue(*it) << " = " << count << endl;
+ } else {
+ rb << " " << enumName(e->param()) << "_" << *it << " = " << count << endl;
+ }
+ }
+ if (!globalEnums) {
+ rb << " " << enumName(e->param()) << "_COUNT = " << count << endl;
+ }
+ rb << endl;
+
+ rb << " def " << enumName(e->param()) << "ToString(i)" << endl;
+ rb << " [";
+ count = 0;
+ for ( QStringList::Iterator it = values.begin(); it != values.end(); ++it, count++ ) {
+ if (count > 0) {
+ rb << ", ";
+ }
+
+ rb << "\"" << *it << "\"";
+ }
+
+ rb << "].at(i)" << endl;
+ rb << " end" << endl;
+ }
+ }
+
+ rb << endl;
+
+ for( e = entries.first(); e; e = entries.next() ) {
+ QString n = e->name();
+ QString t = e->type();
+
+ // Manipulator
+ if (allMutators || mutators.contains(n))
+ {
+ rb << " #" << endl;
+ rb << " # Set " << e->label() << endl;
+ rb << " #" << endl;
+ rb << " def " << setFunction(n) << "( ";
+ if (!e->param().isEmpty())
+ rb << " i, ";
+ rb << " v )" << endl;
+ rb << " item = findItem( \"";
+ if (!e->param().isEmpty()) {
+ rb << e->paramName().replace("$("+e->param()+")", "%s") << "\" % ";
+ if ( e->paramType() == "Enum" ) {
+ rb << " ";
+ if (globalEnums)
+ rb << enumName(e->param()) << "ToString(i)";
+ else
+ rb << enumName(e->param()) << "ToString(i)";
+ } else {
+ rb << "i";
+ }
+ } else {
+ rb << n << "\"";
+ }
+ rb << " )" << endl;
+ rb << " if !item.immutable? " << endl;
+ rb << " item.property = " << varName(n);
+ if (!e->param().isEmpty())
+ rb << "[i]";
+ rb << " = Qt::Variant.new( v )" << endl;
+ rb << " end" << endl;
+ rb << " end" << endl << endl;
+ }
+
+ // Accessor
+ rb << " #" << endl;
+ rb << " # Get " << e->label() << endl;
+ rb << " #" << endl;
+ rb << " def " << getFunction(n) << "(";
+ if (!e->param().isEmpty())
+ rb << " " <<" i ";
+ rb << ")" << endl;
+ rb << " " << varName(n);
+ if (!e->param().isEmpty()) rb << "[i]";
+ rb << " = findItem( \"";
+ if (!e->param().isEmpty()) {
+ rb << e->paramName().replace("$("+e->param()+")", "%s") << "\" % ";
+ if ( e->paramType() == "Enum" ) {
+ rb << " ";
+ if (globalEnums)
+ rb << enumName(e->param()) << "ToString(i)";
+ else
+ rb << enumName(e->param()) << "ToString(i)";
+ } else {
+ rb << "i";
+ }
+ } else {
+ rb << n << "\"";
+ }
+ rb << " ).property" << endl;
+ rb << " return " << varName(n);
+ if (!e->param().isEmpty()) rb << "[i]";
+ if ( e->type() == "Enum" ) {
+ rb << ".toInt" << endl;
+ } else if ( e->type() == "Int64" ) {
+ rb << ".toLongLong" << endl;
+ } else if ( e->type() == "Path" ) {
+ rb << ".toString" << endl;
+ } else {
+ rb << ".to" << itemType( e->type() ) << endl;
+ }
+ rb << " end" << endl;
+
+ // Item accessor
+ if ( itemAccessors ) {
+ rb << endl;
+ rb << " #" << endl;
+ rb << " # Get Item object corresponding to " << n << "()"
+ << endl;
+ rb << " #" << endl;
+ rb << " def "
+ << getFunction( n ) << "Item(";
+ if (!e->param().isEmpty()) {
+ rb << " " << " i ";
+ }
+ rb << ")" << endl;
+ rb << " return " << itemVar(e);
+ if (!e->param().isEmpty()) rb << "[i]";
+ rb << endl << " end" << endl;
+ }
+
+ rb << endl;
+ }
+
+
+ if (customAddons)
+ {
+ rb << " # Include custom additions" << endl;
+ }
+
+
+ // Constructor
+ rb << " def initialize( ";
+ if (cfgFileNameArg)
+ rb << " config" << (parameters.isEmpty() ? " " : ", ");
+ for (QStringList::ConstIterator it = parameters.begin();
+ it != parameters.end(); ++it)
+ {
+ if (it != parameters.begin())
+ rb << ",";
+ rb << " " << *it;
+ }
+ rb << " )" << endl;
+
+ rb << " super(";
+ if ( !cfgFileName.isEmpty() ) rb << " \"" << cfgFileName << "\" ";
+ if ( cfgFileNameArg ) rb << " config ";
+// if ( !cfgFileName.isEmpty() ) rb << ") ";
+ rb << ")" << endl;
+
+ // Store parameters
+ for (QStringList::ConstIterator it = parameters.begin();
+ it != parameters.end(); ++it)
+ {
+ rb << " @param" << *it << " = Qt::Variant.new( " << *it << " )" << endl;
+ }
+
+ QString group;
+ for( e = entries.first(); e; e = entries.next() ) {
+ if ( e->group() != group ) {
+ group = e->group();
+ rb << endl;
+ rb << " # " << group << endl;
+ }
+ if (e->param().isEmpty()) {
+ rb << " " << varName(e->name()) << " = Qt::Variant.new( " << rbType(e->type()) << " )";
+ } else {
+ rb << " " << varName(e->name()) << " = [ ";
+ for (int i = 0; i < e->paramMax()+1; i++) {
+ if (i > 0) {
+ rb << ", ";
+ }
+ rb << "Qt::Variant.new( " << rbType(e->type()) << " )";
+ }
+ rb << " ]";
+ }
+ rb << endl;
+ }
+
+ rb << endl;
+
+
+ group = QString::null;
+ for( e = entries.first(); e; e = entries.next() ) {
+ if ( e->group() != group ) {
+ if ( !group.isEmpty() ) rb << endl;
+ group = e->group();
+ rb << " setCurrentGroup( " << paramString(group, parameters) << " )" << endl << endl;
+ }
+
+ QString key = paramString(e->key(), parameters);
+ if ( !e->code().isEmpty())
+ {
+ rb << e->code() << endl;
+ }
+ if ( e->type() == "Enum" ) {
+ rb << " values"
+ << e->name() << " = []" << endl;
+ QValueList<CfgEntry::Choice> choices = e->choices();
+ QValueList<CfgEntry::Choice>::ConstIterator it;
+ for( it = choices.begin(); it != choices.end(); ++it ) {
+ rb << " choice = ItemEnum::Choice.new" << endl;
+ rb << " choice.name = \"" << enumValue((*it).name) << "\" " << endl;
+ if ( setUserTexts ) {
+ if ( !(*it).label.isEmpty() )
+ rb << " choice.label = i18n(" << quoteString((*it).label) << ")" << endl;
+ if ( !(*it).whatsThis.isEmpty() )
+ rb << " choice.whatsThis = i18n(" << quoteString((*it).whatsThis) << ")" << endl;
+ }
+ rb << " values" << e->name() << " << choice" << endl;
+ }
+ }
+
+ if (e->param().isEmpty())
+ {
+ // Normal case
+ rb << " " << itemVar(e) << " = "
+ << newItem( e->type(), e->name(), key, e->defaultValue() ) << endl;
+
+ rb << " " << itemVar(e) << ".property = " << varName(e->name()) << endl;
+
+ if ( !e->minValue().isEmpty() )
+ rb << " " << itemVar(e) << ".setMinValue(" << e->minValue() << ")" << endl;
+ if ( !e->maxValue().isEmpty() )
+ rb << " " << itemVar(e) << ".setMaxValue(" << e->maxValue() << ")" << endl;
+
+ if ( setUserTexts )
+ rb << userTextsFunctions( e );
+
+ rb << " addItem( " << itemVar(e);
+ QString quotedName = e->name();
+ addQuotes( quotedName );
+ if ( quotedName != key ) rb << ", \"" << e->name() << "\"";
+ rb << " )" << endl;
+ }
+ else
+ {
+ // Indexed
+ rb << " " << itemVar(e) << " = Array.new(" << e->paramMax()+1 << ")" << endl;
+ for(int i = 0; i <= e->paramMax(); i++)
+ {
+ QString defaultStr;
+ QString itemVarStr(itemVar(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() );
+
+ rb << " " << itemVarStr << " = "
+ << newItem( e->type(), e->name(), paramString(key, e, i), defaultStr, QString("[%1]").arg(i) )
+ << endl;
+
+ rb << " " << itemVarStr << ".property = " << varName(e->name())+QString("[%1]").arg(i) << endl;
+
+ if ( setUserTexts )
+ rb << 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!.
+ rb << " addItem( " << itemVarStr << ", \"";
+ if ( e->paramType()=="Enum" )
+ rb << e->paramName().replace( "$("+e->param()+")", "%1").arg(e->paramValues()[i] );
+ else
+ rb << e->paramName().replace( "$("+e->param()+")", "%1").arg(i);
+ rb << "\" )" << endl;
+
+ }
+ }
+ }
+
+ rb << " end" << endl << endl;
+
+ rb << "end" << endl << endl;
+
+ if ( !nameSpace.isEmpty() ) rb << "end" << endl << endl;
+
+ implementation.close();
+}
diff --git a/korundum/rubylib/rbkconfig_compiler/tests/Makefile.am b/korundum/rubylib/rbkconfig_compiler/tests/Makefile.am
new file mode 100644
index 00000000..ce61f658
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/tests/Makefile.am
@@ -0,0 +1,40 @@
+check_PROGRAMS = test1 test2 test3 test4 test5
+
+CLEANFILES = test1.rb \
+ test2.rb \
+ test3.rb \
+ test4.rb \
+ test5.rb \
+ md5sums
+
+all: $(SOURCES)
+
+# Splitting this with backslashses produces broken Makefiles
+SOURCES = test1main.rb test1.rb test2main.rb test2.rb test3main.rb test3.rb test4main.rb test4.rb test5main.rb test5.rb
+
+# avoid running the below command in parallel
+test1.rb: $(srcdir)/test1.kcfg ../rbkconfig_compiler $(srcdir)/test1.kcfgc
+ ../rbkconfig_compiler $(srcdir)/test1.kcfg $(srcdir)/test1.kcfgc
+
+# avoid running the below command in parallel
+test2.rb: $(srcdir)/test2.kcfg ../rbkconfig_compiler $(srcdir)/test2.kcfgc
+ ../rbkconfig_compiler $(srcdir)/test2.kcfg $(srcdir)/test2.kcfgc
+
+# avoid running the below command in parallel
+test3.rb: $(srcdir)/test3.kcfg ../rbkconfig_compiler $(srcdir)/test3.kcfgc
+ ../rbkconfig_compiler $(srcdir)/test3.kcfg $(srcdir)/test3.kcfgc
+
+# avoid running the below command in parallel
+test4.rb: $(srcdir)/test4.kcfg ../rbkconfig_compiler $(srcdir)/test4.kcfgc
+ ../rbkconfig_compiler $(srcdir)/test4.kcfg $(srcdir)/test4.kcfgc
+
+# avoid running the below command in parallel
+test5.rb: $(srcdir)/test5.kcfg ../rbkconfig_compiler $(srcdir)/test5.kcfgc
+ ../rbkconfig_compiler $(srcdir)/test5.kcfg $(srcdir)/test5.kcfgc
+
+md5sums:
+ $(MD5SUM) $(srcdir)/test*.ref | sed -e "s,$(srcdir)/,,; s,\.ref$$,," > md5sums
+
+md5check: test1.rb test2.rb test3.rb test4.rb test5.rb md5sums
+ $(MD5SUM) --check md5sums
+
diff --git a/korundum/rubylib/rbkconfig_compiler/tests/myprefs.rb b/korundum/rubylib/rbkconfig_compiler/tests/myprefs.rb
new file mode 100644
index 00000000..a4f1f082
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/tests/myprefs.rb
@@ -0,0 +1,5 @@
+class MyPrefs < KDE::ConfigSkeleton
+ def initialize( a )
+ super( a )
+ end
+end
diff --git a/korundum/rubylib/rbkconfig_compiler/tests/test1.kcfg b/korundum/rubylib/rbkconfig_compiler/tests/test1.kcfg
new file mode 100644
index 00000000..0c0c8216
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_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">Qt::Dir.homeDirPath()+".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/korundum/rubylib/rbkconfig_compiler/tests/test1.kcfgc b/korundum/rubylib/rbkconfig_compiler/tests/test1.kcfgc
new file mode 100644
index 00000000..6e0edd36
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_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/korundum/rubylib/rbkconfig_compiler/tests/test1main.rb b/korundum/rubylib/rbkconfig_compiler/tests/test1main.rb
new file mode 100644
index 00000000..88a151a6
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/tests/test1main.rb
@@ -0,0 +1,4 @@
+require 'Korundum'
+require 'test1.rb'
+
+t = Test1.new(nil, nil)
diff --git a/korundum/rubylib/rbkconfig_compiler/tests/test2.kcfg b/korundum/rubylib/rbkconfig_compiler/tests/test2.kcfg
new file mode 100644
index 00000000..3b19e270
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_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/korundum/rubylib/rbkconfig_compiler/tests/test2.kcfgc b/korundum/rubylib/rbkconfig_compiler/tests/test2.kcfgc
new file mode 100644
index 00000000..56620d2f
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_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/korundum/rubylib/rbkconfig_compiler/tests/test2main.rb b/korundum/rubylib/rbkconfig_compiler/tests/test2main.rb
new file mode 100644
index 00000000..85d18f07
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/tests/test2main.rb
@@ -0,0 +1,5 @@
+require 'Korundum'
+require 'myprefs.rb'
+require 'test2.rb'
+
+t = Test2.new()
diff --git a/korundum/rubylib/rbkconfig_compiler/tests/test3.kcfg b/korundum/rubylib/rbkconfig_compiler/tests/test3.kcfg
new file mode 100644
index 00000000..77916da4
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_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/korundum/rubylib/rbkconfig_compiler/tests/test3.kcfgc b/korundum/rubylib/rbkconfig_compiler/tests/test3.kcfgc
new file mode 100644
index 00000000..ca2c2205
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_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/korundum/rubylib/rbkconfig_compiler/tests/test3main.rb b/korundum/rubylib/rbkconfig_compiler/tests/test3main.rb
new file mode 100644
index 00000000..8c19b442
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/tests/test3main.rb
@@ -0,0 +1,4 @@
+require 'Korundum'
+require 'test3.rb'
+
+t = TestNameSpace::Test3.new()
diff --git a/korundum/rubylib/rbkconfig_compiler/tests/test4.kcfg b/korundum/rubylib/rbkconfig_compiler/tests/test4.kcfg
new file mode 100644
index 00000000..1428bc0d
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_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>defaultColor = [ 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/korundum/rubylib/rbkconfig_compiler/tests/test4.kcfgc b/korundum/rubylib/rbkconfig_compiler/tests/test4.kcfgc
new file mode 100644
index 00000000..754706df
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_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/korundum/rubylib/rbkconfig_compiler/tests/test4main.rb b/korundum/rubylib/rbkconfig_compiler/tests/test4main.rb
new file mode 100644
index 00000000..c75f0995
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/tests/test4main.rb
@@ -0,0 +1,4 @@
+require 'Korundum'
+require 'test4.rb'
+
+t = Test4.instance()
diff --git a/korundum/rubylib/rbkconfig_compiler/tests/test5.kcfg b/korundum/rubylib/rbkconfig_compiler/tests/test5.kcfg
new file mode 100644
index 00000000..1428bc0d
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_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>defaultColor = [ 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/korundum/rubylib/rbkconfig_compiler/tests/test5.kcfgc b/korundum/rubylib/rbkconfig_compiler/tests/test5.kcfgc
new file mode 100644
index 00000000..663005e5
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_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/korundum/rubylib/rbkconfig_compiler/tests/test5main.rb b/korundum/rubylib/rbkconfig_compiler/tests/test5main.rb
new file mode 100644
index 00000000..cd0fbeb7
--- /dev/null
+++ b/korundum/rubylib/rbkconfig_compiler/tests/test5main.rb
@@ -0,0 +1,4 @@
+require 'Korundum'
+require 'test5.rb'
+
+t = Test5.instance()