From 8bbe895759bc32d6a005d3308f04179a7931348c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 22 Feb 2010 11:24:48 +1000 Subject: Increase durations when testing Behaviors. This should make the tests at least somewhat more reliable. --- .../auto/declarative/qmlbehaviors/data/binding.qml | 2 +- tests/auto/declarative/qmlbehaviors/data/color.qml | 2 +- .../declarative/qmlbehaviors/data/cpptrigger.qml | 2 +- .../declarative/qmlbehaviors/data/explicit.qml | 2 +- .../qmlbehaviors/data/groupProperty.qml | 2 +- .../qmlbehaviors/data/groupProperty2.qml | 2 +- .../auto/declarative/qmlbehaviors/data/parent.qml | 2 +- .../qmlbehaviors/data/scripttrigger.qml | 2 +- .../auto/declarative/qmlbehaviors/data/simple.qml | 2 +- .../declarative/qmlbehaviors/tst_qmlbehaviors.cpp | 30 +++++++++++----------- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/auto/declarative/qmlbehaviors/data/binding.qml b/tests/auto/declarative/qmlbehaviors/data/binding.qml index e0c3321..18d6764 100644 --- a/tests/auto/declarative/qmlbehaviors/data/binding.qml +++ b/tests/auto/declarative/qmlbehaviors/data/binding.qml @@ -9,7 +9,7 @@ Rectangle { objectName: "MyRect" width: 100; height: 100; color: "green" x: basex - x: Behavior { NumberAnimation { duration: 200; } } + x: Behavior { NumberAnimation { duration: 500; } } } MouseRegion { id: clicker diff --git a/tests/auto/declarative/qmlbehaviors/data/color.qml b/tests/auto/declarative/qmlbehaviors/data/color.qml index 6598703..aac7283 100644 --- a/tests/auto/declarative/qmlbehaviors/data/color.qml +++ b/tests/auto/declarative/qmlbehaviors/data/color.qml @@ -7,7 +7,7 @@ Rectangle { objectName: "MyRect" width: 100; height: 100; color: "green" - color: Behavior { ColorAnimation { duration: 200; } } + color: Behavior { ColorAnimation { duration: 500; } } } MouseRegion { id: clicker diff --git a/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml b/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml index ba507c4..8d032f0 100644 --- a/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml +++ b/tests/auto/declarative/qmlbehaviors/data/cpptrigger.qml @@ -6,6 +6,6 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { NumberAnimation { duration: 200; } } + x: Behavior { NumberAnimation { duration: 500; } } } } diff --git a/tests/auto/declarative/qmlbehaviors/data/explicit.qml b/tests/auto/declarative/qmlbehaviors/data/explicit.qml index ba36d93..bb17076 100644 --- a/tests/auto/declarative/qmlbehaviors/data/explicit.qml +++ b/tests/auto/declarative/qmlbehaviors/data/explicit.qml @@ -8,7 +8,7 @@ Rectangle { width: 100; height: 100; color: "green" x: Behavior { objectName: "MyBehavior"; - NumberAnimation { target: rect; property: "x"; duration: 200; } + NumberAnimation { target: rect; property: "x"; duration: 500; } } } MouseRegion { diff --git a/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml b/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml index 4f127c1..8a734c1 100644 --- a/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml +++ b/tests/auto/declarative/qmlbehaviors/data/groupProperty.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - pos: Behavior { PropertyAnimation { duration: 200; } } + pos: Behavior { PropertyAnimation { duration: 500; } } } MouseRegion { id: clicker diff --git a/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml b/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml index 19d70b6..602ffbb 100644 --- a/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml +++ b/tests/auto/declarative/qmlbehaviors/data/groupProperty2.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - pos.x: Behavior { NumberAnimation { duration: 200; } } + pos.x: Behavior { NumberAnimation { duration: 500; } } } MouseRegion { id: clicker diff --git a/tests/auto/declarative/qmlbehaviors/data/parent.qml b/tests/auto/declarative/qmlbehaviors/data/parent.qml index 4f4911b..7c7fdcb 100644 --- a/tests/auto/declarative/qmlbehaviors/data/parent.qml +++ b/tests/auto/declarative/qmlbehaviors/data/parent.qml @@ -8,7 +8,7 @@ Rectangle { width: 100; height: 100; color: "green" parent: Behavior { SequentialAnimation { - PauseAnimation { duration: 200 } + PauseAnimation { duration: 500 } PropertyAction {} } } diff --git a/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml b/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml index 4383a0b..a91ca88 100644 --- a/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml +++ b/tests/auto/declarative/qmlbehaviors/data/scripttrigger.qml @@ -11,6 +11,6 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { NumberAnimation { duration: 200; } } + x: Behavior { NumberAnimation { duration: 500; } } } } diff --git a/tests/auto/declarative/qmlbehaviors/data/simple.qml b/tests/auto/declarative/qmlbehaviors/data/simple.qml index 37c3915..c08a1f0 100644 --- a/tests/auto/declarative/qmlbehaviors/data/simple.qml +++ b/tests/auto/declarative/qmlbehaviors/data/simple.qml @@ -8,7 +8,7 @@ Rectangle { width: 100; height: 100; color: "green" x: Behavior { objectName: "MyBehavior"; - NumberAnimation { duration: 200; } + NumberAnimation { duration: 500; } } } MouseRegion { diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp index 99ec728..e31b600 100644 --- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp +++ b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp @@ -79,7 +79,7 @@ void tst_qmlbehaviors::simpleBehavior() QVERIFY(qobject_cast(rect->findChild("MyBehavior"))->animation()); rect->setState("moved"); - QTest::qWait(100); + QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } @@ -92,7 +92,7 @@ void tst_qmlbehaviors::scriptTriggered() QVERIFY(rect); rect->setColor(QColor("red")); - QTest::qWait(100); + QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } @@ -108,7 +108,7 @@ void tst_qmlbehaviors::cppTriggered() QVERIFY(innerRect); innerRect->setProperty("x", 200); - QTest::qWait(100); + QTest::qWait(200); qreal x = innerRect->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } @@ -132,7 +132,7 @@ void tst_qmlbehaviors::colorBehavior() QVERIFY(rect); rect->setState("red"); - QTest::qWait(100); + QTest::qWait(200); QColor color = qobject_cast(rect->findChild("MyRect"))->color(); QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered } @@ -145,11 +145,11 @@ void tst_qmlbehaviors::parentBehavior() QVERIFY(rect); rect->setState("reparented"); - QTest::qWait(100); + QTest::qWait(200); QmlGraphicsItem *newParent = rect->findChild("NewParent"); QmlGraphicsItem *parent = rect->findChild("MyRect")->parentItem(); QVERIFY(parent != newParent); - QTest::qWait(300); + QTest::qWait(600); parent = rect->findChild("MyRect")->parentItem(); QVERIFY(parent == newParent); } @@ -162,29 +162,29 @@ void tst_qmlbehaviors::replaceBinding() QVERIFY(rect); rect->setState("moved"); - QTest::qWait(100); + QTest::qWait(200); QmlGraphicsRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect); qreal x = innerRect->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered - QTest::qWait(300); + QTest::qWait(600); QCOMPARE(innerRect->x(), (qreal)200); rect->setProperty("basex", 10); QCOMPARE(innerRect->x(), (qreal)200); rect->setProperty("movedx", 210); - QTest::qWait(300); + QTest::qWait(600); QCOMPARE(innerRect->x(), (qreal)210); rect->setState(""); - QTest::qWait(100); + QTest::qWait(200); x = innerRect->x(); QVERIFY(x > 10 && x < 210); //i.e. the behavior has been triggered - QTest::qWait(300); + QTest::qWait(600); QCOMPARE(innerRect->x(), (qreal)10); rect->setProperty("movedx", 200); QCOMPARE(innerRect->x(), (qreal)10); rect->setProperty("basex", 20); - QTest::qWait(300); + QTest::qWait(600); QCOMPARE(innerRect->x(), (qreal)20); } @@ -197,7 +197,7 @@ void tst_qmlbehaviors::group() QVERIFY(rect); rect->setState("moved"); - QTest::qWait(100); + QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } @@ -209,7 +209,7 @@ void tst_qmlbehaviors::group() QVERIFY(rect); rect->setState("moved"); - QTest::qWait(100); + QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } @@ -236,7 +236,7 @@ void tst_qmlbehaviors::explicitSelection() QVERIFY(rect); rect->setState("moved"); - QTest::qWait(100); + QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } -- cgit v0.12 From f595c880cf68225d300547d31f13cf9520be3846 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 22 Feb 2010 11:39:22 +1000 Subject: Fix compile error on Solaris QTBUG-8267. Remove templating from QmlTimeLineEvent class (and rename it to QmlTimeLineCallback to more represent what it is). --- .../graphicsitems/qmlgraphicsflickable.cpp | 16 ++++++-- .../graphicsitems/qmlgraphicsflickable_p_p.h | 5 ++- .../graphicsitems/qmlgraphicslistview.cpp | 8 ++-- .../graphicsitems/qmlgraphicspathview.cpp | 9 ++++- .../graphicsitems/qmlgraphicspathview_p_p.h | 3 +- src/declarative/util/qmltimeline.cpp | 47 +++++++++++----------- src/declarative/util/qmltimeline_p_p.h | 43 +++++++------------- 7 files changed, 65 insertions(+), 66 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp index 6825f89..bfee8d4 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp @@ -132,8 +132,6 @@ QmlGraphicsFlickablePrivate::QmlGraphicsFlickablePrivate() , horizontalVelocity(this), verticalVelocity(this), vTime(0), visibleArea(0) , flickDirection(QmlGraphicsFlickable::AutoFlickDirection) { - fixupXEvent = QmlTimeLineEvent::timeLineEvent(&_moveX, this); - fixupYEvent = QmlTimeLineEvent::timeLineEvent(&_moveY, this); } void QmlGraphicsFlickablePrivate::init() @@ -176,7 +174,7 @@ void QmlGraphicsFlickablePrivate::flickX(qreal velocity) } timeline.reset(_moveX); timeline.accel(_moveX, v, deceleration, maxDistance); - timeline.execute(fixupXEvent); + timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this)); if (!flicked) { flicked = true; emit q->flickingChanged(); @@ -214,7 +212,7 @@ void QmlGraphicsFlickablePrivate::flickY(qreal velocity) } timeline.reset(_moveY); timeline.accel(_moveY, v, deceleration, maxDistance); - timeline.execute(fixupYEvent); + timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this)); if (!flicked) { flicked = true; emit q->flickingChanged(); @@ -255,6 +253,16 @@ void QmlGraphicsFlickablePrivate::fixupX() vTime = timeline.time(); } +void QmlGraphicsFlickablePrivate::fixupY_callback(void *data) +{ + ((QmlGraphicsFlickablePrivate *)data)->fixupY(); +} + +void QmlGraphicsFlickablePrivate::fixupX_callback(void *data) +{ + ((QmlGraphicsFlickablePrivate *)data)->fixupX(); +} + void QmlGraphicsFlickablePrivate::fixupY() { Q_Q(QmlGraphicsFlickable); diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h index 0c98f7b..a76ee8a 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h @@ -110,8 +110,6 @@ public: qreal velocityX; qreal velocityY; QTime pressTime; - QmlTimeLineEvent fixupXEvent; - QmlTimeLineEvent fixupYEvent; qreal deceleration; qreal maxVelocity; QTime velocityTime; @@ -125,6 +123,9 @@ public: int pressDelay; int fixupDuration; + static void fixupY_callback(void *); + static void fixupX_callback(void *); + void updateVelocity(); struct Velocity : public QmlTimeLineValue { diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index c646d49..108ac75 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -1200,7 +1200,7 @@ void QmlGraphicsListViewPrivate::flickX(qreal velocity) } timeline.reset(_moveX); timeline.accel(_moveX, v, accel, maxDistance + overshootDist); - timeline.execute(fixupXEvent); + timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this)); flicked = true; emit q->flickingChanged(); emit q->flickStarted(); @@ -1226,7 +1226,7 @@ void QmlGraphicsListViewPrivate::flickX(qreal velocity) } timeline.reset(_moveX); timeline.accelDistance(_moveX, v, -dist + (v < 0 ? -overshootDist : overshootDist)); - timeline.execute(fixupXEvent); + timeline.callback(QmlTimeLineCallback(&_moveX, fixupX_callback, this)); } } else { correctFlick = false; @@ -1298,7 +1298,7 @@ void QmlGraphicsListViewPrivate::flickY(qreal velocity) } timeline.reset(_moveY); timeline.accel(_moveY, v, accel, maxDistance + overshootDist); - timeline.execute(fixupYEvent); + timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this)); flicked = true; emit q->flickingChanged(); emit q->flickStarted(); @@ -1324,7 +1324,7 @@ void QmlGraphicsListViewPrivate::flickY(qreal velocity) } timeline.reset(_moveY); timeline.accelDistance(_moveY, v, -dist + (v < 0 ? -overshootDist : overshootDist)); - timeline.execute(fixupYEvent); + timeline.callback(QmlTimeLineCallback(&_moveY, fixupY_callback, this)); } } else { correctFlick = false; diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp index f862555..aba184d 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp @@ -524,7 +524,7 @@ void QmlGraphicsPathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *) qreal dist = qAbs(velocity/2 - qmlMod(velocity/2, qreal(100.0 / d->model->count()) - inc)); d->moveOffset.setValue(d->_offset); d->tl.accel(d->moveOffset, velocity, 10, dist); - d->tl.execute(d->fixupOffsetEvent); + d->tl.callback(QmlTimeLineCallback(&d->moveOffset, d->fixOffsetCallback, d)); } else { d->fixOffset(); } @@ -886,6 +886,11 @@ void QmlGraphicsPathViewPrivate::updateCurrent() } } +void QmlGraphicsPathViewPrivate::fixOffsetCallback(void *d) +{ + ((QmlGraphicsPathViewPrivate *)d)->fixOffset(); +} + void QmlGraphicsPathViewPrivate::fixOffset() { Q_Q(QmlGraphicsPathView); @@ -938,7 +943,7 @@ void QmlGraphicsPathViewPrivate::snapToCurrent() rounds++; tl.move(moveOffset, targetOffset + 100.0*(-rounds), QEasingCurve(QEasingCurve::InOutQuad), int(100*items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds)))); - tl.execute(fixupOffsetEvent); + tl.callback(QmlTimeLineCallback(&moveOffset, fixOffsetCallback, this)); return; } diff --git a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h index 723d2d5..c635833 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspathview_p_p.h @@ -82,7 +82,6 @@ public: , firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1) , moveReason(Other) { - fixupOffsetEvent = QmlTimeLineEvent::timeLineEvent(&moveOffset, this); } void init() @@ -104,6 +103,7 @@ public: int calcCurrentIndex(); void updateCurrent(); + static void fixOffsetCallback(void*); void fixOffset(); void setOffset(qreal offset); void regenerate(); @@ -127,7 +127,6 @@ public: qreal dragMargin; QmlTimeLine tl; QmlTimeLineValueProxy moveOffset; - QmlTimeLineEvent fixupOffsetEvent; int firstIndex; int pathItems; int pathOffset; diff --git a/src/declarative/util/qmltimeline.cpp b/src/declarative/util/qmltimeline.cpp index 58c87e8..5c5df40 100644 --- a/src/declarative/util/qmltimeline.cpp +++ b/src/declarative/util/qmltimeline.cpp @@ -55,12 +55,12 @@ QT_BEGIN_NAMESPACE struct Update { Update(QmlTimeLineValue *_g, qreal _v) : g(_g), v(_v) {} - Update(const QmlTimeLineEvent &_e) + Update(const QmlTimeLineCallback &_e) : g(0), v(0), e(_e) {} QmlTimeLineValue *g; qreal v; - QmlTimeLineEvent e; + QmlTimeLineCallback e; }; struct QmlTimeLinePrivate @@ -79,7 +79,7 @@ struct QmlTimeLinePrivate }; Op() {} Op(Type t, int l, qreal v, qreal v2, int o, - const QmlTimeLineEvent &ev = QmlTimeLineEvent(), const QEasingCurve &es = QEasingCurve()) + const QmlTimeLineCallback &ev = QmlTimeLineCallback(), const QEasingCurve &es = QEasingCurve()) : type(t), length(l), value(v), value2(v2), order(o), event(ev), easing(es) {} Op(const Op &o) @@ -98,7 +98,7 @@ struct QmlTimeLinePrivate qreal value2; int order; - QmlTimeLineEvent event; + QmlTimeLineCallback event; QEasingCurve easing; }; struct TimeLine @@ -244,7 +244,7 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change } case Op::Execute: - op.event.execute(); + op.event.d0(op.event.d1); *changed = false; return -1; } @@ -364,10 +364,10 @@ void QmlTimeLine::pause(QmlTimeLineObject &obj, int time) /*! Execute the \a event. */ -void QmlTimeLine::execute(const QmlTimeLineEvent &event) +void QmlTimeLine::callback(const QmlTimeLineCallback &callback) { - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, event); - d->add(*event.eventObject(), op); + QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback); + d->add(*callback.callbackObject(), op); } /*! @@ -466,7 +466,7 @@ void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, int t void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time) { if (time <= 0) return; - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineEvent(), easing); + QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineCallback(), easing); d->add(timeLineValue, op); } @@ -488,7 +488,7 @@ void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, int time void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time) { if (time <= 0) return; - QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineEvent(), easing); + QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineCallback(), easing); d->add(timeLineValue, op); } @@ -805,10 +805,11 @@ int QmlTimeLinePrivate::advance(int t) updateQueue = &updates; for (int ii = 0; ii < updates.count(); ++ii) { const Update &v = updates.at(ii).second; - if (v.g) + if (v.g) { v.g->setValue(v.v); - else - v.e.execute(); + } else { + v.e.d0(v.e.d1); + } } updateQueue = 0; } while(t); @@ -854,7 +855,7 @@ void QmlTimeLine::remove(QmlTimeLineObject *v) if (d->updateQueue) { for (int ii = 0; ii < d->updateQueue->count(); ++ii) { if (d->updateQueue->at(ii).second.g == v || - d->updateQueue->at(ii).second.e.eventObject() == v) { + d->updateQueue->at(ii).second.e.callbackObject() == v) { d->updateQueue->removeAt(ii); --ii; } @@ -910,17 +911,22 @@ QmlTimeLineObject::~QmlTimeLineObject() } } -QmlTimeLineEvent::QmlTimeLineEvent() +QmlTimeLineCallback::QmlTimeLineCallback() : d0(0), d1(0), d2(0) { } -QmlTimeLineEvent::QmlTimeLineEvent(const QmlTimeLineEvent &o) +QmlTimeLineCallback::QmlTimeLineCallback(QmlTimeLineObject *b, Callback f, void *d) +: d0(f), d1(d), d2(b) +{ +} + +QmlTimeLineCallback::QmlTimeLineCallback(const QmlTimeLineCallback &o) : d0(o.d0), d1(o.d1), d2(o.d2) { } -QmlTimeLineEvent &QmlTimeLineEvent::operator=(const QmlTimeLineEvent &o) +QmlTimeLineCallback &QmlTimeLineCallback::operator=(const QmlTimeLineCallback &o) { d0 = o.d0; d1 = o.d1; @@ -928,12 +934,7 @@ QmlTimeLineEvent &QmlTimeLineEvent::operator=(const QmlTimeLineEvent &o) return *this; } -void QmlTimeLineEvent::execute() const -{ - d0(d1); -} - -QmlTimeLineObject *QmlTimeLineEvent::eventObject() const +QmlTimeLineObject *QmlTimeLineCallback::callbackObject() const { return d2; } diff --git a/src/declarative/util/qmltimeline_p_p.h b/src/declarative/util/qmltimeline_p_p.h index f271a3f..076355d 100644 --- a/src/declarative/util/qmltimeline_p_p.h +++ b/src/declarative/util/qmltimeline_p_p.h @@ -60,10 +60,10 @@ QT_BEGIN_NAMESPACE class QEasingCurve; class QmlTimeLineValue; -class QmlTimeLineEvent; +class QmlTimeLineCallback; struct QmlTimeLinePrivate; class QmlTimeLineObject; -class Q_DECLARATIVE_EXPORT QmlTimeLine : public QAbstractAnimation +class QmlTimeLine : public QAbstractAnimation { Q_OBJECT public: @@ -75,7 +75,7 @@ public: void setSyncMode(SyncMode); void pause(QmlTimeLineObject &, int); - void execute(const QmlTimeLineEvent &); + void callback(const QmlTimeLineCallback &); void set(QmlTimeLineValue &, qreal); int accel(QmlTimeLineValue &, qreal velocity, qreal accel); @@ -117,7 +117,7 @@ private: QmlTimeLinePrivate *d; }; -class Q_DECLARATIVE_EXPORT QmlTimeLineObject +class QmlTimeLineObject { public: QmlTimeLineObject(); @@ -129,7 +129,7 @@ protected: QmlTimeLine *_t; }; -class Q_DECLARATIVE_EXPORT QmlTimeLineValue : public QmlTimeLineObject +class QmlTimeLineValue : public QmlTimeLineObject { public: QmlTimeLineValue(qreal v = 0.) : _v(v) {} @@ -147,36 +147,21 @@ private: qreal _v; }; -class Q_DECLARATIVE_EXPORT QmlTimeLineEvent +class QmlTimeLineCallback { public: - QmlTimeLineEvent(); - QmlTimeLineEvent(const QmlTimeLineEvent &o); + typedef void (*Callback)(void *); - template - static QmlTimeLineEvent timeLineEvent(QmlTimeLineObject *b, T *c) - { - QmlTimeLineEvent rv; - rv.d0 = &callFunc; - rv.d1 = (void *)c; - rv.d2 = b; - return rv; - } + QmlTimeLineCallback(); + QmlTimeLineCallback(QmlTimeLineObject *b, Callback, void * = 0); + QmlTimeLineCallback(const QmlTimeLineCallback &o); - QmlTimeLineEvent &operator=(const QmlTimeLineEvent &o); - void execute() const; - QmlTimeLineObject *eventObject() const; + QmlTimeLineCallback &operator=(const QmlTimeLineCallback &o); + QmlTimeLineObject *callbackObject() const; private: - typedef void (*CallFunc)(void *c); - - template - static void callFunc(void *c) - { - T *cls = (T *)c; - (cls->*method)(); - } - CallFunc d0; + friend class QmlTimeLinePrivate; + Callback d0; void *d1; QmlTimeLineObject *d2; }; -- cgit v0.12