From 9ad96df6cd1526de32bff2b4f98491dd8318f760 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 24 Nov 2015 23:00:45 +0100 Subject: Use Query::parentProperty to express tree queries That way we don't have to hardcode the parent property, and we can use the property to express non-tree queries as well. --- common/facade.cpp | 7 +++---- common/query.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/facade.cpp b/common/facade.cpp index 08f7500..59972bf 100644 --- a/common/facade.cpp +++ b/common/facade.cpp @@ -350,12 +350,12 @@ template qint64 GenericFacade::executeInitialQuery(const Akonadi2::Query &query, const typename DomainType::Ptr &parent, Akonadi2::ResultProviderInterface &resultProvider) { auto modifiedQuery = query; - if (parent) { + if (parent && !query.parentProperty.isEmpty()) { Trace() << "Running initial query for parent:" << parent->identifier(); - modifiedQuery.propertyFilter.insert("parent", parent->identifier()); + modifiedQuery.propertyFilter.insert(query.parentProperty, parent->identifier()); } else { Trace() << "Running initial query for toplevel"; - modifiedQuery.propertyFilter.insert("parent", QVariant()); + modifiedQuery.propertyFilter.insert(query.parentProperty, QVariant()); } return load(modifiedQuery, [&](Akonadi2::Storage::Transaction &transaction, QSet &remainingFilters) -> ResultSet { return loadInitialResultSet(modifiedQuery, transaction, remainingFilters); @@ -365,6 +365,5 @@ qint64 GenericFacade::executeInitialQuery(const Akonadi2::Query &que template class Akonadi2::GenericFacade; template class Akonadi2::GenericFacade; template class Akonadi2::GenericFacade; -// template class Akonadi2::GenericFacade; #include "facade.moc" diff --git a/common/query.h b/common/query.h index 0cad9fb..5313fa9 100644 --- a/common/query.h +++ b/common/query.h @@ -53,6 +53,7 @@ public: QHash propertyFilter; //Properties to retrieve QSet requestedProperties; + QByteArray parentProperty; bool syncOnDemand; bool processAll; //If live query is false, this query will not continuously be updated -- cgit v1.2.3