summaryrefslogtreecommitdiff
path: root/src/imports/location/qdeclarativegeomappincharea_p.h
diff options
context:
space:
mode:
authorThomas Lowe <thomas.lowe@nokia.com>2012-04-19 09:12:04 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-02 04:41:22 +0200
commit894f0e1143987f9280d5167089a03fdaa0c3e465 (patch)
tree706635ab60255f48d35fe8d5e85cb75a3deb2dc8 /src/imports/location/qdeclarativegeomappincharea_p.h
parentc42e8cf82f314f153a6b1dbae998d4409438da97 (diff)
downloadqtlocation-894f0e1143987f9280d5167089a03fdaa0c3e465.tar.gz
Combined mapFlickable and mapPinchArea into single object mapGestureArea
Concept changes: - 'flick' and 'pinch' are combined to a single 'gesture' object which can use any subset of pan, flick, zoom, rotate and tilt - 'flick' is a type of pan. So map.flick.enabled (which enabled panning and flicking) is now map.gesture.panEnabled. (Old interface also remains) Code changes: - new mapGesture now handles the logic for pinch, pan and flick gestures - mapFlickable and mapPinchArea objects still exist as sham objects for backwards compatibility - so public interface has not changed - Internal logic basically the same but made explicit by using a simple state machine format: - logic related to the touch and mouse events is handled by a touchPointStateMachine function - logic related to panning (and hence flicking) handled by panStateMachine, and is independent of the number of touch points - logic related to pinching (zoom, tilt, rotate) handled by the pinchStateMachine function - the pan and pinch state machines rely on the data from the touch point state machine Task-number: QTBUG-25131 Functionality changes: - pan operates correctly with two touch points, pans around the center of them - pinch gestures act around the center of the touch points Interface changes: - new map.gesture property which roughly contains the combined properties of map.flick and map.pinch Dependencies: - currently a workaround is checked in under #define TOUCH_EVENT_WORKAROUND. The correct fix is dependent on https://codereview.qt-project.org/#change,21896 Questions: - should we keep map.gesture.panEnabled and map.gesture.pinchEnabled after 5.0.0 or just keep map.gesture.enabled? - should disabling be immediate or wait until the current gesture has ended? Currently keeps the old functionality which is to wait with the pinch and immediate with the pan. - should pan and pinch go into separate structures inside gesture, in order to keep the class complexity manageable? Change-Id: Ia5cee3a9d82cfadfaa3862242950ed2a125209e8 Reviewed-by: Alex Wilson <alex.wilson@nokia.com>
Diffstat (limited to 'src/imports/location/qdeclarativegeomappincharea_p.h')
-rw-r--r--src/imports/location/qdeclarativegeomappincharea_p.h209
1 files changed, 76 insertions, 133 deletions
diff --git a/src/imports/location/qdeclarativegeomappincharea_p.h b/src/imports/location/qdeclarativegeomappincharea_p.h
index 34619aeb..309e735c 100644
--- a/src/imports/location/qdeclarativegeomappincharea_p.h
+++ b/src/imports/location/qdeclarativegeomappincharea_p.h
@@ -46,6 +46,9 @@
#include <QTouchEvent>
#include <QObject>
#include <QDebug>
+#include <QElapsedTimer>
+#include "qgeocoordinate.h"
+#include "qdeclarativegeomapgesturearea_p.h"
QT_BEGIN_NAMESPACE
@@ -53,55 +56,9 @@ class QGraphicsSceneMouseEvent;
class QDeclarativeGeoMap;
class QTouchEvent;
class QGeoMap;
+class QPropertyAnimation;
-class QDeclarativeGeoMapPinchEvent : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QPointF center READ center)
- Q_PROPERTY(qreal angle READ angle)
- Q_PROPERTY(QPointF point1 READ point1)
- Q_PROPERTY(QPointF point2 READ point2)
- Q_PROPERTY(int pointCount READ pointCount)
- Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
-
-public:
- QDeclarativeGeoMapPinchEvent(QPointF center, qreal angle,
- QPointF point1, QPointF point2,
- int pointCount = 0, bool accepted = true)
- : QObject(), center_(center), angle_(angle),
- point1_(point1), point2_(point2),
- pointCount_(pointCount), accepted_(accepted) {}
- QDeclarativeGeoMapPinchEvent()
- : QObject(),
- angle_(0.0),
- pointCount_(0),
- accepted_(true) {}
-
- QPointF center() const { return center_; }
- void setCenter(QPointF center) { center_ = center; }
- qreal angle() const { return angle_; }
- void setAngle(qreal angle) { angle_ = angle; }
- QPointF point1() const { return point1_; }
- void setPoint1(QPointF p) { point1_ = p; }
- QPointF point2() const { return point2_; }
- void setPoint2(QPointF p) { point2_ = p; }
- int pointCount() const { return pointCount_; }
- void setPointCount(int count) { pointCount_ = count; }
- bool accepted() const { return accepted_; }
- void setAccepted(bool a) { accepted_ = a; }
-
-private:
- QPointF center_;
- qreal angle_;
- QPointF point1_;
- QPointF point2_;
- int pointCount_;
- bool accepted_;
-};
-
-// tbd: should we have a 'active' / 'moving' boolean attribute when pinch is active?
-
+// Note: this class id being deprecated, please use the gestureArea instead
class QDeclarativeGeoMapPinchArea: public QObject
{
Q_OBJECT
@@ -113,18 +70,10 @@ class QDeclarativeGeoMapPinchArea: public QObject
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)
- // need for these is not clear, use-case(s) not yet identified:
- //Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged)
- //Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged)
- //Q_PROPERTY(qreal minimumZoomLevel READ minimumZoomLevel WRITE setMinimumZoomLevel NOTIFY minimumZoomLevelChanged)
- //Q_PROPERTY(qreal maximumZoomLevel READ maximumZoomLevel WRITE setMaximumZoomLevel NOTIFY maximumZoomLevelChanged)
- // when tilt is supported, these are needed:
- //Q_PROPERTY(qreal maximumTilt READ maximumTilt WRITE setMaximumTilt NOTIFY maximumTiltChanged)
- //Q_PROPERTY(qreal minimumTilt READ minimumTilt WRITE setMinimumTilt NOTIFY minimumTiltChanged)
- //Q_PROPERTY(qreal maximumTiltChange READ maximumTiltChange WRITE setMaximumTiltChange NOTIFY maximumTiltChangeChanged)
+ Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
public:
- QDeclarativeGeoMapPinchArea(QDeclarativeGeoMap* map, QObject *parent = 0);
+ QDeclarativeGeoMapPinchArea(QObject *parent, QDeclarativeGeoMapGestureArea *gestureArea);
~QDeclarativeGeoMapPinchArea();
enum ActiveGesture {
@@ -134,46 +83,73 @@ public:
TiltGesture = 0x0004
};
Q_DECLARE_FLAGS(ActiveGestures, ActiveGesture);
-
- ActiveGestures activeGestures() const;
- void setActiveGestures(ActiveGestures activeGestures);
-
- bool active() const;
- void setActive(bool active);
-
- bool enabled() const;
- void setEnabled(bool enabled);
-
- qreal minimumZoomLevel() const;
- void setMinimumZoomLevel(qreal zoomLevel);
-
- qreal maximumZoomLevel() const;
- void setMaximumZoomLevel(qreal zoomLevel);
-
- qreal maximumZoomLevelChange() const;
- void setMaximumZoomLevelChange(qreal maxChange);
-
- qreal minimumRotation() const;
- void setMinimumRotation(qreal zoomLevel);
-
- qreal maximumRotation() const;
- void setMaximumRotation(qreal zoomLevel);
-
- qreal rotationFactor() const;
- void setRotationFactor(qreal factor);
-
- qreal maximumTilt() const;
- void setMaximumTilt(qreal tilt);
-
- qreal minimumTilt() const;
- void setMinimumTilt(qreal tilt);
-
- qreal maximumTiltChange() const;
- void setMaximumTiltChange(qreal tilt);
-
- void touchEvent(QTouchEvent *event);
-
- void zoomLevelLimits(qreal min, qreal max);
+ ActiveGestures activeGestures()
+ {
+ QDeclarativeGeoMapGestureArea::ActiveGestures gestures = gestureArea_->activeGestures();
+ activeGestures_ &= 0; // reset;
+ if (gestures & QDeclarativeGeoMapGestureArea::ZoomGesture)
+ activeGestures_ |= ZoomGesture;
+ if (gestures & QDeclarativeGeoMapGestureArea::RotationGesture)
+ activeGestures_ |= RotationGesture;
+ if (gestures & QDeclarativeGeoMapGestureArea::TiltGesture)
+ activeGestures_ |= TiltGesture;
+ return activeGestures_;
+ }
+ void setActiveGestures(ActiveGestures activeGestures)
+ {
+ if (activeGestures == activeGestures_)
+ return;
+ activeGestures_ = activeGestures;
+ QDeclarativeGeoMapGestureArea::ActiveGestures &gestures = gestureArea_->activeGestures_;
+ gestures &= ~7; // reset the pinch component;
+ if (activeGestures & ZoomGesture)
+ gestures |= QDeclarativeGeoMapGestureArea::ZoomGesture;
+ if (activeGestures & RotationGesture)
+ gestures |= QDeclarativeGeoMapGestureArea::RotationGesture;
+ if (activeGestures & TiltGesture)
+ gestures |= QDeclarativeGeoMapGestureArea::TiltGesture;
+ emit gestureArea_->activeGesturesChanged();
+ emit activeGesturesChanged();
+ }
+
+ bool active() const { return gestureArea_->isPinchActive(); }
+ void setActive(bool active) { gestureArea_->setPinchActive(active); }
+
+ bool enabled() const { return gestureArea_->pinchEnabled(); }
+ void setEnabled(bool enabled){ gestureArea_->setPinchEnabled(enabled); }
+
+ qreal minimumZoomLevel() const { return gestureArea_->minimumZoomLevel(); }
+ void setMinimumZoomLevel(qreal zoomLevel){ gestureArea_->setMinimumZoomLevel(zoomLevel); }
+
+ qreal maximumZoomLevel() const { return gestureArea_->maximumZoomLevel(); }
+ void setMaximumZoomLevel(qreal zoomLevel){ gestureArea_->setMaximumZoomLevel(zoomLevel); }
+
+ qreal maximumZoomLevelChange() const { return gestureArea_->maximumZoomLevelChange(); }
+ void setMaximumZoomLevelChange(qreal maxChange){ gestureArea_->setMaximumZoomLevelChange(maxChange); }
+
+ qreal minimumRotation() const { return gestureArea_->minimumRotation(); }
+ void setMinimumRotation(qreal zoomLevel){ gestureArea_->setMinimumRotation(zoomLevel); }
+
+ qreal maximumRotation() const { return gestureArea_->maximumRotation(); }
+ void setMaximumRotation(qreal zoomLevel){ gestureArea_->setMaximumRotation(zoomLevel); }
+
+ qreal rotationFactor() const { return gestureArea_->rotationFactor(); }
+ void setRotationFactor(qreal factor){ gestureArea_->setRotationFactor(factor); }
+
+ qreal maximumTilt() const { return gestureArea_->maximumTilt(); }
+ void setMaximumTilt(qreal tilt){ gestureArea_->setMaximumTilt(tilt); }
+
+ qreal minimumTilt() const { return gestureArea_->minimumTilt(); }
+ void setMinimumTilt(qreal tilt){ gestureArea_->setMinimumTilt(tilt); }
+
+ qreal maximumTiltChange() const { return gestureArea_->maximumTiltChange(); }
+ void setMaximumTiltChange(qreal tilt){ gestureArea_->setMaximumTiltChange(tilt); }
+
+ qreal flickDeceleration() const { return gestureArea_->flickDeceleration(); }
+ void setFlickDeceleration(qreal deceleration){ gestureArea_->setFlickDeceleration(deceleration); }
+
+ void zoomLevelLimits(qreal min, qreal max){ gestureArea_->zoomLevelLimits(min, max); }
+ void setMap(QGeoMap* map){ gestureArea_->setMap(map); }
signals:
void activeChanged();
@@ -188,48 +164,15 @@ signals:
void minimumTiltChanged();
void maximumTiltChanged();
void maximumTiltChangeChanged();
+ void flickDecelerationChanged();
void pinchStarted(QDeclarativeGeoMapPinchEvent* pinch);
void pinchUpdated(QDeclarativeGeoMapPinchEvent* pinch);
void pinchFinished(QDeclarativeGeoMapPinchEvent* pinch);
private:
- void updatePinch();
-
-private:
- QDeclarativeGeoMap* map_;
- QDeclarativeGeoMapPinchEvent pinchEvent_;
- bool enabled_;
- bool active_;
- qreal minimumZoomLevel_;
- qreal maximumZoomLevel_;
- qreal minimumRotation_;
- qreal maximumRotation_;
- QList<QTouchEvent::TouchPoint> touchPoints_;
- bool inPinch_;
- bool pinchRejected_;
- bool pinchActivated_;
- QPointF sceneStartPoint1_;
- QPointF sceneStartPoint2_;
- QPointF lastPoint1_;
- QPointF lastPoint2_;
- qreal pinchStartDist_;
- qreal pinchStartZoomLevel_;
- qreal pinchLastZoomLevel_;
- qreal pinchStartRotation_;
- qreal pinchLastAngle_;
- qreal pinchRotation_;
- QPointF sceneLastCenter_;
- int id1_;
- qreal maximumZoomLevelChange_;
- qreal rotationFactor_;
+ QDeclarativeGeoMapGestureArea *gestureArea_; // the destination for this wrapper class
ActiveGestures activeGestures_;
- qreal minimumTilt_;
- qreal maximumTilt_;
- qreal maximumTiltChange_;
-
- qreal pinchLastTilt_;
- qreal pinchStartTilt_;
};
QT_END_NAMESPACE