diff options
Diffstat (limited to 'common/domain')
-rw-r--r-- | common/domain/folder.cpp | 28 |
1 files changed, 28 insertions, 0 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() |