looqs/gui/searchworker.cpp

38 lines
720 B
C++
Raw Normal View History

2018-09-02 12:27:23 +02:00
#include <QRegularExpression>
#include <QDebug>
2018-09-02 12:27:23 +02:00
#include <QSqlError>
#include <QStack>
#include "searchworker.h"
#include "../shared/sqlitesearch.h"
#include "qssgeneralexception.h"
SearchWorker::SearchWorker()
{
}
SearchWorker::SearchWorker(const QString &dbpath)
{
2018-09-02 12:27:23 +02:00
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(dbpath);
if(!db.open())
{
qDebug() << "failed to open database";
}
}
2018-09-02 12:27:23 +02:00
void SearchWorker::search(const QString &query)
{
SqliteSearch searcher(db);
try
{
auto result = searcher.search(query);
emit searchResultsReady(searcher.search(query));
}
catch(QSSGeneralException &e)
{
emit searchError(e.message);
}
2018-09-02 12:27:23 +02:00
}