Refactor search queries: Introduced QSSQuery

Purpose is to seperate certain logic from SQLite and generalize it more.
Even though we only have Sqlite atm, in general the database layers
must be stupid as possible, while QSSQuery should do most of the hard work.

Fixes in Tokenizer logic.
Switched to C++17.
This commit is contained in:
2019-08-17 11:06:35 +02:00
parent ef6485117b
commit 404f05b89f
14 changed files with 504 additions and 620 deletions

View File

@ -1,6 +1,6 @@
QT -= gui
QT += sql concurrent
CONFIG += c++11 console
CONFIG += c++17 console
CONFIG -= app_bundle
# The following define makes your compiler emit warnings if you use
@ -32,7 +32,8 @@ SOURCES += \
databasefactory.cpp \
sqlitedbservice.cpp \
logger.cpp \
commandsearch.cpp
commandsearch.cpp \
commandlist.cpp
HEADERS += \
encodingdetector.h \
@ -53,7 +54,8 @@ HEADERS += \
databasefactory.h \
sqlitedbservice.h \
logger.h \
commandsearch.h
commandsearch.h \
commandlist.h
INCLUDEPATH += /usr/include/poppler/qt5/ /usr/include/quazip5

View File

@ -3,7 +3,6 @@
#include "databasefactory.h"
#include "logger.h"
int CommandSearch::handle(QStringList arguments)
{
QCommandLineParser parser;
@ -25,8 +24,7 @@ int CommandSearch::handle(QStringList arguments)
QStringList files = parser.positionalArguments();
QString queryStrings = files.join(' ');
auto results = dbService->search(queryStrings);
auto results = dbService->search(QSSQuery::build(queryStrings));
for(SearchResult &result : results)
{

View File

@ -20,11 +20,11 @@ bool SqliteDbService::fileExistsInDatabase(QString path, qint64 mtime)
return query.value(0).toBool();
}
QVector<SearchResult> SqliteDbService::search(QString searchQuery)
QVector<SearchResult> SqliteDbService::search(const QSSQuery &query)
{
auto connection = dbFactory->forCurrentThread();
SqliteSearch searcher(connection);
return searcher.search(searchQuery);
return searcher.search(query);
}
bool SqliteDbService::fileExistsInDatabase(QString path)

View File

@ -6,6 +6,7 @@
#include "pagedata.h"
#include "filedata.h"
#include "../shared/sqlitesearch.h"
#include "../shared/token.h"
enum SaveFileResult
{
OK,
@ -25,7 +26,7 @@ public:
bool deleteFile(QString path);
bool fileExistsInDatabase(QString path);
bool fileExistsInDatabase(QString path, qint64 mtime);
QVector<SearchResult> search(QString searchQuery);
QVector<SearchResult> search(const QSSQuery &query);
};