diff options
author | Michal Klocek <michal.klocek@digia.com> | 2011-11-30 13:51:40 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-02 08:18:34 +0100 |
commit | a2191e7bb3d4e02f826ec7a3815a224b463ae115 (patch) | |
tree | d4bdf715bcc00001b5d423284afcccb9a5b853fc /src/imports/location/qdeclarativepolylinemapitem_p.h | |
parent | 94df6200b711576019cb961a44ed9b5e9b6c39ae (diff) | |
download | qtlocation-a2191e7bb3d4e02f826ec7a3815a224b463ae115.tar.gz |
Add route and polyline map items
* adds qdeclarativepolylinemapitem
* adds qdeclarativeroutemapitem
Change-Id: I055aa36aec8321aa7036c7af20b6a549fbf287d1
Reviewed-by: Juha Vuolle <juha.vuolle@nokia.com>
Diffstat (limited to 'src/imports/location/qdeclarativepolylinemapitem_p.h')
-rw-r--r-- | src/imports/location/qdeclarativepolylinemapitem_p.h | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/src/imports/location/qdeclarativepolylinemapitem_p.h b/src/imports/location/qdeclarativepolylinemapitem_p.h new file mode 100644 index 00000000..e1e4bd11 --- /dev/null +++ b/src/imports/location/qdeclarativepolylinemapitem_p.h @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEPOLYLINEMAPITEM +#define QDECLARATIVEPOLYLINEMAPITEM + +#include "qdeclarativegeomapitembase_p.h" +#include "qdeclarativecoordinate_p.h" +#include "qdeclarativegeomap_p.h" +#include <QPen> +#include <QBrush> + +QT_BEGIN_NAMESPACE + +class PolylineMapPaintedItem; +class QDeclarativeGeoMapQuickItem; + +class QDeclarativePolylineMapItem : public QDeclarativeGeoMapItemBase +{ + Q_OBJECT + + Q_PROPERTY(QDeclarativeListProperty<QDeclarativeCoordinate> path READ declarativePath NOTIFY pathChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + +public: + QDeclarativePolylineMapItem(QQuickItem *parent = 0); + ~QDeclarativePolylineMapItem(); + + virtual void componentComplete(); + + Q_INVOKABLE void addCoordinate(QDeclarativeCoordinate* coordinate); + Q_INVOKABLE void removeCoordinate(QDeclarativeCoordinate* coordinate); + + QDeclarativeListProperty<QDeclarativeCoordinate> declarativePath(); + + QColor color() const; + void setColor(const QColor &color); + +Q_SIGNALS: + void pathChanged(); + void colorChanged(const QColor &color); + + +protected Q_SLOTS: + void update(); + +private Q_SLOTS: + // map size changed + void handleCameraDataChanged(const CameraData& cameraData); + +private: + static void path_append(QDeclarativeListProperty<QDeclarativeCoordinate> *prop, QDeclarativeCoordinate *coordinate); + static int path_count(QDeclarativeListProperty<QDeclarativeCoordinate> *prop); + static QDeclarativeCoordinate* path_at(QDeclarativeListProperty<QDeclarativeCoordinate> *prop, int index); + static void path_clear(QDeclarativeListProperty<QDeclarativeCoordinate> *prop); + void pathPropertyChanged(); + +private: + QDeclarativeGeoMapQuickItem *quickItem_; + PolylineMapPaintedItem *polylineMapPaintedItem_; + QList<QDeclarativeCoordinate*> path_; + QColor color_; + bool initialized_; +}; + +////////////////////////////////////////////////////////////////////// + +class PolylineMapPaintedItem : public QQuickPaintedItem +{ + Q_OBJECT + +public: + PolylineMapPaintedItem(QQuickItem *parent = 0); + ~PolylineMapPaintedItem(); + + void setMap(Map* map); + + void setZoomLevel(qreal zoomLevel); + qreal zoomLevel() const; + + QList<QGeoCoordinate> path() const; + void setPath(const QList<QGeoCoordinate>& path); + + void paint(QPainter *painter); + + QPen pen() const; + void setPen(const QPen &pen); + + QBrush brush() const; + void setBrush(const QBrush &brush); + + QGeoCoordinate screenItemCoordinate() const; + QPointF screenItemAnchorPoint() const; + +private: + void updateGeometry(); + + Map *map_; + qreal zoomLevel_; + QGeoCoordinate quickItemCoordinate_; + QPointF quickItemAnchorPoint_; + QPen pen_; + QBrush brush_; + QList<QGeoCoordinate> coordPath_; + QPainterPath path_; + bool initialized_; +}; + + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativePolylineMapItem)); + +#endif /* QDECLARATIVEPOLYLINEMAPITEM_H_ */ |