summaryrefslogtreecommitdiff
path: root/qmapwatchlet/mapview.h
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-17 04:57:27 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-17 04:57:27 +0200
commit659c53b0d8faf26e6f06334833b2e105a4c4193d (patch)
tree8dced84e65f3c662622159acb6ab096bfc005976 /qmapwatchlet/mapview.h
parenta2059b5cfaa600402dfbec5d63099fd724998e9f (diff)
downloadsowatch-659c53b0d8faf26e6f06334833b2e105a4c4193d.tar.gz
sowatch-659c53b0d8faf26e6f06334833b2e105a4c4193d.zip
trying to make the map watchlet more useful
Diffstat (limited to 'qmapwatchlet/mapview.h')
-rw-r--r--qmapwatchlet/mapview.h57
1 files changed, 57 insertions, 0 deletions
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 <QtDeclarative/QDeclarativeItem>
+#include <QtLocation/QGeoMappingManager>
+#include <QtLocation/QGeoPositionInfoSource>
+
+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