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
55 Q_PROPERTY(QGeoShape geoShape READ geoShape WRITE setGeoShape STORED false )
56 Q_PROPERTY(bool autoFadeIn READ autoFadeIn WRITE setAutoFadeIn REVISION(5, 14))
57 Q_PROPERTY(QLocation::ReferenceSurface referenceSurface READ referenceSurface WRITE setReferenceSurface NOTIFY referenceSurfaceChanged REVISION(6, 6))
58 Q_PROPERTY(int lodThreshold READ lodThreshold WRITE setLodThreshold NOTIFY lodThresholdChanged REVISION(5, 15))
59
60public:
61 explicit QDeclarativeGeoMapItemBase(QQuickItem *parent = nullptr);
62 virtual ~QDeclarativeGeoMapItemBase();
63
64
65 virtual void setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map);
66 virtual void setPositionOnMap(const QGeoCoordinate &coordinate, const QPointF &offset);
67
68 QDeclarativeGeoMap *quickMap() const { return quickMap_; }
69 QGeoMap *map() const { return map_; }
70 virtual const QGeoShape &geoShape() const = 0;
71 virtual void setGeoShape(const QGeoShape &shape) = 0;
72
73 bool autoFadeIn() const;
74 void setAutoFadeIn(bool fadeIn);
75
76 QLocation::ReferenceSurface referenceSurface() const;
77 void setReferenceSurface(QLocation::ReferenceSurface referenceSurface);
78
79 int lodThreshold() const;
80 void setLodThreshold(int lt);
81 unsigned int zoomForLOD(int zoom) const;
82
83 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
84 virtual QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *);
85
86 inline QGeoMap::ItemType itemType() const { return m_itemType; }
87 qreal mapItemOpacity() const;
88
89 void setParentGroup(QDeclarativeGeoMapItemGroup &parentGroup);
90
91 template <typename T = QObject>
92 QList<T*> quickChildren() const
93 {
94 QList<T*> res;
95 QObjectList kids = children();
96 const QList<QQuickItem *> quickKids = childItems();
97 for (const auto &quickKid : quickKids)
98 kids.append(quickKid);
99 for (auto *kid : std::as_const(kids)) {
100 if (auto *val = qobject_cast<T*>(kid))
101 res.push_back(val);
102 }
103 return res;
104 }
105
106 void setShapeTriangulationScale(QQuickShape *shape, qreal maxCoord) const;
107
108Q_SIGNALS:
109 void mapItemOpacityChanged();
110 Q_REVISION(5, 12) void addTransitionFinished();
111 Q_REVISION(5, 12) void removeTransitionFinished();
112 void referenceSurfaceChanged();
113 void lodThresholdChanged();
114
115protected Q_SLOTS:
116 virtual void afterChildrenChanged();
117 virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) = 0;
118 void polishAndUpdate();
119
120protected:
121 float zoomLevelOpacity() const;
122 bool isPolishScheduled() const;
123
124 QGeoMap::ItemType m_itemType = QGeoMap::NoItem;
125
126private Q_SLOTS:
127 void baseCameraDataChanged(const QGeoCameraData &camera);
128 void visibleAreaChanged();
129
130private:
131 QPointer<QGeoMap> map_;
132 QDeclarativeGeoMap *quickMap_ = nullptr;
133
134 QSizeF lastMapSize_;
135 QGeoCameraData lastCameraData_;
136
137 QDeclarativeGeoMapItemGroup *parentGroup_ = nullptr;
138
139 std::unique_ptr<QDeclarativeGeoMapItemTransitionManager> m_transitionManager;
140 bool m_autoFadeIn = true;
141 QLocation::ReferenceSurface m_referenceSurface = QLocation::ReferenceSurface::Map;
142 int m_lodThreshold = 0;
143
144 friend class QDeclarativeGeoMap;
145 friend class QDeclarativeGeoMapItemView;
146 friend class QDeclarativeGeoMapItemTransitionManager;
147};
148
150{
152public:
155 {
156 return m_path;
157 }
159 {
160 m_path = path;
161 emit changed();
162 }
167private:
169};
170
171QT_END_NAMESPACE
172
173#endif
Combined button and popup list for selecting options.