1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtOrganizer module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#include "qorganizeritemdetailrangefilter.h"
35#include "qorganizeritemdetailrangefilter_p.h"
36
37QT_BEGIN_NAMESPACE_ORGANIZER
38
39/*!
40 \class QOrganizerItemDetailRangeFilter
41 \brief The QOrganizerItemDetailRangeFilter class provides a filter based around a detail value
42 range criterion.
43 \inmodule QtOrganizer
44 \ingroup organizer-filters
45
46 It may be used to select organizer items which contain a detail of a particular type, whose value
47 falls in a particular range.
48 */
49
50Q_IMPLEMENT_ORGANIZERITEMFILTER_PRIVATE(QOrganizerItemDetailRangeFilter)
51
52/*!
53 \fn QOrganizerItemDetailRangeFilter::QOrganizerItemDetailRangeFilter(const QOrganizerItemFilter &other)
54
55 Constructs a copy of \a other if possible, otherwise constructs a new detail range filter.
56 */
57
58/*!
59 \enum QOrganizerItemDetailRangeFilter::RangeFlag
60
61 This enumeration describes the semantics of the boundary conditions of the detail range filter.
62 \value IncludeLower
63 \value IncludeUpper
64 \value ExcludeLower
65 \value ExcludeUpper
66 */
67
68/*!
69 Constructs a new detail range filter.
70 */
71QOrganizerItemDetailRangeFilter::QOrganizerItemDetailRangeFilter()
72 : QOrganizerItemFilter(new QOrganizerItemDetailRangeFilterPrivate)
73{
74}
75
76/*!
77 Sets the value range criterion of the filter to within \a min and \a max, with boundary conditions
78 specified in the given \a flags.
79
80 \sa minValue(), maxValue(), rangeFlags()
81 */
82void QOrganizerItemDetailRangeFilter::setRange(const QVariant &min, const QVariant &max, RangeFlags flags)
83{
84 Q_D(QOrganizerItemDetailRangeFilter);
85 d->m_minValue = min;
86 d->m_maxValue = max;
87 d->m_rangeflags = flags;
88}
89
90/*!
91 Sets the match flags of the filter criterion to \a flags.
92
93 Not all flags are supported by a range filter. The supported flags include:
94 \list
95 \li QOrganizerItemFilter::MatchExactly
96 \li QOrganizerItemFilter::MatchFixedString
97 \li QOrganizerItemFilter::MatchCaseSensitive
98 \endlist
99
100 Unsupported flags will be ignored.
101
102 \sa matchFlags()
103 */
104void QOrganizerItemDetailRangeFilter::setMatchFlags(QOrganizerItemFilter::MatchFlags flags)
105{
106 Q_D(QOrganizerItemDetailRangeFilter);
107 flags &= (QOrganizerItemFilter::MatchExactly | QOrganizerItemFilter::MatchFixedString | QOrganizerItemFilter::MatchCaseSensitive);
108 d->m_flags = flags;
109}
110
111/*!
112 Sets the type of detail which will be matched to \a detailType, and the field of the detail
113 which will contain the value criterion to \a field.
114
115 \sa detailType(), detailField()
116 */
117/*!
118 Sets the type of detail which will be matched to \a detailType, and the field of the detail
119 which will contain the value criterion to \a field.
120
121 If \a detailType is QOrganizerItemDetail::TypeUndefined, the detail filter will match no organizer items.
122 If \a field is not specified, or equal to -1, the detail filter acts like a "detail exists" filter;
123 if any detail of the specified type is present in the organizer item, that organizer item will match
124 the filter, regardless of what values might be stored in that detail.
125
126 \sa detailType(), detailField()
127 */
128void QOrganizerItemDetailRangeFilter::setDetail(QOrganizerItemDetail::DetailType detailType, int field)
129{
130 Q_D(QOrganizerItemDetailRangeFilter);
131 d->m_detailType = detailType;
132 d->m_detailField = field;
133}
134
135/*!
136 Returns the match flags of the criterion, which define semantics such as case sensitivity, prefix
137 matching, exact matching, etc.
138
139 \sa setMatchFlags()
140 */
141QOrganizerItemFilter::MatchFlags QOrganizerItemDetailRangeFilter::matchFlags() const
142{
143 Q_D(const QOrganizerItemDetailRangeFilter);
144 return d->m_flags;
145}
146
147/*!
148 Returns the type of the detail which will be inspected for matching values.
149
150 \sa setDetail()
151 */
152QOrganizerItemDetail::DetailType QOrganizerItemDetailRangeFilter::detailType() const
153{
154 Q_D(const QOrganizerItemDetailRangeFilter);
155 return d->m_detailType;
156}
157
158/*!
159 Returns the detail field containing the value which will be matched against the value criterion.
160
161 \sa setDetail()
162 */
163int QOrganizerItemDetailRangeFilter::detailField() const
164{
165 Q_D(const QOrganizerItemDetailRangeFilter);
166 return d->m_detailField;
167}
168
169/*!
170 Returns the lower bound of the value range criterion.
171
172 \sa setRange()
173 */
174QVariant QOrganizerItemDetailRangeFilter::minValue() const
175{
176 Q_D(const QOrganizerItemDetailRangeFilter);
177 return d->m_minValue;
178}
179
180/*!
181 Returns the upper bound of the value range criterion.
182
183 \sa setRange()
184 */
185QVariant QOrganizerItemDetailRangeFilter::maxValue() const
186{
187 Q_D(const QOrganizerItemDetailRangeFilter);
188 return d->m_maxValue;
189}
190
191/*!
192 Returns a set of flags which defines the boundary condition semantics of the value range criterion.
193
194 \sa setRange()
195 */
196QOrganizerItemDetailRangeFilter::RangeFlags QOrganizerItemDetailRangeFilter::rangeFlags() const
197{
198 Q_D(const QOrganizerItemDetailRangeFilter);
199 return d->m_rangeflags;
200}
201
202QT_END_NAMESPACE_ORGANIZER
203

source code of qtpim/src/organizer/filters/qorganizeritemdetailrangefilter.cpp