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 QtQml 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 "qdeclarativecontactfilter_p.h" |
35 | |
36 | QTCONTACTS_USE_NAMESPACE |
37 | |
38 | QT_BEGIN_NAMESPACE |
39 | |
40 | /*! |
41 | \qmltype Filter |
42 | \instantiates QDeclarativeContactFilter |
43 | \brief The Filter element is used as a property of ContactModel, to allow |
44 | selection of contacts which have certain details or properties. |
45 | |
46 | \ingroup qml-contacts-main |
47 | \inqmlmodule QtContacts |
48 | |
49 | This element is part of the \b{QtContacts} module. |
50 | |
51 | \sa QContactFilter |
52 | */ |
53 | |
54 | |
55 | /*! |
56 | \qmlproperty enumeration Filter::type |
57 | |
58 | This property holds the type value of this filter. It can be one of: |
59 | |
60 | \list |
61 | \li Filter.DefaultFilter - A filter which matches everything (default). |
62 | \li Filter.InvalidFilter - An invalid filter which matches nothing. |
63 | \li Filter.DetailFilter - A filter which matches contacts containing one or more details of a particular definition with a particular value. |
64 | \li Filter.DetailRangeFilter - A filter which matches contacts containing one or more details of a particular definition whose values are within a particular range. |
65 | \li Filter.ChangeLogFilter - A filter which matches contacts whose timestamps have been updated since some particular date and time. |
66 | \li Filter.ActionFilter - A filter which matches contacts for which a particular action is available, or which contain a detail with a particular value for which a particular action is available. |
67 | \li Filter.RelationshipFilter - A filter which matches contacts which participate in a particular type of relationship, or relationship with a specified contact. |
68 | \li Filter.IntersectionFilter - A filter which matches all contacts that are matched by all filters it includes. |
69 | \li Filter.UnionFilter - A filter which matches any contact that is matched by any of the filters it includes. |
70 | \li Filter.IdFilter - A filter which matches any contact whose local id is contained in a particular list of contact local ids. |
71 | \endlist |
72 | */ |
73 | |
74 | /*! |
75 | \qmltype ActionFilter |
76 | \instantiates QDeclarativeContactActionFilter |
77 | \brief The ActionFilter element provides a filter based around an action availability criterion. |
78 | |
79 | \ingroup qml-contacts-filters |
80 | \inqmlmodule QtContacts |
81 | |
82 | This element is part of the \b{QtContacts} module. |
83 | |
84 | \sa QContactActionFilter |
85 | */ |
86 | |
87 | /*! |
88 | \qmlproperty string ActionFilter::actionName |
89 | |
90 | This property holds the action name criterion of the filter. |
91 | */ |
92 | |
93 | /*! |
94 | \qmltype ChangeLogFilter |
95 | \instantiates QDeclarativeContactChangeLogFilter |
96 | \brief The ChangeLogFilter element provides a filter based around a contact timestamp criterion. |
97 | |
98 | \ingroup qml-contacts-filters |
99 | \inqmlmodule QtContacts |
100 | |
101 | This element is part of the \b{QtContacts} module. |
102 | |
103 | \sa QContactChangeLogFilter |
104 | */ |
105 | |
106 | /*! |
107 | \qmlproperty date ChangeLogFilter::since |
108 | |
109 | This property holds the date and time lower-bound criterion of the filter.The value can be one of: |
110 | \list |
111 | \li ChangeLogFilter.EventAdded |
112 | \li ChangeLogFilter.EventChanged |
113 | \li ChangeLogFilter.EventRemoved |
114 | \endlist |
115 | */ |
116 | |
117 | /*! |
118 | \qmlproperty enumeration ChangeLogFilter::eventType |
119 | |
120 | This property holds the type of change that this filter will match against. |
121 | */ |
122 | |
123 | /*! |
124 | \qmltype DetailFilter |
125 | \instantiates QDeclarativeContactDetailFilter |
126 | \brief The DetailFilter element provides a filter based around a detail value criterion. |
127 | |
128 | \ingroup qml-contacts-filters |
129 | \inqmlmodule QtContacts |
130 | |
131 | This element is part of the \b{QtContacts} module. |
132 | |
133 | \sa QContactDetailFilter |
134 | */ |
135 | |
136 | /*! |
137 | \qmlproperty enumeration DetailFilter::detail |
138 | |
139 | This property holds the detail type of which details will be matched to. |
140 | |
141 | \sa ContactDetail::type |
142 | */ |
143 | |
144 | /*! |
145 | \qmlproperty int DetailFilter::field |
146 | |
147 | This property holds the detail field type of which detail fields will be matched to. |
148 | Detail field types are enumeration values defined in each detail elements. |
149 | |
150 | \sa Address |
151 | \sa Anniversary |
152 | \sa Avatar |
153 | \sa Birthday |
154 | \sa DisplayLabel |
155 | \sa EmailAddress |
156 | \sa Family |
157 | \sa Favorite |
158 | \sa Gender |
159 | \sa GeoLocation |
160 | \sa GlobalPresence |
161 | \sa Guid |
162 | \sa Name |
163 | \sa Nickname |
164 | \sa Note |
165 | \sa OnlineAccount |
166 | \sa Organization |
167 | \sa PhoneNumber |
168 | \sa Presence |
169 | \sa Ringtone |
170 | \sa SyncTarget |
171 | \sa Tag |
172 | \sa Timestamp |
173 | \sa Url |
174 | \sa Hobby |
175 | */ |
176 | |
177 | /*! |
178 | \qmlproperty variant DetailFilter::value |
179 | |
180 | This property holds the value criterion of the detail filter. |
181 | */ |
182 | |
183 | /*! |
184 | \qmlproperty enumeration DetailFilter::matchFlags |
185 | |
186 | This property holds the semantics of the value matching criterion. The valid match flags include: |
187 | \list |
188 | \li MatchExactly - Performs QVariant-based matching (default). |
189 | \li MatchContains - The search term is contained in the item. |
190 | \li MatchStartsWith - The search term matches the start of the item. |
191 | \li MatchEndsWith - The search term matches the end of the item. |
192 | \li MatchFixedString - Performs string-based matching. String-based comparisons are case-insensitive unless the \c MatchCaseSensitive flag is also specified. |
193 | \li MatchCaseSensitive - The search is case sensitive. |
194 | \endlist |
195 | */ |
196 | |
197 | /*! |
198 | \qmltype DetailRangeFilter |
199 | \instantiates QDeclarativeContactDetailRangeFilter |
200 | \brief The DetailRangeFilter element provides a filter based around a detail value range criterion. |
201 | |
202 | |
203 | \ingroup qml-contacts-filters |
204 | \inqmlmodule QtContacts |
205 | |
206 | This element is part of the \b{QtContacts} module. |
207 | |
208 | \sa QContactDetailRangeFilter |
209 | */ |
210 | |
211 | /*! |
212 | \qmlproperty enumeration DetailRangeFilter::detail |
213 | |
214 | This property holds the detail type of which details will be matched to. |
215 | |
216 | \sa ContactDetail::type |
217 | \sa DetailFilter::detail |
218 | */ |
219 | |
220 | /*! |
221 | \qmlproperty int DetailRangeFilter::field |
222 | |
223 | This property holds the detail field type of which detail fields will be matched to. |
224 | Detail field types are enumeration values defined in each detail elements. |
225 | |
226 | \sa DetailFilter::field |
227 | */ |
228 | /*! |
229 | \qmlproperty variant DetailRangeFilter::min |
230 | |
231 | This property holds the lower bound of the value range criterion. By default, there is no lower bound. |
232 | */ |
233 | /*! |
234 | \qmlproperty variant DetailRangeFilter::max |
235 | |
236 | This property holds the upper bound of the value range criterion. By default, there is no upper bound. |
237 | */ |
238 | |
239 | /*! |
240 | \qmlproperty enumeration DetailRangeFilter::matchFlags |
241 | |
242 | This property holds the match flags of the criterion, which define semantics such as case sensitivity, and exact matching. |
243 | |
244 | \sa DetailFilter::matchFlags |
245 | */ |
246 | |
247 | /*! |
248 | \qmlproperty enumeration DetailRangeFilter::rangeFlags |
249 | |
250 | This property holds a set of flags which defines the boundary condition semantics of the value range criterion.The valid range flags include: |
251 | \list |
252 | \li DetailRangeFilter.IncludeLower |
253 | \li DetailRangeFilter.IncludeUpper |
254 | \li DetailRangeFilter.ExcludeLower |
255 | \li DetailRangeFilter.ExcludeUpper |
256 | \endlist |
257 | */ |
258 | /*! |
259 | \qmltype IntersectionFilter |
260 | \instantiates QDeclarativeContactIntersectionFilter |
261 | \brief The IntersectionFilter element provides a filter which intersects the results of other filters. |
262 | |
263 | \ingroup qml-contacts-filters |
264 | \inqmlmodule QtContacts |
265 | |
266 | This element is part of the \b{QtContacts} module. |
267 | |
268 | \sa QContactIntersectionFilter |
269 | */ |
270 | |
271 | /*! |
272 | \qmlproperty list<Filter> IntersectionFilter::filters |
273 | |
274 | This property holds the list of filters which form the intersection filter. |
275 | */ |
276 | |
277 | |
278 | /*! |
279 | \qmltype UnionFilter |
280 | \instantiates QDeclarativeContactUnionFilter |
281 | \brief The UnionFilter element provides a filter which unions the results of other filters. |
282 | |
283 | \ingroup qml-contacts-filters |
284 | \inqmlmodule QtContacts |
285 | |
286 | This element is part of the \b{QtContacts} module. |
287 | |
288 | \sa QContactUnionFilter |
289 | */ |
290 | |
291 | /*! |
292 | \qmlproperty list<Filter> UnionFilter::filters |
293 | |
294 | This property holds the list of filters which form the union filter. |
295 | */ |
296 | |
297 | /*! |
298 | \qmltype IdFilter |
299 | \instantiates QDeclarativeContactIdFilter |
300 | \brief The IdFilter element provides a filter based around a list of contact ids. |
301 | |
302 | \ingroup qml-contacts-filters |
303 | \inqmlmodule QtContacts |
304 | |
305 | This element is part of the \b{QtContacts} module. |
306 | |
307 | \sa QContactIdFilter |
308 | */ |
309 | |
310 | /*! |
311 | \qmlproperty list<string> IdFilter::ids |
312 | |
313 | This property holds the list of ids of contacts which match this filter. |
314 | */ |
315 | |
316 | |
317 | /*! |
318 | \qmltype RelationshipFilter |
319 | \instantiates QDeclarativeContactRelationshipFilter |
320 | \brief The RelationshipFilter element provides a filter based around relationship criteria. |
321 | |
322 | \ingroup qml-contacts-filters |
323 | \inqmlmodule QtContacts |
324 | |
325 | |
326 | This element is part of the \b{QtContacts} module. |
327 | |
328 | \sa Relationship |
329 | \sa RelationshipModel |
330 | \sa QContactRelationshipFilter |
331 | \sa QContactRelationship |
332 | */ |
333 | |
334 | |
335 | /*! |
336 | \qmlproperty variant RelationshipFilter::relationshipType |
337 | |
338 | This property holds the type of relationship that a contact must have in order to match the filter. |
339 | |
340 | \sa Relationship::type |
341 | */ |
342 | |
343 | /*! |
344 | \qmlproperty int RelationshipFilter::relatedContactId |
345 | |
346 | This property holds the id of the contact with whom the tested contact must have a relationship in order for the tested contact to match this filter |
347 | */ |
348 | /*! |
349 | \qmlproperty enumeration RelationshipFilter::relatedContactRole |
350 | |
351 | This property holds the role in the relationship with the tested contact that the related contact must play in order for the tested contact to match this filter. |
352 | The role can be one of: |
353 | \list |
354 | \li Relationship.First - The contact is the first contact in the relationship. |
355 | \li Relationship.Second - The contact is the second contact in the relationship. |
356 | \li Relationship.Either - The contact is either the first or second contact in the relationship (default). |
357 | \endlist |
358 | */ |
359 | |
360 | /*! |
361 | \qmltype InvalidFilter |
362 | \instantiates QDeclarativeContactInvalidFilter |
363 | \brief the InvalidFilter element provides a filter which will never match any contacts. |
364 | |
365 | \ingroup qml-contacts-filters |
366 | \inqmlmodule QtContacts |
367 | |
368 | This element is part of the \b{QtContacts} module. |
369 | |
370 | \sa QContactInvalidFilter |
371 | */ |
372 | |
373 | QQmlListProperty<QDeclarativeContactFilter> QDeclarativeContactCompoundFilter::filters() |
374 | { |
375 | return QQmlListProperty<QDeclarativeContactFilter>(this, |
376 | 0, // opaque data parameter |
377 | filters_append, |
378 | filters_count, |
379 | filters_at, |
380 | filters_clear); |
381 | } |
382 | |
383 | void QDeclarativeContactCompoundFilter::filters_append(QQmlListProperty<QDeclarativeContactFilter>* prop, QDeclarativeContactFilter* filter) |
384 | { |
385 | QDeclarativeContactCompoundFilter* compoundFilter = static_cast<QDeclarativeContactCompoundFilter*>(prop->object); |
386 | compoundFilter->m_filters.append(t: filter); |
387 | QObject::connect(sender: filter, SIGNAL(filterChanged()), receiver: compoundFilter, SIGNAL(filterChanged()), Qt::UniqueConnection); |
388 | emit compoundFilter->filterChanged(); |
389 | } |
390 | |
391 | int QDeclarativeContactCompoundFilter::filters_count(QQmlListProperty<QDeclarativeContactFilter>* prop) |
392 | { |
393 | // The 'prop' is in a sense 'this' for this static function (as given in filters() function) |
394 | return static_cast<QDeclarativeContactCompoundFilter*>(prop->object)->m_filters.count(); |
395 | } |
396 | |
397 | QDeclarativeContactFilter* QDeclarativeContactCompoundFilter::filters_at(QQmlListProperty<QDeclarativeContactFilter>* prop, int index) |
398 | { |
399 | return static_cast<QDeclarativeContactCompoundFilter*>(prop->object)->m_filters.at(i: index); |
400 | } |
401 | |
402 | void QDeclarativeContactCompoundFilter::filters_clear(QQmlListProperty<QDeclarativeContactFilter>* prop) |
403 | { |
404 | QDeclarativeContactCompoundFilter* compoundFilter = static_cast<QDeclarativeContactCompoundFilter*>(prop->object); |
405 | if (!compoundFilter->m_filters.isEmpty()) { |
406 | foreach (QDeclarativeContactFilter* filter, compoundFilter->m_filters) { |
407 | QObject::disconnect(sender: filter, SIGNAL(filterChanged()), receiver: compoundFilter, SIGNAL(filterChanged())); |
408 | } |
409 | compoundFilter->m_filters.clear(); |
410 | emit compoundFilter->filterChanged(); |
411 | } |
412 | } |
413 | |
414 | #include "moc_qdeclarativecontactfilter_p.cpp" |
415 | |
416 | QT_END_NAMESPACE |
417 | |