mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 16:44:39 +03:00
Building for different script engine has been fixed
This commit is contained in:
parent
0a0e1504fa
commit
e0ef984fca
@ -47,6 +47,7 @@ lessThan(QT_MAJOR_VERSION, 5){
|
|||||||
contains(CONFIG, qtscriptengine){
|
contains(CONFIG, qtscriptengine){
|
||||||
CONFIG -= qjsengine
|
CONFIG -= qjsengine
|
||||||
QT *= script
|
QT *= script
|
||||||
|
DEFINES *= USE_QTSCRIPTENGINE
|
||||||
message(qtscriptengine)
|
message(qtscriptengine)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,13 +42,6 @@
|
|||||||
# define LIMEREPORT_EXPORT /**/
|
# define LIMEREPORT_EXPORT /**/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_QJSENGINE
|
|
||||||
//#include <QJSEngine>
|
|
||||||
#include <QQmlEngine>
|
|
||||||
#else
|
|
||||||
#include <QtScript/QScriptEngine>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace LimeReport {
|
namespace LimeReport {
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
@ -146,27 +139,12 @@ namespace Const{
|
|||||||
virtual ~IPainterProxy();
|
virtual ~IPainterProxy();
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_QT4
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
typedef QStyleOptionViewItemV4 StyleOptionViewItem;
|
typedef QStyleOptionViewItemV4 StyleOptionViewItem;
|
||||||
#else
|
#else
|
||||||
typedef QStyleOptionViewItem StyleOptionViewItem;
|
typedef QStyleOptionViewItem StyleOptionViewItem;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_QJSENGINE
|
|
||||||
typedef QJSEngine ScriptEngineType;
|
|
||||||
typedef QJSValue ScriptValueType;
|
|
||||||
template <typename T>
|
|
||||||
static inline QJSValue getJSValue(QJSEngine &e, T *p)
|
|
||||||
{
|
|
||||||
QJSValue res = e.newQObject(p);
|
|
||||||
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
typedef QScriptEngine ScriptEngineType;
|
|
||||||
typedef QScriptValue ScriptValueType;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
|
||||||
Q_NAMESPACE
|
Q_NAMESPACE
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,17 +29,47 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifndef LRSCRIPTENGINEMANAGERINTF_H
|
#ifndef LRSCRIPTENGINEMANAGERINTF_H
|
||||||
#define LRSCRIPTENGINEMANAGERINTF_H
|
#define LRSCRIPTENGINEMANAGERINTF_H
|
||||||
|
#include "qglobal.h"
|
||||||
|
|
||||||
//#include <QJSEngine>
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
#include "lrglobal.h"
|
#ifndef USE_QTSCRIPTENGINE
|
||||||
|
#ifndef USE_QJSENGINE
|
||||||
|
#define USE_QJSENGINE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifndef USE_QTSCRIPTENGINE
|
||||||
|
#define USE_QTSCRIPTENGINE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_QJSENGINE
|
||||||
|
#include <QQmlEngine>
|
||||||
|
#else
|
||||||
|
#include <QtScript/QScriptEngine>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace LimeReport{
|
namespace LimeReport{
|
||||||
|
|
||||||
|
#ifdef USE_QJSENGINE
|
||||||
|
typedef QJSEngine ScriptEngineType;
|
||||||
|
typedef QJSValue ScriptValueType;
|
||||||
|
template <typename T>
|
||||||
|
static inline QJSValue getJSValue(QJSEngine &e, T *p)
|
||||||
|
{
|
||||||
|
QJSValue res = e.newQObject(p);
|
||||||
|
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
typedef QScriptEngine ScriptEngineType;
|
||||||
|
typedef QScriptValue ScriptValueType;
|
||||||
|
#endif
|
||||||
|
|
||||||
class IScriptEngineManager{
|
class IScriptEngineManager{
|
||||||
public:
|
public:
|
||||||
virtual ScriptEngineType* scriptEngine() = 0;
|
virtual ScriptEngineType* scriptEngine() = 0;
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
virtual bool addFunction(const QString& name, ScriptEngineType::FunctionSignature function,
|
virtual bool addFunction(const QString& name, ScriptEngineType::FunctionSignature function,
|
||||||
const QString& category="", const QString& description="") = 0;
|
const QString& category="", const QString& description="") = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,9 +29,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QTextLayout>
|
#include <QTextLayout>
|
||||||
#ifndef USE_QJSENGINE
|
|
||||||
#include <QtScript/QScriptEngine>
|
|
||||||
#endif
|
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -42,13 +42,6 @@
|
|||||||
# define LIMEREPORT_EXPORT /**/
|
# define LIMEREPORT_EXPORT /**/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_QJSENGINE
|
|
||||||
//#include <QJSEngine>
|
|
||||||
#include <QQmlEngine>
|
|
||||||
#else
|
|
||||||
#include <QtScript/QScriptEngine>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace LimeReport {
|
namespace LimeReport {
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
@ -146,27 +139,12 @@ namespace Const{
|
|||||||
virtual ~IPainterProxy();
|
virtual ~IPainterProxy();
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_QT4
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
typedef QStyleOptionViewItemV4 StyleOptionViewItem;
|
typedef QStyleOptionViewItemV4 StyleOptionViewItem;
|
||||||
#else
|
#else
|
||||||
typedef QStyleOptionViewItem StyleOptionViewItem;
|
typedef QStyleOptionViewItem StyleOptionViewItem;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_QJSENGINE
|
|
||||||
typedef QJSEngine ScriptEngineType;
|
|
||||||
typedef QJSValue ScriptValueType;
|
|
||||||
template <typename T>
|
|
||||||
static inline QJSValue getJSValue(QJSEngine &e, T *p)
|
|
||||||
{
|
|
||||||
QJSValue res = e.newQObject(p);
|
|
||||||
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
typedef QScriptEngine ScriptEngineType;
|
|
||||||
typedef QScriptValue ScriptValueType;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
|
||||||
Q_NAMESPACE
|
Q_NAMESPACE
|
||||||
#endif
|
#endif
|
||||||
|
@ -1172,7 +1172,9 @@ ReportPages ReportEnginePrivate::renderToPages()
|
|||||||
}
|
}
|
||||||
|
|
||||||
scriptContext()->qobjectToScript("engine",this);
|
scriptContext()->qobjectToScript("engine",this);
|
||||||
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
|
ScriptEngineManager::instance().scriptEngine()->pushContext();
|
||||||
|
#endif
|
||||||
if (m_scriptEngineContext->runInitScript()){
|
if (m_scriptEngineContext->runInitScript()){
|
||||||
|
|
||||||
dataManager()->clearErrors();
|
dataManager()->clearErrors();
|
||||||
@ -1230,6 +1232,9 @@ ReportPages ReportEnginePrivate::renderToPages()
|
|||||||
}
|
}
|
||||||
m_reportRendering = false;
|
m_reportRendering = false;
|
||||||
//activateLanguage(QLocale::AnyLanguage);
|
//activateLanguage(QLocale::AnyLanguage);
|
||||||
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
|
ScriptEngineManager::instance().scriptEngine()->popContext();
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
return ReportPages();
|
return ReportPages();
|
||||||
|
@ -243,10 +243,6 @@ void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool
|
|||||||
|
|
||||||
savePage(true);
|
savePage(true);
|
||||||
|
|
||||||
#ifndef USE_QJSENGINE
|
|
||||||
ScriptEngineManager::instance().scriptEngine()->popContext();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ReportRender::pageCount()
|
int ReportRender::pageCount()
|
||||||
@ -1422,7 +1418,8 @@ void ReportRender::savePage(bool isLast)
|
|||||||
moveTearOffBand();
|
moveTearOffBand();
|
||||||
m_scriptEngineContext->setCurrentPage(m_renderPageItem);
|
m_scriptEngineContext->setCurrentPage(m_renderPageItem);
|
||||||
emit m_patternPageItem->afterRender();
|
emit m_patternPageItem->afterRender();
|
||||||
if (isLast) emit m_patternPageItem->afterLastPageRendered();
|
if (isLast)
|
||||||
|
emit m_patternPageItem->afterLastPageRendered();
|
||||||
if (isLast && m_patternPageItem->endlessHeight()){
|
if (isLast && m_patternPageItem->endlessHeight()){
|
||||||
qreal pageHeight = 0;
|
qreal pageHeight = 0;
|
||||||
foreach (BandDesignIntf* band, m_renderPageItem->bands()) {
|
foreach (BandDesignIntf* band, m_renderPageItem->bands()) {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
#include <QScriptValueIterator>
|
#include <QScriptValueIterator>
|
||||||
#endif
|
#endif
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@ -50,7 +50,7 @@ Q_DECLARE_METATYPE(QColor)
|
|||||||
Q_DECLARE_METATYPE(QFont)
|
Q_DECLARE_METATYPE(QFont)
|
||||||
Q_DECLARE_METATYPE(LimeReport::ScriptEngineManager *)
|
Q_DECLARE_METATYPE(LimeReport::ScriptEngineManager *)
|
||||||
|
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
QScriptValue constructColor(QScriptContext *context, QScriptEngine *engine)
|
QScriptValue constructColor(QScriptContext *context, QScriptEngine *engine)
|
||||||
{
|
{
|
||||||
QColor color(context->argument(0).toString());
|
QColor color(context->argument(0).toString());
|
||||||
@ -278,7 +278,7 @@ bool ScriptEngineManager::containsFunction(const QString& functionName){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
#if QT_VERSION > 0x050600
|
#if QT_VERSION > 0x050600
|
||||||
Q_DECL_DEPRECATED
|
Q_DECL_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
@ -818,6 +818,23 @@ bool ScriptEngineManager::createGetFieldByKeyFunction()
|
|||||||
return addFunction(fd);
|
return addFunction(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScriptEngineManager::createGetFieldByRowIndex()
|
||||||
|
{
|
||||||
|
JSFunctionDesc fd;
|
||||||
|
fd.setManager(m_functionManager);
|
||||||
|
fd.setManagerName(LimeReport::Const::FUNCTION_MANAGER_NAME);
|
||||||
|
fd.setCategory(tr("GENERAL"));
|
||||||
|
fd.setName("getFieldByRowIndex");
|
||||||
|
fd.setDescription("getFieldByRowIndex(\""+tr("FieldName")+"\", \""+
|
||||||
|
tr("RowIndex")+"\")"
|
||||||
|
);
|
||||||
|
fd.setScriptWrapper(QString("function getFieldByRowIndex(fieldName, rowIndex){"
|
||||||
|
"return %1.getFieldByRowIndex(fieldName, rowIndex);}"
|
||||||
|
).arg(LimeReport::Const::FUNCTION_MANAGER_NAME)
|
||||||
|
);
|
||||||
|
return addFunction(fd);
|
||||||
|
}
|
||||||
|
|
||||||
bool ScriptEngineManager::createAddTableOfContentsItemFunction()
|
bool ScriptEngineManager::createAddTableOfContentsItemFunction()
|
||||||
{
|
{
|
||||||
JSFunctionDesc fd;
|
JSFunctionDesc fd;
|
||||||
@ -869,7 +886,7 @@ ScriptEngineManager::ScriptEngineManager()
|
|||||||
m_scriptEngine = new ScriptEngineType;
|
m_scriptEngine = new ScriptEngineType;
|
||||||
m_functionManager = new ScriptFunctionsManager(this);
|
m_functionManager = new ScriptFunctionsManager(this);
|
||||||
m_functionManager->setScriptEngineManager(this);
|
m_functionManager->setScriptEngineManager(this);
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
m_scriptEngine->setDefaultPrototype(qMetaTypeId<QComboBox*>(),
|
m_scriptEngine->setDefaultPrototype(qMetaTypeId<QComboBox*>(),
|
||||||
m_scriptEngine->newQObject(new ComboBoxPrototype()));
|
m_scriptEngine->newQObject(new ComboBoxPrototype()));
|
||||||
#endif
|
#endif
|
||||||
@ -887,9 +904,10 @@ ScriptEngineManager::ScriptEngineManager()
|
|||||||
#endif
|
#endif
|
||||||
createSetVariableFunction();
|
createSetVariableFunction();
|
||||||
createGetFieldFunction();
|
createGetFieldFunction();
|
||||||
|
createGetFieldByRowIndex();
|
||||||
createGetFieldByKeyFunction();
|
createGetFieldByKeyFunction();
|
||||||
createGetVariableFunction();
|
createGetVariableFunction();
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
QScriptValue colorCtor = m_scriptEngine->newFunction(constructColor);
|
QScriptValue colorCtor = m_scriptEngine->newFunction(constructColor);
|
||||||
m_scriptEngine->globalObject().setProperty("QColor", colorCtor);
|
m_scriptEngine->globalObject().setProperty("QColor", colorCtor);
|
||||||
|
|
||||||
@ -1362,9 +1380,6 @@ bool ScriptEngineContext::runInitScript(){
|
|||||||
ScriptEngineManager::instance().setContext(this);
|
ScriptEngineManager::instance().setContext(this);
|
||||||
m_tableOfContents->clear();
|
m_tableOfContents->clear();
|
||||||
|
|
||||||
#ifndef USE_QJSENGINE
|
|
||||||
engine->pushContext();
|
|
||||||
#endif
|
|
||||||
ScriptValueType res = engine->evaluate(initScript());
|
ScriptValueType res = engine->evaluate(initScript());
|
||||||
if (res.isBool()) return res.toBool();
|
if (res.isBool()) return res.toBool();
|
||||||
#ifdef USE_QJSENGINE
|
#ifdef USE_QJSENGINE
|
||||||
@ -1595,6 +1610,12 @@ QVariant ScriptFunctionsManager::getFieldByKeyField(const QString& datasourceNam
|
|||||||
return dm->fieldDataByKey(datasourceName, valueFieldName, keyFieldName, keyValue);
|
return dm->fieldDataByKey(datasourceName, valueFieldName, keyFieldName, keyValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant ScriptFunctionsManager::getFieldByRowIndex(const QString &fieldName, int rowIndex)
|
||||||
|
{
|
||||||
|
DataSourceManager* dm = scriptEngineManager()->dataManager();
|
||||||
|
return dm->fieldDataByRowIndex(fieldName, rowIndex);
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptFunctionsManager::reopenDatasource(const QString& datasourceName)
|
void ScriptFunctionsManager::reopenDatasource(const QString& datasourceName)
|
||||||
{
|
{
|
||||||
DataSourceManager* dm = scriptEngineManager()->dataManager();
|
DataSourceManager* dm = scriptEngineManager()->dataManager();
|
||||||
@ -1923,7 +1944,7 @@ void TableBuilder::checkBaseLayout()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
void ComboBoxPrototype::addItem(const QString &text)
|
void ComboBoxPrototype::addItem(const QString &text)
|
||||||
{
|
{
|
||||||
QComboBox* comboBox = qscriptvalue_cast<QComboBox*>(thisObject());
|
QComboBox* comboBox = qscriptvalue_cast<QComboBox*>(thisObject());
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifndef LRSCRIPTENGINEMANAGER_H
|
#ifndef LRSCRIPTENGINEMANAGER_H
|
||||||
#define LRSCRIPTENGINEMANAGER_H
|
#define LRSCRIPTENGINEMANAGER_H
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
#include <QtScript/QScriptEngine>
|
#include <QtScript/QScriptEngine>
|
||||||
#include <QScriptable>
|
#include <QScriptable>
|
||||||
#endif
|
#endif
|
||||||
@ -272,7 +272,7 @@ private:
|
|||||||
QString m_scriptWrapper;
|
QString m_scriptWrapper;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
class ComboBoxPrototype : public QObject, public QScriptable{
|
class ComboBoxPrototype : public QObject, public QScriptable{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -363,6 +363,7 @@ public:
|
|||||||
Q_INVOKABLE QVariant getVariable(const QString& name);
|
Q_INVOKABLE QVariant getVariable(const QString& name);
|
||||||
Q_INVOKABLE QVariant getField(const QString& field);
|
Q_INVOKABLE QVariant getField(const QString& field);
|
||||||
Q_INVOKABLE QVariant getFieldByKeyField(const QString& datasourceName, const QString& valueFieldName, const QString& keyFieldName, QVariant keyValue);
|
Q_INVOKABLE QVariant getFieldByKeyField(const QString& datasourceName, const QString& valueFieldName, const QString& keyFieldName, QVariant keyValue);
|
||||||
|
Q_INVOKABLE QVariant getFieldByRowIndex(const QString& fieldName, int rowIndex);
|
||||||
Q_INVOKABLE void reopenDatasource(const QString& datasourceName);
|
Q_INVOKABLE void reopenDatasource(const QString& datasourceName);
|
||||||
Q_INVOKABLE QVariant color(const QString& color){ return QColor(color);}
|
Q_INVOKABLE QVariant color(const QString& color){ return QColor(color);}
|
||||||
Q_INVOKABLE void addTableOfContentsItem(const QString& uniqKey, const QString& content, int indent = 0);
|
Q_INVOKABLE void addTableOfContentsItem(const QString& uniqKey, const QString& content, int indent = 0);
|
||||||
@ -399,7 +400,7 @@ public:
|
|||||||
void deleteFunction(const QString& functionsName);
|
void deleteFunction(const QString& functionsName);
|
||||||
|
|
||||||
bool addFunction(const JSFunctionDesc& functionsDescriber);
|
bool addFunction(const JSFunctionDesc& functionsDescriber);
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
bool addFunction(const QString &name, QScriptEngine::FunctionSignature function, const QString &category, const QString &description);
|
bool addFunction(const QString &name, QScriptEngine::FunctionSignature function, const QString &category, const QString &description);
|
||||||
#endif
|
#endif
|
||||||
bool addFunction(const QString &name, const QString& script,
|
bool addFunction(const QString &name, const QString& script,
|
||||||
@ -438,6 +439,7 @@ private:
|
|||||||
bool createGetVariableFunction();
|
bool createGetVariableFunction();
|
||||||
bool createGetFieldFunction();
|
bool createGetFieldFunction();
|
||||||
bool createGetFieldByKeyFunction();
|
bool createGetFieldByKeyFunction();
|
||||||
|
bool createGetFieldByRowIndex();
|
||||||
bool createAddTableOfContentsItemFunction();
|
bool createAddTableOfContentsItemFunction();
|
||||||
bool createClearTableOfContentsFunction();
|
bool createClearTableOfContentsFunction();
|
||||||
bool createReopenDatasourceFunction();
|
bool createReopenDatasourceFunction();
|
||||||
@ -483,7 +485,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
class QFontPrototype : public QObject, public QScriptable {
|
class QFontPrototype : public QObject, public QScriptable {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString family READ family)
|
Q_PROPERTY(QString family READ family)
|
||||||
@ -533,7 +535,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
Q_DECLARE_METATYPE(LimeReport::ComboBoxPrototype*)
|
Q_DECLARE_METATYPE(LimeReport::ComboBoxPrototype*)
|
||||||
Q_DECLARE_METATYPE(QComboBox*)
|
Q_DECLARE_METATYPE(QComboBox*)
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,17 +29,47 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifndef LRSCRIPTENGINEMANAGERINTF_H
|
#ifndef LRSCRIPTENGINEMANAGERINTF_H
|
||||||
#define LRSCRIPTENGINEMANAGERINTF_H
|
#define LRSCRIPTENGINEMANAGERINTF_H
|
||||||
|
#include "qglobal.h"
|
||||||
|
|
||||||
//#include <QJSEngine>
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
#include "lrglobal.h"
|
#ifndef USE_QTSCRIPTENGINE
|
||||||
|
#ifndef USE_QJSENGINE
|
||||||
|
#define USE_QJSENGINE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifndef USE_QTSCRIPTENGINE
|
||||||
|
#define USE_QTSCRIPTENGINE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_QJSENGINE
|
||||||
|
#include <QQmlEngine>
|
||||||
|
#else
|
||||||
|
#include <QtScript/QScriptEngine>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace LimeReport{
|
namespace LimeReport{
|
||||||
|
|
||||||
|
#ifdef USE_QJSENGINE
|
||||||
|
typedef QJSEngine ScriptEngineType;
|
||||||
|
typedef QJSValue ScriptValueType;
|
||||||
|
template <typename T>
|
||||||
|
static inline QJSValue getJSValue(QJSEngine &e, T *p)
|
||||||
|
{
|
||||||
|
QJSValue res = e.newQObject(p);
|
||||||
|
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
typedef QScriptEngine ScriptEngineType;
|
||||||
|
typedef QScriptValue ScriptValueType;
|
||||||
|
#endif
|
||||||
|
|
||||||
class IScriptEngineManager{
|
class IScriptEngineManager{
|
||||||
public:
|
public:
|
||||||
virtual ScriptEngineType* scriptEngine() = 0;
|
virtual ScriptEngineType* scriptEngine() = 0;
|
||||||
#ifndef USE_QJSENGINE
|
#ifdef USE_QTSCRIPTENGINE
|
||||||
virtual bool addFunction(const QString& name, ScriptEngineType::FunctionSignature function,
|
virtual bool addFunction(const QString& name, ScriptEngineType::FunctionSignature function,
|
||||||
const QString& category="", const QString& description="") = 0;
|
const QString& category="", const QString& description="") = 0;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user