| 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 QGALLERYQUERYREQUEST_H |
| 43 | #define QGALLERYQUERYREQUEST_H |
| 44 | |
| 45 | #include <qgalleryabstractrequest.h> |
| 46 | #include <qgalleryproperty.h> |
| 47 | #include <qgalleryresource.h> |
| 48 | #include <QtCore/qurl.h> |
| 49 | |
| 50 | QT_BEGIN_NAMESPACE_DOCGALLERY |
| 51 | |
| 52 | class QGalleryFilter; |
| 53 | class QGalleryResultSet; |
| 54 | |
| 55 | class QGalleryQueryRequestPrivate; |
| 56 | |
| 57 | class Q_GALLERY_EXPORT QGalleryQueryRequest : public QGalleryAbstractRequest |
| 58 | { |
| 59 | Q_OBJECT |
| 60 | |
| 61 | Q_ENUMS(Scope) |
| 62 | |
| 63 | Q_PROPERTY(QStringList propertyNames READ propertyNames WRITE setPropertyNames NOTIFY propertyNamesChanged) |
| 64 | Q_PROPERTY(QStringList sortPropertyNames READ sortPropertyNames WRITE setSortPropertyNames NOTIFY sortPropertyNamesChanged) |
| 65 | Q_PROPERTY(bool autoUpdate READ autoUpdate WRITE setAutoUpdate NOTIFY autoUpdateChanged) |
| 66 | Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged) |
| 67 | Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged) |
| 68 | Q_PROPERTY(QString rootType READ rootType WRITE setRootType NOTIFY rootTypeChanged) |
| 69 | Q_PROPERTY(QVariant rootItem READ rootItem WRITE setRootItem NOTIFY rootItemChanged) |
| 70 | Q_PROPERTY(QGalleryQueryRequest::Scope scope READ scope WRITE setScope NOTIFY scopeChanged) |
| 71 | Q_PROPERTY(QGalleryFilter filter READ filter WRITE setFilter NOTIFY filterChanged) |
| 72 | Q_PROPERTY(bool valid READ isValid NOTIFY currentItemChanged) |
| 73 | Q_PROPERTY(QVariant itemId READ itemId NOTIFY currentItemChanged) |
| 74 | Q_PROPERTY(QString itemType READ itemType NOTIFY currentItemChanged) |
| 75 | Q_PROPERTY(QUrl itemUrl READ itemUrl NOTIFY currentItemChanged) |
| 76 | Q_PROPERTY(QList<QGalleryResource> resources READ resources NOTIFY currentItemChanged) |
| 77 | Q_PROPERTY(int currentIndex READ currentIndex WRITE seek NOTIFY currentItemChanged) |
| 78 | |
| 79 | public: |
| 80 | enum Scope { |
| 81 | AllDescendants, |
| 82 | DirectDescendants |
| 83 | }; |
| 84 | |
| 85 | explicit QGalleryQueryRequest(QObject *parent = Q_NULLPTR); |
| 86 | explicit QGalleryQueryRequest(QAbstractGallery *gallery, QObject *parent = Q_NULLPTR); |
| 87 | ~QGalleryQueryRequest(); |
| 88 | |
| 89 | QStringList propertyNames() const; |
| 90 | void setPropertyNames(const QStringList &names); |
| 91 | |
| 92 | QStringList sortPropertyNames() const; |
| 93 | void setSortPropertyNames(const QStringList &names); |
| 94 | |
| 95 | bool autoUpdate() const; |
| 96 | void setAutoUpdate(bool enabled); |
| 97 | |
| 98 | int offset() const; |
| 99 | void setOffset(int offset); |
| 100 | |
| 101 | int limit() const; |
| 102 | void setLimit(int limit); |
| 103 | |
| 104 | QString rootType() const; |
| 105 | void setRootType(const QString &itemType); |
| 106 | |
| 107 | QVariant rootItem() const; |
| 108 | void setRootItem(const QVariant &itemId); |
| 109 | |
| 110 | QGalleryQueryRequest::Scope scope() const; |
| 111 | void setScope(QGalleryQueryRequest::Scope scope); |
| 112 | |
| 113 | QGalleryFilter filter() const; |
| 114 | void setFilter(const QGalleryFilter &filter); |
| 115 | |
| 116 | QGalleryResultSet *resultSet() const; |
| 117 | |
| 118 | int propertyKey(const QString &property) const; |
| 119 | QGalleryProperty::Attributes propertyAttributes(int key) const; |
| 120 | QVariant::Type propertyType(int key) const; |
| 121 | |
| 122 | int itemCount() const; |
| 123 | |
| 124 | bool isValid() const; |
| 125 | |
| 126 | QVariant itemId() const; |
| 127 | QUrl itemUrl() const; |
| 128 | QString itemType() const; |
| 129 | QList<QGalleryResource> resources() const; |
| 130 | |
| 131 | QVariant metaData(int key) const; |
| 132 | bool setMetaData(int key, const QVariant &value); |
| 133 | |
| 134 | QVariant metaData(const QString &property) const; |
| 135 | bool setMetaData(const QString &property, const QVariant &value); |
| 136 | |
| 137 | int currentIndex() const; |
| 138 | bool seek(int index, bool relative = false); |
| 139 | bool next(); |
| 140 | bool previous(); |
| 141 | bool first(); |
| 142 | bool last(); |
| 143 | |
| 144 | Q_SIGNALS: |
| 145 | void propertyNamesChanged(); |
| 146 | void sortPropertyNamesChanged(); |
| 147 | void autoUpdateChanged(); |
| 148 | void offsetChanged(); |
| 149 | void limitChanged(); |
| 150 | void rootTypeChanged(); |
| 151 | void rootItemChanged(); |
| 152 | void scopeChanged(); |
| 153 | void filterChanged(); |
| 154 | void resultSetChanged(QGalleryResultSet *resultSet); |
| 155 | void currentItemChanged(); |
| 156 | |
| 157 | protected: |
| 158 | void setResponse(QGalleryAbstractResponse *response); |
| 159 | |
| 160 | private: |
| 161 | Q_DECLARE_PRIVATE(QGalleryQueryRequest) |
| 162 | }; |
| 163 | |
| 164 | QT_END_NAMESPACE_DOCGALLERY |
| 165 | |
| 166 | #endif |
| 167 | |