| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). |
| 4 | ** Contact: http://www.qt-project.org/legal |
| 5 | ** |
| 6 | ** This file is part of the QtDocGallery module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 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 Digia. For licensing terms and |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information |
| 15 | ** use the contact form at http://qt.digia.com/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 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| 24 | ** |
| 25 | ** In addition, as a special exception, Digia gives you certain additional |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| 28 | ** |
| 29 | ** GNU General Public License Usage |
| 30 | ** Alternatively, this file may be used under the terms of the GNU |
| 31 | ** General Public License version 3.0 as published by the Free Software |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the |
| 33 | ** packaging of this file. Please review the following information to |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. |
| 36 | ** |
| 37 | ** |
| 38 | ** $QT_END_LICENSE$ |
| 39 | ** |
| 40 | ****************************************************************************/ |
| 41 | |
| 42 | #ifndef QGALLERYFILTER_H |
| 43 | #define QGALLERYFILTER_H |
| 44 | |
| 45 | #include "qgalleryglobal.h" |
| 46 | |
| 47 | #include <QtCore/qset.h> |
| 48 | #include <QtCore/qshareddata.h> |
| 49 | #include <QtCore/qvariant.h> |
| 50 | #include <QtCore/qvector.h> |
| 51 | |
| 52 | QT_BEGIN_NAMESPACE |
| 53 | class QDebug; |
| 54 | QT_END_NAMESPACE |
| 55 | |
| 56 | QT_BEGIN_NAMESPACE_DOCGALLERY |
| 57 | |
| 58 | class QGalleryFilter; |
| 59 | class QGalleryIntersectionFilter; |
| 60 | class QGalleryMetaDataFilter; |
| 61 | class QGalleryUnionFilter; |
| 62 | class QGalleryFilterPrivate; |
| 63 | |
| 64 | class Q_GALLERY_EXPORT QGalleryFilter |
| 65 | { |
| 66 | public: |
| 67 | enum Type |
| 68 | { |
| 69 | Invalid, |
| 70 | Intersection, |
| 71 | Union, |
| 72 | MetaData |
| 73 | }; |
| 74 | |
| 75 | enum Comparator |
| 76 | { |
| 77 | Equals, |
| 78 | LessThan, |
| 79 | GreaterThan, |
| 80 | LessThanEquals, |
| 81 | GreaterThanEquals, |
| 82 | Contains, |
| 83 | StartsWith, |
| 84 | EndsWith, |
| 85 | Wildcard, |
| 86 | RegExp |
| 87 | }; |
| 88 | |
| 89 | QGalleryFilter(); |
| 90 | QGalleryFilter(const QGalleryFilter &filter); |
| 91 | QGalleryFilter(const QGalleryIntersectionFilter &filter); |
| 92 | QGalleryFilter(const QGalleryUnionFilter &filter); |
| 93 | QGalleryFilter(const QGalleryMetaDataFilter &filter); |
| 94 | ~QGalleryFilter(); |
| 95 | |
| 96 | QGalleryFilter &operator =(const QGalleryFilter &filter); |
| 97 | |
| 98 | Type type() const; |
| 99 | bool isValid() const; |
| 100 | |
| 101 | QGalleryIntersectionFilter toIntersectionFilter() const; |
| 102 | QGalleryUnionFilter toUnionFilter() const; |
| 103 | QGalleryMetaDataFilter toMetaDataFilter() const; |
| 104 | |
| 105 | private: |
| 106 | QSharedDataPointer<QGalleryFilterPrivate> d; |
| 107 | |
| 108 | friend Q_GALLERY_EXPORT bool operator ==( |
| 109 | const QGalleryFilter &filter1, const QGalleryFilter &filter2); |
| 110 | friend Q_GALLERY_EXPORT bool operator !=( |
| 111 | const QGalleryFilter &filter1, const QGalleryFilter &filter2); |
| 112 | |
| 113 | #ifndef QT_NO_DEBUG_STREAM |
| 114 | friend Q_GALLERY_EXPORT QDebug operator <<(QDebug debug, const QGalleryFilter &filter); |
| 115 | #endif |
| 116 | }; |
| 117 | |
| 118 | Q_GALLERY_EXPORT bool operator ==(const QGalleryFilter &filter1, const QGalleryFilter &filter2); |
| 119 | Q_GALLERY_EXPORT bool operator !=(const QGalleryFilter &filter1, const QGalleryFilter &filter2); |
| 120 | |
| 121 | #ifndef QT_NO_DEBUG_STREAM |
| 122 | Q_GALLERY_EXPORT QDebug operator <<(QDebug debug, const QGalleryFilter &filter); |
| 123 | #endif |
| 124 | |
| 125 | class QGalleryIntersectionFilterPrivate; |
| 126 | |
| 127 | class Q_GALLERY_EXPORT QGalleryIntersectionFilter |
| 128 | { |
| 129 | public: |
| 130 | QGalleryIntersectionFilter(); |
| 131 | QGalleryIntersectionFilter(const QGalleryMetaDataFilter &filter); |
| 132 | QGalleryIntersectionFilter(const QGalleryUnionFilter &filter); |
| 133 | QGalleryIntersectionFilter(const QGalleryIntersectionFilter &filter); |
| 134 | ~QGalleryIntersectionFilter(); |
| 135 | |
| 136 | QGalleryIntersectionFilter &operator =(const QGalleryIntersectionFilter &filter); |
| 137 | |
| 138 | bool isValid() const; |
| 139 | |
| 140 | int filterCount() const; |
| 141 | bool isEmpty() const; |
| 142 | |
| 143 | QList<QGalleryFilter> filters() const; |
| 144 | |
| 145 | void append(const QGalleryMetaDataFilter &filter); |
| 146 | void append(const QGalleryUnionFilter &filter); |
| 147 | void append(const QGalleryIntersectionFilter &filter); |
| 148 | |
| 149 | void prepend(const QGalleryMetaDataFilter &filter); |
| 150 | void prepend(const QGalleryUnionFilter &filter); |
| 151 | void prepend(const QGalleryIntersectionFilter &filter); |
| 152 | |
| 153 | void insert(int index, const QGalleryMetaDataFilter &filter); |
| 154 | void insert(int index, const QGalleryUnionFilter &filter); |
| 155 | void insert(int index, const QGalleryIntersectionFilter &filter); |
| 156 | |
| 157 | void replace(int index, const QGalleryMetaDataFilter &filter); |
| 158 | void replace(int index, const QGalleryUnionFilter &filter); |
| 159 | |
| 160 | void remove(int index); |
| 161 | void clear(); |
| 162 | |
| 163 | QGalleryIntersectionFilter &operator <<(const QGalleryIntersectionFilter &filter); |
| 164 | |
| 165 | private: |
| 166 | explicit inline QGalleryIntersectionFilter(QGalleryFilterPrivate *d); |
| 167 | explicit inline QGalleryIntersectionFilter(QGalleryFilter::Type type); |
| 168 | |
| 169 | QSharedDataPointer<QGalleryIntersectionFilterPrivate> d; |
| 170 | |
| 171 | friend class QGalleryFilter; |
| 172 | }; |
| 173 | |
| 174 | QGalleryIntersectionFilter Q_GALLERY_EXPORT operator &&( |
| 175 | const QGalleryIntersectionFilter &filter1, const QGalleryIntersectionFilter &filter2); |
| 176 | |
| 177 | class QGalleryUnionFilterPrivate; |
| 178 | |
| 179 | class Q_GALLERY_EXPORT QGalleryUnionFilter |
| 180 | { |
| 181 | public: |
| 182 | QGalleryUnionFilter(); |
| 183 | QGalleryUnionFilter(const QGalleryMetaDataFilter &filter); |
| 184 | QGalleryUnionFilter(const QGalleryIntersectionFilter &filter); |
| 185 | QGalleryUnionFilter(const QGalleryUnionFilter &other); |
| 186 | ~QGalleryUnionFilter(); |
| 187 | |
| 188 | QGalleryUnionFilter &operator =(const QGalleryUnionFilter &filter); |
| 189 | |
| 190 | bool isValid() const; |
| 191 | |
| 192 | int filterCount() const; |
| 193 | bool isEmpty() const; |
| 194 | |
| 195 | QList<QGalleryFilter> filters() const; |
| 196 | |
| 197 | void append(const QGalleryMetaDataFilter &filter); |
| 198 | void append(const QGalleryIntersectionFilter &filter); |
| 199 | void append(const QGalleryUnionFilter &filter); |
| 200 | |
| 201 | void prepend(const QGalleryMetaDataFilter &filter); |
| 202 | void prepend(const QGalleryIntersectionFilter &filter); |
| 203 | void prepend(const QGalleryUnionFilter &filter); |
| 204 | |
| 205 | void insert(int index, const QGalleryMetaDataFilter &filter); |
| 206 | void insert(int index, const QGalleryIntersectionFilter &filter); |
| 207 | void insert(int index, const QGalleryUnionFilter &filter); |
| 208 | |
| 209 | void replace(int index, const QGalleryMetaDataFilter &filter); |
| 210 | void replace(int index, const QGalleryIntersectionFilter &filter); |
| 211 | |
| 212 | void remove(int index); |
| 213 | void clear(); |
| 214 | |
| 215 | QGalleryUnionFilter &operator <<(const QGalleryUnionFilter &filter); |
| 216 | |
| 217 | private: |
| 218 | explicit inline QGalleryUnionFilter(QGalleryFilterPrivate *d); |
| 219 | explicit inline QGalleryUnionFilter(QGalleryFilter::Type type); |
| 220 | |
| 221 | QSharedDataPointer<QGalleryUnionFilterPrivate> d; |
| 222 | |
| 223 | friend class QGalleryFilter; |
| 224 | }; |
| 225 | |
| 226 | QGalleryUnionFilter Q_GALLERY_EXPORT operator ||( |
| 227 | const QGalleryUnionFilter &filter1, const QGalleryUnionFilter &filter2); |
| 228 | |
| 229 | class QGalleryMetaDataFilterPrivate; |
| 230 | |
| 231 | class Q_GALLERY_EXPORT QGalleryMetaDataFilter |
| 232 | { |
| 233 | public: |
| 234 | QGalleryMetaDataFilter(); |
| 235 | QGalleryMetaDataFilter( |
| 236 | const QString &propertyName, |
| 237 | const QVariant &value, |
| 238 | QGalleryFilter::Comparator comparator = QGalleryFilter::Equals); |
| 239 | QGalleryMetaDataFilter(const QGalleryMetaDataFilter &other); |
| 240 | ~QGalleryMetaDataFilter(); |
| 241 | |
| 242 | QGalleryMetaDataFilter &operator =(const QGalleryMetaDataFilter &filter); |
| 243 | |
| 244 | bool isValid() const; |
| 245 | |
| 246 | QString propertyName() const; |
| 247 | void setPropertyName(const QString &name); |
| 248 | |
| 249 | QVariant value() const; |
| 250 | void setValue(const QVariant &value); |
| 251 | |
| 252 | QGalleryFilter::Comparator comparator() const; |
| 253 | void setComparator(QGalleryFilter::Comparator comparator); |
| 254 | |
| 255 | bool isNegated() const; |
| 256 | void setNegated(bool inverted); |
| 257 | |
| 258 | QGalleryMetaDataFilter operator !() const; |
| 259 | |
| 260 | private: |
| 261 | explicit inline QGalleryMetaDataFilter(QGalleryFilterPrivate *d); |
| 262 | explicit inline QGalleryMetaDataFilter(QGalleryFilter::Type type); |
| 263 | |
| 264 | QSharedDataPointer<QGalleryMetaDataFilterPrivate> d; |
| 265 | |
| 266 | friend class QGalleryFilter; |
| 267 | }; |
| 268 | |
| 269 | QT_END_NAMESPACE_DOCGALLERY |
| 270 | |
| 271 | #endif |
| 272 | |