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,14 +107,24 @@ 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());
}
if (context->argumentCount() > 2) {
const QString key = value;
value = context->argument(2).toString();
iFace->setData(source, key, value);
iFace->setData(source, data);
} else {
iFace->setData(source, value);
QString value = context->argument(1).toString();
if (context->argumentCount() > 2) {
const QString key = value;
value = context->argument(2).toString();
iFace->setData(source, key, value);
} else {
iFace->setData(source, value);
}
}
return engine->newVariant(true);