shared: LooqsQuery: Allow constructing from tokens and sort conditions

このコミットが含まれているのは:
Albert S. 2022-07-28 17:50:29 +02:00
コミット c11fd1a9ff

ファイルの表示

@ -44,6 +44,13 @@ class LooqsQuery
QVector<Token> tokens; QVector<Token> tokens;
QVector<SortCondition> sortConditions; QVector<SortCondition> sortConditions;
void addToken(Token t); void addToken(Token t);
void updateTokensMask()
{
for(const Token &t : tokens)
{
this->tokensMask |= t.type;
}
}
public: public:
const QVector<Token> &getTokens() const; const QVector<Token> &getTokens() const;
@ -65,8 +72,34 @@ class LooqsQuery
bool hasPathSearch() const; bool hasPathSearch() const;
void addSortCondition(SortCondition sc); void addSortCondition(SortCondition sc);
void setTokens(const QVector<Token> &tokens)
{
this->tokens = tokens;
updateTokensMask();
}
static bool checkParanthesis(QString query); static bool checkParanthesis(QString query);
static LooqsQuery build(QString query, TokenType loneWordsTokenType, bool mergeLoneWords); static LooqsQuery build(QString query, TokenType loneWordsTokenType, bool mergeLoneWords);
LooqsQuery()
{
}
LooqsQuery(const QVector<Token> &tokens, const QVector<SortCondition> &sortConditions)
{
this->tokens = tokens;
this->sortConditions = sortConditions;
updateTokensMask();
}
LooqsQuery(const LooqsQuery &o)
{
this->tokens = o.tokens;
this->sortConditions = o.sortConditions;
this->tokensMask = o.tokensMask;
this->limit = o.limit;
}
}; };
#endif // LOOQSQUERY_H #endif // LOOQSQUERY_H