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 | |
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')
-rw-r--r-- | src/imports/location/location.cpp | 4 | ||||
-rw-r--r-- | src/imports/location/location.pro | 8 | ||||
-rw-r--r-- | src/imports/location/qdeclarativegeoroute_p.h | 2 | ||||
-rw-r--r-- | src/imports/location/qdeclarativepolylinemapitem.cpp | 329 | ||||
-rw-r--r-- | src/imports/location/qdeclarativepolylinemapitem_p.h | 152 | ||||
-rw-r--r-- | src/imports/location/qdeclarativeroutemapitem.cpp | 120 | ||||
-rw-r--r-- | src/imports/location/qdeclarativeroutemapitem_p.h | 98 |
7 files changed, 710 insertions, 3 deletions
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp index 046f5ae2..e7f8e3ff 100644 --- a/src/imports/location/location.cpp +++ b/src/imports/location/location.cpp @@ -65,6 +65,8 @@ #include "qdeclarativegeomaptype_p.h" #include "qdeclarativerectanglemapitem_p.h" #include "qdeclarativecirclemapitem_p.h" +#include "qdeclarativeroutemapitem_p.h" +#include "qdeclarativepolylinemapitem_p.h" //Place includes #include "qdeclarativecategory_p.h" @@ -143,6 +145,8 @@ public: qmlRegisterType<QDeclarativePlaceUser>(uri, 5, 0, "User"); qmlRegisterType<QDeclarativeRectangleMapItem>(uri, 5, 0, "MapRectangle"); qmlRegisterType<QDeclarativeCircleMapItem>(uri, 5, 0, "MapCircle"); + qmlRegisterType<QDeclarativePolylineMapItem>(uri, 5, 0, "MapPolyline"); + qmlRegisterType<QDeclarativeRouteMapItem>(uri, 5, 0, "MapRoute"); qmlRegisterType<QDeclarativeRecommendationModel>(uri, 5, 0, "PlaceRecommendationModel"); qmlRegisterType<QDeclarativeSupportedCategoriesModel>(uri, 5, 0, "CategoryModel"); diff --git a/src/imports/location/location.pro b/src/imports/location/location.pro index d07ae983..abb103be 100644 --- a/src/imports/location/location.pro +++ b/src/imports/location/location.pro @@ -40,7 +40,9 @@ HEADERS += qdeclarativeposition_p.h \ qdeclarativegeomapquickitem_p.h \ mapnode_p.h \ qdeclarativecirclemapitem_p.h \ - qdeclarativerectanglemapitem_p.h + qdeclarativerectanglemapitem_p.h \ + qdeclarativepolylinemapitem_p.h \ + qdeclarativeroutemapitem_p.h SOURCES += qdeclarativeposition.cpp \ location.cpp \ @@ -68,7 +70,9 @@ SOURCES += qdeclarativeposition.cpp \ qdeclarativegeomapquickitem.cpp \ mapnode.cpp \ qdeclarativecirclemapitem.cpp \ - qdeclarativerectanglemapitem.cpp + qdeclarativerectanglemapitem.cpp \ + qdeclarativepolylinemapitem.cpp \ + qdeclarativeroutemapitem.cpp include(declarativeplaces/declarativeplaces.pri) diff --git a/src/imports/location/qdeclarativegeoroute_p.h b/src/imports/location/qdeclarativegeoroute_p.h index defc8154..bd418313 100644 --- a/src/imports/location/qdeclarativegeoroute_p.h +++ b/src/imports/location/qdeclarativegeoroute_p.h @@ -90,7 +90,7 @@ private: QDeclarativeGeoBoundingBox* bounds_; QList<QDeclarativeCoordinate*> path_; QList<QDeclarativeGeoRouteSegment*> segments_; - friend class QDeclarativeGeoMapRouteObject; + friend class QDeclarativeRouteMapItem; }; QT_END_NAMESPACE diff --git a/src/imports/location/qdeclarativepolylinemapitem.cpp b/src/imports/location/qdeclarativepolylinemapitem.cpp new file mode 100644 index 00000000..efdbadc4 --- /dev/null +++ b/src/imports/location/qdeclarativepolylinemapitem.cpp @@ -0,0 +1,329 @@ +/**************************************************************************** + ** + ** 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$ + ** + ****************************************************************************/ + +#include "qdeclarativepolylinemapitem_p.h" +#include "qdeclarativegeomapquickitem_p.h" +#include <QDeclarativeInfo> +#include <QPainter> + +static QPainterPath createPath(const Map& map, const QList<QGeoCoordinate> &path, qreal& w, + qreal& h) +{ + QPainterPath painter; + + qreal minX, maxX, minY, maxY; + //TODO: dateline handling + + for (int i = 0; i < path.size(); ++i) { + + const QGeoCoordinate &coord = path.at(i); + + if (!coord.isValid()) + continue; + + QPointF point = map.coordinateToScreenPosition(coord, false); + + if (i == 0) { + minX = point.x(); + maxX = point.x(); + minY = point.y(); + maxY = point.y(); + painter.moveTo(point); + } else { + minX = qMin(point.x(), minX); + maxX = qMax(point.x(), maxX); + minY = qMin(point.y(), minY); + maxY = qMax(point.y(), maxY); + painter.lineTo(point); + } + + } + + painter.translate(-minX, -minY); + + w = maxX - minX; + h = maxY - minY; + + return painter; +} + +QDeclarativePolylineMapItem::QDeclarativePolylineMapItem(QQuickItem *parent) : + QDeclarativeGeoMapItemBase(parent), quickItem_(new QDeclarativeGeoMapQuickItem(this)), polylineMapPaintedItem_( + new PolylineMapPaintedItem(quickItem_)), initialized_(false) +{ +} + +QDeclarativePolylineMapItem::~QDeclarativePolylineMapItem() +{ +} + +void QDeclarativePolylineMapItem::componentComplete() +{ + initialized_ = true; +} + +QDeclarativeListProperty<QDeclarativeCoordinate> QDeclarativePolylineMapItem::declarativePath() +{ + return QDeclarativeListProperty<QDeclarativeCoordinate>(this, 0, path_append, path_count, + path_at, path_clear); +} + +void QDeclarativePolylineMapItem::path_append( + QDeclarativeListProperty<QDeclarativeCoordinate> *property, QDeclarativeCoordinate *coordinate) +{ + QDeclarativePolylineMapItem* item = qobject_cast<QDeclarativePolylineMapItem*>( + property->object); + item->path_.append(coordinate); + QList<QGeoCoordinate> p = item->polylineMapPaintedItem_->path(); + p.append(coordinate->coordinate()); + item->polylineMapPaintedItem_->setPath(p); + if (item->initialized_) + emit item->pathChanged(); +} + +int QDeclarativePolylineMapItem::path_count( + QDeclarativeListProperty<QDeclarativeCoordinate> *property) +{ + return qobject_cast<QDeclarativePolylineMapItem*>(property->object)->path_.count(); +} + +QDeclarativeCoordinate* QDeclarativePolylineMapItem::path_at( + QDeclarativeListProperty<QDeclarativeCoordinate> *property, int index) +{ + return qobject_cast<QDeclarativePolylineMapItem*>(property->object)->path_.at(index); +} + +void QDeclarativePolylineMapItem::path_clear( + QDeclarativeListProperty<QDeclarativeCoordinate> *property) +{ + QDeclarativePolylineMapItem* item = qobject_cast<QDeclarativePolylineMapItem*>( + property->object); + qDeleteAll(item->path_); + item->path_.clear(); + item->polylineMapPaintedItem_->setPath(QList<QGeoCoordinate>()); + if (item->initialized_) + emit item->pathChanged(); +} + +void QDeclarativePolylineMapItem::addCoordinate(QDeclarativeCoordinate* coordinate) +{ + path_.append(coordinate); + QList<QGeoCoordinate> path = polylineMapPaintedItem_->path(); + path.append(coordinate->coordinate()); + polylineMapPaintedItem_->setPath(path); + emit pathChanged(); +} + +void QDeclarativePolylineMapItem::removeCoordinate(QDeclarativeCoordinate* coordinate) +{ + int index = path_.lastIndexOf(coordinate); + + if (index == -1) { + qmlInfo(this) << tr("Coordinate does not belong to PolylineMapItem."); + return; + } + + QList<QGeoCoordinate> path = polylineMapPaintedItem_->path(); + + if (path.count() < index + 1) { + qmlInfo(this) << tr("Coordinate does not belong to PolylineMapItem."); + return; + } + path.removeAt(index); + polylineMapPaintedItem_->setPath(path); + path_.removeAt(index); + emit pathChanged(); +} + +void QDeclarativePolylineMapItem::update() +{ + if (!map()) + return; + + quickItem_->setCoordinate( + new QDeclarativeCoordinate(polylineMapPaintedItem_->screenItemCoordinate())); + quickItem_->setAnchorPoint(polylineMapPaintedItem_->screenItemAnchorPoint()); + + if (quickItem_->sourceItem() == 0) { + QObject::connect(map(), SIGNAL(cameraDataChanged(CameraData)), this, + SLOT(handleCameraDataChanged(CameraData))); + polylineMapPaintedItem_->setMap(map()); + quickItem_->setMap(quickMap(), map()); + quickItem_->setSourceItem(polylineMapPaintedItem_); + } +} + +void QDeclarativePolylineMapItem::handleCameraDataChanged(const CameraData& cameraData) +{ + polylineMapPaintedItem_->setZoomLevel(cameraData.zoomFactor()); + update(); +} + +QColor QDeclarativePolylineMapItem::color() const +{ + return color_; +} + +void QDeclarativePolylineMapItem::setColor(const QColor &color) +{ + if (color_ == color) + return; + + color_ = color; + QPen pen(color); + polylineMapPaintedItem_->setPen(pen); + emit colorChanged(color_); +} + +////////////////////////////////////////////////////////////////////// + +PolylineMapPaintedItem::PolylineMapPaintedItem(QQuickItem *parent) : + QQuickPaintedItem(parent), map_(0), zoomLevel_(-1), initialized_(false) +{ + setAntialiasing(true); + connect(this, SIGNAL(xChanged()), this, SLOT(update())); + connect(this, SIGNAL(yChanged()), this, SLOT(update())); +} + +PolylineMapPaintedItem::~PolylineMapPaintedItem() +{ +} + +void PolylineMapPaintedItem::setMap(Map* map) +{ + map_ = map; +} + +void PolylineMapPaintedItem::setZoomLevel(qreal zoomLevel) +{ + if (zoomLevel_ == zoomLevel) + return; + + zoomLevel_ = zoomLevel; + updateGeometry(); +} + +qreal PolylineMapPaintedItem::zoomLevel() const +{ + return zoomLevel_; +} + +void PolylineMapPaintedItem::setPath(const QList<QGeoCoordinate>& path) +{ + coordPath_ = path; + updateGeometry(); +} + +QList<QGeoCoordinate> PolylineMapPaintedItem::path() const +{ + return coordPath_; +} + +QGeoCoordinate PolylineMapPaintedItem::screenItemCoordinate() const +{ + return quickItemCoordinate_; +} + +QPointF PolylineMapPaintedItem::screenItemAnchorPoint() const +{ + return quickItemAnchorPoint_; +} + +void PolylineMapPaintedItem::setBrush(const QBrush &brush) +{ + brush_ = brush; +} + +QBrush PolylineMapPaintedItem::brush() const +{ + return brush_; +} + +void PolylineMapPaintedItem::setPen(const QPen &pen) +{ + pen_ = pen; +} + +QPen PolylineMapPaintedItem::pen() const +{ + return pen_; +} + +void PolylineMapPaintedItem::paint(QPainter *painter) +{ + if (!initialized_) + return; + painter->setPen(pen_); + painter->setBrush(brush_); + painter->drawPath(path_); +} + +void PolylineMapPaintedItem::updateGeometry() +{ + initialized_ = false; + + if (!map_) + return; + + if (coordPath_.size() == 0) + return; + + if (zoomLevel_ == -1) + return; + + QPointF point = map_->coordinateToScreenPosition(coordPath_.at(0), false); + + qreal w = 0; + qreal h = 0; + + //TODO: optimize essential part + path_ = createPath(*map_, coordPath_, w, h); + + setWidth(w); + setHeight(h); + setContentsSize(QSize(w, h)); + + quickItemCoordinate_ = coordPath_.at(0); + quickItemAnchorPoint_ = path_.pointAtPercent(0); + initialized_ = true; + + update(); +} 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_ */ diff --git a/src/imports/location/qdeclarativeroutemapitem.cpp b/src/imports/location/qdeclarativeroutemapitem.cpp new file mode 100644 index 00000000..9ba56f9e --- /dev/null +++ b/src/imports/location/qdeclarativeroutemapitem.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + + +#include "qdeclarativeroutemapitem_p.h" +#include "qdeclarativepolylinemapitem_p.h" +#include "qdeclarativegeomapquickitem_p.h" +#include "qdeclarativegeoroute_p.h" +#include <QPainter> + +QDeclarativeRouteMapItem::QDeclarativeRouteMapItem(QQuickItem *parent) + : QDeclarativeGeoMapItemBase(parent), + quickItem_(new QDeclarativeGeoMapQuickItem(this)), + polylineMapPaintedItem_(new PolylineMapPaintedItem(quickItem_)), + route_(0) +{ +} + +QDeclarativeRouteMapItem::~QDeclarativeRouteMapItem() +{ +} + +QColor QDeclarativeRouteMapItem::color() const +{ + return color_; +} + +void QDeclarativeRouteMapItem::setColor(const QColor &color) +{ + if (color_ == color) + return; + + color_ = color; + QBrush m_brush(color); + polylineMapPaintedItem_->setBrush(m_brush); + emit colorChanged(color_); +} + +QDeclarativeGeoRoute* QDeclarativeRouteMapItem::route() const +{ + return route_; +} + + +void QDeclarativeRouteMapItem::setRoute(QDeclarativeGeoRoute *route) +{ + if (route_ == route) + return; + + route_ = route; + + if (route_) { + polylineMapPaintedItem_->setPath(route_->route_.path()); + } else { + polylineMapPaintedItem_->setPath(QList<QGeoCoordinate>()); + } + + emit routeChanged(route_); + +} + +void QDeclarativeRouteMapItem::update() +{ + if (!map()) + return; + + quickItem_->setCoordinate(new QDeclarativeCoordinate(polylineMapPaintedItem_->screenItemCoordinate())); + quickItem_->setAnchorPoint(polylineMapPaintedItem_->screenItemAnchorPoint()); + + if (quickItem_->sourceItem() == 0) { + QObject::connect(map(), SIGNAL(cameraDataChanged(CameraData)), this, SLOT(handleCameraDataChanged(CameraData))); + polylineMapPaintedItem_->setMap(map()); + quickItem_->setMap(quickMap(), map()); + quickItem_->setSourceItem(polylineMapPaintedItem_); + } +} + +void QDeclarativeRouteMapItem::handleCameraDataChanged(const CameraData& cameraData) +{ + polylineMapPaintedItem_->setZoomLevel(cameraData.zoomFactor()); + update(); +} diff --git a/src/imports/location/qdeclarativeroutemapitem_p.h b/src/imports/location/qdeclarativeroutemapitem_p.h new file mode 100644 index 00000000..b18b1dea --- /dev/null +++ b/src/imports/location/qdeclarativeroutemapitem_p.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** 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 QDECLARATIVEROUTEMAPITEM_H_ +#define QDECLARATIVEROUTEMAPITEM_H_ + +#include "qdeclarativegeomapitembase_p.h" +#include "qdeclarativecoordinate_p.h" +#include "qdeclarativegeomap_p.h" +#include <QPen> +#include <QBrush> + +QT_BEGIN_NAMESPACE + +class QDeclarativeGeoRoute; +class PolylineMapPaintedItem; +class QDeclarativeGeoMapQuickItem; + +class QDeclarativeRouteMapItem : public QDeclarativeGeoMapItemBase +{ + Q_OBJECT + + Q_PROPERTY(QDeclarativeGeoRoute* route READ route WRITE setRoute NOTIFY routeChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + +public: + QDeclarativeRouteMapItem(QQuickItem *parent = 0); + ~QDeclarativeRouteMapItem(); + + QDeclarativeGeoRoute* route() const; + void setRoute(QDeclarativeGeoRoute *route); + + QColor color() const; + void setColor(const QColor &color); + +Q_SIGNALS: + void routeChanged(const QDeclarativeGeoRoute *route); + void colorChanged(const QColor &color); + +protected Q_SLOTS: + void update(); + +private Q_SLOTS: + // map size changed + void handleCameraDataChanged(const CameraData& cameraData); + + +private: + QDeclarativeGeoMapQuickItem *quickItem_; + PolylineMapPaintedItem *polylineMapPaintedItem_; + QDeclarativeGeoRoute* route_; + QColor color_; + +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeRouteMapItem)); + +#endif /* QDECLARATIVEROUTEMAPITEM_H_ */ |