LocationSession.hpp Example File
locationdiagnostics/src/LocationSession.hpp
#ifndef LOCATIONSESSION_HPP
#define LOCATIONSESSION_HPP
#include <QDebug>
#include <QtLocationSubset/QGeoPositionInfo>
#include <QtLocationSubset/QGeoPositionInfoSource>
#include <QtLocationSubset/QGeoSatelliteInfo>
#include <QtLocationSubset/QGeoSatelliteInfoSource>
#include <bb/cascades/maps/MapView>
#include <QtCore/QObject>
#include <QtCore/QPointer>
using namespace QtMobilitySubset;
class LocationSession: public QObject
{
Q_OBJECT
Q_PROPERTY(QString method READ method NOTIFY dataChanged)
Q_PROPERTY(double latitude READ latitude NOTIFY dataChanged)
Q_PROPERTY(double longitude READ longitude NOTIFY dataChanged)
Q_PROPERTY(double altitude READ altitude NOTIFY dataChanged)
Q_PROPERTY(QString time READ time NOTIFY dataChanged)
Q_PROPERTY(QString direction READ direction NOTIFY dataChanged)
Q_PROPERTY(QString groundSpeed READ groundSpeed NOTIFY dataChanged)
Q_PROPERTY(QString verticalSpeed READ verticalSpeed NOTIFY dataChanged)
Q_PROPERTY(QString horizontalAccuracy READ horizontalAccuracy NOTIFY dataChanged)
Q_PROPERTY(QString verticalAccuracy READ verticalAccuracy NOTIFY dataChanged)
Q_PROPERTY(QString magneticVariation READ magneticVariation NOTIFY dataChanged)
Q_PROPERTY(QString horizontalDilution READ horizontalDilution NOTIFY dataChanged)
Q_PROPERTY(QString verticalDilution READ verticalDilution NOTIFY dataChanged)
Q_PROPERTY(QString positionDilution READ positionDilution NOTIFY dataChanged)
Q_PROPERTY(QString ttff READ ttff NOTIFY dataChanged)
Q_PROPERTY(QString gpsWeek READ gpsWeek NOTIFY dataChanged)
Q_PROPERTY(QString gpsTimeOfWeek READ gpsTimeOfWeek NOTIFY dataChanged)
Q_PROPERTY(bool isPropagated READ isPropagated NOTIFY dataChanged)
Q_PROPERTY(QString satellitesInUse READ satellitesInUse NOTIFY dataChanged)
Q_PROPERTY(QString satellitesInView READ satellitesInView NOTIFY dataChanged)
Q_PROPERTY(QString log READ log NOTIFY logChanged)
Q_PROPERTY(bb::cascades::maps::MapView* mapView READ mapView WRITE setMapView NOTIFY mapViewChanged)
public:
LocationSession(QObject* parent, bool satInfo);
void startUpdates();
void requestUpdate();
QGeoPositionInfoSource* positionSource() const;
void setSoundEnabled(bool enabled);
Q_INVOKABLE void stopUpdates();
Q_INVOKABLE void resetSession(const QString &type);
Q_SIGNALS:
void dataChanged();
void logChanged();
void mapViewChanged();
private Q_SLOTS:
void positionUpdated(const QGeoPositionInfo & pos);
void positionUpdateTimeout();
void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> & satellites);
void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> & satellites);
void onPinCreated(const QString& pinID);
private:
void parseRawData();
void log(const QString &msg, bool showInUi = true);
QString method() const;
double latitude() const;
double longitude() const;
double altitude() const;
QString time() const;
QString direction() const;
QString groundSpeed() const;
QString verticalSpeed() const;
QString horizontalAccuracy() const;
QString verticalAccuracy() const;
QString magneticVariation() const;
QString horizontalDilution() const;
QString verticalDilution() const;
QString positionDilution() const;
QString ttff() const;
QString gpsWeek() const;
QString gpsTimeOfWeek() const;
bool isPropagated() const;
QString satellitesInUse() const;
QString satellitesInView() const;
QString log() const;
bb::cascades::maps::MapView* mapView() const;
void setMapView(bb::cascades::maps::MapView *mapView);
bool m_soundEnabled;
QGeoPositionInfoSource *m_positionSource;
QGeoSatelliteInfoSource *m_satelliteSource;
QString m_method;
double m_latitude;
double m_longitude;
double m_altitude;
QString m_time;
QString m_direction;
QString m_groundSpeed;
QString m_verticalSpeed;
QString m_horizontalAccuracy;
QString m_verticalAccuracy;
QString m_magneticVariation;
QString m_horizontalDilution;
QString m_verticalDilution;
QString m_positionDilution;
QString m_ttff;
QString m_gpsWeek;
QString m_gpsTimeOfWeek;
bool m_isPropagated;
QString m_satellitesInUse;
QString m_satellitesInView;
QString m_log;
QPointer<bb::cascades::maps::MapView> m_mapView;
};
#endif