diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-15 11:09:31 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-15 11:09:31 +0100 |
commit | d4b10a3de396eebc6c815093e9e1725ece270e9e (patch) | |
tree | baa77406ae79bedee9b74b836789c3370b1fa934 /common | |
parent | ec902175d53d371b03d8e754d917e196cd15aafa (diff) | |
download | sink-d4b10a3de396eebc6c815093e9e1725ece270e9e.tar.gz sink-d4b10a3de396eebc6c815093e9e1725ece270e9e.zip |
Working folder tree query
Diffstat (limited to 'common')
-rw-r--r-- | common/domain/folder.cpp | 28 | ||||
-rw-r--r-- | common/modelresult.h | 5 |
2 files changed, 30 insertions, 3 deletions
diff --git a/common/domain/folder.cpp b/common/domain/folder.cpp index 50f73c2..82f6c1f 100644 --- a/common/domain/folder.cpp +++ b/common/domain/folder.cpp | |||
@@ -37,15 +37,43 @@ using namespace Akonadi2::ApplicationDomain; | |||
37 | ResultSet TypeImplementation<Folder>::queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction) | 37 | ResultSet TypeImplementation<Folder>::queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction) |
38 | { | 38 | { |
39 | QVector<QByteArray> keys; | 39 | QVector<QByteArray> keys; |
40 | if (query.propertyFilter.contains("parent")) { | ||
41 | Index index("folder.index.parent", transaction); | ||
42 | auto lookupKey = query.propertyFilter.value("parent").toByteArray(); | ||
43 | if (lookupKey.isEmpty()) { | ||
44 | lookupKey = "toplevel"; | ||
45 | } | ||
46 | index.lookup(lookupKey, [&](const QByteArray &value) { | ||
47 | keys << value; | ||
48 | }, | ||
49 | [](const Index::Error &error) { | ||
50 | Warning() << "Error in uid index: " << error.message; | ||
51 | }); | ||
52 | appliedFilters << "parent"; | ||
53 | } | ||
54 | Trace() << "Index lookup found " << keys.size() << " keys."; | ||
40 | return ResultSet(keys); | 55 | return ResultSet(keys); |
41 | } | 56 | } |
42 | 57 | ||
43 | void TypeImplementation<Folder>::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | 58 | void TypeImplementation<Folder>::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) |
44 | { | 59 | { |
60 | const auto parent = bufferAdaptor.getProperty("parent"); | ||
61 | Trace() << "indexing " << identifier << " with parent " << parent.toByteArray(); | ||
62 | if (parent.isValid()) { | ||
63 | Index("folder.index.parent", transaction).add(parent.toByteArray(), identifier); | ||
64 | } else { | ||
65 | Index("folder.index.parent", transaction).add("toplevel", identifier); | ||
66 | } | ||
45 | } | 67 | } |
46 | 68 | ||
47 | void TypeImplementation<Folder>::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | 69 | void TypeImplementation<Folder>::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) |
48 | { | 70 | { |
71 | const auto parent = bufferAdaptor.getProperty("parent"); | ||
72 | if (parent.isValid()) { | ||
73 | Index("folder.index.parent", transaction).remove(parent.toByteArray(), identifier); | ||
74 | } else { | ||
75 | Index("folder.index.parent", transaction).remove("toplevel", identifier); | ||
76 | } | ||
49 | } | 77 | } |
50 | 78 | ||
51 | QSharedPointer<ReadPropertyMapper<TypeImplementation<Folder>::Buffer> > TypeImplementation<Folder>::initializeReadPropertyMapper() | 79 | QSharedPointer<ReadPropertyMapper<TypeImplementation<Folder>::Buffer> > TypeImplementation<Folder>::initializeReadPropertyMapper() |
diff --git a/common/modelresult.h b/common/modelresult.h index eabb868..8ca6daa 100644 --- a/common/modelresult.h +++ b/common/modelresult.h | |||
@@ -116,7 +116,7 @@ public: | |||
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | auto parent = createIndexFromId(id); | 118 | auto parent = createIndexFromId(id); |
119 | qDebug() << "Added entity " << childId; | 119 | qDebug() << "Added entity " << childId << value->identifier(); |
120 | const auto keys = mTree[id]; | 120 | const auto keys = mTree[id]; |
121 | int index = 0; | 121 | int index = 0; |
122 | for (; index < keys.size(); index++) { | 122 | for (; index < keys.size(); index++) { |
@@ -166,7 +166,6 @@ public: | |||
166 | 166 | ||
167 | void fetchEntities(const QModelIndex &parent) | 167 | void fetchEntities(const QModelIndex &parent) |
168 | { | 168 | { |
169 | qDebug() << "Fetching entities"; | ||
170 | const auto id = getIdentifier(parent); | 169 | const auto id = getIdentifier(parent); |
171 | mEntityChildrenFetched[id] = true; | 170 | mEntityChildrenFetched[id] = true; |
172 | QByteArray parentIdentifier; | 171 | QByteArray parentIdentifier; |
@@ -178,7 +177,7 @@ public: | |||
178 | Q_ASSERT(object); | 177 | Q_ASSERT(object); |
179 | parentIdentifier = object->identifier(); | 178 | parentIdentifier = object->identifier(); |
180 | } | 179 | } |
181 | Trace() << "Loading entities"; | 180 | Trace() << "Loading child entities of: " << parentIdentifier; |
182 | loadEntities(parentIdentifier); | 181 | loadEntities(parentIdentifier); |
183 | } | 182 | } |
184 | 183 | ||