From 760e0914a0fd9518e9807534272d3e633b27badc Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 27 Apr 2010 21:13:37 +0000 Subject: [PATCH] allow defining what type of widget to return from widgets() svn path=/trunk/KDE/kdebase/workspace/; revision=1119874 --- containment.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/containment.cpp b/containment.cpp index 609a453be..8fdf20f81 100644 --- a/containment.cpp +++ b/containment.cpp @@ -210,20 +210,22 @@ QScriptValue Containment::addWidget(QScriptContext *context, QScriptEngine *engi QScriptValue Containment::widgets(QScriptContext *context, QScriptEngine *engine) { - Q_UNUSED(context) Containment *c = qobject_cast(context->thisObject().toQObject()); if (!c || !c->d->containment) { return engine->undefinedValue(); } + const QString widgetType = context->argumentCount() > 0 ? context->argument(0).toString() : QString(); QScriptValue widgets = engine->newArray(); ScriptEngine *env = ScriptEngine::envFor(engine); int count = 0; foreach (Plasma::Applet *widget, c->d->containment.data()->applets()) { - widgets.setProperty(count, env->wrap(widget)); - ++count; + if (widgetType.isEmpty() || widget->pluginName() == widgetType) { + widgets.setProperty(count, env->wrap(widget)); + ++count; + } } widgets.setProperty("length", count);