diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-12 10:41:48 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-12 10:42:46 +0200 |
commit | d425436c268a748381f003646bd02e8d74ef7fba (patch) | |
tree | 5437c16b3752eae57001ef667248abe4361ff172 | |
parent | 8e91505e656743bd69166b3ba1cf29dfa7cfbea5 (diff) | |
download | sink-d425436c268a748381f003646bd02e8d74ef7fba.tar.gz sink-d425436c268a748381f003646bd02e8d74ef7fba.zip |
Added draft property index.
We need this for the composer to efficiently query.
Since we don't have any migration code this will require all data to be
refetched (sinksh upgrade).
-rw-r--r-- | common/domain/typeimplementations.cpp | 1 | ||||
-rw-r--r-- | common/typeindex.cpp | 18 |
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 | ||
85 | template <> | 89 | template <> |
90 | void 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 | |||
103 | template <> | ||
86 | void TypeIndex::addProperty<QString>(const QByteArray &property) | 104 | void 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) { |