From cd753894befe6a5393f529858b7478177a32d80a Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Wed, 19 May 2010 22:22:52 +0000 Subject: [PATCH] support setting full arrays of data svn path=/trunk/KDE/kdebase/runtime/; revision=1128673 --- .../javascript/javascriptdataengine.cpp | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/scriptengines/javascript/javascriptdataengine.cpp b/scriptengines/javascript/javascriptdataengine.cpp index 1f7f9e9bd..c98e43912 100644 --- a/scriptengines/javascript/javascriptdataengine.cpp +++ b/scriptengines/javascript/javascriptdataengine.cpp @@ -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);