diff options
Diffstat (limited to 'qmapwatchlet/compassview.h')
-rw-r--r-- | qmapwatchlet/compassview.h | 56 |
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 |