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

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