From 0c1f6da51631c0a573a44e2f93eb4012d52dfe5c Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 20 Oct 2016 17:46:10 +0200 Subject: Get access to properties in indexes. --- common/domain/event.cpp | 5 +++++ common/domain/event.h | 2 ++ common/domain/folder.cpp | 5 +++++ common/domain/folder.h | 2 ++ common/domain/mail.cpp | 10 ++++++++++ common/domain/mail.h | 2 ++ 6 files changed, 26 insertions(+) (limited to 'common/domain') diff --git a/common/domain/event.cpp b/common/domain/event.cpp index a8098b7..10c92bb 100644 --- a/common/domain/event.cpp +++ b/common/domain/event.cpp @@ -50,3 +50,8 @@ void TypeImplementation::configure(WritePropertyMapper &pr propertyMapper.addMapping(&BufferBuilder::add_uid); propertyMapper.addMapping(&BufferBuilder::add_attachment); } + +void TypeImplementation::configure(IndexPropertyMapper &) +{ + +} diff --git a/common/domain/event.h b/common/domain/event.h index d85b9b3..b683f5f 100644 --- a/common/domain/event.h +++ b/common/domain/event.h @@ -26,6 +26,7 @@ template class ReadPropertyMapper; template class WritePropertyMapper; +class IndexPropertyMapper; class TypeIndex; @@ -49,6 +50,7 @@ public: static void configure(TypeIndex &); static void configure(ReadPropertyMapper &); static void configure(WritePropertyMapper &); + static void configure(IndexPropertyMapper &indexPropertyMapper); }; } diff --git a/common/domain/folder.cpp b/common/domain/folder.cpp index e6701ac..4bc2efb 100644 --- a/common/domain/folder.cpp +++ b/common/domain/folder.cpp @@ -51,3 +51,8 @@ void TypeImplementation::configure(WritePropertyMapper &p propertyMapper.addMapping(&BufferBuilder::add_icon); propertyMapper.addMapping(&BufferBuilder::add_specialpurpose); } + +void TypeImplementation::configure(IndexPropertyMapper &) +{ + +} diff --git a/common/domain/folder.h b/common/domain/folder.h index 3c83794..f232ab5 100644 --- a/common/domain/folder.h +++ b/common/domain/folder.h @@ -24,6 +24,7 @@ template class ReadPropertyMapper; template class WritePropertyMapper; +class IndexPropertyMapper; class TypeIndex; @@ -43,6 +44,7 @@ public: static void configure(TypeIndex &); static void configure(ReadPropertyMapper &); static void configure(WritePropertyMapper &); + static void configure(IndexPropertyMapper &indexPropertyMapper); }; } diff --git a/common/domain/mail.cpp b/common/domain/mail.cpp index 8abe259..c1b0b34 100644 --- a/common/domain/mail.cpp +++ b/common/domain/mail.cpp @@ -27,6 +27,7 @@ #include "entitybuffer.h" #include "entity_generated.h" #include "mail/threadindexer.h" +#include "domainadaptor.h" #include "mail_generated.h" @@ -53,6 +54,15 @@ void TypeImplementation::configure(TypeIndex &index) index.addSecondaryProperty(); } +void TypeImplementation::configure(IndexPropertyMapper &indexPropertyMapper) +{ + indexPropertyMapper.addIndexLookupProperty([](TypeIndex &index, const ApplicationDomain::BufferAdaptor &entity) { + auto messageId = entity.getProperty(Mail::MessageId::name); + auto thread = index.secondaryLookup(messageId); + Q_ASSERT(!thread.isEmpty()); + return thread.first(); + }); +} void TypeImplementation::configure(ReadPropertyMapper &propertyMapper) { diff --git a/common/domain/mail.h b/common/domain/mail.h index c12976a..e052448 100644 --- a/common/domain/mail.h +++ b/common/domain/mail.h @@ -26,6 +26,7 @@ template class ReadPropertyMapper; template class WritePropertyMapper; +class IndexPropertyMapper; class TypeIndex; @@ -44,6 +45,7 @@ public: static void configure(TypeIndex &index); static void configure(ReadPropertyMapper &propertyMapper); static void configure(WritePropertyMapper &propertyMapper); + static void configure(IndexPropertyMapper &indexPropertyMapper); }; } -- cgit v1.2.3