From 659c53b0d8faf26e6f06334833b2e105a4c4193d Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Fri, 17 Aug 2012 04:57:27 +0200 Subject: trying to make the map watchlet more useful --- qmapwatchlet/mapview.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 qmapwatchlet/mapview.h (limited to 'qmapwatchlet/mapview.h') diff --git a/qmapwatchlet/mapview.h b/qmapwatchlet/mapview.h new file mode 100644 index 0000000..f3e457f --- /dev/null +++ b/qmapwatchlet/mapview.h @@ -0,0 +1,57 @@ +#ifndef MAPVIEW_H +#define MAPVIEW_H + +#include +#include +#include + +namespace sowatch +{ + +using QTM_PREPEND_NAMESPACE(QGeoPositionInfo); +using QTM_PREPEND_NAMESPACE(QGeoMapData); +using QTM_PREPEND_NAMESPACE(QGeoPositionInfoSource); + +class MapView : 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 zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged) + +public: + explicit MapView(QDeclarativeItem *parent = 0); + ~MapView(); + + bool updateEnabled() const; + void setUpdateEnabled(bool enabled); + + int updateInterval() const; + void setUpdateInterval(int msec); + + qreal zoomLevel() const; + void setZoomLevel(qreal level); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +signals: + void updateEnabledChanged(); + void updateIntervalChanged(); + void zoomLevelChanged(); + +protected: + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); + +private slots: + void handlePositionUpdate(const QGeoPositionInfo& info); + void handleMapChanged(const QRectF& rect); + +private: + bool _enabled; + QGeoMapData *_mapData; + QGeoPositionInfoSource *_pos; +}; + +} + +#endif // MAPVIEW_H -- cgit v1.2.3