diff --git a/core/core.pro b/core/core.pro index c0a6c46..5e996c1 100644 --- a/core/core.pro +++ b/core/core.pro @@ -125,7 +125,8 @@ HEADERS += core.h\ reporting/reportviewer.h \ reporting/reportdialog.h \ iimporter.h \ - csvimporter.h + csvimporter.h \ + iimportprogress.h unix { target.path = /usr/lib diff --git a/core/csvimporter.h b/core/csvimporter.h index b395fd9..59a5489 100644 --- a/core/csvimporter.h +++ b/core/csvimporter.h @@ -5,7 +5,7 @@ #include #include -class CsvImporter : public QObject, public IImporter +class CORESHARED_EXPORT CsvImporter : public QObject, public IImporter { Q_OBJECT diff --git a/core/iimporter.h b/core/iimporter.h index 19d62a7..5326071 100644 --- a/core/iimporter.h +++ b/core/iimporter.h @@ -4,8 +4,9 @@ #include #include #include +#include "core_global.h" -class IImporter +class CORESHARED_EXPORT IImporter { public: explicit IImporter(const QMetaObject *metaObject) { m_metaObject = metaObject; } diff --git a/core/iimportprogress.h b/core/iimportprogress.h new file mode 100644 index 0000000..49fc035 --- /dev/null +++ b/core/iimportprogress.h @@ -0,0 +1,11 @@ +#ifndef IIMPORTPROGRESS_H +#define IIMPORTPROGRESS_H + +class IImportProgress +{ +public: + virtual void updateProgress(int currentPos) = 0; + virtual bool terminate() = 0; +}; + +#endif // IIMPORTPROGRESS_H diff --git a/core/service.h b/core/service.h index 60b9fa0..94c3760 100644 --- a/core/service.h +++ b/core/service.h @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include #include @@ -15,6 +17,7 @@ #include "iservice.h" #include "permissionevaluator.h" #include "iimporter.h" +#include "iimportprogress.h" #include "transaction.h" @@ -179,7 +182,7 @@ public: } } - bool importData(IImporter *importer) { + bool importData(IImporter *importer, IImportProgress *progress = NULL) { int count = importer->recordCount(); if (importer->isError()) { @@ -201,6 +204,18 @@ public: { return false; } + + qApp->processEvents(); + + if (progress != NULL && progress->terminate()) + { + return true; + } + + if (progress != NULL) + { + progress->updateProgress(i * 100 / count); + } } return true;