summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/domain/mail.cpp14
-rw-r--r--common/typeindex.cpp13
-rw-r--r--common/typeindex.h6
3 files changed, 25 insertions, 8 deletions
diff --git a/common/domain/mail.cpp b/common/domain/mail.cpp
index f9a20d7..9f120cc 100644
--- a/common/domain/mail.cpp
+++ b/common/domain/mail.cpp
@@ -36,17 +36,15 @@ using namespace Sink::ApplicationDomain;
36 36
37void TypeImplementation<Mail>::configure(TypeIndex &index) 37void TypeImplementation<Mail>::configure(TypeIndex &index)
38{ 38{
39 index.addProperty<QByteArray>(Mail::Uid::name); 39 index.addProperty<Mail::Uid>();
40 index.addProperty<QByteArray>(Mail::Sender::name); 40 // index.addProperty<Mail::Sender>();
41 /* index.addProperty<QByteArray>(Mail::SenderName::name); */ 41 /* index.addProperty<QByteArray>(Mail::SenderName::name); */
42 /* index->addProperty<QString>(Mail::Subject::name); */ 42 /* index->addProperty<QString>(Mail::Subject::name); */
43 /* index->addFulltextProperty<QString>(Mail::Subject::name); */ 43 /* index->addFulltextProperty<QString>(Mail::Subject::name); */
44 index.addProperty<QDateTime>(Mail::Date::name); 44 index.addProperty<Mail::Date>();
45 index.addProperty<QByteArray>(Mail::Folder::name); 45 index.addProperty<Mail::Folder>();
46 index.addPropertyWithSorting<QByteArray, QDateTime>(Mail::Folder::name, Mail::Date::name); 46 index.addPropertyWithSorting<Mail::Folder, Mail::Date>();
47 index.addProperty<QByteArray>(Mail::MessageId::name); 47 index.addProperty<Mail::ParentMessageId>();
48 index.addProperty<QByteArray>(Mail::ParentMessageId::name);
49
50 index.addProperty<Mail::MessageId>(); 48 index.addProperty<Mail::MessageId>();
51 49
52 index.addSecondaryPropertyIndexer<Mail::MessageId, Mail::ThreadId, ThreadIndexer>(); 50 index.addSecondaryPropertyIndexer<Mail::MessageId, Mail::ThreadId, ThreadIndexer>();
diff --git a/common/typeindex.cpp b/common/typeindex.cpp
index 077bfa1..a65c676 100644
--- a/common/typeindex.cpp
+++ b/common/typeindex.cpp
@@ -103,6 +103,12 @@ void TypeIndex::addProperty<QDateTime>(const QByteArray &property)
103} 103}
104 104
105template <> 105template <>
106void TypeIndex::addProperty<ApplicationDomain::Reference>(const QByteArray &property)
107{
108 addProperty<QByteArray>(property);
109}
110
111template <>
106void TypeIndex::addPropertyWithSorting<QByteArray, QDateTime>(const QByteArray &property, const QByteArray &sortProperty) 112void TypeIndex::addPropertyWithSorting<QByteArray, QDateTime>(const QByteArray &property, const QByteArray &sortProperty)
107{ 113{
108 auto indexer = [=](const QByteArray &identifier, const QVariant &value, const QVariant &sortValue, Sink::Storage::DataStore::Transaction &transaction) { 114 auto indexer = [=](const QByteArray &identifier, const QVariant &value, const QVariant &sortValue, Sink::Storage::DataStore::Transaction &transaction) {
@@ -114,8 +120,15 @@ void TypeIndex::addPropertyWithSorting<QByteArray, QDateTime>(const QByteArray &
114 mSortedProperties.insert(property, sortProperty); 120 mSortedProperties.insert(property, sortProperty);
115} 121}
116 122
123template <>
124void TypeIndex::addPropertyWithSorting<ApplicationDomain::Reference, QDateTime>(const QByteArray &property, const QByteArray &sortProperty)
125{
126 addPropertyWithSorting<QByteArray, QDateTime>(property, sortProperty);
127}
128
117void TypeIndex::add(const QByteArray &identifier, const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Storage::DataStore::Transaction &transaction) 129void TypeIndex::add(const QByteArray &identifier, const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Storage::DataStore::Transaction &transaction)
118{ 130{
131 SinkTrace() << "add " << identifier;
119 for (const auto &property : mProperties) { 132 for (const auto &property : mProperties) {
120 const auto value = entity.getProperty(property); 133 const auto value = entity.getProperty(property);
121 auto indexer = mIndexer.value(property); 134 auto indexer = mIndexer.value(property);
diff --git a/common/typeindex.h b/common/typeindex.h
index 626959e..7ff2029 100644
--- a/common/typeindex.h
+++ b/common/typeindex.h
@@ -41,6 +41,12 @@ public:
41 template <typename T, typename S> 41 template <typename T, typename S>
42 void addPropertyWithSorting(const QByteArray &property, const QByteArray &sortProperty); 42 void addPropertyWithSorting(const QByteArray &property, const QByteArray &sortProperty);
43 43
44 template <typename T, typename S>
45 void addPropertyWithSorting()
46 {
47 addPropertyWithSorting<typename T::Type, typename S::Type>(T::name, S::name);
48 }
49
44 template <typename T> 50 template <typename T>
45 void addProperty() 51 void addProperty()
46 { 52 {