blob: c812ee85b2dba4253afdf95af22fe636b969c65c (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#ifndef IMPORTMANAGER_H
#define IMPORTMANAGER_H
#include "pluginservicebase.h"
#include "coreSQLiteStudio_global.h"
#include <QFlags>
#include <QStringList>
class ImportPlugin;
class Db;
class CfgEntry;
class API_EXPORT ImportManager : public PluginServiceBase
{
Q_OBJECT
public:
struct StandardImportConfig
{
/**
* @brief Text encoding.
*
* Always one of QTextCodec::availableCodecs().
* Codec is important for text-based data. For binary data it should irrelevant to the import plugin.
*/
QString codec;
/**
* @brief Name of the file that the import is being done from.
*
* This is provided just for information to the import process,
* but the plugin should use data stream provided to each called import method,
* instead of opening the file from this name.
*
* It will be null string if importing is not performed from a file, but from somewhere else
* (for example from a clipboard).
*/
QString inputFileName;
bool ignoreErrors = false;
bool skipTransaction = false;
bool noDbLock = false;
};
enum StandardConfigFlag
{
CODEC = 0x01, /**< Text encoding (see StandardImportConfig::codec). */
FILE_NAME = 0x02, /**< Input file (see StandardImportConfig::inputFileName). */
};
Q_DECLARE_FLAGS(StandardConfigFlags, StandardConfigFlag)
ImportManager();
QStringList getImportDataSourceTypes() const;
ImportPlugin* getPluginForDataSourceType(const QString& dataSourceType) const;
void configure(const QString& dataSourceType, const StandardImportConfig& config);
void importToTable(Db* db, const QString& table, bool async = true);
static bool isAnyPluginAvailable();
private:
StandardImportConfig importConfig;
ImportPlugin* plugin = nullptr;
bool importInProgress = false;
Db* db = nullptr;
QString table;
public slots:
void interrupt();
private slots:
void finalizeImport(bool result, int rowCount);
void handleTableCreated(Db* db, const QString& table);
signals:
void importFinished();
void importSuccessful();
void importFailed();
void orderWorkerToInterrupt();
void schemaModified(Db* db);
};
#define IMPORT_MANAGER SQLITESTUDIO->getImportManager()
Q_DECLARE_OPERATORS_FOR_FLAGS(ImportManager::StandardConfigFlags)
#endif // IMPORTMANAGER_H
|