From a2191e7bb3d4e02f826ec7a3815a224b463ae115 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Wed, 30 Nov 2011 13:51:40 +0200 Subject: Add route and polyline map items * adds qdeclarativepolylinemapitem * adds qdeclarativeroutemapitem Change-Id: I055aa36aec8321aa7036c7af20b6a549fbf287d1 Reviewed-by: Juha Vuolle --- .../location/qdeclarativepolylinemapitem_p.h | 152 +++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 src/imports/location/qdeclarativepolylinemapitem_p.h (limited to 'src/imports/location/qdeclarativepolylinemapitem_p.h') 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 +#include + +QT_BEGIN_NAMESPACE + +class PolylineMapPaintedItem; +class QDeclarativeGeoMapQuickItem; + +class QDeclarativePolylineMapItem : public QDeclarativeGeoMapItemBase +{ + Q_OBJECT + + Q_PROPERTY(QDeclarativeListProperty 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 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 *prop, QDeclarativeCoordinate *coordinate); + static int path_count(QDeclarativeListProperty *prop); + static QDeclarativeCoordinate* path_at(QDeclarativeListProperty *prop, int index); + static void path_clear(QDeclarativeListProperty *prop); + void pathPropertyChanged(); + +private: + QDeclarativeGeoMapQuickItem *quickItem_; + PolylineMapPaintedItem *polylineMapPaintedItem_; + QList 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 path() const; + void setPath(const QList& 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 coordPath_; + QPainterPath path_; + bool initialized_; +}; + + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativePolylineMapItem)); + +#endif /* QDECLARATIVEPOLYLINEMAPITEM_H_ */ -- cgit v1.2.1