Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdeclarativegeolocation.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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
5
7
52: QObject(parent)
53
54{
55 setLocationInternal(QGeoLocation());
56}
57
59: QObject(parent)
60{
61 setLocationInternal(src);
62}
63
67
74void QDeclarativeGeoLocation::setLocationInternal(const QGeoLocation &src)
75{
76 m_address.setValueBypassingBindings(new QDeclarativeGeoAddress(src.address(), this));
77 m_coordinate.setValueBypassingBindings(src.coordinate());
78 m_boundingShape.setValueBypassingBindings(src.boundingShape());
79 m_extendedAttributes.setValueBypassingBindings(src.extendedAttributes());
80}
81
92{
93 if (m_address && m_address->parent() == this) {
94 m_address->setAddress(src.address());
95 } else if (!m_address || m_address->parent() != this) {
96 m_address.setValue(new QDeclarativeGeoAddress(src.address(), this));
97 m_address.notify();
98 }
99
100 setCoordinate(src.coordinate());
101 setBoundingShape(src.boundingShape());
102 setExtendedAttributes(src.extendedAttributes());
103}
104
106{
107 QGeoLocation retValue;
108 retValue.setAddress(m_address ? m_address->address() : QGeoAddress());
109 retValue.setCoordinate(m_coordinate);
110 retValue.setBoundingShape(m_boundingShape);
111 retValue.setExtendedAttributes(m_extendedAttributes);
112 return retValue;
113}
114
121{
122 m_address.removeBindingUnlessInWrapper();
123
124 const QDeclarativeGeoAddress *oldAddress = m_address.valueBypassingBindings();
125 if (oldAddress == address)
126 return;
127
128 // implicitly deleting m_address.value() will force the QML bindings to
129 // be reevaluated by the QML engine. So we defer the deletion of the old
130 // address until a new value is assigned to the m_address.
131 m_address.setValueBypassingBindings(address);
132 m_address.notify();
133 if (oldAddress && (oldAddress->parent() == this))
134 delete oldAddress;
135}
136
137QBindable<QDeclarativeGeoAddress *> QDeclarativeGeoLocation::bindableAddress()
138{
139 return QBindable<QDeclarativeGeoAddress *>(&m_address);
140}
141
143{
144 return m_address;
145}
146
156{
157 m_coordinate = coordinate;
158}
159
161{
162 return QBindable<QGeoCoordinate>(&m_coordinate);
163}
164
166{
167 return m_coordinate;
168}
169
194{
195 m_boundingShape = boundingShape;
196}
197
199{
200 return QBindable<QGeoShape>(&m_boundingShape);
201}
202
204{
205 return m_extendedAttributes;
206}
207
209{
210 m_extendedAttributes = attributes;
211}
212
214{
215 return QBindable<QVariantMap>(&m_extendedAttributes);
216}
217
219{
220 return m_boundingShape;
221}
222
224
225#include "moc_qdeclarativegeolocation_p.cpp"
void setBoundingShape(const QGeoShape &boundingShape)
void setExtendedAttributes(const QVariantMap &attributes)
QBindable< QGeoCoordinate > bindableCoordinate()
QBindable< QDeclarativeGeoAddress * > bindableAddress()
QDeclarativeGeoLocation(QObject *parent=0)
\qmltype Location \inqmlmodule QtPositioning
QBindable< QVariantMap > bindableExtendedAttributes()
QBindable< QGeoShape > bindableBoundingShape()
void setAddress(QDeclarativeGeoAddress *address)
\qmlproperty Address QtPositioning::Location::address
QDeclarativeGeoAddress * address
void setLocation(const QGeoLocation &src)
\qmlproperty QGeoLocation QtPositioning::Location::location
void setCoordinate(const QGeoCoordinate coordinate)
\qmlproperty coordinate QtPositioning::Location::coordinate
\inmodule QtPositioning
Definition qgeoaddress.h:18
\inmodule QtPositioning
\inmodule QtPositioning
void setAddress(const QGeoAddress &address)
Sets the address of the location.
\inmodule QtPositioning
Definition qgeoshape.h:17
\inmodule QtCore
Definition qobject.h:103
Combined button and popup list for selecting options.
GLenum src
GLuint GLuint64EXT address