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
qdeclarativepositionsource_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 QDECLARATIVEPOSITIONSOURCE_H
5#define QDECLARATIVEPOSITIONSOURCE_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 <QtPositioningQuick/private/qpositioningquickglobal_p.h>
19#include <QtPositioningQuick/private/qdeclarativeposition_p.h>
20#include <QtCore/QObject>
21#include <QtNetwork/QAbstractSocket>
22#include <QtQml/QQmlParserStatus>
23#include <QtPositioning/qgeopositioninfosource.h>
24#include <QtPositioningQuick/private/qdeclarativepluginparameter_p.h>
25#include <QtCore/private/qproperty_p.h>
26
28
29class QFile;
30class QTcpSocket;
31
32class Q_POSITIONINGQUICK_EXPORT QDeclarativePositionSource : public QObject, public QQmlParserStatus
33{
35 QML_NAMED_ELEMENT(PositionSource)
37
38 Q_PROPERTY(QDeclarativePosition *position READ position NOTIFY positionChanged
39 BINDABLE bindablePosition)
40 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged
41 BINDABLE bindableActive)
42 Q_PROPERTY(bool valid READ isValid NOTIFY validityChanged BINDABLE bindableIsValid)
43 Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval
44 NOTIFY updateIntervalChanged)
45 Q_PROPERTY(PositioningMethods supportedPositioningMethods READ supportedPositioningMethods
46 NOTIFY supportedPositioningMethodsChanged
47 BINDABLE bindableSupportedPositioningMethods)
48 Q_PROPERTY(PositioningMethods preferredPositioningMethods READ preferredPositioningMethods
49 WRITE setPreferredPositioningMethods NOTIFY preferredPositioningMethodsChanged)
50 Q_PROPERTY(SourceError sourceError READ sourceError NOTIFY sourceErrorChanged
51 BINDABLE bindableSourceError)
52 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged BINDABLE bindableName)
53 Q_PROPERTY(QQmlListProperty<QDeclarativePluginParameter> parameters READ parameters REVISION(5, 14))
55
56 Q_CLASSINFO("DefaultProperty", "parameters")
58
59public:
66
67 Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod)
68 Q_FLAGS(PositioningMethods)
69
77 Q_ENUMS(SourceError)
78
81 void setUpdateInterval(int updateInterval);
82 void setActive(bool active);
83 void setPreferredPositioningMethods(PositioningMethods methods);
84
85 QString name() const;
86 void setName(const QString &name);
87
88 int updateInterval() const;
89 bool isActive() const;
90 bool isValid() const;
92 PositioningMethods supportedPositioningMethods() const;
93 PositioningMethods preferredPositioningMethods() const;
94 SourceError sourceError() const;
95 QGeoPositionInfoSource *positionSource() const;
96 QQmlListProperty<QDeclarativePluginParameter> parameters();
97 QVariantMap parameterMap() const;
98
99 // Virtuals from QQmlParserStatus
100 void classBegin() override { }
101 void componentComplete() override;
102
103 Q_REVISION(5, 14) Q_INVOKABLE bool setBackendProperty(const QString &name, const QVariant &value);
104 Q_REVISION(5, 14) Q_INVOKABLE QVariant backendProperty(const QString &name) const;
105
106 QBindable<PositioningMethods> bindableSupportedPositioningMethods() const;
107 QBindable<SourceError> bindableSourceError() const;
108 QBindable<bool> bindableIsValid() const;
109 QBindable<QString> bindableName();
110 QBindable<QDeclarativePosition *> bindablePosition() const;
111 QBindable<bool> bindableActive();
112
113public Q_SLOTS:
114 void update(int timeout = 0);
115 void start();
116 void stop();
117
119 void positionChanged();
120 void activeChanged();
121 void updateIntervalChanged();
122 void supportedPositioningMethodsChanged();
123 void preferredPositioningMethodsChanged();
124 void sourceErrorChanged();
125 void nameChanged();
126 void validityChanged();
127
129 void positionUpdateReceived(const QGeoPositionInfo &update);
130 void sourceErrorReceived(const QGeoPositionInfoSource::Error error);
131 void onParameterInitialized();
132 void notifySupportedPositioningMethodsChanged();
133
134private:
135 void setPosition(const QGeoPositionInfo &pi);
136 void setSource(QGeoPositionInfoSource *source);
137 bool parametersReady();
138 void tryAttach(const QString &name, bool useFallback = true);
139
140 static void parameter_append(QQmlListProperty<QDeclarativePluginParameter> *prop, QDeclarativePluginParameter *mapObject);
141 static qsizetype parameter_count(QQmlListProperty<QDeclarativePluginParameter> *prop);
143 static void parameter_clear(QQmlListProperty<QDeclarativePluginParameter> *prop);
144
145 bool isValidActualComputation() const;
146 PositioningMethods supportedMethodsActualComputation() const;
147
148 void executeStart();
149
150 QGeoPositionInfoSource *m_positionSource = nullptr;
151 PositioningMethods m_preferredPositioningMethods = AllPositioningMethods;
152 int m_updateInterval = 0;
153 QList<QDeclarativePluginParameter *> m_parameters;
154
157 &QDeclarativePositionSource::nameChanged)
158
160 &QDeclarativePositionSource::setActive,
162
164
166 NoError)
167
169 m_supportedPositioningMethods,
170 &QDeclarativePositionSource::supportedMethodsActualComputation)
171
173 &QDeclarativePositionSource::isValidActualComputation)
174
175 quint8 m_singleUpdate : 1;
176 quint8 m_regularUpdates : 1;
177 quint8 m_componentComplete : 1;
178 quint8 m_parametersInitialized : 1;
179 quint8 m_startRequested : 1;
180 quint8 m_defaultSourceUsed : 1;
181};
182
184
186
187#endif
static JNINativeMethod methods[]
bool m_active
bool isActive
\inmodule QtCore
Definition qproperty.h:811
void classBegin() override
Invoked after class creation, but before any properties have been set.
Q_REVISION(5, 14) Q_INVOKABLE bool setBackendProperty(const QString &name
QQmlListProperty< QDeclarativePluginParameter > parameters()
QDeclarativePosition * position()
\inmodule QtCore
Definition qfile.h:93
\inmodule QtPositioning
\inmodule QtPositioning
Definition qlist.h:75
\inmodule QtCore
Definition qobject.h:103
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
The QQmlParserStatus class provides updates on the QML parser state.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QTcpSocket class provides a TCP socket.
Definition qtcpsocket.h:18
\inmodule QtCore
Definition qvariant.h:65
employee setName("Richard Schmit")
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
n void setPosition(void) \n\
GLuint index
[2]
GLbitfield GLuint64 timeout
[4]
GLuint start
GLuint name
GLsizei GLsizei GLchar * source
#define Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(...)
Definition qproperty.h:1266
#define Q_OBJECT_COMPUTED_PROPERTY(Class, Type, name, ...)
Definition qproperty.h:1355
#define Q_OBJECT_BINDABLE_PROPERTY(...)
Definition qproperty.h:1239
#define Q_OBJECT_COMPAT_PROPERTY(...)
#define Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(...)
#define QML_DECLARE_TYPE(TYPE)
Definition qqml.h:19
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
@ NoError
Definition main.cpp:34
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_CLASSINFO(name, value)
#define Q_INVOKABLE
#define Q_FLAGS(x)
#define Q_INTERFACES(x)
#define Q_SLOTS
#define Q_ENUMS(x)
#define Q_SIGNALS
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned char quint8
Definition qtypes.h:46