1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2017 Mapbox, Inc. 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 QQMAPBOXGLSTYLECHANGE_P_H 38 #define QQMAPBOXGLSTYLECHANGE_P_H 39 40 #include <QtCore/QList> 41 #include <QtCore/QSharedPointer> 42 #include <QtCore/QString> 43 #include <QtCore/QVariant> 44 #include <QtCore/QVariantMap> 45 #include <QtGui/QImage> 46 #include <QtLocation/private/qdeclarativecirclemapitem_p.h> 47 #include <QtLocation/private/qdeclarativegeomapitembase_p.h> 48 #include <QtLocation/private/qdeclarativepolygonmapitem_p.h> 49 #include <QtLocation/private/qdeclarativepolylinemapitem_p.h> 50 #include <QtLocation/private/qdeclarativerectanglemapitem_p.h> 51 #include <QtLocation/private/qgeomapparameter_p.h> 52 53 #include <QMapboxGL> 54 55 class QMapboxGLStyleChange 56 { 57 public: 58 virtual ~QMapboxGLStyleChange() = default; 59 60 static QList<QSharedPointer<QMapboxGLStyleChange>> addMapParameter(QGeoMapParameter *); 61 static QList<QSharedPointer<QMapboxGLStyleChange>> addMapItem(QDeclarativeGeoMapItemBase *, const QString &before); 62 static QList<QSharedPointer<QMapboxGLStyleChange>> removeMapParameter(QGeoMapParameter *); 63 static QList<QSharedPointer<QMapboxGLStyleChange>> removeMapItem(QDeclarativeGeoMapItemBase *); 64 65 virtual void apply(QMapboxGL *map) = 0; 66 }; 67 68 class QMapboxGLStyleSetLayoutProperty : public QMapboxGLStyleChange 69 { 70 public: 71 static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapParameter(QGeoMapParameter *); 72 static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapItem(QDeclarativeGeoMapItemBase *); 73 74 void apply(QMapboxGL *map) override; 75 76 private: 77 static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapItem(QDeclarativePolylineMapItem *); 78 79 QMapboxGLStyleSetLayoutProperty() = default; 80 QMapboxGLStyleSetLayoutProperty(const QString &layer, const QString &property, const QVariant &value); 81 82 QString m_layer; 83 QString m_property; 84 QVariant m_value; 85 }; 86 87 class QMapboxGLStyleSetPaintProperty : public QMapboxGLStyleChange 88 { 89 public: 90 static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapParameter(QGeoMapParameter *); 91 static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapItem(QDeclarativeGeoMapItemBase *); 92 93 void apply(QMapboxGL *map) override; 94 95 private: 96 static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapItem(QDeclarativeRectangleMapItem *); 97 static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapItem(QDeclarativeCircleMapItem *); 98 static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapItem(QDeclarativePolygonMapItem *); 99 static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapItem(QDeclarativePolylineMapItem *); 100 101 QMapboxGLStyleSetPaintProperty() = default; 102 QMapboxGLStyleSetPaintProperty(const QString &layer, const QString &property, const QVariant &value); 103 104 QString m_layer; 105 QString m_property; 106 QVariant m_value; 107 }; 108 109 class QMapboxGLStyleAddLayer : public QMapboxGLStyleChange 110 { 111 public: 112 static QSharedPointer<QMapboxGLStyleChange> fromMapParameter(QGeoMapParameter *); 113 static QSharedPointer<QMapboxGLStyleChange> fromFeature(const QMapbox::Feature &feature, const QString &before); 114 115 void apply(QMapboxGL *map) override; 116 117 private: 118 QMapboxGLStyleAddLayer() = default; 119 120 QVariantMap m_params; 121 QString m_before; 122 }; 123 124 class QMapboxGLStyleRemoveLayer : public QMapboxGLStyleChange 125 { 126 public: 127 explicit QMapboxGLStyleRemoveLayer(const QString &id); 128 129 void apply(QMapboxGL *map) override; 130 131 private: 132 QMapboxGLStyleRemoveLayer() = default; 133 134 QString m_id; 135 }; 136 137 class QMapboxGLStyleAddSource : public QMapboxGLStyleChange 138 { 139 public: 140 static QSharedPointer<QMapboxGLStyleChange> fromMapParameter(QGeoMapParameter *); 141 static QSharedPointer<QMapboxGLStyleChange> fromFeature(const QMapbox::Feature &feature); 142 static QSharedPointer<QMapboxGLStyleChange> fromMapItem(QDeclarativeGeoMapItemBase *); 143 144 void apply(QMapboxGL *map) override; 145 146 private: 147 QMapboxGLStyleAddSource() = default; 148 149 QString m_id; 150 QVariantMap m_params; 151 }; 152 153 class QMapboxGLStyleRemoveSource : public QMapboxGLStyleChange 154 { 155 public: 156 explicit QMapboxGLStyleRemoveSource(const QString &id); 157 158 void apply(QMapboxGL *map) override; 159 160 private: 161 QMapboxGLStyleRemoveSource() = default; 162 163 QString m_id; 164 }; 165 166 class QMapboxGLStyleSetFilter : public QMapboxGLStyleChange 167 { 168 public: 169 static QSharedPointer<QMapboxGLStyleChange> fromMapParameter(QGeoMapParameter *); 170 171 void apply(QMapboxGL *map) override; 172 173 private: 174 QMapboxGLStyleSetFilter() = default; 175 176 QString m_layer; 177 QVariant m_filter; 178 }; 179 180 class QMapboxGLStyleAddImage : public QMapboxGLStyleChange 181 { 182 public: 183 static QSharedPointer<QMapboxGLStyleChange> fromMapParameter(QGeoMapParameter *); 184 185 void apply(QMapboxGL *map) override; 186 187 private: 188 QMapboxGLStyleAddImage() = default; 189 190 QString m_name; 191 QImage m_sprite; 192 }; 193 194 #endif // QQMAPBOXGLSTYLECHANGE_P_H 195