summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Bugge Monsen <mmonsen@trolltech.com>2009-10-10 23:12:56 +0200
committerMarius Bugge Monsen <mmonsen@trolltech.com>2009-10-10 23:12:56 +0200
commit9dcf4c92947d0e968b48b20b604ac07f92c26d63 (patch)
treed6e2f34be23cd3f23149acd8e8195426459c8d28
parent9ddbb688c8c1b0ffdc45be7a7b6eb344fe0b5e28 (diff)
Re-enable animations in QGraphicsPathView.
-rw-r--r--src/experimental/qgraphicspathview.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/experimental/qgraphicspathview.cpp b/src/experimental/qgraphicspathview.cpp
index 40f995f..7ab8959 100644
--- a/src/experimental/qgraphicspathview.cpp
+++ b/src/experimental/qgraphicspathview.cpp
@@ -31,7 +31,7 @@
#include <qpainter.h>
#include <qstyle.h>
#include <qstyleoption.h>
-//#include <qtimeline.h>
+#include <qtimeline.h>
#include <qapplication.h>
QT_BEGIN_NAMESPACE
@@ -44,35 +44,37 @@ public:
void _q_currentChanged(int current, int previous);
QPainterPath path;
-// QTimeLine timeline;
+ QTimeLine timeline;
};
QtGraphicsPathViewPrivate::QtGraphicsPathViewPrivate()
: QtGraphicsListViewPrivate()
{
- //path.moveTo(50,0);
- //path.lineTo(50,100);
-
+ /*
+ path.moveTo(50,0);
+ path.lineTo(50,100);
+ *//**/
path.moveTo(0,0);
path.quadTo(QPointF(100, 25), QPointF(50,50));
path.quadTo(QPointF(0, 75), QPointF(100,100));
+ /**/
}
void QtGraphicsPathViewPrivate::_q_currentChanged(int current, int previous)
{
Q_UNUSED(current);
Q_UNUSED(previous);
- /*
+ /**/
QTimeLine::Direction direction = current > previous ? QTimeLine::Backward : QTimeLine::Forward;
if (previous == 0 && current == model->count() - 1)
direction = QTimeLine::Forward;
if (current == 0 && previous == model->count() - 1)
direction = QTimeLine::Backward;
timeline.stop();
- timeline.setDuration(200);
+ timeline.setDuration(1000);
timeline.setDirection(direction);
timeline.start();
- */
+ /**/
}
/*!
@@ -84,9 +86,7 @@ QtGraphicsPathView::QtGraphicsPathView(QGraphicsWidget *parent, Qt::WindowFlags
: QtGraphicsListView(*(new QtGraphicsPathViewPrivate), Qt::Vertical, parent, wFlags)
{
//Q_D(QtGraphicsPathView);
- //connect(&d->timeline, SIGNAL(valueChanged(qreal)), this, SLOT(setAnimationProgress(qreal)));
//connect(&d->timeline, SIGNAL(valueChanged(qreal)), this, SLOT(_q_update()));
- //connect(&d->timeline, SIGNAL(finished()), this, SLOT(clearAnimation()));
//connect(&d->timeline, SIGNAL(finished()), this, SLOT(update()));
}
@@ -160,14 +160,13 @@ void QtGraphicsPathView::doLayout()
qreal verticalFactor = (pathHeight > 0 ? (boundingRect.height() / pathHeight) : 1);
// animation
- bool running = false;//d->timeline.state() == QTimeLine::Running;
- bool forward = false;//d->timeline.direction() == QTimeLine::Forward;
- qreal progress = /*animationProgress()*/1 - (running && forward ? 1 : 0);
+ bool running = d->timeline.state() == QTimeLine::Running;
+ bool forward = d->timeline.direction() == QTimeLine::Forward;
+ qreal progress = (running ? (forward ? d->timeline.currentValue() - 1 : d->timeline.currentValue()) : 0);
while (!path.isEmpty() && counter < count) {
- //initStyleOption(&option, index);
qreal c = qreal(counter) + progress;
- QSizeF size = d->itemSize(index);
+ //QSizeF size = d->itemSize(index);
//qreal scale = (qreal(count - qAbs(c - (count / 2))) / qreal(count));
qreal t = qBound(qreal(0), c / qreal(count), qreal(1));
QPointF pos = path.pointAtPercent(t);