default implementation for saveState so that saving to random files works even if nobody implements saveState

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=755693
This commit is contained in:
Aaron J. Seigo 2008-01-02 02:05:47 +00:00
parent add3c7eacd
commit 11d08f34b3

View File

@ -369,6 +369,22 @@ public:
return mainConfig;
}
void copyEntries(KConfigGroup *source, KConfigGroup *destination)
{
foreach (const QString &group, source->groupList()) {
KConfigGroup subSource(source, group);
KConfigGroup subDest(destination, group);
copyEntries(&subSource, &subDest);
}
QMap<QString, QString> entries = source->entryMap();
QMapIterator<QString, QString> it(entries);
while (it.hasNext()) {
it.next();
destination->writeEntry(it.key(), it.value());
}
}
//TODO: examine the usage of memory here; there's a pretty large
// number of members at this point.
uint appletId;
@ -455,11 +471,19 @@ void Applet::save(KConfigGroup* group) const
}
KConfigGroup appletConfigGroup(group, "Configuration");
//FIXME: we need a global save state too
saveState(&appletConfigGroup);
}
void Applet::saveState(KConfigGroup* group) const
{
if (group->config()->name() != config().config()->name()) {
// we're being saved to a different file!
// let's just copy the current values in our configuration over
KConfigGroup c = config();
d->copyEntries(&c, group);
}
Q_UNUSED(group)
}