diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/modelresult.cpp | 6 | ||||
-rw-r--r-- | common/query.cpp | 2 | ||||
-rw-r--r-- | common/query.h | 15 | ||||
-rw-r--r-- | common/queryrunner.cpp | 6 | ||||
-rw-r--r-- | common/test.cpp | 2 |
5 files changed, 21 insertions, 10 deletions
diff --git a/common/modelresult.cpp b/common/modelresult.cpp index 7565eea..16e3857 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp | |||
@@ -50,8 +50,8 @@ static qint64 getIdentifier(const QModelIndex &idx) | |||
50 | template <class T, class Ptr> | 50 | template <class T, class Ptr> |
51 | qint64 ModelResult<T, Ptr>::parentId(const Ptr &value) | 51 | qint64 ModelResult<T, Ptr>::parentId(const Ptr &value) |
52 | { | 52 | { |
53 | if (!mQuery.parentProperty.isEmpty()) { | 53 | if (!mQuery.parentProperty().isEmpty()) { |
54 | const auto identifier = value->getProperty(mQuery.parentProperty).toByteArray(); | 54 | const auto identifier = value->getProperty(mQuery.parentProperty()).toByteArray(); |
55 | if (!identifier.isEmpty()) { | 55 | if (!identifier.isEmpty()) { |
56 | return qHash(T(value->resourceInstanceIdentifier(), identifier, 0, QSharedPointer<Sink::ApplicationDomain::BufferAdaptor>())); | 56 | return qHash(T(value->resourceInstanceIdentifier(), identifier, 0, QSharedPointer<Sink::ApplicationDomain::BufferAdaptor>())); |
57 | } | 57 | } |
@@ -149,7 +149,7 @@ QModelIndex ModelResult<T, Ptr>::parent(const QModelIndex &index) const | |||
149 | template <class T, class Ptr> | 149 | template <class T, class Ptr> |
150 | bool ModelResult<T, Ptr>::hasChildren(const QModelIndex &parent) const | 150 | bool ModelResult<T, Ptr>::hasChildren(const QModelIndex &parent) const |
151 | { | 151 | { |
152 | if (mQuery.parentProperty.isEmpty() && parent.isValid()) { | 152 | if (mQuery.parentProperty().isEmpty() && parent.isValid()) { |
153 | return false; | 153 | return false; |
154 | } | 154 | } |
155 | //Figure out whether we have children | 155 | //Figure out whether we have children |
diff --git a/common/query.cpp b/common/query.cpp index caca775..14acde0 100644 --- a/common/query.cpp +++ b/common/query.cpp | |||
@@ -52,7 +52,7 @@ QDebug operator<<(QDebug dbg, const Sink::Query &query) | |||
52 | { | 52 | { |
53 | dbg << static_cast<Sink::QueryBase>(query); | 53 | dbg << static_cast<Sink::QueryBase>(query); |
54 | dbg.nospace() << " Requested: " << query.requestedProperties << "\n"; | 54 | dbg.nospace() << " Requested: " << query.requestedProperties << "\n"; |
55 | dbg.nospace() << " Parent: " << query.parentProperty << "\n"; | 55 | dbg.nospace() << " Parent: " << query.parentProperty() << "\n"; |
56 | dbg.nospace() << " IsLive: " << query.liveQuery() << "\n"; | 56 | dbg.nospace() << " IsLive: " << query.liveQuery() << "\n"; |
57 | return dbg.maybeSpace(); | 57 | return dbg.maybeSpace(); |
58 | } | 58 | } |
diff --git a/common/query.h b/common/query.h index 8459850..e77bfd9 100644 --- a/common/query.h +++ b/common/query.h | |||
@@ -296,10 +296,21 @@ public: | |||
296 | template <typename T> | 296 | template <typename T> |
297 | Query &requestTree() | 297 | Query &requestTree() |
298 | { | 298 | { |
299 | parentProperty = T::name; | 299 | mParentProperty = T::name; |
300 | return *this; | 300 | return *this; |
301 | } | 301 | } |
302 | 302 | ||
303 | Query &requestTree(const QByteArray &parentProperty) | ||
304 | { | ||
305 | mParentProperty = parentProperty; | ||
306 | return *this; | ||
307 | } | ||
308 | |||
309 | QByteArray parentProperty() const | ||
310 | { | ||
311 | return mParentProperty; | ||
312 | } | ||
313 | |||
303 | template <typename T> | 314 | template <typename T> |
304 | Query &sort() | 315 | Query &sort() |
305 | { | 316 | { |
@@ -374,7 +385,6 @@ public: | |||
374 | } | 385 | } |
375 | 386 | ||
376 | QByteArrayList requestedProperties; | 387 | QByteArrayList requestedProperties; |
377 | QByteArray parentProperty; | ||
378 | 388 | ||
379 | void setFlags(Flags flags) | 389 | void setFlags(Flags flags) |
380 | { | 390 | { |
@@ -442,6 +452,7 @@ private: | |||
442 | int mLimit; | 452 | int mLimit; |
443 | Flags mFlags; | 453 | Flags mFlags; |
444 | Filter mResourceFilter; | 454 | Filter mResourceFilter; |
455 | QByteArray mParentProperty; | ||
445 | }; | 456 | }; |
446 | 457 | ||
447 | class SyncScope : public QueryBase { | 458 | class SyncScope : public QueryBase { |
diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp index b6c9aee..cf56268 100644 --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp | |||
@@ -221,13 +221,13 @@ QPair<qint64, qint64> QueryWorker<DomainType>::executeInitialQuery( | |||
221 | time.start(); | 221 | time.start(); |
222 | 222 | ||
223 | auto modifiedQuery = query; | 223 | auto modifiedQuery = query; |
224 | if (!query.parentProperty.isEmpty()) { | 224 | if (!query.parentProperty().isEmpty()) { |
225 | if (parent) { | 225 | if (parent) { |
226 | SinkTrace() << "Running initial query for parent:" << parent->identifier(); | 226 | SinkTrace() << "Running initial query for parent:" << parent->identifier(); |
227 | modifiedQuery.filter(query.parentProperty, Query::Comparator(parent->identifier())); | 227 | modifiedQuery.filter(query.parentProperty(), Query::Comparator(parent->identifier())); |
228 | } else { | 228 | } else { |
229 | SinkTrace() << "Running initial query for toplevel"; | 229 | SinkTrace() << "Running initial query for toplevel"; |
230 | modifiedQuery.filter(query.parentProperty, Query::Comparator(QVariant())); | 230 | modifiedQuery.filter(query.parentProperty(), Query::Comparator(QVariant())); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | 233 | ||
diff --git a/common/test.cpp b/common/test.cpp index cf2e8a3..1a0d9bc 100644 --- a/common/test.cpp +++ b/common/test.cpp | |||
@@ -151,7 +151,7 @@ public: | |||
151 | for (const auto &res : mTestAccount->entities<T>()) { | 151 | for (const auto &res : mTestAccount->entities<T>()) { |
152 | qDebug() << "Parent filter " << query.getFilter("parent").value.toByteArray() << res->identifier() << res->getProperty("parent").toByteArray(); | 152 | qDebug() << "Parent filter " << query.getFilter("parent").value.toByteArray() << res->identifier() << res->getProperty("parent").toByteArray(); |
153 | auto parentProperty = res->getProperty("parent").toByteArray(); | 153 | auto parentProperty = res->getProperty("parent").toByteArray(); |
154 | if ((!parent && parentProperty.isEmpty()) || (parent && parentProperty == parent->identifier()) || query.parentProperty.isEmpty()) { | 154 | if ((!parent && parentProperty.isEmpty()) || (parent && parentProperty == parent->identifier()) || query.parentProperty().isEmpty()) { |
155 | qDebug() << "Found a match" << res->identifier(); | 155 | qDebug() << "Found a match" << res->identifier(); |
156 | resultProvider->add(res.template staticCast<T>()); | 156 | resultProvider->add(res.template staticCast<T>()); |
157 | } | 157 | } |