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

Merge tag '1.5.34' into develop

Finish 1.5.34
This commit is contained in:
Arin Alexander 2020-02-04 17:17:03 +03:00
commit f9a0277a3c
3 changed files with 34 additions and 42 deletions

View File

@ -1,5 +1,5 @@
# LimeReport v1.5.16 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bc31412ea4814f30825b5ed3723e9a70)](https://app.codacy.com/app/fralx/LimeReport?utm_source=github.com&utm_medium=referral&utm_content=fralx/LimeReport&utm_campaign=Badge_Grade_Dashboard) # LimeReport v1.5.33 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/bc31412ea4814f30825b5ed3723e9a70)](https://app.codacy.com/app/fralx/LimeReport?utm_source=github.com&utm_medium=referral&utm_content=fralx/LimeReport&utm_campaign=Badge_Grade_Dashboard)
## Official LimeReport web site [http://limereport.ru](http://limereport.ru) ## Official LimeReport web site [http://limereport.ru](http://limereport.ru)

View File

@ -60,14 +60,18 @@ QScriptValue constructColor(QScriptContext *context, QScriptEngine *engine)
namespace LimeReport{ namespace LimeReport{
ScriptEngineNode::ScriptEngineNode(const QString &name, const QString &description,
ScriptEngineNode::NodeType type, ScriptEngineNode *parent, const QIcon &icon)
:m_name(name), m_description(description), m_icon(icon), m_type(type), m_parent(parent)
{}
ScriptEngineNode::~ScriptEngineNode() ScriptEngineNode::~ScriptEngineNode()
{ {
for (int i = 0; i<m_childs.count(); ++i){ qDeleteAll(m_childs.begin(), m_childs.end());
delete m_childs[i];
}
} }
ScriptEngineNode*ScriptEngineNode::addChild(const QString& name, const QString& description, ScriptEngineNode::NodeType type, const QIcon& icon) ScriptEngineNode*ScriptEngineNode::addChild(const QString& name, const QString& description,
ScriptEngineNode::NodeType type, const QIcon& icon)
{ {
ScriptEngineNode* res = new ScriptEngineNode(name, description, type,this,icon); ScriptEngineNode* res = new ScriptEngineNode(name, description, type,this,icon);
m_childs.push_back(res); m_childs.push_back(res);
@ -213,26 +217,23 @@ ScriptEngineManager::~ScriptEngineManager()
bool ScriptEngineManager::isFunctionExists(const QString &functionName) const bool ScriptEngineManager::isFunctionExists(const QString &functionName) const
{ {
foreach (ScriptFunctionDesc desc, m_functions) { return m_functions.contains(functionName);
if (desc.name.compare(functionName,Qt::CaseInsensitive)==0){ // foreach (ScriptFunctionDesc desc, m_functions.values()) {
return true; // if (desc.name.compare(functionName,Qt::CaseInsensitive)==0){
} // return true;
} // }
return false; // }
// return false;
} }
void ScriptEngineManager::deleteFunction(const QString &functionsName) void ScriptEngineManager::deleteFunction(const QString &functionsName)
{ {
QMutableListIterator<ScriptFunctionDesc> it(m_functions); m_functions.remove(functionsName);
while(it.hasNext()){
if (it.next().name.compare(functionsName, Qt::CaseInsensitive)==0){
it.remove();
}
}
} }
bool ScriptEngineManager::addFunction(const JSFunctionDesc &functionDescriber) bool ScriptEngineManager::addFunction(const JSFunctionDesc &functionDescriber)
{ {
if (m_functions.contains(functionDescriber.name())) return false;
ScriptValueType functionManager = scriptEngine()->globalObject().property(functionDescriber.managerName()); ScriptValueType functionManager = scriptEngine()->globalObject().property(functionDescriber.managerName());
#ifdef USE_QJSENGINE #ifdef USE_QJSENGINE
if (functionManager.isUndefined()){ if (functionManager.isUndefined()){
@ -254,7 +255,7 @@ bool ScriptEngineManager::addFunction(const JSFunctionDesc &functionDescriber)
funct.description = functionDescriber.description(); funct.description = functionDescriber.description();
funct.category = functionDescriber.category(); funct.category = functionDescriber.category();
funct.type = ScriptFunctionDesc::Native; funct.type = ScriptFunctionDesc::Native;
m_functions.append(funct); m_functions.insert(funct.name, funct);
if (m_model) if (m_model)
m_model->updateModel(); m_model->updateModel();
return true; return true;
@ -269,15 +270,6 @@ bool ScriptEngineManager::addFunction(const JSFunctionDesc &functionDescriber)
} }
bool ScriptEngineManager::containsFunction(const QString& functionName){
foreach (ScriptFunctionDesc funct, m_functions) {
if (funct.name.compare(functionName)== 0){
return true;
}
}
return false;
}
#ifdef USE_QTSCRIPTENGINE #ifdef USE_QTSCRIPTENGINE
#if QT_VERSION > 0x050600 #if QT_VERSION > 0x050600
Q_DECL_DEPRECATED Q_DECL_DEPRECATED
@ -317,7 +309,7 @@ bool ScriptEngineManager::addFunction(const QString& name, const QString& script
funct.category = category; funct.category = category;
funct.description = description; funct.description = description;
funct.type = ScriptFunctionDesc::Script; funct.type = ScriptFunctionDesc::Script;
m_functions.append(funct); m_functions.insert(name, funct);
m_model->updateModel(); m_model->updateModel();
return true; return true;
} else { } else {
@ -328,16 +320,17 @@ bool ScriptEngineManager::addFunction(const QString& name, const QString& script
QStringList ScriptEngineManager::functionsNames() QStringList ScriptEngineManager::functionsNames()
{ {
QStringList res; return m_functions.keys();
foreach(ScriptFunctionDesc func, m_functions){ // QStringList res;
res<<func.name; // foreach(ScriptFunctionDesc func, m_functions){
} // res<<func.name;
return res; // }
// return res;
} }
void ScriptEngineManager::setDataManager(DataSourceManager *dataManager){ void ScriptEngineManager::setDataManager(DataSourceManager *dataManager){
if (dataManager && m_dataManager != dataManager){ if (dataManager && m_dataManager != dataManager){
m_dataManager = dataManager; m_dataManager = dataManager;
if (m_dataManager){ if (m_dataManager){
foreach(QString func, m_dataManager->groupFunctionNames()){ foreach(QString func, m_dataManager->groupFunctionNames()){
JSFunctionDesc describer( JSFunctionDesc describer(

View File

@ -98,14 +98,15 @@ struct ScriptFunctionDesc{
class ScriptEngineNode { class ScriptEngineNode {
public: public:
enum NodeType{Root,Category,Function,Dialog,DialogElement}; enum NodeType{Root, Category, Function, Dialog, DialogElement};
ScriptEngineNode(const QString& name="", const QString& description ="", NodeType type=Root, ScriptEngineNode* parent=0, const QIcon& icon=QIcon()) ScriptEngineNode(const QString& name = "", const QString& description = "", NodeType type = Root,
:m_name(name), m_description(description), m_icon(icon), m_type(type), m_parent(parent){} ScriptEngineNode* parent = 0, const QIcon& icon = QIcon());
virtual ~ScriptEngineNode(); virtual ~ScriptEngineNode();
int childCount(){return m_childs.count();} int childCount(){return m_childs.count();}
ScriptEngineNode* child(int index){return m_childs[index];} ScriptEngineNode* child(int index){return m_childs[index];}
ScriptEngineNode* parent(){return m_parent;} ScriptEngineNode* parent(){return m_parent;}
ScriptEngineNode* addChild(const QString& name="", const QString &description="", NodeType type=Root, const QIcon& icon=QIcon()); ScriptEngineNode* addChild(const QString& name = "", const QString &description = "",
NodeType type = Root, const QIcon& icon = QIcon());
int row(); int row();
QString name(){return m_name;} QString name(){return m_name;}
QString description(){return m_description;} QString description(){return m_description;}
@ -455,7 +456,7 @@ public:
const QString &category="", const QString &description=""); const QString &category="", const QString &description="");
const QString& lastError() const {return m_lastError;} const QString& lastError() const {return m_lastError;}
QStringList functionsNames(); QStringList functionsNames();
const QList<ScriptFunctionDesc>& functionsDescribers(){return m_functions;} const QHash<QString,ScriptFunctionDesc>& functionsDescribers(){return m_functions;}
ScriptEngineModel* model(){return m_model;} ScriptEngineModel* model(){return m_model;}
void setContext(ScriptEngineContext* context){m_context=context;} void setContext(ScriptEngineContext* context){m_context=context;}
DataSourceManager* dataManager() const {return m_dataManager;} DataSourceManager* dataManager() const {return m_dataManager;}
@ -473,10 +474,8 @@ public:
void addTableOfContentsItem(const QString& uniqKey, const QString& content, int indent); void addTableOfContentsItem(const QString& uniqKey, const QString& content, int indent);
void clearTableOfContents(); void clearTableOfContents();
ScriptValueType moveQObjectToScript(QObject* object, const QString objectName); ScriptValueType moveQObjectToScript(QObject* object, const QString objectName);
protected: protected:
void updateModel(); void updateModel();
bool containsFunction(const QString &functionName);
private: private:
Q_DISABLE_COPY(ScriptEngineManager) Q_DISABLE_COPY(ScriptEngineManager)
bool createLineFunction(); bool createLineFunction();
@ -503,7 +502,7 @@ private:
ScriptEngineManager(); ScriptEngineManager();
ScriptEngineType* m_scriptEngine; ScriptEngineType* m_scriptEngine;
QString m_lastError; QString m_lastError;
QList<ScriptFunctionDesc> m_functions; QHash<QString,ScriptFunctionDesc> m_functions;
ScriptEngineModel* m_model; ScriptEngineModel* m_model;
ScriptEngineContext* m_context; ScriptEngineContext* m_context;
DataSourceManager* m_dataManager; DataSourceManager* m_dataManager;