From e5a0d2943d5a27e80894066df8c92deb197c12bb Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Thu, 24 Jan 2019 22:10:15 +0300 Subject: [PATCH] IDataSource extracted to own file --- include/lrdatasourcemanagerintf.h | 6 ++- limereport/limereport.pri | 1 + limereport/limereport.pro | 1 + limereport/lrdatadesignintf.h | 69 ++++++++++++++-------------- limereport/lrdatasourceintf.h | 47 +++++++++++++++++++ limereport/lrdatasourcemanager.h | 1 + limereport/lrdatasourcemanagerintf.h | 6 ++- 7 files changed, 95 insertions(+), 36 deletions(-) create mode 100644 limereport/lrdatasourceintf.h diff --git a/include/lrdatasourcemanagerintf.h b/include/lrdatasourcemanagerintf.h index f86e51e..a10cb05 100644 --- a/include/lrdatasourcemanagerintf.h +++ b/include/lrdatasourcemanagerintf.h @@ -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,13 @@ 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; }; } #endif // LRDATASOURCEMANAGERINTF_H + diff --git a/limereport/limereport.pri b/limereport/limereport.pri index 5e086a7..bc752e2 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -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 \ diff --git a/limereport/limereport.pro b/limereport/limereport.pro index 3c324b0..f790982 100644 --- a/limereport/limereport.pro +++ b/limereport/limereport.pro @@ -34,6 +34,7 @@ contains(CONFIG, staticlib){ EXTRA_FILES += \ $$PWD/lrglobal.h \ + $$PWD/lrdatasourceintf.h \ $$PWD/lrdatasourcemanagerintf.h \ $$PWD/lrreportengine.h \ $$PWD/lrscriptenginemanagerintf.h \ diff --git a/limereport/lrdatadesignintf.h b/limereport/lrdatadesignintf.h index 2336ad5..85d7957 100644 --- a/limereport/lrdatadesignintf.h +++ b/limereport/lrdatadesignintf.h @@ -40,46 +40,47 @@ #include #include "lrcollection.h" #include "lrcallbackdatasourceintf.h" +#include "lrdatasourceintf.h" namespace LimeReport{ class DataSourceManager; -class IDataSource { -public: - enum DatasourceMode{DESIGN_MODE,RENDER_MODE}; - typedef QSharedPointer 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 IDataSource { +//public: +// enum DatasourceMode{DESIGN_MODE,RENDER_MODE}; +// typedef QSharedPointer 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 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 diff --git a/limereport/lrdatasourceintf.h b/limereport/lrdatasourceintf.h new file mode 100644 index 0000000..c2a6c90 --- /dev/null +++ b/limereport/lrdatasourceintf.h @@ -0,0 +1,47 @@ +#ifndef LRDATASOURCEINTF_H +#define LRDATASOURCEINTF_H +#include +#include +namespace LimeReport { + +class IDataSource { +public: + enum DatasourceMode{DESIGN_MODE,RENDER_MODE}; + typedef QSharedPointer 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 + + diff --git a/limereport/lrdatasourcemanager.h b/limereport/lrdatasourcemanager.h index 628a5f5..74dfe20 100644 --- a/limereport/lrdatasourcemanager.h +++ b/limereport/lrdatasourcemanager.h @@ -38,6 +38,7 @@ #include "lrvariablesholder.h" #include "lrgroupfunctions.h" #include "lrdatasourcemanagerintf.h" +#include "lrdatasourceintf.h" namespace LimeReport{ diff --git a/limereport/lrdatasourcemanagerintf.h b/limereport/lrdatasourcemanagerintf.h index f86e51e..a10cb05 100644 --- a/limereport/lrdatasourcemanagerintf.h +++ b/limereport/lrdatasourcemanagerintf.h @@ -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,13 @@ 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; }; } #endif // LRDATASOURCEMANAGERINTF_H +