[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: KConfig XT / kconfig_compiler
From:       "Stefan Nikolaus" <stefan.nikolaus () stuco ! uni-oldenburg ! de>
Date:       2004-11-29 21:09:51
Message-ID: opsh8vqprgpowx5f () stahl ! stuco ! uni-oldenburg ! de
[Download RAW message or body]

Am Mon, 29 Nov 2004 17:50:25 +0100 hat Stefan Nikolaus  
<stefan.nikolaus@stuco.uni-oldenburg.de> geschrieben:
> What about defining default values for the parameters passed to the  
> configuration object. Some of the member functions already define  
> default group names.
> For each member function that takes a variable group name, we define a  
> parameter and a corresponding group in the .kcfg file.
>
> For example:
>
> <kcfgfile arg="true">
>    <parameter name="ConfigGroup1">
>      <default>KMainWindow</default>
>    </parameter>
>    <parameter name="ConfigGroup2">
>      <default>MainToolbar</default>
>    </parameter>
> </kcfgfile>
>
> <group name="$(ConfigGroup1)">
>    ... <!-- e.g. entries handled by  
> KMainWindow::saveMainWindowSettings(...) -->
> </group>
> <group name="$(ConfigGroup2)">
>    ... <!-- e.g. entries handled by KToolbar::saveSettings(...) -->
> </group>
>
> If no parameter is passed to the configuration object, it works on the  
> default group. If we want to let it work on a special group, we pass the  
> corresponding parameter. In order to set the second parameter, for  
> example, without affecting the first, QString:null can be interpreted as  
> default value. That should be possible. The advantage is exactly one  
> configuration object. The disadvantage is that several parameters may  
> have to be passed. It may become confusing which parameter affects which  
> group.

I thought about something like this...

Of course the XML schema has to be adjusted.

Regards,
Stefan


-- 
Stefan Nikolaus
["kcc_pd.patch" (kcc_pd.patch)]

===================================================================
RCS file: /home/kde/kdelibs/kdecore/kconfig_compiler/kconfig_compiler.cpp,v
retrieving revision 1.57
diff -U3 -r1.57 kconfig_compiler.cpp
--- kconfig_compiler.cpp	24 Nov 2004 16:25:52 -0000	1.57
+++ kconfig_compiler.cpp	29 Nov 2004 20:59:21 -0000
@@ -847,6 +847,7 @@
   QString cfgFileName;
   bool cfgFileNameArg = false;
   QStringList parameters;
+  QStringList parameterDefaults;
   QStringList includes;
 
   QPtrList<CfgEntry> entries;
@@ -871,6 +872,11 @@
         QDomElement e2 = n2.toElement();
         if ( e2.tagName() == "parameter" ) {
           parameters.append( e2.attribute( "name" ) );
+          if ( e2.firstChild().toElement().tagName() == "default" ) {
+            parameterDefaults.append( e2.firstChild().toElement().text() );
+          }
+          else
+            parameterDefaults.append( QString::null );
         }
       }
 
@@ -1020,6 +1026,10 @@
        if (it != parameters.begin())
          h << ",";
        h << " const QString &" << *it;
+       QString parameterDefaultValue = parameterDefaults[ parameters.findIndex( *it \
) ]; +       if ( !parameterDefaultValue.isNull() ) {
+         h << " = \"" << parameterDefaultValue << "\"";
+       }
     }
     h << " );" << endl;
   } else {
@@ -1264,6 +1274,19 @@
   if ( singleton )
     cpp << "  mSelf = this;" << endl;
 
+  bool appendNewLine = false;
+  for (QStringList::ConstIterator it = parameters.begin();
+       it != parameters.end(); ++it)
+  {
+    QString parameterDefaultValue = parameterDefaults[ parameters.findIndex( *it ) \
]; +    if ( !parameterDefaultValue.isNull() ) {
+      cpp << "  if ( mParam" << *it << ".isNull() ) mParam" << *it << " = \
QString(\"" << parameterDefaultValue << "\");" << endl; +      appendNewLine = true;
+    }
+  }
+  if ( appendNewLine )
+    cpp << endl;
+  
   group = QString::null;
   for( e = entries.first(); e; e = entries.next() ) {
     if ( e->group() != group ) {



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic