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 QDECLARATIVEGEOMAPITEMBASE_H
38#define QDECLARATIVEGEOMAPITEMBASE_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
53#include <QtQuick/QQuickItem>
54#include <QtPositioning/QGeoShape>
55
56#include <QtLocation/private/qdeclarativegeomap_p.h>
57#include <QtLocation/private/qlocationglobal_p.h>
58#include <QtLocation/private/qgeomap_p.h>
59#include <QtLocation/private/qdeclarativegeomapitemtransitionmanager_p.h>
60#include <QScopedPointer>
61
62QT_BEGIN_NAMESPACE
63
64class Q_LOCATION_PRIVATE_EXPORT QGeoMapViewportChangeEvent
65{
66public:
67 explicit QGeoMapViewportChangeEvent();
68 QGeoMapViewportChangeEvent(const QGeoMapViewportChangeEvent &other);
69 QGeoMapViewportChangeEvent &operator=(const QGeoMapViewportChangeEvent &other);
70
71 QGeoCameraData cameraData;
72 QSizeF mapSize;
73
74 bool zoomLevelChanged;
75 bool centerChanged;
76 bool mapSizeChanged;
77 bool tiltChanged;
78 bool bearingChanged;
79 bool rollChanged;
80};
81
82class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoMapItemBase : public QQuickItem
83{
84 Q_OBJECT
85
86 Q_PROPERTY(QGeoShape geoShape READ geoShape WRITE setGeoShape STORED false )
87 Q_PROPERTY(bool autoFadeIn READ autoFadeIn WRITE setAutoFadeIn REVISION 14)
88 Q_PROPERTY(int lodThreshold READ lodThreshold WRITE setLodThreshold NOTIFY lodThresholdChanged REVISION 15)
89
90public:
91 explicit QDeclarativeGeoMapItemBase(QQuickItem *parent = 0);
92 virtual ~QDeclarativeGeoMapItemBase();
93
94 virtual void setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map);
95 virtual void setPositionOnMap(const QGeoCoordinate &coordinate, const QPointF &offset);
96
97 QDeclarativeGeoMap *quickMap() const { return quickMap_; }
98 QGeoMap *map() const { return map_; }
99 virtual const QGeoShape &geoShape() const = 0;
100 virtual void setGeoShape(const QGeoShape &shape) = 0;
101
102 bool autoFadeIn() const;
103 void setAutoFadeIn(bool fadeIn);
104
105 int lodThreshold() const;
106 void setLodThreshold(int lt);
107 unsigned int zoomForLOD(int zoom) const;
108
109 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
110 virtual QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *);
111
112 QGeoMap::ItemType itemType() const;
113 qreal mapItemOpacity() const;
114
115 void setParentGroup(QDeclarativeGeoMapItemGroup &parentGroup);
116
117 template <typename T = QObject>
118
119 QList<T*> quickChildren() const
120 {
121 QList<T*> res;
122 QObjectList kids = children();
123 QList<QQuickItem *> quickKids = childItems();
124 for (int i = 0; i < quickKids.count(); ++i)
125 kids.append(t: quickKids.at(i));
126 for (auto kid : qAsConst(t&: kids)) {
127 auto val = qobject_cast<T*>(kid);
128 if (val)
129 res.push_back(val);
130 }
131 return res;
132 }
133
134Q_SIGNALS:
135 void mapItemOpacityChanged();
136 Q_REVISION(12) void addTransitionFinished();
137 Q_REVISION(12) void removeTransitionFinished();
138 void lodThresholdChanged();
139
140protected Q_SLOTS:
141 virtual void afterChildrenChanged();
142 virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) = 0;
143 void polishAndUpdate();
144
145protected:
146 float zoomLevelOpacity() const;
147 bool childMouseEventFilter(QQuickItem *item, QEvent *event);
148 bool isPolishScheduled() const;
149 virtual void setMaterialDirty();
150
151 QGeoMap::ItemType m_itemType = QGeoMap::NoItem;
152
153private Q_SLOTS:
154 void baseCameraDataChanged(const QGeoCameraData &camera);
155 void visibleAreaChanged();
156
157private:
158 QPointer<QGeoMap> map_;
159 QDeclarativeGeoMap *quickMap_;
160
161 QSizeF lastSize_;
162 QGeoCameraData lastCameraData_;
163
164 QDeclarativeGeoMapItemGroup *parentGroup_;
165
166 QScopedPointer<QDeclarativeGeoMapItemTransitionManager> m_transitionManager;
167 bool m_autoFadeIn = true;
168 int m_lodThreshold = 0;
169
170 friend class QDeclarativeGeoMap;
171 friend class QDeclarativeGeoMapItemView;
172 friend class QDeclarativeGeoMapItemTransitionManager;
173};
174
175QT_END_NAMESPACE
176
177#endif
178

source code of qtlocation/src/location/declarativemaps/qdeclarativegeomapitembase_p.h