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

source code of qtpim/src/contacts/filters/qcontactdetailfilter.cpp