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
qdeclarativesatellitesource_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// Qt-Security score:significant reason:default
4
5#ifndef QDECLARATIVESATELLITESOURCE_H
6#define QDECLARATIVESATELLITESOURCE_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/private/qproperty_p.h>
20#include <QtCore/QObject>
21
22#include <QtPositioning/qgeosatelliteinfosource.h>
23
24#include <QtPositioningQuick/private/qdeclarativepluginparameter_p.h>
25#include <QtPositioningQuick/private/qpositioningquickglobal_p.h>
26
27#include <QtQml/QQmlParserStatus>
28
30
31class Q_POSITIONINGQUICK_EXPORT QDeclarativeSatelliteSource : public QObject, public QQmlParserStatus
32{
33 Q_OBJECT
34 QML_NAMED_ELEMENT(SatelliteSource)
35 QML_ADDED_IN_VERSION(6, 5)
36
37 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
38 Q_PROPERTY(bool valid READ isValid NOTIFY validityChanged)
39 Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval
40 NOTIFY updateIntervalChanged)
41 Q_PROPERTY(SourceError sourceError READ sourceError NOTIFY sourceErrorChanged)
42 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
43 Q_PROPERTY(QQmlListProperty<QDeclarativePluginParameter> parameters READ parameters)
44 Q_PROPERTY(QList<QGeoSatelliteInfo> satellitesInUse READ satellitesInUse
45 NOTIFY satellitesInUseChanged)
46 Q_PROPERTY(QList<QGeoSatelliteInfo> satellitesInView READ satellitesInView
47 NOTIFY satellitesInViewChanged)
48
49 Q_CLASSINFO("DefaultProperty", "parameters")
50 Q_INTERFACES(QQmlParserStatus)
52public:
53 enum SourceError {
54 AccessError = QGeoSatelliteInfoSource::AccessError,
55 ClosedError = QGeoSatelliteInfoSource::ClosedError,
56 NoError = QGeoSatelliteInfoSource::NoError,
57 UnknownSourceError = QGeoSatelliteInfoSource::UnknownSourceError,
58 UpdateTimeoutError = QGeoSatelliteInfoSource::UpdateTimeoutError,
59 };
60 Q_ENUM(SourceError)
61
62 QDeclarativeSatelliteSource();
63 ~QDeclarativeSatelliteSource();
64
65 bool isActive() const;
66 bool isValid() const;
67 int updateInterval() const;
68 SourceError sourceError() const;
69 QString name() const;
70 QQmlListProperty<QDeclarativePluginParameter> parameters();
71 QList<QGeoSatelliteInfo> satellitesInUse() const;
72 QList<QGeoSatelliteInfo> satellitesInView() const;
73
74 void setUpdateInterval(int updateInterval);
75 void setActive(bool active);
76 void setName(const QString &name);
77
78 // virtuals from QQmlParserStatus
79 void classBegin() override { }
80 void componentComplete() override;
81
82 Q_INVOKABLE bool setBackendProperty(const QString &name, const QVariant &value);
83 Q_INVOKABLE QVariant backendProperty(const QString &name) const;
84
85public Q_SLOTS:
86 void update(int timeout = 0);
87 void start();
88 void stop();
90Q_SIGNALS:
91 void activeChanged();
92 void validityChanged();
93 void updateIntervalChanged();
94 void sourceErrorChanged();
95 void nameChanged();
96 void satellitesInUseChanged();
97 void satellitesInViewChanged();
98
99private Q_SLOTS:
100 void sourceErrorReceived(const QGeoSatelliteInfoSource::Error error);
101 void onParameterInitialized();
102 void satellitesInViewUpdateReceived(const QList<QGeoSatelliteInfo> &satellites);
103 void satellitesInUseUpdateReceived(const QList<QGeoSatelliteInfo> &satellites);
104
105private:
106 QVariantMap parameterMap() const;
107 void createSource(const QString &newName);
108 void handleSingleUpdateReceived();
109 void executeStart();
110 void executeSingleUpdate(int timeout);
111
112 using PluginParameterProperty = QQmlListProperty<QDeclarativePluginParameter>;
113 static void parameter_append(PluginParameterProperty *prop,
114 QDeclarativePluginParameter *parameter);
115 static qsizetype parameter_count(PluginParameterProperty *prop);
116 static QDeclarativePluginParameter *parameter_at(PluginParameterProperty *prop,
117 qsizetype index);
118 static void parameter_clear(PluginParameterProperty *prop);
119
120 std::unique_ptr<QGeoSatelliteInfoSource> m_source;
121 QList<QDeclarativePluginParameter *> m_parameters;
122
123 int m_updateInterval = 0;
124 SourceError m_error = SourceError::NoError;
125 QString m_name;
126 QList<QGeoSatelliteInfo> m_satellitesInView;
127 QList<QGeoSatelliteInfo> m_satellitesInUse;
128
129 int m_singleUpdateDesiredTimeout = 0;
130
131 quint8 m_active : 1;
132 quint8 m_componentComplete : 1;
133 quint8 m_parametersInitialized : 1;
134 quint8 m_startRequested : 1;
135 quint8 m_defaultSourceUsed : 1;
136 quint8 m_regularUpdates : 1;
137 quint8 m_singleUpdate : 1;
138 quint8 m_singleUpdateRequested : 1;
139};
140
141QT_END_NAMESPACE
142
143#endif // QDECLARATIVESATELLITESOURCE_H
Combined button and popup list for selecting options.