LooqsQuery: Add hasContentSearch(),hasPathSearch() convenience functions

This commit is contained in:
Albert S. 2022-01-04 11:09:41 +01:00
parent 1f35e2120e
commit c0657947b1
2 changed files with 14 additions and 1 deletions

View File

@ -23,6 +23,16 @@ QueryType LooqsQuery::getQueryType()
return static_cast<QueryType>(tokensMask & COMBINED); return static_cast<QueryType>(tokensMask & COMBINED);
} }
bool LooqsQuery::hasContentSearch()
{
return (this->getTokensMask() & FILTER_CONTENT) == FILTER_CONTENT;
}
bool LooqsQuery::hasPathSearch()
{
return (this->getTokensMask() & FILTER_PATH) == FILTER_PATH;
}
void LooqsQuery::addSortCondition(SortCondition sc) void LooqsQuery::addSortCondition(SortCondition sc)
{ {
this->sortConditions.append(sc); this->sortConditions.append(sc);
@ -312,7 +322,7 @@ LooqsQuery LooqsQuery::build(QString expression, TokenType loneWordsTokenType, b
} }
} }
bool contentsearch = (result.getTokensMask() & FILTER_CONTENT) == FILTER_CONTENT; bool contentsearch = result.hasContentSearch();
bool sortsForContent = std::any_of(result.sortConditions.begin(), result.sortConditions.end(), bool sortsForContent = std::any_of(result.sortConditions.begin(), result.sortConditions.end(),
[](SortCondition c) { return c.field == CONTENT_TEXT; }); [](SortCondition c) { return c.field == CONTENT_TEXT; });

View File

@ -52,6 +52,9 @@ class LooqsQuery
{ {
return tokensMask; return tokensMask;
} }
bool hasContentSearch();
bool hasPathSearch();
void addSortCondition(SortCondition sc); void addSortCondition(SortCondition sc);
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);