support setting full arrays of data

svn path=/trunk/KDE/kdebase/runtime/; revision=1128673
This commit is contained in:
Aaron J. Seigo 2010-05-19 22:22:52 +00:00
parent a52bd2b9fb
commit cd753894be

View File

@ -107,8 +107,17 @@ QScriptValue JavaScriptDataEngine::jsSetData(QScriptContext *context, QScriptEng
}
const QString source = context->argument(0).toString();
QString value = context->argument(1).toString();
if (context->argument(1).isArray()) {
QScriptValueIterator it(context->argument(1));
DataEngine::Data data;
while (it.hasNext()) {
it.next();
data.insert(it.name(), it.value().toVariant());
}
iFace->setData(source, data);
} else {
QString value = context->argument(1).toString();
if (context->argumentCount() > 2) {
const QString key = value;
value = context->argument(2).toString();
@ -116,6 +125,7 @@ QScriptValue JavaScriptDataEngine::jsSetData(QScriptContext *context, QScriptEng
} else {
iFace->setData(source, value);
}
}
return engine->newVariant(true);
}