aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/importworker.h
blob: c3ef7211cf534dc5e7c70a6f02b607532d2802d0 (plain) (blame)
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
#ifndef IMPORTWORKER_H
#define IMPORTWORKER_H

#include "services/importmanager.h"
#include <QObject>
#include <QRunnable>
#include <QMutex>

class ImportWorker : public QObject, public QRunnable
{
        Q_OBJECT
    public:
        ImportWorker(ImportPlugin* plugin, ImportManager::StandardImportConfig* config, Db* db, const QString& table, QObject *parent = 0);

        void run();

    private:
        void readPluginColumns();
        void error(const QString& err);
        bool prepareTable();
        bool importData(int& rowCount);
        bool isInterrupted();

        ImportPlugin* plugin = nullptr;
        ImportManager::StandardImportConfig* config = nullptr;
        Db* db = nullptr;
        QString table;
        QStringList columnsFromPlugin;
        QStringList columnTypesFromPlugin;
        QStringList tableColumns;
        QStringList targetColumns;
        bool interrupted = false;
        QMutex interruptMutex;
        bool tableCreated = false;
        bool shouldSkipTransaction = false;

    public slots:
        void interrupt();

    signals:
        void createdTable(Db* db, const QString& table);
        void finished(bool result, int rowCount);
};

#endif // IMPORTWORKER_H