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

IDataSource extracted to own file

This commit is contained in:
Arin Alexander 2019-01-24 22:10:15 +03:00
parent 3b94666a33
commit e5a0d2943d
7 changed files with 95 additions and 36 deletions

View File

@ -32,6 +32,7 @@
#include "lrcallbackdatasourceintf.h" #include "lrcallbackdatasourceintf.h"
#include "lrglobal.h" #include "lrglobal.h"
#include "lrdatasourceintf.h"
class QVariant; class QVariant;
class QString; class QString;
@ -40,12 +41,14 @@ namespace LimeReport{
class IDbCredentialsProvider{ class IDbCredentialsProvider{
public: public:
virtual ~IDbCredentialsProvider(){}
virtual QString getUserName(const QString& connectionName) = 0; virtual QString getUserName(const QString& connectionName) = 0;
virtual QString getPassword(const QString& connectionName) = 0; virtual QString getPassword(const QString& connectionName) = 0;
}; };
class IDataSourceManager{ class IDataSourceManager{
public: public:
virtual ~IDataSourceManager(){}
virtual void setReportVariable(const QString& name, const QVariant& value) = 0; virtual void setReportVariable(const QString& name, const QVariant& value) = 0;
virtual void setDefaultDatabasePath(const QString &defaultDatabasePath) = 0; virtual void setDefaultDatabasePath(const QString &defaultDatabasePath) = 0;
virtual void deleteVariable(const QString& name) = 0; virtual void deleteVariable(const QString& name) = 0;
@ -57,12 +60,13 @@ public:
virtual void clearUserVariables()=0; virtual void clearUserVariables()=0;
virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0; virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0;
virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0; virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0;
virtual QStringList variableNames() = 0; virtual QStringList variableNames() = 0;
virtual bool variableIsMandatory(const QString& name) = 0; virtual bool variableIsMandatory(const QString& name) = 0;
virtual VariableDataType variableDataType(const QString& name) = 0; virtual VariableDataType variableDataType(const QString& name) = 0;
virtual bool variableIsSystem(const QString& name) = 0; virtual bool variableIsSystem(const QString& name) = 0;
virtual IDataSource* dataSource(const QString& name) = 0;
}; };
} }
#endif // LRDATASOURCEMANAGERINTF_H #endif // LRDATASOURCEMANAGERINTF_H

View File

@ -131,6 +131,7 @@ HEADERS += \
$$REPORT_PATH/lrvariablesholder.h \ $$REPORT_PATH/lrvariablesholder.h \
$$REPORT_PATH/lrgroupfunctions.h \ $$REPORT_PATH/lrgroupfunctions.h \
$$REPORT_PATH/lrreportengine.h \ $$REPORT_PATH/lrreportengine.h \
$$REPORT_PATH/lrdatasourceintf.h \
$$REPORT_PATH/lrdatasourcemanagerintf.h \ $$REPORT_PATH/lrdatasourcemanagerintf.h \
$$REPORT_PATH/lrscriptenginemanagerintf.h \ $$REPORT_PATH/lrscriptenginemanagerintf.h \
$$REPORT_PATH/lrsimplecrypt.h \ $$REPORT_PATH/lrsimplecrypt.h \

View File

@ -34,6 +34,7 @@ contains(CONFIG, staticlib){
EXTRA_FILES += \ EXTRA_FILES += \
$$PWD/lrglobal.h \ $$PWD/lrglobal.h \
$$PWD/lrdatasourceintf.h \
$$PWD/lrdatasourcemanagerintf.h \ $$PWD/lrdatasourcemanagerintf.h \
$$PWD/lrreportengine.h \ $$PWD/lrreportengine.h \
$$PWD/lrscriptenginemanagerintf.h \ $$PWD/lrscriptenginemanagerintf.h \

View File

@ -40,46 +40,47 @@
#include <QVariant> #include <QVariant>
#include "lrcollection.h" #include "lrcollection.h"
#include "lrcallbackdatasourceintf.h" #include "lrcallbackdatasourceintf.h"
#include "lrdatasourceintf.h"
namespace LimeReport{ namespace LimeReport{
class DataSourceManager; class DataSourceManager;
class IDataSource { //class IDataSource {
public: //public:
enum DatasourceMode{DESIGN_MODE,RENDER_MODE}; // enum DatasourceMode{DESIGN_MODE,RENDER_MODE};
typedef QSharedPointer<IDataSource> Ptr; // typedef QSharedPointer<IDataSource> Ptr;
virtual ~IDataSource(){} // virtual ~IDataSource(){}
virtual bool next() = 0; // virtual bool next() = 0;
virtual bool hasNext() = 0; // virtual bool hasNext() = 0;
virtual bool prior() = 0; // virtual bool prior() = 0;
virtual void first() = 0; // virtual void first() = 0;
virtual void last() = 0; // virtual void last() = 0;
virtual bool bof() = 0; // virtual bool bof() = 0;
virtual bool eof() = 0; // virtual bool eof() = 0;
virtual QVariant data(const QString& columnName) = 0; // virtual QVariant data(const QString& columnName) = 0;
virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData) = 0; // virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData) = 0;
virtual int columnCount() = 0; // virtual int columnCount() = 0;
virtual QString columnNameByIndex(int columnIndex) = 0; // virtual QString columnNameByIndex(int columnIndex) = 0;
virtual int columnIndexByName(QString name) = 0; // virtual int columnIndexByName(QString name) = 0;
virtual bool isInvalid() const = 0; // virtual bool isInvalid() const = 0;
virtual QString lastError() = 0; // virtual QString lastError() = 0;
virtual QAbstractItemModel* model() = 0; // virtual QAbstractItemModel* model() = 0;
}; //};
class IDataSourceHolder { //class IDataSourceHolder {
public: //public:
virtual IDataSource* dataSource(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE) = 0; // virtual IDataSource* dataSource(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE) = 0;
virtual QString lastError() const = 0; // virtual QString lastError() const = 0;
virtual bool isInvalid() const = 0; // virtual bool isInvalid() const = 0;
virtual bool isOwned() const = 0; // virtual bool isOwned() const = 0;
virtual bool isEditable() const = 0; // virtual bool isEditable() const = 0;
virtual bool isRemovable() const = 0; // virtual bool isRemovable() const = 0;
virtual void invalidate(IDataSource::DatasourceMode mode, bool dbWillBeClosed = false) = 0; // virtual void invalidate(IDataSource::DatasourceMode mode, bool dbWillBeClosed = false) = 0;
virtual void update() = 0; // virtual void update() = 0;
virtual void clearErrors() = 0; // virtual void clearErrors() = 0;
virtual ~IDataSourceHolder(){} // virtual ~IDataSourceHolder(){}
}; //};
class ModelHolder: public QObject, public IDataSourceHolder{ class ModelHolder: public QObject, public IDataSourceHolder{
Q_OBJECT Q_OBJECT

View 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

View File

@ -38,6 +38,7 @@
#include "lrvariablesholder.h" #include "lrvariablesholder.h"
#include "lrgroupfunctions.h" #include "lrgroupfunctions.h"
#include "lrdatasourcemanagerintf.h" #include "lrdatasourcemanagerintf.h"
#include "lrdatasourceintf.h"
namespace LimeReport{ namespace LimeReport{

View File

@ -32,6 +32,7 @@
#include "lrcallbackdatasourceintf.h" #include "lrcallbackdatasourceintf.h"
#include "lrglobal.h" #include "lrglobal.h"
#include "lrdatasourceintf.h"
class QVariant; class QVariant;
class QString; class QString;
@ -40,12 +41,14 @@ namespace LimeReport{
class IDbCredentialsProvider{ class IDbCredentialsProvider{
public: public:
virtual ~IDbCredentialsProvider(){}
virtual QString getUserName(const QString& connectionName) = 0; virtual QString getUserName(const QString& connectionName) = 0;
virtual QString getPassword(const QString& connectionName) = 0; virtual QString getPassword(const QString& connectionName) = 0;
}; };
class IDataSourceManager{ class IDataSourceManager{
public: public:
virtual ~IDataSourceManager(){}
virtual void setReportVariable(const QString& name, const QVariant& value) = 0; virtual void setReportVariable(const QString& name, const QVariant& value) = 0;
virtual void setDefaultDatabasePath(const QString &defaultDatabasePath) = 0; virtual void setDefaultDatabasePath(const QString &defaultDatabasePath) = 0;
virtual void deleteVariable(const QString& name) = 0; virtual void deleteVariable(const QString& name) = 0;
@ -57,12 +60,13 @@ public:
virtual void clearUserVariables()=0; virtual void clearUserVariables()=0;
virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0; virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0;
virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0; virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0;
virtual QStringList variableNames() = 0; virtual QStringList variableNames() = 0;
virtual bool variableIsMandatory(const QString& name) = 0; virtual bool variableIsMandatory(const QString& name) = 0;
virtual VariableDataType variableDataType(const QString& name) = 0; virtual VariableDataType variableDataType(const QString& name) = 0;
virtual bool variableIsSystem(const QString& name) = 0; virtual bool variableIsSystem(const QString& name) = 0;
virtual IDataSource* dataSource(const QString& name) = 0;
}; };
} }
#endif // LRDATASOURCEMANAGERINTF_H #endif // LRDATASOURCEMANAGERINTF_H