aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOswald Buddenhagen <ossi@kde.org>2008-06-22 08:46:02 +0000
committerAleix Pol <aleixpol@kde.org>2014-04-26 14:11:15 +0200
commitf1e2568213da1e6bf20d0747033aba0f9bf50cc3 (patch)
treebe3fd7967fb4c1ae4fd8cd6a63c8669acdae2202 /src
parentafee0bd96b333a1e1fbc0f5b1a7ce1e4167cb8d2 (diff)
downloadkconfig-f1e2568213da1e6bf20d0747033aba0f9bf50cc3.tar.gz
kconfig-f1e2568213da1e6bf20d0747033aba0f9bf50cc3.tar.bz2
support nested groups.
svn path=/trunk/KDE/kdebase/runtime/; revision=822957
Diffstat (limited to 'src')
-rw-r--r--src/kreadconfig/kreadconfig.cpp8
-rw-r--r--src/kreadconfig/kwriteconfig.cpp8
2 files changed, 10 insertions, 6 deletions
diff --git a/src/kreadconfig/kreadconfig.cpp b/src/kreadconfig/kreadconfig.cpp
index 915c0967..83ed0a8e 100644
--- a/src/kreadconfig/kreadconfig.cpp
+++ b/src/kreadconfig/kreadconfig.cpp
@@ -44,14 +44,14 @@ int main(int argc, char **argv)
KCmdLineOptions options;
options.add("file <file>", ki18n("Use <file> instead of global config"));
- options.add("group <group>", ki18n("Group to look in"), "KDE");
+ options.add("group <group>", ki18n("Group to look in. Use repeatedly for nested groups."), "KDE");
options.add("key <key>", ki18n("Key to look for"));
options.add("default <default>", ki18n("Default value"));
options.add("type <type>", ki18n("Type of variable"));
KCmdLineArgs::addCmdLineOptions(options);
KCmdLineArgs *args=KCmdLineArgs::parsedArgs();
- QString group=args->getOption("group");
+ QStringList groups=args->getOptionList("group");
QString key=args->getOption("key");
QString file=args->getOption("file");
QString dflt=args->getOption("default");
@@ -74,7 +74,9 @@ int main(int argc, char **argv)
konfig = new KConfig( file, KConfig::NoGlobals );
configMustDeleted=true;
}
- KConfigGroup cfgGroup = konfig->group(group);
+ KConfigGroup cfgGroup = konfig->group("");
+ foreach (const QString &grp, groups)
+ cfgGroup = cfgGroup.group(grp);
if(type=="bool") {
dflt=dflt.toLower();
bool def=(dflt=="true" || dflt=="on" || dflt=="yes" || dflt=="1");
diff --git a/src/kreadconfig/kwriteconfig.cpp b/src/kreadconfig/kwriteconfig.cpp
index 2a3be11a..b226be53 100644
--- a/src/kreadconfig/kwriteconfig.cpp
+++ b/src/kreadconfig/kwriteconfig.cpp
@@ -29,14 +29,14 @@ int main(int argc, char **argv)
KCmdLineOptions options;
options.add("file <file>", ki18n("Use <file> instead of global config"));
- options.add("group <group>", ki18n("Group to look in"), "KDE");
+ options.add("group <group>", ki18n("Group to look in. Use repeatedly for nested groups."), "KDE");
options.add("key <key>", ki18n("Key to look for"));
options.add("type <type>", ki18n("Type of variable. Use \"bool\" for a boolean, otherwise it is treated as a string"));
options.add("+value", ki18n( "The value to write. Mandatory, on a shell use '' for empty" ));
KCmdLineArgs::addCmdLineOptions(options);
KCmdLineArgs *args=KCmdLineArgs::parsedArgs();
- QString group=args->getOption("group");
+ QStringList groups=args->getOptionList("group");
QString key=args->getOption("key");
QString file=args->getOption("file");
QString type=args->getOption("type").toLower();
@@ -56,7 +56,9 @@ int main(int argc, char **argv)
else
konfig = new KConfig( file, KConfig::NoGlobals );
- KConfigGroup cfgGroup = konfig->group(group);
+ KConfigGroup cfgGroup = konfig->group("");
+ foreach (const QString &grp, groups)
+ cfgGroup = cfgGroup.group(grp);
if ( konfig->accessMode() != KConfig::ReadWrite || cfgGroup.isEntryImmutable( key ) ) return 2;
if(type=="bool") {