make DataEngine::serviceForSource work with the bindings
svn path=/branches/KDE/4.4/kdebase/runtime/; revision=1089371
This commit is contained in:
parent
6cc6249851
commit
f0775b0de4
@ -185,6 +185,42 @@ void extenderFromQScriptValue(const QScriptValue &scriptValue, ExtenderPtr &exte
|
||||
extender = static_cast<Plasma::Extender *>(obj);
|
||||
}
|
||||
|
||||
typedef Plasma::Service *ServicePtr;
|
||||
QScriptValue qScriptValueFromService(QScriptEngine *engine, const ServicePtr &service)
|
||||
{
|
||||
return engine->newQObject(const_cast<Plasma::Service *>(service), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
|
||||
}
|
||||
|
||||
void serviceFromQScriptValue(const QScriptValue &scriptValue, ServicePtr &service)
|
||||
{
|
||||
QObject *obj = scriptValue.toQObject();
|
||||
service = static_cast<Plasma::Service *>(obj);
|
||||
}
|
||||
|
||||
typedef Plasma::DataEngine *DataEnginePtr;
|
||||
QScriptValue qScriptValueFromDataEngine(QScriptEngine *engine, const DataEnginePtr &dataEngine)
|
||||
{
|
||||
return engine->newQObject(const_cast<Plasma::DataEngine *>(dataEngine), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
|
||||
}
|
||||
|
||||
void dataEngineFromQScriptValue(const QScriptValue &scriptValue, DataEnginePtr &dataEngine)
|
||||
{
|
||||
QObject *obj = scriptValue.toQObject();
|
||||
dataEngine = static_cast<Plasma::DataEngine *>(obj);
|
||||
}
|
||||
|
||||
typedef Plasma::ServiceJob *ServiceJobPtr;
|
||||
QScriptValue qScriptValueFromServiceJob(QScriptEngine *engine, const ServiceJobPtr &serviceJob)
|
||||
{
|
||||
return engine->newQObject(const_cast<Plasma::ServiceJob *>(serviceJob), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
|
||||
}
|
||||
|
||||
void serviceJobFromQScriptValue(const QScriptValue &scriptValue, ServiceJobPtr &serviceJob)
|
||||
{
|
||||
QObject *obj = scriptValue.toQObject();
|
||||
serviceJob = static_cast<Plasma::ServiceJob *>(obj);
|
||||
}
|
||||
|
||||
void registerSimpleAppletMetaTypes(QScriptEngine *engine)
|
||||
{
|
||||
qScriptRegisterMetaType<QGraphicsWidget*>(engine, qScriptValueFromQGraphicsWidget, qGraphicsWidgetFromQScriptValue);
|
||||
@ -194,9 +230,12 @@ void registerSimpleAppletMetaTypes(QScriptEngine *engine)
|
||||
qScriptRegisterMetaType<KIO::Job *>(engine, qScriptValueFromKIOJob, qKIOJobFromQScriptValue);
|
||||
|
||||
qScriptRegisterMetaType<Plasma::Animation *>(engine, qScriptValueFromAnimation, abstractAnimationFromQScriptValue);
|
||||
qScriptRegisterMetaType<Plasma::Extender *>(engine, qScriptValueFromExtender , extenderFromQScriptValue);
|
||||
qScriptRegisterMetaType<Plasma::VideoWidget::Controls>(engine, qScriptValueFromControls, controlsFromScriptValue, QScriptValue());
|
||||
qRegisterMetaType<DataEngine::Data>("Plasma::DataEngine::Data");
|
||||
qRegisterMetaType<DataEngine::Data>("DataEngine::Data");
|
||||
qScriptRegisterMapMetaType<DataEngine::Data>(engine);
|
||||
qScriptRegisterMetaType<Plasma::Extender *>(engine, qScriptValueFromExtender , extenderFromQScriptValue);
|
||||
qScriptRegisterMetaType<Plasma::VideoWidget::Controls>(engine, qScriptValueFromControls, controlsFromScriptValue, QScriptValue());
|
||||
qScriptRegisterMetaType<Plasma::Service *>(engine, qScriptValueFromService, serviceFromQScriptValue);
|
||||
qScriptRegisterMetaType<Plasma::DataEngine *>(engine, qScriptValueFromDataEngine, dataEngineFromQScriptValue);
|
||||
qScriptRegisterMetaType<Plasma::ServiceJob *>(engine, qScriptValueFromServiceJob, serviceJobFromQScriptValue);
|
||||
}
|
||||
|
@ -534,13 +534,6 @@ void SimpleJavaScriptApplet::setupObjects()
|
||||
global.setProperty("AnimationGroup", m_engine->newFunction(SimpleJavaScriptApplet::animationGroup));
|
||||
global.setProperty("ParallelAnimationGroup", m_engine->newFunction(SimpleJavaScriptApplet::parallelAnimationGroup));
|
||||
|
||||
// Bindings for data engine
|
||||
m_engine->setDefaultPrototype(qMetaTypeId<DataEngine*>(), m_engine->newQObject(new DataEngine(), QScriptEngine::ScriptOwnership));
|
||||
m_engine->setDefaultPrototype(qMetaTypeId<Service*>(), m_engine->newQObject(new DummyService(), QScriptEngine::ScriptOwnership));
|
||||
m_engine->setDefaultPrototype(qMetaTypeId<ServiceJob*>(),
|
||||
m_engine->newQObject(new ServiceJob(QString(), QString(), QMap<QString, QVariant>()),
|
||||
QScriptEngine::ScriptOwnership ));
|
||||
|
||||
bindI18N(m_engine);
|
||||
global.setProperty("dataEngine", m_engine->newFunction(SimpleJavaScriptApplet::dataEngine));
|
||||
global.setProperty("service", m_engine->newFunction(SimpleJavaScriptApplet::service));
|
||||
|
Loading…
Reference in New Issue
Block a user