8#include "searchquery.h"
14using namespace KGAPI2::Drive;
20 Private(
const Private &other) =
default;
23 static QString compareOperatorToString(CompareOperator op);
24 static QString logicOperatorToString(LogicOperator op);
29 CompareOperator compareOp;
30 LogicOperator logicOp;
33QString SearchQuery::Private::compareOperatorToString(CompareOperator op)
37 return QStringLiteral(
" contains ");
39 return QStringLiteral(
" = ");
41 return QStringLiteral(
" != ");
43 return QStringLiteral(
" < ");
45 return QStringLiteral(
" <= ");
47 return QStringLiteral(
" > ");
49 return QStringLiteral(
" >= ");
51 return QStringLiteral(
" in ");
53 return QStringLiteral(
" has ");
60QString SearchQuery::Private::logicOperatorToString(SearchQuery::LogicOperator op)
64 return QStringLiteral(
" and ");
66 return QStringLiteral(
" or ");
73SearchQuery::SearchQuery(SearchQuery::LogicOperator op)
79SearchQuery::SearchQuery(
const SearchQuery &other) =
default;
81SearchQuery::~SearchQuery() =
default;
85void SearchQuery::addQuery(
const QString &field, SearchQuery::CompareOperator op,
const QString &value)
88 query.d->field = field;
89 query.d->compareOp = op;
91 d->subqueries.append(query);
96 d->subqueries.append(query);
99bool SearchQuery::isEmpty()
const
101 return d->value.isNull() && d->subqueries.isEmpty();
104QString SearchQuery::serialize()
const
112 if (d->subqueries.isEmpty()) {
113 if (d->compareOp == In) {
114 r += QStringLiteral(
"%1 in %2").
arg(d->value, d->field);
116 r += d->field % Private::compareOperatorToString(d->compareOp) % d->value;
121 for (iter = d->subqueries.constBegin(), end = d->subqueries.constEnd(); iter != end; ++iter) {
122 if (iter != d->subqueries.constBegin()) {
123 r += Private::logicOperatorToString(d->logicOp);
125 r += (*iter).serialize();
SearchQuery class should be used as a base class for building file/team search queries.
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
A job to fetch a single map tile described by a StaticMapUrl.
QAction * end(const QObject *recvr, const char *slot, QObject *parent)
T value(qsizetype i) const const
QString arg(Args &&... args) const const