7#include <QtCore/QCoreApplication>
8#include <QtQml/qqmlinfo.h>
12#include <QtNetwork/QTcpSocket>
150 : m_singleUpdate(0), m_regularUpdates(0), m_componentComplete(0),
151 m_parametersInitialized(0), m_startRequested(0), m_defaultSourceUsed(0)
158 delete m_positionSource;
185 m_sourceName.removeBindingUnlessInWrapper();
186 if (m_positionSource && m_positionSource->
sourceName() == newName)
189 if (newName.
isEmpty() && m_defaultSourceUsed)
194 if (!m_componentComplete || !m_parametersInitialized) {
195 if (previousName != newName) {
196 m_sourceName.setValueBypassingBindings(newName);
197 m_sourceName.notify();
203 tryAttach(newName,
false);
219void QDeclarativePositionSource::tryAttach(
const QString &newName,
bool useFallback)
222 const bool sourceExisted = (m_positionSource !=
nullptr);
228 m_defaultSourceUsed =
false;
232 m_defaultSourceUsed =
true;
235 if (!m_positionSource && useFallback) {
237 m_defaultSourceUsed =
true;
241 if (m_positionSource) {
242 m_sourceName.setValueBypassingBindings(m_positionSource->
sourceName());
251 static_cast<QGeoPositionInfoSource::PositioningMethods
>(
int(m_preferredPositioningMethods)));
253 if (m_startRequested) {
259 m_sourceName.setValueBypassingBindings(newName);
260 m_defaultSourceUsed =
false;
265 m_active.setValueBypassingBindings(
false);
277 notifySupportedPositioningMethodsChanged();
279 const bool sourceCurrentlyExists = (m_positionSource !=
nullptr);
280 if (sourceExisted != sourceCurrentlyExists) {
290 m_active.setValueBypassingBindings(
false);
292 }
else if (m_startRequested) {
293 m_startRequested =
false;
297 if (previousName != m_sourceName)
298 m_sourceName.notify();
313 return m_isValid.value();
321bool QDeclarativePositionSource::isValidActualComputation()
const
323 return m_positionSource !=
nullptr;
329void QDeclarativePositionSource::onParameterInitialized()
331 m_parametersInitialized =
true;
333 if (!
p->isInitialized()) {
334 m_parametersInitialized =
false;
340 if (m_parametersInitialized)
341 tryAttach(m_sourceName.value());
344void QDeclarativePositionSource::notifySupportedPositioningMethodsChanged()
346 m_supportedPositioningMethods.notify();
352 m_position.value()->setPosition(
pi);
359 if (m_positionSource)
360 delete m_positionSource;
363 m_positionSource =
nullptr;
365 m_positionSource =
source;
367 this, &QDeclarativePositionSource::notifySupportedPositioningMethodsChanged);
371bool QDeclarativePositionSource::parametersReady()
374 if (!
p->isInitialized())
387 for (
const auto *parameter : m_parameters)
388 map.
insert(parameter->name(), parameter->value());
398 if (m_positionSource) {
426 if (!m_positionSource)
427 return m_updateInterval;
447QDeclarativePositionSource::PositioningMethods
450 return m_supportedPositioningMethods.value();
453QDeclarativePositionSource::PositioningMethods
454QDeclarativePositionSource::supportedMethodsActualComputation()
const
456 if (m_positionSource) {
457 return static_cast<QDeclarativePositionSource::PositioningMethods
>(
486 if (m_positionSource) {
489 m_preferredPositioningMethods =
methods;
491 if (previousPreferredPositioningMethods !=
methods) {
493 static_cast<QGeoPositionInfoSource::PositioningMethods
>(
int(
methods)));
498 if (m_preferredPositioningMethods !=
methods) {
499 m_preferredPositioningMethods =
methods;
507 if (m_positionSource) {
508 return static_cast<QDeclarativePositionSource::PositioningMethods
>(
511 return m_preferredPositioningMethods;
529 if (m_positionSource) {
530 m_active.removeBindingUnlessInWrapper();
554 if (m_positionSource) {
555 m_singleUpdate =
true;
560 m_active.setValueBypassingBindings(
true);
585 if (m_positionSource) {
587 m_regularUpdates =
false;
591 m_active.removeBindingUnlessInWrapper();
592 if (m_active && !m_singleUpdate) {
593 m_active.setValueBypassingBindings(
false);
612 m_active.removeBindingUnlessInWrapper();
619 if (m_componentComplete && m_parametersInitialized)
622 m_startRequested =
true;
652 return m_position.value();
655void QDeclarativePositionSource::positionUpdateReceived(
const QGeoPositionInfo &update)
659 if (m_singleUpdate && m_active) {
661 m_singleUpdate =
false;
662 if (!m_regularUpdates) {
665 m_active.setValueBypassingBindings(
false);
694 return m_sourceError;
705 return m_positionSource;
732 p->m_parameters.
append(parameter);
760void QDeclarativePositionSource::executeStart()
762 if (m_positionSource) {
771 m_regularUpdates =
true;
773 m_active.setValueBypassingBindings(
true);
781 m_componentComplete =
true;
782 m_parametersInitialized =
true;
784 if (!
p->isInitialized()) {
785 m_parametersInitialized =
false;
787 this, &QDeclarativePositionSource::onParameterInitialized,
792 if (m_parametersInitialized)
793 tryAttach(m_sourceName.value());
810 if (m_positionSource)
829 if (m_positionSource)
855 m_sourceError.notify();
860 if (m_active && m_singleUpdate) {
861 m_singleUpdate =
false;
862 if (!m_regularUpdates) {
863 m_active.setValueBypassingBindings(
false);
871#include "moc_qdeclarativepositionsource_p.cpp"
static JNINativeMethod methods[]
void setUpdateInterval(int updateInterval)
QBindable< SourceError > bindableSourceError() const
void preferredPositioningMethodsChanged()
QBindable< bool > bindableIsValid() const
bool isValid() const
\qmlproperty bool PositionSource::valid
QDeclarativePositionSource()
The PositionSource type provides the device's current position.
QQmlListProperty< QDeclarativePluginParameter > parameters
\qmlproperty list<PluginParameter> PositionSource::parameters \qmldefault
void updateIntervalChanged()
void stop()
\qmlmethod PositionSource::stop()
~QDeclarativePositionSource()
void setPreferredPositioningMethods(PositioningMethods methods)
\qmlproperty enumeration PositionSource::preferredPositioningMethods
void supportedPositioningMethodsChanged()
QGeoPositionInfoSource * positionSource() const
void sourceErrorChanged()
QBindable< QDeclarativePosition * > bindablePosition() const
void setName(const QString &name)
void start()
\qmlmethod PositionSource::start()
QVariantMap parameterMap() const
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
QBindable< PositioningMethods > bindableSupportedPositioningMethods() const
QBindable< QString > bindableName()
PositioningMethods preferredPositioningMethods
QBindable< bool > bindableActive()
void setActive(bool active)
\qmlproperty bool PositionSource::active
PositioningMethods supportedPositioningMethods
void update(int timeout=0)
\qmlmethod PositionSource::update(int timeout)
QDeclarativePosition * position
\qmlproperty Position PositionSource::position
virtual void requestUpdate(int timeout=0)=0
Attempts to get the current position and emit positionUpdated() with this information.
virtual void stopUpdates()=0
Stops emitting updates at regular intervals.
virtual QVariant backendProperty(const QString &name) const
Returns the value of the backend-specific property named name, if present.
int updateInterval
This property holds the requested interval in milliseconds between each update.
virtual PositioningMethods supportedPositioningMethods() const =0
Returns the positioning methods available to this source.
virtual bool setBackendProperty(const QString &name, const QVariant &value)
Sets the backend-specific property named name to value.
virtual void startUpdates()=0
Starts emitting updates at regular intervals as specified by setUpdateInterval().
static QGeoPositionInfoSource * createDefaultSource(QObject *parent)
Creates and returns a position source with the given parent that reads from the system's default sour...
virtual void setPreferredPositioningMethods(PositioningMethods methods)
QString sourceName
This property holds the unique name of the position source implementation in use.
virtual QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly=false) const =0
Returns an update containing the last known position, or a null update if none is available.
static QGeoPositionInfoSource * createSource(const QString &sourceName, QObject *parent)
Creates and returns a position source with the given parent, by loading the plugin named sourceName.
void supportedPositioningMethodsChanged()
This signal is emitted when the supported positioning methods changed.
Error
The Error enumeration represents the errors which can occur.
virtual void setUpdateInterval(int msec)
PositioningMethods preferredPositioningMethods
Sets the preferred positioning methods for this source.
bool isValid() const
Returns true if the timestamp() and coordinate() values are both valid.
qsizetype size() const noexcept
void append(parameter_type t)
iterator insert(const Key &key, const T &value)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QMap< QString, QString > map
[6]
static void positionUpdated(JNIEnv *env, jobject thiz, QtJniTypes::Location location, jint androidClassKey, jboolean isSingleUpdate)
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
n void setPosition(void) \n\
GLbitfield GLuint64 timeout
[4]
GLsizei GLsizei GLchar * source