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 "qorganizeritemidfilter.h"
35#include "qorganizeritemidfilter_p.h"
36
37QT_BEGIN_NAMESPACE_ORGANIZER
38
39/*!
40 \class QOrganizerItemIdFilter
41 \brief The QOrganizerItemIdFilter class provides a filter based around a list of organizer item IDs.
42 \inmodule QtOrganizer
43 \ingroup organizer-filters
44
45 It may be used to select organizer items whose IDs are contained in the given list.
46
47 Note: a QOrganizerItemIdFilter will not be preserved if streamed to a QDataStream.
48 */
49
50Q_IMPLEMENT_ORGANIZERITEMFILTER_PRIVATE(QOrganizerItemIdFilter)
51
52/*!
53 \fn QOrganizerItemIdFilter::QOrganizerItemIdFilter(const QOrganizerItemFilter &other)
54
55 Constructs a copy of \a other if possible, otherwise constructs a new organizer item ID filter.
56 */
57
58/*!
59 Constructs a new organizer item ID filter.
60 */
61QOrganizerItemIdFilter::QOrganizerItemIdFilter()
62 : QOrganizerItemFilter(new QOrganizerItemIdFilterPrivate)
63{
64}
65
66/*!
67 Sets the list which contains the IDs of possible matching organizer items to \a ids.
68
69 \sa ids()
70 */
71void QOrganizerItemIdFilter::setIds(const QList<QOrganizerItemId> &ids)
72{
73 Q_D(QOrganizerItemIdFilter);
74 d->m_ids = ids;
75}
76
77/*!
78 Inserts the \a id into the list which contains the IDs of possible matching items.
79
80 \sa setIds()
81 */
82void QOrganizerItemIdFilter::insert(const QOrganizerItemId &id)
83{
84 Q_D(QOrganizerItemIdFilter);
85 if (!d->m_ids.contains(t: id))
86 d->m_ids.append(t: id);
87}
88
89/*!
90 Removes the id \a id from the list which contains the IDs of possible matching items.
91
92 \sa clear()
93 */
94void QOrganizerItemIdFilter::remove(const QOrganizerItemId &id)
95{
96 Q_D(QOrganizerItemIdFilter);
97 d->m_ids.removeAll(t: id);
98}
99
100/*!
101 Clears the list which contains the IDs of possible matching items. Note that an item ID filter
102 with an empty list will match no items.
103
104 \sa setIds()
105 */
106void QOrganizerItemIdFilter::clear()
107{
108 Q_D(QOrganizerItemIdFilter);
109 d->m_ids.clear();
110}
111
112/*!
113 Returns the list of IDs of organizer items which match this filter.
114
115 \sa setIds()
116 */
117QList<QOrganizerItemId> QOrganizerItemIdFilter::ids() const
118{
119 Q_D(const QOrganizerItemIdFilter);
120 return d->m_ids;
121}
122
123QT_END_NAMESPACE_ORGANIZER
124

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