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 QDECLARATIVEGALLERYTYPE_H |
54 | #define QDECLARATIVEGALLERYTYPE_H |
55 | |
56 | #include <qgallerytyperequest.h> |
57 | |
58 | #include <QtCore/qpointer.h> |
59 | #include <QtCore/qurl.h> |
60 | #include <QtQml/qqml.h> |
61 | #include <QtQml/qqmlpropertymap.h> |
62 | |
63 | #include "qdeclarativedocumentgallery.h" |
64 | #include "qdeclarativegalleryfilter.h" |
65 | |
66 | QT_BEGIN_NAMESPACE_DOCGALLERY |
67 | |
68 | class QDeclarativeGalleryType : public QObject, public QQmlParserStatus |
69 | { |
70 | Q_OBJECT |
71 | Q_INTERFACES(QQmlParserStatus) |
72 | Q_ENUMS(Status) |
73 | Q_PROPERTY(Status status READ status NOTIFY statusChanged) |
74 | Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) |
75 | Q_PROPERTY(QStringList properties READ propertyNames WRITE setPropertyNames NOTIFY propertyNamesChanged) |
76 | Q_PROPERTY(bool autoUpdate READ autoUpdate WRITE setAutoUpdate NOTIFY autoUpdateChanged) |
77 | Q_PROPERTY(bool available READ available NOTIFY availableChanged) |
78 | Q_PROPERTY(QObject *metaData READ metaData NOTIFY metaDataChanged) |
79 | public: |
80 | enum Status |
81 | { |
82 | Null = QGalleryAbstractRequest::Inactive, |
83 | Active = QGalleryAbstractRequest::Active, |
84 | Canceling = QGalleryAbstractRequest::Canceling, |
85 | Canceled = QGalleryAbstractRequest::Canceled, |
86 | Idle = QGalleryAbstractRequest::Idle, |
87 | Finished = QGalleryAbstractRequest::Finished, |
88 | Error = QGalleryAbstractRequest::Error |
89 | }; |
90 | |
91 | ~QDeclarativeGalleryType(); |
92 | |
93 | Status status() const { return m_status; } |
94 | |
95 | qreal progress() const; |
96 | |
97 | QStringList propertyNames() { return m_request.propertyNames(); } |
98 | void setPropertyNames(const QStringList &names); |
99 | |
100 | bool autoUpdate() const { return m_request.autoUpdate(); } |
101 | void setAutoUpdate(bool enabled); |
102 | |
103 | bool available() const { return m_request.isValid(); } |
104 | |
105 | QObject *metaData() const { return m_metaData; } |
106 | |
107 | void componentComplete(); |
108 | |
109 | public Q_SLOTS: |
110 | void reload(); |
111 | void cancel(); |
112 | void clear(); |
113 | |
114 | Q_SIGNALS: |
115 | void statusChanged(); |
116 | void progressChanged(); |
117 | void availableChanged(); |
118 | void metaDataChanged(); |
119 | |
120 | void galleryChanged(); |
121 | void propertyNamesChanged(); |
122 | void autoUpdateChanged(); |
123 | |
124 | protected: |
125 | enum UpdateStatus |
126 | { |
127 | Incomplete, |
128 | NoUpdate, |
129 | PendingUpdate, |
130 | CanceledUpdate |
131 | }; |
132 | |
133 | explicit QDeclarativeGalleryType(QObject *parent = Q_NULLPTR); |
134 | |
135 | void deferredExecute(); |
136 | |
137 | bool event(QEvent *event); |
138 | |
139 | QGalleryTypeRequest m_request; |
140 | QQmlPropertyMap *m_metaData; |
141 | QHash<int, QString> m_propertyKeys; |
142 | Status m_status; |
143 | UpdateStatus m_updateStatus; |
144 | |
145 | private Q_SLOTS: |
146 | void _q_stateChanged(); |
147 | void _q_typeChanged(); |
148 | void _q_metaDataChanged(const QList<int> &keys); |
149 | }; |
150 | |
151 | class QDeclarativeDocumentGalleryType : public QDeclarativeGalleryType |
152 | { |
153 | Q_OBJECT |
154 | Q_PROPERTY(QDocGallery::QDeclarativeDocumentGallery::ItemType itemType READ itemType WRITE setItemType NOTIFY itemTypeChanged) |
155 | public: |
156 | explicit QDeclarativeDocumentGalleryType(QObject *parent = Q_NULLPTR); |
157 | ~QDeclarativeDocumentGalleryType(); |
158 | |
159 | void classBegin(); |
160 | |
161 | QDeclarativeDocumentGallery::ItemType itemType() const; |
162 | void setItemType(QDeclarativeDocumentGallery::ItemType itemType); |
163 | |
164 | Q_SIGNALS: |
165 | void itemTypeChanged(); |
166 | |
167 | }; |
168 | |
169 | QT_END_NAMESPACE_DOCGALLERY |
170 | |
171 | QML_DECLARE_TYPE(QT_DOCGALLERY_PREPEND_NAMESPACE(QDeclarativeDocumentGalleryType)) |
172 | |
173 | #endif |
174 | |