[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [akonadi-next/develop] /: Use Query::parentProperty to express tree queries
From:       Christian Mollekopf <chrigi_1 () fastmail ! fm>
Date:       2015-11-30 17:52:46
Message-ID: E1a3Sd4-0003TI-BJ () scm ! kde ! org
[Download RAW message or body]

Git commit 9ad96df6cd1526de32bff2b4f98491dd8318f760 by Christian Mollekopf.
Committed on 24/11/2015 at 22:00.
Pushed by cmollekopf into branch 'develop'.

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.

M  +3    -4    common/facade.cpp
M  +1    -0    common/query.h
M  +1    -0    tests/querytest.cpp

http://commits.kde.org/akonadi-next/9ad96df6cd1526de32bff2b4f98491dd8318f760

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<class DomainType>
 qint64 GenericFacade<DomainType>::executeInitialQuery(const Akonadi2::Query &query, \
const typename DomainType::Ptr &parent, Akonadi2::ResultProviderInterface<typename \
DomainType::Ptr> &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<QByteArray> &remainingFilters) -> ResultSet {
         return loadInitialResultSet(modifiedQuery, transaction, remainingFilters);
@@ -365,6 +365,5 @@ qint64 GenericFacade<DomainType>::executeInitialQuery(const \
Akonadi2::Query &que  template class \
Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Folder>;  template class \
Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Mail>;  template class \
                Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>;
-// template class Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::AkonadiResource>;
  
 #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<QByteArray, QVariant> propertyFilter;
     //Properties to retrieve
     QSet<QByteArray> requestedProperties;
+    QByteArray parentProperty;
     bool syncOnDemand;
     bool processAll;
     //If live query is false, this query will not continuously be updated
diff --git a/tests/querytest.cpp b/tests/querytest.cpp
index 677dbac..fdfb609 100644
--- a/tests/querytest.cpp
+++ b/tests/querytest.cpp
@@ -145,6 +145,7 @@ private Q_SLOTS:
         query.resources << "org.kde.dummy.instance1";
         query.syncOnDemand = false;
         query.processAll = true;
+        query.parentProperty = "parent";
 
         //Ensure all local data is processed
         Akonadi2::Store::synchronize(query).exec().waitForFinished();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic