mirror of
https://github.com/fralx/LimeReport.git
synced 2025-01-11 17:18:10 +03:00
Finish ds_from_script
This commit is contained in:
commit
89139c108a
@ -32,6 +32,7 @@
|
||||
|
||||
#include "lrcallbackdatasourceintf.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourceintf.h"
|
||||
|
||||
class QVariant;
|
||||
class QString;
|
||||
@ -40,12 +41,14 @@ namespace LimeReport{
|
||||
|
||||
class IDbCredentialsProvider{
|
||||
public:
|
||||
virtual ~IDbCredentialsProvider(){}
|
||||
virtual QString getUserName(const QString& connectionName) = 0;
|
||||
virtual QString getPassword(const QString& connectionName) = 0;
|
||||
};
|
||||
|
||||
class IDataSourceManager{
|
||||
public:
|
||||
virtual ~IDataSourceManager(){}
|
||||
virtual void setReportVariable(const QString& name, const QVariant& value) = 0;
|
||||
virtual void setDefaultDatabasePath(const QString &defaultDatabasePath) = 0;
|
||||
virtual void deleteVariable(const QString& name) = 0;
|
||||
@ -57,12 +60,14 @@ public:
|
||||
virtual void clearUserVariables()=0;
|
||||
virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0;
|
||||
virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0;
|
||||
|
||||
virtual QStringList variableNames() = 0;
|
||||
virtual bool variableIsMandatory(const QString& name) = 0;
|
||||
virtual VariableDataType variableDataType(const QString& name) = 0;
|
||||
virtual bool variableIsSystem(const QString& name) = 0;
|
||||
virtual IDataSource* dataSource(const QString& name) = 0;
|
||||
virtual IDataSourceHolder* dataSourceHolder(const QString& name) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRDATASOURCEMANAGERINTF_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
|
||||
|
@ -131,6 +131,7 @@ HEADERS += \
|
||||
$$REPORT_PATH/lrvariablesholder.h \
|
||||
$$REPORT_PATH/lrgroupfunctions.h \
|
||||
$$REPORT_PATH/lrreportengine.h \
|
||||
$$REPORT_PATH/lrdatasourceintf.h \
|
||||
$$REPORT_PATH/lrdatasourcemanagerintf.h \
|
||||
$$REPORT_PATH/lrscriptenginemanagerintf.h \
|
||||
$$REPORT_PATH/lrsimplecrypt.h \
|
||||
|
@ -34,6 +34,7 @@ contains(CONFIG, staticlib){
|
||||
|
||||
EXTRA_FILES += \
|
||||
$$PWD/lrglobal.h \
|
||||
$$PWD/lrdatasourceintf.h \
|
||||
$$PWD/lrdatasourcemanagerintf.h \
|
||||
$$PWD/lrreportengine.h \
|
||||
$$PWD/lrscriptenginemanagerintf.h \
|
||||
|
@ -40,47 +40,12 @@
|
||||
#include <QVariant>
|
||||
#include "lrcollection.h"
|
||||
#include "lrcallbackdatasourceintf.h"
|
||||
#include "lrdatasourceintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class DataSourceManager;
|
||||
|
||||
class IDataSource {
|
||||
public:
|
||||
enum DatasourceMode{DESIGN_MODE,RENDER_MODE};
|
||||
typedef QSharedPointer<IDataSource> Ptr;
|
||||
virtual ~IDataSource(){}
|
||||
virtual bool next() = 0;
|
||||
virtual bool hasNext() = 0;
|
||||
virtual bool prior() = 0;
|
||||
virtual void first() = 0;
|
||||
virtual void last() = 0;
|
||||
virtual bool bof() = 0;
|
||||
virtual bool eof() = 0;
|
||||
virtual QVariant data(const QString& columnName) = 0;
|
||||
virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData) = 0;
|
||||
virtual int columnCount() = 0;
|
||||
virtual QString columnNameByIndex(int columnIndex) = 0;
|
||||
virtual int columnIndexByName(QString name) = 0;
|
||||
virtual bool isInvalid() const = 0;
|
||||
virtual QString lastError() = 0;
|
||||
virtual QAbstractItemModel* model() = 0;
|
||||
};
|
||||
|
||||
class IDataSourceHolder {
|
||||
public:
|
||||
virtual IDataSource* dataSource(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE) = 0;
|
||||
virtual QString lastError() const = 0;
|
||||
virtual bool isInvalid() const = 0;
|
||||
virtual bool isOwned() const = 0;
|
||||
virtual bool isEditable() const = 0;
|
||||
virtual bool isRemovable() const = 0;
|
||||
virtual void invalidate(IDataSource::DatasourceMode mode, bool dbWillBeClosed = false) = 0;
|
||||
virtual void update() = 0;
|
||||
virtual void clearErrors() = 0;
|
||||
virtual ~IDataSourceHolder(){}
|
||||
};
|
||||
|
||||
class ModelHolder: public QObject, public IDataSourceHolder{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
47
limereport/lrdatasourceintf.h
Normal file
47
limereport/lrdatasourceintf.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef LRDATASOURCEINTF_H
|
||||
#define LRDATASOURCEINTF_H
|
||||
#include <QSharedPointer>
|
||||
#include <QAbstractItemModel>
|
||||
namespace LimeReport {
|
||||
|
||||
class IDataSource {
|
||||
public:
|
||||
enum DatasourceMode{DESIGN_MODE,RENDER_MODE};
|
||||
typedef QSharedPointer<IDataSource> Ptr;
|
||||
virtual ~IDataSource() {}
|
||||
virtual bool next() = 0;
|
||||
virtual bool hasNext() = 0;
|
||||
virtual bool prior() = 0;
|
||||
virtual void first() = 0;
|
||||
virtual void last() = 0;
|
||||
virtual bool bof() = 0;
|
||||
virtual bool eof() = 0;
|
||||
virtual QVariant data(const QString& columnName) = 0;
|
||||
virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData) = 0;
|
||||
virtual int columnCount() = 0;
|
||||
virtual QString columnNameByIndex(int columnIndex) = 0;
|
||||
virtual int columnIndexByName(QString name) = 0;
|
||||
virtual bool isInvalid() const = 0;
|
||||
virtual QString lastError() = 0;
|
||||
virtual QAbstractItemModel* model() = 0;
|
||||
};
|
||||
|
||||
class IDataSourceHolder {
|
||||
public:
|
||||
virtual ~IDataSourceHolder(){}
|
||||
virtual IDataSource* dataSource(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE) = 0;
|
||||
virtual QString lastError() const = 0;
|
||||
virtual bool isInvalid() const = 0;
|
||||
virtual bool isOwned() const = 0;
|
||||
virtual bool isEditable() const = 0;
|
||||
virtual bool isRemovable() const = 0;
|
||||
virtual void invalidate(IDataSource::DatasourceMode mode, bool dbWillBeClosed = false) = 0;
|
||||
virtual void update() = 0;
|
||||
virtual void clearErrors() = 0;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRDATASOURCEINTF_H
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "lrvariablesholder.h"
|
||||
#include "lrgroupfunctions.h"
|
||||
#include "lrdatasourcemanagerintf.h"
|
||||
#include "lrdatasourceintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "lrcallbackdatasourceintf.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourceintf.h"
|
||||
|
||||
class QVariant;
|
||||
class QString;
|
||||
@ -40,12 +41,14 @@ namespace LimeReport{
|
||||
|
||||
class IDbCredentialsProvider{
|
||||
public:
|
||||
virtual ~IDbCredentialsProvider(){}
|
||||
virtual QString getUserName(const QString& connectionName) = 0;
|
||||
virtual QString getPassword(const QString& connectionName) = 0;
|
||||
};
|
||||
|
||||
class IDataSourceManager{
|
||||
public:
|
||||
virtual ~IDataSourceManager(){}
|
||||
virtual void setReportVariable(const QString& name, const QVariant& value) = 0;
|
||||
virtual void setDefaultDatabasePath(const QString &defaultDatabasePath) = 0;
|
||||
virtual void deleteVariable(const QString& name) = 0;
|
||||
@ -57,12 +60,14 @@ public:
|
||||
virtual void clearUserVariables()=0;
|
||||
virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0;
|
||||
virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0;
|
||||
|
||||
virtual QStringList variableNames() = 0;
|
||||
virtual bool variableIsMandatory(const QString& name) = 0;
|
||||
virtual VariableDataType variableDataType(const QString& name) = 0;
|
||||
virtual bool variableIsSystem(const QString& name) = 0;
|
||||
virtual IDataSource* dataSource(const QString& name) = 0;
|
||||
virtual IDataSourceHolder* dataSourceHolder(const QString& name) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRDATASOURCEMANAGERINTF_H
|
||||
|
||||
|
@ -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()
|
||||
{
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user