9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
66QDeclarativeSatelliteSource::QDeclarativeSatelliteSource()
67 : m_active(0), m_componentComplete(0), m_parametersInitialized(0),
68 m_startRequested(0), m_defaultSourceUsed(0), m_regularUpdates(0),
69 m_singleUpdate(0), m_singleUpdateRequested(0)
73QDeclarativeSatelliteSource::~QDeclarativeSatelliteSource()
76 m_source->disconnect(
this);
80
81
82
83
84
85
86
87
88bool QDeclarativeSatelliteSource::isActive()
const
94
95
96
97
98
99
100
101
102
103
104bool QDeclarativeSatelliteSource::isValid()
const
106 return m_source !=
nullptr;
110
111
112
113
114int QDeclarativeSatelliteSource::updateInterval()
const
116 return m_source ? m_source->updateInterval() : m_updateInterval;
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141QDeclarativeSatelliteSource::SourceError QDeclarativeSatelliteSource::sourceError()
const
147
148
149
150
151
152
153
154
155
156
157
158
159
160QString QDeclarativeSatelliteSource::name()
const
162 return m_source ? m_source->sourceName() : m_name;
166
167
168
169
170
171
172
173
174QQmlListProperty<QDeclarativePluginParameter> QDeclarativeSatelliteSource::parameters()
176 return QQmlListProperty<QDeclarativePluginParameter>(
this,
nullptr,
184
185
186
187
188
189
190
191QList<QGeoSatelliteInfo> QDeclarativeSatelliteSource::satellitesInUse()
const
193 return m_satellitesInUse;
197
198
199
200
201
202QList<QGeoSatelliteInfo> QDeclarativeSatelliteSource::satellitesInView()
const
204 return m_satellitesInView;
207void QDeclarativeSatelliteSource::setUpdateInterval(
int updateInterval)
209 if (m_updateInterval == updateInterval)
212 const auto oldInterval = m_updateInterval;
215 m_source->setUpdateInterval(updateInterval);
219 m_updateInterval = m_source->updateInterval();
221 m_updateInterval = updateInterval;
223 if (oldInterval != m_updateInterval)
224 emit updateIntervalChanged();
227void QDeclarativeSatelliteSource::setActive(
bool active)
229 if (active == m_active)
238void QDeclarativeSatelliteSource::setName(
const QString &name)
240 if ((m_name == name) || (name.isEmpty() && m_defaultSourceUsed))
243 if (m_componentComplete && m_parametersInitialized) {
251void QDeclarativeSatelliteSource::componentComplete()
253 m_componentComplete =
true;
254 m_parametersInitialized =
true;
255 for (QDeclarativePluginParameter *p: std::as_const(m_parameters)) {
256 if (!p->isInitialized()) {
257 m_parametersInitialized =
false;
258 connect(p, &QDeclarativePluginParameter::initialized,
259 this, &QDeclarativeSatelliteSource::onParameterInitialized,
260 Qt::SingleShotConnection);
264 if (m_parametersInitialized)
265 createSource(m_name);
269
270
271
272
273
274
275bool QDeclarativeSatelliteSource::setBackendProperty(
const QString &name,
const QVariant &value)
278 return m_source->setBackendProperty(name, value);
283
284
285
286
287
288
289QVariant QDeclarativeSatelliteSource::backendProperty(
const QString &name)
const
291 return m_source ? m_source->backendProperty(name) : QVariant{};
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310void QDeclarativeSatelliteSource::update(
int timeout)
312 if (m_componentComplete && m_parametersInitialized) {
313 executeSingleUpdate(timeout);
315 m_singleUpdateDesiredTimeout = timeout;
316 m_singleUpdateRequested =
true;
321
322
323
324
325
326
327
328
329void QDeclarativeSatelliteSource::start()
331 if (m_componentComplete && m_parametersInitialized)
334 m_startRequested =
true;
338
339
340
341
342
343
344
345void QDeclarativeSatelliteSource::stop()
348 m_source->stopUpdates();
349 m_regularUpdates =
false;
351 if (m_active && !m_singleUpdate) {
353 emit activeChanged();
356 m_startRequested =
false;
360void QDeclarativeSatelliteSource::sourceErrorReceived(
const QGeoSatelliteInfoSource::Error error)
362 const auto oldError = m_error;
363 m_error =
static_cast<SourceError>(error);
364 if (m_error != oldError)
365 emit sourceErrorChanged();
369 if (m_singleUpdate) {
370 m_singleUpdate =
false;
371 if (m_active && !m_regularUpdates) {
373 emit activeChanged();
378void QDeclarativeSatelliteSource::onParameterInitialized()
380 m_parametersInitialized =
true;
381 for (QDeclarativePluginParameter *p: std::as_const(m_parameters)) {
382 if (!p->isInitialized()) {
383 m_parametersInitialized =
false;
389 if (m_parametersInitialized)
390 createSource(m_name);
393void QDeclarativeSatelliteSource::satellitesInViewUpdateReceived(
const QList<QGeoSatelliteInfo> &satellites)
395 m_satellitesInView = satellites;
396 emit satellitesInViewChanged();
397 handleSingleUpdateReceived();
400void QDeclarativeSatelliteSource::satellitesInUseUpdateReceived(
const QList<QGeoSatelliteInfo> &satellites)
402 m_satellitesInUse = satellites;
403 emit satellitesInUseChanged();
404 handleSingleUpdateReceived();
407QVariantMap QDeclarativeSatelliteSource::parameterMap()
const
410 for (
const auto *parameter : std::as_const(m_parameters))
411 map.insert(parameter->name(), parameter->value());
415void QDeclarativeSatelliteSource::createSource(
const QString &newName)
417 if (m_source && m_source->sourceName() == newName)
420 const auto oldName = name();
421 const bool oldIsValid = isValid();
422 const bool oldActive = isActive();
423 const auto oldUpdateInterval = updateInterval();
426 m_source->disconnect(
this);
427 m_source->stopUpdates();
428 m_source.reset(
nullptr);
432 if (!newName.isEmpty()) {
433 m_source.reset(QGeoSatelliteInfoSource::createSource(newName, parameterMap(),
nullptr));
434 m_defaultSourceUsed =
false;
436 m_source.reset(QGeoSatelliteInfoSource::createDefaultSource(parameterMap(),
nullptr));
437 m_defaultSourceUsed =
true;
441 connect(m_source.get(), &QGeoSatelliteInfoSource::errorOccurred,
442 this, &QDeclarativeSatelliteSource::sourceErrorReceived);
443 connect(m_source.get(), &QGeoSatelliteInfoSource::satellitesInViewUpdated,
444 this, &QDeclarativeSatelliteSource::satellitesInViewUpdateReceived);
445 connect(m_source.get(), &QGeoSatelliteInfoSource::satellitesInUseUpdated,
446 this, &QDeclarativeSatelliteSource::satellitesInUseUpdateReceived);
448 m_name = m_source->sourceName();
449 m_source->setUpdateInterval(m_updateInterval);
450 m_updateInterval = m_source->updateInterval();
453 m_defaultSourceUsed =
false;
456 if (oldName != name())
459 if (oldIsValid != isValid())
460 emit validityChanged();
462 if (oldActive != isActive())
463 emit activeChanged();
465 if (oldUpdateInterval != updateInterval())
466 emit updateIntervalChanged();
468 if (m_startRequested) {
469 m_startRequested =
false;
472 if (m_singleUpdateRequested) {
473 m_singleUpdateRequested =
false;
474 executeSingleUpdate(m_singleUpdateDesiredTimeout);
478void QDeclarativeSatelliteSource::handleSingleUpdateReceived()
480 if (m_singleUpdate) {
481 m_singleUpdate =
false;
482 if (m_active && !m_regularUpdates) {
484 emit activeChanged();
489void QDeclarativeSatelliteSource::executeStart()
492 m_regularUpdates =
true;
495 emit activeChanged();
497 m_source->startUpdates();
501void QDeclarativeSatelliteSource::executeSingleUpdate(
int timeout)
504 m_singleUpdate =
true;
507 emit activeChanged();
509 m_source->requestUpdate(timeout);
513void QDeclarativeSatelliteSource::parameter_append(PluginParameterProperty *prop,
514 QDeclarativePluginParameter *parameter)
516 auto *src =
static_cast<QDeclarativeSatelliteSource *>(prop->object);
517 src->m_parameters.append(parameter);
520qsizetype QDeclarativeSatelliteSource::parameter_count(PluginParameterProperty *prop)
522 return static_cast<QDeclarativeSatelliteSource *>(prop->object)->m_parameters.size();
525QDeclarativePluginParameter *
526QDeclarativeSatelliteSource::parameter_at(PluginParameterProperty *prop, qsizetype index)
528 return static_cast<QDeclarativeSatelliteSource *>(prop->object)->m_parameters[index];
531void QDeclarativeSatelliteSource::parameter_clear(PluginParameterProperty *prop)
533 auto *src =
static_cast<QDeclarativeSatelliteSource *>(prop->object);
534 src->m_parameters.clear();
Combined button and popup list for selecting options.