2019-04-16 08:49:02 +02:00
|
|
|
#ifndef SQLITEDBSERVICE_H
|
|
|
|
#define SQLITEDBSERVICE_H
|
|
|
|
#include <QFileInfo>
|
2023-01-08 17:37:28 +01:00
|
|
|
#include <optional>
|
|
|
|
|
2019-04-16 08:49:02 +02:00
|
|
|
#include "databasefactory.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "pagedata.h"
|
|
|
|
#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);
|
|
|
|
|
2019-04-16 08:49:02 +02:00
|
|
|
public:
|
|
|
|
SqliteDbService(DatabaseFactory &dbFactory);
|
2023-01-08 17:37:28 +01:00
|
|
|
SaveFileResult saveFile(QFileInfo fileInfo, QVector<PageData> &pageData, bool pathsOnly);
|
2022-06-03 10:04:43 +02:00
|
|
|
unsigned int getFiles(QVector<FileData> &results, QString wildCardPattern, int offset, int limit);
|
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-02 21:38:55 +02:00
|
|
|
bool addTag(QString tag, QString path);
|
|
|
|
bool addTag(QString tag, const QVector<QString> &paths);
|
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);
|
2019-04-16 08:49:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SQLITEDBSERVICE_H
|