Import progress is shown while import.
This commit is contained in:
+2
-1
@@ -125,7 +125,8 @@ HEADERS += core.h\
|
|||||||
reporting/reportviewer.h \
|
reporting/reportviewer.h \
|
||||||
reporting/reportdialog.h \
|
reporting/reportdialog.h \
|
||||||
iimporter.h \
|
iimporter.h \
|
||||||
csvimporter.h
|
csvimporter.h \
|
||||||
|
iimportprogress.h
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
target.path = /usr/lib
|
target.path = /usr/lib
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class CsvImporter : public QObject, public IImporter
|
class CORESHARED_EXPORT CsvImporter : public QObject, public IImporter
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -4,8 +4,9 @@
|
|||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
#include "core_global.h"
|
||||||
|
|
||||||
class IImporter
|
class CORESHARED_EXPORT IImporter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit IImporter(const QMetaObject *metaObject) { m_metaObject = metaObject; }
|
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
|
||||||
+16
-1
@@ -4,6 +4,8 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QEventLoop>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
#include <odb/core.hxx>
|
#include <odb/core.hxx>
|
||||||
#include <odb/transaction.hxx>
|
#include <odb/transaction.hxx>
|
||||||
@@ -15,6 +17,7 @@
|
|||||||
#include "iservice.h"
|
#include "iservice.h"
|
||||||
#include "permissionevaluator.h"
|
#include "permissionevaluator.h"
|
||||||
#include "iimporter.h"
|
#include "iimporter.h"
|
||||||
|
#include "iimportprogress.h"
|
||||||
|
|
||||||
#include "transaction.h"
|
#include "transaction.h"
|
||||||
|
|
||||||
@@ -179,7 +182,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool importData(IImporter *importer) {
|
bool importData(IImporter *importer, IImportProgress *progress = NULL) {
|
||||||
int count = importer->recordCount();
|
int count = importer->recordCount();
|
||||||
|
|
||||||
if (importer->isError()) {
|
if (importer->isError()) {
|
||||||
@@ -201,6 +204,18 @@ public:
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qApp->processEvents();
|
||||||
|
|
||||||
|
if (progress != NULL && progress->terminate())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (progress != NULL)
|
||||||
|
{
|
||||||
|
progress->updateProgress(i * 100 / count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user