0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 16:44:39 +03:00

moveQObjectToScript() has been added to ScriptManager

This commit is contained in:
Arin Alexander 2019-01-30 01:53:21 +03:00
parent 6a18faf600
commit f48e414114
4 changed files with 12 additions and 1 deletions

View File

@ -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

View File

@ -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()
{

View File

@ -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);

View File

@ -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