diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-12-29 14:32:42 +0100 |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2010-12-29 14:32:42 +0100 |
commit | 16977ad4af73ba31e6b80a8baf19f43a3729342c (patch) | |
tree | 46081febfd0f2d1d7c2a841ae863b000ff0dbb17 | |
parent | 535a1209735a035eb8454fba784e887ba59eaa6b (diff) |
Make PathView usable with qt-scene-graph.
We need this patch until we have a better replacement for QxPathView :-)
It is almost impossible to flick without this patch.
-rw-r--r-- | src/graphicsitems/qxpathview.cpp | 17 | ||||
-rw-r--r-- | src/graphicsitems/qxpathview_p.h | 4 | ||||
-rw-r--r-- | src/graphicsitems/qxpathview_p_p.h | 3 |
3 files changed, 23 insertions, 1 deletions
diff --git a/src/graphicsitems/qxpathview.cpp b/src/graphicsitems/qxpathview.cpp index 19c8b50..54a1dbd 100644 --- a/src/graphicsitems/qxpathview.cpp +++ b/src/graphicsitems/qxpathview.cpp @@ -955,7 +955,7 @@ void QxPathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) if (!d->stealMouse) { QPointF delta = event->pos() - d->startPoint; - if (qAbs(delta.x()) > QApplication::startDragDistance() && qAbs(delta.y()) > QApplication::startDragDistance()) + if (qAbs(delta.x()) > QApplication::startDragDistance() || qAbs(delta.y()) > QApplication::startDragDistance()) d->stealMouse = true; } @@ -976,6 +976,11 @@ void QxPathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) d->lastDist = diff; d->startPc = newPc; } + if (!d->moving) { + d->moving = true; + emit movingChanged(); + emit movementStarted(); + } } } @@ -1348,6 +1353,16 @@ void QxPathView::ticked() d->updateCurrent(); } +void QxPathView::onTimeLineCompleted() +{ + Q_D(QxPathView); + if (d->moving && !d->stealMouse) { + d->moving = false; + emit movingChanged(); + emit movementEnded(); + } +} + // find the item closest to the snap position int QxPathViewPrivate::calcCurrentIndex() { diff --git a/src/graphicsitems/qxpathview_p.h b/src/graphicsitems/qxpathview_p.h index f1958b8..0c43bba 100644 --- a/src/graphicsitems/qxpathview_p.h +++ b/src/graphicsitems/qxpathview_p.h @@ -136,6 +136,9 @@ Q_SIGNALS: void modelChanged(); void countChanged(); void pathChanged(); + void movingChanged(); + void movementStarted(); + void movementEnded(); void preferredHighlightBeginChanged(); void preferredHighlightEndChanged(); void highlightRangeModeChanged(); @@ -161,6 +164,7 @@ protected: private Q_SLOTS: void refill(); void ticked(); + void onTimeLineCompleted(); void itemsInserted(int index, int count); void itemsRemoved(int index, int count); void itemsMoved(int,int,int); diff --git a/src/graphicsitems/qxpathview_p_p.h b/src/graphicsitems/qxpathview_p_p.h index 290e091..210cc7c 100644 --- a/src/graphicsitems/qxpathview_p_p.h +++ b/src/graphicsitems/qxpathview_p_p.h @@ -77,6 +77,7 @@ public: , lastElapsed(0), mappedRange(1.0) , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true) , autoHighlight(true), highlightUp(false), layoutScheduled(false) + , moving(false) , dragMargin(0), deceleration(100) , moveOffset(this, &QxPathViewPrivate::setOffset) , firstIndex(-1), pathItems(-1), requestedIndex(-1) @@ -96,6 +97,7 @@ public: isFocusScope = true; q->setFiltersChildEvents(true); q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked())); + q->connect(&tl, SIGNAL(completed()), q, SLOT(onTimeLineCompleted())); lastPosTime.invalidate(); } @@ -154,6 +156,7 @@ public: bool autoHighlight : 1; bool highlightUp : 1; bool layoutScheduled : 1; + bool moving; QElapsedTimer lastPosTime; QPointF lastPos; qreal dragMargin; |