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//
43// W A R N I N G
44// -------------
45//
46// This file is not part of the Qt API. It exists purely as an
47// implementation detail. This header file may change from version to
48// version without notice, or even be removed.
49//
50// We mean it.
51//
52
53#ifndef QDECLARATIVEGALLERYFILTER_H
54#define QDECLARATIVEGALLERYFILTER_H
55
56#include <qgalleryfilter.h>
57#include <QtQml/qqml.h>
58
59QT_BEGIN_NAMESPACE_DOCGALLERY
60
61class QGalleryFilter;
62
63class QDeclarativeGalleryFilterBase : public QObject
64{
65 Q_OBJECT
66public:
67 explicit QDeclarativeGalleryFilterBase(QObject *parent = Q_NULLPTR)
68 : QObject(parent)
69 {
70 }
71
72 virtual QGalleryFilter filter() const = 0;
73
74Q_SIGNALS:
75 void filterChanged();
76};
77
78enum Comparator
79{
80 Equals,
81 LessThan,
82 GreaterThan,
83 LessThanEquals,
84 GreaterThanEquals,
85 Contains,
86 StartsWith,
87 EndsWith,
88 Wildcard,
89 RegExp
90};
91
92class QDeclarativeGalleryValueFilter : public QDeclarativeGalleryFilterBase
93{
94 Q_OBJECT
95 Q_PROPERTY(QString property READ propertyName WRITE setPropertyName NOTIFY propertyNameChanged)
96 Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
97 Q_PROPERTY(bool negated READ isNegated WRITE setNegated NOTIFY negatedChanged)
98public:
99 QString propertyName() const { return m_filter.propertyName(); }
100 void setPropertyName(const QString &name);
101
102 QVariant value() const { return m_filter.value(); }
103 void setValue(const QVariant &value);
104
105 bool isNegated() const { return m_filter.isNegated(); }
106 void setNegated(bool negated);
107
108 QGalleryFilter filter() const;
109
110Q_SIGNALS:
111 void propertyNameChanged();
112 void valueChanged();
113 void negatedChanged();
114
115protected:
116 explicit QDeclarativeGalleryValueFilter(
117 QGalleryFilter::Comparator comparator, QObject *parent = Q_NULLPTR)
118 : QDeclarativeGalleryFilterBase(parent)
119 {
120 m_filter.setComparator(comparator);
121 }
122
123 QGalleryMetaDataFilter m_filter;
124};
125
126class QDeclarativeGalleryStringFilter : public QDeclarativeGalleryFilterBase
127{
128 Q_OBJECT
129 Q_PROPERTY(QString property READ propertyName WRITE setPropertyName NOTIFY propertyNameChanged)
130 Q_PROPERTY(QString value READ value WRITE setValue NOTIFY valueChanged)
131 Q_PROPERTY(bool negated READ isNegated WRITE setNegated NOTIFY negatedChanged)
132public:
133 QString propertyName() const { return m_filter.propertyName(); }
134 void setPropertyName(const QString &name);
135
136 QString value() const { return m_filter.value().toString(); }
137 void setValue(const QString &value);
138
139 bool isNegated() const { return m_filter.isNegated(); }
140 void setNegated(bool negated);
141
142 QGalleryFilter filter() const;
143
144Q_SIGNALS:
145 void propertyNameChanged();
146 void valueChanged();
147 void negatedChanged();
148
149protected:
150 explicit QDeclarativeGalleryStringFilter(
151 QGalleryFilter::Comparator comparator, QObject *parent = Q_NULLPTR)
152 : QDeclarativeGalleryFilterBase(parent)
153 {
154 m_filter.setComparator(comparator);
155 }
156
157 QGalleryMetaDataFilter m_filter;
158};
159
160class QDeclarativeGalleryEqualsFilter : public QDeclarativeGalleryValueFilter
161{
162 Q_OBJECT
163public:
164 explicit QDeclarativeGalleryEqualsFilter(QObject *parent = Q_NULLPTR)
165 : QDeclarativeGalleryValueFilter(QGalleryFilter::Equals, parent)
166 {
167 }
168
169 QGalleryFilter filter() const;
170};
171
172class QDeclarativeGalleryLessThanFilter : public QDeclarativeGalleryValueFilter
173{
174 Q_OBJECT
175public:
176 explicit QDeclarativeGalleryLessThanFilter(QObject *parent = Q_NULLPTR)
177 : QDeclarativeGalleryValueFilter(QGalleryFilter::LessThan, parent)
178 {
179 }
180};
181
182class QDeclarativeGalleryLessThanEqualsFilter : public QDeclarativeGalleryValueFilter
183{
184 Q_OBJECT
185public:
186 explicit QDeclarativeGalleryLessThanEqualsFilter(QObject *parent = Q_NULLPTR)
187 : QDeclarativeGalleryValueFilter(QGalleryFilter::LessThanEquals, parent)
188 {
189 }
190};
191
192class QDeclarativeGalleryGreaterThanFilter : public QDeclarativeGalleryValueFilter
193{
194 Q_OBJECT
195public:
196 explicit QDeclarativeGalleryGreaterThanFilter(QObject *parent = Q_NULLPTR)
197 : QDeclarativeGalleryValueFilter(QGalleryFilter::GreaterThan, parent)
198 {
199 }
200};
201
202class QDeclarativeGalleryGreaterThanEqualsFilter : public QDeclarativeGalleryValueFilter
203{
204 Q_OBJECT
205public:
206 explicit QDeclarativeGalleryGreaterThanEqualsFilter(QObject *parent = Q_NULLPTR)
207 : QDeclarativeGalleryValueFilter(QGalleryFilter::GreaterThanEquals, parent)
208 {
209 }
210};
211
212class QDeclarativeGalleryContainsFilter : public QDeclarativeGalleryStringFilter
213{
214 Q_OBJECT
215public:
216 explicit QDeclarativeGalleryContainsFilter(QObject *parent = Q_NULLPTR)
217 : QDeclarativeGalleryStringFilter(QGalleryFilter::Contains, parent)
218 {
219 }
220};
221
222class QDeclarativeGalleryStartsWithFilter : public QDeclarativeGalleryStringFilter
223{
224 Q_OBJECT
225public:
226 explicit QDeclarativeGalleryStartsWithFilter(QObject *parent = Q_NULLPTR)
227 : QDeclarativeGalleryStringFilter(QGalleryFilter::StartsWith, parent)
228 {
229 }
230};
231
232
233class QDeclarativeGalleryEndsWithFilter : public QDeclarativeGalleryStringFilter
234{
235 Q_OBJECT
236public:
237 explicit QDeclarativeGalleryEndsWithFilter(QObject *parent = Q_NULLPTR)
238 : QDeclarativeGalleryStringFilter(QGalleryFilter::EndsWith, parent)
239 {
240 }
241};
242
243class QDeclarativeGalleryWildcardFilter : public QDeclarativeGalleryStringFilter
244{
245 Q_OBJECT
246public:
247 explicit QDeclarativeGalleryWildcardFilter(QObject *parent = Q_NULLPTR)
248 : QDeclarativeGalleryStringFilter(QGalleryFilter::Wildcard, parent)
249 {
250 }
251};
252
253class QDeclarativeGalleryFilterGroup
254 : public QDeclarativeGalleryFilterBase
255 , public QQmlParserStatus
256{
257 Q_OBJECT
258 Q_INTERFACES(QQmlParserStatus)
259 Q_PROPERTY(QQmlListProperty<QDocGallery::QDeclarativeGalleryFilterBase> filters READ filters)
260 Q_CLASSINFO("DefaultProperty", "filters")
261public:
262 explicit QDeclarativeGalleryFilterGroup(QObject *parent = Q_NULLPTR)
263 : QDeclarativeGalleryFilterBase(parent)
264 , m_complete(false)
265 {
266 }
267
268 void classBegin();
269 void componentComplete();
270
271 QQmlListProperty<QDeclarativeGalleryFilterBase> filters();
272
273protected:
274 QList<QDeclarativeGalleryFilterBase *> m_filters;
275
276private:
277 bool m_complete;
278
279 static void append(
280 QQmlListProperty<QDeclarativeGalleryFilterBase> *filters,
281 QDeclarativeGalleryFilterBase *filter);
282 static int count(QQmlListProperty<QDeclarativeGalleryFilterBase> *filters);
283 static QDeclarativeGalleryFilterBase *at(
284 QQmlListProperty<QDeclarativeGalleryFilterBase> *filters, int index);
285 static void clear(QQmlListProperty<QDeclarativeGalleryFilterBase> *filters);
286};
287
288class QDeclarativeGalleryFilterUnion : public QDeclarativeGalleryFilterGroup
289{
290 Q_OBJECT
291public:
292 explicit QDeclarativeGalleryFilterUnion(QObject *parent = Q_NULLPTR)
293 : QDeclarativeGalleryFilterGroup(parent)
294 {
295 }
296
297 QGalleryFilter filter() const;
298};
299
300class QDeclarativeGalleryFilterIntersection : public QDeclarativeGalleryFilterGroup
301{
302 Q_OBJECT
303public:
304 explicit QDeclarativeGalleryFilterIntersection(QObject *parent = Q_NULLPTR)
305 : QDeclarativeGalleryFilterGroup(parent)
306 {
307 }
308
309 QGalleryFilter filter() const;
310};
311
312QT_END_NAMESPACE_DOCGALLERY
313
314QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryFilterBase))
315QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryEqualsFilter))
316QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryLessThanFilter))
317QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryLessThanEqualsFilter))
318QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryGreaterThanFilter))
319QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryGreaterThanEqualsFilter))
320QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryContainsFilter))
321QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryStartsWithFilter))
322QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryEndsWithFilter))
323QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryWildcardFilter))
324QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryFilterUnion))
325QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeGalleryFilterIntersection))
326
327#endif
328

source code of qtdocgallery/src/imports/gallery/qdeclarativegalleryfilter.h