summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/domain/typeimplementations.cpp1
-rw-r--r--common/typeindex.cpp18
2 files changed, 19 insertions, 0 deletions
diff --git a/common/domain/typeimplementations.cpp b/common/domain/typeimplementations.cpp
index 4e61bad..40b0cfd 100644
--- a/common/domain/typeimplementations.cpp
+++ b/common/domain/typeimplementations.cpp
@@ -41,6 +41,7 @@ typedef IndexConfig<Mail,
41 ValueIndex<Mail::Folder>, 41 ValueIndex<Mail::Folder>,
42 ValueIndex<Mail::ParentMessageId>, 42 ValueIndex<Mail::ParentMessageId>,
43 ValueIndex<Mail::MessageId>, 43 ValueIndex<Mail::MessageId>,
44 ValueIndex<Mail::Draft>,
44 SortedIndex<Mail::Folder, Mail::Date>, 45 SortedIndex<Mail::Folder, Mail::Date>,
45 SecondaryIndex<Mail::MessageId, Mail::ThreadId>, 46 SecondaryIndex<Mail::MessageId, Mail::ThreadId>,
46 SecondaryIndex<Mail::ThreadId, Mail::MessageId>, 47 SecondaryIndex<Mail::ThreadId, Mail::MessageId>,
diff --git a/common/typeindex.cpp b/common/typeindex.cpp
index 3e66ffe..b8845b7 100644
--- a/common/typeindex.cpp
+++ b/common/typeindex.cpp
@@ -31,6 +31,10 @@ static QByteArray getByteArray(const QVariant &value)
31 if (result.isEmpty()) { 31 if (result.isEmpty()) {
32 return "nodate"; 32 return "nodate";
33 } 33 }
34 return result;
35 }
36 if (value.type() == QVariant::Bool) {
37 return value.toBool() ? "t" : "f";
34 } 38 }
35 if (value.canConvert<Sink::ApplicationDomain::Reference>()) { 39 if (value.canConvert<Sink::ApplicationDomain::Reference>()) {
36 const auto ba = value.value<Sink::ApplicationDomain::Reference>().value; 40 const auto ba = value.value<Sink::ApplicationDomain::Reference>().value;
@@ -83,6 +87,20 @@ void TypeIndex::addProperty<QByteArray>(const QByteArray &property)
83} 87}
84 88
85template <> 89template <>
90void TypeIndex::addProperty<bool>(const QByteArray &property)
91{
92 auto indexer = [this, property](bool add, const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction) {
93 if (add) {
94 Index(indexName(property), transaction).add(getByteArray(value), identifier);
95 } else {
96 Index(indexName(property), transaction).remove(getByteArray(value), identifier);
97 }
98 };
99 mIndexer.insert(property, indexer);
100 mProperties << property;
101}
102
103template <>
86void TypeIndex::addProperty<QString>(const QByteArray &property) 104void TypeIndex::addProperty<QString>(const QByteArray &property)
87{ 105{
88 auto indexer = [this, property](bool add, const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction) { 106 auto indexer = [this, property](bool add, const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction) {