widgets()
svn path=/trunk/KDE/kdebase/workspace/; revision=1119843
This commit is contained in:
parent
7d27adbe34
commit
fa83ab3f21
@ -208,6 +208,28 @@ QScriptValue Containment::addWidget(QScriptContext *context, QScriptEngine *engi
|
||||
return engine->undefinedValue();
|
||||
}
|
||||
|
||||
QScriptValue Containment::widgets(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
Q_UNUSED(context)
|
||||
Containment *c = qobject_cast<Containment*>(context->thisObject().toQObject());
|
||||
|
||||
if (!c || !c->d->containment) {
|
||||
return engine->undefinedValue();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
widgets.setProperty("length", count);
|
||||
return widgets;
|
||||
}
|
||||
|
||||
uint Containment::id() const
|
||||
{
|
||||
if (!d->containment) {
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
|
||||
static QScriptValue widgetById(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue addWidget(QScriptContext *context, QScriptEngine *engine);
|
||||
static QScriptValue widgets(QScriptContext *context, QScriptEngine *engine);
|
||||
|
||||
public Q_SLOTS:
|
||||
void remove();
|
||||
|
@ -153,6 +153,7 @@ QScriptValue ScriptEngine::wrap(Containment *c)
|
||||
QScriptEngine::ExcludeSuperClassMethods);
|
||||
v.setProperty("widgetById", newFunction(Containment::widgetById));
|
||||
v.setProperty("addWidget", newFunction(Containment::addWidget));
|
||||
v.setProperty("widgets", newFunction(Containment::widgets));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user