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 "qorganizeritemintersectionfilter.h"
35#include "qorganizeritemintersectionfilter_p.h"
36
37QT_BEGIN_NAMESPACE_ORGANIZER
38
39/*!
40 \class QOrganizerItemIntersectionFilter
41 \brief The QOrganizerItemIntersectionFilter class provides a filter which intersects the results
42 of other filters.
43 \inmodule QtOrganizer
44 \ingroup organizer-filters
45
46 It may be used to select organizer items which match all of the filters in the intersection filter.
47 */
48
49Q_IMPLEMENT_ORGANIZERITEMFILTER_PRIVATE(QOrganizerItemIntersectionFilter)
50
51/*!
52 \fn QOrganizerItemIntersectionFilter::QOrganizerItemIntersectionFilter(const QOrganizerItemFilter &other)
53
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 */
60QOrganizerItemIntersectionFilter::QOrganizerItemIntersectionFilter()
61 : QOrganizerItemFilter(new QOrganizerItemIntersectionFilterPrivate)
62{
63}
64
65/*!
66 Sets the filters whose criteria will be intersected to \a filters.
67
68 \sa filters(), clear()
69 */
70void QOrganizerItemIntersectionFilter::setFilters(const QList<QOrganizerItemFilter> &filters)
71{
72 Q_D(QOrganizerItemIntersectionFilter);
73 d->m_filters = filters;
74}
75
76/*!
77 Clears the list of filters. Note that an empty intersection filter will match no items.
78
79 \sa filters(), setFilters()
80 */
81void QOrganizerItemIntersectionFilter::clear()
82{
83 Q_D(QOrganizerItemIntersectionFilter);
84 d->m_filters.clear();
85}
86
87/*!
88 Prepends the given \a filter to the list of intersected filters.
89
90 \sa append(), filters()
91 */
92void QOrganizerItemIntersectionFilter::prepend(const QOrganizerItemFilter &filter)
93{
94 Q_D(QOrganizerItemIntersectionFilter);
95 d->m_filters.prepend(t: filter);
96}
97
98/*!
99 Appends the given \a filter to the list of intersected filters.
100
101 \sa operator<<(), prepend(), filters()
102 */
103void QOrganizerItemIntersectionFilter::append(const QOrganizerItemFilter &filter)
104{
105 Q_D(QOrganizerItemIntersectionFilter);
106 d->m_filters.append(t: filter);
107}
108
109/*!
110 Removes the given \a filter from the intersection list.
111
112 \sa filters(), append(), prepend(), clear()
113 */
114void QOrganizerItemIntersectionFilter::remove(const QOrganizerItemFilter &filter)
115{
116 Q_D(QOrganizerItemIntersectionFilter);
117 d->m_filters.removeAll(t: filter);
118}
119
120/*!
121 Appends the given \a filter to the list of intersected filters.
122
123 \sa append()
124 */
125QOrganizerItemIntersectionFilter &QOrganizerItemIntersectionFilter::operator<<(const QOrganizerItemFilter &filter)
126{
127 Q_D(QOrganizerItemIntersectionFilter);
128 d->m_filters << filter;
129 return *this;
130}
131
132/*!
133 Returns the list of filters which form the intersection filter.
134
135 \sa setFilters(), prepend(), append(), remove()
136 */
137QList<QOrganizerItemFilter> QOrganizerItemIntersectionFilter::filters() const
138{
139 Q_D(const QOrganizerItemIntersectionFilter);
140 return d->m_filters;
141}
142
143QT_END_NAMESPACE_ORGANIZER
144

source code of qtpim/src/organizer/filters/qorganizeritemintersectionfilter.cpp