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
65
67QDeclarativeSatelliteSource::QDeclarativeSatelliteSource()
68 : m_active(0), m_componentComplete(0), m_parametersInitialized(0),
69 m_startRequested(0), m_defaultSourceUsed(0), m_regularUpdates(0),
70 m_singleUpdate(0), m_singleUpdateRequested(0)
74QDeclarativeSatelliteSource::~QDeclarativeSatelliteSource()
77 m_source->disconnect(
this);
81
82
83
84
85
86
87
88
89bool QDeclarativeSatelliteSource::isActive()
const
95
96
97
98
99
100
101
102
103
104
105bool QDeclarativeSatelliteSource::isValid()
const
107 return m_source !=
nullptr;
111
112
113
114
115int QDeclarativeSatelliteSource::updateInterval()
const
117 return m_source ? m_source->updateInterval() : m_updateInterval;
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142QDeclarativeSatelliteSource::SourceError QDeclarativeSatelliteSource::sourceError()
const
148
149
150
151
152
153
154
155
156
157
158
159
160
161QString QDeclarativeSatelliteSource::name()
const
163 return m_source ? m_source->sourceName() : m_name;
167
168
169
170
171
172
173
174
175QQmlListProperty<QDeclarativePluginParameter> QDeclarativeSatelliteSource::parameters()
177 return QQmlListProperty<QDeclarativePluginParameter>(
this,
nullptr,
185
186
187
188
189
190
191
192QList<QGeoSatelliteInfo> QDeclarativeSatelliteSource::satellitesInUse()
const
194 return m_satellitesInUse;
198
199
200
201
202
203QList<QGeoSatelliteInfo> QDeclarativeSatelliteSource::satellitesInView()
const
205 return m_satellitesInView;
208void QDeclarativeSatelliteSource::setUpdateInterval(
int updateInterval)
210 if (m_updateInterval == updateInterval)
213 const auto oldInterval = m_updateInterval;
216 m_source->setUpdateInterval(updateInterval);
220 m_updateInterval = m_source->updateInterval();
222 m_updateInterval = updateInterval;
224 if (oldInterval != m_updateInterval)
225 emit updateIntervalChanged();
228void QDeclarativeSatelliteSource::setActive(
bool active)
230 if (active == m_active)
239void QDeclarativeSatelliteSource::setName(
const QString &name)
241 if ((m_name == name) || (name.isEmpty() && m_defaultSourceUsed))
244 if (m_componentComplete && m_parametersInitialized) {
252void QDeclarativeSatelliteSource::componentComplete()
254 m_componentComplete =
true;
255 m_parametersInitialized =
true;
256 for (QDeclarativePluginParameter *p: std::as_const(m_parameters)) {
257 if (!p->isInitialized()) {
258 m_parametersInitialized =
false;
259 connect(p, &QDeclarativePluginParameter::initialized,
260 this, &QDeclarativeSatelliteSource::onParameterInitialized,
261 Qt::SingleShotConnection);
265 if (m_parametersInitialized)
266 createSource(m_name);
270
271
272
273
274
275
276bool QDeclarativeSatelliteSource::setBackendProperty(
const QString &name,
const QVariant &value)
279 return m_source->setBackendProperty(name, value);
284
285
286
287
288
289
290QVariant QDeclarativeSatelliteSource::backendProperty(
const QString &name)
const
292 return m_source ? m_source->backendProperty(name) : QVariant{};
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311void QDeclarativeSatelliteSource::update(
int timeout)
313 if (m_componentComplete && m_parametersInitialized) {
314 executeSingleUpdate(timeout);
316 m_singleUpdateDesiredTimeout = timeout;
317 m_singleUpdateRequested =
true;
322
323
324
325
326
327
328
329
330void QDeclarativeSatelliteSource::start()
332 if (m_componentComplete && m_parametersInitialized)
335 m_startRequested =
true;
339
340
341
342
343
344
345
346void QDeclarativeSatelliteSource::stop()
349 m_source->stopUpdates();
350 m_regularUpdates =
false;
352 if (m_active && !m_singleUpdate) {
354 emit activeChanged();
357 m_startRequested =
false;
361void QDeclarativeSatelliteSource::sourceErrorReceived(
const QGeoSatelliteInfoSource::Error error)
363 const auto oldError = m_error;
364 m_error =
static_cast<SourceError>(error);
365 if (m_error != oldError)
366 emit sourceErrorChanged();
370 if (m_singleUpdate) {
371 m_singleUpdate =
false;
372 if (m_active && !m_regularUpdates) {
374 emit activeChanged();
379void QDeclarativeSatelliteSource::onParameterInitialized()
381 m_parametersInitialized =
true;
382 for (QDeclarativePluginParameter *p: std::as_const(m_parameters)) {
383 if (!p->isInitialized()) {
384 m_parametersInitialized =
false;
390 if (m_parametersInitialized)
391 createSource(m_name);
394void QDeclarativeSatelliteSource::satellitesInViewUpdateReceived(
const QList<QGeoSatelliteInfo> &satellites)
396 m_satellitesInView = satellites;
397 emit satellitesInViewChanged();
398 handleSingleUpdateReceived();
401void QDeclarativeSatelliteSource::satellitesInUseUpdateReceived(
const QList<QGeoSatelliteInfo> &satellites)
403 m_satellitesInUse = satellites;
404 emit satellitesInUseChanged();
405 handleSingleUpdateReceived();
408QVariantMap QDeclarativeSatelliteSource::parameterMap()
const
411 for (
const auto *parameter : std::as_const(m_parameters))
412 map.insert(parameter->name(), parameter->value());
416void QDeclarativeSatelliteSource::createSource(
const QString &newName)
418 if (m_source && m_source->sourceName() == newName)
421 const auto oldName = name();
422 const bool oldIsValid = isValid();
423 const bool oldActive = isActive();
424 const auto oldUpdateInterval = updateInterval();
427 m_source->disconnect(
this);
428 m_source->stopUpdates();
429 m_source.reset(
nullptr);
433 if (!newName.isEmpty()) {
434 m_source.reset(QGeoSatelliteInfoSource::createSource(newName, parameterMap(),
nullptr));
435 m_defaultSourceUsed =
false;
437 m_source.reset(QGeoSatelliteInfoSource::createDefaultSource(parameterMap(),
nullptr));
438 m_defaultSourceUsed =
true;
442 connect(m_source.get(), &QGeoSatelliteInfoSource::errorOccurred,
443 this, &QDeclarativeSatelliteSource::sourceErrorReceived);
444 connect(m_source.get(), &QGeoSatelliteInfoSource::satellitesInViewUpdated,
445 this, &QDeclarativeSatelliteSource::satellitesInViewUpdateReceived);
446 connect(m_source.get(), &QGeoSatelliteInfoSource::satellitesInUseUpdated,
447 this, &QDeclarativeSatelliteSource::satellitesInUseUpdateReceived);
449 m_name = m_source->sourceName();
450 m_source->setUpdateInterval(m_updateInterval);
451 m_updateInterval = m_source->updateInterval();
454 m_defaultSourceUsed =
false;
457 if (oldName != name())
460 if (oldIsValid != isValid())
461 emit validityChanged();
463 if (oldActive != isActive())
464 emit activeChanged();
466 if (oldUpdateInterval != updateInterval())
467 emit updateIntervalChanged();
469 if (m_startRequested) {
470 m_startRequested =
false;
473 if (m_singleUpdateRequested) {
474 m_singleUpdateRequested =
false;
475 executeSingleUpdate(m_singleUpdateDesiredTimeout);
479void QDeclarativeSatelliteSource::handleSingleUpdateReceived()
481 if (m_singleUpdate) {
482 m_singleUpdate =
false;
483 if (m_active && !m_regularUpdates) {
485 emit activeChanged();
490void QDeclarativeSatelliteSource::executeStart()
493 m_regularUpdates =
true;
496 emit activeChanged();
498 m_source->startUpdates();
502void QDeclarativeSatelliteSource::executeSingleUpdate(
int timeout)
505 m_singleUpdate =
true;
508 emit activeChanged();
510 m_source->requestUpdate(timeout);
514void QDeclarativeSatelliteSource::parameter_append(PluginParameterProperty *prop,
515 QDeclarativePluginParameter *parameter)
517 auto *src =
static_cast<QDeclarativeSatelliteSource *>(prop->object);
518 src->m_parameters.append(parameter);
521qsizetype QDeclarativeSatelliteSource::parameter_count(PluginParameterProperty *prop)
523 return static_cast<QDeclarativeSatelliteSource *>(prop->object)->m_parameters.size();
526QDeclarativePluginParameter *
527QDeclarativeSatelliteSource::parameter_at(PluginParameterProperty *prop, qsizetype index)
529 return static_cast<QDeclarativeSatelliteSource *>(prop->object)->m_parameters[index];
532void QDeclarativeSatelliteSource::parameter_clear(PluginParameterProperty *prop)
534 auto *src =
static_cast<QDeclarativeSatelliteSource *>(prop->object);
535 src->m_parameters.clear();
Combined button and popup list for selecting options.