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 "qorganizeritemdetailfieldfilter.h" |
35 | #include "qorganizeritemdetailfieldfilter_p.h" |
36 | |
37 | QT_BEGIN_NAMESPACE_ORGANIZER |
38 | |
39 | /*! |
40 | \class QOrganizerItemDetailFieldFilter |
41 | \brief The QOrganizerItemDetailFieldFilter class provides a filter based around a detail value criterion. |
42 | \inmodule QtOrganizer |
43 | \ingroup organizer-filters |
44 | |
45 | It may be used to select organizeritems which contain a detail of a particular type and a particular value. |
46 | */ |
47 | |
48 | Q_IMPLEMENT_ORGANIZERITEMFILTER_PRIVATE(QOrganizerItemDetailFieldFilter) |
49 | |
50 | /*! |
51 | \fn QOrganizerItemDetailFieldFilter::QOrganizerItemDetailFieldFilter(const QOrganizerItemFilter &other) |
52 | |
53 | Constructs a copy of \a other if possible, otherwise constructs a new detail filter. |
54 | */ |
55 | |
56 | /*! |
57 | Constructs a new detail filter. |
58 | */ |
59 | QOrganizerItemDetailFieldFilter::QOrganizerItemDetailFieldFilter() |
60 | : QOrganizerItemFilter(new QOrganizerItemDetailFieldFilterPrivate) |
61 | { |
62 | } |
63 | |
64 | /*! |
65 | Sets the type of detail which will be matched to \a detailType, and the field of the detail |
66 | which will contain the value criterion to \a field. |
67 | |
68 | If \a detailType is QOrganizerItemDetail::TypeUndefined, the detail filter will match no organizer items. |
69 | If \a field is not specified, or equal to -1, the detail filter acts like a "detail exists" filter; |
70 | if any detail of the specified type is present in the organizer item, that organizer item will match |
71 | the filter, regardless of what values might be stored in that detail. |
72 | |
73 | \sa detailType(), detailField() |
74 | */ |
75 | void QOrganizerItemDetailFieldFilter::setDetail(QOrganizerItemDetail::DetailType detailType, int field) |
76 | { |
77 | Q_D(QOrganizerItemDetailFieldFilter); |
78 | d->m_detailType = detailType; |
79 | d->m_detailField = field; |
80 | } |
81 | |
82 | /*! |
83 | Sets the value criterion of the filter to \a value. |
84 | |
85 | \sa value() |
86 | */ |
87 | void QOrganizerItemDetailFieldFilter::setValue(const QVariant &value) |
88 | { |
89 | Q_D(QOrganizerItemDetailFieldFilter); |
90 | d->m_exactValue = value; |
91 | } |
92 | |
93 | /*! |
94 | Sets the semantics of the value matching criterion to those defined in \a flags. |
95 | |
96 | \sa matchFlags() |
97 | */ |
98 | void QOrganizerItemDetailFieldFilter::setMatchFlags(QOrganizerItemFilter::MatchFlags flags) |
99 | { |
100 | Q_D(QOrganizerItemDetailFieldFilter); |
101 | d->m_flags = flags; |
102 | } |
103 | |
104 | /*! |
105 | Returns the semantics of the value matching criterion. |
106 | |
107 | \sa setMatchFlags() |
108 | */ |
109 | QOrganizerItemFilter::MatchFlags QOrganizerItemDetailFieldFilter::matchFlags() const |
110 | { |
111 | Q_D(const QOrganizerItemDetailFieldFilter); |
112 | return d->m_flags; |
113 | } |
114 | |
115 | /*! |
116 | Returns the type of the detail which will be inspected for matching values. |
117 | |
118 | \sa setDetail() |
119 | */ |
120 | QOrganizerItemDetail::DetailType QOrganizerItemDetailFieldFilter::detailType() const |
121 | { |
122 | Q_D(const QOrganizerItemDetailFieldFilter); |
123 | return d->m_detailType; |
124 | } |
125 | |
126 | /*! |
127 | Returns the detail field containing the value which will be matched against the value criterion. |
128 | |
129 | \sa setDetail() |
130 | */ |
131 | int QOrganizerItemDetailFieldFilter::detailField() const |
132 | { |
133 | Q_D(const QOrganizerItemDetailFieldFilter); |
134 | return d->m_detailField; |
135 | } |
136 | |
137 | /*! |
138 | Returns the value criterion of the detail filter. |
139 | |
140 | \sa setValue() |
141 | */ |
142 | QVariant QOrganizerItemDetailFieldFilter::value() const |
143 | { |
144 | Q_D(const QOrganizerItemDetailFieldFilter); |
145 | return d->m_exactValue; |
146 | } |
147 | |
148 | QT_END_NAMESPACE_ORGANIZER |
149 | |