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