a bit more manual, but it works much better.DataEngine::serviceForSource actually works now, for instance

svn path=/trunk/KDE/kdebase/runtime/; revision=1089368
This commit is contained in:
Aaron J. Seigo 2010-02-13 00:32:26 +00:00
parent dda89cd693
commit 1072174a96
2 changed files with 41 additions and 6 deletions

View File

@ -184,9 +184,46 @@ void extenderFromQScriptValue(const QScriptValue &scriptValue, ExtenderPtr &exte
QObject *obj = scriptValue.toQObject(); QObject *obj = scriptValue.toQObject();
extender = static_cast<Plasma::Extender *>(obj); 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);
}
using namespace Plasma; using namespace Plasma;
void registerSimpleAppletMetaTypes(QScriptEngine *engine) void registerSimpleAppletMetaTypes(QScriptEngine *engine, bool includeUi)
{ {
qScriptRegisterMetaType<QGraphicsWidget*>(engine, qScriptValueFromQGraphicsWidget, qGraphicsWidgetFromQScriptValue); qScriptRegisterMetaType<QGraphicsWidget*>(engine, qScriptValueFromQGraphicsWidget, qGraphicsWidgetFromQScriptValue);
@ -200,4 +237,7 @@ void registerSimpleAppletMetaTypes(QScriptEngine *engine)
qScriptRegisterMapMetaType<DataEngine::Data>(engine); qScriptRegisterMapMetaType<DataEngine::Data>(engine);
qScriptRegisterMetaType<Plasma::Extender *>(engine, qScriptValueFromExtender, extenderFromQScriptValue); qScriptRegisterMetaType<Plasma::Extender *>(engine, qScriptValueFromExtender, extenderFromQScriptValue);
qScriptRegisterMetaType<Plasma::VideoWidget::Controls>(engine, qScriptValueFromControls, controlsFromScriptValue, QScriptValue()); 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);
} }

View File

@ -306,11 +306,6 @@ void SimpleJavaScriptApplet::setupObjects()
global.setProperty("ParallelAnimationGroup", m_engine->newFunction(SimpleJavaScriptApplet::parallelAnimationGroup)); global.setProperty("ParallelAnimationGroup", m_engine->newFunction(SimpleJavaScriptApplet::parallelAnimationGroup));
// Bindings for data engine // 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); bindI18N(m_engine);
global.setProperty("dataEngine", m_engine->newFunction(SimpleJavaScriptApplet::dataEngine)); global.setProperty("dataEngine", m_engine->newFunction(SimpleJavaScriptApplet::dataEngine));