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 "qcontactintersectionfilter.h"
35#include "qcontactintersectionfilter_p.h"
36
37QT_BEGIN_NAMESPACE_CONTACTS
38
39/*!
40 \class QContactIntersectionFilter
41 \brief The QContactIntersectionFilter class provides a filter which intersects the results of other filters.
42
43 \inmodule QtContacts
44
45 \ingroup contacts-filters
46
47 It may be used to select contacts which match all of the filters in the intersection
48 */
49
50Q_IMPLEMENT_CONTACTFILTER_PRIVATE(QContactIntersectionFilter);
51
52/*!
53 * \fn QContactIntersectionFilter::QContactIntersectionFilter(const QContactFilter& other)
54 * Constructs a copy of \a other if possible, otherwise constructs a new intersection filter
55 */
56
57/*!
58 * Constructs a new intersection filter
59 */
60QContactIntersectionFilter::QContactIntersectionFilter()
61 : QContactFilter(new QContactIntersectionFilterPrivate)
62{
63}
64
65/*!
66 * Sets the filters whose criteria will be intersected to \a filters
67 * \sa filters(), clear()
68 */
69void QContactIntersectionFilter::setFilters(const QList<QContactFilter>& filters)
70{
71 Q_D(QContactIntersectionFilter);
72 d->m_filters = filters;
73}
74
75/*!
76 * Clears the list of filters. A cleared intersection filter will match no contacts.
77 * \sa filters(), setFilters()
78 */
79void QContactIntersectionFilter::clear()
80{
81 Q_D(QContactIntersectionFilter);
82 d->m_filters.clear();
83}
84
85/*!
86 * Prepends the given \a filter to the list of intersected filters
87 * \sa append(), filters()
88 */
89void QContactIntersectionFilter::prepend(const QContactFilter& filter)
90{
91 Q_D(QContactIntersectionFilter);
92 d->m_filters.prepend(t: filter);
93}
94
95/*!
96 * Appends the given \a filter to the list of intersected filters
97 * \sa operator<<(), prepend(), filters()
98 */
99void QContactIntersectionFilter::append(const QContactFilter& filter)
100{
101 Q_D(QContactIntersectionFilter);
102 d->m_filters.append(t: filter);
103}
104
105/*!
106 * Removes the given \a filter from the intersection list
107 * \sa filters(), append(), prepend(), clear()
108 */
109void QContactIntersectionFilter::remove(const QContactFilter& filter)
110{
111 Q_D(QContactIntersectionFilter);
112 d->m_filters.removeAll(t: filter);
113}
114
115/*!
116 * Appends the given \a filter to the list of intersected filters
117 * \sa append()
118 */
119QContactIntersectionFilter& QContactIntersectionFilter::operator<<(const QContactFilter& filter)
120{
121 Q_D(QContactIntersectionFilter);
122 d->m_filters << filter;
123 return *this;
124}
125
126/*!
127 * Returns the list of filters which form the intersection filter
128 * \sa setFilters(), prepend(), append(), remove()
129 */
130QList<QContactFilter> QContactIntersectionFilter::filters() const
131{
132 Q_D(const QContactIntersectionFilter);
133 return d->m_filters;
134}
135
136QT_END_NAMESPACE_CONTACTS
137

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