From 6df11eb1581441e45d18728baf066aa5136042ae Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sun, 19 Aug 2012 19:18:40 +0200 Subject: testin compass watchlet --- qmapwatchlet/compassview.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 qmapwatchlet/compassview.h (limited to 'qmapwatchlet/compassview.h') 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 +#include +#include + +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 -- cgit v1.2.3