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