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

List:       kde-commits
Subject:    kdelibs/kinit
From:       Luboš Luňák <l.lunak () kde ! org>
Date:       2005-03-15 13:22:55
Message-ID: 20050315132255.9C3EC12E73 () office ! kde ! org
[Download RAW message or body]

CVS commit by lunakl: 

Make it possible to also specify a whole group instead of listing many keys.


  M +34 -9     kdostartupconfig.cpp   1.2
  M +6 -0      kstartupconfig.cpp   1.3


--- kdelibs/kinit/kdostartupconfig.cpp  #1.1:1.2
@@ -25,4 +25,6 @@ DEALINGS IN THE SOFTWARE.
 #undef QT_NO_CAST_ASCII
 
+// See description in kstartupconfig.cpp .
+
 #include <qfile.h>
 #include <qtextstream.h>
@@ -90,6 +92,28 @@ int main()
         key = get_entry( &tmp );
         def = get_entry( &tmp );
-        if( file.isEmpty() || group.isEmpty() || key.isEmpty())
+        if( file.isEmpty() || group.isEmpty())
             return 6;
+        if( group.left( 1 ) == "[" && group.right( 1 ) == "]" )
+            { // whole config group
+            KConfig cfg( file );
+            group = group.mid( 1, group.length() - 2 );
+            QMap< QString, QString > entries = cfg.entryMap( group );
+            startupconfig << "# " << line << "\n";
+            for( QMap< QString, QString >::ConstIterator it = entries.begin();
+                 it != entries.end();
+                 ++it )
+                {
+                QString key = it.key();
+                QString value = *it;
+                startupconfig << file.replace( ' ', '_' ).lower()
+                    << "_" << group.replace( ' ', '_' ).lower()
+                    << "_" << key.replace( ' ', '_' ).lower()
+                    << "=\"" << value.replace( "\"", "\\\"" ) << "\"\n";
+                }
+            }
+        else
+            { // a single key
+            if( key.isEmpty())
+                return 7;
         KConfig cfg( file );
         cfg.setGroup( group );
@@ -100,4 +124,5 @@ int main()
             << "_" << key.replace( ' ', '_' ).lower()
             << "=\"" << value.replace( "\"", "\\\"" ) << "\"\n";
+            }
         startupconfigfiles << line << endl;
         // use even currently non-existing paths in $KDEDIRS

--- kdelibs/kinit/kstartupconfig.cpp  #1.2:1.3
@@ -37,4 +37,10 @@ by underscores, everything lowercase). S
 "ksplashrc KSplash Theme Default" may result in "ksplashrc_ksplash_theme=Default".
 
+In order to real a whole group it is possible to use <file> <[group]>, e.g.
+"ksplashrc [KSplash]", which will set shell variables for all keys in the group.
+It is not possible to specify default values, but since the configuration options
+are processed in the order they are specified this can be solved by first
+specifying a group and then all the entries that need default values.
+
 When a kconf_update script is used to update such option, kstartupconfig is run
 before kconf_update and therefore cannot see the change in time. To avoid this


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

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