0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-01-11 17:18:10 +03:00

QQmlEngine -> QJSEngine

This commit is contained in:
Arin Alexander 2018-05-08 10:52:23 +03:00
parent eacc5c645e
commit 2151a549e8
3 changed files with 6 additions and 7 deletions

View File

@ -138,13 +138,12 @@ namespace Const{
#endif
#ifdef USE_QJSENGINE
typedef QQmlEngine ScriptEngineType;
typedef QJSEngine ScriptEngineType;
typedef QJSValue ScriptValueType;
template <typename T>
static inline QJSValue getCppOwnedJSValue(QJSEngine &e, T *p)
static inline QJSValue getJSValue(QJSEngine &e, T *p)
{
QJSValue res = e.newQObject(p);
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
return res;
}
#else

View File

@ -299,7 +299,7 @@ void ReportRender::initRenderPage()
ScriptEngineType* se = ScriptEngineManager::instance().scriptEngine();
#ifdef USE_QJSENGINE
svCurrentPage = getCppOwnedJSValue(*se, m_renderPageItem);
svCurrentPage = getJSValue(*se, m_renderPageItem);
se->globalObject().setProperty("currentPage", svCurrentPage);
#else
svCurrentPage = se->globalObject().property("currentPage");

View File

@ -474,7 +474,7 @@ QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue,
ScriptValueType svThis;
#ifdef USE_QJSENGINE
svThis = getCppOwnedJSValue(*se, reportItem);
svThis = getJSValue(*se, reportItem);
se->globalObject().setProperty("THIS",svThis);
#else
svThis = se->globalObject().property("THIS");
@ -1280,7 +1280,7 @@ void ScriptEngineContext::baseDesignIntfToScript(const QString& pageName, BaseDe
ScriptEngineType* engine = ScriptEngineManager::instance().scriptEngine();
#ifdef USE_QJSENGINE
ScriptValueType sItem = getCppOwnedJSValue(*engine, item);
ScriptValueType sItem = getJSValue(*engine, item);
QString on = item->patternName().compare(pageName) == 0 ? pageName : pageName+"_"+item->patternName();
engine->globalObject().setProperty(on, sItem);
#else
@ -1303,7 +1303,7 @@ void ScriptEngineContext::qobjectToScript(const QString& name, QObject *item)
{
ScriptEngineType* engine = ScriptEngineManager::instance().scriptEngine();
#ifdef USE_QJSENGINE
ScriptValueType sItem = getCppOwnedJSValue(*engine, item);
ScriptValueType sItem = getJSValue(*engine, item);
engine->globalObject().setProperty(name, sItem);
#else
ScriptValueType sItem = engine->globalObject().property(name);