diff options
Diffstat (limited to 'common/typeindex.cpp')
-rw-r--r-- | common/typeindex.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
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) { |