summaryrefslogtreecommitdiff
path: root/qmapwatchlet/compassview.h
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-19 19:18:40 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-19 19:18:40 +0200
commit6df11eb1581441e45d18728baf066aa5136042ae (patch)
tree5672071de8a2ca680495b12f330bc8b3e093fbd4 /qmapwatchlet/compassview.h
parent26b8b909570bca66882c68f1c6f578f2aeef1e7e (diff)
downloadsowatch-6df11eb1581441e45d18728baf066aa5136042ae.tar.gz
sowatch-6df11eb1581441e45d18728baf066aa5136042ae.zip
testin compass watchlet
Diffstat (limited to 'qmapwatchlet/compassview.h')
-rw-r--r--qmapwatchlet/compassview.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/qmapwatchlet/compassview.h b/qmapwatchlet/compassview.h
new file mode 100644
index 0000000..3e87a65
--- /dev/null
+++ b/qmapwatchlet/compassview.h
@@ -0,0 +1,56 @@
+#ifndef COMPASSVIEW_H
+#define COMPASSVIEW_H
+
+#include <QtGui/QImage>
+#include <QtDeclarative/QDeclarativeItem>
+#include <QtLocation/QGeoPositionInfoSource>
+
+using QTM_PREPEND_NAMESPACE(QGeoPositionInfoSource);
+using QTM_PREPEND_NAMESPACE(QGeoPositionInfo);
+
+class CompassView : public QDeclarativeItem
+{
+ Q_OBJECT
+ Q_PROPERTY(bool updateEnabled READ updateEnabled WRITE setUpdateEnabled NOTIFY updateEnabledChanged)
+ Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval NOTIFY updateIntervalChanged)
+
+ Q_PROPERTY(qreal currentSpeed READ currentSpeed NOTIFY currentSpeedChanged)
+ Q_PROPERTY(qreal currentAltitude READ currentAltitude NOTIFY currentAltitudeChanged)
+
+public:
+ explicit CompassView(QDeclarativeItem *parent = 0);
+
+ bool updateEnabled() const;
+ void setUpdateEnabled(bool enabled);
+
+ int updateInterval() const;
+ void setUpdateInterval(int msec);
+
+ qreal currentSpeed() const;
+ qreal currentAltitude() const;
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+signals:
+ void updateEnabledChanged();
+ void updateIntervalChanged();
+ void currentSpeedChanged();
+ void currentAltitudeChanged();
+
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
+
+private slots:
+ void handlePositionUpdate(const QGeoPositionInfo& info);
+
+private:
+ bool _enabled;
+ QSize _size;
+ QImage _image;
+ QGeoPositionInfoSource *_posSource;
+ qreal _direction;
+ qreal _speed;
+ qreal _altitude;
+};
+
+#endif // COMPASSVIEW_H