2019-04-16 08:49:02 +02:00
|
|
|
#ifndef SQLITEDBSERVICE_H
|
|
|
|
#define SQLITEDBSERVICE_H
|
|
|
|
#include <QFileInfo>
|
2024-05-23 18:46:01 +02:00
|
|
|
#include <QMutexLocker>
|
2023-01-08 17:37:28 +01:00
|
|
|
#include <optional>
|
|
|
|
|
2019-04-16 08:49:02 +02:00
|
|
|
#include "databasefactory.h"
|
|
|
|
#include "utils.h"
|
2023-05-14 14:21:22 +02:00
|
|
|
#include "documentprocessresult.h"
|
2019-04-16 08:49:02 +02:00
|
|
|
#include "filedata.h"
|
2019-04-22 22:00:40 +02:00
|
|
|
#include "../shared/sqlitesearch.h"
|
2019-08-17 11:06:35 +02:00
|
|
|
#include "../shared/token.h"
|
2022-06-24 17:05:44 +02:00
|
|
|
#include "savefileresult.h"
|
2022-06-23 15:23:37 +02:00
|
|
|
|
2019-04-16 08:49:02 +02:00
|
|
|
class SqliteDbService
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
DatabaseFactory *dbFactory = nullptr;
|
2022-10-18 16:05:00 +02:00
|
|
|
bool insertToFTS(bool useTrigrams, QSqlDatabase &db, int fileid, QVector<PageData> &pageData);
|
2019-04-16 08:49:02 +02:00
|
|
|
|
2023-03-26 15:38:45 +02:00
|
|
|
QSqlQuery exec(QString query, std::initializer_list<QVariant> args);
|
|
|
|
bool execBool(QString querystr, std::initializer_list<QVariant> args);
|
|
|
|
|
2024-05-23 18:46:01 +02:00
|
|
|
bool beginTransaction(QSqlDatabase &db);
|
|
|
|
bool commitTransaction(QSqlDatabase &db);
|
|
|
|
|
|
|
|
QMutex writeMutex;
|
|
|
|
|
2019-04-16 08:49:02 +02:00
|
|
|
public:
|
|
|
|
SqliteDbService(DatabaseFactory &dbFactory);
|
2023-05-14 14:21:22 +02:00
|
|
|
SaveFileResult saveFile(QFileInfo fileInfo, DocumentProcessResult &pageData, bool pathsOnly);
|
2023-04-10 18:25:49 +02:00
|
|
|
|
2019-04-16 08:49:02 +02:00
|
|
|
bool deleteFile(QString path);
|
|
|
|
bool fileExistsInDatabase(QString path);
|
|
|
|
bool fileExistsInDatabase(QString path, qint64 mtime);
|
2023-03-26 15:38:45 +02:00
|
|
|
bool fileExistsInDatabase(QString path, qint64 mtime, QChar filetype);
|
2023-04-10 18:25:49 +02:00
|
|
|
unsigned int getFiles(QVector<FileData> &results, QString wildCardPattern, int offset, int limit);
|
|
|
|
|
2023-04-02 21:38:55 +02:00
|
|
|
bool addTag(QString tag, QString path);
|
|
|
|
bool addTag(QString tag, const QVector<QString> &paths);
|
2023-04-10 18:25:49 +02:00
|
|
|
QVector<QString> getTags();
|
|
|
|
QVector<QString> getTagsForPath(QString path);
|
2023-05-07 16:51:42 +02:00
|
|
|
QVector<QString> getPathsForTag(QString path);
|
2023-04-10 18:25:49 +02:00
|
|
|
bool setTags(QString path, const QSet<QString> &tags);
|
2023-05-07 16:51:42 +02:00
|
|
|
bool removePathsForTag(QString tag, const QVector<QString> &paths);
|
|
|
|
bool deleteTag(QString tag);
|
2023-04-10 18:25:49 +02:00
|
|
|
|
2021-06-12 14:59:58 +02:00
|
|
|
QVector<SearchResult> search(const LooqsQuery &query);
|
2023-01-08 17:37:28 +01:00
|
|
|
|
|
|
|
std::optional<QChar> queryFileType(QString absPath);
|
2023-05-14 14:21:22 +02:00
|
|
|
bool insertOutline(QSqlDatabase &db, int fileid, const QVector<DocumentOutlineEntry> &outlines);
|
2024-05-23 18:46:01 +02:00
|
|
|
|
|
|
|
bool runWalCheckpoint();
|
2019-04-16 08:49:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SQLITEDBSERVICE_H
|