From f48e414114a9d49c4266b6243b96cf2893052de8 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 30 Jan 2019 01:53:21 +0300 Subject: [PATCH] moveQObjectToScript() has been added to ScriptManager --- include/lrscriptenginemanagerintf.h | 2 ++ limereport/lrscriptenginemanager.cpp | 7 +++++++ limereport/lrscriptenginemanager.h | 2 +- limereport/lrscriptenginemanagerintf.h | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/lrscriptenginemanagerintf.h b/include/lrscriptenginemanagerintf.h index 4c2767a..1d306bd 100644 --- a/include/lrscriptenginemanagerintf.h +++ b/include/lrscriptenginemanagerintf.h @@ -46,7 +46,9 @@ public: virtual bool addFunction(const QString &name, const QString& script, const QString &category="", const QString &description="") = 0; virtual const QString& lastError() const = 0; + virtual ScriptValueType moveQObjectToScript(QObject* object, const QString objectName) = 0; virtual ~IScriptEngineManager(){} + }; } //namespace LimeReport diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index ae3abad..30cd800 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -562,6 +562,13 @@ void ScriptEngineManager::clearTableOfContents(){ } } +ScriptValueType ScriptEngineManager::moveQObjectToScript(QObject* object, const QString objectName) +{ + ScriptValueType result = scriptEngine()->newQObject(object); + scriptEngine()->globalObject().setProperty(objectName, result); + return result; +} + void ScriptEngineManager::updateModel() { diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index 2241c85..076ee21 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -377,7 +377,7 @@ public: QVariant evaluateScript(const QString &script); void addTableOfContentsItem(const QString& uniqKey, const QString& content, int indent); void clearTableOfContents(); - + ScriptValueType moveQObjectToScript(QObject* object, const QString objectName); protected: void updateModel(); bool containsFunction(const QString &functionName); diff --git a/limereport/lrscriptenginemanagerintf.h b/limereport/lrscriptenginemanagerintf.h index 4c2767a..1d306bd 100644 --- a/limereport/lrscriptenginemanagerintf.h +++ b/limereport/lrscriptenginemanagerintf.h @@ -46,7 +46,9 @@ public: virtual bool addFunction(const QString &name, const QString& script, const QString &category="", const QString &description="") = 0; virtual const QString& lastError() const = 0; + virtual ScriptValueType moveQObjectToScript(QObject* object, const QString objectName) = 0; virtual ~IScriptEngineManager(){} + }; } //namespace LimeReport