mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
kreadconfig: optimizations
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
a0b92ba949
commit
04d7b0c309
2 changed files with 16 additions and 10 deletions
|
@ -100,21 +100,24 @@ int main(int argc, char **argv)
|
|||
KConfigGroup cfgGroup = konfig->group("");
|
||||
foreach (const QString &grp, groups) {
|
||||
cfgGroup = cfgGroup.group(grp);
|
||||
if (type == "bool") {
|
||||
if (type == QLatin1String("bool")) {
|
||||
dflt = dflt.toLower();
|
||||
bool def= (dflt == "true" || dflt == "on" || dflt == "yes" || dflt == "1");
|
||||
bool def = (
|
||||
dflt == QLatin1String("true") || dflt == QLatin1String("on")
|
||||
|| dflt == QLatin1String("yes") || dflt == QLatin1String("1")
|
||||
);
|
||||
bool retValue = !cfgGroup.readEntry(key, def);
|
||||
if (configMustDeleted) {
|
||||
delete konfig;
|
||||
}
|
||||
return retValue;
|
||||
} else if (type=="num" || type == "int") {
|
||||
} else if (type == QLatin1String("num") || type == QLatin1String("int")) {
|
||||
int retValue = cfgGroup.readEntry(key, dflt.toInt());
|
||||
if (configMustDeleted) {
|
||||
delete konfig;
|
||||
}
|
||||
return retValue;
|
||||
} else if (type == "path"){
|
||||
} else if (type == QLatin1String("path")) {
|
||||
fprintf(stdout, "%s\n", cfgGroup.readPathEntry(key, dflt).toLocal8Bit().data());
|
||||
if (configMustDeleted) {
|
||||
delete konfig;
|
||||
|
|
|
@ -63,7 +63,7 @@ int main(int argc, char **argv)
|
|||
KCmdLineArgs::usage();
|
||||
return 1;
|
||||
}
|
||||
QByteArray value = args->arg(0).toLocal8Bit();
|
||||
QString value = args->arg(0);
|
||||
|
||||
KComponentData inst(&aboutData);
|
||||
|
||||
|
@ -81,14 +81,17 @@ int main(int argc, char **argv)
|
|||
return 2;
|
||||
}
|
||||
|
||||
if (type == "bool") {
|
||||
if (type == QLatin1String("bool")) {
|
||||
// For symetry with kreadconfig accept a wider range of values as true than Katie
|
||||
bool boolvalue = (value == "true" || value == "on" || value == "yes" || value=="1");
|
||||
bool boolvalue = (
|
||||
value == QLatin1String("true") || value == QLatin1String("on")
|
||||
|| value == QLatin1String("yes") || value == QLatin1String("1")
|
||||
);
|
||||
cfgGroup.writeEntry(key, boolvalue);
|
||||
} else if (type == "path") {
|
||||
cfgGroup.writePathEntry(key, QString::fromLocal8Bit(value));
|
||||
} else if (type == QLatin1String("path")) {
|
||||
cfgGroup.writePathEntry(key, value);
|
||||
} else {
|
||||
cfgGroup.writeEntry(key, QString::fromLocal8Bit(value));
|
||||
cfgGroup.writeEntry(key, value);
|
||||
}
|
||||
konfig->sync();
|
||||
delete konfig;
|
||||
|
|
Loading…
Add table
Reference in a new issue