| 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 QGALLERYABSTRACTREQUEST_H |
| 43 | #define QGALLERYABSTRACTREQUEST_H |
| 44 | |
| 45 | #include "qgalleryglobal.h" |
| 46 | |
| 47 | #include <QtCore/qobject.h> |
| 48 | #include <QtCore/qstringlist.h> |
| 49 | |
| 50 | QT_BEGIN_HEADER |
| 51 | QT_BEGIN_NAMESPACE_DOCGALLERY |
| 52 | |
| 53 | class QAbstractGallery; |
| 54 | class QGalleryAbstractResponse; |
| 55 | class QGalleryAbstractRequestPrivate; |
| 56 | |
| 57 | class Q_GALLERY_EXPORT QGalleryAbstractRequest : public QObject |
| 58 | { |
| 59 | Q_OBJECT |
| 60 | |
| 61 | Q_ENUMS(State) |
| 62 | Q_ENUMS(RequestType) |
| 63 | |
| 64 | Q_PROPERTY(QAbstractGallery* gallery READ gallery WRITE setGallery NOTIFY galleryChanged) |
| 65 | Q_PROPERTY(bool supported READ isSupported NOTIFY supportedChanged) |
| 66 | Q_PROPERTY(State state READ state NOTIFY stateChanged) |
| 67 | Q_PROPERTY(int error READ error NOTIFY errorChanged) |
| 68 | Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged) |
| 69 | Q_PROPERTY(int currentProgress READ currentProgress NOTIFY progressChanged) |
| 70 | Q_PROPERTY(int maximumProgress READ maximumProgress NOTIFY progressChanged) |
| 71 | |
| 72 | public: |
| 73 | enum State { |
| 74 | Inactive, |
| 75 | Active, |
| 76 | Canceling, |
| 77 | Canceled, |
| 78 | Idle, |
| 79 | Finished, |
| 80 | Error |
| 81 | }; |
| 82 | |
| 83 | enum RequestError { |
| 84 | NoError, |
| 85 | NoGallery, |
| 86 | NotSupported, |
| 87 | GalleryError = 100 |
| 88 | }; |
| 89 | |
| 90 | enum RequestType { |
| 91 | QueryRequest, |
| 92 | ItemRequest, |
| 93 | TypeRequest |
| 94 | }; |
| 95 | |
| 96 | explicit QGalleryAbstractRequest(RequestType type, QObject *parent = Q_NULLPTR); |
| 97 | explicit QGalleryAbstractRequest( QAbstractGallery *gallery, RequestType type, QObject *parent = Q_NULLPTR); |
| 98 | ~QGalleryAbstractRequest(); |
| 99 | |
| 100 | QAbstractGallery *gallery() const; |
| 101 | void setGallery(QAbstractGallery *gallery); |
| 102 | |
| 103 | bool isSupported() const; |
| 104 | |
| 105 | RequestType type() const; |
| 106 | State state() const; |
| 107 | |
| 108 | int error() const; |
| 109 | QString errorString() const; |
| 110 | |
| 111 | int currentProgress() const; |
| 112 | int maximumProgress() const; |
| 113 | |
| 114 | bool waitForFinished(int msecs); |
| 115 | |
| 116 | public Q_SLOTS: |
| 117 | void execute(); |
| 118 | void cancel(); |
| 119 | void clear(); |
| 120 | |
| 121 | Q_SIGNALS: |
| 122 | void galleryChanged(); |
| 123 | void supportedChanged(); |
| 124 | void finished(); |
| 125 | void canceled(); |
| 126 | void error(int error, const QString &errorString); |
| 127 | void stateChanged(QGalleryAbstractRequest::State state); |
| 128 | void errorChanged(); |
| 129 | void progressChanged(int current, int maximum); |
| 130 | |
| 131 | protected: |
| 132 | virtual void setResponse(QGalleryAbstractResponse *response) = 0; |
| 133 | |
| 134 | explicit QGalleryAbstractRequest(QGalleryAbstractRequestPrivate &dd, QObject *parent); |
| 135 | |
| 136 | QScopedPointer<QGalleryAbstractRequestPrivate> d_ptr; |
| 137 | |
| 138 | private: |
| 139 | Q_DECLARE_PRIVATE(QGalleryAbstractRequest) |
| 140 | Q_PRIVATE_SLOT(d_func(), void _q_finished()) |
| 141 | Q_PRIVATE_SLOT(d_func(), void _q_canceled()) |
| 142 | Q_PRIVATE_SLOT(d_func(), void _q_resumed()) |
| 143 | Q_PRIVATE_SLOT(d_func(), void _q_progressChanged(int, int)) |
| 144 | }; |
| 145 | |
| 146 | QT_END_NAMESPACE_DOCGALLERY |
| 147 | QT_END_HEADER |
| 148 | |
| 149 | #endif |
| 150 | |