summaryrefslogtreecommitdiff
path: root/qmapwatchlet/mapview.h
blob: f3e457f552f8298bb594f4a94ff38f744bf5aab2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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