diff options
author | Fabian Bumberger <fbumberger@rim.com> | 2014-01-26 19:48:39 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-11 15:12:39 +0100 |
commit | 14dc46ee4dc05e78b227910f38e7f97f87004290 (patch) | |
tree | 5364982a47c74583465fd2811ac08d12e7d2960e | |
parent | 334b9f3b0c4acb77db7254380c4a96cea6d589a8 (diff) |
Remove bearing and tilt from the qml API
Bearing and tilt are rather far away from a working state.
This patch removes them from the public qml API and the documentation.
Change-Id: I820fed3f1acf9a05e250e474bf3ac35fcb6fc19f
Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r-- | src/imports/location/qdeclarativegeomap.cpp | 111 | ||||
-rw-r--r-- | src/imports/location/qdeclarativegeomap_p.h | 13 | ||||
-rw-r--r-- | src/imports/location/qdeclarativegeomapgesturearea.cpp | 81 | ||||
-rw-r--r-- | src/imports/location/qdeclarativegeomapgesturearea_p.h | 33 |
4 files changed, 8 insertions, 230 deletions
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp index a59b30e7..8310fd48 100644 --- a/src/imports/location/qdeclarativegeomap.cpp +++ b/src/imports/location/qdeclarativegeomap.cpp @@ -187,8 +187,6 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent) serviceProvider_(0), mappingManager_(0), zoomLevel_(8.0), - bearing_(0.0), - tilt_(0.0), center_(0,0), activeMapType_(0), componentCompleted_(false), @@ -498,22 +496,12 @@ void QDeclarativeGeoMap::mappingManagerInitialized() this, SIGNAL(centerChanged(QGeoCoordinate))); connect(map_->mapController(), - SIGNAL(bearingChanged(qreal)), - this, - SLOT(mapBearingChanged(qreal))); - connect(map_->mapController(), - SIGNAL(tiltChanged(qreal)), - this, - SLOT(mapTiltChanged(qreal))); - connect(map_->mapController(), SIGNAL(zoomChanged(qreal)), this, SLOT(mapZoomLevelChanged(qreal))); map_->mapController()->setCenter(center_); map_->mapController()->setZoom(zoomLevel_); - map_->mapController()->setBearing(bearing_); - map_->mapController()->setTilt(tilt_); QList<QGeoMapType> types = mappingManager_->supportedMapTypes(); for (int i = 0; i < types.size(); ++i) { @@ -637,81 +625,6 @@ qreal QDeclarativeGeoMap::maximumZoomLevel() const } /*! - \internal -*/ -void QDeclarativeGeoMap::setBearing(qreal bearing) -{ - if (bearing_ == bearing) - return; - bool clockwise = (bearing >= 0); - qreal fractions = bearing - int(bearing); - bearing = (int(qAbs(bearing))) % 359; - if (!clockwise) - bearing = (-1.0 * bearing) + 360; - bearing_ = bearing + fractions; - if (mappingManagerInitialized_) - map_->mapController()->setBearing(bearing_); - emit bearingChanged(bearing_); -} - -/*! - \qmlproperty real Map::bearing - - This property holds the current bearing (starting from 0 and increasing - clockwise to 359,9 degrees) pointing up. - - For example setting bearing to 10 will set bearing 10 to point up, which - visually looks like rotating the map counter-clockwise. - - You can also assign negative values, which will internally get - translated into positive bearing (for example -10 equals 350). This is primarily for - convenience (for example you can decrement bearing without worrying about it). - Assigning values greater than abs(360) will be mod'd (for example 365 will result - in 5). - - The default value is 0 corresponding North pointing up. -*/ - -qreal QDeclarativeGeoMap::bearing() const -{ - if (mappingManagerInitialized_) { - if (map_->mapController()->bearing() >= 0) - return map_->mapController()->bearing(); - else - return map_->mapController()->bearing() + 360; - } else { - return bearing_; - } -} - -/*! - \qmlproperty real Map::tilt - - This property holds the current tilt (starting from 0 and increasing to 85 degrees). - - The tilt gives the map a 2.5D feel. Certain map objects may be rendered - in 3D if the tilt is different from 0. - - The default value is 0 corresponding to no tilt. -*/ -qreal QDeclarativeGeoMap::tilt() const -{ - if (!mappingManagerInitialized_) - return tilt_; - return map_->mapController()->tilt(); -} - -void QDeclarativeGeoMap::setTilt(qreal tilt) -{ - if (tilt_ == tilt || tilt > 85.0 || tilt < 0) - return; - tilt_ = tilt; - if (mappingManagerInitialized_) - map_->mapController()->setTilt(tilt); - emit tiltChanged(tilt); -} - -/*! \qmlproperty real QtLocation::Map::zoomLevel This property holds the zoom level for the map. @@ -785,28 +698,6 @@ void QDeclarativeGeoMap::mapZoomLevelChanged(qreal zoom) } /*! - \internal -*/ -void QDeclarativeGeoMap::mapTiltChanged(qreal tilt) -{ - if (tilt == zoomLevel_) - return; - tilt_ = tilt; - emit tiltChanged(tilt_); -} - -/*! - \internal -*/ -void QDeclarativeGeoMap::mapBearingChanged(qreal bearing) -{ - if (bearing == bearing_) - return; - bearing_ = bearing; - emit bearingChanged(bearing_); -} - -/*! \qmlproperty list<MapType> QtLocation::Map::supportedMapTypes This read-only property holds the set of \l{MapType}{map types} supported by this map. @@ -863,7 +754,7 @@ QPointF QDeclarativeGeoMap::toScreenPosition(const QGeoCoordinate &coordinate) c Positive values for \a dx move the map right, negative values left. Positive values for \a dy move the map down, negative values up. - During panning the \l center, \l tilt, \l bearing, and \l zoomLevel may change. + During panning the \l center, and \l zoomLevel may change. */ void QDeclarativeGeoMap::pan(int dx, int dy) { diff --git a/src/imports/location/qdeclarativegeomap_p.h b/src/imports/location/qdeclarativegeomap_p.h index b024d006..fb00e1b7 100644 --- a/src/imports/location/qdeclarativegeomap_p.h +++ b/src/imports/location/qdeclarativegeomap_p.h @@ -106,9 +106,6 @@ class QDeclarativeGeoMap : public QQuickItem Q_PROPERTY(QQmlListProperty<QDeclarativeGeoMapType> supportedMapTypes READ supportedMapTypes NOTIFY supportedMapTypesChanged) Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter NOTIFY centerChanged) Q_PROPERTY(QList<QObject *> mapItems READ mapItems NOTIFY mapItemsChanged) - // Tilt and bearing are not part of supported API - Q_PROPERTY(qreal tilt READ tilt WRITE setTilt NOTIFY tiltChanged) - Q_PROPERTY(qreal bearing READ bearing WRITE setBearing NOTIFY bearingChanged) Q_INTERFACES(QQmlParserStatus) public: @@ -140,12 +137,6 @@ public: void setZoomLevel(qreal zoomLevel); qreal zoomLevel() const; - void setBearing(qreal bearing); - qreal bearing() const; - - void setTilt(qreal tilt); - qreal tilt() const; - void setCenter(const QGeoCoordinate ¢er); QGeoCoordinate center() const; @@ -183,8 +174,6 @@ Q_SIGNALS: void wheelAngleChanged(QPoint angleDelta); void pluginChanged(QDeclarativeGeoServiceProvider *plugin); void zoomLevelChanged(qreal zoomLevel); - void bearingChanged(qreal bearing); - void tiltChanged(qreal tilt); void centerChanged(const QGeoCoordinate &coordinate); void activeMapTypeChanged(); void supportedMapTypesChanged(); @@ -196,8 +185,6 @@ private Q_SLOTS: void updateMapDisplay(const QRectF &target); void mappingManagerInitialized(); void mapZoomLevelChanged(qreal zoom); - void mapTiltChanged(qreal tilt); - void mapBearingChanged(qreal bearing); void pluginReady(); void onMapChildrenChanged(); diff --git a/src/imports/location/qdeclarativegeomapgesturearea.cpp b/src/imports/location/qdeclarativegeomapgesturearea.cpp index 88925524..9adc422d 100644 --- a/src/imports/location/qdeclarativegeomapgesturearea.cpp +++ b/src/imports/location/qdeclarativegeomapgesturearea.cpp @@ -234,16 +234,10 @@ QT_BEGIN_NAMESPACE \list \li MapGestureArea.NoGesture - Don't support any additional gestures (value: 0x0000). \li MapGestureArea.ZoomGesture - Support the map zoom gesture (value: 0x0001). - \li MapGestureArea.RotationGesture - Support the map rotation gesture (value: 0x0002). - \li MapGestureArea.TiltGesture - Support the map tilt gesture (value: 0x0004). - \li MapGestureArea.PanGesture - Support the map pan gesture (value: 0x0008). - \li MapGestureArea.FlickGesture - Support the map flick gesture (value: 0x0010). + \li MapGestureArea.PanGesture - Support the map pan gesture (value: 0x0002). + \li MapGestureArea.FlickGesture - Support the map flick gesture (value: 0x0004). \endlist - For the extremist, one may OR flag the RotationGesture or TiltGesture - but these come with absolutely no warranty or guarantees at the moment - (may be removed, changed, moved around) - \note For the time being, only MapGestureArea.ZoomGesture is supported. */ @@ -259,16 +253,6 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlproperty real MapGestureArea::rotationFactor - - This property holds the rotation factor for zoom, essentially meant to be used for setting - the rotation sensitivity. - - It is an indicative measure; the default value 1.0 means the map roughly follows the fingers, - whereas 2.0 means rotating twice as fast. Maximum value is 5.0. -*/ - -/*! \qmlproperty real MapGestureArea::flickDeceleration This property holds the rate at which a flick will decelerate. @@ -386,10 +370,6 @@ void QDeclarativeGeoMapGestureArea::setActiveGestures(ActiveGestures activeGestu if (activeGestures == activeGestures_) return; activeGestures_ = activeGestures; - if (activeGestures_ & RotationGesture) - qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, PINCH_ROTATE_GESTURE_ACTIVATED); - if (activeGestures_ & TiltGesture) - qmlInfo(this) << QCoreApplication::translate(CONTEXT_NAME, PINCH_TILT_GESTURE_ACTIVATED); emit activeGesturesChanged(); } @@ -533,25 +513,6 @@ void QDeclarativeGeoMapGestureArea::setMaximumZoomLevelChange(qreal maxChange) /*! \internal */ -qreal QDeclarativeGeoMapGestureArea::rotationFactor() const -{ - return pinch_.rotation.factor; -} - -/*! - \internal -*/ -void QDeclarativeGeoMapGestureArea::setRotationFactor(qreal factor) -{ - if (pinch_.rotation.factor == factor || factor < 0 || factor > 5) - return; - pinch_.rotation.factor = factor; - emit rotationFactorChanged(); -} - -/*! - \internal -*/ qreal QDeclarativeGeoMapGestureArea::flickDeceleration() const { return pan_.deceleration_; @@ -747,7 +708,7 @@ void QDeclarativeGeoMapGestureArea::update() touchPointStateMachine(); // Parallel state machine for pinch - if (isPinchActive() || (enabled_ && pinch_.enabled && (activeGestures_ & (ZoomGesture | TiltGesture | RotationGesture)))) + if (isPinchActive() || (enabled_ && pinch_.enabled && (activeGestures_ & (ZoomGesture)))) pinchStateMachine(); // Parallel state machine for pan (since you can pan at the same time as pinching) @@ -952,16 +913,12 @@ void QDeclarativeGeoMapGestureArea::startPinch() { pinch_.startDist = distanceBetweenTouchPoints_; pinch_.zoom.previous = 1.0; - pinch_.tilt.previous = 0.0; pinch_.lastAngle = twoTouchAngle_; - pinch_.rotation.angle = 0.0; pinch_.lastPoint1 = touchPoints_.at(0).scenePos(); pinch_.lastPoint2 = touchPoints_.at(1).scenePos(); pinch_.zoom.start = declarativeMap_->zoomLevel(); - pinch_.rotation.start = declarativeMap_->bearing(); - pinch_.tilt.start = declarativeMap_->tilt(); } /*! @@ -985,7 +942,6 @@ void QDeclarativeGeoMapGestureArea::updatePinch() da -= 360; else if (da < -180) da += 360; - pinch_.rotation.angle -= da; pinch_.event.setCenter(declarativeMap_->mapFromScene(sceneCenter_)); pinch_.event.setAngle(twoTouchAngle_); @@ -1006,37 +962,6 @@ void QDeclarativeGeoMapGestureArea::updatePinch() newZoomLevel = qMin(qMax(perPinchMinimumZoomLevel, newZoomLevel), perPinchMaximumZoomLevel); declarativeMap_->setZoomLevel(newZoomLevel); } - if (activeGestures_ & TiltGesture && pinch_.zoom.minimum >= 0 && pinch_.zoom.maximum >= 0) { - // Note: tilt is not yet supported. - qreal newTilt = pinch_.tilt.previous; - if (distanceBetweenTouchPoints_) { - newTilt = - // How much further/closer the current touchpoints are (in pixels) compared to pinch start - ((distanceBetweenTouchPoints_ - pinch_.startDist) * - // How much one pixel corresponds in units of tilt degrees (and multiply by above delta) - (pinch_.tilt.maximumChange / ((declarativeMap_->width() + declarativeMap_->height()) / 2))) + - // Add to starting tilt. - pinch_.tilt.start; - } - qreal perPinchMinimumTilt = qMax(pinch_.tilt.start - pinch_.tilt.maximumChange, pinch_.tilt.minimum); - qreal perPinchMaximumTilt = qMin(pinch_.tilt.start + pinch_.tilt.maximumChange, pinch_.tilt.maximum); - newTilt = qMin(qMax(perPinchMinimumTilt, newTilt), perPinchMaximumTilt); - pinch_.tilt.previous = newTilt; - declarativeMap_->setTilt(newTilt); - } - if (activeGestures_ & RotationGesture) { - bool unlimitedRotation = (pinch_.rotation.minimum == 0.0 && pinch_.rotation.maximum == 0.0); - if ((pinch_.rotation.start >= pinch_.rotation.minimum && pinch_.rotation.start <= pinch_.rotation.maximum) || unlimitedRotation) { - qreal r = pinch_.rotation.angle * pinch_.rotation.factor + pinch_.rotation.start; - if (!unlimitedRotation) - r = qMin(qMax(pinch_.rotation.minimum,r), pinch_.rotation.maximum); - if (r > 360.0) - r -= 360; - if (r < -360.0) - r += 360.0; - declarativeMap_->setBearing(r); - } - } } /*! diff --git a/src/imports/location/qdeclarativegeomapgesturearea_p.h b/src/imports/location/qdeclarativegeomapgesturearea_p.h index 73235cf7..3b87bbe0 100644 --- a/src/imports/location/qdeclarativegeomapgesturearea_p.h +++ b/src/imports/location/qdeclarativegeomapgesturearea_p.h @@ -106,7 +106,7 @@ private: // tbd: should we have a 'active' / 'moving' boolean attribute when pinch is active? -// class QDeclarativeGeoMapGestureArea: public QObject // supporting pinching, panning, flicking, tilting +// class QDeclarativeGeoMapGestureArea: public QObject // supporting pinching, panning, flicking class QDeclarativeGeoMapGestureArea: public QObject { Q_OBJECT @@ -120,7 +120,6 @@ class QDeclarativeGeoMapGestureArea: public QObject Q_PROPERTY(bool isPanActive READ isPanActive) Q_PROPERTY(ActiveGestures activeGestures READ activeGestures WRITE setActiveGestures NOTIFY activeGesturesChanged) Q_PROPERTY(qreal maximumZoomLevelChange READ maximumZoomLevelChange WRITE setMaximumZoomLevelChange NOTIFY maximumZoomLevelChangeChanged) - Q_PROPERTY(qreal rotationFactor READ rotationFactor WRITE setRotationFactor NOTIFY rotationFactorChanged) Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) public: QDeclarativeGeoMapGestureArea(QDeclarativeGeoMap *map, QObject *parent = 0); @@ -129,10 +128,8 @@ public: enum ActiveGesture { NoGesture = 0x0000, ZoomGesture = 0x0001, - RotationGesture = 0x0002, - TiltGesture = 0x0004, - PanGesture = 0x0008, - FlickGesture = 0x0010 + PanGesture = 0x0002, + FlickGesture = 0x004 }; Q_DECLARE_FLAGS(ActiveGestures, ActiveGesture) @@ -155,9 +152,6 @@ public: qreal maximumZoomLevelChange() const; void setMaximumZoomLevelChange(qreal maxChange); - qreal rotationFactor() const; - void setRotationFactor(qreal factor); - qreal flickDeceleration() const; void setFlickDeceleration(qreal deceleration); @@ -184,7 +178,6 @@ Q_SIGNALS: void pinchActiveChanged(); void enabledChanged(); void maximumZoomLevelChangeChanged(); - void rotationFactorChanged(); void activeGesturesChanged(); void flickDecelerationChanged(); @@ -211,7 +204,7 @@ private: void startTwoTouchPoints(); void updateTwoTouchPoints(); - // All pinch related code, which encompasses zoom, rotation and tilt + // All pinch related code, which encompasses zoom void pinchStateMachine(); bool canStartPinch(); void startPinch(); @@ -254,24 +247,6 @@ private: qreal previous; qreal maximumChange; } zoom; - struct Rotation - { - Rotation() : minimum(0.0), maximum(0.0), start(0.0), angle(0.0), factor(1.0) {} - qreal minimum; - qreal maximum; - qreal start; - qreal angle; - qreal factor; - } rotation; - struct Tilt - { - Tilt() : minimum(0.0), maximum(90.0), maximumChange(20.0), previous(0.0), start(0.0) {} - qreal minimum; - qreal maximum; - qreal maximumChange; - qreal previous; - qreal start; - } tilt; QPointF lastPoint1; QPointF lastPoint2; |