* simpler way of registering DataEngine::Data
* reg DataEngine::Data with Qt by name so it can find it at runtime; allows DataEngine::query to actually work svn path=/branches/KDE/4.4/kdebase/runtime/; revision=1077825
This commit is contained in:
parent
a983cb2adc
commit
ced5e76676
@ -8,7 +8,6 @@ set(simple_javascript_engine_SRCS
|
||||
simplebindings/bytearrayclass.cpp
|
||||
simplebindings/bytearrayprototype.cpp
|
||||
simplebindings/color.cpp
|
||||
simplebindings/dataengine.cpp
|
||||
simplebindings/easingcurve.cpp
|
||||
simplebindings/font.cpp
|
||||
simplebindings/filedialogproxy.cpp
|
||||
@ -69,7 +68,6 @@ install(FILES plasma-scriptengine-runner-javascript.desktop DESTINATION ${SERVIC
|
||||
|
||||
set(javascript_dataengine_engine_SRCS
|
||||
javascriptdataengine.cpp
|
||||
simplebindings/dataengine.cpp
|
||||
simplebindings/variant.cpp
|
||||
)
|
||||
kde4_add_plugin(plasma_dataenginescript_javascript ${javascript_dataengine_engine_SRCS})
|
||||
|
@ -47,7 +47,9 @@ bool JavaScriptDataEngine::init()
|
||||
global.setProperty("removeData", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsRemoveData));
|
||||
global.setProperty("removeAllSources", m_qscriptEngine->newFunction(JavaScriptDataEngine::jsRemoveAllSources));
|
||||
|
||||
qScriptRegisterMetaType<DataEngine::Data>(m_qscriptEngine, qScriptValueFromData, 0, QScriptValue());
|
||||
qRegisterMetaType<DataEngine::Data>("Plasma::DataEngine::Data");
|
||||
qRegisterMetaType<DataEngine::Data>("DataEngine::Data");
|
||||
qScriptRegisterMapMetaType<DataEngine::Data>(m_qscriptEngine);
|
||||
/**
|
||||
TODO: Service bindings
|
||||
m_qscriptEngine->setDefaultPrototype(qMetaTypeId<Service*>(), m_qscriptEngine->newQObject(new DummyService()));
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007 Richard J. Moore <rich@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "dataengine.h"
|
||||
|
||||
QScriptValue qScriptValueFromData(QScriptEngine *engine, const DataEngine::Data &data)
|
||||
{
|
||||
DataEngine::Data::const_iterator begin = data.begin();
|
||||
DataEngine::Data::const_iterator end = data.end();
|
||||
DataEngine::Data::const_iterator it;
|
||||
|
||||
QScriptValue obj = engine->newObject();
|
||||
|
||||
for (it = begin; it != end; ++it) {
|
||||
//kDebug() << "setting" << it.key() << "to" << it.value();
|
||||
QString prop = it.key();
|
||||
prop.replace(' ', '_');
|
||||
obj.setProperty(prop, variantToScriptValue(engine, it.value()));
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
@ -74,7 +74,5 @@ int qScriptRegisterMapMetaType(
|
||||
qScriptValueToMap, prototype);
|
||||
}
|
||||
|
||||
QScriptValue qScriptValueFromData(QScriptEngine *engine, const DataEngine::Data &data);
|
||||
|
||||
#endif // DATAENGINE_H
|
||||
|
||||
|
@ -194,7 +194,9 @@ void registerSimpleAppletMetaTypes(QScriptEngine *engine)
|
||||
qScriptRegisterMetaType<KIO::Job *>(engine, qScriptValueFromKIOJob, qKIOJobFromQScriptValue);
|
||||
|
||||
qScriptRegisterMetaType<Plasma::Animation *>(engine, qScriptValueFromAnimation, abstractAnimationFromQScriptValue);
|
||||
qScriptRegisterMetaType<Plasma::DataEngine::Data>(engine, qScriptValueFromData, 0, 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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user