Mercurial > dedupe
comparison SqliteDBLink.hpp @ 94:93981e675d67
Full support for bulkcommits.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Tue, 22 Oct 2013 14:11:50 +0200 |
| parents | 308a718812ba |
| children | c7da835ea912 |
comparison
equal
deleted
inserted
replaced
| 93:308a718812ba | 94:93981e675d67 |
|---|---|
| 2 #define SQLITEDBLINK_HPP | 2 #define SQLITEDBLINK_HPP |
| 3 #include "FileDBLink.hpp" | 3 #include "FileDBLink.hpp" |
| 4 | 4 |
| 5 #include <QtSql/QSqlDatabase> | 5 #include <QtSql/QSqlDatabase> |
| 6 #include <QtCore/QPair> | 6 #include <QtCore/QPair> |
| 7 #include <QtCore/QVariant> | |
| 7 | 8 |
| 8 class SqliteDBLink : public FileDBLink { | 9 class SqliteDBLink : public FileDBLink { |
| 9 public: | 10 public: |
| 10 SqliteDBLink(const QString& dbpath); | 11 SqliteDBLink(const QString& dbpath); |
| 11 ~SqliteDBLink(); | 12 ~SqliteDBLink(); |
| 28 const QStringList& files); | 29 const QStringList& files); |
| 29 virtual void deleteFileFromDB(const QString& path); | 30 virtual void deleteFileFromDB(const QString& path); |
| 30 bool commit(); | 31 bool commit(); |
| 31 | 32 |
| 32 private: | 33 private: |
| 33 typedef enum {Add, Update } OperationType; | 34 typedef enum {None = 0, Add, Update } OperationType; |
| 34 typedef QPair<DBInfo, OperationType> Operation; | 35 typedef QPair<DBInfo, OperationType> Operation; |
| 35 | 36 |
| 36 void addFile(const DBInfo& info, bool lazy = false); | 37 void addFile(const DBInfo& info, bool lazy = false); |
| 37 bool tryAddFile(const DBInfo& info); | 38 bool tryAddFile(const DBInfo& info); |
| 38 void updateFile(const DBInfo& dbinfo, bool lazy = false); | 39 void updateFile(const DBInfo& dbinfo, bool lazy = false); |
| 41 static const QString connectionName; | 42 static const QString connectionName; |
| 42 | 43 |
| 43 QSqlQuery* preparedSizePrefixQuery; | 44 QSqlQuery* preparedSizePrefixQuery; |
| 44 QSqlQuery* preparedSizeQuery; | 45 QSqlQuery* preparedSizeQuery; |
| 45 QSqlQuery* preparedTryAddQuery; | 46 QSqlQuery* preparedTryAddQuery; |
| 47 QSqlQuery* preparedUpdateQuery; | |
| 46 QList<Operation> operations; | 48 QList<Operation> operations; |
| 49 void executeOperation(QVariantList& paths, QVariantList& sizes, | |
| 50 QVariantList& mtimes, QVariantList& checksums, | |
| 51 OperationType operation); | |
| 47 }; | 52 }; |
| 48 | 53 |
| 49 #endif //MEMORYDBLINK_HPP | 54 #endif //MEMORYDBLINK_HPP |
