From 8296732635887e7b2ab738ba5da3154d8e3a06d3 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 10 May 2016 15:54:08 +0200 Subject: Some query API for use with property definitions --- common/query.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'common') diff --git a/common/query.h b/common/query.h index 8a420f9..8a7edf6 100644 --- a/common/query.h +++ b/common/query.h @@ -139,6 +139,40 @@ public: return query; } + template + Query &request() + { + requestedProperties << T::name; + return *this; + } + + template + Query &sort() + { + sortProperty = T::name; + return *this; + } + + template + Query &filter(const QVariant &value) + { + propertyFilter.insert(T::name, value); + return *this; + } + + template + Query &filter(const ApplicationDomain::Entity &value) + { + propertyFilter.insert(T::name, QVariant::fromValue(value.identifier())); + return *this; + } + + Query(const ApplicationDomain::Entity &value) : limit(0) + { + ids << value.identifier(); + resources << value.resourceInstanceIdentifier(); + } + Query(Flags flags = Flags()) : limit(0) { } -- cgit v1.2.3