Import progress is shown while import.

master
Josef Rokos 8 years ago
parent 39ab4b74e2
commit dbbf4a0a67

@ -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

@ -5,7 +5,7 @@
#include <QStringList>
#include <QObject>
class CsvImporter : public QObject, public IImporter
class CORESHARED_EXPORT CsvImporter : public QObject, public IImporter
{
Q_OBJECT

@ -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; }

@ -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

@ -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;

Loading…
Cancel
Save