LatitudeUpdater 0.1, fix the previous commit
[googlelatitude] / gpscontrol.h
diff --git a/gpscontrol.h b/gpscontrol.h
new file mode 100644 (file)
index 0000000..7a7f6f5
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef GPSCONTROL_H
+#define GPSCONTROL_H
+
+#include <QObject>
+#include <QtCore/QDebug>
+#include <QtCore/QSettings>
+#include <QtCore/QTimer>
+#include <QtLocation/QGeoPositionInfo>
+#include <QtLocation/QGeoPositionInfoSource>
+
+using namespace QtMobility;
+
+class GpsControl : public QObject {
+    Q_OBJECT
+public:
+    GpsControl(QObject *parent = 0);
+
+signals:
+    void gotUpdate();
+    void gotFix();
+
+public slots:
+    void setTimeOut(int sec);
+    int getTimeOut();
+    void setInterval(int sec);
+    int getInterval();
+    void setPositioningMethod(QString method);
+    QString getPositioningMethod() {return GpsSettings.value("gps_method").toString();}
+    void startUpdates();
+    void stopUpdates(bool force = false);
+    double getCurrentLatitude();
+    double getCurrentLongitude();
+    double getCurrentAccuracy();
+    unsigned int getCurrentTimestamp();
+
+private slots:
+    void setCurrentLocation(QGeoPositionInfo pos);
+    void onGotUpdate() { qDebug() << "* GpsControl::ongotUpdate"; }
+    void onGotFix() { qDebug() << "* GpsControl::ongotFix"; }
+
+private:
+    QSettings GpsSettings;
+    QGeoPositionInfoSource *GpsSource;
+    QGeoPositionInfo GpsPosition;
+    QTimer GpsTimeout;
+    QTimer GpsInterval;
+};
+
+#endif // GPSCONTROL_H