reconstruct an hopefully correct kconfiggroup

svn path=/trunk/KDE/kdebase/workspace/plasma/scriptengines/javascript/; revision=906280
This commit is contained in:
Marco Martin 2009-01-05 20:53:39 +00:00
parent 2c325585e3
commit eb42130a45
2 changed files with 13 additions and 4 deletions

View File

@ -142,8 +142,11 @@ QScriptValue qScriptValueFromKConfigGroup(QScriptEngine *engine, const KConfigGr
QMap<QString, QString>::const_iterator begin = it;
QMap<QString, QString>::const_iterator end = entryMap.constEnd();
//setting the group name
obj.setProperty("__name", QScriptValue(engine, config.name()));
//setting the key/value pairs
for (it = begin; it != end; ++it) {
//kDebug() << "setting" << it.key() << "to" << it.value();
QString prop = it.key();
prop.replace(' ', '_');
obj.setProperty(prop, variant2ScriptValue(engine, it.value()));
@ -156,8 +159,14 @@ void kConfigGroupFromScriptValue(const QScriptValue& obj, KConfigGroup &config)
{
QScriptValueIterator it(obj);
KConfigSkeleton *skel = new KConfigSkeleton();
config = KConfigGroup(skel->config(), obj.property("__name").toString());
while (it.hasNext()) {
config.writeEntry(it.name(), it.value().toString());
if (it.name() != "__name") {
config.writeEntry(it.name(), it.value().toString());
}
it.next();
}
}
@ -373,7 +382,7 @@ void SimpleJavaScriptApplet::setupObjects()
// Bindings for data engine
m_engine->setDefaultPrototype(qMetaTypeId<DataEngine*>(), m_engine->newQObject(new DataEngine()));
m_engine->setDefaultPrototype(qMetaTypeId<Service*>(), m_engine->newQObject(new DummyService()));
m_engine->setDefaultPrototype(qMetaTypeId<Service*>(), m_engine->newQObject(new DummyService()));
m_engine->setDefaultPrototype(qMetaTypeId<ServiceJob*>(), m_engine->newQObject(new ServiceJob(QString(), QString(), QMap<QString, QVariant>())));
global.setProperty("dataEngine", m_engine->newFunction(SimpleJavaScriptApplet::dataEngine));

View File

@ -11,7 +11,7 @@ plasmoid.dataUpdate = function(a, b)
plasmoid.stop = function()
{
data = controler.operationDescription("stop");
data = controller.operationDescription("stop");
print(data+controller.name());
for ( var i in data ) {
print(i + ' -> ' + data[i] );