summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-22 03:35:10 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-22 03:35:10 (GMT)
commit47862497693ffac597557f940535909df549d897 (patch)
tree955c2c9d0f014e79ec6f3fe801f2e2baa4b4bfa1 /src/declarative
parentfb94bfda66ac8767c96cb521a1f77c6b8be5bb95 (diff)
downloadQt-47862497693ffac597557f940535909df549d897.zip
Qt-47862497693ffac597557f940535909df549d897.tar.gz
Qt-47862497693ffac597557f940535909df549d897.tar.bz2
Replace Flickable overshoot property with boundsBehavior
Task-number: QTBUG-9993
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/QmlChanges.txt5
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp62
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p.h9
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp1
6 files changed, 63 insertions, 17 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 2cae293..55f7b21 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -1,4 +1,9 @@
=============================================================================
+The changes below are pre Qt 4.7.0 RC
+
+Flickable: overShoot is replaced by boundsBehavior enumeration.
+
+=============================================================================
The changes below are pre Qt 4.7.0 beta
TextEdit: wrap property is replaced by wrapMode enumeration.
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 7b9b5e0..b462443 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -41,7 +41,7 @@
#include "private/qdeclarativeflickable_p.h"
#include "private/qdeclarativeflickable_p_p.h"
-
+#include <qdeclarativeinfo.h>
#include <QGraphicsSceneMouseEvent>
#include <QPointer>
#include <QTimer>
@@ -125,12 +125,13 @@ QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate()
: viewport(new QDeclarativeItem)
, hData(this, &QDeclarativeFlickablePrivate::setRoundedViewportX)
, vData(this, &QDeclarativeFlickablePrivate::setRoundedViewportY)
- , overShoot(true), flicked(false), moving(false), stealMouse(false)
+ , flicked(false), moving(false), stealMouse(false)
, pressed(false)
, interactive(true), deceleration(500), maxVelocity(2000), reportedVelocitySmoothing(100)
, delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(600)
, vTime(0), visibleArea(0)
, flickDirection(QDeclarativeFlickable::AutoFlickDirection)
+ , boundsBehavior(QDeclarativeFlickable::DragAndOvershootBounds)
{
}
@@ -203,6 +204,7 @@ void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal
{
Q_Q(QDeclarativeFlickable);
qreal maxDistance = -1;
+ bool overShoot = boundsBehavior == QDeclarativeFlickable::DragAndOvershootBounds;
// -ve velocity means list is moving up
if (velocity > 0) {
if (data.move.value() < minExtent)
@@ -646,7 +648,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
newY = minY + (newY - minY) / 2;
if (newY < maxY && maxY - minY <= 0)
newY = maxY + (newY - maxY) / 2;
- if (!q->overShoot() && (newY > minY || newY < maxY)) {
+ if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newY > minY || newY < maxY)) {
if (newY > minY)
newY = minY;
else if (newY < maxY)
@@ -673,7 +675,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
newX = minX + (newX - minX) / 2;
if (newX < maxX && maxX - minX <= 0)
newX = maxX + (newX - maxX) / 2;
- if (!q->overShoot() && (newX > minX || newX < maxX)) {
+ if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newX > minX || newX < maxX)) {
if (newX > minX)
newX = minX;
else if (newX < maxX)
@@ -997,28 +999,58 @@ QDeclarativeListProperty<QGraphicsObject> QDeclarativeFlickable::flickableChildr
return QGraphicsItemPrivate::get(d->viewport)->childrenList();
}
+bool QDeclarativeFlickable::overShoot() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->boundsBehavior == DragAndOvershootBounds;
+}
+
+void QDeclarativeFlickable::setOverShoot(bool o)
+{
+ Q_D(QDeclarativeFlickable);
+ if ((o && d->boundsBehavior == DragAndOvershootBounds)
+ || (!o && d->boundsBehavior == StopAtBounds))
+ return;
+ qmlInfo(this) << "overshoot is deprecated and will be removed imminently - use boundsBehavior.";
+ d->boundsBehavior = o ? DragAndOvershootBounds : StopAtBounds;
+ emit boundsBehaviorChanged();
+ emit overShootChanged();
+}
+
/*!
- \qmlproperty bool Flickable::overShoot
- This property holds whether the surface may overshoot the
+ \qmlproperty enumeration Flickable::boundsBehavior
+ This property holds whether the surface may be dragged
+ beyond the Fickable's boundaries, or overshoot the
Flickable's boundaries when flicked.
- If overShoot is true the contents can be flicked beyond the boundary
- of the Flickable before being moved back to the boundary. This provides
- the feeling that the edges of the view are soft, rather than a hard
- physical boundary.
+ This enables the feeling that the edges of the view are soft,
+ rather than a hard physical boundary.
+
+ boundsBehavior can be one of:
+
+ \list
+ \o \e StopAtBounds - the contents can not be dragged beyond the boundary
+ of the flickable, and flicks will not overshoot.
+ \o \e DragOverBounds - the contents can be dragged beyond the boundary
+ of the Flickable, but flicks will not overshoot.
+ \o \e DragAndOvershootBounds (default) - the contents can be dragged
+ beyond the boundary of the Flickable, and can overshoot the
+ boundary when flicked.
+ \endlist
*/
-bool QDeclarativeFlickable::overShoot() const
+QDeclarativeFlickable::BoundsBehavior QDeclarativeFlickable::boundsBehavior() const
{
Q_D(const QDeclarativeFlickable);
- return d->overShoot;
+ return d->boundsBehavior;
}
-void QDeclarativeFlickable::setOverShoot(bool o)
+void QDeclarativeFlickable::setBoundsBehavior(BoundsBehavior b)
{
Q_D(QDeclarativeFlickable);
- if (d->overShoot == o)
+ if (b == d->boundsBehavior)
return;
- d->overShoot = o;
+ d->boundsBehavior = b;
+ emit boundsBehaviorChanged();
emit overShootChanged();
}
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
index 1fa2c74..f031a24 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
@@ -64,7 +64,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem
Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
- Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot NOTIFY overShootChanged)
+ Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot NOTIFY overShootChanged) // deprecated
+ Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
@@ -86,6 +87,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem
Q_CLASSINFO("DefaultProperty", "flickableData")
Q_ENUMS(FlickDirection)
+ Q_ENUMS(BoundsBehavior)
public:
QDeclarativeFlickable(QDeclarativeItem *parent=0);
@@ -97,6 +99,10 @@ public:
bool overShoot() const;
void setOverShoot(bool);
+ enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
+ BoundsBehavior boundsBehavior() const;
+ void setBoundsBehavior(BoundsBehavior);
+
qreal contentWidth() const;
void setContentWidth(qreal);
@@ -156,6 +162,7 @@ Q_SIGNALS:
void flickDirectionChanged();
void interactiveChanged();
void overShootChanged();
+ void boundsBehaviorChanged();
void maximumFlickVelocityChanged();
void flickDecelerationChanged();
void pressDelayChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
index 1a04091..01cfb18 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
@@ -131,7 +131,6 @@ public:
AxisData vData;
QDeclarativeTimeLine timeline;
- bool overShoot : 1;
bool flicked : 1;
bool moving : 1;
bool stealMouse : 1;
@@ -160,6 +159,7 @@ public:
QDeclarativeTimeLine velocityTimeline;
QDeclarativeFlickableVisibleArea *visibleArea;
QDeclarativeFlickable::FlickDirection flickDirection;
+ QDeclarativeFlickable::BoundsBehavior boundsBehavior;
void handleMousePressEvent(QGraphicsSceneMouseEvent *);
void handleMouseMoveEvent(QGraphicsSceneMouseEvent *);
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index f6666f2..f8b773e 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -831,6 +831,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
if (snapMode == QDeclarativeGridView::NoSnap && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
data.flickTarget = maxExtent;
}
+ bool overShoot = boundsBehavior == QDeclarativeFlickable::DragAndOvershootBounds;
if (maxDistance > 0 || overShoot) {
// This mode requires the grid to stop exactly on a row boundary.
qreal v = velocity;
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index a4ca651..60e8f6c 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -1190,6 +1190,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
if (snapMode == QDeclarativeListView::NoSnap && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
data.flickTarget = maxExtent;
}
+ bool overShoot = boundsBehavior == QDeclarativeFlickable::DragAndOvershootBounds;
if (maxDistance > 0 || overShoot) {
// These modes require the list to stop exactly on an item boundary.
// The initial flick will estimate the boundary to stop on.