diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-15 12:46:26 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-15 12:46:26 +0100 |
commit | 972f3a4e96876e4c36162a11062e40863d88a2a1 (patch) | |
tree | e5173c26f35895e8f3386822d47b7b0d93374db5 /common/entitystorage.cpp | |
parent | d4b10a3de396eebc6c815093e9e1725ece270e9e (diff) | |
download | sink-972f3a4e96876e4c36162a11062e40863d88a2a1.tar.gz sink-972f3a4e96876e4c36162a11062e40863d88a2a1.zip |
Cleanup
Diffstat (limited to 'common/entitystorage.cpp')
-rw-r--r-- | common/entitystorage.cpp | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/common/entitystorage.cpp b/common/entitystorage.cpp deleted file mode 100644 index 5d4df9f..0000000 --- a/common/entitystorage.cpp +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #include "entitystorage.h" | ||
21 | |||
22 | ResultSet EntityStorageBase::filteredSet(const ResultSet &resultSet, const std::function<bool(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> &filter, const Akonadi2::Storage::Transaction &transaction, bool initialQuery) | ||
23 | { | ||
24 | auto resultSetPtr = QSharedPointer<ResultSet>::create(resultSet); | ||
25 | |||
26 | //Read through the source values and return whatever matches the filter | ||
27 | std::function<bool(std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)>)> generator = [this, resultSetPtr, &transaction, filter, initialQuery](std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)> callback) -> bool { | ||
28 | while (resultSetPtr->next()) { | ||
29 | readEntity(transaction, resultSetPtr->id(), [this, filter, callback, initialQuery](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject, Akonadi2::Operation operation) { | ||
30 | //Always remove removals, they probably don't match due to non-available properties | ||
31 | if (filter(domainObject) || operation == Akonadi2::Operation_Removal) { | ||
32 | if (initialQuery) { | ||
33 | //We're not interested in removals during the initial query | ||
34 | if (operation != Akonadi2::Operation_Removal) { | ||
35 | callback(domainObject, Akonadi2::Operation_Creation); | ||
36 | } | ||
37 | } else { | ||
38 | callback(domainObject, operation); | ||
39 | } | ||
40 | } | ||
41 | }); | ||
42 | } | ||
43 | return false; | ||
44 | }; | ||
45 | return ResultSet(generator); | ||
46 | } | ||
47 | |||
48 | |||
49 | ResultSet EntityStorageBase::getResultSet(const Akonadi2::Query &query, Akonadi2::Storage::Transaction &transaction, qint64 baseRevision) | ||
50 | { | ||
51 | QSet<QByteArray> remainingFilters = query.propertyFilter.keys().toSet(); | ||
52 | ResultSet resultSet; | ||
53 | const bool initialQuery = (baseRevision == 1); | ||
54 | if (initialQuery) { | ||
55 | Trace() << "Initial result set update"; | ||
56 | resultSet = loadInitialResultSet(query, transaction, remainingFilters); | ||
57 | } else { | ||
58 | //TODO fallback in case the old revision is no longer available to clear + redo complete initial scan | ||
59 | Trace() << "Incremental result set update" << baseRevision; | ||
60 | resultSet = loadIncrementalResultSet(baseRevision, query, transaction, remainingFilters); | ||
61 | } | ||
62 | |||
63 | auto filter = [remainingFilters, query, baseRevision](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject) -> bool { | ||
64 | for (const auto &filterProperty : remainingFilters) { | ||
65 | //TODO implement other comparison operators than equality | ||
66 | if (domainObject->getProperty(filterProperty) != query.propertyFilter.value(filterProperty)) { | ||
67 | return false; | ||
68 | } | ||
69 | } | ||
70 | return true; | ||
71 | }; | ||
72 | |||
73 | return filteredSet(resultSet, filter, transaction, initialQuery); | ||
74 | } | ||