| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. |
| 4 | ** Contact: http://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtLocation module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
| 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 The Qt Company. For licensing terms |
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at http://www.qt.io/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 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or later as published by the Free |
| 28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
| 29 | ** the packaging of this file. Please review the following information to |
| 30 | ** ensure the GNU General Public License version 2.0 requirements will be |
| 31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
| 32 | ** |
| 33 | ** $QT_END_LICENSE$ |
| 34 | ** |
| 35 | ****************************************************************************/ |
| 36 | |
| 37 | #ifndef QDECLARATIVECATEGORY_P_H |
| 38 | #define QDECLARATIVECATEGORY_P_H |
| 39 | |
| 40 | // |
| 41 | // W A R N I N G |
| 42 | // ------------- |
| 43 | // |
| 44 | // This file is not part of the Qt API. It exists purely as an |
| 45 | // implementation detail. This header file may change from version to |
| 46 | // version without notice, or even be removed. |
| 47 | // |
| 48 | // We mean it. |
| 49 | // |
| 50 | |
| 51 | #include <QtLocation/private/qlocationglobal_p.h> |
| 52 | #include <QtQml/qqml.h> |
| 53 | #include <QtQml/QQmlParserStatus> |
| 54 | #include <QObject> |
| 55 | |
| 56 | #include <QtLocation/qplacecategory.h> |
| 57 | |
| 58 | #include <QtLocation/private/qdeclarativegeoserviceprovider_p.h> |
| 59 | |
| 60 | QT_BEGIN_NAMESPACE |
| 61 | |
| 62 | class QDeclarativePlaceIcon; |
| 63 | class QPlaceReply; |
| 64 | class QPlaceManager; |
| 65 | |
| 66 | class Q_LOCATION_PRIVATE_EXPORT QDeclarativeCategory : public QObject, public QQmlParserStatus |
| 67 | { |
| 68 | Q_OBJECT |
| 69 | |
| 70 | Q_ENUMS(Status Visibility) |
| 71 | |
| 72 | |
| 73 | Q_PROPERTY(QPlaceCategory category READ category WRITE setCategory) |
| 74 | Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged) |
| 75 | Q_PROPERTY(QString categoryId READ categoryId WRITE setCategoryId NOTIFY categoryIdChanged) |
| 76 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) |
| 77 | Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged) |
| 78 | Q_PROPERTY(QDeclarativePlaceIcon *icon READ icon WRITE setIcon NOTIFY iconChanged) |
| 79 | Q_PROPERTY(Status status READ status NOTIFY statusChanged) |
| 80 | |
| 81 | Q_INTERFACES(QQmlParserStatus) |
| 82 | |
| 83 | public: |
| 84 | explicit QDeclarativeCategory(QObject *parent = 0); |
| 85 | QDeclarativeCategory(const QPlaceCategory &category, QDeclarativeGeoServiceProvider *plugin, QObject *parent = 0); |
| 86 | ~QDeclarativeCategory(); |
| 87 | |
| 88 | enum Visibility { |
| 89 | UnspecifiedVisibility = QLocation::UnspecifiedVisibility, |
| 90 | DeviceVisibility = QLocation::DeviceVisibility, |
| 91 | PrivateVisibility = QLocation::PrivateVisibility, |
| 92 | PublicVisibility = QLocation::PublicVisibility |
| 93 | }; |
| 94 | enum Status {Ready, Saving, Removing, Error}; |
| 95 | |
| 96 | //From QQmlParserStatus |
| 97 | virtual void classBegin() {} |
| 98 | virtual void componentComplete(); |
| 99 | |
| 100 | void setPlugin(QDeclarativeGeoServiceProvider *plugin); |
| 101 | QDeclarativeGeoServiceProvider *plugin() const; |
| 102 | |
| 103 | QPlaceCategory category(); |
| 104 | void setCategory(const QPlaceCategory &category); |
| 105 | |
| 106 | QString categoryId() const; |
| 107 | void setCategoryId(const QString &catID); |
| 108 | QString name() const; |
| 109 | void setName(const QString &name); |
| 110 | |
| 111 | Visibility visibility() const; |
| 112 | void setVisibility(Visibility visibility); |
| 113 | |
| 114 | QDeclarativePlaceIcon *icon() const; |
| 115 | void setIcon(QDeclarativePlaceIcon *icon); |
| 116 | |
| 117 | Q_INVOKABLE QString errorString() const; |
| 118 | |
| 119 | Status status() const; |
| 120 | void setStatus(Status status, const QString &errorString = QString()); |
| 121 | |
| 122 | Q_INVOKABLE void save(const QString &parentId = QString()); |
| 123 | Q_INVOKABLE void remove(); |
| 124 | |
| 125 | Q_SIGNALS: |
| 126 | void pluginChanged(); |
| 127 | void categoryIdChanged(); |
| 128 | void nameChanged(); |
| 129 | void visibilityChanged(); |
| 130 | void iconChanged(); |
| 131 | void statusChanged(); |
| 132 | |
| 133 | private Q_SLOTS: |
| 134 | void replyFinished(); |
| 135 | void pluginReady(); |
| 136 | |
| 137 | private: |
| 138 | QPlaceManager *manager(); |
| 139 | |
| 140 | QPlaceCategory m_category; |
| 141 | QDeclarativePlaceIcon *m_icon; |
| 142 | QDeclarativeGeoServiceProvider *m_plugin; |
| 143 | QPlaceReply *m_reply; |
| 144 | bool m_complete; |
| 145 | Status m_status; |
| 146 | QString m_errorString; |
| 147 | }; |
| 148 | |
| 149 | QT_END_NAMESPACE |
| 150 | |
| 151 | QML_DECLARE_TYPE(QDeclarativeCategory) |
| 152 | |
| 153 | #endif // QDECLARATIVECATEGORY_P_H |
| 154 | |