Import progress is shown while import.

This commit is contained in:
2017-04-25 21:36:23 +02:00
parent 39ab4b74e2
commit dbbf4a0a67
5 changed files with 32 additions and 4 deletions
+2 -1
View File
@@ -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
+1 -1
View File
@@ -5,7 +5,7 @@
#include <QStringList>
#include <QObject>
class CsvImporter : public QObject, public IImporter
class CORESHARED_EXPORT CsvImporter : public QObject, public IImporter
{
Q_OBJECT
+2 -1
View File
@@ -4,8 +4,9 @@
#include <QMetaObject>
#include <QObject>
#include <QSharedPointer>
#include "core_global.h"
class IImporter
class CORESHARED_EXPORT IImporter
{
public:
explicit IImporter(const QMetaObject *metaObject) { m_metaObject = metaObject; }
+11
View File
@@ -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
+16 -1
View File
@@ -4,6 +4,8 @@
#include <QList>
#include <QSharedPointer>
#include <QString>
#include <QEventLoop>
#include <QApplication>
#include <odb/core.hxx>
#include <odb/transaction.hxx>
@@ -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;