From e68da09400cb33e3f351f3aafe7d58ea2120d2f5 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 5 Aug 2010 23:17:07 +0000 Subject: [PATCH] listAddons now returns an array of objects that contain information about the addons. svn path=/trunk/KDE/kdebase/runtime/; revision=1159687 --- scriptengines/javascript/scriptenv.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scriptengines/javascript/scriptenv.cpp b/scriptengines/javascript/scriptenv.cpp index d4c2355d1..bba1dc239 100644 --- a/scriptengines/javascript/scriptenv.cpp +++ b/scriptengines/javascript/scriptenv.cpp @@ -373,22 +373,26 @@ QScriptValue ScriptEnv::listAddons(QScriptContext *context, QScriptEngine *engin return context->throwError(i18n("listAddons takes one argument: addon type")); } - QStringList addons; const QString type = context->argument(0).toString(); if (type.isEmpty()) { - return qScriptValueFromValue(engine, addons); + return engine->undefinedValue(); } const QString constraint = QString("[X-KDE-PluginInfo-Category] == '%1'").arg(type); KService::List offers = KServiceTypeTrader::self()->query("Plasma/JavascriptAddon", constraint); + int i = 0; + QScriptValue addons = engine->newArray(offers.count()); foreach (KService::Ptr offer, offers) { KPluginInfo info(offer); - addons << info.pluginName(); + QScriptValue v = engine->newObject(); + v.setProperty("id", info.pluginName(), QScriptValue::ReadOnly); + v.setProperty("name", info.name(), QScriptValue::ReadOnly); + addons.setProperty(i++, v); } - return qScriptValueFromValue(engine, addons); + return addons; } QScriptValue ScriptEnv::loadAddon(QScriptContext *context, QScriptEngine *engine)