2021-06-12 14:59:58 +02:00
|
|
|
#ifndef LOOQSQUERY_H
|
|
|
|
#define LOOQSQUERY_H
|
2019-08-17 11:06:35 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QVector>
|
2021-06-12 14:59:58 +02:00
|
|
|
#include "looqsgeneralexception.h"
|
2019-08-17 11:06:35 +02:00
|
|
|
#include "token.h"
|
|
|
|
/* Fields that can be queried or sorted */
|
|
|
|
enum QueryField
|
|
|
|
{
|
|
|
|
FILE_PATH,
|
|
|
|
FILE_MTIME,
|
|
|
|
FILE_SIZE,
|
|
|
|
CONTENT_TEXT,
|
|
|
|
CONTENT_TEXT_PAGE
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SortOrder
|
|
|
|
{
|
|
|
|
ASC,
|
|
|
|
DESC
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SortCondition
|
|
|
|
{
|
|
|
|
QueryField field;
|
|
|
|
SortOrder order;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum QueryType
|
|
|
|
{
|
|
|
|
NOTHING = 0,
|
|
|
|
PATH_ONLY = FILTER_PATH,
|
|
|
|
CONTENT_ONLY = FILTER_CONTENT,
|
|
|
|
COMBINED = PATH_ONLY | CONTENT_ONLY
|
|
|
|
};
|
|
|
|
|
2021-06-12 14:59:58 +02:00
|
|
|
class LooqsQuery
|
2019-08-17 11:06:35 +02:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
/* Helper field to determine quertype as well as to quickly check what kind of filters etc.
|
|
|
|
* are being used in this query*/
|
2021-06-12 22:48:59 +02:00
|
|
|
int tokensMask = 0;
|
2022-06-04 23:12:58 +02:00
|
|
|
int limit = -1;
|
2019-08-17 11:06:35 +02:00
|
|
|
QVector<Token> tokens;
|
|
|
|
QVector<SortCondition> sortConditions;
|
|
|
|
void addToken(Token t);
|
|
|
|
|
|
|
|
public:
|
|
|
|
const QVector<Token> &getTokens() const;
|
|
|
|
const QVector<SortCondition> &getSortConditions() const;
|
|
|
|
QueryType getQueryType();
|
|
|
|
int getTokensMask() const
|
|
|
|
{
|
|
|
|
return tokensMask;
|
|
|
|
}
|
2022-06-04 23:12:58 +02:00
|
|
|
int getLimit() const
|
|
|
|
{
|
|
|
|
return limit;
|
|
|
|
}
|
|
|
|
void setLimit(int limit)
|
|
|
|
{
|
|
|
|
this->limit = limit;
|
|
|
|
}
|
2022-01-04 11:09:41 +01:00
|
|
|
bool hasContentSearch();
|
|
|
|
bool hasPathSearch();
|
|
|
|
|
2019-08-19 21:09:03 +02:00
|
|
|
void addSortCondition(SortCondition sc);
|
2019-08-17 11:06:35 +02:00
|
|
|
static bool checkParanthesis(QString query);
|
2021-12-30 12:17:12 +01:00
|
|
|
static LooqsQuery build(QString query, TokenType loneWordsTokenType, bool mergeLoneWords);
|
2019-08-17 11:06:35 +02:00
|
|
|
};
|
|
|
|
|
2021-06-12 14:59:58 +02:00
|
|
|
#endif // LOOQSQUERY_H
|