summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
authorA-Team <ateam@pad.test.qt.nokia.com>2010-11-24 23:00:17 (GMT)
committerA-Team <ateam@pad.test.qt.nokia.com>2010-11-24 23:00:17 (GMT)
commitc2e21fea3cd670127a898ac2ff5abd8135bde5f0 (patch)
treebf49e35e7dffe54301aab6cae5874977bc696496 /src/declarative/graphicsitems
parentbe28cdcc51a8c22151199bcf8cd171e28287e8d0 (diff)
parent422282c4f3e439990abc6c6b79699d943b9541d7 (diff)
downloadQt-c2e21fea3cd670127a898ac2ff5abd8135bde5f0.zip
Qt-c2e21fea3cd670127a898ac2ff5abd8135bde5f0.tar.gz
Qt-c2e21fea3cd670127a898ac2ff5abd8135bde5f0.tar.bz2
Merge branch '4.7-upstream' into 4.7-doc
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp16
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp37
3 files changed, 42 insertions, 19 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 1870647..377f3b5 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -281,7 +281,6 @@ void QDeclarativeFlickablePrivate::fixupY()
void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent)
{
- Q_Q(QDeclarativeFlickable);
if (data.move.value() > minExtent || maxExtent > minExtent) {
timeline.reset(data.move);
if (data.move.value() != minExtent) {
@@ -290,8 +289,7 @@ void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal
timeline.move(data.move, minExtent - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
timeline.move(data.move, minExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4);
} else {
- data.move.setValue(minExtent);
- q->viewportMoved();
+ timeline.set(data.move, minExtent);
}
}
} else if (data.move.value() < maxExtent) {
@@ -301,8 +299,7 @@ void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal
timeline.move(data.move, maxExtent - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
timeline.move(data.move, maxExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4);
} else {
- data.move.setValue(maxExtent);
- q->viewportMoved();
+ timeline.set(data.move, minExtent);
}
}
vTime = timeline.time();
@@ -703,6 +700,9 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
bool rejectY = false;
bool rejectX = false;
+ bool stealY = false;
+ bool stealX = false;
+
if (q->yflick()) {
int dy = int(event->pos().y() - pressPos.y());
if (qAbs(dy) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) {
@@ -731,7 +731,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
vMoved = true;
}
if (qAbs(dy) > QApplication::startDragDistance())
- stealMouse = true;
+ stealY = true;
}
}
@@ -764,10 +764,12 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
}
if (qAbs(dx) > QApplication::startDragDistance())
- stealMouse = true;
+ stealX = true;
}
}
+ stealMouse = stealX || stealY;
+
if (!lastPos.isNull()) {
qreal elapsed = qreal(QDeclarativeItemPrivate::restart(lastPosTime)) / 1000.;
if (elapsed <= 0)
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 6be49ba..450b6af 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -183,6 +183,7 @@ public:
, ownModel(false), wrap(false), autoHighlight(true), haveHighlightRange(false)
, correctFlick(false), inFlickCorrection(false), lazyRelease(false)
, deferredRelease(false), layoutScheduled(false), currentIndexCleared(false)
+ , inViewportMoved(false)
, minExtentDirty(true), maxExtentDirty(true)
{}
@@ -503,6 +504,7 @@ public:
bool deferredRelease : 1;
bool layoutScheduled : 1;
bool currentIndexCleared : 1;
+ bool inViewportMoved : 1;
mutable bool minExtentDirty : 1;
mutable bool maxExtentDirty : 1;
};
@@ -2281,6 +2283,10 @@ void QDeclarativeListView::viewportMoved()
QDeclarativeFlickable::viewportMoved();
if (!d->itemCount)
return;
+ // Recursion can occur due to refill changing the content size.
+ if (d->inViewportMoved)
+ return;
+ d->inViewportMoved = true;
d->lazyRelease = true;
refill();
if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically)
@@ -2294,6 +2300,7 @@ void QDeclarativeListView::viewportMoved()
pos = viewPos + d->highlightRangeEnd - d->highlight->size();
if (pos < viewPos + d->highlightRangeStart)
pos = viewPos + d->highlightRangeStart;
+ d->highlightPosAnimator->stop();
d->highlight->setPosition(qRound(pos));
// update current index
@@ -2341,6 +2348,7 @@ void QDeclarativeListView::viewportMoved()
}
d->inFlickCorrection = false;
}
+ d->inViewportMoved = false;
}
qreal QDeclarativeListView::minYExtent() const
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index d9edd11..0a043a7 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -500,17 +500,9 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
const int dragThreshold = QApplication::startDragDistance();
qreal dx = qAbs(curLocalPos.x() - startLocalPos.x());
qreal dy = qAbs(curLocalPos.y() - startLocalPos.y());
- if ((d->dragX && !(dx < dragThreshold)) || (d->dragY && !(dy < dragThreshold))) {
+
+ if (keepMouseGrab() && d->stealMouse)
d->drag->setActive(true);
- d->stealMouse = true;
- }
- if (!keepMouseGrab()) {
- if ((!d->dragY && dy < dragThreshold && d->dragX && dx > dragThreshold)
- || (!d->dragX && dx < dragThreshold && d->dragY && dy > dragThreshold)
- || (d->dragX && d->dragY)) {
- setKeepMouseGrab(true);
- }
- }
if (d->dragX && d->drag->active()) {
qreal x = (curLocalPos.x() - startLocalPos.x()) + d->startX;
@@ -528,6 +520,16 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
y = drag()->ymax();
drag()->target()->setY(y);
}
+
+ if (!keepMouseGrab()) {
+ if ((!d->dragY && dy < dragThreshold && d->dragX && dx > dragThreshold)
+ || (!d->dragX && dx < dragThreshold && d->dragY && dy > dragThreshold)
+ || (d->dragX && d->dragY && (dx > dragThreshold || dy > dragThreshold))) {
+ setKeepMouseGrab(true);
+ d->stealMouse = true;
+ }
+ }
+
d->moved = true;
}
QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
@@ -618,6 +620,7 @@ bool QDeclarativeMouseArea::sceneEvent(QEvent *event)
// if our mouse grab has been removed (probably by Flickable), fix our
// state
d->pressed = false;
+ d->stealMouse = false;
setKeepMouseGrab(false);
emit canceled();
emit pressedChanged();
@@ -672,8 +675,18 @@ bool QDeclarativeMouseArea::sendMouseEvent(QGraphicsSceneMouseEvent *event)
return stealThisEvent;
}
if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) {
- d->stealMouse = false;
- ungrabMouse();
+ if (d->pressed) {
+ d->pressed = false;
+ d->stealMouse = false;
+ if (s && s->mouseGrabberItem() == this)
+ ungrabMouse();
+ emit canceled();
+ emit pressedChanged();
+ if (d->hovered) {
+ d->hovered = false;
+ emit hoveredChanged();
+ }
+ }
}
return false;
}