-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileImporter.h
47 lines (35 loc) · 956 Bytes
/
FileImporter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include "Database.h"
#include <QFuture>
#include <atomic>
class FileImporter: public QObject
{
Q_OBJECT
Q_PROPERTY(ImportStatus importStatus READ importStatus NOTIFY importStatusChanged)
public:
enum ImportStatus
{
READY,
LOADING,
PARSING,
IMPORTING,
INVALID_FILE,
ABORTED,
FINISHED
};
Q_ENUM(ImportStatus)
FileImporter(Database &db, QObject *parent = nullptr);
~FileImporter();
ImportStatus importStatus() const;
void importFile(const QString &filename);
void abortImporting();
signals:
void importStatusChanged(ImportStatus importStatus);
void importProgress(qint64 accountsProcessed, quint32 accountsTotal, qint64 accountsNew);
private:
void setImportStatus(ImportStatus importStatus);
Database &_db;
ImportStatus _importStatus = READY;
std::atomic<bool> _isAborted;
QFuture<void> _threadFuture;
};