Rename all symbols to new project name
Šī revīzija ir iekļauta:
@ -7,7 +7,7 @@
|
||||
#include <QSqlError>
|
||||
#include <QTextStream>
|
||||
#include <QDebug>
|
||||
#include "qssgeneralexception.h"
|
||||
#include "looqsgeneralexception.h"
|
||||
#include "common.h"
|
||||
|
||||
#define SETTINGS_KEY_DBPATH "dbpath"
|
||||
@ -66,13 +66,13 @@ void Common::ensureConfigured()
|
||||
{
|
||||
if(!dir.mkpath(dbpath))
|
||||
{
|
||||
throw QSSGeneralException("Failed to create dbpath directory");
|
||||
throw LooqsGeneralException("Failed to create dbpath directory");
|
||||
}
|
||||
}
|
||||
dbpath += "/qss.sqlite";
|
||||
dbpath += "/looqs.sqlite";
|
||||
if(!initSqliteDatabase(dbpath))
|
||||
{
|
||||
throw QSSGeneralException("Failed to initialize sqlite database");
|
||||
throw LooqsGeneralException("Failed to initialize sqlite database");
|
||||
}
|
||||
settings.setValue(SETTINGS_KEY_FIRSTRUN, false);
|
||||
settings.setValue(SETTINGS_KEY_DBPATH, dbpath);
|
||||
@ -83,7 +83,7 @@ void Common::ensureConfigured()
|
||||
QString dbpath = databasePath();
|
||||
if(!QFile::exists(dbpath))
|
||||
{
|
||||
throw QSSGeneralException("Database " + dbpath + " was not found");
|
||||
throw LooqsGeneralException("Database " + dbpath + " was not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,7 +92,7 @@ void Common::setupAppInfo()
|
||||
{
|
||||
QCoreApplication::setOrganizationName("quitesimple.org");
|
||||
QCoreApplication::setOrganizationDomain("quitesimple.org");
|
||||
QCoreApplication::setApplicationName("qss");
|
||||
QCoreApplication::setApplicationName("looqs");
|
||||
}
|
||||
|
||||
QString Common::databasePath()
|
||||
|
@ -1 +1 @@
|
||||
#include "qssgeneralexception.h"
|
||||
#include "looqsgeneralexception.h"
|
||||
|
@ -1,13 +1,13 @@
|
||||
#ifndef QSSGENERALEXCEPTION_H
|
||||
#define QSSGENERALEXCEPTION_H
|
||||
#ifndef LOOQSGENERALEXCEPTION_H
|
||||
#define LOOQSGENERALEXCEPTION_H
|
||||
|
||||
#include <QException>
|
||||
|
||||
class QSSGeneralException : public QException
|
||||
class LooqsGeneralException : public QException
|
||||
{
|
||||
public:
|
||||
QString message;
|
||||
QSSGeneralException(QString message)
|
||||
LooqsGeneralException(QString message)
|
||||
{
|
||||
this->message = message;
|
||||
}
|
||||
@ -15,10 +15,10 @@ class QSSGeneralException : public QException
|
||||
{
|
||||
throw *this;
|
||||
}
|
||||
QSSGeneralException *clone() const override
|
||||
LooqsGeneralException *clone() const override
|
||||
{
|
||||
return new QSSGeneralException(*this);
|
||||
return new LooqsGeneralException(*this);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QSSGENERALEXCEPTION_H
|
||||
#endif // LOOQSGENERALEXCEPTION_H
|
||||
|
@ -6,29 +6,29 @@
|
||||
#include <QDebug>
|
||||
#include <optional>
|
||||
#include <algorithm>
|
||||
#include "qssquery.h"
|
||||
#include "looqsquery.h"
|
||||
|
||||
const QVector<Token> &QSSQuery::getTokens() const
|
||||
const QVector<Token> &LooqsQuery::getTokens() const
|
||||
{
|
||||
return tokens;
|
||||
}
|
||||
|
||||
const QVector<SortCondition> &QSSQuery::getSortConditions() const
|
||||
const QVector<SortCondition> &LooqsQuery::getSortConditions() const
|
||||
{
|
||||
return sortConditions;
|
||||
}
|
||||
|
||||
QueryType QSSQuery::getQueryType()
|
||||
QueryType LooqsQuery::getQueryType()
|
||||
{
|
||||
return static_cast<QueryType>(tokensMask & COMBINED);
|
||||
}
|
||||
|
||||
void QSSQuery::addSortCondition(SortCondition sc)
|
||||
void LooqsQuery::addSortCondition(SortCondition sc)
|
||||
{
|
||||
this->sortConditions.append(sc);
|
||||
}
|
||||
|
||||
bool QSSQuery::checkParanthesis(QString expression)
|
||||
bool LooqsQuery::checkParanthesis(QString expression)
|
||||
{
|
||||
QStack<QChar> open;
|
||||
QStack<QChar> close;
|
||||
@ -104,14 +104,14 @@ QVector<SortCondition> createSortConditions(QString sortExpression)
|
||||
QStringList splitted = splitted_inner[i].split(" ");
|
||||
if(splitted.length() < 1 || splitted.length() > 2)
|
||||
{
|
||||
throw QSSGeneralException("sort specifier must have format [field] (asc|desc)");
|
||||
throw LooqsGeneralException("sort specifier must have format [field] (asc|desc)");
|
||||
}
|
||||
|
||||
QString field = splitted[0];
|
||||
auto queryField = fromString(field);
|
||||
if(!queryField)
|
||||
{
|
||||
throw QSSGeneralException("Unknown sort field supplied");
|
||||
throw LooqsGeneralException("Unknown sort field supplied");
|
||||
}
|
||||
|
||||
SortOrder order;
|
||||
@ -128,7 +128,7 @@ QVector<SortCondition> createSortConditions(QString sortExpression)
|
||||
}
|
||||
else
|
||||
{
|
||||
throw QSSGeneralException("Unknown order specifier: " + order);
|
||||
throw LooqsGeneralException("Unknown order specifier: " + order);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -145,7 +145,7 @@ QVector<SortCondition> createSortConditions(QString sortExpression)
|
||||
return result;
|
||||
}
|
||||
|
||||
void QSSQuery::addToken(Token t)
|
||||
void LooqsQuery::addToken(Token t)
|
||||
{
|
||||
tokens.append(t);
|
||||
tokensMask |= t.type;
|
||||
@ -157,14 +157,14 @@ void QSSQuery::addToken(Token t)
|
||||
* thus, "Downloads zip" becomes essentailly "path.contains:(Downloads) AND path.contains:(zip)"
|
||||
*
|
||||
* TODO: It's a bit ugly still*/
|
||||
QSSQuery QSSQuery::build(QString expression)
|
||||
LooqsQuery LooqsQuery::build(QString expression)
|
||||
{
|
||||
if(!checkParanthesis(expression))
|
||||
{
|
||||
throw QSSGeneralException("Invalid paranthesis");
|
||||
throw LooqsGeneralException("Invalid paranthesis");
|
||||
}
|
||||
|
||||
QSSQuery result;
|
||||
LooqsQuery result;
|
||||
// TODO: merge lonewords
|
||||
QRegularExpression rx("((?<filtername>(\\.|\\w)+):(?<args>\\((?<innerargs>[^\\)]+)\\)|([\\w,])+)|(?<boolean>AND|OR)"
|
||||
"|(?<negation>!)|(?<bracket>\\(|\\))|(?<loneword>\\w+))");
|
||||
@ -185,11 +185,11 @@ QSSQuery QSSQuery::build(QString expression)
|
||||
{
|
||||
if(previousWasBool())
|
||||
{
|
||||
throw QSSGeneralException("Can't have two booleans following each other");
|
||||
throw LooqsGeneralException("Can't have two booleans following each other");
|
||||
}
|
||||
if(previousWas(NEGATION))
|
||||
{
|
||||
throw QSSGeneralException("Can't have a negation preceeding a boolean");
|
||||
throw LooqsGeneralException("Can't have a negation preceeding a boolean");
|
||||
}
|
||||
if(boolean == "AND")
|
||||
{
|
||||
@ -204,7 +204,7 @@ QSSQuery QSSQuery::build(QString expression)
|
||||
{
|
||||
if(previousWas(NEGATION))
|
||||
{
|
||||
throw QSSGeneralException("Can't have two negations following each other");
|
||||
throw LooqsGeneralException("Can't have two negations following each other");
|
||||
}
|
||||
if(!previousWasBool())
|
||||
{
|
||||
@ -274,7 +274,7 @@ QSSQuery QSSQuery::build(QString expression)
|
||||
{
|
||||
if(!result.sortConditions.empty())
|
||||
{
|
||||
throw QSSGeneralException("Two sort statements are illegal");
|
||||
throw LooqsGeneralException("Two sort statements are illegal");
|
||||
}
|
||||
// TODO: hack, since we are not a "filter", we must remove a preceeding (implicit) boolean
|
||||
if(result.tokens.last().type & BOOL == BOOL)
|
||||
@ -286,7 +286,7 @@ QSSQuery QSSQuery::build(QString expression)
|
||||
}
|
||||
else
|
||||
{
|
||||
throw QSSGeneralException("Unknown filter provided!");
|
||||
throw LooqsGeneralException("Unknown filter provided!");
|
||||
}
|
||||
result.addToken(Token(tokenType, value));
|
||||
}
|
||||
@ -298,7 +298,7 @@ QSSQuery QSSQuery::build(QString expression)
|
||||
|
||||
if(!contentsearch && sortsForContent)
|
||||
{
|
||||
throw QSSGeneralException("We cannot sort by text if we don't search for it");
|
||||
throw LooqsGeneralException("We cannot sort by text if we don't search for it");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef QSSQUERY_H
|
||||
#define QSSQUERY_H
|
||||
#ifndef LOOQSQUERY_H
|
||||
#define LOOQSQUERY_H
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include "qssgeneralexception.h"
|
||||
#include "looqsgeneralexception.h"
|
||||
#include "token.h"
|
||||
/* Fields that can be queried or sorted */
|
||||
enum QueryField
|
||||
@ -34,7 +34,7 @@ enum QueryType
|
||||
COMBINED = PATH_ONLY | CONTENT_ONLY
|
||||
};
|
||||
|
||||
class QSSQuery
|
||||
class LooqsQuery
|
||||
{
|
||||
private:
|
||||
/* Helper field to determine quertype as well as to quickly check what kind of filters etc.
|
||||
@ -54,7 +54,7 @@ class QSSQuery
|
||||
}
|
||||
void addSortCondition(SortCondition sc);
|
||||
static bool checkParanthesis(QString query);
|
||||
static QSSQuery build(QString query);
|
||||
static LooqsQuery build(QString query);
|
||||
};
|
||||
|
||||
#endif // QSSQUERY_H
|
||||
#endif // LOOQSQUERY_H
|
||||
|
@ -25,16 +25,16 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += sqlitesearch.cpp \
|
||||
qssgeneralexception.cpp \
|
||||
qssquery.cpp \
|
||||
common.cpp
|
||||
looqsgeneralexception.cpp \
|
||||
common.cpp \
|
||||
looqsquery.cpp
|
||||
|
||||
HEADERS += sqlitesearch.h \
|
||||
filedata.h \
|
||||
looqsgeneralexception.h \
|
||||
looqsquery.h \
|
||||
searchresult.h \
|
||||
qssgeneralexception.h \
|
||||
token.h \
|
||||
qssquery.h \
|
||||
common.h
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
#include "sqlitesearch.h"
|
||||
#include "qssgeneralexception.h"
|
||||
#include "looqsgeneralexception.h"
|
||||
|
||||
SqliteSearch::SqliteSearch(QSqlDatabase &db)
|
||||
{
|
||||
@ -46,7 +46,7 @@ QString SqliteSearch::createSortSql(const QVector<SortCondition> sortConditions)
|
||||
QString field = fieldToColumn(sc.field);
|
||||
if(field == "")
|
||||
{
|
||||
throw QSSGeneralException("Unknown sort field supplied");
|
||||
throw LooqsGeneralException("Unknown sort field supplied");
|
||||
}
|
||||
if(sc.order == DESC)
|
||||
{
|
||||
@ -119,10 +119,10 @@ QPair<QString, QVector<QString>> SqliteSearch::createSql(const Token &token)
|
||||
"rank) ",
|
||||
{value}};
|
||||
}
|
||||
throw QSSGeneralException("Unknown token passed (should not happen)");
|
||||
throw LooqsGeneralException("Unknown token passed (should not happen)");
|
||||
}
|
||||
|
||||
QSqlQuery SqliteSearch::makeSqlQuery(const QSSQuery &query)
|
||||
QSqlQuery SqliteSearch::makeSqlQuery(const LooqsQuery &query)
|
||||
{
|
||||
QString whereSql;
|
||||
QString joinSql;
|
||||
@ -130,7 +130,7 @@ QSqlQuery SqliteSearch::makeSqlQuery(const QSSQuery &query)
|
||||
bool isContentSearch = query.getTokensMask() & FILTER_CONTENT == FILTER_CONTENT;
|
||||
if(query.getTokens().isEmpty())
|
||||
{
|
||||
throw QSSGeneralException("Nothing to search for supplied");
|
||||
throw LooqsGeneralException("Nothing to search for supplied");
|
||||
}
|
||||
|
||||
for(const Token &token : query.getTokens())
|
||||
@ -185,7 +185,7 @@ QSqlQuery SqliteSearch::makeSqlQuery(const QSSQuery &query)
|
||||
return dbquery;
|
||||
}
|
||||
|
||||
QVector<SearchResult> SqliteSearch::search(const QSSQuery &query)
|
||||
QVector<SearchResult> SqliteSearch::search(const LooqsQuery &query)
|
||||
{
|
||||
QVector<SearchResult> results;
|
||||
QSqlQuery dbQuery = makeSqlQuery(query);
|
||||
@ -195,7 +195,7 @@ QVector<SearchResult> SqliteSearch::search(const QSSQuery &query)
|
||||
|
||||
qDebug() << dbQuery.lastError();
|
||||
qDebug() << dbQuery.executedQuery();
|
||||
throw QSSGeneralException("SQL Error: " + dbQuery.lastError().text());
|
||||
throw LooqsGeneralException("SQL Error: " + dbQuery.lastError().text());
|
||||
}
|
||||
|
||||
while(dbQuery.next())
|
||||
|
@ -4,17 +4,17 @@
|
||||
#include <QPair>
|
||||
#include "searchresult.h"
|
||||
#include "token.h"
|
||||
#include "../shared/qssquery.h"
|
||||
#include "../shared/looqsquery.h"
|
||||
class SqliteSearch
|
||||
{
|
||||
|
||||
public:
|
||||
SqliteSearch(QSqlDatabase &db);
|
||||
QVector<SearchResult> search(const QSSQuery &query);
|
||||
QVector<SearchResult> search(const LooqsQuery &query);
|
||||
|
||||
private:
|
||||
QSqlDatabase *db;
|
||||
QSqlQuery makeSqlQuery(const QSSQuery &query);
|
||||
QSqlQuery makeSqlQuery(const LooqsQuery &query);
|
||||
QString fieldToColumn(QueryField field);
|
||||
QPair<QString, QVector<QString>> createSql(const Token &token);
|
||||
QString createSortSql(const QVector<SortCondition> sortConditions);
|
||||
|
Atsaukties uz šo jaunā problēmā
Block a user