Repository navigation
Expand file tree
/
Copy pathsatinfosource.cpp
More file actions
79 lines (67 loc) · 2.55 KB
/
Copy pathsatinfosource.cpp
File metadata and controls
79 lines (67 loc) · 2.55 KB
1
2
3
4
5
6
7
8
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
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "satinfosource.h"
#include <QDebug>
SatInfoSource::SatInfoSource(QObject *parent) :
QObject(parent),
myGeoSatelliteInfoSource(QGeoSatelliteInfoSource::createDefaultSource(this)),
_satsInUse(0),
_satsInView(0)
{
//myGeoSatelliteInfoSource = QGeoSatelliteInfoSource::createDefaultSource(0);
if (myGeoSatelliteInfoSource) {
qDebug() << "satellite info source available";
connect(myGeoSatelliteInfoSource, SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &)), this, SLOT(onSatsInViewUpdated(const QList<QGeoSatelliteInfo> &)));
connect(myGeoSatelliteInfoSource, SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &)), this, SLOT(onSatsInUseUpdated(const QList<QGeoSatelliteInfo> &)));
}
else {
qDebug() << "No satellite info source available";
}
}
SatInfoSource::~SatInfoSource()
{
}
void SatInfoSource::startUpdates() {
if (myGeoSatelliteInfoSource) {
myGeoSatelliteInfoSource->startUpdates();
}
else {
qDebug() << "Start Updates requested, but no satellite info source available";
}
}
void SatInfoSource::stopUpdates() {
if (myGeoSatelliteInfoSource) {
myGeoSatelliteInfoSource->stopUpdates();
}
else {
qDebug() << "Stop Updates requested, but no satellite info source available";
}
}
int SatInfoSource::satsInView() const
{
return _satsInView;
}
int SatInfoSource::satsInUse() const
{
return _satsInUse;
}
void SatInfoSource::onSatsInViewUpdated(const QList<QGeoSatelliteInfo> &list) {
int newInView = list.count();
if (newInView != _satsInView) {
qDebug() << "satInfoSource.cpp: onSatsinViewUpdated: " << QString::number(newInView, 'g', 2);
for (int i = 0; i < newInView; i++ ) {
qDebug() << "satsInView: id: " << list[i].satelliteIdentifier() << ", system: " << list[i].satelliteSystem() << ", strength: " + list[i].signalStrength();
}
_satsInView = newInView;
emit satellitesInViewChanged(newInView);
}
}
void SatInfoSource::onSatsInUseUpdated(const QList<QGeoSatelliteInfo> &list) {
int newInUse = list.count();
if (newInUse != _satsInUse) {
qDebug() << "satInfoSource.cpp: onSatsinUseUpdated: " << QString::number(newInUse, 'g', 2);
for (int i = 0; i < newInUse; i++ ) {
qDebug() << "satsInUse: id: " << list[i].satelliteIdentifier() << ", system: " << list[i].satelliteSystem() << ", strength: " + list[i].signalStrength();
}
_satsInUse = newInUse;
emit satellitesInUseChanged(newInUse);
}
}