diff options
Diffstat (limited to 'common/domain/folder.cpp')
-rw-r--r-- | common/domain/folder.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/common/domain/folder.cpp b/common/domain/folder.cpp index 824fa0b..f04a3e7 100644 --- a/common/domain/folder.cpp +++ b/common/domain/folder.cpp | |||
@@ -44,25 +44,30 @@ static QMutex sMutex; | |||
44 | 44 | ||
45 | using namespace Sink::ApplicationDomain; | 45 | using namespace Sink::ApplicationDomain; |
46 | 46 | ||
47 | void TypeImplementation<Folder>::configureIndex(TypeIndex &index) | ||
48 | { | ||
49 | index.addProperty<QByteArray>(Folder::Parent::name); | ||
50 | index.addProperty<QString>(Folder::Name::name); | ||
51 | } | ||
52 | |||
47 | static TypeIndex &getIndex() | 53 | static TypeIndex &getIndex() |
48 | { | 54 | { |
49 | QMutexLocker locker(&sMutex); | 55 | QMutexLocker locker(&sMutex); |
50 | static TypeIndex *index = 0; | 56 | static TypeIndex *index = 0; |
51 | if (!index) { | 57 | if (!index) { |
52 | index = new TypeIndex("folder"); | 58 | index = new TypeIndex("folder"); |
53 | index->addProperty<QByteArray>("parent"); | 59 | TypeImplementation<Folder>::configureIndex(*index); |
54 | index->addProperty<QString>("name"); | ||
55 | } | 60 | } |
56 | return *index; | 61 | return *index; |
57 | } | 62 | } |
58 | 63 | ||
59 | void TypeImplementation<Folder>::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction) | 64 | void TypeImplementation<Folder>::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::DataStore::Transaction &transaction) |
60 | { | 65 | { |
61 | SinkTrace() << "Indexing " << identifier; | 66 | SinkTrace() << "Indexing " << identifier; |
62 | getIndex().add(identifier, bufferAdaptor, transaction); | 67 | getIndex().add(identifier, bufferAdaptor, transaction); |
63 | } | 68 | } |
64 | 69 | ||
65 | void TypeImplementation<Folder>::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction) | 70 | void TypeImplementation<Folder>::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::DataStore::Transaction &transaction) |
66 | { | 71 | { |
67 | getIndex().remove(identifier, bufferAdaptor, transaction); | 72 | getIndex().remove(identifier, bufferAdaptor, transaction); |
68 | } | 73 | } |
@@ -87,10 +92,10 @@ QSharedPointer<WritePropertyMapper<TypeImplementation<Folder>::BufferBuilder> > | |||
87 | return propertyMapper; | 92 | return propertyMapper; |
88 | } | 93 | } |
89 | 94 | ||
90 | DataStoreQuery::Ptr TypeImplementation<Folder>::prepareQuery(const Sink::Query &query, Sink::Storage::Transaction &transaction) | 95 | DataStoreQuery::Ptr TypeImplementation<Folder>::prepareQuery(const Sink::Query &query, Sink::Storage::EntityStore::Ptr store) |
91 | { | 96 | { |
92 | auto mapper = initializeReadPropertyMapper(); | 97 | auto mapper = initializeReadPropertyMapper(); |
93 | return DataStoreQuery::Ptr::create(query, ApplicationDomain::getTypeName<Folder>(), transaction, getIndex(), [mapper](const Sink::Entity &entity, const QByteArray &property) { | 98 | return DataStoreQuery::Ptr::create(query, ApplicationDomain::getTypeName<Folder>(), store, getIndex(), [mapper](const Sink::Entity &entity, const QByteArray &property) { |
94 | const auto localBuffer = Sink::EntityBuffer::readBuffer<Buffer>(entity.local()); | 99 | const auto localBuffer = Sink::EntityBuffer::readBuffer<Buffer>(entity.local()); |
95 | return mapper->getProperty(property, localBuffer); | 100 | return mapper->getProperty(property, localBuffer); |
96 | }); | 101 | }); |