allow defining what type of widget to return from widgets()
svn path=/trunk/KDE/kdebase/workspace/; revision=1119874
This commit is contained in:
parent
1d60579972
commit
760e0914a0
@ -210,20 +210,22 @@ QScriptValue Containment::addWidget(QScriptContext *context, QScriptEngine *engi
|
|||||||
|
|
||||||
QScriptValue Containment::widgets(QScriptContext *context, QScriptEngine *engine)
|
QScriptValue Containment::widgets(QScriptContext *context, QScriptEngine *engine)
|
||||||
{
|
{
|
||||||
Q_UNUSED(context)
|
|
||||||
Containment *c = qobject_cast<Containment*>(context->thisObject().toQObject());
|
Containment *c = qobject_cast<Containment*>(context->thisObject().toQObject());
|
||||||
|
|
||||||
if (!c || !c->d->containment) {
|
if (!c || !c->d->containment) {
|
||||||
return engine->undefinedValue();
|
return engine->undefinedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString widgetType = context->argumentCount() > 0 ? context->argument(0).toString() : QString();
|
||||||
QScriptValue widgets = engine->newArray();
|
QScriptValue widgets = engine->newArray();
|
||||||
ScriptEngine *env = ScriptEngine::envFor(engine);
|
ScriptEngine *env = ScriptEngine::envFor(engine);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
foreach (Plasma::Applet *widget, c->d->containment.data()->applets()) {
|
foreach (Plasma::Applet *widget, c->d->containment.data()->applets()) {
|
||||||
widgets.setProperty(count, env->wrap(widget));
|
if (widgetType.isEmpty() || widget->pluginName() == widgetType) {
|
||||||
++count;
|
widgets.setProperty(count, env->wrap(widget));
|
||||||
|
++count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
widgets.setProperty("length", count);
|
widgets.setProperty("length", count);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user