summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjuhvu <qt-info@nokia.com>2011-10-20 11:24:34 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-20 07:08:21 +0200
commit0acb68f58dc276faea85c74311fee3920a99eac6 (patch)
tree43843899bad652d583eff61ec58438a4c6d5abfc /src
parent8f765817b02e72356a0a4461b2889344fdc83dea (diff)
QML Map pinch and flick part 1/3
Autotest fw changes. First autotests and related fixes. Map initialization order changed to avoid blinking in hardcoded geocoordinate during app startup. Change-Id: Iaad879c135b6283957e0705b991474517f933485 Reviewed-by: David Laing <david.laing@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/imports/location/qdeclarative3dgraphicsgeomap.cpp167
-rw-r--r--src/imports/location/qdeclarative3dgraphicsgeomap_p.h3
-rw-r--r--src/imports/location/qdeclarativegeomapflickable.cpp21
-rw-r--r--src/imports/location/qdeclarativegeomapflickable_p.h4
-rw-r--r--src/imports/location/qdeclarativegeomappincharea.cpp39
-rw-r--r--src/location/maps/qgeomappingmanager.cpp23
-rw-r--r--src/location/maps/qgeomappingmanager.h2
-rw-r--r--src/location/maps/qgeomappingmanagerengine.cpp40
-rw-r--r--src/location/maps/qgeomappingmanagerengine.h2
-rw-r--r--src/location/maps/qgeomappingmanagerengine_p.h2
-rw-r--r--src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.cpp6
11 files changed, 216 insertions, 93 deletions
diff --git a/src/imports/location/qdeclarative3dgraphicsgeomap.cpp b/src/imports/location/qdeclarative3dgraphicsgeomap.cpp
index 1d5a8d2e..f0778dd7 100644
--- a/src/imports/location/qdeclarative3dgraphicsgeomap.cpp
+++ b/src/imports/location/qdeclarative3dgraphicsgeomap.cpp
@@ -111,10 +111,10 @@ QDeclarative3DGraphicsGeoMap::QDeclarative3DGraphicsGeoMap(QSGItem *parent)
serviceProvider_(0),
mappingManager_(0),
center_(0),
- initialCoordinate(0),
// mapType_(NoMap),
// connectivityMode_(NoConnectivity),
componentCompleted_(false),
+ mappingManagerInitialized_(false),
flickable_(0),
pinchArea_(0),
mouseGrabberItem_(0),
@@ -123,25 +123,17 @@ QDeclarative3DGraphicsGeoMap::QDeclarative3DGraphicsGeoMap(QSGItem *parent)
tileCache_(0)
{
QLOC_TRACE0;
- initialCoordinate = new QGeoCoordinate(-27.0, 153.0);
zoomLevel_ = 8;
size_ = QSizeF(100.0, 100.0);
setAcceptHoverEvents(false);
setAcceptedMouseButtons(Qt::LeftButton | Qt::MidButton | Qt::RightButton);
setFlags(QSGItem::ItemHasContents);
+ // Create internal flickable and pinch area.
tileCache_ = new TileCache();
map_ = new Map(tileCache_, this);
- connect(map_,
- SIGNAL(updateRequired()),
- this,
- SLOT(update()));
- connect(map_,
- SIGNAL(cameraDataChanged(CameraData)),
- this,
- SLOT(cameraDataChanged(CameraData)));
- // Create internal flickable and pinch area.
- flickable_ = new QDeclarativeGeoMapFlickable(map_, this);
+ flickable_ = new QDeclarativeGeoMapFlickable(this);
+ flickable_->setMap(map_);
pinchArea_ = new QDeclarativeGeoMapPinchArea(this, this);
setRenderTarget(QSGPaintedItem::FramebufferObject);
}
@@ -193,9 +185,6 @@ QDeclarative3DGraphicsGeoMap::~QDeclarative3DGraphicsGeoMap()
mouseAreas_.clear();
if (serviceProvider_)
delete serviceProvider_;
- if (initialCoordinate) {
- delete initialCoordinate;
- }
}
void QDeclarative3DGraphicsGeoMap::componentComplete()
@@ -203,12 +192,6 @@ void QDeclarative3DGraphicsGeoMap::componentComplete()
QLOC_TRACE0;
componentCompleted_ = true;
populateMap();
- map_->resize(width(), height());
- CameraData cameraData = map_->cameraData();
- map_->setCameraData(cameraData);
- map_->update();
- if (mappingManager_)
- pinchArea_->zoomLevelLimits(mappingManager_->minimumZoomLevel(), mappingManager_->maximumZoomLevel());
QSGItem::componentComplete();
}
@@ -226,8 +209,6 @@ void QDeclarative3DGraphicsGeoMap::itemChange(ItemChange change, const ItemChang
void QDeclarative3DGraphicsGeoMap::populateMap()
{
- if (!componentCompleted_)
- return;
QObjectList kids = children();
for (int i = 0; i < kids.size(); ++i) {
// dispatch items appropriately
@@ -277,6 +258,8 @@ qreal ViewportSubsurface::aspectRatio() const
void QDeclarative3DGraphicsGeoMap::updateAspectRatio()
{
+ if (!mappingManagerInitialized_)
+ return;
map_->resize(width(), height());
if (!map_->autoUpdate())
map_->update();
@@ -291,6 +274,8 @@ void QDeclarative3DGraphicsGeoMap::geometryChanged(const QRectF &newGeometry, co
void QDeclarative3DGraphicsGeoMap::keyPressEvent(QKeyEvent *e)
{
+ if (!mappingManagerInitialized_)
+ return;
QLOC_TRACE2(" key: ", e->key());
CameraData cameraData = map_->cameraData();
if (e->key() == Qt::Key_Left) {
@@ -357,7 +342,7 @@ void QDeclarative3DGraphicsGeoMap::keyPressEvent(QKeyEvent *e)
void QDeclarative3DGraphicsGeoMap::paint(QPainter* p)
{
- if (!isVisible())
+ if (!isVisible() || !mappingManagerInitialized_)
return;
QGLPainter painter(p);
@@ -398,6 +383,8 @@ void QDeclarative3DGraphicsGeoMap::paint(QPainter* p)
void QDeclarative3DGraphicsGeoMap::setCameraData(const CameraData &camera)
{
+ if (!mappingManagerInitialized_)
+ return;
map_->setCameraData(camera);
if (!map_->autoUpdate())
map_->update();
@@ -405,6 +392,8 @@ void QDeclarative3DGraphicsGeoMap::setCameraData(const CameraData &camera)
CameraData QDeclarative3DGraphicsGeoMap::cameraData() const
{
+ if (!mappingManagerInitialized_)
+ return CameraData();
return map_->cameraData();
}
@@ -464,10 +453,8 @@ void QDeclarative3DGraphicsGeoMap::earlyDraw(QGLPainter *painter)
void QDeclarative3DGraphicsGeoMap::paintGL(QGLPainter *painter)
{
- if (map_) {
- painter->projectionMatrix().scale(1,-1, 1); // qt3d and qsg interpret y differently
- map_->paintGL(painter);
- }
+ painter->projectionMatrix().scale(1,-1, 1); // qt3d and qsg interpret y differently
+ map_->paintGL(painter);
}
/*!
@@ -504,8 +491,11 @@ void QDeclarative3DGraphicsGeoMap::setPlugin(QDeclarativeGeoServiceProvider *plu
mappingManager_ = 0;
return;
}
-
- map_->setMappingManager(mappingManager_);
+ pinchArea_->zoomLevelLimits(mappingManager_->minimumZoomLevel(), mappingManager_->maximumZoomLevel());
+ if (!mappingManager_->isInitialized())
+ connect(mappingManager_, SIGNAL(initialized()), this, SLOT(mappingManagerInitialized()));
+ else
+ mappingManagerInitialized();
// mapData_ = mappingManager_->createMapData();
// mapData_->init();
@@ -523,8 +513,6 @@ void QDeclarative3DGraphicsGeoMap::setPlugin(QDeclarativeGeoServiceProvider *plu
// mapData_->setMapType(QGraphicsGeoMap::MapType(mapType_));
// mapData_->setConnectivityMode(QGraphicsGeoMap::ConnectivityMode(connectivityMode_));
- // Populate the map objects.
- populateMap();
// setup signals
// connect(mapData_,
// SIGNAL(updateMapDisplay(QRectF)),
@@ -557,6 +545,27 @@ void QDeclarative3DGraphicsGeoMap::setPlugin(QDeclarativeGeoServiceProvider *plu
// SIGNAL(zoomLevelChanged(qreal)));
}
+// this function will only be ever called once
+void QDeclarative3DGraphicsGeoMap::mappingManagerInitialized()
+{
+ mappingManagerInitialized_ = true;
+ connect(map_,
+ SIGNAL(updateRequired()),
+ this,
+ SLOT(update()));
+ connect(map_,
+ SIGNAL(cameraDataChanged(CameraData)),
+ this,
+ SLOT(cameraDataChanged(CameraData)));
+ map_->setMappingManager(mappingManager_);
+ map_->resize(width(), height());
+ CameraData cameraData = map_->cameraData();
+ cameraData.setCenter(center_->coordinate());
+ cameraData.setZoomFactor(zoomLevel_);
+ map_->setCameraData(cameraData);
+ map_->update();
+}
+
void QDeclarative3DGraphicsGeoMap::updateMapDisplay(const QRectF &target)
{
Q_UNUSED(target);
@@ -643,12 +652,17 @@ void QDeclarative3DGraphicsGeoMap::setZoomLevel(qreal zoomLevel)
{
if (zoomLevel_ == zoomLevel)
return;
+ if (!componentCompleted_) {
+ zoomLevel_ = zoomLevel;
+ return;
+ }
if (mappingManager_ &&
(zoomLevel < mappingManager_->minimumZoomLevel() ||
- zoomLevel > mappingManager_->maximumZoomLevel()))
+ zoomLevel > mappingManager_->maximumZoomLevel())) {
return;
+ }
zoomLevel_ = zoomLevel;
- if (map_) {
+ if (mappingManagerInitialized_) {
CameraData cameraData = map_->cameraData();
cameraData.setZoomFactor(zoomLevel);
map_->setCameraData(cameraData);
@@ -660,11 +674,10 @@ void QDeclarative3DGraphicsGeoMap::setZoomLevel(qreal zoomLevel)
qreal QDeclarative3DGraphicsGeoMap::zoomLevel() const
{
- if (map_) {
+ if (mappingManagerInitialized_)
return map_->cameraData().zoomFactor();
- } else {
+ else
return zoomLevel_;
- }
}
/*!
@@ -695,7 +708,7 @@ void QDeclarative3DGraphicsGeoMap::setCenter(QDeclarativeCoordinate *center)
SIGNAL(altitudeChanged(double)),
this,
SLOT(centerAltitudeChanged(double)));
- if (center_->coordinate().isValid()) {
+ if (center_->coordinate().isValid() && mappingManagerInitialized_) {
CameraData cameraData = map_->cameraData();
cameraData.setCenter(center_->coordinate());
map_->setCameraData(cameraData);
@@ -708,7 +721,10 @@ void QDeclarative3DGraphicsGeoMap::setCenter(QDeclarativeCoordinate *center)
QDeclarativeCoordinate* QDeclarative3DGraphicsGeoMap::center()
{
if (!center_) {
- center_ = new QDeclarativeCoordinate(map_->cameraData().center());
+ if (mappingManagerInitialized_)
+ center_ = new QDeclarativeCoordinate(map_->cameraData().center());
+ else
+ center_ = new QDeclarativeCoordinate(QGeoCoordinate(0,0));
connect(center_,
SIGNAL(latitudeChanged(double)),
this,
@@ -727,6 +743,8 @@ QDeclarativeCoordinate* QDeclarative3DGraphicsGeoMap::center()
void QDeclarative3DGraphicsGeoMap::cameraDataChanged(const CameraData &cameraData)
{
+ if (!componentCompleted_)
+ return;
// check what has changed and emit appropriate signals
if (!center_ || cameraData.center() != center_->coordinate()) {
QDeclarativeCoordinate* currentCenter = center();
@@ -743,12 +761,14 @@ void QDeclarative3DGraphicsGeoMap::centerLatitudeChanged(double latitude)
{
if (qIsNaN(latitude))
return;
- CameraData cameraData = map_->cameraData();
- QGeoCoordinate coord = cameraData.center();
- coord.setLatitude(latitude);
- cameraData.setCenter(coord);
- map_->setCameraData(cameraData);
- update();
+ if (mappingManagerInitialized_) {
+ CameraData cameraData = map_->cameraData();
+ QGeoCoordinate coord = cameraData.center();
+ coord.setLatitude(latitude);
+ cameraData.setCenter(coord);
+ map_->setCameraData(cameraData);
+ update();
+ }
emit centerChanged(center_);
}
@@ -756,12 +776,14 @@ void QDeclarative3DGraphicsGeoMap::centerLongitudeChanged(double longitude)
{
if (qIsNaN(longitude))
return;
- CameraData cameraData = map_->cameraData();
- QGeoCoordinate coord = cameraData.center();
- coord.setLongitude(longitude);
- cameraData.setCenter(coord);
- map_->setCameraData(cameraData);
- update();
+ if (mappingManagerInitialized_) {
+ CameraData cameraData = map_->cameraData();
+ QGeoCoordinate coord = cameraData.center();
+ coord.setLongitude(longitude);
+ cameraData.setCenter(coord);
+ map_->setCameraData(cameraData);
+ update();
+ }
emit centerChanged(center_);
}
@@ -769,12 +791,14 @@ void QDeclarative3DGraphicsGeoMap::centerAltitudeChanged(double altitude)
{
if (qIsNaN(altitude))
return;
- CameraData cameraData = map_->cameraData();
- QGeoCoordinate coord = cameraData.center();
- coord.setAltitude(altitude);
- cameraData.setCenter(coord);
- map_->setCameraData(cameraData);
- update();
+ if (mappingManagerInitialized_) {
+ CameraData cameraData = map_->cameraData();
+ QGeoCoordinate coord = cameraData.center();
+ coord.setAltitude(altitude);
+ cameraData.setCenter(coord);
+ map_->setCameraData(cameraData);
+ update();
+ }
emit centerChanged(center_);
}
@@ -888,7 +912,7 @@ void QDeclarative3DGraphicsGeoMap::centerAltitudeChanged(double altitude)
QDeclarativeCoordinate* QDeclarative3DGraphicsGeoMap::toCoordinate(QPointF screenPosition) const
{
QGeoCoordinate coordinate;
- if (map_)
+ if (mappingManagerInitialized_)
coordinate = map_->screenPositionToCoordinate(screenPosition);
// by default objects returned from method call get javascript ownership,
// so we don't need to worry about this as long as we don't set the parent
@@ -908,7 +932,7 @@ QDeclarativeCoordinate* QDeclarative3DGraphicsGeoMap::toCoordinate(QPointF scree
QPointF QDeclarative3DGraphicsGeoMap::toScreenPosition(QDeclarativeCoordinate* coordinate) const
{
QPointF point;
- if (map_)
+ if (mappingManagerInitialized_)
point = map_->coordinateToScreenPosition(coordinate->coordinate());
return point;
}
@@ -922,6 +946,10 @@ void QDeclarative3DGraphicsGeoMap::pan(int dx, int dy)
void QDeclarative3DGraphicsGeoMap::touchEvent(QTouchEvent *event)
{
+ if (!mappingManagerInitialized_) {
+ event->ignore();
+ return;
+ }
QLOC_TRACE0;
event->accept();
pinchArea_->touchEvent(event);
@@ -1005,6 +1033,10 @@ bool QDeclarative3DGraphicsGeoMap::deliverInitialMousePressEvent(QDeclarativeGeo
void QDeclarative3DGraphicsGeoMap::mousePressEvent(QMouseEvent *event)
{
QLOC_TRACE2(" ~~~~~~~ event, coordinates: ", event->pos());
+ if (!mappingManagerInitialized_) {
+ event->ignore();
+ return;
+ }
bool consumed = deliverMouseEvent(event);
consumed |= flickable_->mousePressEvent(event);
if (consumed)
@@ -1029,6 +1061,10 @@ QList<QDeclarativeGeoMapMouseArea*> QDeclarative3DGraphicsGeoMap::mouseAreasAt(Q
void QDeclarative3DGraphicsGeoMap::mouseReleaseEvent(QMouseEvent *event)
{
QLOC_TRACE2(" ~~~~~~~ event, coordinates: ", event->pos());
+ if (!mappingManagerInitialized_) {
+ event->ignore();
+ return;
+ }
bool consumed = false;
if (mouseGrabberItem_) {
consumed = deliverMouseEvent(event);
@@ -1044,6 +1080,10 @@ void QDeclarative3DGraphicsGeoMap::mouseReleaseEvent(QMouseEvent *event)
void QDeclarative3DGraphicsGeoMap::mouseDoubleClickEvent(QMouseEvent *event)
{
QLOC_TRACE2(" ~~~~~~~ event, coordinates: ", event->pos());
+ if (!mappingManagerInitialized_) {
+ event->ignore();
+ return;
+ }
if (!mouseGrabberItem_ && (event->button() & event->buttons()) == event->buttons()) {
QList<QDeclarativeGeoMapMouseArea*> mouseAreas = mouseAreasAt(event->pos());
for (int i = 0; i < mouseAreas.count(); ++i) {
@@ -1063,7 +1103,10 @@ void QDeclarative3DGraphicsGeoMap::mouseDoubleClickEvent(QMouseEvent *event)
void QDeclarative3DGraphicsGeoMap::mouseMoveEvent(QMouseEvent *event)
{
- //QLOC_TRACE2(" ~~~~~~~ event, coordinates: ", event->pos());
+ if (!mappingManagerInitialized_) {
+ event->ignore();
+ return;
+ }
bool consumed = false;
if (mouseGrabberItem_)
consumed = deliverMouseEvent(event);
@@ -1126,7 +1169,7 @@ void QDeclarative3DGraphicsGeoMap::removeMapItem(QDeclarativeGeoMapItem *item)
{
QLOC_TRACE0;
#ifdef QSGSHADEREFFECTSOURCE_AVAILABLE
- if (!item)
+ if (!item || !map_)
return;
if (mapItemsPending_.contains(item)) {
mapItemsPending_.removeAll(item);
@@ -1151,7 +1194,7 @@ void QDeclarative3DGraphicsGeoMap::removeMapItem(QDeclarativeGeoMapItem *item)
// TODO clears all items including ones from models/MapItemview which is not intended
void QDeclarative3DGraphicsGeoMap::clearMapItems()
{
- if (mapItems_.isEmpty())
+ if (mapItems_.isEmpty() || !map_)
return;
updateMutex_.lock();
mapItems_.clear();
diff --git a/src/imports/location/qdeclarative3dgraphicsgeomap_p.h b/src/imports/location/qdeclarative3dgraphicsgeomap_p.h
index 2fd4ed25..c178e172 100644
--- a/src/imports/location/qdeclarative3dgraphicsgeomap_p.h
+++ b/src/imports/location/qdeclarative3dgraphicsgeomap_p.h
@@ -221,6 +221,7 @@ private Q_SLOTS:
void centerAltitudeChanged(double altitude);
void mapItemDestroyed(QObject* item);
void cameraDataChanged(const CameraData &cameraData);
+ void mappingManagerInitialized();
private:
void setupMapView(QDeclarativeGeoMapItemView *view);
@@ -252,12 +253,12 @@ private:
qreal zoomLevel_;
QPointer<QDeclarativeCoordinate> center_;
- QGeoCoordinate* initialCoordinate;
// QDeclarative3DGraphicsGeoMap::MapType mapType_;
// QDeclarative3DGraphicsGeoMap::ConnectivityMode connectivityMode_;
QSizeF size_;
bool componentCompleted_;
+ bool mappingManagerInitialized_;
QList<QDeclarativeGeoMapItemView*> mapViews_;
QDeclarativeGeoMapFlickable* flickable_;
diff --git a/src/imports/location/qdeclarativegeomapflickable.cpp b/src/imports/location/qdeclarativegeomapflickable.cpp
index 41eb2ea8..4646f529 100644
--- a/src/imports/location/qdeclarativegeomapflickable.cpp
+++ b/src/imports/location/qdeclarativegeomapflickable.cpp
@@ -80,32 +80,35 @@ const qreal MinimumFlickVelocity = 75.0;
QT_BEGIN_NAMESPACE
-QDeclarativeGeoMapFlickable::QDeclarativeGeoMapFlickable(Map* map, QObject *parent)
+QDeclarativeGeoMapFlickable::QDeclarativeGeoMapFlickable(QObject *parent)
: QObject(parent),
pressed_(false),
maxVelocity_(QML_FLICK_DEFAULTMAXVELOCITY),
deceleration_(QML_FLICK_DEFAULTDECELERATION),
flicking_(false),
- map_(map),
+ map_(0),
enabled_(false),
moving_(false)
{
- Q_ASSERT(map_);
pressTime_.invalidate();
lastPosTime_.invalidate();
velocityTime_.invalidate();
- //animation_ = new QPropertyAnimation(map_->mapCamera(), "cameraData", this);
- //animation_ = new QPropertyAnimation(map_->mapCamera(), "center", this);
- animation_ = new QPropertyAnimation(map_, "camera", this);
- animation_->setEasingCurve(QEasingCurve(QEasingCurve::OutQuad));
- connect(animation_, SIGNAL(finished()), this, SLOT(flickAnimationFinished()));
- //connect(animation_, SIGNAL(valueChanged(const QVariant&)), this, SLOT(flickAnimationValueChanged(const QVariant&)));
}
QDeclarativeGeoMapFlickable::~QDeclarativeGeoMapFlickable()
{
}
+void QDeclarativeGeoMapFlickable::setMap(Map* map)
+{
+ if (map_ || !map)
+ return;
+ map_ = map;
+ animation_ = new QPropertyAnimation(map_, "camera", this);
+ animation_->setEasingCurve(QEasingCurve(QEasingCurve::OutQuad));
+ connect(animation_, SIGNAL(finished()), this, SLOT(flickAnimationFinished()));
+}
+
qreal QDeclarativeGeoMapFlickable::deceleration() const
{
return deceleration_;
diff --git a/src/imports/location/qdeclarativegeomapflickable_p.h b/src/imports/location/qdeclarativegeomapflickable_p.h
index ee2e7ced..8b57343a 100644
--- a/src/imports/location/qdeclarativegeomapflickable_p.h
+++ b/src/imports/location/qdeclarativegeomapflickable_p.h
@@ -71,7 +71,7 @@ class QDeclarativeGeoMapFlickable: public QObject
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged())
public:
- QDeclarativeGeoMapFlickable(Map* map, QObject *parent = 0);
+ QDeclarativeGeoMapFlickable(QObject *parent = 0);
~QDeclarativeGeoMapFlickable();
qreal deceleration() const;
@@ -80,6 +80,8 @@ public:
bool enabled() const;
void setEnabled(bool enabled);
+ void setMap(Map* map);
+
bool mousePressEvent(QMouseEvent *event);
bool mouseMoveEvent(QMouseEvent *event);
bool mouseReleaseEvent(QMouseEvent *event);
diff --git a/src/imports/location/qdeclarativegeomappincharea.cpp b/src/imports/location/qdeclarativegeomappincharea.cpp
index d0e0feb7..016be089 100644
--- a/src/imports/location/qdeclarativegeomappincharea.cpp
+++ b/src/imports/location/qdeclarativegeomappincharea.cpp
@@ -55,10 +55,10 @@ QDeclarativeGeoMapPinchArea::QDeclarativeGeoMapPinchArea(QDeclarative3DGraphicsG
map_(map),
enabled_(true),
active_(false),
- minimumZoomLevel_(0.0),
- maximumZoomLevel_(100.0),
+ minimumZoomLevel_(-1.0),
+ maximumZoomLevel_(-1.0),
minimumRotation_(0.0),
- maximumRotation_(0.0),
+ maximumRotation_(45.0),
inPinch_(false),
pinchRejected_(false),
pinchActivated_(false),
@@ -71,10 +71,11 @@ QDeclarativeGeoMapPinchArea::QDeclarativeGeoMapPinchArea(QDeclarative3DGraphicsG
pinchRotation_(0.0),
id1_(-1),
maximumZoomLevelChange_(2.0),
+ rotationSpeed_(1.0),
activeGestures_(ZoomGesture | RotationGesture),
minimumTilt_(0.0),
maximumTilt_(90.0),
- maximumTiltChange_(10.0),
+ maximumTiltChange_(20.0),
pinchLastTilt_(0.0),
pinchStartTilt_(0.0)
{
@@ -108,7 +109,7 @@ void QDeclarativeGeoMapPinchArea::setActive(bool active)
{
if (active == active_)
return;
- active = active_;
+ active_ = active;
emit activeChanged();
}
@@ -121,7 +122,7 @@ void QDeclarativeGeoMapPinchArea::setEnabled(bool enabled)
{
if (enabled == enabled_)
return;
- enabled = enabled_;
+ enabled_ = enabled;
emit enabledChanged();
}
@@ -132,7 +133,9 @@ qreal QDeclarativeGeoMapPinchArea::minimumZoomLevel() const
void QDeclarativeGeoMapPinchArea::setMinimumZoomLevel(qreal zoomLevel)
{
- if (zoomLevel == minimumZoomLevel_ || zoomLevel < map_->minimumZoomLevel())
+ if (zoomLevel == minimumZoomLevel_ ||
+ zoomLevel < map_->minimumZoomLevel() ||
+ (maximumZoomLevel_ != -1.0 && zoomLevel > maximumZoomLevel_) )
return;
minimumZoomLevel_ = zoomLevel;
emit minimumZoomLevelChanged();
@@ -145,7 +148,9 @@ qreal QDeclarativeGeoMapPinchArea::maximumZoomLevel() const
void QDeclarativeGeoMapPinchArea::setMaximumZoomLevel(qreal zoomLevel)
{
- if (zoomLevel == maximumZoomLevel_ || zoomLevel > map_->maximumZoomLevel())
+ if (zoomLevel == maximumZoomLevel_ ||
+ zoomLevel > map_->maximumZoomLevel() ||
+ (minimumZoomLevel_ != - 1.0 && zoomLevel < minimumZoomLevel_))
return;
maximumZoomLevel_ = zoomLevel;
emit maximumZoomLevelChanged();
@@ -156,9 +161,9 @@ void QDeclarativeGeoMapPinchArea::setMaximumZoomLevel(qreal zoomLevel)
// it possible to check against mapping plugins' limits)
void QDeclarativeGeoMapPinchArea::zoomLevelLimits(qreal min, qreal max)
{
- if (min > minimumZoomLevel_)
+ if (minimumZoomLevel_ == -1.0 || min > minimumZoomLevel_)
setMinimumZoomLevel(min);
- if (max < maximumZoomLevel_)
+ if (maximumZoomLevel_ == -1.0 || max < maximumZoomLevel_)
setMaximumZoomLevel(max);
}
@@ -169,7 +174,7 @@ qreal QDeclarativeGeoMapPinchArea::maximumZoomLevelChange() const
void QDeclarativeGeoMapPinchArea::setMaximumZoomLevelChange(qreal maxChange)
{
- if (maxChange == maximumZoomLevelChange_ || maxChange < 0.1)
+ if (maxChange == maximumZoomLevelChange_ || maxChange < 0.1 || maxChange > 10.0)
return;
maximumZoomLevelChange_ = maxChange;
emit maximumZoomLevelChangeChanged();
@@ -182,7 +187,9 @@ qreal QDeclarativeGeoMapPinchArea::minimumRotation() const
void QDeclarativeGeoMapPinchArea::setMinimumRotation(qreal rotation)
{
- if (rotation == minimumRotation_ || rotation < 0.1)
+ if (rotation == minimumRotation_ ||
+ rotation < 0 ||
+ rotation > maximumRotation_)
return;
minimumRotation_ = rotation;
emit minimumRotationChanged();
@@ -195,7 +202,9 @@ qreal QDeclarativeGeoMapPinchArea::maximumRotation() const
void QDeclarativeGeoMapPinchArea::setMaximumRotation(qreal rotation)
{
- if (rotation == maximumRotation_ || rotation > 360)
+ if (rotation == maximumRotation_ ||
+ rotation > 360 ||
+ rotation < minimumRotation_)
return;
maximumRotation_ = rotation;
emit maximumRotationChanged();
@@ -208,7 +217,9 @@ qreal QDeclarativeGeoMapPinchArea::rotationSpeed() const
void QDeclarativeGeoMapPinchArea::setRotationSpeed(qreal speed)
{
- if (rotationSpeed_ == speed || speed < 0.1)
+ if (rotationSpeed_ == speed ||
+ speed < 0 ||
+ speed > 10)
return;
rotationSpeed_ = speed;
emit rotationSpeedChanged();
diff --git a/src/location/maps/qgeomappingmanager.cpp b/src/location/maps/qgeomappingmanager.cpp
index 6cc8a5fe..37a59c57 100644
--- a/src/location/maps/qgeomappingmanager.cpp
+++ b/src/location/maps/qgeomappingmanager.cpp
@@ -123,6 +123,11 @@ QGeoMappingManager::QGeoMappingManager(QGeoMappingManagerEngine *engine, QObject
SLOT(threadStarted()),
Qt::QueuedConnection);
+ connect(d_ptr->engine,
+ SIGNAL(initialized()),
+ this,
+ SIGNAL(initialized()));
+
d_ptr->engine->moveToThread(d_ptr->thread);
QTimer::singleShot(0, d_ptr->thread, SLOT(start()));
}
@@ -136,6 +141,13 @@ QGeoMappingManager::~QGeoMappingManager()
}
/*!
+ \fn void QGeoMappingManager::initialized()
+
+ This signal is emitted when the mapping manager has been initialized
+ and is ready to be used.
+*/
+
+/*!
Returns the name of the engine which implements the behaviour of this
mapping manager.
@@ -232,6 +244,17 @@ bool QGeoMappingManager::supportsBearing() const
}
/*!
+ Return whether the manager has been initialized
+ (will be done automatically but may take some time).
+
+*/
+bool QGeoMappingManager::isInitialized() const
+{
+ return d_ptr->engine->isInitialized();
+}
+
+
+/*!
Return whether tilting is supported by this manager.
*/
bool QGeoMappingManager::supportsTilting() const
diff --git a/src/location/maps/qgeomappingmanager.h b/src/location/maps/qgeomappingmanager.h
index deac7227..33d42426 100644
--- a/src/location/maps/qgeomappingmanager.h
+++ b/src/location/maps/qgeomappingmanager.h
@@ -94,6 +94,7 @@ public:
qreal maximumZoomLevel() const;
bool supportsBearing() const;
+ bool isInitialized() const;
bool supportsTilting() const;
qreal minimumTilt() const;
@@ -106,6 +107,7 @@ Q_SIGNALS:
void tileFinished(const TileSpec &spec, const QByteArray &bytes);
void tileError(const TileSpec &spec, const QString &errorString);
void queueFinished();
+ void initialized();
private:
QGeoMappingManager(QGeoMappingManagerEngine *engine, QObject *parent = 0);
diff --git a/src/location/maps/qgeomappingmanagerengine.cpp b/src/location/maps/qgeomappingmanagerengine.cpp
index b70cd5a8..242c2e02 100644
--- a/src/location/maps/qgeomappingmanagerengine.cpp
+++ b/src/location/maps/qgeomappingmanagerengine.cpp
@@ -79,6 +79,7 @@ QGeoMappingManagerEngine::QGeoMappingManagerEngine(const QMap<QString, QVariant>
d_ptr(new QGeoMappingManagerEnginePrivate())
{
d_ptr->parameters = parameters;
+ d_ptr->initialized = false;
}
/*!
@@ -103,8 +104,21 @@ QMap<QString, QVariant> QGeoMappingManagerEngine::parameters() const
return d->parameters;
}
+/*!
+ Initializes the engine. Subclasses of QGeoMappingManagerEngine may
+ implement this function to perform (potentially asynchronous) initialization.
+
+ Static/already known data (such as min/max zoom levels) is better to
+ initialize already earlier (e.g. in constructor).
+
+ Once subclasses are done with initialization, they should call this baseclass
+ implementation of init().
+*/
void QGeoMappingManagerEngine::init()
{
+ Q_D(QGeoMappingManagerEngine);
+ d->initialized = true;
+ emit initialized();
}
void QGeoMappingManagerEngine::threadStarted()
@@ -344,6 +358,17 @@ QSize QGeoMappingManagerEngine::tileSize() const
return d->tileSize;
}
+
+/*!
+ Return whether the engine has been initialized and is ready to be used.
+*/
+
+bool QGeoMappingManagerEngine::isInitialized() const
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d->initialized;
+}
+
/*!
Sets the minimum zoom level supported by this engine to \a minimumZoom.
@@ -360,6 +385,17 @@ void QGeoMappingManagerEngine::setMinimumZoomLevel(qreal minimumZoom)
}
/*!
+ \fn void QGeoMappingManagerEngine::initialized()
+
+ This signal is emitted when the mapping manager has been initialized
+ and is ready to be used.
+
+ Subclasses of QGeoMappingManagerEngine should call the
+ QGeoMappingManagerEngine init() when they have initialized themselves.
+*/
+
+
+/*!
Sets the maximum zoom level supported by this engine to \a maximumZoom.
Larger values of the zoom level correspond to more detailed views of the
@@ -503,8 +539,8 @@ QLocale QGeoMappingManagerEngine::locale() const
QGeoMappingManagerEnginePrivate::QGeoMappingManagerEnginePrivate()
: managerVersion(-1),
- minimumZoomLevel(1.0),
- maximumZoomLevel(20.0), // todo fixme, this needs to come from plugin
+ minimumZoomLevel(-2.0),
+ maximumZoomLevel(-2.0), // todo fixme, this needs to come from plugin
supportsBearing(false),
supportsTilting(false),
minimumTilt(0.0),
diff --git a/src/location/maps/qgeomappingmanagerengine.h b/src/location/maps/qgeomappingmanagerengine.h
index 9beb567b..d9df0017 100644
--- a/src/location/maps/qgeomappingmanagerengine.h
+++ b/src/location/maps/qgeomappingmanagerengine.h
@@ -97,6 +97,7 @@ public:
QLocale locale() const;
virtual void init();
+ bool isInitialized() const;
public Q_SLOTS:
void threadStarted();
@@ -110,6 +111,7 @@ Q_SIGNALS:
void tileFinished(const TileSpec &spec, const QByteArray &bytes);
void tileError(const TileSpec &spec, const QString &errorString);
void queueFinished();
+ void initialized();
protected:
QGeoMappingManagerEngine(QGeoMappingManagerEnginePrivate *dd, QObject *parent = 0);
diff --git a/src/location/maps/qgeomappingmanagerengine_p.h b/src/location/maps/qgeomappingmanagerengine_p.h
index e262cc2c..bbfed6f8 100644
--- a/src/location/maps/qgeomappingmanagerengine_p.h
+++ b/src/location/maps/qgeomappingmanagerengine_p.h
@@ -88,8 +88,8 @@ public:
qreal maximumTilt;
QLocale locale;
-
bool started_;
+ bool initialized;
QTimer *timer_;
QList<TileSpec> queue_;
QHash<QGeoTiledMapReply*, TileSpec> map_;
diff --git a/src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.cpp
index 164e9460..74475d5d 100644
--- a/src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeomappingmanagerengine_nokia.cpp
@@ -115,6 +115,8 @@ QGeoMappingManagerEngineNokia::QGeoMappingManagerEngineNokia(const QMap<QString,
{
Q_UNUSED(error)
Q_UNUSED(errorString)
+ setMinimumZoomLevel(0.0);
+ setMaximumZoomLevel(20.0);
}
QGeoMappingManagerEngineNokia::~QGeoMappingManagerEngineNokia() {}
@@ -122,9 +124,6 @@ QGeoMappingManagerEngineNokia::~QGeoMappingManagerEngineNokia() {}
void QGeoMappingManagerEngineNokia::init()
{
setTileSize(QSize(256, 256));
- setMinimumZoomLevel(0.0);
- setMaximumZoomLevel(20.0);
-
// QList<QGraphicsGeoMap::MapType> types;
// types << QGraphicsGeoMap::StreetMap;
// types << QGraphicsGeoMap::SatelliteMapDay;
@@ -206,6 +205,7 @@ void QGeoMappingManagerEngineNokia::init()
m_networkManager->setCache(m_cache);
}
#endif
+ QGeoMappingManagerEngine::init();
}
QGeoTiledMapReply* QGeoMappingManagerEngineNokia::getTileImage(const TileSpec &spec)