diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-04 08:25:18 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-04 08:25:18 +0200 |
commit | d6a01b3f82d626856001356c0875aa738a0346ac (patch) | |
tree | d77a6000e9d53be7844d72697496efa093b5f8ad /common/query.h | |
parent | 48ba18c92eede967afc4cf8894a3b06fd6a3c179 (diff) | |
download | sink-d6a01b3f82d626856001356c0875aa738a0346ac.tar.gz sink-d6a01b3f82d626856001356c0875aa738a0346ac.zip |
Support for subqueries.
This allows us to match properties from a subquery.
Unfortunately this also means that DataStoreQuery needs access to all
type implementations to issue the subquery (for potentially another type).
Diffstat (limited to 'common/query.h')
-rw-r--r-- | common/query.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/common/query.h b/common/query.h index 3362ac7..403c5b5 100644 --- a/common/query.h +++ b/common/query.h | |||
@@ -46,7 +46,8 @@ public: | |||
46 | enum Comparators { | 46 | enum Comparators { |
47 | Invalid, | 47 | Invalid, |
48 | Equals, | 48 | Equals, |
49 | Contains | 49 | Contains, |
50 | In | ||
50 | }; | 51 | }; |
51 | 52 | ||
52 | Comparator(); | 53 | Comparator(); |
@@ -158,6 +159,7 @@ public: | |||
158 | QByteArrayList requestedProperties; | 159 | QByteArrayList requestedProperties; |
159 | QByteArray parentProperty; | 160 | QByteArray parentProperty; |
160 | QByteArray sortProperty; | 161 | QByteArray sortProperty; |
162 | QByteArray type; | ||
161 | int limit; | 163 | int limit; |
162 | bool liveQuery; | 164 | bool liveQuery; |
163 | bool synchronousQuery; | 165 | bool synchronousQuery; |
@@ -222,6 +224,14 @@ public: | |||
222 | return filter(T::name, QVariant::fromValue(value.identifier())); | 224 | return filter(T::name, QVariant::fromValue(value.identifier())); |
223 | } | 225 | } |
224 | 226 | ||
227 | template <typename T> | ||
228 | Query &filter(const Query &query) | ||
229 | { | ||
230 | auto q = query; | ||
231 | q.type = ApplicationDomain::getTypeName<typename T::ReferenceType>(); | ||
232 | return filter(T::name, QVariant::fromValue(q)); | ||
233 | } | ||
234 | |||
225 | Query &filter(const ApplicationDomain::SinkResource &resource) | 235 | Query &filter(const ApplicationDomain::SinkResource &resource) |
226 | { | 236 | { |
227 | resources << resource.identifier(); | 237 | resources << resource.identifier(); |
@@ -353,3 +363,4 @@ public: | |||
353 | QDebug operator<<(QDebug dbg, const Sink::Query::Comparator &c); | 363 | QDebug operator<<(QDebug dbg, const Sink::Query::Comparator &c); |
354 | 364 | ||
355 | Q_DECLARE_OPERATORS_FOR_FLAGS(Sink::Query::Flags) | 365 | Q_DECLARE_OPERATORS_FOR_FLAGS(Sink::Query::Flags) |
366 | Q_DECLARE_METATYPE(Sink::Query); | ||