diff options
author | Rémi Nicole <nicole@kolabsystems.com> | 2018-05-28 10:08:49 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-05-28 10:09:31 +0200 |
commit | f400cee1d5896577c22626d0cf50478057989857 (patch) | |
tree | e24e77562e0e893f281965c512ca4b74f88b20d3 /common/query.cpp | |
parent | 411c7cdad70c5c7902002545fd107ed1b2ac06ac (diff) | |
download | sink-f400cee1d5896577c22626d0cf50478057989857.tar.gz sink-f400cee1d5896577c22626d0cf50478057989857.zip |
Implement ranged queries
Summary:
Notes:
- For now, only for QDateTime indexes
- Invalid QDateTimes are stored in the index (subject to change)
- Should be a drop-in replacement from ValueIndexes (except for `In` and `Contains` queries)
Reviewers: cmollekopf
Tags: #sink
Differential Revision: https://phabricator.kde.org/D13105
Diffstat (limited to 'common/query.cpp')
-rw-r--r-- | common/query.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/common/query.cpp b/common/query.cpp index 5f6d095..404a304 100644 --- a/common/query.cpp +++ b/common/query.cpp | |||
@@ -132,8 +132,8 @@ bool QueryBase::Filter::operator==(const QueryBase::Filter &other) const | |||
132 | 132 | ||
133 | bool QueryBase::operator==(const QueryBase &other) const | 133 | bool QueryBase::operator==(const QueryBase &other) const |
134 | { | 134 | { |
135 | auto ret = mType == other.mType | 135 | auto ret = mType == other.mType |
136 | && mSortProperty == other.mSortProperty | 136 | && mSortProperty == other.mSortProperty |
137 | && mBaseFilterStage == other.mBaseFilterStage; | 137 | && mBaseFilterStage == other.mBaseFilterStage; |
138 | return ret; | 138 | return ret; |
139 | } | 139 | } |
@@ -171,6 +171,14 @@ bool QueryBase::Comparator::matches(const QVariant &v) const | |||
171 | return false; | 171 | return false; |
172 | } | 172 | } |
173 | return value.value<QByteArrayList>().contains(v.toByteArray()); | 173 | return value.value<QByteArrayList>().contains(v.toByteArray()); |
174 | case Within: { | ||
175 | auto range = value.value<QList<QVariant>>(); | ||
176 | if (range.size() < 2) { | ||
177 | return false; | ||
178 | } | ||
179 | |||
180 | return range[0] <= v && v <= range[1]; | ||
181 | } | ||
174 | case Fulltext: | 182 | case Fulltext: |
175 | case Invalid: | 183 | case Invalid: |
176 | default: | 184 | default: |