Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdeclarativegeomapitembase_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QDECLARATIVEGEOMAPITEMBASE_H
5#define QDECLARATIVEGEOMAPITEMBASE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtLocation/private/qlocationglobal_p.h>
19
20#include <QtQuick/QQuickItem>
21#include <QtPositioning/QGeoShape>
22
23#include <QtLocation/qlocation.h>
24#include <QtLocation/private/qdeclarativegeomap_p.h>
25#include <QtLocation/private/qlocationglobal_p.h>
26#include <QtLocation/private/qgeomap_p.h>
27#include <QtLocation/private/qdeclarativegeomapitemtransitionmanager_p.h>
28#include <QScopedPointer>
29#include <QtQuickShapes/private/qquickshape_p.h>
30
31#include <QtCore/qpointer.h>
32
34
35struct Q_LOCATION_EXPORT QGeoMapViewportChangeEvent
36{
37 QGeoCameraData cameraData;
38 QSizeF mapSize;
39
40 bool zoomLevelChanged = false;
41 bool centerChanged = false;
42 bool mapSizeChanged = false;
43 bool tiltChanged = false;
44 bool bearingChanged = false;
45 bool rollChanged = false;
46};
47
48class Q_LOCATION_EXPORT QDeclarativeGeoMapItemBase : public QQuickItem
49{
50 Q_OBJECT
51 QML_NAMED_ELEMENT(GeoMapItemBase)
52 QML_ADDED_IN_VERSION(5, 0)
53 QML_UNCREATABLE("GeoMapItemBase is not intended instantiable by developer.")
54 Q_ENUMS(ReferenceSurface)
55
56 Q_PROPERTY(QGeoShape geoShape READ geoShape WRITE setGeoShape STORED false )
57 Q_PROPERTY(bool autoFadeIn READ autoFadeIn WRITE setAutoFadeIn REVISION(5, 14))
58 Q_PROPERTY(QLocation::ReferenceSurface referenceSurface READ referenceSurface WRITE setReferenceSurface NOTIFY referenceSurfaceChanged REVISION(6, 6))
59 Q_PROPERTY(int lodThreshold READ lodThreshold WRITE setLodThreshold NOTIFY lodThresholdChanged REVISION(5, 15))
60
61public:
62 explicit QDeclarativeGeoMapItemBase(QQuickItem *parent = nullptr);
63 virtual ~QDeclarativeGeoMapItemBase();
64
65
66 virtual void setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map);
67 virtual void setPositionOnMap(const QGeoCoordinate &coordinate, const QPointF &offset);
68
69 QDeclarativeGeoMap *quickMap() const { return quickMap_; }
70 QGeoMap *map() const { return map_; }
71 virtual const QGeoShape &geoShape() const = 0;
72 virtual void setGeoShape(const QGeoShape &shape) = 0;
73
74 bool autoFadeIn() const;
75 void setAutoFadeIn(bool fadeIn);
76
77 QLocation::ReferenceSurface referenceSurface() const;
78 void setReferenceSurface(QLocation::ReferenceSurface referenceSurface);
79
80 int lodThreshold() const;
81 void setLodThreshold(int lt);
82 unsigned int zoomForLOD(int zoom) const;
83
84 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
85 virtual QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *);
86
87 inline QGeoMap::ItemType itemType() const { return m_itemType; }
88 qreal mapItemOpacity() const;
89
90 void setParentGroup(QDeclarativeGeoMapItemGroup &parentGroup);
91
92 template <typename T = QObject>
93 QList<T*> quickChildren() const
94 {
95 QList<T*> res;
96 QObjectList kids = children();
97 const QList<QQuickItem *> quickKids = childItems();
98 for (const auto &quickKid : quickKids)
99 kids.append(quickKid);
100 for (auto *kid : std::as_const(kids)) {
101 if (auto *val = qobject_cast<T*>(kid))
102 res.push_back(val);
103 }
104 return res;
105 }
106
107 void setShapeTriangulationScale(QQuickShape *shape, qreal maxCoord) const;
108
109Q_SIGNALS:
110 void mapItemOpacityChanged();
111 Q_REVISION(5, 12) void addTransitionFinished();
112 Q_REVISION(5, 12) void removeTransitionFinished();
113 void referenceSurfaceChanged();
114 void lodThresholdChanged();
115
116protected Q_SLOTS:
117 virtual void afterChildrenChanged();
118 virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) = 0;
119 void polishAndUpdate();
120
121protected:
122 float zoomLevelOpacity() const;
123 bool isPolishScheduled() const;
124
125 QGeoMap::ItemType m_itemType = QGeoMap::NoItem;
126
127private Q_SLOTS:
128 void baseCameraDataChanged(const QGeoCameraData &camera);
129 void visibleAreaChanged();
130
131private:
132 QPointer<QGeoMap> map_;
133 QDeclarativeGeoMap *quickMap_ = nullptr;
134
135 QSizeF lastMapSize_;
136 QGeoCameraData lastCameraData_;
137
138 QDeclarativeGeoMapItemGroup *parentGroup_ = nullptr;
139
140 std::unique_ptr<QDeclarativeGeoMapItemTransitionManager> m_transitionManager;
141 bool m_autoFadeIn = true;
142 QLocation::ReferenceSurface m_referenceSurface = QLocation::ReferenceSurface::Map;
143 int m_lodThreshold = 0;
144
145 friend class QDeclarativeGeoMap;
146 friend class QDeclarativeGeoMapItemView;
147 friend class QDeclarativeGeoMapItemTransitionManager;
148};
149
151{
153public:
156 {
157 return m_path;
158 }
160 {
161 m_path = path;
162 emit changed();
163 }
168private:
170};
171
172QT_END_NAMESPACE
173
174#endif