summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/snapshot14
-rw-r--r--doc/src/statemachine.qdoc12
-rw-r--r--examples/animation/animatedtiles/main.cpp29
-rw-r--r--examples/animation/appchooser/main.cpp23
-rw-r--r--examples/animation/easing/window.cpp2
-rw-r--r--examples/animation/example/mainwindow.cpp70
-rw-r--r--examples/animation/moveblocks/main.cpp15
-rw-r--r--examples/animation/research/memberfunctions/qvalueanimation.cpp4
-rw-r--r--examples/animation/states/main.cpp127
-rw-r--r--examples/animation/stickman/editor/animationdialog.cpp151
-rw-r--r--examples/animation/stickman/editor/animationdialog.h41
-rw-r--r--examples/animation/stickman/editor/editor.pri2
-rw-r--r--examples/animation/stickman/editor/mainwindow.cpp35
-rw-r--r--examples/animation/stickman/editor/mainwindow.h17
-rw-r--r--examples/animation/stickman/graphicsview.cpp27
-rw-r--r--examples/animation/stickman/graphicsview.h4
-rw-r--r--examples/animation/stickman/lifecycle.cpp72
-rw-r--r--examples/animation/stickman/lifecycle.h2
-rw-r--r--examples/animation/stickman/main.cpp2
-rw-r--r--examples/animation/stickman/node.cpp9
-rw-r--r--examples/animation/stickman/node.h5
-rw-r--r--examples/animation/stickman/stickman.cpp37
-rw-r--r--examples/animation/stickman/stickman.h1
-rw-r--r--examples/animation/stickman/stickman.pro2
-rw-r--r--examples/animation/sub-attaq/boat.cpp7
-rw-r--r--examples/animation/sub-attaq/bomb.cpp12
-rw-r--r--examples/animation/sub-attaq/custompropertyanimation.cpp57
-rw-r--r--examples/animation/sub-attaq/custompropertyanimation.h3
-rw-r--r--examples/animation/sub-attaq/graphicsscene.cpp19
-rw-r--r--examples/animation/sub-attaq/qanimationstate.cpp175
-rw-r--r--examples/animation/sub-attaq/qanimationstate.h (renamed from examples/animation/sub-attaq/custompropertyanimation_p.h)56
-rw-r--r--examples/animation/sub-attaq/states.cpp6
-rw-r--r--examples/animation/sub-attaq/states.h4
-rw-r--r--examples/animation/sub-attaq/sub-attaq.pro8
-rw-r--r--examples/animation/sub-attaq/submarine.cpp11
-rw-r--r--examples/animation/sub-attaq/submarine_p.h18
-rw-r--r--examples/animation/sub-attaq/torpedo.cpp12
-rw-r--r--examples/statemachine/citizenquartz/citizenquartz.qrc1
-rw-r--r--examples/statemachine/citizenquartz/clock.cpp44
-rw-r--r--examples/statemachine/citizenquartz/clock.h4
-rw-r--r--examples/statemachine/citizenquartz/clockdisplay.cpp3
-rw-r--r--examples/statemachine/citizenquartz/clockdisplay.h16
-rw-r--r--examples/statemachine/citizenquartz/propertyaddstate.cpp2
-rw-r--r--examples/statemachine/citizenquartz/propertyaddstate.h2
-rw-r--r--examples/statemachine/citizenquartz/timeperiod.h2
-rw-r--r--examples/statemachine/clockticking/main.cpp36
-rw-r--r--examples/statemachine/composition/main.cpp42
-rw-r--r--examples/statemachine/eventtransitions/main.cpp40
-rw-r--r--examples/statemachine/factorial/main.cpp36
-rw-r--r--examples/statemachine/helloworld/main.cpp34
-rw-r--r--examples/statemachine/pauseandresume/main.cpp34
-rw-r--r--examples/statemachine/pingpong/main.cpp36
-rw-r--r--examples/statemachine/trafficlight/main.cpp42
-rw-r--r--examples/statemachine/twowaybutton/main.cpp38
-rw-r--r--src/corelib/animation/qabstractanimation.cpp94
-rw-r--r--src/corelib/animation/qabstractanimation.h12
-rw-r--r--src/corelib/animation/qabstractanimation_p.h8
-rw-r--r--src/corelib/animation/qanimationgroup.cpp3
-rw-r--r--src/corelib/animation/qparallelanimationgroup.cpp24
-rw-r--r--src/corelib/animation/qparallelanimationgroup_p.h4
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp6
-rw-r--r--src/corelib/animation/qpropertyanimation.h1
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp28
-rw-r--r--src/corelib/animation/qsequentialanimationgroup_p.h4
-rw-r--r--src/corelib/animation/qvariantanimation.cpp6
-rw-r--r--src/corelib/animation/qvariantanimation.h3
-rw-r--r--src/corelib/animation/qvariantanimation_p.h4
-rw-r--r--src/corelib/kernel/qcoreevent.cpp3
-rw-r--r--src/corelib/statemachine/qabstractstate.cpp115
-rw-r--r--src/corelib/statemachine/qabstractstate.h48
-rw-r--r--src/corelib/statemachine/qabstractstate_p.h51
-rw-r--r--src/corelib/statemachine/qabstracttransition.cpp88
-rw-r--r--src/corelib/statemachine/qabstracttransition.h46
-rw-r--r--src/corelib/statemachine/qabstracttransition_p.h38
-rw-r--r--src/corelib/statemachine/qactionstate.cpp162
-rw-r--r--src/corelib/statemachine/qactionstate.h47
-rw-r--r--src/corelib/statemachine/qactionstate_p.h36
-rw-r--r--src/corelib/statemachine/qactiontransition.cpp230
-rw-r--r--src/corelib/statemachine/qactiontransition.h96
-rw-r--r--src/corelib/statemachine/qactiontransition_p.h (renamed from src/gui/animation/qitemanimation_p.h)39
-rw-r--r--src/corelib/statemachine/qanimationstate.cpp574
-rw-r--r--src/corelib/statemachine/qanimationstate.h63
-rw-r--r--src/corelib/statemachine/qboundevent_p.h34
-rw-r--r--src/corelib/statemachine/qeventtransition.cpp65
-rw-r--r--src/corelib/statemachine/qeventtransition.h45
-rw-r--r--src/corelib/statemachine/qeventtransition_p.h38
-rw-r--r--src/corelib/statemachine/qfinalstate.cpp35
-rw-r--r--src/corelib/statemachine/qfinalstate.h34
-rw-r--r--src/corelib/statemachine/qhistorystate.cpp35
-rw-r--r--src/corelib/statemachine/qhistorystate.h34
-rw-r--r--src/corelib/statemachine/qhistorystate_p.h34
-rw-r--r--src/corelib/statemachine/qsignalevent.h34
-rw-r--r--src/corelib/statemachine/qsignaleventgenerator_p.h34
-rw-r--r--src/corelib/statemachine/qsignaltransition.cpp53
-rw-r--r--src/corelib/statemachine/qsignaltransition.h41
-rw-r--r--src/corelib/statemachine/qsignaltransition_p.h38
-rw-r--r--src/corelib/statemachine/qstate.cpp149
-rw-r--r--src/corelib/statemachine/qstate.h54
-rw-r--r--src/corelib/statemachine/qstate_p.h34
-rw-r--r--src/corelib/statemachine/qstateaction.cpp187
-rw-r--r--src/corelib/statemachine/qstateaction.h66
-rw-r--r--src/corelib/statemachine/qstateaction_p.h49
-rw-r--r--src/corelib/statemachine/qstatefinishedevent.h34
-rw-r--r--src/corelib/statemachine/qstatefinishedtransition.cpp51
-rw-r--r--src/corelib/statemachine/qstatefinishedtransition.h41
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp409
-rw-r--r--src/corelib/statemachine/qstatemachine.h47
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h69
-rw-r--r--src/corelib/statemachine/qtransition.cpp230
-rw-r--r--src/corelib/statemachine/qtransition.h68
-rw-r--r--src/corelib/statemachine/qtransition_p.h50
-rw-r--r--src/corelib/statemachine/statemachine.pri11
-rw-r--r--src/gui/animation/animation.pri7
-rw-r--r--src/gui/animation/qguivariantanimation.cpp (renamed from src/gui/animation/qitemanimation.h)84
-rw-r--r--src/gui/animation/qitemanimation.cpp361
-rw-r--r--src/gui/statemachine/qguistatemachine.cpp74
-rw-r--r--src/gui/statemachine/qkeyeventtransition.cpp4
-rw-r--r--src/gui/statemachine/qmouseeventtransition.cpp3
-rw-r--r--tests/auto/qanimationgroup/tst_qanimationgroup.cpp80
-rw-r--r--tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp30
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp40
-rw-r--r--tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp88
-rw-r--r--tests/auto/qstate/tst_qstate.cpp111
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp206
124 files changed, 3641 insertions, 2886 deletions
diff --git a/bin/snapshot b/bin/snapshot
index 8cf3be217a..783d15cfbd 100644
--- a/bin/snapshot
+++ b/bin/snapshot
@@ -39,6 +39,7 @@ my @files = (
"corelib/animation/qsequentialanimationgroup.cpp",
"corelib/animation/qsequentialanimationgroup.h",
"corelib/animation/qsequentialanimationgroup_p.h",
+ "gui/animation/qguivariantanimation.cpp",
"corelib/statemachine/statemachine.pri",
"corelib/statemachine/qabstractstate.cpp",
"corelib/statemachine/qabstractstate.h",
@@ -49,8 +50,6 @@ my @files = (
"corelib/statemachine/qactionstate.h",
"corelib/statemachine/qactionstate_p.h",
"corelib/statemachine/qactionstate.cpp",
- "corelib/statemachine/qanimationstate.cpp",
- "corelib/statemachine/qanimationstate.h",
"corelib/statemachine/qboundevent_p.h",
"corelib/statemachine/qeventtransition.cpp",
"corelib/statemachine/qeventtransition.h",
@@ -77,9 +76,9 @@ my @files = (
"corelib/statemachine/qstatemachine.h",
"corelib/statemachine/qstatemachine_p.h",
"corelib/statemachine/qstate_p.h",
- "corelib/statemachine/qtransition.cpp",
- "corelib/statemachine/qtransition.h",
- "corelib/statemachine/qtransition_p.h",
+ "corelib/statemachine/qactiontransition.cpp",
+ "corelib/statemachine/qactiontransition.h",
+ "corelib/statemachine/qactiontransition_p.h",
"gui/statemachine/qkeyeventtransition.h",
"gui/statemachine/qkeyeventtransition.cpp",
"gui/statemachine/qbasickeyeventtransition.cpp",
@@ -144,7 +143,6 @@ my %animation_examples = (
"bomb.cpp",
"bomb.h",
"custompropertyanimation.h",
- "custompropertyanimation_p.h",
"custompropertyanimation.cpp",
"graphicsscene.cpp",
"graphicsscene.h",
@@ -254,7 +252,6 @@ sub copyFile
$filecontents =~s/QAbstractStateGroup/QtAbstractStateGroup/g;
$filecontents =~s/QAbstractTransition/QtAbstractTransition/g;
$filecontents =~s/QActionState/QtActionState/g;
- $filecontents =~s/QAnimationState/QtAnimationState/g;
$filecontents =~s/QEventTransition/QtEventTransition/g;
$filecontents =~s/QFinalState/QtFinalState/g;
$filecontents =~s/QHistoryState/QtHistoryState/g;
@@ -263,12 +260,11 @@ sub copyFile
$filecontents =~s/QSignalTransition/QtSignalTransition/g;
$filecontents =~s/QState/QtState/g;
$filecontents =~s/QStateAction/QtStateAction/g;
- $filecontents =~s/QStateSetPropertyAction/QtStateSetPropertyAction/g;
$filecontents =~s/QStateInvokeMethodAction/QtStateInvokeMethodAction/g;
$filecontents =~s/QStateFinishedEvent/QtStateFinishedEvent/g;
$filecontents =~s/QStateFinishedTransition/QtStateFinishedTransition/g;
$filecontents =~s/QStateMachine/QtStateMachine/g;
- $filecontents =~s/QTransition/QtTransition/g;
+ $filecontents =~s/QActionTransition/QtActionTransition/g;
$filecontents =~s/QMouseEventTransition/QtMouseEventTransition/g;
$filecontents =~s/QKeyEventTransition/QtKeyEventTransition/g;
$filecontents =~s/QGraphicsWidget/QtGraphicsWidget/g;
diff --git a/doc/src/statemachine.qdoc b/doc/src/statemachine.qdoc
index c79839f029..3051d195ed 100644
--- a/doc/src/statemachine.qdoc
+++ b/doc/src/statemachine.qdoc
@@ -77,21 +77,21 @@
The above state machine is perfectly fine, but it doesn't \e do anything; it
merely transitions from one state to another. The
- QState::setPropertyOnEntry() function can be used to have a state set a
+ QAbstractState::assignProperty() function can be used to have a state set a
property of a QObject when the state is entered. In the following snippet,
the value that should be assigned to a QLabel's text property is specified
for each state:
\code
- s1->setPropertyOnEntry(label, "text", "In state s1");
- s2->setPropertyOnEntry(label, "text", "In state s2");
- s3->setPropertyOnEntry(label, "text", "In state s3");
+ s1->assignProperty(label, "text", "In state s1");
+ s2->assignProperty(label, "text", "In state s2");
+ s3->assignProperty(label, "text", "In state s3");
\endcode
When any of the states is entered, the label's text will be changed
accordingly.
- The QState::invokeMethodOnEntry() function can be used to have a state
+ The QActionState::invokeMethodOnEntry() function can be used to have a state
invoke a method (a slot) of a QObject when the state is entered. In the
following snippet, the button's showMaximized() slot will be called when
state \c s3 is entered:
@@ -204,7 +204,7 @@
QHistoryState *s1h = s1->addHistoryState();
QState *s3 = new QState();
- s3->setPropertyOnEntry(label, "text", "In s3");
+ s3->assignProperty(label, "text", "In s3");
QMessageBox mbox;
mbox.addButton(QMessageBox::Ok);
mbox.setText("Interrupted!");
diff --git a/examples/animation/animatedtiles/main.cpp b/examples/animation/animatedtiles/main.cpp
index e4a774c281..cfaa4ce687 100644
--- a/examples/animation/animatedtiles/main.cpp
+++ b/examples/animation/animatedtiles/main.cpp
@@ -3,6 +3,7 @@
# include "qgraphicswidget.h"
# include "qstate.h"
# include "qstatemachine.h"
+# include "qabstracttransition.h"
# include "qgraphicswidget.h"
# include "qparallelanimationgroup.h"
# include "qpropertyanimation.h"
@@ -147,27 +148,27 @@ int main(int argc, char **argv)
for (int i = 0; i < 64; ++i) {
Pixmap *item = items.at(i);
// Ellipse
- ellipseState->setPropertyOnEntry(item, "pos",
+ ellipseState->assignProperty(item, "pos",
QPointF(cos((i / 63.0) * 6.28) * 250,
sin((i / 63.0) * 6.28) * 250));
// Figure 8
- figure8State->setPropertyOnEntry(item, "pos",
+ figure8State->assignProperty(item, "pos",
QPointF(sin((i / 63.0) * 6.28) * 250,
sin(((i * 2)/63.0) * 6.28) * 250));
// Random
- randomState->setPropertyOnEntry(item, "pos",
+ randomState->assignProperty(item, "pos",
QPointF(-250 + qrand() % 500,
-250 + qrand() % 500));
// Tiled
- tiledState->setPropertyOnEntry(item, "pos",
+ tiledState->assignProperty(item, "pos",
QPointF(((i % 8) - 4) * kineticPix.width() + kineticPix.width() / 2,
((i / 8) - 4) * kineticPix.height() + kineticPix.height() / 2));
// Centered
- centeredState->setPropertyOnEntry(item, "pos", QPointF());
+ centeredState->assignProperty(item, "pos", QPointF());
}
// Ui
@@ -184,7 +185,6 @@ int main(int argc, char **argv)
states.setInitialState(rootState);
rootState->setInitialState(centeredState);
- // rootState->addTransition(ellipseButton, SIGNAL(pressed()), ellipseState);
QParallelAnimationGroup *group = new QParallelAnimationGroup;
for (int i = 0; i < 64; ++i) {
QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos");
@@ -192,7 +192,8 @@ int main(int argc, char **argv)
anim->setEasingCurve(QEasingCurve::InOutBack);
group->addAnimation(anim);
}
- rootState->addAnimatedTransition(ellipseButton, SIGNAL(pressed()), ellipseState, group);
+ QAbstractTransition *trans = rootState->addTransition(ellipseButton, SIGNAL(pressed()), ellipseState);
+ trans->addAnimation(group);
group = new QParallelAnimationGroup;
for (int i = 0; i < 64; ++i) {
@@ -201,7 +202,8 @@ int main(int argc, char **argv)
anim->setEasingCurve(QEasingCurve::InOutBack);
group->addAnimation(anim);
}
- rootState->addAnimatedTransition(figure8Button, SIGNAL(pressed()), figure8State, group);
+ trans = rootState->addTransition(figure8Button, SIGNAL(pressed()), figure8State);
+ trans->addAnimation(group);
group = new QParallelAnimationGroup;
for (int i = 0; i < 64; ++i) {
@@ -210,7 +212,8 @@ int main(int argc, char **argv)
anim->setEasingCurve(QEasingCurve::InOutBack);
group->addAnimation(anim);
}
- rootState->addAnimatedTransition(randomButton, SIGNAL(pressed()), randomState, group);
+ trans = rootState->addTransition(randomButton, SIGNAL(pressed()), randomState);
+ trans->addAnimation(group);
group = new QParallelAnimationGroup;
for (int i = 0; i < 64; ++i) {
@@ -219,7 +222,8 @@ int main(int argc, char **argv)
anim->setEasingCurve(QEasingCurve::InOutBack);
group->addAnimation(anim);
}
- rootState->addAnimatedTransition(tiledButton, SIGNAL(pressed()), tiledState, group);
+ trans = rootState->addTransition(tiledButton, SIGNAL(pressed()), tiledState);
+ trans->addAnimation(group);
group = new QParallelAnimationGroup;
for (int i = 0; i < 64; ++i) {
@@ -228,13 +232,14 @@ int main(int argc, char **argv)
anim->setEasingCurve(QEasingCurve::InOutBack);
group->addAnimation(anim);
}
- rootState->addAnimatedTransition(centeredButton, SIGNAL(pressed()), centeredState, group);
+ trans = rootState->addTransition(centeredButton, SIGNAL(pressed()), centeredState);
+ trans->addAnimation(group);
states.start();
QTimer timer;
timer.start(125);
timer.setSingleShot(true);
- rootState->addAnimatedTransition(&timer, SIGNAL(timeout()), ellipseState, group);
+ rootState->addTransition(&timer, SIGNAL(timeout()), ellipseState);
return app.exec();
}
diff --git a/examples/animation/appchooser/main.cpp b/examples/animation/appchooser/main.cpp
index 536bbb6eb8..1a43ed7d2f 100644
--- a/examples/animation/appchooser/main.cpp
+++ b/examples/animation/appchooser/main.cpp
@@ -54,13 +54,19 @@ private:
QPixmap p;
};
-void createStateAndTransition(QObject *o1, const QRect &selectedRect, QState *parent)
+void createStates(const QObjectList &objects,
+ const QRect &selectedRect, QState *parent)
{
- QState *state = new QState(parent);
- state->setPropertyOnEntry(o1, "geometry", selectedRect);
-
- QPropertyAnimation *animation = new QPropertyAnimation(o1, "geometry");
- parent->addAnimatedTransition(o1, SIGNAL(clicked()), state, animation);
+ for (int i = 0; i < objects.size(); ++i) {
+ QState *state = new QState(parent);
+ state->assignProperty(objects.at(i), "geometry", selectedRect);
+ QAbstractTransition *trans = parent->addTransition(objects.at(i), SIGNAL(clicked()), state);
+ for (int j = 0; j < objects.size(); ++j) {
+ QPropertyAnimation *animation = new QPropertyAnimation(objects.at(j), "geometry");
+ animation->setDuration(2000);
+ trans->addAnimation(animation);
+ }
+ }
}
int main(int argc, char **argv)
@@ -107,10 +113,7 @@ int main(int argc, char **argv)
QState *idleState = new QState(group);
group->setInitialState(idleState);
- createStateAndTransition(p1, selectedRect, group);
- createStateAndTransition(p2, selectedRect, group);
- createStateAndTransition(p3, selectedRect, group);
- createStateAndTransition(p4, selectedRect, group);
+ createStates(QObjectList() << p1 << p2 << p3 << p4, selectedRect, group);
machine.setInitialState(group);
machine.start();
diff --git a/examples/animation/easing/window.cpp b/examples/animation/easing/window.cpp
index c6ea3609b2..bb45770578 100644
--- a/examples/animation/easing/window.cpp
+++ b/examples/animation/easing/window.cpp
@@ -88,7 +88,7 @@ void Window::startAnimation()
m_anim->setStartValue(QPointF(0, 0));
m_anim->setEndValue(QPointF(100, 100));
m_anim->setDuration(2000);
- m_anim->setIterationCount(-1); // forever
+ m_anim->setLoopCount(-1); // forever
m_anim->start();
}
diff --git a/examples/animation/example/mainwindow.cpp b/examples/animation/example/mainwindow.cpp
index dfb5c70d68..2b0e035fa5 100644
--- a/examples/animation/example/mainwindow.cpp
+++ b/examples/animation/example/mainwindow.cpp
@@ -94,50 +94,50 @@ MainWindow::MainWindow() : QMainWindow(0)
machine->setInitialState(group);
// State 1
- state1->setPropertyOnEntry(button, "text", "Edit");
- state1->setPropertyOnEntry(button2, "text", "Add");
- state1->setPropertyOnEntry(button3, "text", "Remove");
- state1->setPropertyOnEntry(button4, "text", "Accept");
+ state1->assignProperty(button, "text", "Edit");
+ state1->assignProperty(button2, "text", "Add");
+ state1->assignProperty(button3, "text", "Remove");
+ state1->assignProperty(button4, "text", "Accept");
state1->addTransition(button2, SIGNAL(clicked()), state3);
- state1->setPropertyOnEntry(listProxy, "geometry", QRectF(0, 0, 700, 560));
- state1->setPropertyOnEntry(widget, "geometry", QRectF(0, 0, 700, 600));
- state1->setPropertyOnEntry(editProxy, "opacity", double(0));
- state1->setPropertyOnEntry(labelProxy, "opacity", double(0));
- state1->setPropertyOnEntry(label2Proxy, "opacity", double(0));
- state1->setPropertyOnEntry(buttonProxy4, "opacity", double(0));
- state1->setPropertyOnEntry(labelWidget, "text", "Name : ");
- state1->setPropertyOnEntry(label2Widget, "text", "Edit a contact");
- state1->setPropertyOnEntry(label2Proxy, "geometry", QRectF(375, -50, 300, 30));
- state1->setPropertyOnEntry(labelProxy, "geometry", QRectF(350, 300, 100, 30));
- state1->setPropertyOnEntry(editProxy, "geometry", QRectF(750, 300, 250, 30));
- state1->setPropertyOnEntry(buttonProxy4, "geometry", QRectF(500, 350, 80, 25));
+ state1->assignProperty(listProxy, "geometry", QRectF(0, 0, 700, 560));
+ state1->assignProperty(widget, "geometry", QRectF(0, 0, 700, 600));
+ state1->assignProperty(editProxy, "opacity", double(0));
+ state1->assignProperty(labelProxy, "opacity", double(0));
+ state1->assignProperty(label2Proxy, "opacity", double(0));
+ state1->assignProperty(buttonProxy4, "opacity", double(0));
+ state1->assignProperty(labelWidget, "text", "Name : ");
+ state1->assignProperty(label2Widget, "text", "Edit a contact");
+ state1->assignProperty(label2Proxy, "geometry", QRectF(375, -50, 300, 30));
+ state1->assignProperty(labelProxy, "geometry", QRectF(350, 300, 100, 30));
+ state1->assignProperty(editProxy, "geometry", QRectF(750, 300, 250, 30));
+ state1->assignProperty(buttonProxy4, "geometry", QRectF(500, 350, 80, 25));
// State 2
- state2->setPropertyOnEntry(button, "text", "Close Editing");
- state2->setPropertyOnEntry(listProxy, "geometry", QRectF(0, 0, 350, 560));
+ state2->assignProperty(button, "text", "Close Editing");
+ state2->assignProperty(listProxy, "geometry", QRectF(0, 0, 350, 560));
state2->addTransition(button2, SIGNAL(clicked()), state3);
state2->addTransition(button4, SIGNAL(clicked()), state1);
- state2->setPropertyOnEntry(editProxy, "opacity", double(1));
- state2->setPropertyOnEntry(labelProxy, "opacity", double(1));
- state2->setPropertyOnEntry(label2Proxy, "opacity", double(1));
- state2->setPropertyOnEntry(buttonProxy4, "opacity", double(1));
+ state2->assignProperty(editProxy, "opacity", double(1));
+ state2->assignProperty(labelProxy, "opacity", double(1));
+ state2->assignProperty(label2Proxy, "opacity", double(1));
+ state2->assignProperty(buttonProxy4, "opacity", double(1));
- state2->setPropertyOnEntry(label2Proxy, "geometry", QRectF(375, 250, 300, 30));
- state2->setPropertyOnEntry(editProxy, "geometry", QRectF(440, 300, 260, 30));
+ state2->assignProperty(label2Proxy, "geometry", QRectF(375, 250, 300, 30));
+ state2->assignProperty(editProxy, "geometry", QRectF(440, 300, 260, 30));
// State 3
- state3->setPropertyOnEntry(button4, "text", "Create New");
- state3->setPropertyOnEntry(listProxy, "geometry", QRectF(0, 0, 350, 560));
+ state3->assignProperty(button4, "text", "Create New");
+ state3->assignProperty(listProxy, "geometry", QRectF(0, 0, 350, 560));
state3->addTransition(button4, SIGNAL(clicked()), state1);
state3->addTransition(button, SIGNAL(clicked()), state1);
- state3->setPropertyOnEntry(editProxy, "opacity", double(1));
- state3->setPropertyOnEntry(labelProxy, "opacity", double(1));
- state3->setPropertyOnEntry(label2Proxy, "opacity", double(1));
- state3->setPropertyOnEntry(buttonProxy4, "opacity", double(1));
+ state3->assignProperty(editProxy, "opacity", double(1));
+ state3->assignProperty(labelProxy, "opacity", double(1));
+ state3->assignProperty(label2Proxy, "opacity", double(1));
+ state3->assignProperty(buttonProxy4, "opacity", double(1));
- state3->setPropertyOnEntry(label2Proxy, "geometry", QRectF(375, 250, 300, 30));
- state3->setPropertyOnEntry(editProxy, "geometry", QRectF(440, 300, 260, 30));
+ state3->assignProperty(label2Proxy, "geometry", QRectF(375, 250, 300, 30));
+ state3->assignProperty(editProxy, "geometry", QRectF(440, 300, 260, 30));
{
QAnimationGroup *animationGroup = new QParallelAnimationGroup;
@@ -150,7 +150,8 @@ MainWindow::MainWindow() : QMainWindow(0)
anim = new QPropertyAnimation(listProxy, "geometry");
animationGroup->addAnimation(anim);
- state1->addAnimatedTransition(button, SIGNAL(clicked()), state2, animationGroup);
+ QAbstractTransition *trans = state1->addTransition(button, SIGNAL(clicked()), state2);
+ trans->addAnimation(animationGroup);
}
{
@@ -162,7 +163,8 @@ MainWindow::MainWindow() : QMainWindow(0)
animationGroup->addAnimation(anim);
anim = new QPropertyAnimation(listProxy, "geometry");
animationGroup->addAnimation(anim);
- state2->addAnimatedTransition(button, SIGNAL(clicked()), state1, animationGroup);
+ QAbstractTransition *trans = state2->addTransition(button, SIGNAL(clicked()), state1);
+ trans->addAnimation(animationGroup);
}
currentState = state1;
diff --git a/examples/animation/moveblocks/main.cpp b/examples/animation/moveblocks/main.cpp
index f4c754d7e3..1f253f3b17 100644
--- a/examples/animation/moveblocks/main.cpp
+++ b/examples/animation/moveblocks/main.cpp
@@ -13,8 +13,8 @@
#include <QtGui>
#if defined(QT_EXPERIMENTAL_SOLUTION)
#include "qstatemachine.h"
+#include "qstate.h"
#include "qabstracttransition.h"
-#include "qanimationstate.h"
#include "qpropertyanimation.h"
#include "qsequentialanimationgroup.h"
#include "qparallelanimationgroup.h"
@@ -99,7 +99,8 @@ public:
void addState(QState *state, QAbstractAnimation *animation) {
StateSwitchTransition *trans = new StateSwitchTransition(++m_stateCount);
trans->setTargetState(state);
- addAnimatedTransition(trans, animation);
+ addTransition(trans);
+ trans->addAnimation(animation);
}
@@ -116,11 +117,11 @@ QState *createGeometryState(QObject *w1, const QRect &rect1,
QState *parent)
{
QState *result = new QState(parent);
- result->setPropertyOnEntry(w1, "geometry", rect1);
- result->setPropertyOnEntry(w1, "geometry", rect1);
- result->setPropertyOnEntry(w2, "geometry", rect2);
- result->setPropertyOnEntry(w3, "geometry", rect3);
- result->setPropertyOnEntry(w4, "geometry", rect4);
+ result->assignProperty(w1, "geometry", rect1);
+ result->assignProperty(w1, "geometry", rect1);
+ result->assignProperty(w2, "geometry", rect2);
+ result->assignProperty(w3, "geometry", rect3);
+ result->assignProperty(w4, "geometry", rect4);
return result;
}
diff --git a/examples/animation/research/memberfunctions/qvalueanimation.cpp b/examples/animation/research/memberfunctions/qvalueanimation.cpp
index 2fe9be9fe2..58652baf66 100644
--- a/examples/animation/research/memberfunctions/qvalueanimation.cpp
+++ b/examples/animation/research/memberfunctions/qvalueanimation.cpp
@@ -21,8 +21,8 @@ void QValueAnimationPrivate::initDefaultStartValue()
{
Q_Q(QValueAnimation);
if (animProp && !q->startValue().isValid()
- && ((currentTime == 0 && (currentIteration || currentIteration == 0))
- || (currentTime == duration && currentIteration == (iterationCount - 1)))) {
+ && (currentTime == 0
+ || (currentTime == duration && currentLoop == (loopCount - 1)))) {
setDefaultStartValue(animProp->read());
}
}
diff --git a/examples/animation/states/main.cpp b/examples/animation/states/main.cpp
index 5c004a2ac3..da5051989e 100644
--- a/examples/animation/states/main.cpp
+++ b/examples/animation/states/main.cpp
@@ -109,69 +109,69 @@ int main(int argc, char *argv[])
machine.setInitialState(state1);
// State 1
- state1->setPropertyOnEntry(button, "text", "Switch to state 2");
- state1->setPropertyOnEntry(widget, "geometry", QRectF(0, 0, 400, 150));
- state1->setPropertyOnEntry(box, "geometry", QRect(-200, 150, 200, 150));
- state1->setPropertyOnEntry(p1, "geometry", QRectF(68, 185, 64, 64));
- state1->setPropertyOnEntry(p2, "geometry", QRectF(168, 185, 64, 64));
- state1->setPropertyOnEntry(p3, "geometry", QRectF(268, 185, 64, 64));
- state1->setPropertyOnEntry(p4, "geometry", QRectF(68-150, 48-150, 64, 64));
- state1->setPropertyOnEntry(p5, "geometry", QRectF(168, 48-150, 64, 64));
- state1->setPropertyOnEntry(p6, "geometry", QRectF(268+150, 48-150, 64, 64));
- state1->setPropertyOnEntry(p1, "zRotation", qreal(0));
- state1->setPropertyOnEntry(p2, "zRotation", qreal(0));
- state1->setPropertyOnEntry(p3, "zRotation", qreal(0));
- state1->setPropertyOnEntry(p4, "zRotation", qreal(-270));
- state1->setPropertyOnEntry(p5, "zRotation", qreal(-90));
- state1->setPropertyOnEntry(p6, "zRotation", qreal(270));
- state1->setPropertyOnEntry(boxProxy, "opacity", qreal(0));
- state1->setPropertyOnEntry(p1, "opacity", qreal(1));
- state1->setPropertyOnEntry(p2, "opacity", qreal(1));
- state1->setPropertyOnEntry(p3, "opacity", qreal(1));
- state1->setPropertyOnEntry(p4, "opacity", qreal(0));
- state1->setPropertyOnEntry(p5, "opacity", qreal(0));
- state1->setPropertyOnEntry(p6, "opacity", qreal(0));
+ state1->assignProperty(button, "text", "Switch to state 2");
+ state1->assignProperty(widget, "geometry", QRectF(0, 0, 400, 150));
+ state1->assignProperty(box, "geometry", QRect(-200, 150, 200, 150));
+ state1->assignProperty(p1, "geometry", QRectF(68, 185, 64, 64));
+ state1->assignProperty(p2, "geometry", QRectF(168, 185, 64, 64));
+ state1->assignProperty(p3, "geometry", QRectF(268, 185, 64, 64));
+ state1->assignProperty(p4, "geometry", QRectF(68-150, 48-150, 64, 64));
+ state1->assignProperty(p5, "geometry", QRectF(168, 48-150, 64, 64));
+ state1->assignProperty(p6, "geometry", QRectF(268+150, 48-150, 64, 64));
+ state1->assignProperty(p1, "zRotation", qreal(0));
+ state1->assignProperty(p2, "zRotation", qreal(0));
+ state1->assignProperty(p3, "zRotation", qreal(0));
+ state1->assignProperty(p4, "zRotation", qreal(-270));
+ state1->assignProperty(p5, "zRotation", qreal(-90));
+ state1->assignProperty(p6, "zRotation", qreal(270));
+ state1->assignProperty(boxProxy, "opacity", qreal(0));
+ state1->assignProperty(p1, "opacity", qreal(1));
+ state1->assignProperty(p2, "opacity", qreal(1));
+ state1->assignProperty(p3, "opacity", qreal(1));
+ state1->assignProperty(p4, "opacity", qreal(0));
+ state1->assignProperty(p5, "opacity", qreal(0));
+ state1->assignProperty(p6, "opacity", qreal(0));
// State 2
- state2->setPropertyOnEntry(button, "text", "Switch to state 3");
- state2->setPropertyOnEntry(widget, "geometry", QRectF(200, 150, 200, 150));
- state2->setPropertyOnEntry(box, "geometry", QRect(9, 150, 190, 150));
- state2->setPropertyOnEntry(p1, "geometry", QRectF(68-150, 185+150, 64, 64));
- state2->setPropertyOnEntry(p2, "geometry", QRectF(168, 185+150, 64, 64));
- state2->setPropertyOnEntry(p3, "geometry", QRectF(268+150, 185+150, 64, 64));
- state2->setPropertyOnEntry(p4, "geometry", QRectF(64, 48, 64, 64));
- state2->setPropertyOnEntry(p5, "geometry", QRectF(168, 48, 64, 64));
- state2->setPropertyOnEntry(p6, "geometry", QRectF(268, 48, 64, 64));
- state2->setPropertyOnEntry(p1, "zRotation", qreal(-270));
- state2->setPropertyOnEntry(p2, "zRotation", qreal(90));
- state2->setPropertyOnEntry(p3, "zRotation", qreal(270));
- state2->setPropertyOnEntry(p4, "zRotation", qreal(0));
- state2->setPropertyOnEntry(p5, "zRotation", qreal(0));
- state2->setPropertyOnEntry(p6, "zRotation", qreal(0));
- state2->setPropertyOnEntry(boxProxy, "opacity", qreal(1));
- state2->setPropertyOnEntry(p1, "opacity", qreal(0));
- state2->setPropertyOnEntry(p2, "opacity", qreal(0));
- state2->setPropertyOnEntry(p3, "opacity", qreal(0));
- state2->setPropertyOnEntry(p4, "opacity", qreal(1));
- state2->setPropertyOnEntry(p5, "opacity", qreal(1));
- state2->setPropertyOnEntry(p6, "opacity", qreal(1));
+ state2->assignProperty(button, "text", "Switch to state 3");
+ state2->assignProperty(widget, "geometry", QRectF(200, 150, 200, 150));
+ state2->assignProperty(box, "geometry", QRect(9, 150, 190, 150));
+ state2->assignProperty(p1, "geometry", QRectF(68-150, 185+150, 64, 64));
+ state2->assignProperty(p2, "geometry", QRectF(168, 185+150, 64, 64));
+ state2->assignProperty(p3, "geometry", QRectF(268+150, 185+150, 64, 64));
+ state2->assignProperty(p4, "geometry", QRectF(64, 48, 64, 64));
+ state2->assignProperty(p5, "geometry", QRectF(168, 48, 64, 64));
+ state2->assignProperty(p6, "geometry", QRectF(268, 48, 64, 64));
+ state2->assignProperty(p1, "zRotation", qreal(-270));
+ state2->assignProperty(p2, "zRotation", qreal(90));
+ state2->assignProperty(p3, "zRotation", qreal(270));
+ state2->assignProperty(p4, "zRotation", qreal(0));
+ state2->assignProperty(p5, "zRotation", qreal(0));
+ state2->assignProperty(p6, "zRotation", qreal(0));
+ state2->assignProperty(boxProxy, "opacity", qreal(1));
+ state2->assignProperty(p1, "opacity", qreal(0));
+ state2->assignProperty(p2, "opacity", qreal(0));
+ state2->assignProperty(p3, "opacity", qreal(0));
+ state2->assignProperty(p4, "opacity", qreal(1));
+ state2->assignProperty(p5, "opacity", qreal(1));
+ state2->assignProperty(p6, "opacity", qreal(1));
// State 3
- state3->setPropertyOnEntry(button, "text", "Switch to state 1");
- state3->setPropertyOnEntry(p1, "geometry", QRectF(5, 5, 64, 64));
- state3->setPropertyOnEntry(p2, "geometry", QRectF(5, 5 + 64 + 5, 64, 64));
- state3->setPropertyOnEntry(p3, "geometry", QRectF(5, 5 + (64 + 5) + 64, 64, 64));
- state3->setPropertyOnEntry(p4, "geometry", QRectF(5 + 64 + 5, 5, 64, 64));
- state3->setPropertyOnEntry(p5, "geometry", QRectF(5 + 64 + 5, 5 + 64 + 5, 64, 64));
- state3->setPropertyOnEntry(p6, "geometry", QRectF(5 + 64 + 5, 5 + (64 + 5) + 64, 64, 64));
- state3->setPropertyOnEntry(widget, "geometry", QRectF(138, 5, 400 - 138, 200));
- state3->setPropertyOnEntry(box, "geometry", QRect(5, 205, 400, 90));
- state3->setPropertyOnEntry(p1, "opacity", qreal(1));
- state3->setPropertyOnEntry(p2, "opacity", qreal(1));
- state3->setPropertyOnEntry(p3, "opacity", qreal(1));
- state3->setPropertyOnEntry(p4, "opacity", qreal(1));
- state3->setPropertyOnEntry(p5, "opacity", qreal(1));
- state3->setPropertyOnEntry(p6, "opacity", qreal(1));
+ state3->assignProperty(button, "text", "Switch to state 1");
+ state3->assignProperty(p1, "geometry", QRectF(5, 5, 64, 64));
+ state3->assignProperty(p2, "geometry", QRectF(5, 5 + 64 + 5, 64, 64));
+ state3->assignProperty(p3, "geometry", QRectF(5, 5 + (64 + 5) + 64, 64, 64));
+ state3->assignProperty(p4, "geometry", QRectF(5 + 64 + 5, 5, 64, 64));
+ state3->assignProperty(p5, "geometry", QRectF(5 + 64 + 5, 5 + 64 + 5, 64, 64));
+ state3->assignProperty(p6, "geometry", QRectF(5 + 64 + 5, 5 + (64 + 5) + 64, 64, 64));
+ state3->assignProperty(widget, "geometry", QRectF(138, 5, 400 - 138, 200));
+ state3->assignProperty(box, "geometry", QRect(5, 205, 400, 90));
+ state3->assignProperty(p1, "opacity", qreal(1));
+ state3->assignProperty(p2, "opacity", qreal(1));
+ state3->assignProperty(p3, "opacity", qreal(1));
+ state3->assignProperty(p4, "opacity", qreal(1));
+ state3->assignProperty(p5, "opacity", qreal(1));
+ state3->assignProperty(p6, "opacity", qreal(1));
QParallelAnimationGroup animation1;
@@ -244,9 +244,12 @@ int main(int argc, char *argv[])
animation3.addAnimation(new QPropertyAnimation(p5, "opacity"));
animation3.addAnimation(new QPropertyAnimation(p6, "opacity"));
- state1->addAnimatedTransition(button, SIGNAL(clicked()), state2, &animation1);
- state2->addAnimatedTransition(button, SIGNAL(clicked()), state3, &animation2);
- state3->addAnimatedTransition(button, SIGNAL(clicked()), state1, &animation3);
+ QAbstractTransition *t1 = state1->addTransition(button, SIGNAL(clicked()), state2);
+ t1->addAnimation(&animation1);
+ QAbstractTransition *t2 = state2->addTransition(button, SIGNAL(clicked()), state3);
+ t2->addAnimation(&animation2);
+ QAbstractTransition *t3 = state3->addTransition(button, SIGNAL(clicked()), state1);
+ t3->addAnimation(&animation3);
machine.start();
diff --git a/examples/animation/stickman/editor/animationdialog.cpp b/examples/animation/stickman/editor/animationdialog.cpp
new file mode 100644
index 0000000000..ca0daf0d54
--- /dev/null
+++ b/examples/animation/stickman/editor/animationdialog.cpp
@@ -0,0 +1,151 @@
+#include "animationdialog.h"
+#include "stickman.h"
+#include "animation.h"
+#include "node.h"
+
+#include <QHBoxLayout>
+#include <QStackedWidget>
+#include <QSpinBox>
+#include <QPushButton>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMessageBox>
+#include <QFileDialog>
+
+AnimationDialog::AnimationDialog(StickMan *stickman, QWidget *parent)
+ : QDialog(parent), m_animation(0), m_stickman(stickman)
+{
+ initUi();
+}
+
+AnimationDialog::~AnimationDialog()
+{
+ delete m_animation;
+}
+
+void AnimationDialog::initUi()
+{
+ setWindowTitle("Animation");
+ setEnabled(false);
+
+ // Second page
+ m_currentFrame = new QSpinBox();
+ m_totalFrames = new QSpinBox();
+ m_name = new QLineEdit();
+
+ connect(m_currentFrame, SIGNAL(valueChanged(int)), this, SLOT(currentFrameChanged(int)));
+ connect(m_totalFrames, SIGNAL(valueChanged(int)), this, SLOT(totalFramesChanged(int)));
+ connect(m_name, SIGNAL(textChanged(QString)), this, SLOT(setCurrentAnimationName(QString)));
+
+ QGridLayout *gridLayout = new QGridLayout(this);
+ gridLayout->addWidget(new QLabel("Name:"), 0, 0, 1, 2);
+ gridLayout->addWidget(m_name, 0, 2, 1, 2);
+ gridLayout->addWidget(new QLabel("Frame:"), 1, 0);
+ gridLayout->addWidget(m_currentFrame, 1, 1);
+ gridLayout->addWidget(new QLabel("of total # of frames: "), 1, 2);
+ gridLayout->addWidget(m_totalFrames, 1, 3);
+}
+
+void AnimationDialog::initFromAnimation()
+{
+ m_currentFrame->setRange(0, m_animation->totalFrames()-1);
+ m_currentFrame->setValue(m_animation->currentFrame());
+
+ m_totalFrames->setRange(1, 1000);
+ m_totalFrames->setValue(m_animation->totalFrames());
+
+ m_name->setText(m_animation->name());
+}
+
+void AnimationDialog::saveAnimation()
+{
+ saveCurrentFrame();
+
+ QString fileName = QFileDialog::getSaveFileName(this, "Save animation");
+
+ QFile file(fileName);
+ if (file.open(QIODevice::WriteOnly))
+ m_animation->save(&file);
+}
+
+void AnimationDialog::loadAnimation()
+{
+ if (maybeSave() != QMessageBox::Cancel) {
+ QString fileName = QFileDialog::getOpenFileName(this, "Open animation");
+
+ QFile file(fileName);
+ if (file.open(QIODevice::ReadOnly)) {
+ if (m_animation == 0)
+ newAnimation();
+
+ m_animation->load(&file);
+ stickManFromCurrentFrame();
+ initFromAnimation();
+ }
+ }
+}
+
+QMessageBox::StandardButton AnimationDialog::maybeSave()
+{
+ if (m_animation == 0)
+ return QMessageBox::No;
+
+ QMessageBox::StandardButton button = QMessageBox::question(this, "Save?", "Do you want to save your changes?",
+ QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+ if (button == QMessageBox::Save)
+ saveAnimation();
+
+ return button;
+}
+
+void AnimationDialog::newAnimation()
+{
+ if (maybeSave() != QMessageBox::Cancel) {
+ setEnabled(true);
+ delete m_animation;
+ m_animation = new Animation();
+ initFromAnimation();
+ }
+}
+
+// Gets the data from the stickman and stores it in current frame
+void AnimationDialog::saveCurrentFrame()
+{
+ int count = m_stickman->nodeCount();
+ m_animation->setNodeCount(count);
+ for (int i=0; i<count; ++i) {
+ QGraphicsItem *node = m_stickman->node(i);
+ m_animation->setNodePos(i, node->pos());
+ }
+}
+
+// Gets the data from the current frame and sets the stickman
+void AnimationDialog::stickManFromCurrentFrame()
+{
+ int count = m_animation->nodeCount();
+ for (int i=0;i<count;++i) {
+ QGraphicsItem *node = m_stickman->node(i);
+ node->setPos(m_animation->nodePos(i));
+ }
+}
+
+void AnimationDialog::currentFrameChanged(int currentFrame)
+{
+ saveCurrentFrame();
+ qDebug("currentFrame: %d", currentFrame);
+ m_animation->setCurrentFrame(currentFrame);
+ stickManFromCurrentFrame();
+ initFromAnimation();
+}
+
+void AnimationDialog::totalFramesChanged(int totalFrames)
+{
+ m_animation->setTotalFrames(totalFrames);
+ stickManFromCurrentFrame();
+ initFromAnimation();
+}
+
+void AnimationDialog::setCurrentAnimationName(const QString &name)
+{
+ m_animation->setName(name);
+} \ No newline at end of file
diff --git a/examples/animation/stickman/editor/animationdialog.h b/examples/animation/stickman/editor/animationdialog.h
new file mode 100644
index 0000000000..c144fd82f0
--- /dev/null
+++ b/examples/animation/stickman/editor/animationdialog.h
@@ -0,0 +1,41 @@
+#ifndef ANIMATIONDIALOG_H
+#define ANIMATIONDIALOG_H
+
+#include <QDialog>
+#include <QMessageBox>
+
+class QSpinBox;
+class QLineEdit;
+class StickMan;
+class Animation;
+class AnimationDialog: public QDialog
+{
+ Q_OBJECT
+public:
+ AnimationDialog(StickMan *stickMan, QWidget *parent = 0);
+ ~AnimationDialog();
+
+public slots:
+ void currentFrameChanged(int currentFrame);
+ void totalFramesChanged(int totalFrames);
+ void setCurrentAnimationName(const QString &name);
+
+ void newAnimation();
+ void saveAnimation();
+ void loadAnimation();
+
+private:
+ void saveCurrentFrame();
+ void stickManFromCurrentFrame();
+ void initFromAnimation();
+ void initUi();
+ QMessageBox::StandardButton maybeSave();
+
+ QSpinBox *m_currentFrame;
+ QSpinBox *m_totalFrames;
+ QLineEdit *m_name;
+ Animation *m_animation;
+ StickMan *m_stickman;
+};
+
+#endif
diff --git a/examples/animation/stickman/editor/editor.pri b/examples/animation/stickman/editor/editor.pri
new file mode 100644
index 0000000000..7ad9edba4a
--- /dev/null
+++ b/examples/animation/stickman/editor/editor.pri
@@ -0,0 +1,2 @@
+SOURCES += $$PWD/animationdialog.cpp $$PWD/mainwindow.cpp
+HEADERS += $$PWD/animationdialog.h $$PWD/mainwindow.h
diff --git a/examples/animation/stickman/editor/mainwindow.cpp b/examples/animation/stickman/editor/mainwindow.cpp
new file mode 100644
index 0000000000..158c9b78d9
--- /dev/null
+++ b/examples/animation/stickman/editor/mainwindow.cpp
@@ -0,0 +1,35 @@
+#include "mainwindow.h"
+#include "animationdialog.h"
+#include "stickman.h"
+
+#include <QMenuBar>
+#include <QApplication>
+
+MainWindow::MainWindow(StickMan *stickMan)
+{
+ initActions(stickMan);
+}
+
+MainWindow::~MainWindow()
+{
+}
+
+void MainWindow::initActions(StickMan *stickMan)
+{
+ AnimationDialog *dialog = new AnimationDialog(stickMan, this);
+ dialog->show();
+
+ QMenu *fileMenu = menuBar()->addMenu("&File");
+ QAction *loadAction = fileMenu->addAction("&Open");
+ QAction *saveAction = fileMenu->addAction("&Save");
+ QAction *exitAction = fileMenu->addAction("E&xit");
+
+ QMenu *animationMenu = menuBar()->addMenu("&Animation");
+ QAction *newAnimationAction = animationMenu->addAction("&New animation");
+
+ connect(loadAction, SIGNAL(triggered()), dialog, SLOT(loadAnimation()));
+ connect(saveAction, SIGNAL(triggered()), dialog, SLOT(saveAnimation()));
+ connect(exitAction, SIGNAL(triggered()), QApplication::instance(), SLOT(quit()));
+ connect(newAnimationAction, SIGNAL(triggered()), dialog, SLOT(newAnimation()));
+
+}
diff --git a/examples/animation/stickman/editor/mainwindow.h b/examples/animation/stickman/editor/mainwindow.h
new file mode 100644
index 0000000000..279fc07202
--- /dev/null
+++ b/examples/animation/stickman/editor/mainwindow.h
@@ -0,0 +1,17 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+class StickMan;
+class MainWindow: public QMainWindow
+{
+public:
+ MainWindow(StickMan *stickMan);
+ ~MainWindow();
+
+private:
+ void initActions(StickMan *stickMan);
+};
+
+#endif
diff --git a/examples/animation/stickman/graphicsview.cpp b/examples/animation/stickman/graphicsview.cpp
index 1b6afa9e6a..d4f0e3a991 100644
--- a/examples/animation/stickman/graphicsview.cpp
+++ b/examples/animation/stickman/graphicsview.cpp
@@ -1,14 +1,39 @@
#include "graphicsview.h"
+#include "editor/mainwindow.h"
+#include "stickman.h"
#include <QtGui/QKeyEvent>
+#include <QtGui/QGraphicsScene>
+#include <QtGui/QGraphicsView>
-GraphicsView::GraphicsView(QWidget *parent) : QGraphicsView(parent) {}
+GraphicsView::GraphicsView(QWidget *parent) : QGraphicsView(parent), m_editor(0) {}
void GraphicsView::keyPressEvent(QKeyEvent *e)
{
if (e->key() == Qt::Key_Escape)
close();
+#if 0
+ if (e->key() == Qt::Key_F1) {
+ if (m_editor == 0) {
+ QGraphicsScene *scene = new QGraphicsScene;
+ StickMan *stickMan = new StickMan;
+ stickMan->setDrawSticks(true);
+ scene->addItem(stickMan);
+
+ QGraphicsView *view = new QGraphicsView;
+ view->setBackgroundBrush(Qt::black);
+ view->setRenderHints(QPainter::Antialiasing);
+ view->setScene(scene);
+
+ m_editor = new MainWindow(stickMan);
+ m_editor->setCentralWidget(view);
+ }
+
+ m_editor->showMaximized();
+ }
+#endif
+
emit keyPressed(Qt::Key(e->key()));
}
diff --git a/examples/animation/stickman/graphicsview.h b/examples/animation/stickman/graphicsview.h
index 9ea2cfb373..58ed95b043 100644
--- a/examples/animation/stickman/graphicsview.h
+++ b/examples/animation/stickman/graphicsview.h
@@ -3,6 +3,7 @@
#include <QtGui/QGraphicsView>
+class MainWindow;
class GraphicsView: public QGraphicsView
{
Q_OBJECT
@@ -14,6 +15,9 @@ protected:
signals:
void keyPressed(int key);
+
+private:
+ MainWindow *m_editor;
};
#endif
diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp
index 3e92aec652..9233760536 100644
--- a/examples/animation/stickman/lifecycle.cpp
+++ b/examples/animation/stickman/lifecycle.cpp
@@ -6,6 +6,15 @@
#include <QtCore>
#include <QtGui>
+#if defined(QT_EXPERIMENTAL_SOLUTION)
+#include "qstatemachine.h"
+#include "qstate.h"
+#include "qeventtransition.h"
+#include "qsignaltransition.h"
+#include "qsignalevent.h"
+#include "qpropertyanimation.h"
+#include "qparallelanimationgroup.h"
+#endif
class KeyPressTransition: public QSignalTransition
{
@@ -69,27 +78,34 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
// Make it blink when lightning strikes before entering dead animation
QState *lightningBlink = new QState(m_machine->rootState());
lightningBlink->setRestorePolicy(QState::DoNotRestoreProperties);
- lightningBlink->setPropertyOnEntry(m_stickMan->scene(), "backgroundBrush", Qt::white);
- lightningBlink->setPropertyOnEntry(m_stickMan, "penColor", Qt::black);
- lightningBlink->setPropertyOnEntry(m_stickMan, "fillColor", Qt::white);
- lightningBlink->setPropertyOnEntry(m_stickMan, "isDead", true);
+ lightningBlink->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::white);
+ lightningBlink->assignProperty(m_stickMan, "penColor", Qt::black);
+ lightningBlink->assignProperty(m_stickMan, "fillColor", Qt::white);
+ lightningBlink->assignProperty(m_stickMan, "isDead", true);
+
+ QTimer *timer = new QTimer(lightningBlink);
+ timer->setSingleShot(true);
+ timer->setInterval(100);
+ lightningBlink->invokeMethodOnEntry(timer, "start");
+ lightningBlink->invokeMethodOnExit(timer, "stop");
m_dead = new QState(m_machine->rootState());
m_dead->setRestorePolicy(QState::DoNotRestoreProperties);
- m_dead->setPropertyOnEntry(m_stickMan->scene(), "backgroundBrush", Qt::black);
- m_dead->setPropertyOnEntry(m_stickMan, "penColor", Qt::white);
- m_dead->setPropertyOnEntry(m_stickMan, "fillColor", Qt::black);
+ m_dead->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::black);
+ m_dead->assignProperty(m_stickMan, "penColor", Qt::white);
+ m_dead->assignProperty(m_stickMan, "fillColor", Qt::black);
m_dead->setObjectName("dead");
// Idle state (sets no properties)
m_idle = new QState(m_alive);
m_idle->setObjectName("idle");
+
m_alive->setInitialState(m_idle);
// Lightning strikes at random
m_alive->addTransition(new LightningStrikesTransition(lightningBlink));
- m_alive->addTransition(new KeyPressTransition(m_keyReceiver, Qt::Key_L, lightningBlink));
- connectByAnimation(m_machine->rootState(), lightningBlink, m_dead);
+ //m_alive->addTransition(new KeyPressTransition(m_keyReceiver, Qt::Key_L, lightningBlink));
+ connectByAnimation(lightningBlink, m_dead, new QSignalTransition(timer, SIGNAL(timeout())));
m_machine->setInitialState(m_alive);
}
@@ -98,7 +114,9 @@ void LifeCycle::setResetKey(Qt::Key resetKey)
{
// When resetKey is pressed, enter the idle state and do a restoration animation
// (requires no animation pointer, since no property is being set in the idle state)
- m_alive->addAnimatedTransition(new KeyPressTransition(m_keyReceiver, resetKey, m_idle));
+ KeyPressTransition *trans = new KeyPressTransition(m_keyReceiver, resetKey, m_idle);
+ trans->addAnimation(m_animationGroup);
+ m_alive->addTransition(trans);
}
void LifeCycle::setDeathAnimation(const QString &fileName)
@@ -112,26 +130,22 @@ void LifeCycle::start()
m_machine->start();
}
-void LifeCycle::connectByAnimation(QState *parentState,
- QState *s1, QAbstractState *s2,
+void LifeCycle::connectByAnimation(QState *s1, QAbstractState *s2,
QAbstractTransition *transition)
{
- QAnimationState *animationState = new QAnimationState(m_animationGroup, parentState);
-
- if (transition == 0)
- s1->addTransition(animationState);
- else {
- transition->setTargetStates(QList<QAbstractState*>() << animationState);
+ if (transition == 0) {
+ transition = s1->addTransition(s2);
+ } else {
+ transition->setTargetState(s2);
s1->addTransition(transition);
}
-
- animationState->addFinishedTransition(s2);
+ transition->addAnimation(m_animationGroup);
}
void LifeCycle::addActivity(const QString &fileName, Qt::Key key)
{
QState *state = makeState(m_alive, fileName);
- connectByAnimation(m_alive, m_alive, state, new KeyPressTransition(m_keyReceiver, key));
+ connectByAnimation(m_alive, state, new KeyPressTransition(m_keyReceiver, key));
}
QState *LifeCycle::makeState(QState *parentState, const QString &animationFileName)
@@ -149,21 +163,25 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa
QState *previousState = 0;
for (int i=0; i<frameCount; ++i) {
QState *frameState = new QState(topLevel);
-
+ frameState->setObjectName(QString::fromLatin1("frame %0").arg(i));
+
animation.setCurrentFrame(i);
const int nodeCount = animation.nodeCount();
for (int j=0; j<nodeCount; ++j)
- frameState->setPropertyOnEntry(m_stickMan->node(j), "position", animation.nodePos(j));
+ frameState->assignProperty(m_stickMan->node(j), "position", animation.nodePos(j));
- if (previousState == 0)
+ if (previousState == 0) {
topLevel->setInitialState(frameState);
- else
- connectByAnimation(topLevel, previousState, frameState);
+ } else {
+ connectByAnimation(previousState, frameState,
+ new QSignalTransition(m_machine, SIGNAL(animationsFinished())));
+ }
previousState = frameState;
}
// Loop
- connectByAnimation(topLevel, previousState, topLevel->initialState());
+ connectByAnimation(previousState, topLevel->initialState(),
+ new QSignalTransition(m_machine, SIGNAL(animationsFinished())));
return topLevel;
diff --git a/examples/animation/stickman/lifecycle.h b/examples/animation/stickman/lifecycle.h
index 8094a76dcf..437e935e51 100644
--- a/examples/animation/stickman/lifecycle.h
+++ b/examples/animation/stickman/lifecycle.h
@@ -23,7 +23,7 @@ public:
void start();
private:
- void connectByAnimation(QState *parentState, QState *s1, QAbstractState *s2,
+ void connectByAnimation(QState *s1, QAbstractState *s2,
QAbstractTransition *transition = 0);
QState *makeState(QState *parentState, const QString &animationFileName);
diff --git a/examples/animation/stickman/main.cpp b/examples/animation/stickman/main.cpp
index a094e289b1..62860ec862 100644
--- a/examples/animation/stickman/main.cpp
+++ b/examples/animation/stickman/main.cpp
@@ -26,7 +26,7 @@ int main(int argc, char **argv)
"<li>Press <font color=\"purple\">Return</font> to make him return to his original position.</li>"
"<li>When you are done, press <font color=\"purple\">Escape</font>.</li>"
"</i></p>"
- "<p>If you are unlucky, the stickman will get struck by lightning, and never jump, dance or chill out again."
+ "<p>If he is unlucky, the stickman will get struck by lightning, and never jump, dance or chill out again."
"</p></font>");
qreal w = textItem->boundingRect().width();
QRectF stickManBoundingRect = stickMan->mapToScene(stickMan->boundingRect()).boundingRect();
diff --git a/examples/animation/stickman/node.cpp b/examples/animation/stickman/node.cpp
index f3468d00ce..5932b60204 100644
--- a/examples/animation/stickman/node.cpp
+++ b/examples/animation/stickman/node.cpp
@@ -1,4 +1,5 @@
#include "node.h"
+#include "stickman.h"
#include <QRectF>
#include <QPainter>
@@ -25,6 +26,14 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
painter->drawEllipse(QPointF(0.0, 0.0), 5.0, 5.0);
}
+QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ if (change == QGraphicsItem::ItemPositionChange)
+ emit positionChanged();
+
+ return QGraphicsItem::itemChange(change, value);
+}
+
void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
m_dragging = true;
diff --git a/examples/animation/stickman/node.h b/examples/animation/stickman/node.h
index b796774d33..e9e9190dac 100644
--- a/examples/animation/stickman/node.h
+++ b/examples/animation/stickman/node.h
@@ -14,7 +14,12 @@ public:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+signals:
+ void positionChanged();
+
protected:
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+
void mousePressEvent(QGraphicsSceneMouseEvent *);
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
diff --git a/examples/animation/stickman/stickman.cpp b/examples/animation/stickman/stickman.cpp
index 22d48d3055..13938369da 100644
--- a/examples/animation/stickman/stickman.cpp
+++ b/examples/animation/stickman/stickman.cpp
@@ -81,6 +81,7 @@ StickMan::StickMan()
// Set up start position of limbs
for (int i=0; i<NodeCount; ++i) {
m_nodes[i] = new Node(QPointF(Coords[i * 2], Coords[i * 2 + 1]), this);
+ connect(m_nodes[i], SIGNAL(positionChanged()), this, SLOT(childPositionChanged()));
}
m_perfectBoneLengths = new qreal[BoneCount];
@@ -103,6 +104,11 @@ StickMan::~StickMan()
delete m_nodes;
}
+void StickMan::childPositionChanged()
+{
+ prepareGeometryChange();
+}
+
void StickMan::setDrawSticks(bool on)
{
m_sticks = on;
@@ -114,8 +120,8 @@ void StickMan::setDrawSticks(bool on)
QRectF StickMan::boundingRect() const
{
- // account for head radius=50.0 plus pen which is 5.0, plus jump height :-)
- return QRectF(-125, -200, 250, 450 + 50).adjusted(-55.0, -55.0, 55.0, 55.0);
+ // account for head radius=50.0 plus pen which is 5.0
+ return childrenBoundingRect().adjusted(-55.0, -55.0, 55.0, 55.0);
}
int StickMan::nodeCount() const
@@ -125,7 +131,6 @@ int StickMan::nodeCount() const
Node *StickMan::node(int idx) const
{
- const_cast<StickMan *>(this)->prepareGeometryChange();
if (idx >= 0 && idx < NodeCount)
return m_nodes[idx];
else
@@ -134,11 +139,13 @@ Node *StickMan::node(int idx) const
void StickMan::timerEvent(QTimerEvent *e)
{
- prepareGeometryChange();
+ update();
}
void StickMan::stabilize()
{
+ static const qreal threshold = 0.001;
+
for (int i=0; i<BoneCount; ++i) {
int n1 = Bones[i * 2];
int n2 = Bones[i * 2 + 1];
@@ -153,12 +160,14 @@ void StickMan::stabilize()
qreal length = sqrt(pow(dist.x(),2) + pow(dist.y(),2));
qreal diff = (length - m_perfectBoneLengths[i]) / length;
- pos1 -= dist * (0.5 * diff);
- pos2 += dist * (0.5 * diff);
-
- node1->setPos(pos1);
- node2->setPos(pos2);
+ QPointF p = dist * (0.5 * diff);
+ if (p.x() > threshold && p.y() > threshold) {
+ pos1 -= p;
+ pos2 += p;
+ node1->setPos(pos1);
+ node2->setPos(pos2);
+ }
}
}
@@ -245,19 +254,12 @@ void StickMan::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidge
qreal angle = asin(sinAngle) * 180.0 / M_PI;
QPointF headPos = node1->pos();
- painter->save();
painter->translate(headPos);
painter->rotate(-angle);
painter->setBrush(m_fillColor);
painter->drawEllipse(QPointF(0,0), 50.0, 50.0);
- /*painter->drawArc(QRectF(-20.0, 0.0, 40.0, 20.0), 30.0 * 16, 120.0 * 16);
-
- painter->setBrush(m_penColor);
- painter->drawEllipse(QPointF(-30.0, -30.0), 2.5, 2.5);
- painter->drawEllipse(QPointF(30.0, -30.0), 2.5, 2.5);*/
-
painter->setBrush(m_penColor);
painter->setPen(QPen(m_penColor, 2.5, Qt::SolidLine, Qt::RoundCap));
@@ -288,9 +290,6 @@ void StickMan::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidge
painter->drawEllipse(QPointF(-12.0, -25.0), 5.0, 5.0);
painter->drawEllipse(QPointF(22.0, -25.0), 5.0, 5.0);
}
-
-
- painter->restore();
}
}
}
diff --git a/examples/animation/stickman/stickman.h b/examples/animation/stickman/stickman.h
index ae406ca4b0..e659cdb031 100644
--- a/examples/animation/stickman/stickman.h
+++ b/examples/animation/stickman/stickman.h
@@ -37,6 +37,7 @@ public:
public slots:
void stabilize();
+ void childPositionChanged();
protected:
void timerEvent(QTimerEvent *e);
diff --git a/examples/animation/stickman/stickman.pro b/examples/animation/stickman/stickman.pro
index 136cb44154..bfee5b0017 100644
--- a/examples/animation/stickman/stickman.pro
+++ b/examples/animation/stickman/stickman.pro
@@ -7,6 +7,8 @@ TARGET =
DEPENDPATH += .
INCLUDEPATH += .
+include(editor/editor.pri)
+
# Input
HEADERS += stickman.h animation.h node.h lifecycle.h graphicsview.h
SOURCES += main.cpp stickman.cpp animation.cpp node.cpp lifecycle.cpp graphicsview.cpp
diff --git a/examples/animation/sub-attaq/boat.cpp b/examples/animation/sub-attaq/boat.cpp
index 6824f1768d..633e1b167c 100644
--- a/examples/animation/sub-attaq/boat.cpp
+++ b/examples/animation/sub-attaq/boat.cpp
@@ -47,6 +47,7 @@
#include "graphicsscene.h"
#include "animationmanager.h"
#include "custompropertyanimation.h"
+#include "qanimationstate.h"
//Qt
#if defined(QT_EXPERIMENTAL_SOLUTION)
@@ -56,7 +57,6 @@
# include "qfinalstate.h"
# include "qstate.h"
#include "qsequentialanimationgroup.h"
-#include "qanimationstate.h"
#else
#include <QPropertyAnimation>
#include <QStateMachine>
@@ -64,7 +64,6 @@
#include <QFinalState>
#include <QState>
#include <QSequentialAnimationGroup>
-#include <QAnimationState>
#endif
static QAbstractAnimation *setupDestroyAnimation(Boat *boat)
@@ -208,13 +207,13 @@ Boat::Boat(QGraphicsItem * parent, Qt::WindowFlags wFlags)
//This state play the destroyed animation
QAnimationState *destroyedState = new QAnimationState(machine->rootState());
- destroyedState->addAnimation(setupDestroyAnimation(this));
+ destroyedState->setAnimation(setupDestroyAnimation(this));
//Play a nice animation when the boat is destroyed
moving->addTransition(this, SIGNAL(boatDestroyed()),destroyedState);
//Transition to final state when the destroyed animation is finished
- destroyedState->addFinishedTransition(final);
+ destroyedState->addTransition(destroyedState, SIGNAL(animationFinished()), final);
//The machine has finished to be executed, then the boat is dead
connect(machine,SIGNAL(finished()),this, SIGNAL(boatExecutionFinished()));
diff --git a/examples/animation/sub-attaq/bomb.cpp b/examples/animation/sub-attaq/bomb.cpp
index b6ae5a347f..04310aa9bc 100644
--- a/examples/animation/sub-attaq/bomb.cpp
+++ b/examples/animation/sub-attaq/bomb.cpp
@@ -44,19 +44,18 @@
#include "submarine.h"
#include "pixmapitem.h"
#include "animationmanager.h"
+#include "qanimationstate.h"
//Qt
#if defined(QT_EXPERIMENTAL_SOLUTION)
#include "qpropertyanimation.h"
#include "qsequentialanimationgroup.h"
-#include "qanimationstate.h"
#include "qstatemachine.h"
#include "qfinalstate.h"
#else
#include <QtCore/QSequentialAnimationGroup>
#include <QtCore/QPropertyAnimation>
-#include <QtCore/QAnimationState>
#include <QtCore/QStateMachine>
#include <QtCore/QFinalState>
#endif
@@ -94,18 +93,19 @@ void Bomb::launch(Bomb::Direction direction)
QStateMachine *machine = new QStateMachine(this);
//This state is when the launch animation is playing
- QAnimationState *launched = new QAnimationState(launchAnimation,machine->rootState());
-
- machine->setInitialState(launched);
+ QAnimationState *launched = new QAnimationState(machine->rootState());
+ launched->setAnimation(launchAnimation);
//End
QFinalState *final = new QFinalState(machine->rootState());
+ machine->setInitialState(launched);
+
//### Add a nice animation when the bomb is destroyed
launched->addTransition(this, SIGNAL(bombExplosed()),final);
//If the animation is finished, then we move to the final state
- launched->addFinishedTransition(final);
+ launched->addTransition(launched, SIGNAL(animationFinished()), final);
//The machine has finished to be executed, then the boat is dead
connect(machine,SIGNAL(finished()),this, SIGNAL(bombExecutionFinished()));
diff --git a/examples/animation/sub-attaq/custompropertyanimation.cpp b/examples/animation/sub-attaq/custompropertyanimation.cpp
index 45997afe7d..f7ab269046 100644
--- a/examples/animation/sub-attaq/custompropertyanimation.cpp
+++ b/examples/animation/sub-attaq/custompropertyanimation.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include "custompropertyanimation.h"
-#include "custompropertyanimation_p.h"
// Qt
#include <QtCore/qdebug.h>
@@ -48,23 +47,8 @@
QT_BEGIN_NAMESPACE
-void CustomPropertyAnimationPrivate::initDefaultStartValue()
-{
- if (!animProp)
- return;
- QVariant def = animProp->read();
- if (def.isValid())
- convertValues(def.userType());
- if (animProp && !defaultStartValue.isValid()
- && ((currentTime == 0 && (currentIteration || currentIteration == 0))
- || (currentTime == duration && currentIteration == (iterationCount - 1)))) {
- setDefaultStartValue(def);
- }
-}
-
-
CustomPropertyAnimation::CustomPropertyAnimation(QObject *parent) :
- QVariantAnimation(*new CustomPropertyAnimationPrivate, parent)
+ QVariantAnimation(parent), animProp(0)
{
}
@@ -72,13 +56,12 @@ CustomPropertyAnimation::~CustomPropertyAnimation()
{
}
-void CustomPropertyAnimation::setProperty(AbstractProperty *animProp)
+void CustomPropertyAnimation::setProperty(AbstractProperty *_animProp)
{
- Q_D(CustomPropertyAnimation);
- if (d->animProp == animProp)
+ if (animProp == _animProp)
return;
- delete d->animProp;
- d->animProp = animProp;
+ delete animProp;
+ animProp = _animProp;
}
/*!
@@ -86,11 +69,10 @@ void CustomPropertyAnimation::setProperty(AbstractProperty *animProp)
*/
void CustomPropertyAnimation::updateCurrentValue(const QVariant &value)
{
- Q_D(CustomPropertyAnimation);
- if (!d->animProp || state() == QAbstractAnimation::Stopped)
+ if (!animProp || state() == QAbstractAnimation::Stopped)
return;
- d->animProp->write(value);
+ animProp->write(value);
}
@@ -99,10 +81,29 @@ void CustomPropertyAnimation::updateCurrentValue(const QVariant &value)
*/
void CustomPropertyAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState)
{
- Q_D(CustomPropertyAnimation);
// Initialize start value
- if (oldState == QAbstractAnimation::Stopped)
- d->initDefaultStartValue();
+ if (oldState == QAbstractAnimation::Stopped) {
+ if (!animProp)
+ return;
+ QVariant def = animProp->read();
+ if (def.isValid()) {
+ const int t = def.userType();
+ KeyValues values = keyValues();
+ //this ensures that all the keyValues are of type t
+ for (int i = 0; i < values.count(); ++i) {
+ QVariantAnimation::KeyValue &pair = values[i];
+ if (pair.second.userType() != t)
+ pair.second.convert(static_cast<QVariant::Type>(t));
+ }
+ //let's now update the key values
+ setKeyValues(values);
+ }
+
+ if (animProp && !startValue().isValid() && currentTime() == 0
+ || (currentTime() == duration() && currentLoop() == (loopCount() - 1))) {
+ setStartValue(def);
+ }
+ }
QVariantAnimation::updateState(oldState, newState);
}
diff --git a/examples/animation/sub-attaq/custompropertyanimation.h b/examples/animation/sub-attaq/custompropertyanimation.h
index ba6ef5598e..48a50c9732 100644
--- a/examples/animation/sub-attaq/custompropertyanimation.h
+++ b/examples/animation/sub-attaq/custompropertyanimation.h
@@ -49,7 +49,6 @@
#endif
class QGraphicsItem;
-class CustomPropertyAnimationPrivate;
struct AbstractProperty
{
@@ -111,7 +110,7 @@ public:
private:
Q_DISABLE_COPY(CustomPropertyAnimation);
- Q_DECLARE_PRIVATE(CustomPropertyAnimation);
+ AbstractProperty *animProp;
};
#endif // CUSTOMPROPERTYANIMATION_H
diff --git a/examples/animation/sub-attaq/graphicsscene.cpp b/examples/animation/sub-attaq/graphicsscene.cpp
index a7f4c1b7a9..5dcc0349e7 100644
--- a/examples/animation/sub-attaq/graphicsscene.cpp
+++ b/examples/animation/sub-attaq/graphicsscene.cpp
@@ -49,6 +49,7 @@
#include "pixmapitem.h"
#include "custompropertyanimation.h"
#include "animationmanager.h"
+#include "qanimationstate.h"
//Qt
#if defined(QT_EXPERIMENTAL_SOLUTION)
@@ -56,7 +57,6 @@
#include "qsequentialanimationgroup.h"
#include "qparallelanimationgroup.h"
#include "qstatemachine.h"
-#include "qanimationstate.h"
#include "qfinalstate.h"
#include "qpauseanimation.h"
#else
@@ -64,7 +64,6 @@
#include <QSequentialAnimationGroup>
#include <QParallelAnimationGroup>
#include <QStateMachine>
-#include <QAnimationState>
#include <QFinalState>
#include <QPauseAnimation>
#endif
@@ -236,18 +235,26 @@ void GraphicsScene::setupScene(const QList<QAction *> &actions)
QFinalState *final = new QFinalState(machine->rootState());
//Animation when the player enter in the game
- QAnimationState *animationState = new QAnimationState(lettersGroupMoving, machine->rootState());
- animationState->addAnimatedTransition(newAction, SIGNAL(triggered()),gameState,lettersGroupFading);
+ QAnimationState *lettersMovingState = new QAnimationState(machine->rootState());
+ lettersMovingState->setAnimation(lettersGroupMoving);
+
+ //Animation when the welcome screen disappear
+ QAnimationState *lettersFadingState = new QAnimationState(machine->rootState());
+ lettersFadingState->setAnimation(lettersGroupFading);
+
+ //if new game then we fade out the welcome screen and start playing
+ lettersMovingState->addTransition(newAction, SIGNAL(triggered()),lettersFadingState);
+ lettersFadingState->addTransition(lettersFadingState, SIGNAL(animationFinished()),gameState);
//New Game is triggered then player start playing
gameState->addTransition(newAction, SIGNAL(triggered()),gameState);
//Wanna quit, then connect to CTRL+Q
gameState->addTransition(quitAction, SIGNAL(triggered()),final);
- animationState->addTransition(quitAction, SIGNAL(triggered()),final);
+ lettersMovingState->addTransition(quitAction, SIGNAL(triggered()),final);
//Welcome screen is the initial state
- machine->setInitialState(animationState);
+ machine->setInitialState(lettersMovingState);
machine->start();
diff --git a/examples/animation/sub-attaq/qanimationstate.cpp b/examples/animation/sub-attaq/qanimationstate.cpp
new file mode 100644
index 0000000000..70285a82ce
--- /dev/null
+++ b/examples/animation/sub-attaq/qanimationstate.cpp
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qanimationstate.h"
+
+#if defined(QT_EXPERIMENTAL_SOLUTION)
+# include "qstate.h"
+#else
+# include <QtCore/qstate.h>
+#endif
+
+#include <private/qstate_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+\class QAnimationState
+
+\brief The QAnimationState class provides state that handle an animation and emit
+a signal when this animation is finished.
+
+\ingroup statemachine
+
+QAnimationState provides a state that handle an animation. It will start this animation
+when the state is entered and stop it when it is leaved. When the animation has finished the
+state emit animationFinished signal.
+QAnimationState is part of \l{The State Machine Framework}.
+
+\code
+QStateMachine machine;
+QAnimationState *s = new QAnimationState(machine->rootState());
+QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
+s->setAnimation(animation);
+QState *s2 = new QState(machine->rootState());
+s->addTransition(s, SIGNAL(animationFinished()), s2);
+machine.start();
+\endcode
+
+\sa QState, {The Animation Framework}
+*/
+
+
+#ifndef QT_NO_ANIMATION
+
+class QAnimationStatePrivate : public QStatePrivate
+{
+ Q_DECLARE_PUBLIC(QAnimationState)
+public:
+ QAnimationStatePrivate()
+ : animation(0)
+ {
+
+ }
+ ~QAnimationStatePrivate() {}
+
+ QAbstractAnimation *animation;
+};
+
+/*!
+ Constructs a new state with the given \a parent state.
+*/
+QAnimationState::QAnimationState(QState *parent)
+ : QState(*new QAnimationStatePrivate, parent)
+{
+}
+
+/*!
+ Destroys the animation state.
+*/
+QAnimationState::~QAnimationState()
+{
+}
+
+/*!
+ Set an \a animation for this QAnimationState. If an animation was previously handle by this
+ state then it won't emit animationFinished for the old animation. The QAnimationState doesn't
+ take the ownership of the animation.
+*/
+void QAnimationState::setAnimation(QAbstractAnimation *animation)
+{
+ Q_D(QAnimationState);
+
+ if (animation == d->animation)
+ return;
+
+ //Disconnect from the previous animation if exist
+ if(d->animation)
+ disconnect(d->animation, SIGNAL(finished()), this, SIGNAL(animationFinished()));
+
+ d->animation = animation;
+
+ if (d->animation) {
+ //connect the new animation
+ connect(d->animation, SIGNAL(finished()), this, SIGNAL(animationFinished()));
+ }
+}
+
+/*!
+ Returns the animation handle by this animation state, or 0 if there is no animation.
+*/
+QAbstractAnimation* QAnimationState::animation() const
+{
+ Q_D(const QAnimationState);
+ return d->animation;
+}
+
+/*!
+ \reimp
+*/
+void QAnimationState::onEntry()
+{
+ Q_D(QAnimationState);
+ if (d->animation)
+ d->animation->start();
+}
+
+/*!
+ \reimp
+*/
+void QAnimationState::onExit()
+{
+ Q_D(QAnimationState);
+ if (d->animation)
+ d->animation->stop();
+}
+
+/*!
+ \reimp
+*/
+bool QAnimationState::event(QEvent *e)
+{
+ return QState::event(e);
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/examples/animation/sub-attaq/custompropertyanimation_p.h b/examples/animation/sub-attaq/qanimationstate.h
index 89fc757ccf..ddf56815d2 100644
--- a/examples/animation/sub-attaq/custompropertyanimation_p.h
+++ b/examples/animation/sub-attaq/qanimationstate.h
@@ -3,7 +3,7 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the QtCore module of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,26 +39,54 @@
**
****************************************************************************/
-#ifndef CUSTOMPROPERTYANIMATION_P_H
-#define CUSTOMPROPERTYANIMATION_P_H
+#ifndef QANIMATIONSTATE_H
+#define QANIMATIONSTATE_H
-#ifdef QT_EXPERIMENTAL_SOLUTION
-# include "qvariantanimation_p.h"
+#ifndef QT_STATEMACHINE_SOLUTION
+# include <QtCore/qstate.h>
+# include <QtCore/qabstractanimation.h>
#else
-# include <private/qvariantanimation_p.h>
+# include "qstate.h"
+# include "qabstractanimation.h"
#endif
-class CustomPropertyAnimationPrivate : public QVariantAnimationPrivate
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ANIMATION
+
+class QAnimationStatePrivate;
+
+class QAnimationState : public QState
{
- Q_DECLARE_PUBLIC(CustomPropertyAnimation)
+ Q_OBJECT
public:
- CustomPropertyAnimationPrivate() : QVariantAnimationPrivate(), animProp(0)
- {
- }
+ QAnimationState(QState *parent = 0);
+ ~QAnimationState();
+
+ void setAnimation(QAbstractAnimation *animation);
+ QAbstractAnimation* animation() const;
- void initDefaultStartValue();
+Q_SIGNALS:
+ void animationFinished();
- AbstractProperty *animProp;
+protected:
+ void onEntry();
+ void onExit();
+ bool event(QEvent *e);
+
+private:
+ Q_DISABLE_COPY(QAnimationState)
+ Q_DECLARE_PRIVATE(QAnimationState)
};
-#endif //QTCUSTOMPROPERTYANIMATION_P_H
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QANIMATIONSTATE_H
diff --git a/examples/animation/sub-attaq/states.cpp b/examples/animation/sub-attaq/states.cpp
index 32e0bb81c6..f476f551d1 100644
--- a/examples/animation/sub-attaq/states.cpp
+++ b/examples/animation/sub-attaq/states.cpp
@@ -131,7 +131,7 @@ void PlayState::onEntry()
playState->addTransition(scoreTransition);
//We go back to play state
- scoreState->addFinishedTransition(playState);
+ scoreState->addTransition(playState);
//We start playing!!!
machine->setInitialState(playState);
@@ -242,14 +242,14 @@ void WinState::onEntry()
}
/** UpdateScore State */
-UpdateScoreState::UpdateScoreState(PlayState *game, QState *parent) : QAnimationState(parent)
+UpdateScoreState::UpdateScoreState(PlayState *game, QState *parent) : QState(parent)
{
this->game = game;
}
void UpdateScoreState::onEntry()
{
//### Make a nice anim to update the score in the scene
- QAnimationState::onEntry();
+ QState::onEntry();
}
/** Win transition */
diff --git a/examples/animation/sub-attaq/states.h b/examples/animation/sub-attaq/states.h
index 10018272c6..52d4ffaf44 100644
--- a/examples/animation/sub-attaq/states.h
+++ b/examples/animation/sub-attaq/states.h
@@ -46,12 +46,10 @@
#if defined(QT_EXPERIMENTAL_SOLUTION)
#include "qstate.h"
#include "qsignaltransition.h"
-#include "qanimationstate.h"
#include "qpropertyanimation.h"
#else
#include <QState>
#include <QSignalTransition>
-#include <QAnimationState>
#include <QPropertyAnimation>
#endif
#include <QSet>
@@ -122,7 +120,7 @@ private :
PlayState *game;
};
-class UpdateScoreState : public QAnimationState
+class UpdateScoreState : public QState
{
public:
UpdateScoreState(PlayState *game, QState *parent);
diff --git a/examples/animation/sub-attaq/sub-attaq.pro b/examples/animation/sub-attaq/sub-attaq.pro
index d8de6f5744..1456d0ecdf 100644
--- a/examples/animation/sub-attaq/sub-attaq.pro
+++ b/examples/animation/sub-attaq/sub-attaq.pro
@@ -20,8 +20,8 @@ HEADERS += boat.h \
states.h \
boat_p.h \
submarine_p.h \
- custompropertyanimation_p.h \
- custompropertyanimation.h
+ custompropertyanimation.h \
+ qanimationstate.h
SOURCES += boat.cpp \
bomb.cpp \
main.cpp \
@@ -32,5 +32,7 @@ SOURCES += boat.cpp \
graphicsscene.cpp \
animationmanager.cpp \
states.cpp \
- custompropertyanimation.cpp
+ custompropertyanimation.cpp \
+ qanimationstate.cpp
+
RESOURCES += subattaq.qrc
diff --git a/examples/animation/sub-attaq/submarine.cpp b/examples/animation/sub-attaq/submarine.cpp
index 481c7483c7..e64ffdd80a 100644
--- a/examples/animation/sub-attaq/submarine.cpp
+++ b/examples/animation/sub-attaq/submarine.cpp
@@ -47,18 +47,17 @@
#include "graphicsscene.h"
#include "animationmanager.h"
#include "custompropertyanimation.h"
+#include "qanimationstate.h"
#if defined(QT_EXPERIMENTAL_SOLUTION)
#include "qpropertyanimation.h"
#include "qstatemachine.h"
#include "qfinalstate.h"
-#include "qanimationstate.h"
#include "qsequentialanimationgroup.h"
#else
#include <QPropertyAnimation>
#include <QStateMachine>
#include <QFinalState>
-#include <QAnimationState>
#include <QSequentialAnimationGroup>
#endif
@@ -143,20 +142,20 @@ SubMarine::SubMarine(int type, const QString &name, int points, QGraphicsItem *
QFinalState *final = new QFinalState(machine->rootState());
//If the moving animation is finished we move to the return state
- movement->addFinishedTransition(rotation);
+ movement->addTransition(movement, SIGNAL(animationFinished()), rotation);
//If the return animation is finished we move to the moving state
- rotation->addFinishedTransition(movement);
+ rotation->addTransition(rotation, SIGNAL(animationFinished()), movement);
//This state play the destroyed animation
QAnimationState *destroyedState = new QAnimationState(machine->rootState());
- destroyedState->addAnimation(setupDestroyAnimation(this));
+ destroyedState->setAnimation(setupDestroyAnimation(this));
//Play a nice animation when the submarine is destroyed
moving->addTransition(this, SIGNAL(subMarineDestroyed()),destroyedState);
//Transition to final state when the destroyed animation is finished
- destroyedState->addFinishedTransition(final);
+ destroyedState->addTransition(destroyedState, SIGNAL(animationFinished()), final);
//The machine has finished to be executed, then the submarine is dead
connect(machine,SIGNAL(finished()),this, SIGNAL(subMarineExecutionFinished()));
diff --git a/examples/animation/sub-attaq/submarine_p.h b/examples/animation/sub-attaq/submarine_p.h
index 5aa84b6740..354a4064d1 100644
--- a/examples/animation/sub-attaq/submarine_p.h
+++ b/examples/animation/sub-attaq/submarine_p.h
@@ -45,18 +45,16 @@
//Own
#include "animationmanager.h"
#include "submarine.h"
+#include "qanimationstate.h"
//Qt
#if defined(QT_EXPERIMENTAL_SOLUTION)
-#include "qanimationstate.h"
#include "qpropertyanimation.h"
#else
-#include <QAnimationState>
#include <QPropertyAnimation>
#endif
#include <QGraphicsScene>
-
//This state is describing when the boat is moving right
class MovementState : public QAnimationState
{
@@ -66,16 +64,18 @@ public:
{
movementAnimation = new QPropertyAnimation(submarine, "pos");
connect(movementAnimation,SIGNAL(valueChanged(const QVariant &)),this,SLOT(onAnimationMovementValueChanged(const QVariant &)));
- addAnimation(movementAnimation);
+ setAnimation(movementAnimation);
AnimationManager::self()->registerAnimation(movementAnimation);
this->submarine = submarine;
}
+
protected slots:
void onAnimationMovementValueChanged(const QVariant &)
{
if (qrand() % 200 + 1 == 3)
submarine->launchTorpedo(qrand() % 3 + 1);
}
+
protected:
void onEntry()
{
@@ -91,11 +91,6 @@ protected:
QAnimationState::onEntry();
}
- void onExit()
- {
- movementAnimation->stop();
- QAnimationState::onExit();
- }
private:
SubMarine *submarine;
QPropertyAnimation *movementAnimation;
@@ -109,9 +104,10 @@ public:
{
returnAnimation = new QPropertyAnimation(submarine, "yRotation");
AnimationManager::self()->registerAnimation(returnAnimation);
- addAnimation(returnAnimation);
+ setAnimation(returnAnimation);
this->submarine = submarine;
}
+
protected:
void onEntry()
{
@@ -124,10 +120,10 @@ protected:
void onExit()
{
- returnAnimation->stop();
submarine->currentDirection() == SubMarine::Right ? submarine->setCurrentDirection(SubMarine::Left) : submarine->setCurrentDirection(SubMarine::Right);
QAnimationState::onExit();
}
+
private:
SubMarine *submarine;
QPropertyAnimation *returnAnimation;
diff --git a/examples/animation/sub-attaq/torpedo.cpp b/examples/animation/sub-attaq/torpedo.cpp
index 4964192be4..b24948d8db 100644
--- a/examples/animation/sub-attaq/torpedo.cpp
+++ b/examples/animation/sub-attaq/torpedo.cpp
@@ -45,15 +45,14 @@
#include "boat.h"
#include "graphicsscene.h"
#include "animationmanager.h"
+#include "qanimationstate.h"
#if defined(QT_EXPERIMENTAL_SOLUTION)
#include "qpropertyanimation.h"
#include "qstatemachine.h"
#include "qfinalstate.h"
-#include "qanimationstate.h"
#else
#include <QPropertyAnimation>
-#include <QAnimationState>
#include <QStateMachine>
#include <QFinalState>
#endif
@@ -81,18 +80,19 @@ void Torpedo::launch()
QStateMachine *machine = new QStateMachine(this);
//This state is when the launch animation is playing
- QAnimationState *launched = new QAnimationState(launchAnimation,machine->rootState());
-
- machine->setInitialState(launched);
+ QAnimationState *launched = new QAnimationState(machine->rootState());
+ launched->setAnimation(launchAnimation);
//End
QFinalState *final = new QFinalState(machine->rootState());
+ machine->setInitialState(launched);
+
//### Add a nice animation when the torpedo is destroyed
launched->addTransition(this, SIGNAL(torpedoExplosed()),final);
//If the animation is finished, then we move to the final state
- launched->addFinishedTransition(final);
+ launched->addTransition(launched, SIGNAL(animationFinished()), final);
//The machine has finished to be executed, then the boat is dead
connect(machine,SIGNAL(finished()),this, SIGNAL(torpedoExecutionFinished()));
diff --git a/examples/statemachine/citizenquartz/citizenquartz.qrc b/examples/statemachine/citizenquartz/citizenquartz.qrc
index bcc675ade0..fc09ef9e50 100644
--- a/examples/statemachine/citizenquartz/citizenquartz.qrc
+++ b/examples/statemachine/citizenquartz/citizenquartz.qrc
@@ -1,5 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>sound/alarm.wav</file>
+ <file>images/alarm.png</file>
</qresource>
</RCC> \ No newline at end of file
diff --git a/examples/statemachine/citizenquartz/clock.cpp b/examples/statemachine/citizenquartz/clock.cpp
index 51180f5d66..1b2b21e887 100644
--- a/examples/statemachine/citizenquartz/clock.cpp
+++ b/examples/statemachine/citizenquartz/clock.cpp
@@ -24,6 +24,7 @@ Clock::Clock(QGraphicsItem *parent)
m_timeState(0),
m_updateState(0),
m_regularState(0),
+ m_displaysHistoryState(0),
m_alarmSound(new QSound(":/sound/alarm.wav", this))
{
}
@@ -84,9 +85,19 @@ void Clock::initializeStateMachine()
displays->setObjectName("displays");
initializeDisplaysState(displays);
- /*QState *alarmsBeep = new QState(m_stateMachine->rootState());
- alarmsBeep->setObjectName("alarmsBeep");
- initializeAlarmsBeepState(alarmsBeep);*/
+ QState *alarmsBeepState = new QState(m_stateMachine->rootState());
+ alarmsBeepState->setObjectName("alarmsBeep");
+ alarmsBeepState->invokeMethodOnEntry(this, "playSound");
+ alarmsBeepState->invokeMethodOnExit(this, "stopSound");
+
+ QTimer *alarmTimeOut = new QTimer(alarmsBeepState);
+ alarmTimeOut->setInterval(30000);
+ alarmsBeepState->invokeMethodOnEntry(alarmTimeOut, "start");
+ alarmsBeepState->invokeMethodOnExit(alarmTimeOut, "stop");
+
+ displays->addTransition(m_clockDisplay, SIGNAL(alarmTriggered()), alarmsBeepState);
+ alarmsBeepState->addTransition(this, SIGNAL(anyButtonPressed()), m_displaysHistoryState);
+ alarmsBeepState->addTransition(alarmTimeOut, SIGNAL(timeout()), m_displaysHistoryState);
m_stateMachine->setInitialState(displays);
m_stateMachine->start();
@@ -101,8 +112,7 @@ void Clock::initializeUpdateState(QState *updateState)
PropertyAddState *secIncrease = new PropertyAddState(updateState);
secIncrease->setObjectName("sec ++");
- secIncrease->addToProperty(m_clockDisplay, "currentTime",
- TimePeriod().setSeconds(1));
+ secIncrease->addToProperty(m_clockDisplay, "currentTime", TimePeriod().setSeconds(1));
sec->addTransition(m_buttonD, SIGNAL(pressed()), secIncrease);
secIncrease->addTransition(sec);
@@ -113,8 +123,7 @@ void Clock::initializeUpdateState(QState *updateState)
PropertyAddState *oneMinIncrease = new PropertyAddState(updateState);
oneMinIncrease->setObjectName("1 min ++");
- oneMinIncrease->addToProperty(m_clockDisplay, "currentTime",
- TimePeriod().setMinutes(1));
+ oneMinIncrease->addToProperty(m_clockDisplay, "currentTime", TimePeriod().setMinutes(1));
oneMin->addTransition(m_buttonD, SIGNAL(pressed()), oneMinIncrease);
oneMinIncrease->addTransition(oneMin);
@@ -125,8 +134,7 @@ void Clock::initializeUpdateState(QState *updateState)
PropertyAddState *tenMinIncrease = new PropertyAddState(updateState);
tenMinIncrease->setObjectName("10 min ++");
- tenMinIncrease->addToProperty(m_clockDisplay, "currentTime",
- TimePeriod().setMinutes(10));
+ tenMinIncrease->addToProperty(m_clockDisplay, "currentTime", TimePeriod().setMinutes(10));
tenMin->addTransition(m_buttonD, SIGNAL(pressed()), tenMinIncrease);
tenMinIncrease->addTransition(tenMin);
@@ -137,8 +145,7 @@ void Clock::initializeUpdateState(QState *updateState)
PropertyAddState *hrIncrease = new PropertyAddState(updateState);
hrIncrease->setObjectName("hr ++");
- hrIncrease->addToProperty(m_clockDisplay, "currentTime",
- TimePeriod().setHours(1));
+ hrIncrease->addToProperty(m_clockDisplay, "currentTime", TimePeriod().setHours(1));
hr->addTransition(m_buttonD, SIGNAL(pressed()), hrIncrease);
hrIncrease->addTransition(hr);
@@ -149,8 +156,7 @@ void Clock::initializeUpdateState(QState *updateState)
PropertyAddState *monIncrease = new PropertyAddState(updateState);
monIncrease->setObjectName("mon ++");
- monIncrease->addToProperty(m_clockDisplay, "currentTime",
- TimePeriod().setMonths(1));
+ monIncrease->addToProperty(m_clockDisplay, "currentTime", TimePeriod().setMonths(1));
mon->addTransition(m_buttonD, SIGNAL(pressed()), monIncrease);
monIncrease->addTransition(mon);
@@ -161,8 +167,7 @@ void Clock::initializeUpdateState(QState *updateState)
PropertyAddState *dayIncrease = new PropertyAddState(updateState);
dayIncrease->setObjectName("day ++");
- dayIncrease->addToProperty(m_clockDisplay, "currentTime",
- TimePeriod().setDays(1));
+ dayIncrease->addToProperty(m_clockDisplay, "currentTime", TimePeriod().setDays(1));
day->addTransition(m_buttonD, SIGNAL(pressed()), dayIncrease);
dayIncrease->addTransition(day);
@@ -173,8 +178,7 @@ void Clock::initializeUpdateState(QState *updateState)
PropertyAddState *yearIncrease = new PropertyAddState(updateState);
yearIncrease->setObjectName("year ++");
- yearIncrease->addToProperty(m_clockDisplay, "currentTime",
- TimePeriod().setYears(1));
+ yearIncrease->addToProperty(m_clockDisplay, "currentTime", TimePeriod().setYears(1));
year->addTransition(m_buttonD, SIGNAL(pressed()), yearIncrease);
yearIncrease->addTransition(year);
year->addTransition(m_buttonC, SIGNAL(pressed()), m_timeState);
@@ -305,6 +309,8 @@ void Clock::initializeDisplaysState(QState *displays)
wait->invokeMethodOnEntry(waitTimer, "start");
wait->invokeMethodOnExit(waitTimer, "stop");
+ m_displaysHistoryState = displays->addHistoryState(QState::DeepHistory);
+
m_timeState->addTransition(m_buttonC, SIGNAL(pressed()), wait);
wait->addTransition(waitTimer, SIGNAL(timeout()), m_updateState);
wait->addTransition(m_buttonC, SIGNAL(released()), m_timeState);
@@ -324,7 +330,7 @@ void Clock::initializeAlarmState(QState *alarmState)
QHistoryState *history = alarmState->addHistoryState();
history->setObjectName("alarmHistory");
- history->setDefaultState(onState);
+ history->setDefaultState(offState);
offState->addTransition(m_buttonD, SIGNAL(pressed()), onState);
onState->addTransition(m_buttonD, SIGNAL(pressed()), offState);
@@ -371,12 +377,14 @@ void Clock::updateTime()
void Clock::playSound()
{
+ qDebug("playing sound");
m_alarmSound->stop();
m_alarmSound->play();
}
void Clock::stopSound()
{
+ qDebug("stopping sound");
m_alarmSound->stop();
}
diff --git a/examples/statemachine/citizenquartz/clock.h b/examples/statemachine/citizenquartz/clock.h
index aee1b5590c..afd6433036 100644
--- a/examples/statemachine/citizenquartz/clock.h
+++ b/examples/statemachine/citizenquartz/clock.h
@@ -10,6 +10,7 @@ class QStateMachine ;
class QState ;
class QTimerState ;
class QSound ;
+class QHistoryState ;
class Clock: public QObject, public QGraphicsItem
{
@@ -25,7 +26,6 @@ public:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
signals:
- void alarm();
void anyButtonPressed();
public slots:
@@ -53,6 +53,8 @@ private:
QState *m_updateState;
QState *m_regularState;
+ QHistoryState *m_displaysHistoryState;
+
QSound *m_alarmSound;
QTime m_time;
};
diff --git a/examples/statemachine/citizenquartz/clockdisplay.cpp b/examples/statemachine/citizenquartz/clockdisplay.cpp
index 717b881380..db026f5705 100644
--- a/examples/statemachine/citizenquartz/clockdisplay.cpp
+++ b/examples/statemachine/citizenquartz/clockdisplay.cpp
@@ -124,8 +124,7 @@ QRectF ClockDisplay::boundingRect() const
void ClockDisplay::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
- if (m_alarmEnabled)
- m_alarmSymbol->setVisible(true);
+ m_alarmSymbol->setVisible(m_alarmEnabled);
updateText();
diff --git a/examples/statemachine/citizenquartz/clockdisplay.h b/examples/statemachine/citizenquartz/clockdisplay.h
index e0ac8bb078..ec86509944 100644
--- a/examples/statemachine/citizenquartz/clockdisplay.h
+++ b/examples/statemachine/citizenquartz/clockdisplay.h
@@ -42,7 +42,13 @@ public:
DisplayMode displayMode() const { return m_displayMode; }
QDateTime currentTime() const { return m_currentTime; }
- void setCurrentTime(const QDateTime &time) { m_currentTime = time; update(); }
+ void setCurrentTime(const QDateTime &time)
+ {
+ if (m_alarmEnabled && !alarmMatches(m_currentTime) && alarmMatches(time))
+ emit alarmTriggered();
+ m_currentTime = time;
+ update();
+ }
QTime alarm() const { return m_alarm; }
void setAlarm(const QTime &time) { m_alarm = time; update(); }
@@ -53,12 +59,20 @@ public:
virtual QRectF boundingRect() const;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *);
+signals:
+ void alarmTriggered();
+
private slots:
void toggleBlinkFlag();
private:
void updateText();
+ bool alarmMatches(const QDateTime &dt)
+ {
+ return (dt.time().hour() == m_alarm.hour() && dt.time().minute() == m_alarm.minute());
+ }
+
DisplayMode m_displayMode;
QDateTime m_currentTime;
diff --git a/examples/statemachine/citizenquartz/propertyaddstate.cpp b/examples/statemachine/citizenquartz/propertyaddstate.cpp
index f129c8de1c..dd2394896d 100644
--- a/examples/statemachine/citizenquartz/propertyaddstate.cpp
+++ b/examples/statemachine/citizenquartz/propertyaddstate.cpp
@@ -37,7 +37,7 @@ void PropertyAddState::onEntry()
{
foreach (PropertyAdder propertyAdder, m_propertyAdditions) {
QObject *object = propertyAdder.object;
- const char *propertyName = propertyAdder.propertyName;
+ QByteArray propertyName = propertyAdder.propertyName;
QVariant toAdd = propertyAdder.valueToAdd;
QVariant current = object->property(propertyName);
diff --git a/examples/statemachine/citizenquartz/propertyaddstate.h b/examples/statemachine/citizenquartz/propertyaddstate.h
index 96f45fc4b9..4d28055d1a 100644
--- a/examples/statemachine/citizenquartz/propertyaddstate.h
+++ b/examples/statemachine/citizenquartz/propertyaddstate.h
@@ -24,7 +24,7 @@ private:
}
QObject *object;
- const char *propertyName;
+ QByteArray propertyName;
QVariant valueToAdd;
};
QList<PropertyAdder> m_propertyAdditions;
diff --git a/examples/statemachine/citizenquartz/timeperiod.h b/examples/statemachine/citizenquartz/timeperiod.h
index a64c17c64d..c5a3a16d95 100644
--- a/examples/statemachine/citizenquartz/timeperiod.h
+++ b/examples/statemachine/citizenquartz/timeperiod.h
@@ -76,7 +76,7 @@ inline QTime operator+(const QTime &time, const TimePeriod &timePeriod)
QTime result(time);
result += timePeriod;
- return time;
+ return result;
}
Q_DECLARE_METATYPE(TimePeriod)
diff --git a/examples/statemachine/clockticking/main.cpp b/examples/statemachine/clockticking/main.cpp
index e903988431..5501e2c7ba 100644
--- a/examples/statemachine/clockticking/main.cpp
+++ b/examples/statemachine/clockticking/main.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -14,7 +44,7 @@
#ifdef QT_STATEMACHINE_SOLUTION
#include <qstatemachine.h>
#include <qstate.h>
-#include <qtransition.h>
+#include <qabstracttransition.h>
#endif
class ClockEvent : public QEvent
diff --git a/examples/statemachine/composition/main.cpp b/examples/statemachine/composition/main.cpp
index 892542de72..24b823c478 100644
--- a/examples/statemachine/composition/main.cpp
+++ b/examples/statemachine/composition/main.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -26,8 +56,8 @@ int main(int argc, char **argv)
QState *s1 = new QState();
s1->setObjectName("s1");
- s1->setPropertyOnEntry(&label, "text", "In S1, hang on...");
- s1->setPropertyOnEntry(&label, "geometry", QRect(100, 100, 200, 100));
+ s1->assignProperty(&label, "text", "In S1, hang on...");
+ s1->assignProperty(&label, "geometry", QRect(100, 100, 200, 100));
QState *s1_timer = new QState(s1);
s1_timer->setObjectName("s1_timer");
@@ -41,8 +71,8 @@ int main(int argc, char **argv)
QState *s2 = new QState();
s2->setObjectName("s2");
- s2->setPropertyOnEntry(&label, "text", "In S2, I'm gonna quit on you...");
- s2->setPropertyOnEntry(&label, "geometry", QRect(300, 300, 300, 100));
+ s2->assignProperty(&label, "text", "In S2, I'm gonna quit on you...");
+ s2->assignProperty(&label, "geometry", QRect(300, 300, 300, 100));
// s2->invokeMethodOnEntry(&label, "setNum", QList<QVariant>() << 123);
// s2->invokeMethodOnEntry(&label, "showMaximized");
diff --git a/examples/statemachine/eventtransitions/main.cpp b/examples/statemachine/eventtransitions/main.cpp
index 51b2d82a86..f564b7e551 100644
--- a/examples/statemachine/eventtransitions/main.cpp
+++ b/examples/statemachine/eventtransitions/main.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -28,10 +58,10 @@ public:
QStateMachine *machine = new QStateMachine(this);
QState *s1 = new QState();
- s1->setPropertyOnEntry(button, "text", "Outside");
+ s1->assignProperty(button, "text", "Outside");
QState *s2 = new QState();
- s2->setPropertyOnEntry(button, "text", "Inside");
+ s2->assignProperty(button, "text", "Inside");
QEventTransition *enterTransition = new QEventTransition(button, QEvent::Enter);
enterTransition->setTargetState(s2);
@@ -42,7 +72,7 @@ public:
s2->addTransition(leaveTransition);
QState *s3 = new QState();
- s3->setPropertyOnEntry(button, "text", "Pressing...");
+ s3->assignProperty(button, "text", "Pressing...");
QEventTransition *pressTransition = new QEventTransition(button, QEvent::MouseButtonPress);
pressTransition->setTargetState(s3);
diff --git a/examples/statemachine/factorial/main.cpp b/examples/statemachine/factorial/main.cpp
index 985b09f8f7..9e39ced2b8 100644
--- a/examples/statemachine/factorial/main.cpp
+++ b/examples/statemachine/factorial/main.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -124,7 +154,7 @@ int main(int argc, char **argv)
computing->addTransition(doneTransition);
QState *initialize = new QState(machine.rootState());
- initialize->setPropertyOnEntry(&factorial, "x", 6);
+ initialize->assignProperty(&factorial, "x", 6);
FactorialLoopTransition *enterLoopTransition = new FactorialLoopTransition(&factorial);
enterLoopTransition->setTargetState(computing);
initialize->addTransition(enterLoopTransition);
diff --git a/examples/statemachine/helloworld/main.cpp b/examples/statemachine/helloworld/main.cpp
index a124623cd7..13486d4ddf 100644
--- a/examples/statemachine/helloworld/main.cpp
+++ b/examples/statemachine/helloworld/main.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/examples/statemachine/pauseandresume/main.cpp b/examples/statemachine/pauseandresume/main.cpp
index 7aed84b47e..e0ebbfff4a 100644
--- a/examples/statemachine/pauseandresume/main.cpp
+++ b/examples/statemachine/pauseandresume/main.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/examples/statemachine/pingpong/main.cpp b/examples/statemachine/pingpong/main.cpp
index d749076a65..00ff643dc2 100644
--- a/examples/statemachine/pingpong/main.cpp
+++ b/examples/statemachine/pingpong/main.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -14,7 +44,7 @@
#ifdef QT_STATEMACHINE_SOLUTION
#include <qstate.h>
#include <qstatemachine.h>
-#include <qtransition.h>
+#include <qabstracttransition.h>
#endif
class PingEvent : public QEvent
diff --git a/examples/statemachine/trafficlight/main.cpp b/examples/statemachine/trafficlight/main.cpp
index fbb6b687a7..528ed00f03 100644
--- a/examples/statemachine/trafficlight/main.cpp
+++ b/examples/statemachine/trafficlight/main.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -35,6 +65,10 @@ public:
update();
}
+public slots:
+ void turnOff() { setOn(false); }
+ void turnOn() { setOn(true); }
+
protected:
virtual void paintEvent(QPaintEvent *)
{
@@ -63,9 +97,9 @@ public:
timer->setInterval(duration);
timer->setSingleShot(true);
QState *timing = new QState(this);
- timing->setPropertyOnEntry(light, "on", true);
+ timing->invokeMethodOnEntry(light, "turnOn");
timing->invokeMethodOnEntry(timer, "start");
- timing->setPropertyOnExit(light, "on", false);
+ timing->invokeMethodOnExit(light, "turnOff");
QFinalState *done = new QFinalState(this);
timing->addTransition(timer, SIGNAL(timeout()), done);
setInitialState(timing);
diff --git a/examples/statemachine/twowaybutton/main.cpp b/examples/statemachine/twowaybutton/main.cpp
index eab0b3d091..61a0f320cd 100644
--- a/examples/statemachine/twowaybutton/main.cpp
+++ b/examples/statemachine/twowaybutton/main.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -26,13 +56,13 @@ int main(int argc, char **argv)
first->setObjectName("first");
QState *off = new QState();
- off->setPropertyOnEntry(&button, "text", "Off");
+ off->assignProperty(&button, "text", "Off");
off->setObjectName("off");
first->addTransition(off);
QState *on = new QState();
on->setObjectName("on");
- on->setPropertyOnEntry(&button, "text", "On");
+ on->assignProperty(&button, "text", "On");
off->addTransition(&button, SIGNAL(clicked()), on);
on->addTransition(&button, SIGNAL(clicked()), off);
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 08dc11cd83..6c55a779ed 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -55,15 +55,15 @@
QVariantAnimation and QAnimationGroup, instead.
QAbstractAnimation provides an interface for the current time and
- duration, the iteration count, and the state of an animation. These properties
+ duration, the loop count, and the state of an animation. These properties
define the base functionality common to all animations in Qt. The virtual
duration() function returns the local duration of the animation; i.e., for
how long the animation should update the current time before
looping. Subclasses can implement this function differently; for example,
QVariantAnimation returns the duration of a simple animated property, whereas
QAnimationGroup returns the duration of a set or sequence of
- animations. You can also set a loop count by calling setIterationCount(); a
- iteration count of 2 will let the animation run twice (the default value is
+ animations. You can also set a loop count by calling setLoopCount(); a
+ loop count of 2 will let the animation run twice (the default value is
1).
Like QTimeLine, QAbstractAnimation also provides an interface for starting
@@ -119,12 +119,12 @@
*/
/*!
- \fn QAbstractAnimation::currentIterationChanged(int currentIteration)
+ \fn QAbstractAnimation::currentLoopChanged(int currentLoop)
- QAbstractAnimation emits this signal whenever the current iteration
- changes. \a currentIteration is the current iteration.
+ QAbstractAnimation emits this signal whenever the current loop
+ changes. \a currentLoop is the current loop.
- \sa currentIteration(), iterationCount()
+ \sa currentLoop(), loopCount()
*/
/*!
@@ -255,7 +255,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
QAbstractAnimation::State oldState = state;
int oldCurrentTime = currentTime;
- int oldCurrentIteration = currentIteration;
+ int oldCurrentLoop = currentLoop;
QAbstractAnimation::Direction oldDirection = direction;
state = newState;
@@ -284,7 +284,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
if (direction == QAbstractAnimation::Forward)
q->setCurrentTime(0);
else
- q->setCurrentTime(iterationCount == -1 ? q->duration() : q->totalDuration());
+ q->setCurrentTime(loopCount == -1 ? q->duration() : q->totalDuration());
}
// Check if the setCurrentTime() function called stop().
@@ -312,8 +312,8 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
QUnifiedTimer::instance()->unregisterAnimation(q);
- if (dura == -1 || iterationCount < 0
- || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentIteration + 1)) == (dura * iterationCount))
+ if (dura == -1 || loopCount < 0
+ || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount))
|| (oldDirection == QAbstractAnimation::Backward && oldCurrentTime == 0)) {
if (guard)
emit q->finished();
@@ -469,10 +469,10 @@ void QAbstractAnimation::setDirection(Direction direction)
if (state() == Stopped) {
if (direction == Backward) {
d->currentTime = duration();
- d->currentIteration = d->iterationCount - 1;
+ d->currentLoop = d->loopCount - 1;
} else {
d->currentTime = 0;
- d->currentIteration = 0;
+ d->currentLoop = 0;
}
}
updateDirection(direction);
@@ -484,14 +484,14 @@ void QAbstractAnimation::setDirection(Direction direction)
\brief the duration of the animation.
If the duration is -1, it means that the duration is undefined.
- In this case, iterationCount is ignored.
+ In this case, loopCount is ignored.
*/
/*!
- \property QAbstractAnimation::iterationCount
- \brief the iteration count of the animation
+ \property QAbstractAnimation::loopCount
+ \brief the loop count of the animation
- This property describes the iteration count of the animation as an integer.
+ This property describes the loop count of the animation as an integer.
By default this value is 1, indicating that the animation
should run once only, and then stop. By changing it you can let the
animation loop several times. With a value of 0, the animation will not
@@ -500,34 +500,34 @@ void QAbstractAnimation::setDirection(Direction direction)
It is not supported to have loop on an animation that has an undefined
duration. It will only run once.
*/
-int QAbstractAnimation::iterationCount() const
+int QAbstractAnimation::loopCount() const
{
Q_D(const QAbstractAnimation);
- return d->iterationCount;
+ return d->loopCount;
}
-void QAbstractAnimation::setIterationCount(int iterationCount)
+void QAbstractAnimation::setLoopCount(int loopCount)
{
Q_D(QAbstractAnimation);
- d->iterationCount = iterationCount;
+ d->loopCount = loopCount;
}
/*!
- \property QAbstractAnimation::currentIteration
- \brief the current iteration of the animation
+ \property QAbstractAnimation::currentLoop
+ \brief the current loop of the animation
- This property describes the current iteration of the animation. By default,
- the animation's iteration count is 1, and so the current iteration will
- always be 0. If the iteration count is 2 and the animation runs past its
+ This property describes the current loop of the animation. By default,
+ the animation's loop count is 1, and so the current loop will
+ always be 0. If the loop count is 2 and the animation runs past its
duration, it will automatically rewind and restart at current time 0, and
- current iteration 1, and so on.
+ current loop 1, and so on.
- When the current iteration changes, QAbstractAnimation emits the
- currentIterationChanged() signal.
+ When the current loop changes, QAbstractAnimation emits the
+ currentLoopChanged() signal.
*/
-int QAbstractAnimation::currentIteration() const
+int QAbstractAnimation::currentLoop() const
{
Q_D(const QAbstractAnimation);
- return d->currentIteration;
+ return d->currentLoop;
}
/*!
@@ -535,7 +535,7 @@ int QAbstractAnimation::currentIteration() const
This pure virtual function returns the duration of the animation, and
defines for how long QAbstractAnimation should update the current
- time. This duration is local, and does not include the iteration count.
+ time. This duration is local, and does not include the loop count.
A return value of -1 indicates that the animation has no defined duration;
the animation should run forever until stopped. This is useful for
@@ -545,24 +545,24 @@ int QAbstractAnimation::currentIteration() const
If the animation is a parallel QAnimationGroup, the duration will be the longest
duration of all its animations. If the animation is a sequential QAnimationGroup,
the duration will be the sum of the duration of all its animations.
- \sa iterationCount
+ \sa loopCount
*/
/*!
Returns the total and effective duration of the animation, including the
- iteration count.
+ loop count.
\sa duration(), currentTime
*/
int QAbstractAnimation::totalDuration() const
{
Q_D(const QAbstractAnimation);
- if (d->iterationCount < 0)
+ if (d->loopCount < 0)
return -1;
int dura = duration();
if (dura == -1)
return -1;
- return dura * d->iterationCount;
+ return dura * d->loopCount;
}
/*!
@@ -575,11 +575,11 @@ int QAbstractAnimation::totalDuration() const
progresses.
The animation's current time starts at 0, and ends at duration(). If the
- animation's iterationCount is larger than 1, the current time will rewind and
+ animation's loopCount is larger than 1, the current time will rewind and
start at 0 again for the consecutive loops. If the animation has a pause.
currentTime will also include the duration of the pause.
- \sa iterationCount
+ \sa loopCount
*/
int QAbstractAnimation::currentTime() const
{
@@ -593,31 +593,31 @@ void QAbstractAnimation::setCurrentTime(int msecs)
// Calculate new time and loop.
int dura = duration();
- int totalDura = (d->iterationCount < 0 || dura == -1) ? -1 : dura * d->iterationCount;
+ int totalDura = (d->loopCount < 0 || dura == -1) ? -1 : dura * d->loopCount;
if (totalDura != -1)
msecs = qMin(totalDura, msecs);
d->totalCurrentTime = msecs;
// Update new values.
- int oldLoop = d->currentIteration;
- d->currentIteration = ((dura <= 0) ? 0 : (msecs / dura));
- if (d->currentIteration == d->iterationCount) {
+ int oldLoop = d->currentLoop;
+ d->currentLoop = ((dura <= 0) ? 0 : (msecs / dura));
+ if (d->currentLoop == d->loopCount) {
//we're at the end
d->currentTime = qMax(0, dura);
- d->currentIteration = qMax(0, d->iterationCount - 1);
+ d->currentLoop = qMax(0, d->loopCount - 1);
} else {
if (d->direction == Forward) {
d->currentTime = (dura <= 0) ? msecs : (msecs % dura);
} else {
d->currentTime = (dura <= 0) ? msecs : ((msecs - 1) % dura) + 1;
if (d->currentTime == dura)
- --d->currentIteration;
+ --d->currentLoop;
}
}
updateCurrentTime(msecs);
- if (d->currentIteration != oldLoop)
- emit currentIterationChanged(d->currentIteration);
+ if (d->currentLoop != oldLoop)
+ emit currentLoopChanged(d->currentLoop);
// All animations are responsible for stopping the animation when their
// own end state is reached; in this case the animation is time driven,
@@ -658,7 +658,7 @@ void QAbstractAnimation::start(DeletionPolicy policy)
signal, and state() returns Stopped. The current time is not changed.
If the animation stops by itself after reaching the end (i.e.,
- currentTime() == duration() and currentIteration() > iterationCount() - 1), the
+ currentTime() == duration() and currentLoop() > loopCount() - 1), the
finished() signal is emitted.
\sa start(), state()
diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h
index d6260cdb6a..a7f0082a3d 100644
--- a/src/corelib/animation/qabstractanimation.h
+++ b/src/corelib/animation/qabstractanimation.h
@@ -60,9 +60,9 @@ class Q_CORE_EXPORT QAbstractAnimation : public QObject
{
Q_OBJECT
Q_PROPERTY(State state READ state NOTIFY stateChanged)
- Q_PROPERTY(int iterationCount READ iterationCount WRITE setIterationCount)
+ Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount)
Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime)
- Q_PROPERTY(int currentIteration READ currentIteration NOTIFY currentIterationChanged)
+ Q_PROPERTY(int currentLoop READ currentLoop NOTIFY currentLoopChanged)
Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged)
Q_PROPERTY(int duration READ duration)
@@ -93,9 +93,9 @@ public:
Direction direction() const;
void setDirection(Direction direction);
- int iterationCount() const;
- void setIterationCount(int iterationCount);
- int currentIteration() const;
+ int loopCount() const;
+ void setLoopCount(int loopCount);
+ int currentLoop() const;
virtual int duration() const = 0;
int totalDuration() const;
@@ -105,7 +105,7 @@ public:
Q_SIGNALS:
void finished();
void stateChanged(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
- void currentIterationChanged(int currentIteration);
+ void currentLoopChanged(int currentLoop);
void directionChanged(QAbstractAnimation::Direction);
public Q_SLOTS:
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index 39cca5604e..08eed2bde6 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -78,8 +78,8 @@ public:
deleteWhenStopped(false),
totalCurrentTime(0),
currentTime(0),
- iterationCount(1),
- currentIteration(0),
+ loopCount(1),
+ currentLoop(0),
group(0)
{
}
@@ -98,8 +98,8 @@ public:
int totalCurrentTime;
int currentTime;
- int iterationCount;
- int currentIteration;
+ int loopCount;
+ int currentLoop;
QAnimationGroup *group;
#ifdef QT_EXPERIMENTAL_SOLUTION
diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp
index f39738b4af..03573bb193 100644
--- a/src/corelib/animation/qanimationgroup.cpp
+++ b/src/corelib/animation/qanimationgroup.cpp
@@ -164,9 +164,10 @@ void QAnimationGroup::insertAnimationAt(int index, QAbstractAnimation *animation
return;
}
- d->animations.insert(index, animation);
if (QAnimationGroup *oldGroup = animation->group())
oldGroup->removeAnimation(animation);
+
+ d->animations.insert(index, animation);
QAbstractAnimationPrivate::get(animation)->group = this;
// this will make sure that ChildAdded event is sent to 'this'
animation->setParent(this);
diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp
index 993c577eb5..407ffde42a 100644
--- a/src/corelib/animation/qparallelanimationgroup.cpp
+++ b/src/corelib/animation/qparallelanimationgroup.cpp
@@ -111,7 +111,7 @@ void QParallelAnimationGroup::updateCurrentTime(int)
if (d->animations.isEmpty())
return;
- if (d->currentIteration > d->lastIteration) {
+ if (d->currentLoop > d->lastLoop) {
// simulate completion of the loop
int dura = duration();
if (dura > 0) {
@@ -119,7 +119,7 @@ void QParallelAnimationGroup::updateCurrentTime(int)
animation->setCurrentTime(dura); // will stop
}
}
- } else if (d->currentIteration < d->lastIteration) {
+ } else if (d->currentLoop < d->lastLoop) {
// simulate completion of the loop seeking backwards
foreach (QAbstractAnimation *animation, d->animations) {
animation->setCurrentTime(0);
@@ -127,11 +127,11 @@ void QParallelAnimationGroup::updateCurrentTime(int)
}
}
- bool timeFwd = ((d->currentIteration == d->lastIteration && d->currentTime >= d->lastCurrentTime)
- || d->currentIteration > d->lastIteration);
+ bool timeFwd = ((d->currentLoop == d->lastLoop && d->currentTime >= d->lastCurrentTime)
+ || d->currentLoop > d->lastLoop);
#ifdef QANIMATION_DEBUG
qDebug("QParallellAnimationGroup %5d: setCurrentTime(%d), loop:%d, last:%d, timeFwd:%d, lastcurrent:%d, %d",
- __LINE__, d->currentTime, d->currentIteration, d->lastIteration, timeFwd, d->lastCurrentTime, state());
+ __LINE__, d->currentTime, d->currentLoop, d->lastLoop, timeFwd, d->lastCurrentTime, state());
#endif
// finally move into the actual time of the current loop
foreach (QAbstractAnimation *animation, d->animations) {
@@ -139,7 +139,7 @@ void QParallelAnimationGroup::updateCurrentTime(int)
if (dura == -1 && d->isUncontrolledAnimationFinished(animation))
continue;
if (dura == -1 || (d->currentTime <= dura && dura != 0)
- || (dura == 0 && d->currentIteration != d->lastIteration)) {
+ || (dura == 0 && d->currentLoop != d->lastLoop)) {
switch (state()) {
case Running:
animation->start();
@@ -165,7 +165,7 @@ void QParallelAnimationGroup::updateCurrentTime(int)
if (d->currentTime > dura)
animation->stop();
}
- d->lastIteration = d->currentIteration;
+ d->lastLoop = d->currentLoop;
d->lastCurrentTime = d->currentTime;
}
@@ -207,7 +207,7 @@ void QParallelAnimationGroupPrivate::_q_uncontrolledAnimationFinished()
Q_ASSERT(animation);
int uncontrolledRunningCount = 0;
- if (animation->duration() == -1 || animation->iterationCount() < 0) {
+ if (animation->duration() == -1 || animation->loopCount() < 0) {
QHash<QAbstractAnimation *, int>::iterator it = uncontrolledFinishTime.begin();
while (it != uncontrolledFinishTime.end()) {
if (it.key() == animation) {
@@ -248,7 +248,7 @@ void QParallelAnimationGroupPrivate::connectUncontrolledAnimations()
Q_Q(QParallelAnimationGroup);
foreach (QAbstractAnimation *animation, animations) {
- if (animation->duration() == -1 || animation->iterationCount() < 0) {
+ if (animation->duration() == -1 || animation->loopCount() < 0) {
uncontrolledFinishTime[animation] = -1;
QObject::connect(animation, SIGNAL(finished()), q, SLOT(_q_uncontrolledAnimationFinished()));
}
@@ -273,11 +273,11 @@ void QParallelAnimationGroup::updateDirection(QAbstractAnimation::Direction dire
}
} else {
if (direction == Forward) {
- d->lastIteration = 0;
+ d->lastLoop = 0;
d->lastCurrentTime = 0;
} else {
- // Looping backwards with iterationCount == -1 does not really work well...
- d->lastIteration = (d->iterationCount == -1 ? 0 : d->iterationCount - 1);
+ // Looping backwards with loopCount == -1 does not really work well...
+ d->lastLoop = (d->loopCount == -1 ? 0 : d->loopCount - 1);
d->lastCurrentTime = duration();
}
}
diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h
index 8a4dc1b5fd..f36d972e62 100644
--- a/src/corelib/animation/qparallelanimationgroup_p.h
+++ b/src/corelib/animation/qparallelanimationgroup_p.h
@@ -64,12 +64,12 @@ class QParallelAnimationGroupPrivate : public QAnimationGroupPrivate
Q_DECLARE_PUBLIC(QParallelAnimationGroup)
public:
QParallelAnimationGroupPrivate()
- : lastIteration(0), lastCurrentTime(0)
+ : lastLoop(0), lastCurrentTime(0)
{
}
QHash<QAbstractAnimation*, int> uncontrolledFinishTime;
- int lastIteration;
+ int lastLoop;
int lastCurrentTime;
bool isUncontrolledAnimationFinished(QAbstractAnimation *anim) const;
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index adf3527c72..edcabaab1f 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -233,14 +233,16 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState,
d->updateMetaProperty();
QPropertyAnimation *oldAnim = hash->value(key, 0);
if (oldAnim) {
- //we try to stop the top level group
+ // try to stop the top level group
QAbstractAnimation *current = oldAnim;
while(current->group() && current->state() != Stopped) current = current->group();
current->stop();
}
hash->insert(key, this);
// Initialize start value
- if (d->target && !d->defaultStartValue.isValid() && (d->atBeginning() || d->atEnd())) {
+ // ### review this line below, d->atEnd() ?
+ // ### avoid entering a state where start value is not set
+ if (d->target && (d->atBeginning() || d->atEnd())) {
d->setDefaultStartValue(d->target->property(d->propertyName.constData()));
}
} else if (hash->value(key) == this) {
diff --git a/src/corelib/animation/qpropertyanimation.h b/src/corelib/animation/qpropertyanimation.h
index e5d5305254..b619256590 100644
--- a/src/corelib/animation/qpropertyanimation.h
+++ b/src/corelib/animation/qpropertyanimation.h
@@ -47,7 +47,6 @@
#else
# include <QtCore/qvariantanimation.h>
#endif
-#include <QtCore/qvariant.h>
QT_BEGIN_HEADER
diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp
index 879532c475..61ff98da53 100644
--- a/src/corelib/animation/qsequentialanimationgroup.cpp
+++ b/src/corelib/animation/qsequentialanimationgroup.cpp
@@ -77,7 +77,7 @@ bool QSequentialAnimationGroupPrivate::atEnd() const
// 3. the current animation is the last one
// 4. the current animation has reached its end
const int animTotalCurrentTime = QAbstractAnimationPrivate::get(currentAnimation)->totalCurrentTime;
- return (currentIteration == iterationCount - 1
+ return (currentLoop == loopCount - 1
&& direction == QAbstractAnimation::Forward
&& currentAnimation == animations.last()
&& animTotalCurrentTime == animationActualTotalDuration(currentAnimationIndex));
@@ -101,7 +101,7 @@ QSequentialAnimationGroupPrivate::AnimationIndex QSequentialAnimationGroupPrivat
int duration = 0;
// in case duration is -1, currentLoop will always be 0
- ret.timeOffset = currentIteration * q->duration();
+ ret.timeOffset = currentLoop * q->duration();
for (int i = 0; i < animations.size(); ++i) {
duration = animationActualTotalDuration(i);
@@ -133,13 +133,13 @@ void QSequentialAnimationGroupPrivate::restart()
{
// restarting the group by making the first/last animation the current one
if (direction == QAbstractAnimation::Forward) {
- lastIteration = 0;
+ lastLoop = 0;
if (currentAnimationIndex == 0)
activateCurrentAnimation();
else
setCurrentAnimation(0);
} else { // direction == QAbstractAnimation::Backward
- lastIteration = iterationCount - 1;
+ lastLoop = loopCount - 1;
int index = animations.size() - 1;
if (currentAnimationIndex == index)
activateCurrentAnimation();
@@ -156,7 +156,7 @@ void QSequentialAnimationGroupPrivate::restart()
*/
void QSequentialAnimationGroupPrivate::advanceForwards(const AnimationIndex &newAnimationIndex)
{
- if (lastIteration < currentIteration) {
+ if (lastLoop < currentLoop) {
// we need to fast forward to the end
for (int i = currentAnimationIndex; i < animations.size(); ++i) {
QAbstractAnimation *anim = animations.at(i);
@@ -188,7 +188,7 @@ void QSequentialAnimationGroupPrivate::advanceForwards(const AnimationIndex &new
*/
void QSequentialAnimationGroupPrivate::rewindForwards(const AnimationIndex &newAnimationIndex)
{
- if (lastIteration > currentIteration) {
+ if (lastLoop > currentLoop) {
// we need to fast rewind to the beginning
for (int i = currentAnimationIndex; i >= 0 ; --i) {
QAbstractAnimation *anim = animations.at(i);
@@ -329,12 +329,12 @@ void QSequentialAnimationGroup::updateCurrentTime(int msecs)
d->actualDuration.removeLast();
// newAnimationIndex.index is the new current animation
- if (d->lastIteration < d->currentIteration
- || (d->lastIteration == d->currentIteration && d->currentAnimationIndex < newAnimationIndex.index)) {
+ if (d->lastLoop < d->currentLoop
+ || (d->lastLoop == d->currentLoop && d->currentAnimationIndex < newAnimationIndex.index)) {
// advancing with forward direction is the same as rewinding with backwards direction
d->advanceForwards(newAnimationIndex);
- } else if (d->lastIteration > d->currentIteration
- || (d->lastIteration == d->currentIteration && d->currentAnimationIndex > newAnimationIndex.index)) {
+ } else if (d->lastLoop > d->currentLoop
+ || (d->lastLoop == d->currentLoop && d->currentAnimationIndex > newAnimationIndex.index)) {
// rewinding with forward direction is the same as advancing with backwards direction
d->rewindForwards(newAnimationIndex);
}
@@ -358,7 +358,7 @@ void QSequentialAnimationGroup::updateCurrentTime(int msecs)
stop();
}
- d->lastIteration = d->currentIteration;
+ d->lastLoop = d->currentLoop;
}
/*!
@@ -505,7 +505,7 @@ void QSequentialAnimationGroupPrivate::animationInsertedAt(int index)
setCurrentAnimation(0); // initialize the current animation
if (currentAnimationIndex == index
- && currentAnimation->currentTime() == 0 && currentAnimation->currentIteration() == 0) {
+ && currentAnimation->currentTime() == 0 && currentAnimation->currentLoop() == 0) {
//in this case we simply insert an animation before the current one has actually started
setCurrentAnimation(index);
}
@@ -513,7 +513,7 @@ void QSequentialAnimationGroupPrivate::animationInsertedAt(int index)
//we update currentAnimationIndex in case it has changed (the animation pointer is still valid)
currentAnimationIndex = animations.indexOf(currentAnimation);
- if (index < currentAnimationIndex || currentIteration != 0) {
+ if (index < currentAnimationIndex || currentLoop != 0) {
qWarning("QSequentialGroup::insertAnimationAt only supports to add animations after the current one.");
return; //we're not affected because it is added after the current one
}
@@ -562,7 +562,7 @@ void QSequentialAnimationGroupPrivate::animationRemovedAt(int index)
}
//let's also update the total current time
- totalCurrentTime = currentTime + iterationCount * q->duration();
+ totalCurrentTime = currentTime + loopCount * q->duration();
}
QT_END_NAMESPACE
diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h
index 05d2a40ac2..3ac90f8d33 100644
--- a/src/corelib/animation/qsequentialanimationgroup_p.h
+++ b/src/corelib/animation/qsequentialanimationgroup_p.h
@@ -64,7 +64,7 @@ class QSequentialAnimationGroupPrivate : public QAnimationGroupPrivate
Q_DECLARE_PUBLIC(QSequentialAnimationGroup)
public:
QSequentialAnimationGroupPrivate()
- : currentAnimation(0), currentAnimationIndex(-1), lastIteration(0)
+ : currentAnimation(0), currentAnimationIndex(-1), lastLoop(0)
{ }
@@ -96,7 +96,7 @@ public:
QList<int> actualDuration;
void restart();
- int lastIteration;
+ int lastLoop;
// handle time changes
void rewindForwards(const AnimationIndex &newAnimationIndex);
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index 6b162aecdc..9f8cbf0359 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -279,7 +279,7 @@ QVariantAnimation::~QVariantAnimation()
of the interpolated property.
The easing curve is used with the interpolator, the interpolated() virtual
- function, the animation's duration, and iterationCount, to control how the
+ function, the animation's duration, and loopCount, to control how the
current value changes as the animation progresses.
*/
QEasingCurve QVariantAnimation::easingCurve() const
@@ -340,7 +340,7 @@ template<typename T> static inline QVariantAnimation::Interpolator castToInterpo
return reinterpret_cast<QVariantAnimation::Interpolator>(func);
}
-static QVariantAnimation::Interpolator getInterpolator(int interpolationType)
+QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int interpolationType)
{
QReadLocker locker(registeredInterpolatorsLock());
QVariantAnimation::Interpolator ret = 0;
@@ -574,7 +574,7 @@ QVariant QVariantAnimation::interpolated(const QVariant &from, const QVariant &t
Q_D(const QVariantAnimation);
if (d->interpolator == 0) {
if (from.userType() == to.userType())
- d->interpolator = getInterpolator(from.userType());
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(from.userType());
if (d->interpolator == 0) //no interpolator found
return QVariant();
}
diff --git a/src/corelib/animation/qvariantanimation.h b/src/corelib/animation/qvariantanimation.h
index 7ce597fd64..69dbbf3971 100644
--- a/src/corelib/animation/qvariantanimation.h
+++ b/src/corelib/animation/qvariantanimation.h
@@ -49,8 +49,7 @@
# include <QtCore/qeasingcurve.h>
# include <QtCore/qabstractanimation.h>
#endif
-#include <QtCore/qlist.h>
-#include <QtCore/qpoint.h>
+#include <QtCore/qvector.h>
#include <QtCore/qvariant.h>
#include <QtCore/qpair.h>
diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h
index e468ac9845..66910c1d58 100644
--- a/src/corelib/animation/qvariantanimation_p.h
+++ b/src/corelib/animation/qvariantanimation_p.h
@@ -97,7 +97,7 @@ public:
bool atEnd() const
{
- return currentTime == duration && currentIteration == (iterationCount - 1);
+ return currentTime == duration && currentLoop == (loopCount - 1);
}
void setDefaultStartValue(const QVariant &value);
@@ -124,6 +124,8 @@ public:
void setValueAt(qreal, const QVariant &);
QVariant valueAt(qreal step) const;
void convertValues(int t);
+
+ static QVariantAnimation::Interpolator getInterpolator(int interpolationType);
};
//this should make the interpolation faster
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index 3fcfc98c50..fc1cefb651 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -263,6 +263,9 @@ QT_BEGIN_NAMESPACE
\omitvalue NetworkReplyUpdated
\omitvalue FutureCallOut
\omitvalue CocoaRequestModal
+ \omitvalue Bound
+ \omitvalue Signal
+ \omitvalue StateFinished
*/
/*!
diff --git a/src/corelib/statemachine/qabstractstate.cpp b/src/corelib/statemachine/qabstractstate.cpp
index 68a7fdc84d..89dcff99a8 100644
--- a/src/corelib/statemachine/qabstractstate.cpp
+++ b/src/corelib/statemachine/qabstractstate.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -13,6 +43,7 @@
#include "qabstractstate_p.h"
#include "qstatemachine.h"
#include "qstatemachine_p.h"
+#include "qstate.h"
QT_BEGIN_NAMESPACE
@@ -21,12 +52,16 @@ QT_BEGIN_NAMESPACE
\brief The QAbstractState class is the base class of states of a QStateMachine.
+ \since 4.6
\ingroup statemachine
The QAbstractState class is the abstract base class of states that are part
of a QStateMachine. It defines the interface that all state objects have in
common. QAbstractState is part of \l{The State Machine Framework}.
+ The assignProperty() function is used for defining property assignments that
+ should be performed when a state is entered.
+
The parentState() function returns the state's parent state.
\section1 Subclassing
@@ -38,7 +73,45 @@ QT_BEGIN_NAMESPACE
function to perform custom processing when the state is exited.
*/
+/*!
+ \enum QAbstractState::RestorePolicy
+
+ This enum specifies the restore policy type for a state. The restore policy
+ takes effect when the machine enters a state which sets one or more
+ properties. If the restore policy of the state is set to RestoreProperties,
+ the state machine will save the original value of the property before the
+ new value is set.
+
+ Later, when the machine either enters a state which has its restore policy
+ set to DoNotRestoreProperties or when it enters a state which does not set
+ a value for the given property, the property will automatically be restored
+ to its initial value.
+
+ Only one initial value will be saved for any given property. If a value for a property has
+ already been saved by the state machine, it will not be overwritten until the property has been
+ successfully restored. Once the property has been restored, the state machine will clear the
+ initial value until it enters a new state which sets the property and which has RestoreProperties
+ as its restore policy.
+
+ \value GlobalRestorePolicy The restore policy for the state should be retrieved using
+ QStateMachine::globalRestorePolicy()
+ \value DoNotRestoreProperties The state machine should not save the initial values of properties
+ set in the state and restore them later.
+ \value RestoreProperties The state machine should save the initial values of properties
+ set in the state and restore them later.
+
+
+ \sa setRestorePolicy(), restorePolicy(), QAbstractState::assignProperty()
+*/
+
+/*!
+ \property QAbstractState::restorePolicy
+
+ \brief the restore policy of this state
+*/
+
QAbstractStatePrivate::QAbstractStatePrivate()
+ : restorePolicy(QAbstractState::GlobalRestorePolicy)
{
}
@@ -131,6 +204,44 @@ QState *QAbstractState::parentState() const
}
/*!
+ Instructs this state to set the property with the given \a name of the given
+ \a object to the given \a value when the state is entered.
+*/
+void QAbstractState::assignProperty(QObject *object, const char *name,
+ const QVariant &value)
+{
+ Q_D(QAbstractState);
+ for (int i = 0; i < d->propertyAssignments.size(); ++i) {
+ QPropertyAssignment &assn = d->propertyAssignments[i];
+ if ((assn.object == object) && (assn.propertyName == name)) {
+ assn.value = value;
+ return;
+ }
+ }
+ d->propertyAssignments.append(QPropertyAssignment(object, name, value));
+}
+
+/*!
+ Sets the restore policy of this state to \a restorePolicy.
+
+ The default restore policy is QAbstractState::GlobalRestorePolicy.
+*/
+void QAbstractState::setRestorePolicy(RestorePolicy restorePolicy)
+{
+ Q_D(QAbstractState);
+ d->restorePolicy = restorePolicy;
+}
+
+/*!
+ Returns the restore policy for this state.
+*/
+QAbstractState::RestorePolicy QAbstractState::restorePolicy() const
+{
+ Q_D(const QAbstractState);
+ return d->restorePolicy;
+}
+
+/*!
\fn QAbstractState::onExit()
This function is called when the state is exited. Reimplement this function
diff --git a/src/corelib/statemachine/qabstractstate.h b/src/corelib/statemachine/qabstractstate.h
index cbf7ab553e..b788a88d65 100644
--- a/src/corelib/statemachine/qabstractstate.h
+++ b/src/corelib/statemachine/qabstractstate.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -26,11 +56,25 @@ class QAbstractStatePrivate;
class Q_CORE_EXPORT QAbstractState : public QObject
{
Q_OBJECT
+ Q_ENUMS(RestorePolicy)
+ Q_PROPERTY(RestorePolicy restorePolicy READ restorePolicy WRITE setRestorePolicy)
public:
+ enum RestorePolicy {
+ GlobalRestorePolicy,
+ DoNotRestoreProperties,
+ RestoreProperties
+ };
+
~QAbstractState();
QState *parentState() const;
+ void assignProperty(QObject *object, const char *name,
+ const QVariant &value);
+
+ void setRestorePolicy(RestorePolicy restorePolicy);
+ RestorePolicy restorePolicy() const;
+
protected:
QAbstractState(QState *parent = 0);
diff --git a/src/corelib/statemachine/qabstractstate_p.h b/src/corelib/statemachine/qabstractstate_p.h
index 631d0b4a49..7c565f0696 100644
--- a/src/corelib/statemachine/qabstractstate_p.h
+++ b/src/corelib/statemachine/qabstractstate_p.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -28,6 +58,8 @@
#endif
#include <QtCore/qlist.h>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qvariant.h>
QT_BEGIN_NAMESPACE
@@ -35,6 +67,18 @@ class QAbstractTransition;
class QHistoryState;
class QStateMachine;
+struct QPropertyAssignment
+{
+ QPropertyAssignment(QObject *o, const QByteArray &n,
+ const QVariant &v, bool es = true)
+ : object(o), propertyName(n), value(v), explicitlySet(es)
+ {}
+ QObject *object;
+ QByteArray propertyName;
+ QVariant value;
+ bool explicitlySet;
+};
+
class QAbstractState;
class Q_CORE_EXPORT QAbstractStatePrivate
#ifndef QT_STATEMACHINE_SOLUTION
@@ -54,6 +98,9 @@ public:
void callOnEntry();
void callOnExit();
+ QAbstractState::RestorePolicy restorePolicy;
+ QList<QPropertyAssignment> propertyAssignments;
+
#ifdef QT_STATEMACHINE_SOLUTION
QAbstractState *q_ptr;
#endif
diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp
index d9ca154047..dfce310c79 100644
--- a/src/corelib/statemachine/qabstracttransition.cpp
+++ b/src/corelib/statemachine/qabstracttransition.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -22,6 +52,7 @@ QT_BEGIN_NAMESPACE
\brief The QAbstractTransition class is the base class of transitions between QAbstractState objects.
+ \since 4.6
\ingroup statemachine
The QAbstractTransition class is the abstract base class of transitions
@@ -29,12 +60,12 @@ QT_BEGIN_NAMESPACE
QStateMachine. QAbstractTransition is part of \l{The State Machine
Framework}.
- The QTransition class provides a default (action-based) implementation of
- the QAbstractTransition interface.
-
The sourceState() function returns the source of the transition. The
targetStates() function returns the targets of the transition.
+ Transitions can cause animations to be played. Use the addAnimation()
+ function to add an animation to the transition.
+
\section1 Subclassing
The eventTest() function is called by the state machine to determine whether
@@ -255,6 +286,53 @@ void QAbstractTransition::setTargetStates(const QList<QAbstractState*> &targets)
d->targetStates = targets;
}
+#ifndef QT_NO_ANIMATION
+
+/*!
+ Adds the given \a animation to this transition.
+ The transition does not take ownership of the animation.
+
+ \sa removeAnimation(), animations()
+*/
+void QAbstractTransition::addAnimation(QAbstractAnimation *animation)
+{
+ Q_D(QAbstractTransition);
+ if (!animation) {
+ qWarning("QAbstractTransition::addAnimation: cannot add null animation");
+ return;
+ }
+ d->animations.append(animation);
+}
+
+/*!
+ Removes the given \a animation from this transition.
+
+ \sa addAnimation()
+*/
+void QAbstractTransition::removeAnimation(QAbstractAnimation *animation)
+{
+ Q_D(QAbstractTransition);
+ if (!animation) {
+ qWarning("QAbstractTransition::removeAnimation: cannot remove null animation");
+ return;
+ }
+ d->animations.removeOne(animation);
+}
+
+/*!
+ Returns the list of animations associated with this transition, or an empty
+ list if it has no animations.
+
+ \sa addAnimation()
+*/
+QList<QAbstractAnimation*> QAbstractTransition::animations() const
+{
+ Q_D(const QAbstractTransition);
+ return d->animations;
+}
+
+#endif
+
/*!
\fn QAbstractTransition::eventTest(QEvent *event) const
diff --git a/src/corelib/statemachine/qabstracttransition.h b/src/corelib/statemachine/qabstracttransition.h
index 4cf7faec5e..c49731f038 100644
--- a/src/corelib/statemachine/qabstracttransition.h
+++ b/src/corelib/statemachine/qabstracttransition.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -14,6 +44,8 @@
#include <QtCore/qobject.h>
+#include <QtCore/qlist.h>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -24,6 +56,10 @@ class QEvent;
class QAbstractState;
class QState;
+#ifndef QT_NO_ANIMATION
+class QAbstractAnimation;
+#endif
+
class QAbstractTransitionPrivate;
class Q_CORE_EXPORT QAbstractTransition : public QObject
{
@@ -42,6 +78,12 @@ public:
QList<QAbstractState*> targetStates() const;
void setTargetStates(const QList<QAbstractState*> &targets);
+#ifndef QT_NO_ANIMATION
+ void addAnimation(QAbstractAnimation *animation);
+ void removeAnimation(QAbstractAnimation *animation);
+ QList<QAbstractAnimation*> animations() const;
+#endif
+
protected:
virtual bool eventTest(QEvent *event) const = 0;
diff --git a/src/corelib/statemachine/qabstracttransition_p.h b/src/corelib/statemachine/qabstracttransition_p.h
index 796af11add..a48a09ccde 100644
--- a/src/corelib/statemachine/qabstracttransition_p.h
+++ b/src/corelib/statemachine/qabstracttransition_p.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -55,6 +85,10 @@ public:
QList<QAbstractState*> targetStates;
+#ifndef QT_NO_ANIMATION
+ QList<QAbstractAnimation*> animations;
+#endif
+
#ifdef QT_STATEMACHINE_SOLUTION
QAbstractTransition *q_ptr;
#endif
diff --git a/src/corelib/statemachine/qactionstate.cpp b/src/corelib/statemachine/qactionstate.cpp
index 312465ea9e..1da035065a 100644
--- a/src/corelib/statemachine/qactionstate.cpp
+++ b/src/corelib/statemachine/qactionstate.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -21,6 +51,7 @@ QT_BEGIN_NAMESPACE
\brief The QActionState class provides an action-based state.
+ \since 4.6
\ingroup statemachine
QActionState executes \l{QStateAction}{state actions} when the state is
@@ -30,19 +61,6 @@ QT_BEGIN_NAMESPACE
functions. The state executes the actions when the state is entered and
exited, respectively.
- Built-in actions are provided for setting properties and invoking methods of
- QObjects. The setPropertyOnEntry() and setPropertyOnExit() functions are
- used for defining property assignments that should be performed when a state
- is entered and exited, respectively.
-
- \code
- QLabel label;
- QStateMachine machine;
- QState *s1 = new QState();
- s1->setPropertyOnEntry(&label, "text", "Entered state s1");
- machine.addState(s1);
- \endcode
-
The invokeMethodOnEntry() and invokeMethodOnExit() functions are used for
defining method invocations that should be performed when a state is entered
and exited, respectively.
@@ -56,43 +74,7 @@ QT_BEGIN_NAMESPACE
\sa QStateAction
*/
-/*!
- \enum QActionState::RestorePolicy
-
- This enum specifies the restore policy type for a state. The restore policy takes effect when
- the machine enters a state which has entry actions of the type QStateSetPropertyAction. If the
- restore policy of the state is set to RestoreProperties, the state machine will save the
- value of the property before the QStateSetPropertyAction is executed.
-
- Later, when the machine either enters a state which has its restore policy set to
- DoNotRestoreProperties or when it enters a state which does not set a value for the given
- property, the property will automatically be restored to its initial value. The state machine
- will only detect which properties are being set if they are being set using a
- QStateSetPropertyAction object set as entry action on a state.
-
- Special rules apply when using QAnimationState. If a QAnimationState registers that a property
- should be restored before entering the target state of its QStateFinishedTransition, it will
- restore this property using a QPropertyAnimation.
-
- Only one initial value will be saved for any given property. If a value for a property has
- already been saved by the state machine, it will not be overwritten until the property has been
- successfully restored. Once the property has been restored, the state machine will clear the
- initial value until it enters a new state which sets the property and which has RestoreProperties
- as its restore policy.
-
- \value GlobalRestorePolicy The restore policy for the state should be retrieved using
- QStateMachine::globalRestorePolicy()
- \value DoNotRestoreProperties The state machine should not save the initial values of properties
- set in the state and restore them later.
- \value RestoreProperties The state machine should save the initial values of properties
- set in the state and restore them later.
-
-
- \sa setRestorePolicy(), restorePolicy(), addEntryAction(), setPropertyOnEntry()
-*/
-
QActionStatePrivate::QActionStatePrivate()
- : restorePolicy(QActionState::GlobalRestorePolicy)
{
}
@@ -165,66 +147,12 @@ QActionState::~QActionState()
}
/*!
- Instructs this state to set the property with the given \a name of the given
- \a object to the given \a value when the state is entered. This function
- will create a QStateSetPropertyAction object and add it to the entry actions
- of the state. If there is already an existing action associated with the
- property, the value of that action is updated.
-
- \sa setPropertyOnExit(), invokeMethodOnEntry(), addEntryAction()
-*/
-void QActionState::setPropertyOnEntry(QObject *object, const char *name,
- const QVariant &value)
-{
- Q_D(QActionState);
- QList<QStateAction*> actions = d->entryActions();
- for (int i=0; i<actions.size(); ++i) {
- QStateAction *action = actions.at(i);
- if (QStateSetPropertyAction *spa = qobject_cast<QStateSetPropertyAction*>(action)) {
- if (spa->targetObject() == object && spa->propertyName() == name) {
- QStateSetPropertyActionPrivate::get(spa)->value = value;
- return;
- }
- }
- }
-
- addEntryAction(new QStateSetPropertyAction(object, name, value));
-}
-
-/*!
- Instructs this state to set the property with the given \a name of the given
- \a object to the given \a value when the state is exited. This function will
- create a QStateSetPropertyAction object and add it to the exit actions of
- the state. If there is already an existing action associated with the
- property, the value of that action is updated.
-
- \sa setPropertyOnEntry(), invokeMethodOnExit(), addExitAction()
-*/
-void QActionState::setPropertyOnExit(QObject *object, const char *name,
- const QVariant &value)
-{
- Q_D(QActionState);
- QList<QStateAction*> actions = d->exitActions();
- for (int i=0; i<actions.size(); ++i) {
- QStateAction *action = actions.at(i);
- if (QStateSetPropertyAction *spa = qobject_cast<QStateSetPropertyAction*>(action)) {
- if (spa->targetObject() == object && spa->propertyName() == name) {
- QStateSetPropertyActionPrivate::get(spa)->value = value;
- return;
- }
- }
- }
-
- addExitAction(new QStateSetPropertyAction(object, name, value));
-}
-
-/*!
Instructs this state to invoke the given \a method of the given \a object
with the given \a arguments when the state is entered. This function will
create a QStateInvokeMethodAction object and add it to the entry actions of
the state.
- \sa invokeMethodOnExit(), setPropertyOnEntry(), addEntryAction()
+ \sa invokeMethodOnExit(), addEntryAction()
*/
void QActionState::invokeMethodOnEntry(QObject *object, const char *method,
const QList<QVariant> &arguments)
@@ -238,7 +166,7 @@ void QActionState::invokeMethodOnEntry(QObject *object, const char *method,
create a QStateInvokeMethodAction object and add it to the exit actions of
the state.
- \sa invokeMethodOnEntry(), setPropertyOnExit(), addExitAction()
+ \sa invokeMethodOnEntry(), addExitAction()
*/
void QActionState::invokeMethodOnExit(QObject *object, const char *method,
const QList<QVariant> &arguments)
@@ -333,26 +261,6 @@ QList<QStateAction*> QActionState::exitActions() const
}
/*!
- Sets the restore policy of this state to \a restorePolicy.
-
- The default restore policy is QActionState::GlobalRestorePolicy.
-*/
-void QActionState::setRestorePolicy(RestorePolicy restorePolicy)
-{
- Q_D(QActionState);
- d->restorePolicy = restorePolicy;
-}
-
-/*!
- Returns the restore policy for this state.
-*/
-QActionState::RestorePolicy QActionState::restorePolicy() const
-{
- Q_D(const QActionState);
- return d->restorePolicy;
-}
-
-/*!
\reimp
*/
void QActionState::onEntry()
diff --git a/src/corelib/statemachine/qactionstate.h b/src/corelib/statemachine/qactionstate.h
index 2af9d4a4a3..517b4b2df8 100644
--- a/src/corelib/statemachine/qactionstate.h
+++ b/src/corelib/statemachine/qactionstate.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -34,19 +64,9 @@ class Q_CORE_EXPORT QActionState : public QAbstractState
{
Q_OBJECT
public:
- enum RestorePolicy {
- GlobalRestorePolicy,
- DoNotRestoreProperties,
- RestoreProperties
- };
-
QActionState(QState *parent = 0);
~QActionState();
- void setPropertyOnEntry(QObject *object, const char *name,
- const QVariant &value);
- void setPropertyOnExit(QObject *object, const char *name,
- const QVariant &value);
void invokeMethodOnEntry(QObject *object, const char *method,
const QList<QVariant> &args = QList<QVariant>());
void invokeMethodOnExit(QObject *object, const char *method,
@@ -61,9 +81,6 @@ public:
QList<QStateAction*> entryActions() const;
QList<QStateAction*> exitActions() const;
- void setRestorePolicy(RestorePolicy restorePolicy);
- RestorePolicy restorePolicy() const;
-
protected:
void onEntry();
void onExit();
diff --git a/src/corelib/statemachine/qactionstate_p.h b/src/corelib/statemachine/qactionstate_p.h
index 69343f8a10..a06dde2b3e 100644
--- a/src/corelib/statemachine/qactionstate_p.h
+++ b/src/corelib/statemachine/qactionstate_p.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -46,8 +76,6 @@ public:
QList<QStateAction*> entryActions() const;
QList<QStateAction*> exitActions() const;
-
- QActionState::RestorePolicy restorePolicy;
};
QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qactiontransition.cpp b/src/corelib/statemachine/qactiontransition.cpp
new file mode 100644
index 0000000000..7c53e15841
--- /dev/null
+++ b/src/corelib/statemachine/qactiontransition.cpp
@@ -0,0 +1,230 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qactiontransition.h"
+#include "qactiontransition_p.h"
+#include "qstateaction.h"
+#include "qstateaction_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QActionTransition
+
+ \brief The QActionTransition class provides an action-based transition.
+
+ \since 4.6
+ \ingroup statemachine
+
+ QActionTransition provides an action-based transition; you add actions with
+ the addAction() function. The transition executes the actions when the
+ transition is triggered. QActionTransition is part of \l{The State Machine
+ Framework}.
+
+ The invokeMethodOnTransition() function is used for defining method
+ invocations that should be performed when a transition is taken.
+
+ \code
+ QStateMachine machine;
+ QState *s1 = new QState();
+ machine.addState(s1);
+ QActionTransition *t1 = new QActionTransition();
+ QLabel label;
+ t1->invokeMethodOnTransition(&label, "clear");
+ QState *s2 = new QState();
+ machine.addState(s2);
+ t1->setTargetState(s2);
+ s1->addTransition(t1);
+ \endcode
+
+ Actions are executed in the order in which they were added.
+
+ \sa QState::addTransition(), QStateAction
+*/
+
+QActionTransitionPrivate::QActionTransitionPrivate()
+{
+}
+
+QActionTransitionPrivate::~QActionTransitionPrivate()
+{
+}
+
+QActionTransitionPrivate *QActionTransitionPrivate::get(QActionTransition *q)
+{
+ return q->d_func();
+}
+
+const QActionTransitionPrivate *QActionTransitionPrivate::get(const QActionTransition *q)
+{
+ return q->d_func();
+}
+
+QList<QStateAction*> QActionTransitionPrivate::actions() const
+{
+ QList<QStateAction*> result;
+ QList<QObject*>::const_iterator it;
+#ifdef QT_STATEMACHINE_SOLUTION
+ const QObjectList &children = q_func()->children();
+#endif
+ for (it = children.constBegin(); it != children.constEnd(); ++it) {
+ QStateAction *s = qobject_cast<QStateAction*>(*it);
+ if (s)
+ result.append(s);
+ }
+ return result;
+}
+
+/*!
+ Constructs a new QActionTransition object with the given \a sourceState.
+*/
+QActionTransition::QActionTransition(QState *sourceState)
+ : QAbstractTransition(*new QActionTransitionPrivate, sourceState)
+{
+}
+
+/*!
+ Constructs a new QActionTransition object with the given \a targets and \a
+ sourceState.
+*/
+QActionTransition::QActionTransition(const QList<QAbstractState*> &targets, QState *sourceState)
+ : QAbstractTransition(*new QActionTransitionPrivate, targets, sourceState)
+{
+}
+
+/*!
+ \internal
+*/
+QActionTransition::QActionTransition(QActionTransitionPrivate &dd, QState *parent)
+ : QAbstractTransition(dd, parent)
+{
+}
+
+/*!
+ \internal
+*/
+QActionTransition::QActionTransition(QActionTransitionPrivate &dd, const QList<QAbstractState*> &targets, QState *parent)
+ : QAbstractTransition(dd, targets, parent)
+{
+}
+
+/*!
+ Destroys this transition.
+*/
+QActionTransition::~QActionTransition()
+{
+}
+
+/*!
+ Instructs this QActionTransition to invoke the given \a method of the given \a
+ object with the given \a arguments when the transition is taken. This
+ function will create a QStateInvokeMethodAction object and add it to the
+ actions of the transition.
+*/
+void QActionTransition::invokeMethodOnTransition(QObject *object, const char *method,
+ const QList<QVariant> &arguments)
+{
+ addAction(new QStateInvokeMethodAction(object, method, arguments));
+}
+
+/*!
+ Adds the given \a action to this transition.
+ The action will be executed when the transition is triggered.
+ The transition takes ownership of the action.
+
+ \sa removeAction()
+*/
+void QActionTransition::addAction(QStateAction *action)
+{
+ if (!action) {
+ qWarning("QActionTransition::addAction: cannot add null action");
+ return;
+ }
+ action->setParent(this);
+}
+
+/*!
+ Removes the given \a action from this transition.
+ The transition releases ownership of the action.
+
+ \sa addAction()
+*/
+void QActionTransition::removeAction(QStateAction *action)
+{
+ if (!action) {
+ qWarning("QActionTransition::removeAction: cannot remove null action");
+ return;
+ }
+ action->setParent(0);
+}
+
+/*!
+ Returns this transitions's actions, or an empty list if the transition has
+ no actions.
+
+ \sa addAction()
+*/
+QList<QStateAction*> QActionTransition::actions() const
+{
+ Q_D(const QActionTransition);
+ return d->actions();
+}
+
+/*!
+ \reimp
+*/
+void QActionTransition::onTransition()
+{
+ Q_D(QActionTransition);
+ QList<QStateAction*> actions = d->actions();
+ for (int i = 0; i < actions.size(); ++i)
+ QStateActionPrivate::get(actions.at(i))->callExecute();
+}
+
+/*!
+ \reimp
+*/
+bool QActionTransition::event(QEvent *e)
+{
+ return QAbstractTransition::event(e);
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qactiontransition.h b/src/corelib/statemachine/qactiontransition.h
new file mode 100644
index 0000000000..1a779fa2fd
--- /dev/null
+++ b/src/corelib/statemachine/qactiontransition.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACTIONTRANSITION_H
+#define QACTIONTRANSITION_H
+
+#ifndef QT_STATEMACHINE_SOLUTION
+#include <QtCore/qabstracttransition.h>
+#else
+#include "qabstracttransition.h"
+#endif
+
+#include <QtCore/qvariant.h>
+#include <QtCore/qlist.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Core)
+
+class QStateAction;
+
+class QActionTransitionPrivate;
+class Q_CORE_EXPORT QActionTransition : public QAbstractTransition
+{
+ Q_OBJECT
+public:
+ QActionTransition(QState *sourceState = 0);
+ QActionTransition(const QList<QAbstractState*> &targets, QState *sourceState = 0);
+ ~QActionTransition();
+
+ void invokeMethodOnTransition(QObject *object, const char *method,
+ const QList<QVariant> &args = QList<QVariant>());
+
+ void addAction(QStateAction *action);
+ void removeAction(QStateAction *action);
+ QList<QStateAction*> actions() const;
+
+protected:
+ virtual void onTransition();
+
+ bool event(QEvent *e);
+
+protected:
+ QActionTransition(QActionTransitionPrivate &dd, QState *parent);
+ QActionTransition(QActionTransitionPrivate &dd, const QList<QAbstractState*> &targets, QState *parent);
+
+private:
+ Q_DISABLE_COPY(QActionTransition)
+ Q_DECLARE_PRIVATE(QActionTransition)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/gui/animation/qitemanimation_p.h b/src/corelib/statemachine/qactiontransition_p.h
index 027c199e0f..34f80d15db 100644
--- a/src/gui/animation/qitemanimation_p.h
+++ b/src/corelib/statemachine/qactiontransition_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,45 +39,42 @@
**
****************************************************************************/
-#ifndef QITEMANIMATION_P_H
-#define QITEMANIMATION_P_H
+#ifndef QACTIONTRANSITION_P_H
+#define QACTIONTRANSITION_P_H
//
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of QIODevice. This header file may change from version to
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
-#include "qitemanimation.h"
+#include "qabstracttransition_p.h"
-#if defined(QT_EXPERIMENTAL_SOLUTION)
-#include "qvariantanimation_p.h"
-#else
-#include "private/qvariantanimation_p.h"
-#endif
+#include <QtCore/qlist.h>
QT_BEGIN_NAMESPACE
-class QItemAnimationPrivate : public QVariantAnimationPrivate
+class QStateAction;
+
+class QActionTransition;
+class Q_CORE_EXPORT QActionTransitionPrivate : public QAbstractTransitionPrivate
{
- Q_DECLARE_PUBLIC(QItemAnimation)
+ Q_DECLARE_PUBLIC(QActionTransition)
public:
- QItemAnimationPrivate() : propertyName(QItemAnimation::None),
- target(0)
- {
- }
+ QActionTransitionPrivate();
+ ~QActionTransitionPrivate();
- void initDefaultStartValue();
+ static QActionTransitionPrivate *get(QActionTransition *q);
+ static const QActionTransitionPrivate *get(const QActionTransition *q);
- QItemAnimation::PropertyName propertyName;
- QGraphicsItem *target;
+ QList<QStateAction*> actions() const;
};
QT_END_NAMESPACE
-#endif //QITEMANIMATION_P_H
+#endif
diff --git a/src/corelib/statemachine/qanimationstate.cpp b/src/corelib/statemachine/qanimationstate.cpp
deleted file mode 100644
index b96395088c..0000000000
--- a/src/corelib/statemachine/qanimationstate.cpp
+++ /dev/null
@@ -1,574 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $TROLLTECH_DUAL_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT_NO_ANIMATION
-
-#include "qanimationstate.h"
-#include "qparallelanimationgroup.h"
-#include "qabstracttransition.h"
-#include "qabstracttransition_p.h"
-#include "qstatefinishedtransition.h"
-#include "qsignaltransition.h"
-#include "qpropertyanimation.h"
-#include "qstatemachine.h"
-#include "qstatemachine_p.h"
-#include "qstateaction.h"
-#include "qstateaction_p.h"
-#include "qstate.h"
-#include "qstate_p.h"
-#include "qfinalstate.h"
-#include "qsignaltransition_p.h"
-#ifdef QT_STATEMACHINE_SOLUTION
-#include "qvariantanimation_p.h"
-#else
-#include "private/qvariantanimation_p.h"
-#endif
-#include "qpauseanimation.h"
-
-#include <QtCore/qhash.h>
-#include <QtCore/qstack.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qsize.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qbitarray.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QAnimationState
- \brief The QAnimationState class provides a state that plays one or more animations.
- \ingroup statemachine
- \preliminary
-
- QAnimationState is part of \l{The State Machine Framework}.
-
- The addAnimation() function adds an animation to be played by the state.
-
- When the state is entered, it will call each of the animations' start() functions.
- When the animation is finished, a QStateFinishedEvent is posted; you can
- use the QStateFinishedTransition class to associate a transition with this
- event.
-
- \code
- QPushButton button;
- QPropertyAnimation animation(&button, "geometry");
- animation.setEndValue(QRect(100, 100, 400, 400));
-
- QStateMachine machine;
- QAnimationState *s1 = new QAnimationState(&animation, machine.rootState());
- QState *s2 = new QState(machine.rootState());
- s1->addFinishedTransition(s2);
- \endcode
-
- If the state is exited before the animation has finished, the animations will
- be stopped, and no event is generated.
-
- For convenience, the QState::addAnimatedTransition() functions can be used to set up the
- animated transition between two states.
-
- \section1 Initializing animations automatically
- QAnimationState will try to automatically initialize any QPropertyAnimation for which no
- specific end value has been set. It will set the animation's end value based on actions in the
- target state of the animation state's QStateFinishedTransition.
-
- The only actions evaluated are the entry actions of the very first states entered after the
- animation state has finished.
-
- QAnimationState will match its QPropertyAnimation objects with QStateSetPropertyAction objects
- in the target states that manipulate the same property on the same object. The end values of the
- animations will be initialized to the values set by the actions.
-
- \code
- QPushButton button;
- QPropertyAnimation animation(&button, "geometry");
-
- QStateMachine machine;
- QAnimationState *s1 = new QAnimationState(&animation, machine.rootState());
- QState *s2 = new QState(machine.rootState());
- s2->setPropertyOnEntry(&button, "geometry", QRect(100, 100, 400, 400));
-
- s1->addFinishedTransition(s2);
- \endcode
-
- Specifically, QAnimationState will evaluate the actions set for the target state itself, and
- also look in following locations:
- objects:
- \list
- \i If the state has children and is not parallel, actions set for its initial
- state will be evaluated.
- \i If the state has children and is parallel, actions set for any of its children will be
- evaluated.
- \endlist
-
- Children of the target state will be evaluated recursively.
-
- \section1 Animated restoring of properties
-
- When a state has restore policy QActionState::RestoreProperties, any
- property that is set in the state using the QStateSetPropertyAction will
- potentially be restored to its original value later on. When regular,
- unanimated transitions are used, the properties will be restored when the
- state machine enters one or more states that do not explicitly set the
- property.
-
- When QAnimationState is used, it will restore the property with an
- animation. Rather than have the state machine restore the properties as it
- enters the target state, they will be restored by the QAnimationState in
- parallel to the regular animations that have been added to the state.
-
- If no animation has been added to the state, only the restore animations
- will be played.
-
- The animations used to restore the properties are QPropertyAnimations with
- with the default easing curve and duration.
-
- \sa QActionState::RestorePolicy, QPropertyAnimation, QStateSetPropertyAction,
- QState::addAnimatedTransition()
-
-*/
-
-namespace {
-
-class AnimatingState : public QState
-{
-public:
- AnimatingState(QState *parent)
- : QState(parent) {}
-protected:
- void onEntry() {}
- void onExit() {}
-};
-
-class AnimationFinishedState : public QFinalState
-{
-public:
- AnimationFinishedState(QState *parent)
- : QFinalState(parent)
- {
- }
-
-protected:
- void onEntry() {}
- void onExit() {}
-};
-
-class AnimationFinishedTransition: public QSignalTransition
-{
-public:
- AnimationFinishedTransition(QAbstractAnimation *animation,
- QAnimationStatePrivate *animationState_d,
- QAbstractState *target)
- : QSignalTransition(animation, SIGNAL(finished()), QList<QAbstractState*>() << target),
- m_animationState_d(animationState_d)
- {
- }
-
- virtual bool eventTest(QEvent *) const;
-
-private:
- QAnimationStatePrivate *m_animationState_d;
-};
-
-} // namespace
-
-class QAnimationStatePrivate : public QStatePrivate
-{
- Q_DECLARE_PUBLIC(QAnimationState)
-
-public:
- typedef QStateMachinePrivate::RestorableId RestorableId;
-
- QAnimationStatePrivate();
- void init();
- QAbstractTransition *finishedTransition() const;
-
- void initializeAnimation(const QList<QStateAction*> &actions, QActionState::RestorePolicy restorePolicy);
- void initializeAnimation(const QList<QAbstractState*> &targets);
- void initializeAnimationFromAction(QAbstractAnimation *anim,
- QStateAction *action,
- QActionState::RestorePolicy restorePolicy);
-
- void restoreAnimations();
-
- void addAnimation(QAbstractAnimation *animation, QList<QAbstractAnimation*> &list);
- void removeAnimation(QAbstractAnimation *animation, QList<QAbstractAnimation*> &list);
-
- QList<QAbstractAnimation *> animations;
- QList<QAbstractAnimation *> restorationAnimations;
- QList<QPropertyAnimation *> resetEndValues;
- QState *animatingState;
- QFinalState *finishedState;
- QTimer *timer;
-
- uint initializeAnimationFromTargetStates : 1;
- uint initializeAnimationFromRestorableVariables : 1;
- uint reserved : 30;
-
- QHash<RestorableId, QVariant> pendingRestorables;
-};
-
-// implement here because it requires the definition of QAnimationStatePrivate.
-namespace {
- bool AnimationFinishedTransition::eventTest(QEvent *e) const
- {
- if (!QSignalTransition::eventTest(e))
- return false;
-
- QList<QAbstractAnimation *> animations = m_animationState_d->animations;
- QList<QAbstractAnimation *> restorationAnimations = m_animationState_d->restorationAnimations;
-
- for (int i=0; i<animations.size(); ++i) {
- if (animations.at(i)->state() != QAbstractAnimation::Stopped)
- return false;
- }
-
- for (int i=0; i<restorationAnimations.size(); ++i) {
- if (restorationAnimations.at(i)->state() != QAbstractAnimation::Stopped)
- return false;
- }
-
- return true;
- }
-}
-
-QAnimationStatePrivate::QAnimationStatePrivate()
-{
-}
-
-void QAnimationStatePrivate::init()
-{
- Q_Q(QAnimationState);
-
- // ### make it a configurable property, as it is highly magical
- initializeAnimationFromTargetStates = true;
- initializeAnimationFromRestorableVariables = true;
-
- animatingState = new AnimatingState(q);
- q->setInitialState(animatingState);
- finishedState = new AnimationFinishedState(q);
-
- timer = 0;
-}
-
-void QAnimationStatePrivate::addAnimation(QAbstractAnimation *animation,
- QList<QAbstractAnimation*> &list)
-{
- if (animation != 0 && !list.contains(animation)) {
- list.append(animation);
- AnimationFinishedTransition *transition = new AnimationFinishedTransition(animation, this, finishedState);
- animatingState->addTransition(transition);
- }
-}
-
-void QAnimationStatePrivate::removeAnimation(QAbstractAnimation *animation,
- QList<QAbstractAnimation*> &list)
-{
- if (animation != 0 && list.contains(animation)) {
- QStatePrivate *state_d = QStatePrivate::get(animatingState);
- QList<QAbstractTransition *> transitions = state_d->transitions();
- Q_ASSERT(transitions.size() > 0);
- for (int i=0; i<transitions.size(); ++i) {
- QSignalTransition *transition = qobject_cast<QSignalTransition *>(transitions.at(i));
-
- if (transition != 0) {
- QSignalTransitionPrivate *transition_p = QSignalTransitionPrivate::get(transition);
- if (transition_p->sender == animation) {
- delete transition;
- break;
- }
- }
- }
-
- list.removeAll(animation);
- }
-}
-
-/*!
- \internal
-
- Returns a transition from this state that is triggered when this state is
- finished, or 0 if there is no such transition.
-*/
-QAbstractTransition *QAnimationStatePrivate::finishedTransition() const
-{
- QList<QAbstractTransition*> trans = transitions();
- for (int i = 0; i < trans.size(); ++i) {
- QAbstractTransition *t = trans.at(i);
- if (QStateFinishedTransition *sft = qobject_cast<QStateFinishedTransition*>(t))
- return sft;
- }
- return 0;
-}
-
-void QAnimationStatePrivate::initializeAnimationFromAction(QAbstractAnimation *abstractAnimation,
- QStateAction *action,
- QActionState::RestorePolicy restorePolicy)
-{
- QAnimationGroup *group = qobject_cast<QAnimationGroup*>(abstractAnimation);
- if (group) {
- for (int i = 0; i < group->animationCount(); ++i) {
- QAbstractAnimation *animationChild = group->animationAt(i);
- initializeAnimationFromAction(animationChild, action, restorePolicy);
- }
- } else {
- QPropertyAnimation *animation = qobject_cast<QPropertyAnimation *>(abstractAnimation);
- QStateSetPropertyAction *propertyAction = qobject_cast<QStateSetPropertyAction*>(action);
- if (propertyAction != 0
- && animation != 0
- && propertyAction->targetObject() == animation->targetObject()
- && propertyAction->propertyName() == animation->propertyName()) {
-
- if (!animation->startValue().isValid()) {
- QByteArray propertyName = animation->propertyName();
- QVariant currentValue = animation->targetObject()->property(propertyName);
-
- QVariantAnimationPrivate::get(animation)->setDefaultStartValue(currentValue);
- }
-
- // Only change end value if it is undefined
- if (!animation->endValue().isValid()) {
- QStateMachinePrivate *machine_d = QStateMachinePrivate::get(machine());
- if (restorePolicy == QActionState::RestoreProperties)
- machine_d->registerRestorable(animation);
-
- RestorableId id(animation->targetObject(), animation->propertyName());
- pendingRestorables.remove(id);
-
- animation->setEndValue(propertyAction->value());
- resetEndValues.append(animation);
- }
- }
- }
-}
-
-void QAnimationStatePrivate::initializeAnimation(const QList<QStateAction*> &actions,
- QActionState::RestorePolicy restorePolicy)
-{
-
- for (int i = 0; i < actions.size(); ++i) {
- QStateAction *act = actions.at(i);
-
- for (int j=0; j<animations.size(); ++j)
- initializeAnimationFromAction(animations.at(j), act, restorePolicy);
- }
-
-
-}
-
-void QAnimationStatePrivate::initializeAnimation(const QList<QAbstractState*> &targets)
-{
- // ### consider resulting action order, and how to resolve conflicts (two actions that set the same property)
- for (int i = 0; i < targets.size(); ++i) {
- QActionState *s = qobject_cast<QActionState*>(targets.at(i));
- if (s != 0) {
- QActionState::RestorePolicy restorePolicy = s->restorePolicy();
- if (restorePolicy == QActionState::GlobalRestorePolicy)
- restorePolicy = machine()->globalRestorePolicy();
- initializeAnimation(QActionStatePrivate::get(s)->entryActions(), restorePolicy);
- }
-
- if (QStateMachinePrivate::isParallel(s)) {
- initializeAnimation(QStatePrivate::get(qobject_cast<QState*>(s))->childStates());
- } else if (QStateMachinePrivate::isCompound(s)) {
- initializeAnimation(QList<QAbstractState*>() << qobject_cast<QState*>(s)->initialState());
- }
- }
-}
-
-void QAnimationStatePrivate::restoreAnimations()
-{
- QStateMachinePrivate *machine_d = QStateMachinePrivate::get(machine());
-
- QHash<RestorableId, QVariant>::const_iterator it;
- for (it=pendingRestorables.constBegin(); it != pendingRestorables.constEnd(); ++it) {
- QPropertyAnimation *animation = machine_d->registeredRestorableAnimations.value(it.key());
- if (animation == 0)
- continue;
-
- // ### Check if this works
- // animation->setDirection(QAbstractAnimation::Backward);
-
- QPropertyAnimation *clonedAnimation = new QPropertyAnimation(animation->targetObject(),
- animation->propertyName());
- clonedAnimation->setEasingCurve(animation->easingCurve());
- clonedAnimation->setEndValue(it.value());
-
- addAnimation(clonedAnimation, restorationAnimations);
- }
-
- pendingRestorables.clear();
-}
-
-
-/*!
- Constructs a new QAnimationState object with the given \a animation and \a
- parent state
-*/
-QAnimationState::QAnimationState(QAbstractAnimation *animation, QState *parent)
- : QState(*new QAnimationStatePrivate, parent)
-{
- Q_D(QAnimationState);
- d->init();
-
- if (animation != 0)
- addAnimation(animation);
-}
-
-/*!
- Constructs a new QAnimationState object with the given \a parent state.
-*/
-QAnimationState::QAnimationState(QState *parent)
- : QState(*new QAnimationStatePrivate, parent)
-{
- Q_D(QAnimationState);
- d->init();
-}
-
-/*!
- Destroys this QAnimationState.
-*/
-QAnimationState::~QAnimationState()
-{
-}
-
-/*!
- Returns the number of animations added to this QAnimationState.
-*/
-int QAnimationState::animationCount() const
-{
- Q_D(const QAnimationState);
- return d->animations.size();
-}
-
-/*!
- Returns the animation associated with this QAnimationState at index \a i.
-*/
-QAbstractAnimation *QAnimationState::animationAt(int i) const
-{
- Q_D(const QAnimationState);
- return d->animations.at(i);
-}
-
-/*!
- Adds \a animation to this QAnimationState.
-*/
-void QAnimationState::addAnimation(QAbstractAnimation *animation)
-{
- Q_D(QAnimationState);
- if (animation == 0) {
- qWarning("QAnimationState::addAnimation: Cannot add null animation");
- return;
- }
-
- d->addAnimation(animation, d->animations);
-}
-
-/*!
- Removes \a animation from this QAnimationState.
-*/
-void QAnimationState::removeAnimation(QAbstractAnimation *animation)
-{
- Q_D(QAnimationState);
- d->removeAnimation(animation, d->animations);
-}
-
-/*!
- \reimp
-*/
-void QAnimationState::onEntry()
-{
- Q_D(QAnimationState);
-
- {
- QStateMachinePrivate *machine_d = QStateMachinePrivate::get(d->machine());
- d->pendingRestorables = machine_d->registeredRestorables;
- }
-
- if (d->initializeAnimationFromTargetStates) {
- if (QAbstractTransition *t = d->finishedTransition())
- d->initializeAnimation(t->targetStates());
- }
-
- if (d->initializeAnimationFromRestorableVariables)
- d->restoreAnimations();
-
- for (int i=0; i<d->animations.size(); ++i)
- d->animations.at(i)->start();
-
- for (int i=0; i<d->restorationAnimations.size(); ++i)
- d->restorationAnimations.at(i)->start();
-
- // If there are no animations playing, we use a 0 timer to trigger the transition
- // to the final state
- if (d->animations.size()+d->restorationAnimations.size() == 0) {
- if (d->timer == 0) {
- d->timer = new QTimer(this);
- d->timer->setInterval(0);
- d->timer->setSingleShot(true);
-
- d->animatingState->addTransition(d->timer, SIGNAL(timeout()), d->finishedState);
- }
-
- d->timer->start();
- }
-
-}
-
-/*!
- \reimp
-*/
-void QAnimationState::onExit()
-{
- Q_D(QAnimationState);
-
- for (int i=0; i<d->animations.size(); ++i) {
- if (d->animations.at(i)->state() != QAbstractAnimation::Stopped)
- d->animations.at(i)->stop();
- }
-
- QList<QAbstractAnimation *> restorationAnimations = d->restorationAnimations;
- for (int i=0; i<restorationAnimations.size(); ++i) {
- QAbstractAnimation *restorationAnimation = restorationAnimations.at(i);
- if (restorationAnimation->state() != QAbstractAnimation::Stopped) {
- restorationAnimation->stop();
- d->removeAnimation(restorationAnimation, d->restorationAnimations);
-
- // ###
- delete restorationAnimation;
- } else {
- QPropertyAnimation *propertyAnimation = qobject_cast<QPropertyAnimation*>(restorationAnimation);
- if (propertyAnimation != 0) {
- QStateMachinePrivate *machine_d = QStateMachinePrivate::get(d->machine());
- machine_d->unregisterRestorable(propertyAnimation->targetObject(),
- propertyAnimation->propertyName());
- }
- }
- }
-
- for (int i=0; i<d->resetEndValues.size(); ++i)
- d->resetEndValues.at(i)->setEndValue(QVariant());
-
- if (d->timer != 0)
- d->timer->stop();
-}
-
-/*!
- \reimp
-*/
-bool QAnimationState::event(QEvent *e)
-{
- return QState::event(e);
-}
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_ANIMATION
diff --git a/src/corelib/statemachine/qanimationstate.h b/src/corelib/statemachine/qanimationstate.h
deleted file mode 100644
index 5d11041c1d..0000000000
--- a/src/corelib/statemachine/qanimationstate.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $TROLLTECH_DUAL_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QANIMATIONSTATE_H
-#define QANIMATIONSTATE_H
-
-#ifndef QT_STATEMACHINE_SOLUTION
-#include <QtCore/qstate.h>
-#else
-#include "qstate.h"
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Core)
-
-#ifndef QT_NO_ANIMATION
-
-class QAbstractAnimation;
-
-class QAnimationStatePrivate;
-class Q_CORE_EXPORT QAnimationState : public QState
-{
- Q_OBJECT
-public:
-
- QAnimationState(QAbstractAnimation *animation, QState *parent = 0);
- QAnimationState(QState *parent = 0);
- ~QAnimationState();
-
- int animationCount() const;
- QAbstractAnimation *animationAt(int i) const;
- void addAnimation(QAbstractAnimation *animation);
- void removeAnimation(QAbstractAnimation *animation);
-
-protected:
- virtual void onEntry();
- virtual void onExit();
-
- bool event(QEvent *e);
-
-private:
- Q_DISABLE_COPY(QAnimationState)
- Q_DECLARE_PRIVATE(QAnimationState)
-};
-
-#endif //QT_NO_ANIMATION
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QANIMATIONSTATE_H
diff --git a/src/corelib/statemachine/qboundevent_p.h b/src/corelib/statemachine/qboundevent_p.h
index 5f31372d17..b641ff3a85 100644
--- a/src/corelib/statemachine/qboundevent_p.h
+++ b/src/corelib/statemachine/qboundevent_p.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qeventtransition.cpp b/src/corelib/statemachine/qeventtransition.cpp
index 65f00752e0..87ed77a82d 100644
--- a/src/corelib/statemachine/qeventtransition.cpp
+++ b/src/corelib/statemachine/qeventtransition.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -25,10 +55,11 @@ QT_BEGIN_NAMESPACE
\brief The QEventTransition class provides a QObject-specific transition for Qt events.
+ \since 4.6
\ingroup statemachine
- A QEventTransition object binds an event or transition to a particular
- QObject. QEventTransition is part of \l{The State Machine Framework}.
+ A QEventTransition object binds an event to a particular QObject.
+ QEventTransition is part of \l{The State Machine Framework}.
Example:
@@ -62,6 +93,11 @@ QT_BEGIN_NAMESPACE
\brief the event source that this event transition is associated with
*/
+/*!
+ \property QEventTransition::eventType
+
+ \brief the type of event that this event transition is associated with
+*/
QEventTransitionPrivate::QEventTransitionPrivate()
{
object = 0;
@@ -93,7 +129,7 @@ void QEventTransitionPrivate::invalidate()
Constructs a new QEventTransition object with the given \a sourceState.
*/
QEventTransition::QEventTransition(QState *sourceState)
- : QTransition(*new QEventTransitionPrivate, sourceState)
+ : QActionTransition(*new QEventTransitionPrivate, sourceState)
{
}
@@ -103,7 +139,7 @@ QEventTransition::QEventTransition(QState *sourceState)
*/
QEventTransition::QEventTransition(QObject *object, QEvent::Type type,
QState *sourceState)
- : QTransition(*new QEventTransitionPrivate, sourceState)
+ : QActionTransition(*new QEventTransitionPrivate, sourceState)
{
Q_D(QEventTransition);
d->registered = false;
@@ -119,7 +155,7 @@ QEventTransition::QEventTransition(QObject *object, QEvent::Type type,
QEventTransition::QEventTransition(QObject *object, QEvent::Type type,
const QList<QAbstractState*> &targets,
QState *sourceState)
- : QTransition(*new QEventTransitionPrivate, targets, sourceState)
+ : QActionTransition(*new QEventTransitionPrivate, targets, sourceState)
{
Q_D(QEventTransition);
d->registered = false;
@@ -131,7 +167,7 @@ QEventTransition::QEventTransition(QObject *object, QEvent::Type type,
\internal
*/
QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QState *parent)
- : QTransition(dd, parent)
+ : QActionTransition(dd, parent)
{
}
@@ -140,7 +176,7 @@ QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QState *parent)
*/
QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object,
QEvent::Type type, QState *parent)
- : QTransition(dd, parent)
+ : QActionTransition(dd, parent)
{
Q_D(QEventTransition);
d->registered = false;
@@ -154,7 +190,7 @@ QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object,
QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object,
QEvent::Type type, const QList<QAbstractState*> &targets,
QState *parent)
- : QTransition(dd, targets, parent)
+ : QActionTransition(dd, targets, parent)
{
Q_D(QEventTransition);
d->registered = false;
@@ -248,16 +284,9 @@ bool QEventTransition::testEventCondition(QEvent *event) const
/*!
\reimp
*/
-void QEventTransition::onTransition()
-{
-}
-
-/*!
- \reimp
-*/
bool QEventTransition::event(QEvent *e)
{
- return QTransition::event(e);
+ return QActionTransition::event(e);
}
QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qeventtransition.h b/src/corelib/statemachine/qeventtransition.h
index ece79e85b8..21a696c3ee 100644
--- a/src/corelib/statemachine/qeventtransition.h
+++ b/src/corelib/statemachine/qeventtransition.h
@@ -3,16 +3,50 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QEVENTTRANSITION_H
#define QEVENTTRANSITION_H
-#include "qtransition.h"
+#ifndef QT_STATEMACHINE_SOLUTION
+#include <QtCore/qactiontransition.h>
+#else
+#include "qactiontransition.h"
+#endif
#include <QtCore/qcoreevent.h>
QT_BEGIN_HEADER
@@ -22,11 +56,13 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Core)
class QEventTransitionPrivate;
-class Q_CORE_EXPORT QEventTransition : public QTransition
+class Q_CORE_EXPORT QEventTransition : public QActionTransition
{
Q_OBJECT
Q_PROPERTY(QObject* object READ eventSource WRITE setEventSource)
+#ifndef QT_STATEMACHINE_SOLUTION
Q_PROPERTY(QEvent::Type eventType READ eventType WRITE setEventType)
+#endif
public:
QEventTransition(QState *sourceState = 0);
QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = 0);
@@ -44,7 +80,6 @@ protected:
virtual bool testEventCondition(QEvent *event) const; // ### name
bool eventTest(QEvent *event) const;
- void onTransition();
bool event(QEvent *e);
diff --git a/src/corelib/statemachine/qeventtransition_p.h b/src/corelib/statemachine/qeventtransition_p.h
index 55ea9e6d1c..2bb5aaab6a 100644
--- a/src/corelib/statemachine/qeventtransition_p.h
+++ b/src/corelib/statemachine/qeventtransition_p.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -23,12 +53,12 @@
// We mean it.
//
-#include "qtransition_p.h"
+#include "qactiontransition_p.h"
QT_BEGIN_NAMESPACE
class QEventTransition;
-class Q_CORE_EXPORT QEventTransitionPrivate : public QTransitionPrivate
+class Q_CORE_EXPORT QEventTransitionPrivate : public QActionTransitionPrivate
{
Q_DECLARE_PUBLIC(QEventTransition)
public:
diff --git a/src/corelib/statemachine/qfinalstate.cpp b/src/corelib/statemachine/qfinalstate.cpp
index c4dbcc9783..abf9d2e170 100644
--- a/src/corelib/statemachine/qfinalstate.cpp
+++ b/src/corelib/statemachine/qfinalstate.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -19,6 +49,7 @@ QT_BEGIN_NAMESPACE
\brief The QFinalState class provides a final state.
+ \since 4.6
\ingroup statemachine
A final state is used to communicate that (part of) a QStateMachine has
diff --git a/src/corelib/statemachine/qfinalstate.h b/src/corelib/statemachine/qfinalstate.h
index ba69c36b9a..36813f502b 100644
--- a/src/corelib/statemachine/qfinalstate.h
+++ b/src/corelib/statemachine/qfinalstate.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qhistorystate.cpp b/src/corelib/statemachine/qhistorystate.cpp
index a3da4be49e..8143d41354 100644
--- a/src/corelib/statemachine/qhistorystate.cpp
+++ b/src/corelib/statemachine/qhistorystate.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -19,6 +49,7 @@ QT_BEGIN_NAMESPACE
\brief The QHistoryState class provides a means of returning to a previously active substate.
+ \since 4.6
\ingroup statemachine
A history state is a pseudo-state that represents the child state that the
diff --git a/src/corelib/statemachine/qhistorystate.h b/src/corelib/statemachine/qhistorystate.h
index a18d064de6..9cd7f0b554 100644
--- a/src/corelib/statemachine/qhistorystate.h
+++ b/src/corelib/statemachine/qhistorystate.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qhistorystate_p.h b/src/corelib/statemachine/qhistorystate_p.h
index 1a2461b80f..84648b5357 100644
--- a/src/corelib/statemachine/qhistorystate_p.h
+++ b/src/corelib/statemachine/qhistorystate_p.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qsignalevent.h b/src/corelib/statemachine/qsignalevent.h
index 50ac380924..5dcabc4e07 100644
--- a/src/corelib/statemachine/qsignalevent.h
+++ b/src/corelib/statemachine/qsignalevent.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qsignaleventgenerator_p.h b/src/corelib/statemachine/qsignaleventgenerator_p.h
index 1d4e7d7628..d18def8a4b 100644
--- a/src/corelib/statemachine/qsignaleventgenerator_p.h
+++ b/src/corelib/statemachine/qsignaleventgenerator_p.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp
index 48add0d32b..32f2d02acb 100644
--- a/src/corelib/statemachine/qsignaltransition.cpp
+++ b/src/corelib/statemachine/qsignaltransition.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -25,6 +55,7 @@ QT_BEGIN_NAMESPACE
\brief The QSignalTransition class provides a transition based on a Qt signal.
+ \since 4.6
\ingroup statemachine
Typically you would use the overload of QState::addTransition() that takes a
@@ -106,7 +137,7 @@ void QSignalTransitionPrivate::invalidate()
Constructs a new signal transition with the given \a sourceState.
*/
QSignalTransition::QSignalTransition(QState *sourceState)
- : QTransition(*new QSignalTransitionPrivate, sourceState)
+ : QActionTransition(*new QSignalTransitionPrivate, sourceState)
{
}
@@ -116,7 +147,7 @@ QSignalTransition::QSignalTransition(QState *sourceState)
*/
QSignalTransition::QSignalTransition(QObject *sender, const char *signal,
QState *sourceState)
- : QTransition(*new QSignalTransitionPrivate, sourceState)
+ : QActionTransition(*new QSignalTransitionPrivate, sourceState)
{
Q_D(QSignalTransition);
d->sender = sender;
@@ -131,7 +162,7 @@ QSignalTransition::QSignalTransition(QObject *sender, const char *signal,
QSignalTransition::QSignalTransition(QObject *sender, const char *signal,
const QList<QAbstractState*> &targets,
QState *sourceState)
- : QTransition(*new QSignalTransitionPrivate, targets, sourceState)
+ : QActionTransition(*new QSignalTransitionPrivate, targets, sourceState)
{
Q_D(QSignalTransition);
d->sender = sender;
@@ -202,8 +233,9 @@ bool QSignalTransition::eventTest(QEvent *event) const
#else
if (event->type() == QEvent::Type(QEvent::User-1)) {
#endif
+ if (d->signalIndex == -1)
+ return false;
QSignalEvent *se = static_cast<QSignalEvent*>(event);
- Q_ASSERT(d->signalIndex != -1);
return (se->sender() == d->sender)
&& (se->signalIndex() == d->signalIndex);
}
@@ -213,16 +245,9 @@ bool QSignalTransition::eventTest(QEvent *event) const
/*!
\reimp
*/
-void QSignalTransition::onTransition()
-{
-}
-
-/*!
- \reimp
-*/
bool QSignalTransition::event(QEvent *e)
{
- return QTransition::event(e);
+ return QActionTransition::event(e);
}
QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h
index c090bd8ee5..c1a41ae5a6 100644
--- a/src/corelib/statemachine/qsignaltransition.h
+++ b/src/corelib/statemachine/qsignaltransition.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -13,9 +43,9 @@
#define QSIGNALTRANSITION_H
#ifndef QT_STATEMACHINE_SOLUTION
-#include <QtCore/qtransition.h>
+#include <QtCore/qactiontransition.h>
#else
-#include "qtransition.h"
+#include "qactiontransition.h"
#endif
QT_BEGIN_HEADER
@@ -25,7 +55,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Core)
class QSignalTransitionPrivate;
-class Q_CORE_EXPORT QSignalTransition : public QTransition
+class Q_CORE_EXPORT QSignalTransition : public QActionTransition
{
Q_OBJECT
Q_PROPERTY(QObject* object READ senderObject WRITE setSenderObject)
@@ -47,7 +77,6 @@ public:
protected:
bool eventTest(QEvent *event) const;
- void onTransition();
bool event(QEvent *e);
diff --git a/src/corelib/statemachine/qsignaltransition_p.h b/src/corelib/statemachine/qsignaltransition_p.h
index d200676b57..bd815d9f54 100644
--- a/src/corelib/statemachine/qsignaltransition_p.h
+++ b/src/corelib/statemachine/qsignaltransition_p.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -23,12 +53,12 @@
// We mean it.
//
-#include "qtransition_p.h"
+#include "qactiontransition_p.h"
QT_BEGIN_NAMESPACE
class QSignalTransition;
-class QSignalTransitionPrivate : public QTransitionPrivate
+class QSignalTransitionPrivate : public QActionTransitionPrivate
{
Q_DECLARE_PUBLIC(QSignalTransition)
public:
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index 26dbd89ab0..e3da1c5156 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -19,9 +49,6 @@
#include "qstatefinishedtransition.h"
#include "qstatemachine.h"
#include "qstatemachine_p.h"
-#ifndef QT_NO_ANIMATION
-#include "qanimationstate.h"
-#endif
QT_BEGIN_NAMESPACE
@@ -30,6 +57,7 @@ QT_BEGIN_NAMESPACE
\brief The QState class provides a general-purpose state for QStateMachine.
+ \since 4.6
\ingroup statemachine
QState objects can have child states, and can have transitions to other
@@ -47,6 +75,9 @@ QT_BEGIN_NAMESPACE
The addHistoryState() function adds a history state.
+ The addFinishedTransition() function creates and adds a transition that's
+ triggered when a final child state is entered.
+
The setErrorState() sets the state's error state. The error state is the
state that the state machine will transition to if an error is detected when
attempting to enter the state (e.g. because no initial state has been set).
@@ -242,36 +273,42 @@ void QState::addTransition(QAbstractTransition *transition)
/*!
Adds a transition associated with the given \a signal of the given \a sender
- object. The transition has this state as the source, and the given \a target
- as the target state.
+ object, and returns the new QSignalTransition object. The transition has
+ this state as the source, and the given \a target as the target state.
*/
-void QState::addTransition(QObject *sender, const char *signal,
- QAbstractState *target)
+QSignalTransition *QState::addTransition(QObject *sender, const char *signal,
+ QAbstractState *target)
{
if (!sender) {
qWarning("QState::addTransition: sender cannot be null");
- return;
+ return 0;
}
if (!signal) {
qWarning("QState::addTransition: signal cannot be null");
- return;
+ return 0;
}
- addTransition(new QSignalTransition(sender, signal, QList<QAbstractState*>() << target));
+ QSignalTransition *trans = new QSignalTransition(sender, signal, QList<QAbstractState*>() << target);
+ addTransition(trans);
+ return trans;
}
/*!
Adds a transition that's triggered by the finished event of this state, and
- that has the given \a target state.
+ returns the new QStateFinishedTransition object. The transition has the
+ given \a target state.
\sa QStateFinishedEvent
*/
-void QState::addFinishedTransition(QAbstractState *target)
+QStateFinishedTransition *QState::addFinishedTransition(QAbstractState *target)
{
- addTransition(new QStateFinishedTransition(this, QList<QAbstractState*>() << target));
+ QStateFinishedTransition *trans = new QStateFinishedTransition(this, QList<QAbstractState*>() << target);
+ addTransition(trans);
+ return trans;
}
namespace {
+// ### Make public?
class UnconditionalTransition : public QAbstractTransition
{
public:
@@ -286,11 +323,13 @@ protected:
/*!
Adds an unconditional transition from this state to the given \a target
- state.
+ state, and returns then new transition object.
*/
-void QState::addTransition(QAbstractState *target)
+QAbstractTransition *QState::addTransition(QAbstractState *target)
{
- addTransition(new UnconditionalTransition(target));
+ UnconditionalTransition *trans = new UnconditionalTransition(target);
+ addTransition(trans);
+ return trans;
}
/*!
@@ -355,80 +394,6 @@ void QState::onExit()
QActionState::onExit();
}
-#ifndef QT_NO_ANIMATION
-
-/*!
- \overload addAnimatedTransition()
-
- Adds an animated transition from the current state to \a targetState for \a animation.
-
- This function creates a QSignalTransition for the \a sender and \a signal, and calls
- addAnimatedTransition() with this transition object.
-*/
-QAnimationState *QState::addAnimatedTransition(QObject *sender, const char *signal,
- QAbstractState *targetState,
- QAbstractAnimation *animation)
-{
- if (!targetState) {
- qWarning("QState::addAnimatedTransition: cannot add transition to null state");
- return 0;
- }
- return addAnimatedTransition(
- new QSignalTransition(sender, signal,
- QList<QAbstractState*>() << targetState), animation);
-}
-
-/*!
- Adds an animated transition from the current state.
-
- The animated transition has an intermediate QAnimationState which plays \a
- animation before entering the target state(s). This QAnimationState will be
- entered when \a transition is taken by the state machine. When the animation
- has finished playing, the transition's target state(s) will be entered.
-
- The new QAnimationState object will become a child of this state's parent state.
-
- \code
- QPushButton button;
- QPropertyAnimation animation(&button, "geometry");
- animation.setEndValue(QRect(100, 100, 400, 400));
-
- QStateMachine machine;
-
- QState *s1 = new QState();
- QState *s2 = new QState();
-
- QTransition *transition = new QTransition(MyEventType);
- s1->addAnimatedTransition(transition, s2, &animation);
- \endcode
-
- The function returns the new QAnimationState. This state can be used if you want to add additional
- transitions into or out from the animation state, and if you want to add additional animations.
-
- \sa QAnimationState
-*/
-QAnimationState *QState::addAnimatedTransition(QAbstractTransition *transition,
- QAbstractAnimation *animation)
-{
- if (!transition) {
- qWarning("QState::addAnimatedTransition: cannot add null transition");
- return 0;
- }
- QList<QAbstractState*> targets = transition->targetStates();
- Q_ASSERT(!targets.isEmpty());
- if (!targets.at(0)->parentState()) {
- qWarning("QState::addAnimatedTransition: cannot add transition to target that doesn't have a parent state");
- return 0;
- }
- QAnimationState *animState = new QAnimationState(animation, targets.at(0)->parentState());
- animState->addTransition(new QStateFinishedTransition(animState, targets));
- transition->setTargetStates(QList<QAbstractState*>() << animState);
- addTransition(transition);
- return animState;
-}
-
-#endif
-
/*!
Returns this state's initial state, or 0 if the state has no initial state.
*/
diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h
index ba2d034daf..4c86e02a76 100644
--- a/src/corelib/statemachine/qstate.h
+++ b/src/corelib/statemachine/qstate.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -26,10 +56,8 @@ QT_MODULE(Core)
class QAbstractTransition;
class QHistoryState;
-#ifndef QT_NO_ANIMATION
-class QAbstractAnimation;
-class QAnimationState;
-#endif
+class QSignalTransition;
+class QStateFinishedTransition;
class QStatePrivate;
class Q_CORE_EXPORT QState : public QActionState
@@ -54,20 +82,12 @@ public:
void setErrorState(QAbstractState *state);
void addTransition(QAbstractTransition *transition);
- void addTransition(QObject *sender, const char *signal, QAbstractState *target);
- void addTransition(QAbstractState *target);
- void addFinishedTransition(QAbstractState *target);
+ QSignalTransition *addTransition(QObject *sender, const char *signal, QAbstractState *target);
+ QAbstractTransition *addTransition(QAbstractState *target);
+ QStateFinishedTransition *addFinishedTransition(QAbstractState *target);
void removeTransition(QAbstractTransition *transition);
QList<QAbstractTransition*> transitions() const;
-#ifndef QT_NO_ANIMATION
- QAnimationState *addAnimatedTransition(QObject *sender, const char *signal,
- QAbstractState *targetState,
- QAbstractAnimation *animation = 0);
- QAnimationState *addAnimatedTransition(QAbstractTransition *transition,
- QAbstractAnimation *animation = 0);
-#endif
-
QHistoryState *addHistoryState(HistoryType type = ShallowHistory);
QAbstractState *initialState() const;
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index fe9b24ab82..17b312a567 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qstateaction.cpp b/src/corelib/statemachine/qstateaction.cpp
index c12b093e50..569d5d57ac 100644
--- a/src/corelib/statemachine/qstateaction.cpp
+++ b/src/corelib/statemachine/qstateaction.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -41,11 +71,12 @@ void QStateActionPrivate::callExecute()
\brief The QStateAction class is the base class of QState actions.
+ \since 4.6
\ingroup statemachine
- A state action is added to a state by calling QState::addEntryAction() or
- QState::addExitAction(). QStateAction is part of \l{The State Machine
- Framework}.
+ A state action is added to a state by calling QActionState::addEntryAction()
+ or QActionState::addExitAction(). QStateAction is part of \l{The State
+ Machine Framework}.
\section1 Subclassing
@@ -112,151 +143,6 @@ bool QStateAction::event(QEvent *e)
return QObject::event(e);
}
-QStateSetPropertyActionPrivate *QStateSetPropertyActionPrivate::get(QStateSetPropertyAction *q)
-{
- return q->d_func();
-}
-
-/*!
- \class QStateSetPropertyAction
-
- \brief The QStateSetPropertyAction class provides a set property action for QObjects.
-
- \ingroup statemachine
-
- The QStateSetPropertyAction class provides an action that sets a property of
- a QObject to a pre-defined value when a QState is entered or exited.
- QStateSetPropertyAction is part of \l{The State Machine Framework}.
-
- Typically you don't construct QStateSetPropertyAction objects directly, but
- rather call the QState::setPropertyOnEntry() function or the
- QState::setPropertyOnExit() function.
-*/
-
-/*!
- \property QStateSetPropertyAction::target
-
- \brief the object for which this action sets a property
-*/
-
-/*!
- \property QStateSetPropertyAction::propertyName
-
- \brief the name of the property set by this action
-*/
-
-/*!
- \property QStateSetPropertyAction::value
-
- \brief the value set by this action
-*/
-
-/*!
- Constructs a new QStateSetPropertyAction object for the property named \a
- propertyName of the given \a target object, with the given \a value, and
- with the given \a parent.
-*/
-QStateSetPropertyAction::QStateSetPropertyAction(
- QObject *target, const QByteArray &propertyName,
- const QVariant &value, QObject *parent)
- : QStateAction(*new QStateSetPropertyActionPrivate, parent)
-{
- Q_D(QStateSetPropertyAction);
- d->target = target;
- d->propertyName = propertyName;
- d->value = value;
-}
-
-/*!
- Constructs a new QStateSetPropertyAction object with the given \a parent.
-*/
-QStateSetPropertyAction::QStateSetPropertyAction(QObject *parent)
- : QStateAction(*new QStateSetPropertyActionPrivate, parent)
-{
- Q_D(QStateSetPropertyAction);
- d->target = 0;
-}
-
-/*!
- Destroys this QStateAbstractSetPropertyAction object.
-*/
-QStateSetPropertyAction::~QStateSetPropertyAction()
-{
-}
-
-/*!
- Returns the object for which this action sets a property.
-*/
-QObject *QStateSetPropertyAction::targetObject() const
-{
- Q_D(const QStateSetPropertyAction);
- return d->target;
-}
-
-/*!
- Sets the object for which this action sets a property.
-*/
-void QStateSetPropertyAction::setTargetObject(QObject *target)
-{
- Q_D(QStateSetPropertyAction);
- d->target = target;
-}
-
-/*!
- Returns the name of the property set by this action.
-*/
-QByteArray QStateSetPropertyAction::propertyName() const
-{
- Q_D(const QStateSetPropertyAction);
- return d->propertyName;
-}
-
-/*!
- Sets the name of the property set by this action.
-*/
-void QStateSetPropertyAction::setPropertyName(const QByteArray &propertyName)
-{
- Q_D(QStateSetPropertyAction);
- d->propertyName = propertyName;
-}
-
-/*!
- Returns the value set by this action.
-*/
-QVariant QStateSetPropertyAction::value() const
-{
- Q_D(const QStateSetPropertyAction);
- return d->value;
-}
-
-/*!
- Sets the value set by this action.
-*/
-void QStateSetPropertyAction::setValue(const QVariant &value)
-{
- Q_D(QStateSetPropertyAction);
- d->value = value;
-}
-
-/*!
- \reimp
-*/
-void QStateSetPropertyAction::execute()
-{
- Q_D(QStateSetPropertyAction);
- if (!d->target)
- return;
- d->target->setProperty(d->propertyName, d->value);
-}
-
-/*!
- \reimp
-*/
-bool QStateSetPropertyAction::event(QEvent *e)
-{
- return QStateAction::event(e);
-}
-
QStateInvokeMethodActionPrivate *QStateInvokeMethodActionPrivate::get(QStateInvokeMethodAction *q)
{
return q->d_func();
@@ -267,6 +153,7 @@ QStateInvokeMethodActionPrivate *QStateInvokeMethodActionPrivate::get(QStateInvo
\brief The QStateInvokeMethodAction class provides an invoke method action for QObjects.
+ \since 4.6
\ingroup statemachine
The QStateInvokeMethodAction class provides an action that calls a method of
diff --git a/src/corelib/statemachine/qstateaction.h b/src/corelib/statemachine/qstateaction.h
index df1e0f0b55..68430809f4 100644
--- a/src/corelib/statemachine/qstateaction.h
+++ b/src/corelib/statemachine/qstateaction.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,38 +78,6 @@ private:
Q_DECLARE_PRIVATE(QStateAction)
};
-class QStateSetPropertyActionPrivate;
-class Q_CORE_EXPORT QStateSetPropertyAction : public QStateAction
-{
- Q_OBJECT
- Q_PROPERTY(QObject* target READ targetObject WRITE setTargetObject)
- Q_PROPERTY(QByteArray propertyName READ propertyName WRITE setPropertyName)
- Q_PROPERTY(QVariant value READ value WRITE setValue)
-public:
- QStateSetPropertyAction(QObject *target, const QByteArray &propertyName,
- const QVariant &value, QObject *parent = 0);
- QStateSetPropertyAction(QObject *parent = 0);
- ~QStateSetPropertyAction();
-
- QObject *targetObject() const;
- void setTargetObject(QObject *target);
-
- QByteArray propertyName() const;
- void setPropertyName(const QByteArray &name);
-
- QVariant value() const;
- void setValue(const QVariant &value);
-
-protected:
- void execute();
-
- bool event(QEvent *e);
-
-private:
- Q_DISABLE_COPY(QStateSetPropertyAction)
- Q_DECLARE_PRIVATE(QStateSetPropertyAction)
-};
-
class QStateInvokeMethodActionPrivate;
class Q_CORE_EXPORT QStateInvokeMethodAction : public QStateAction
{
diff --git a/src/corelib/statemachine/qstateaction_p.h b/src/corelib/statemachine/qstateaction_p.h
index 54e3a05157..4016b74a5a 100644
--- a/src/corelib/statemachine/qstateaction_p.h
+++ b/src/corelib/statemachine/qstateaction_p.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -56,21 +86,6 @@ public:
#endif
};
-class QStateSetPropertyAction;
-class QStateSetPropertyActionPrivate : public QStateActionPrivate
-{
- Q_DECLARE_PUBLIC(QStateSetPropertyAction)
-public:
- QStateSetPropertyActionPrivate() {}
- ~QStateSetPropertyActionPrivate() {}
-
- static QStateSetPropertyActionPrivate *get(QStateSetPropertyAction *q);
-
- QObject *target;
- QByteArray propertyName;
- QVariant value;
-};
-
class QStateInvokeMethodAction;
class QStateInvokeMethodActionPrivate : public QStateActionPrivate
{
diff --git a/src/corelib/statemachine/qstatefinishedevent.h b/src/corelib/statemachine/qstatefinishedevent.h
index d6a11464a1..c2f81f7398 100644
--- a/src/corelib/statemachine/qstatefinishedevent.h
+++ b/src/corelib/statemachine/qstatefinishedevent.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qstatefinishedtransition.cpp b/src/corelib/statemachine/qstatefinishedtransition.cpp
index 3d8c5883a5..33c3d22e29 100644
--- a/src/corelib/statemachine/qstatefinishedtransition.cpp
+++ b/src/corelib/statemachine/qstatefinishedtransition.cpp
@@ -3,15 +3,45 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#include "qstatefinishedtransition.h"
#include "qstatefinishedevent.h"
-#include "qtransition_p.h"
+#include "qactiontransition_p.h"
QT_BEGIN_NAMESPACE
@@ -50,7 +80,7 @@ QT_BEGIN_NAMESPACE
\brief the state whose QStateFinishedEvent this transition is associated with
*/
-class QStateFinishedTransitionPrivate : public QTransitionPrivate
+class QStateFinishedTransitionPrivate : public QActionTransitionPrivate
{
Q_DECLARE_PUBLIC(QStateFinishedTransition)
public:
@@ -76,7 +106,7 @@ QStateFinishedTransitionPrivate *QStateFinishedTransitionPrivate::get(QStateFini
sourceState.
*/
QStateFinishedTransition::QStateFinishedTransition(QState *sourceState)
- : QTransition(*new QStateFinishedTransitionPrivate, sourceState)
+ : QActionTransition(*new QStateFinishedTransitionPrivate, sourceState)
{
}
@@ -86,7 +116,7 @@ QStateFinishedTransition::QStateFinishedTransition(QState *sourceState)
*/
QStateFinishedTransition::QStateFinishedTransition(
QState *state, const QList<QAbstractState*> &targets, QState *sourceState)
- : QTransition(*new QStateFinishedTransitionPrivate, targets, sourceState)
+ : QActionTransition(*new QStateFinishedTransitionPrivate, targets, sourceState)
{
Q_D(QStateFinishedTransition);
d->state = state;
@@ -137,16 +167,9 @@ bool QStateFinishedTransition::eventTest(QEvent *event) const
/*!
\reimp
*/
-void QStateFinishedTransition::onTransition()
-{
-}
-
-/*!
- \reimp
-*/
bool QStateFinishedTransition::event(QEvent *e)
{
- return QTransition::event(e);
+ return QActionTransition::event(e);
}
QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qstatefinishedtransition.h b/src/corelib/statemachine/qstatefinishedtransition.h
index bcd82fa226..f9320f5394 100644
--- a/src/corelib/statemachine/qstatefinishedtransition.h
+++ b/src/corelib/statemachine/qstatefinishedtransition.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -13,9 +43,9 @@
#define QSTATEFINISHEDTRANSITION_H
#ifndef QT_STATEMACHINE_SOLUTION
-#include <QtCore/qtransition.h>
+#include <QtCore/qactiontransition.h>
#else
-#include "qtransition.h"
+#include "qactiontransition.h"
#endif
QT_BEGIN_HEADER
@@ -27,7 +57,7 @@ QT_MODULE(Core)
class QState;
class QStateFinishedTransitionPrivate;
-class Q_CORE_EXPORT QStateFinishedTransition : public QTransition
+class Q_CORE_EXPORT QStateFinishedTransition : public QActionTransition
{
Q_OBJECT
Q_PROPERTY(QState* state READ state WRITE setState)
@@ -42,7 +72,6 @@ public:
protected:
bool eventTest(QEvent *event) const;
- void onTransition();
bool event(QEvent *e);
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 208c6a9bcf..0a1d248d07 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -26,7 +56,6 @@
#include "qhistorystate_p.h"
#include "qstatefinishedevent.h"
#include "qstatefinishedtransition.h"
-#include "qmetaobject.h"
#include "qstate.h"
#include "qstate_p.h"
#include "qstateaction.h"
@@ -44,9 +73,15 @@
#ifndef QT_NO_ANIMATION
#include "qpropertyanimation.h"
-#include "qanimationstate.h"
+#include "qanimationgroup.h"
+# ifndef QT_STATEMACHINE_SOLUTION
+# include <private/qvariantanimation_p.h>
+# else
+# include "qvariantanimation_p.h"
+# endif
#endif
+#include <QtCore/qmetaobject.h>
#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -57,6 +92,7 @@ QT_BEGIN_NAMESPACE
\brief The QStateMachine class provides a hierarchical finite state machine.
+ \since 4.6
\ingroup statemachine
The QStateMachine class provides a hierarchical finite state machine based
@@ -75,7 +111,7 @@ QT_BEGIN_NAMESPACE
invoke methods on QObjects when the state is entered or exited. This is
typically used in conjunction with \l{Signals and Slots}{signals}; the
signals determine the flow of the state graph, whereas the states' property
- assigments and method invocations are the actions.
+ assignments and method invocations are the actions.
Use the addState() function to add a state to the state machine;
alternatively, pass the machine's rootState() to the state constructor. Use
@@ -89,7 +125,7 @@ QT_BEGIN_NAMESPACE
QStateMachine machine;
QState *s1 = new QState();
- s1->setPropertyOnEntry(&button, "text", "Click me");
+ s1->assignProperty(&button, "text", "Click me");
QFinalState *s2 = new QFinalState();
s1->addTransition(&button, SIGNAL(clicked()), s2);
@@ -148,7 +184,6 @@ QT_BEGIN_NAMESPACE
*/
// #define QSTATEMACHINE_DEBUG
-// #define QT_NO_STATEMACHINE_RESTOREPROPERTIES
QStateMachinePrivate::QStateMachinePrivate()
{
@@ -157,7 +192,7 @@ QStateMachinePrivate::QStateMachinePrivate()
processingScheduled = false;
stop = false;
error = QStateMachine::NoError;
- globalRestorePolicy = QState::DoNotRestoreProperties;
+ globalRestorePolicy = QAbstractState::DoNotRestoreProperties;
rootState = 0;
initialErrorStateForRoot = 0;
#ifndef QT_STATEMACHINE_SOLUTION
@@ -320,14 +355,15 @@ void QStateMachinePrivate::microstep(const QList<QAbstractTransition*> &enabledT
qDebug() << q_func() << ": configuration after exiting states:" << configuration;
#endif
executeTransitionContent(enabledTransitions);
- enterStates(enabledTransitions);
+ QList<QAbstractState*> enteredStates = enterStates(enabledTransitions);
+ applyProperties(enabledTransitions, enteredStates);
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q_func() << ": configuration after entering states:" << configuration;
qDebug() << q_func() << ": end microstep";
#endif
}
-void QStateMachinePrivate::exitStates(const QList<QAbstractTransition*> &enabledTransitions)
+QList<QAbstractState*> QStateMachinePrivate::exitStates(const QList<QAbstractTransition*> &enabledTransitions)
{
// qDebug() << "exitStates(" << enabledTransitions << ")";
QSet<QAbstractState*> statesToExit;
@@ -382,6 +418,7 @@ void QStateMachinePrivate::exitStates(const QList<QAbstractTransition*> &enabled
QAbstractStatePrivate::get(s)->callOnExit();
configuration.remove(s);
}
+ return statesToExit_sorted;
}
void QStateMachinePrivate::executeTransitionContent(const QList<QAbstractTransition*> &enabledTransitions)
@@ -395,7 +432,7 @@ void QStateMachinePrivate::executeTransitionContent(const QList<QAbstractTransit
}
}
-void QStateMachinePrivate::enterStates(const QList<QAbstractTransition*> &enabledTransitions)
+QList<QAbstractState*> QStateMachinePrivate::enterStates(const QList<QAbstractTransition*> &enabledTransitions)
{
#ifdef QSTATEMACHINE_DEBUG
Q_Q(QStateMachine);
@@ -458,65 +495,6 @@ void QStateMachinePrivate::enterStates(const QList<QAbstractTransition*> &enable
QList<QAbstractState*> statesToEnter_sorted = statesToEnter.toList();
qSort(statesToEnter_sorted.begin(), statesToEnter_sorted.end(), stateEntryLessThan);
-
-#ifndef QT_NO_STATEMACHINE_RESTOREPROPERTIES
- bool hasAnimationState = false;
-
- QHash<RestorableId, QVariant> pendingRestorables = registeredRestorables;
- for (int i = 0; i < statesToEnter_sorted.size(); ++i) {
- QAbstractState *as = statesToEnter_sorted.at(i);
-
-#ifndef QT_NO_ANIMATION
- // If we are going to an animation state, it will restore properties for us
- hasAnimationState = hasAnimationState
- || qobject_cast<QAnimationState*>(as) != 0;
-#endif
-
- QActionState *s = qobject_cast<QActionState*>(as);
- if (s == 0)
- continue;
-
- QActionState::RestorePolicy restorePolicy = s->restorePolicy();
- if (restorePolicy == QActionState::GlobalRestorePolicy)
- restorePolicy = globalRestorePolicy;
-
- if (restorePolicy == QActionState::DoNotRestoreProperties)
- continue;
-
- QActionStatePrivate *s_d = QActionStatePrivate::get(s);
- QList<QStateAction*> actions = s_d->entryActions();
-
- for (int j = 0; j < actions.size(); ++j) {
- QStateSetPropertyAction *spa = qobject_cast<QStateSetPropertyAction*>(actions.at(j));
- if (spa == 0 || spa->targetObject() == 0)
- continue;
-
- registerRestorable(spa->targetObject(), spa->propertyName());
- pendingRestorables.remove(RestorableId(spa->targetObject(), spa->propertyName()));
- }
- }
-
-#ifndef QT_NO_ANIMATION
- // If the configuration has an animation state, we do not want to restore here, as we
- // might be transitioning inside the animation state (into the final state for instance.)
- // We let the animation state handle the restoration.
- QSet<QAbstractState*>::const_iterator it;
- for (it=configuration.constBegin(); !hasAnimationState && it!=configuration.constEnd(); ++it)
- hasAnimationState = qobject_cast<QAnimationState*>(*it) != 0;
-#endif
-
- if (!hasAnimationState) {
- QHash<RestorableId, QVariant>::const_iterator it;
- for (it = pendingRestorables.constBegin(); it != pendingRestorables.constEnd(); ++it) {
- QObject *object = it.key().first;
- QByteArray propertyName = it.key().second;
-
- object->setProperty(propertyName, it.value());
- unregisterRestorable(object, propertyName);
- }
- }
-
-#endif // QT_NO_STATEMACHINE_RESTOREPROPERTIES
for (int i = 0; i < statesToEnter_sorted.size(); ++i) {
QAbstractState *s = statesToEnter_sorted.at(i);
@@ -568,6 +546,7 @@ void QStateMachinePrivate::enterStates(const QList<QAbstractTransition*> &enable
}
}
// qDebug() << "configuration:" << configuration.toList();
+ return statesToEnter_sorted;
}
void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root,
@@ -618,6 +597,115 @@ void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root,
}
}
+void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &transitionList,
+ const QList<QAbstractState*> &enteredStates)
+{
+#ifndef QT_NO_ANIMATION
+ Q_Q(QStateMachine);
+ // Gracefully terminate playing animations.
+ for (int i = 0; i < playingAnimations.size(); ++i)
+ playingAnimations.at(i)->stop();
+ playingAnimations.clear();
+ for (int i = 0; i < resetEndValues.size(); ++i)
+ qobject_cast<QVariantAnimation*>(resetEndValues.at(i))->setEndValue(QVariant()); // ### generalize
+ resetEndValues.clear();
+
+ // Find the animations to use for the state change.
+ QList<QAbstractAnimation*> selectedAnimations;
+ for (int i = 0; i < transitionList.size(); ++i)
+ selectedAnimations << transitionList.at(i)->animations();
+#else
+ Q_UNUSED(transitionList);
+#endif
+
+ // Process the SetProperty definitions of the entered states.
+ QList<QPropertyAssignment> propertyAssignments;
+ QHash<RestorableId, QVariant> pendingRestorables = registeredRestorables;
+ for (int i = 0; i < enteredStates.size(); ++i) {
+ QAbstractState *s = enteredStates.at(i);
+
+ QAbstractState::RestorePolicy restorePolicy = s->restorePolicy();
+ if (restorePolicy == QAbstractState::GlobalRestorePolicy)
+ restorePolicy = globalRestorePolicy;
+
+ QList<QPropertyAssignment> assignments = QAbstractStatePrivate::get(s)->propertyAssignments;
+ for (int j = 0; j < assignments.size(); ++j) {
+ const QPropertyAssignment &assn = assignments.at(j);
+ if (restorePolicy == QAbstractState::RestoreProperties) {
+ registerRestorable(assn.object, assn.propertyName);
+ }
+ pendingRestorables.remove(RestorableId(assn.object, assn.propertyName));
+ propertyAssignments.append(assn);
+ }
+ }
+ propertyAssignments << restorablesToPropertyList(pendingRestorables);
+
+#ifndef QT_NO_ANIMATION
+ // Set the animated properties that did not finish animating and that are not
+ // set in the new state.
+ for (int i = 0; i < propertiesForAnimations.size(); ++i) {
+ QPropertyAssignment assn = propertiesForAnimations.at(i).second;
+ bool found = false;
+ for (int j = 0; j < propertyAssignments.size(); ++j) {
+ if ((propertyAssignments.at(j).object == assn.object)
+ && (propertyAssignments.at(j).propertyName == assn.propertyName)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ assn.object->setProperty(assn.propertyName, assn.value);
+ }
+ }
+
+ // Initialize animations from SetProperty definitions.
+ propertiesForAnimations.clear();
+ for (int i = 0; i < selectedAnimations.size(); ++i) {
+ QAbstractAnimation *anim = selectedAnimations.at(i);
+ QList<QPropertyAssignment>::iterator it;
+ for (it = propertyAssignments.begin(); it != propertyAssignments.end(); ) {
+ QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> > ret;
+ ret = initializeAnimation(anim, *it);
+ QList<QAbstractAnimation*> handlers = ret.first;
+ if (!handlers.isEmpty()) {
+ for (int j = 0; j < handlers.size(); ++j)
+ propertiesForAnimations.append(qMakePair(handlers.at(j), *it));
+ it = propertyAssignments.erase(it);
+ } else {
+ ++it;
+ }
+ resetEndValues << ret.second;
+ }
+
+ // We require that at least one animation is valid.
+ // ### generalize
+ QList<QVariantAnimation*> variantAnims = qFindChildren<QVariantAnimation*>(anim);
+ if (QVariantAnimation *va = qobject_cast<QVariantAnimation*>(anim))
+ variantAnims.append(va);
+ bool hasValidEndValue = false;
+ for (int j = 0; j < variantAnims.size(); ++j) {
+ if (variantAnims.at(j)->endValue().isValid()) {
+ hasValidEndValue = true;
+ break;
+ }
+ }
+
+ if (hasValidEndValue) {
+ QObject::disconnect(anim, SIGNAL(finished()), q, SLOT(_q_animationFinished()));
+ QObject::connect(anim, SIGNAL(finished()), q, SLOT(_q_animationFinished()));
+ anim->start();
+ playingAnimations.append(anim);
+ }
+ }
+#endif // !QT_NO_ANIMATION
+
+ // Immediately set the properties that are not animated.
+ for (int i = 0; i < propertyAssignments.size(); ++i) {
+ const QPropertyAssignment &assn = propertyAssignments.at(i);
+ assn.object->setProperty(assn.propertyName, assn.value);
+ }
+}
+
bool QStateMachinePrivate::isFinal(const QAbstractState *s)
{
return qobject_cast<const QFinalState*>(s) != 0;
@@ -696,7 +784,18 @@ void QStateMachinePrivate::registerRestorable(QObject *object, const QByteArray
{
RestorableId id(object, propertyName);
if (!registeredRestorables.contains(id))
- registeredRestorables.insert(id, object->property(propertyName));
+ registeredRestorables.insert(id, object->property(propertyName));
+}
+
+QList<QPropertyAssignment> QStateMachinePrivate::restorablesToPropertyList(const QHash<RestorableId, QVariant> &restorables) const
+{
+ QList<QPropertyAssignment> result;
+ QHash<RestorableId, QVariant>::const_iterator it;
+ for (it = restorables.constBegin(); it != restorables.constEnd(); ++it) {
+// qDebug() << "restorable:" << it.key().first << it.key().second << it.value();
+ result.append(QPropertyAssignment(it.key().first, it.key().second, it.value(), /*explicitlySet=*/false));
+ }
+ return result;
}
/*!
@@ -720,48 +819,11 @@ QVariant QStateMachinePrivate::restorableValue(QObject *object, const QByteArray
*/
void QStateMachinePrivate::unregisterRestorable(QObject *object, const QByteArray &propertyName)
{
+// qDebug() << "unregisterRestorable(" << object << propertyName << ")";
RestorableId id(object, propertyName);
registeredRestorables.remove(id);
-
-#ifndef QT_NO_ANIMATION
- registeredRestorableAnimations.remove(id);
-#endif
-
}
-#ifndef QT_NO_ANIMATION
-void QStateMachinePrivate::registerRestorable(QPropertyAnimation *animation)
-{
- // We always want to restore to the first registered value, so if one is already present, we
- // leave it be.
- RestorableId id(animation->targetObject(), animation->propertyName());
- if (!registeredRestorableAnimations.contains(id))
- registeredRestorableAnimations.insert(id, animation);
- registerRestorable(animation->targetObject(), animation->propertyName());
-}
-
-
-/*!
- \internal
- Returns all variables currently registered. The list returned is in no particular order.
-*/
-QList<QPropertyAnimation*> QStateMachinePrivate::restorableAnimations() const
-{
- return registeredRestorableAnimations.values();
-}
-
-/*!
- \internal
- Returns a reference to the restorable identified by \a id.
-*/
-QPropertyAnimation *QStateMachinePrivate::restorableAnimation(QObject *object,
- const QByteArray &propertyName)
-{
- return registeredRestorableAnimations.value(RestorableId(object, propertyName), 0);
-}
-
-#endif // QT_NO_ANIMATION
-
QAbstractState *QStateMachinePrivate::findErrorState(QAbstractState *context)
{
// If the user sets the root state's error state to 0, we return the initial error state
@@ -820,6 +882,82 @@ void QStateMachinePrivate::setError(QStateMachine::Error errorCode, QAbstractSta
}
}
+#ifndef QT_NO_ANIMATION
+
+QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> >
+QStateMachinePrivate::initializeAnimation(QAbstractAnimation *abstractAnimation,
+ const QPropertyAssignment &prop)
+{
+ QList<QAbstractAnimation*> handledAnimations;
+ QList<QAbstractAnimation*> localResetEndValues;
+ QAnimationGroup *group = qobject_cast<QAnimationGroup*>(abstractAnimation);
+ if (group) {
+ for (int i = 0; i < group->animationCount(); ++i) {
+ QAbstractAnimation *animationChild = group->animationAt(i);
+ QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> > ret;
+ ret = initializeAnimation(animationChild, prop);
+ handledAnimations << ret.first;
+ localResetEndValues << ret.second;
+ }
+ } else {
+ QPropertyAnimation *animation = qobject_cast<QPropertyAnimation *>(abstractAnimation);
+ if (animation != 0
+ && prop.object == animation->targetObject()
+ && prop.propertyName == animation->propertyName()) {
+
+ if (!animation->startValue().isValid()) {
+ QByteArray propertyName = animation->propertyName();
+ QVariant currentValue = animation->targetObject()->property(propertyName);
+
+ QVariantAnimationPrivate::get(animation)->setDefaultStartValue(currentValue);
+ }
+
+ // Only change end value if it is undefined
+ if (!animation->endValue().isValid()) {
+ animation->setEndValue(prop.value);
+ localResetEndValues.append(animation);
+ }
+ handledAnimations.append(animation);
+ }
+ }
+ return qMakePair(handledAnimations, localResetEndValues);
+}
+
+static bool isAncestorOf(QObject *anc, QObject *o)
+{
+ for (o = o->parent() ; o != 0; o = o->parent()) {
+ if (o == anc)
+ return true;
+ }
+ return false;
+}
+
+void QStateMachinePrivate::_q_animationFinished()
+{
+ Q_Q(QStateMachine);
+ QAbstractAnimation *animation = qobject_cast<QAbstractAnimation*>(q->sender());
+ Q_ASSERT(animation != 0);
+ QList<QPair<QAbstractAnimation*, QPropertyAssignment> >::iterator it;
+ for (it = propertiesForAnimations.begin(); it != propertiesForAnimations.end(); ) {
+ QAbstractAnimation *a = (*it).first;
+ if (a == animation || isAncestorOf(animation, a)) {
+ QPropertyAssignment assn = (*it).second;
+ assn.object->setProperty(assn.propertyName, assn.value);
+ if (!assn.explicitlySet)
+ unregisterRestorable(assn.object, assn.propertyName);
+ it = propertiesForAnimations.erase(it);
+ } else {
+ ++it;
+ }
+ }
+
+ playingAnimations.removeOne(animation);
+ if (playingAnimations.isEmpty())
+ emit q->animationsFinished();
+}
+
+#endif // !QT_NO_ANIMATION
+
namespace {
class StartState : public QState
@@ -876,6 +1014,7 @@ void QStateMachinePrivate::_q_start()
transitions.append(initialTransition);
executeTransitionContent(transitions);
enterStates(transitions);
+ applyProperties(transitions, QList<QAbstractState*>() << initial);
delete start;
#ifdef QSTATEMACHINE_DEBUG
@@ -911,7 +1050,7 @@ void QStateMachinePrivate::_q_process()
if (enabledTransitions.isEmpty() && !internalEventQueue.isEmpty()) {
e = internalEventQueue.takeFirst();
#ifdef QSTATEMACHINE_DEBUG
- qDebug() << q << ": dequeued internal event" << e;
+ qDebug() << q << ": dequeued internal event" << e << "of type" << e->type();
#endif
enabledTransitions = selectTransitions(e);
if (enabledTransitions.isEmpty()) {
@@ -928,7 +1067,7 @@ void QStateMachinePrivate::_q_process()
} else {
e = externalEventQueue.takeFirst();
#ifdef QSTATEMACHINE_DEBUG
- qDebug() << q << ": dequeued external event" << e;
+ qDebug() << q << ": dequeued external event" << e << "of type" << e->type();
#endif
enabledTransitions = selectTransitions(e);
if (enabledTransitions.isEmpty()) {
@@ -1075,6 +1214,7 @@ void QStateMachinePrivate::unregisterSignalTransition(QSignalTransition *transit
int signalIndex = QSignalTransitionPrivate::get(transition)->signalIndex;
if (signalIndex == -1)
return; // not registered
+#ifndef QT_STATEMACHINE_SOLUTION
const QObject *sender = QSignalTransitionPrivate::get(transition)->sender;
QList<int> &connectedSignalIndexes = connections[sender];
Q_ASSERT(connectedSignalIndexes.contains(signalIndex));
@@ -1087,6 +1227,7 @@ void QStateMachinePrivate::unregisterSignalTransition(QSignalTransition *transit
connections.remove(sender);
QSignalTransitionPrivate::get(transition)->signalIndex = -1;
}
+#endif
}
#ifndef QT_NO_STATEMACHINE_EVENTFILTER
@@ -1174,6 +1315,24 @@ QStateMachine::QStateMachine(QObject *parent)
}
/*!
+ \internal
+*/
+QStateMachine::QStateMachine(QStateMachinePrivate &dd, QObject *parent)
+ : QObject(
+#ifndef QT_STATEMACHINE_SOLUTION
+ dd,
+#endif
+ parent)
+#ifdef QT_STATEMACHINE_SOLUTION
+ , d_ptr(&dd)
+#endif
+{
+#ifdef QT_STATEMACHINE_SOLUTION
+ d_ptr->q_ptr = this;
+#endif
+}
+
+/*!
Destroys this state machine.
*/
QStateMachine::~QStateMachine()
@@ -1332,13 +1491,13 @@ QActionState::RestorePolicy QStateMachine::globalRestorePolicy() const
/*!
Sets the global restore policy of the state machine to \a restorePolicy. The default global
- restore policy is QActionState::DoNotRestoreProperties.
+ restore policy is QAbstractState::DoNotRestoreProperties.
- The global restore policy cannot be set to QActionState::GlobalRestorePolicy.
+ The global restore policy cannot be set to QAbstractState::GlobalRestorePolicy.
- \sa QActionState::setRestorePolicy()
+ \sa QAbstractState::setRestorePolicy()
*/
-void QStateMachine::setGlobalRestorePolicy(QActionState::RestorePolicy restorePolicy)
+void QStateMachine::setGlobalRestorePolicy(QAbstractState::RestorePolicy restorePolicy)
{
Q_D(QStateMachine);
if (restorePolicy == QState::GlobalRestorePolicy) {
@@ -1564,6 +1723,18 @@ QSet<QAbstractState*> QStateMachine::configuration() const
\sa QStateMachine::stop()
*/
+#ifndef QT_NO_ANIMATION
+
+/*!
+ \fn QStateMachine::animationsFinished()
+
+ This signal is emitted when the state machine has finished playing all
+ animations associated with the latest transition (i.e., all properties have
+ reached their target values).
+*/
+
+#endif
+
/*!
\reimp
*/
@@ -1737,6 +1908,7 @@ QSignalEventGenerator::QSignalEventGenerator(
\brief The QSignalEvent class represents a Qt signal event.
+ \since 4.6
\ingroup statemachine
A signal event is generated by a QStateMachine in response to a Qt
@@ -1751,6 +1923,8 @@ QSignalEventGenerator::QSignalEventGenerator(
*/
/*!
+ \internal
+
Constructs a new QSignalEvent object with the given \a sender, \a
signalIndex and \a arguments.
*/
@@ -1800,6 +1974,7 @@ QSignalEvent::~QSignalEvent()
\brief The QStateFinishedEvent class contains parameters that describe a state that has finished.
+ \since 4.6
\ingroup statemachine
A state is finished when one of its final child states (a QFinalState) is
@@ -1814,6 +1989,8 @@ QSignalEvent::~QSignalEvent()
*/
/*!
+ \internal
+
Constructs a new QStateFinishedEvent object associated with the given \a state.
*/
QStateFinishedEvent::QStateFinishedEvent(QState *state)
@@ -1823,7 +2000,7 @@ QStateFinishedEvent::QStateFinishedEvent(QState *state)
#else
QEvent(QEvent::Type(QEvent::User-2))
#endif
- , m_state(state)
+ , m_state(state), d(0)
{
}
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index e3b09e0502..c7de171094 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -66,8 +96,8 @@ public:
QString errorString() const;
void clearError();
- QActionState::RestorePolicy globalRestorePolicy() const;
- void setGlobalRestorePolicy(QActionState::RestorePolicy restorePolicy);
+ QAbstractState::RestorePolicy globalRestorePolicy() const;
+ void setGlobalRestorePolicy(QAbstractState::RestorePolicy restorePolicy);
void postEvent(QEvent *event, int delay = 0);
@@ -87,6 +117,10 @@ Q_SIGNALS:
void stopped();
void finished();
+#ifndef QT_NO_ANIMATION
+ void animationsFinished();
+#endif
+
protected:
void postInternalEvent(QEvent *event);
@@ -98,15 +132,20 @@ protected:
bool event(QEvent *e);
+protected:
#ifdef QT_STATEMACHINE_SOLUTION
QStateMachinePrivate *d_ptr;
#endif
+ QStateMachine(QStateMachinePrivate &dd, QObject *parent);
private:
Q_DISABLE_COPY(QStateMachine)
Q_DECLARE_PRIVATE(QStateMachine)
Q_PRIVATE_SLOT(d_func(), void _q_start())
Q_PRIVATE_SLOT(d_func(), void _q_process())
+#ifndef QT_NO_ANIMATION
+ Q_PRIVATE_SLOT(d_func(), void _q_animationFinished())
+#endif
};
QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index dfa95e5049..04dc71e9b6 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -3,9 +3,39 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
-** This file is part of the $MODULE$ of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -29,9 +59,10 @@
#include <QtCore/qcoreevent.h>
#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
+#include <QtCore/qpair.h>
#include <QtCore/qset.h>
-#include "qstate.h"
+#include "qabstractstate_p.h"
QT_BEGIN_NAMESPACE
@@ -46,7 +77,7 @@ class QAbstractTransition;
class QState;
#ifndef QT_NO_ANIMATION
-class QPropertyAnimation;
+class QAbstractAnimation;
#endif
class QStateMachine;
@@ -84,17 +115,23 @@ public:
// private slots
void _q_start();
void _q_process();
+#ifndef QT_NO_ANIMATION
+ void _q_animationFinished();
+#endif
void microstep(const QList<QAbstractTransition*> &transitionList);
bool isPreempted(const QAbstractState *s, const QSet<QAbstractTransition*> &transitions) const;
QSet<QAbstractTransition*> selectTransitions(QEvent *event) const;
- void exitStates(const QList<QAbstractTransition*> &transitionList);
+ QList<QAbstractState*> exitStates(const QList<QAbstractTransition*> &transitionList);
void executeTransitionContent(const QList<QAbstractTransition*> &transitionList);
- void enterStates(const QList<QAbstractTransition*> &enabledTransitions);
+ QList<QAbstractState*> enterStates(const QList<QAbstractTransition*> &enabledTransitions);
void addStatesToEnter(QAbstractState *s, QState *root,
QSet<QAbstractState*> &statesToEnter,
QSet<QAbstractState*> &statesForDefaultEntry);
+ void applyProperties(const QList<QAbstractTransition*> &transitionList,
+ const QList<QAbstractState*> &enteredStates);
+
bool isInFinalState(QAbstractState *s) const;
static bool isFinal(const QAbstractState *s);
static bool isParallel(const QAbstractState *s);
@@ -121,15 +158,7 @@ public:
void unregisterRestorable(QObject *object, const QByteArray &propertyName);
bool hasRestorable(QObject *object, const QByteArray &propertyName) const;
QVariant restorableValue(QObject *object, const QByteArray &propertyName) const;
-
-#ifndef QT_NO_ANIMATION
- void registerRestorable(QPropertyAnimation *animation);
-
- QPropertyAnimation *restorableAnimation(QObject *object, const QByteArray &propertyName);
- QList<QPropertyAnimation *> restorableAnimations() const;
-
- QHash<RestorableId, QPropertyAnimation*> registeredRestorableAnimations;
-#endif // QT_NO_ANIMATION
+ QList<QPropertyAssignment> restorablesToPropertyList(const QHash<RestorableId, QVariant> &restorables) const;
State state;
bool processing;
@@ -149,6 +178,16 @@ public:
QSet<QAbstractState *> pendingErrorStatesForDefaultEntry;
QAbstractState *initialErrorStateForRoot;
+#ifndef QT_NO_ANIMATION
+ QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> >
+ initializeAnimation(QAbstractAnimation *abstractAnimation,
+ const QPropertyAssignment &prop);
+
+ QList<QPair<QAbstractAnimation*, QPropertyAssignment> > propertiesForAnimations;
+ QList<QAbstractAnimation*> playingAnimations;
+ QList<QAbstractAnimation*> resetEndValues;
+#endif
+
#ifndef QT_STATEMACHINE_SOLUTION
QSignalEventGenerator *signalEventGenerator;
#endif
diff --git a/src/corelib/statemachine/qtransition.cpp b/src/corelib/statemachine/qtransition.cpp
deleted file mode 100644
index ebd972c824..0000000000
--- a/src/corelib/statemachine/qtransition.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $TROLLTECH_DUAL_LICENSE$
-**
-****************************************************************************/
-
-#include "qtransition.h"
-#include "qtransition_p.h"
-#include "qstateaction.h"
-#include "qstateaction_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QTransition
-
- \brief The QTransition class provides an action-based transition.
-
- \ingroup statemachine
-
- QTransition provides an action-based transition; you add actions with the
- addAction() function. The transition executes the actions when the
- transition is triggered. QTransition is part of \l{The State Machine
- Framework}.
-
- Built-in actions are provided for setting properties and invoking methods of
- QObjects. The setPropertyOnTransition() function is used for defining
- property assignments that should be performed when a transition is taken.
- The invokeMethodOnTransition() function is used for defining method
- invocations that should be performed when a transition is taken.
-
- \code
- QStateMachine machine;
- QState *s1 = new QState();
- machine.addState(s1);
- QTransition *t1 = new QTransition();
- QLabel label;
- t1->setPropertyOnTransition(&label, "text", "Transition t1 was triggered");
- QState *s2 = new QState();
- machine.addState(s2);
- t1->setTargetState(s2);
- s1->addTransition(t1);
- \endcode
-
- Actions are executed in the order in which they were added.
-
- \sa QState::addTransition(), QStateAction
-*/
-
-QTransitionPrivate::QTransitionPrivate()
-{
-}
-
-QTransitionPrivate::~QTransitionPrivate()
-{
-}
-
-QTransitionPrivate *QTransitionPrivate::get(QTransition *q)
-{
- return q->d_func();
-}
-
-const QTransitionPrivate *QTransitionPrivate::get(const QTransition *q)
-{
- return q->d_func();
-}
-
-QList<QStateAction*> QTransitionPrivate::actions() const
-{
- QList<QStateAction*> result;
- QList<QObject*>::const_iterator it;
-#ifdef QT_STATEMACHINE_SOLUTION
- const QObjectList &children = q_func()->children();
-#endif
- for (it = children.constBegin(); it != children.constEnd(); ++it) {
- QStateAction *s = qobject_cast<QStateAction*>(*it);
- if (s)
- result.append(s);
- }
- return result;
-}
-
-/*!
- Constructs a new QTransition object with the given \a sourceState.
-*/
-QTransition::QTransition(QState *sourceState)
- : QAbstractTransition(*new QTransitionPrivate, sourceState)
-{
-}
-
-/*!
- Constructs a new QTransition object with the given \a targets and \a
- sourceState.
-*/
-QTransition::QTransition(const QList<QAbstractState*> &targets, QState *sourceState)
- : QAbstractTransition(*new QTransitionPrivate, targets, sourceState)
-{
-}
-
-/*!
- \internal
-*/
-QTransition::QTransition(QTransitionPrivate &dd, QState *parent)
- : QAbstractTransition(dd, parent)
-{
-}
-
-/*!
- \internal
-*/
-QTransition::QTransition(QTransitionPrivate &dd, const QList<QAbstractState*> &targets, QState *parent)
- : QAbstractTransition(dd, targets, parent)
-{
-}
-
-/*!
- Destroys this transition.
-*/
-QTransition::~QTransition()
-{
-}
-
-/*!
- Instructs this QTransition to set the property with the given \a name of the
- given \a object to the given \a value when the transition is taken. This
- function will create a QStateSetPropertyAction object and add it to the
- actions of the transition. If there is already an existing action associated
- with the property, the value of that action is updated.
-
- \sa invokeMethodOnTransition()
-*/
-void QTransition::setPropertyOnTransition(QObject *object, const char *name,
- const QVariant &value)
-{
- Q_D(QTransition);
- QList<QStateAction*> actions = d->actions();
- for (int i = 0; i < actions.size(); ++i) {
- QStateAction *action = actions.at(i);
- if (QStateSetPropertyAction *spa = qobject_cast<QStateSetPropertyAction*>(action)) {
- if (spa->targetObject() == object && spa->propertyName() == name) {
- QStateSetPropertyActionPrivate::get(spa)->value = value;
- return;
- }
- }
- }
- addAction(new QStateSetPropertyAction(object, name, value));
-}
-
-/*!
- Instructs this QTransition to invoke the given \a method of the given \a
- object with the given \a arguments when the transition is taken. This
- function will create a QStateInvokeMethodAction object and add it to the
- actions of the transition.
-
- \sa setPropertyOnTransition()
-*/
-void QTransition::invokeMethodOnTransition(QObject *object, const char *method,
- const QList<QVariant> &arguments)
-{
- addAction(new QStateInvokeMethodAction(object, method, arguments));
-}
-
-/*!
- Adds the given \a action to this transition.
- The action will be executed when the transition is triggered.
- The transition takes ownership of the action.
-
- \sa removeAction()
-*/
-void QTransition::addAction(QStateAction *action)
-{
- if (!action) {
- qWarning("QTransition::addAction: cannot add null action");
- return;
- }
- action->setParent(this);
-}
-
-/*!
- Removes the given \a action from this transition.
- The transition releases ownership of the action.
-
- \sa addAction()
-*/
-void QTransition::removeAction(QStateAction *action)
-{
- if (!action) {
- qWarning("QTransition::removeAction: cannot remove null action");
- return;
- }
- action->setParent(0);
-}
-
-/*!
- Returns this transitions's actions, or an empty list if the transition has
- no actions.
-
- \sa addAction()
-*/
-QList<QStateAction*> QTransition::actions() const
-{
- Q_D(const QTransition);
- return d->actions();
-}
-
-/*!
- \reimp
-*/
-void QTransition::onTransition()
-{
- Q_D(QTransition);
- QList<QStateAction*> actions = d->actions();
- for (int i = 0; i < actions.size(); ++i)
- QStateActionPrivate::get(actions.at(i))->callExecute();
-}
-
-/*!
- \reimp
-*/
-bool QTransition::event(QEvent *e)
-{
- return QAbstractTransition::event(e);
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qtransition.h b/src/corelib/statemachine/qtransition.h
deleted file mode 100644
index 57d97185eb..0000000000
--- a/src/corelib/statemachine/qtransition.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $TROLLTECH_DUAL_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTRANSITION_H
-#define QTRANSITION_H
-
-#ifndef QT_STATEMACHINE_SOLUTION
-#include <QtCore/qabstracttransition.h>
-#else
-#include "qabstracttransition.h"
-#endif
-
-#include <QtCore/qvariant.h>
-#include <QtCore/qlist.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Core)
-
-class QStateAction;
-
-class QTransitionPrivate;
-class Q_CORE_EXPORT QTransition : public QAbstractTransition
-{
- Q_OBJECT
-public:
- QTransition(QState *sourceState = 0);
- QTransition(const QList<QAbstractState*> &targets, QState *sourceState = 0);
- ~QTransition();
-
- void setPropertyOnTransition(QObject *object, const char *name,
- const QVariant &value);
- void invokeMethodOnTransition(QObject *object, const char *method,
- const QList<QVariant> &args = QList<QVariant>());
-
- void addAction(QStateAction *action);
- void removeAction(QStateAction *action);
- QList<QStateAction*> actions() const;
-
-protected:
- virtual void onTransition();
-
- bool event(QEvent *e);
-
-protected:
- QTransition(QTransitionPrivate &dd, QState *parent);
- QTransition(QTransitionPrivate &dd, const QList<QAbstractState*> &targets, QState *parent);
-
-private:
- Q_DISABLE_COPY(QTransition)
- Q_DECLARE_PRIVATE(QTransition)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/corelib/statemachine/qtransition_p.h b/src/corelib/statemachine/qtransition_p.h
deleted file mode 100644
index e5da6ded77..0000000000
--- a/src/corelib/statemachine/qtransition_p.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $TROLLTECH_DUAL_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTRANSITION_P_H
-#define QTRANSITION_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qabstracttransition_p.h"
-
-#include <QtCore/qlist.h>
-
-QT_BEGIN_NAMESPACE
-
-class QStateAction;
-
-class QTransition;
-class Q_CORE_EXPORT QTransitionPrivate : public QAbstractTransitionPrivate
-{
- Q_DECLARE_PUBLIC(QTransition)
-public:
- QTransitionPrivate();
- ~QTransitionPrivate();
-
- static QTransitionPrivate *get(QTransition *q);
- static const QTransitionPrivate *get(const QTransition *q);
-
- QList<QStateAction*> actions() const;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/corelib/statemachine/statemachine.pri b/src/corelib/statemachine/statemachine.pri
index 8409b4d878..4179e4543b 100644
--- a/src/corelib/statemachine/statemachine.pri
+++ b/src/corelib/statemachine/statemachine.pri
@@ -14,8 +14,8 @@ HEADERS += $$PWD/qstatemachine.h \
$$PWD/qhistorystate_p.h \
$$PWD/qabstracttransition.h \
$$PWD/qabstracttransition_p.h \
- $$PWD/qtransition.h \
- $$PWD/qtransition_p.h \
+ $$PWD/qactiontransition.h \
+ $$PWD/qactiontransition_p.h \
$$PWD/qstatefinishedevent.h \
$$PWD/qstatefinishedtransition.h \
$$PWD/qsignalevent.h \
@@ -30,7 +30,7 @@ SOURCES += $$PWD/qstatemachine.cpp \
$$PWD/qfinalstate.cpp \
$$PWD/qhistorystate.cpp \
$$PWD/qabstracttransition.cpp \
- $$PWD/qtransition.cpp \
+ $$PWD/qactiontransition.cpp \
$$PWD/qstatefinishedtransition.cpp \
$$PWD/qsignaltransition.cpp
@@ -40,8 +40,3 @@ HEADERS += $$PWD/qboundevent_p.h \
$$PWD/qeventtransition_p.h
SOURCES += $$PWD/qeventtransition.cpp
}
-
-!contains(DEFINES, QT_NO_ANIMATION) {
-HEADERS += $$PWD/qanimationstate.h
-SOURCES += $$PWD/qanimationstate.cpp
-}
diff --git a/src/gui/animation/animation.pri b/src/gui/animation/animation.pri
index 3092117d68..27763ca003 100644
--- a/src/gui/animation/animation.pri
+++ b/src/gui/animation/animation.pri
@@ -1,8 +1,3 @@
# Qt gui animation module
-HEADERS += \
- animation/qitemanimation.h \
- animation/qitemanimation_p.h
-
-SOURCES += \
- animation/qitemanimation.cpp
+SOURCES += animation/qguivariantanimation.cpp
diff --git a/src/gui/animation/qitemanimation.h b/src/gui/animation/qguivariantanimation.cpp
index d630fe742a..46ba251924 100644
--- a/src/gui/animation/qitemanimation.h
+++ b/src/gui/animation/qguivariantanimation.cpp
@@ -39,73 +39,41 @@
**
****************************************************************************/
-#ifndef QITEMANIMATION_H
-#define QITEMANIMATION_H
+#ifndef QT_NO_ANIMATION
+
+QT_BEGIN_NAMESPACE
-#if defined(QT_EXPERIMENTAL_SOLUTION)
+#ifdef QT_EXPERIMENTAL_SOLUTION
# include "qvariantanimation.h"
+# include "qvariantanimation_p.h"
#else
-# include <QtCore/qvariantanimation.h>
+#include <QtCore/qvariantanimation.h>
+#include <private/qvariantanimation_p.h>
#endif
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ANIMATION
-class QGraphicsItem;
-
-class QItemAnimationPrivate;
-class Q_GUI_EXPORT QItemAnimation : public QVariantAnimation
+template<> Q_INLINE_TEMPLATE QColor _q_interpolate(const QColor &f,const QColor &t, qreal progress)
{
-public:
- enum PropertyName
- {
- None, //default
- Position,
- Opacity,
- RotationX,
- RotationY,
- RotationZ,
- ScaleFactorX,
- ScaleFactorY
- };
-
- Q_OBJECT
- Q_PROPERTY(PropertyName propertyName READ propertyName WRITE setPropertyName)
- Q_PROPERTY(QGraphicsItem* targetItem READ targetItem WRITE setTargetItem) /*NOTIFY targetItemChanged*/
+ return QColor(_q_interpolate(f.red(), t.red(), progress),
+ _q_interpolate(f.green(), t.green(), progress),
+ _q_interpolate(f.blue(), t.blue(), progress),
+ _q_interpolate(f.alpha(), t.alpha(), progress));
+}
-public:
- QItemAnimation(QObject *parent = 0);
- QItemAnimation(QGraphicsItem *target, PropertyName p = None, QObject *parent = 0);
- ~QItemAnimation();
-
- QGraphicsItem *targetItem() const;
- void setTargetItem(QGraphicsItem *item);
-
- PropertyName propertyName() const;
- void setPropertyName(PropertyName);
-
- static QList<QItemAnimation*> runningAnimations(QGraphicsItem *item = 0);
- static QItemAnimation* runningAnimation(QGraphicsItem *item, PropertyName prop);
-
-protected:
- bool event(QEvent *event);
- void updateCurrentValue(const QVariant &value);
- void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
-
-private:
- Q_DISABLE_COPY(QItemAnimation)
- Q_DECLARE_PRIVATE(QItemAnimation)
-};
+static int qRegisterGuiGetInterpolator()
+{
+ qRegisterAnimationInterpolator<QColor>(_q_interpolateVariant<QColor>);
+ return 1;
+}
+Q_CONSTRUCTOR_FUNCTION(qRegisterGuiGetInterpolator)
-#endif //QT_NO_ANIMATION
+static int qUnregisterGuiGetInterpolator()
+{
+ qRegisterAnimationInterpolator<QColor>(0);
+ return 1;
+}
+Q_DESTRUCTOR_FUNCTION(qUnregisterGuiGetInterpolator)
QT_END_NAMESPACE
-QT_END_HEADER
-
-#endif //QITEMANIMATION_H
+#endif //QT_NO_ANIMATION
diff --git a/src/gui/animation/qitemanimation.cpp b/src/gui/animation/qitemanimation.cpp
deleted file mode 100644
index 484b3865a6..0000000000
--- a/src/gui/animation/qitemanimation.cpp
+++ /dev/null
@@ -1,361 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \class QItemAnimation
- \brief The QItemAnimation class animates properties for QGraphicsItem
- \since 4.5
- \ingroup animation
- \preliminary
-
- This class is part of {The Animation Framework}. You can use QItemAnimation
- by itself as a simple animation class, or as part of more complex
- animations through QAnimationGroup.
-
- The most common way to use QItemAnimation is to construct an instance
- of it by passing a pointer to a QGraphicsItem and the property you
- would like to animate to QItemAnimation's constructor.
-
- The start value of the animation is optional. If you do not set any start
- value, the animation will operate on the target's current property value
- at the point when the animation was started. You can call setStartValue()
- to set the start value, and setEndValue() to set the target value for
- the animated property.
-
- You can choose to assign a target item by either calling setTargetItem()
- or by passing a QGraphicsItem pointer to QVariantAnimation's constructor.
-
- \sa QVariantAnimation, QAnimationGroup, {The Animation Framework}
-*/
-
-
-#ifndef QT_NO_ANIMATION
-
-#include "qitemanimation.h"
-#include "qitemanimation_p.h"
-
-#include <QtCore/QMutex>
-#ifdef QT_EXPERIMENTAL_SOLUTION
-#include "qanimationgroup.h"
-#else
-#include <QtCore/QAnimationGroup>
-#endif
-#include <QtGui/QGraphicsItem>
-
-
-QT_BEGIN_NAMESPACE
-
-typedef QPair<QGraphicsItem *, QItemAnimation::PropertyName> QItemAnimationPair;
-typedef QHash<QItemAnimationPair, QItemAnimation*> QItemAnimationHash;
-Q_GLOBAL_STATIC(QItemAnimationHash, _q_runningAnimations)
-Q_GLOBAL_STATIC_WITH_ARGS(QMutex, guardHashLock, (QMutex::Recursive) )
-
-void QItemAnimationPrivate::initDefaultStartValue()
-{
- if (target && !defaultStartValue.isValid() && (atBeginning() || atEnd())) {
- switch (propertyName)
- {
- case QItemAnimation::Position:
- setDefaultStartValue(target->pos());
- break;
- case QItemAnimation::Opacity:
- setDefaultStartValue(target->opacity());
- break;
- case QItemAnimation::RotationX:
- setDefaultStartValue(target->xRotation());
- break;
- case QItemAnimation::RotationY:
- setDefaultStartValue(target->yRotation());
- break;
- case QItemAnimation::RotationZ:
- setDefaultStartValue(target->zRotation());
- break;
- case QItemAnimation::ScaleFactorX:
- setDefaultStartValue(target->xScale());
- break;
- case QItemAnimation::ScaleFactorY:
- setDefaultStartValue(target->yScale());
- break;
- default:
- break;
- }
- }
-}
-
-
-/*!
- Construct a QItemAnimation object. \a parent is passed to QObject's
- constructor.
-*/
-
-QItemAnimation::QItemAnimation(QObject *parent) : QVariantAnimation(*new QItemAnimationPrivate, parent)
-{
-}
-
-/*!
- Construct a QItemAnimation object. \a parent is passed to QObject's
- constructor. The animation changes the property \a propertyName on \a
- target. The default duration is 250ms.
-
- \sa targetItem, propertyName
-*/
-
-QItemAnimation::QItemAnimation(QGraphicsItem *target, PropertyName p, QObject *parent) : QVariantAnimation(*new QItemAnimationPrivate, parent)
-{
- Q_D(QItemAnimation);
- d->target = target;
- d->propertyName = p;
-}
-
-/*!
- Destroys the QPropertyAnimation instance.
- */
-QItemAnimation::~QItemAnimation()
-{
- stop();
-}
-
-/*!
- \property QItemAnimation::targetItem
- \brief the target Graphics Item for this animation.
-
- This property defines the target item for this animation.
-
- \sa targetItem
- */
-
-QGraphicsItem *QItemAnimation::targetItem() const
-{
- Q_D(const QItemAnimation);
- return d->target;
-}
-
-void QItemAnimation::setTargetItem(QGraphicsItem *item)
-{
- Q_D(QItemAnimation);
- d->target = item;
-}
-
-/*!
- \property QItemAnimation::propertyName
- \brief the target property for this animation
-
- This property defines the target property for this animation. The
- property is required for the animation to operate.
- */
-QItemAnimation::PropertyName QItemAnimation::propertyName() const
-{
- Q_D(const QItemAnimation);
- return d->propertyName;
-}
-
-void QItemAnimation::setPropertyName(PropertyName p)
-{
- Q_D(QItemAnimation);
- d->propertyName = p;
-}
-
-/*!
- This static function returns the list of running animations on \a item.
- If item is 0, then it returns all QItemAnimations running on all QGraphicsItem.
- */
-QList<QItemAnimation*> QItemAnimation::runningAnimations(QGraphicsItem *item)
-{
- QMutexLocker locker(guardHashLock());
- QList<QItemAnimation*> animList = _q_runningAnimations()->values();
- if (item == 0)
- return animList;
-
- QList<QItemAnimation*> ret;
-
- for (QList<QItemAnimation*>::const_iterator it = animList.constBegin(); it != animList.constEnd(); ++it) {
- if ((*it)->targetItem() == item)
- ret += *it;
- }
-
- return ret;
-}
-
-/*!
- This static function returns the running animations on \a item and on \a property.
- \a prop.
- */
-QItemAnimation* QItemAnimation::runningAnimation(QGraphicsItem *item, PropertyName prop)
-{
- QMutexLocker locker(guardHashLock());
- return _q_runningAnimations()->value(qMakePair(item, prop), 0 /*default value*/);
-}
-
-/*!
- \reimp
- */
-bool QItemAnimation::event(QEvent *event)
-{
- return QVariantAnimation::event(event);
-}
-
-/*!
- \reimp
- */
-void QItemAnimation::updateCurrentValue(const QVariant &value)
-{
- Q_D(QItemAnimation);
- if (!d->target || d->state == Stopped)
- return;
-
- switch (d->propertyName)
- {
- case Position:
- d->target->setPos(qVariantValue<QPointF>(value));
- break;
- case Opacity:
- d->target->setOpacity(qVariantValue<qreal>(value));
- break;
- case RotationX:
- d->target->setXRotation(qVariantValue<qreal>(value));
- break;
- case RotationY:
- d->target->setYRotation(qVariantValue<qreal>(value));
- break;
- case RotationZ:
- d->target->setZRotation(qVariantValue<qreal>(value));
- break;
- case ScaleFactorX:
- d->target->setXScale(qVariantValue<qreal>(value));
- break;
- case ScaleFactorY:
- d->target->setYScale(qVariantValue<qreal>(value));
- break;
- default:
- qWarning("The property you're trying to animate is not managed by the item");
- break;
- }
-}
-
-
-/*!
- \reimp
-*/
-void QItemAnimation::updateState(QAbstractAnimation::State oldState,
- QAbstractAnimation::State newState)
-{
- Q_D(QItemAnimation);
- QVariantAnimation::updateState(oldState, newState);
- QMutexLocker locker(guardHashLock());
- QItemAnimationHash *hash = _q_runningAnimations();
- QItemAnimationPair key(d->target, d->propertyName);
-
- //let's try to convert start and target values according to the type of the proerty
- //we're animating
- if (newState != Stopped) {
- int type = QVariant::Invalid;
- switch (d->propertyName)
- {
- case Position:
- type = QVariant::PointF;
- break;
- case Opacity:
- case RotationX:
- case RotationY:
- case RotationZ:
- case ScaleFactorX:
- case ScaleFactorY:
- type = qMetaTypeId<qreal>();
- break;
- case None:
- default:
- break;
-
- }
- if (type != QVariant::Invalid) {
- d->convertValues(type);
- }
- }
-
- if (newState == Running) {
- if (hash->contains(key)) {
- QItemAnimation *oldAnim = hash->value(key);
- if (oldAnim != this) {
- //we try to stop the top level group
- QAbstractAnimation *current = oldAnim;
- while(current->group() && current->state() != Stopped) current = current->group();
- current->stop();
- }
- }
- hash->insert(key, this);
- // Initialize start value
- d->initDefaultStartValue();
-
- } else if (hash->value(key) == this) {
- hash->remove(key);
- }
-}
-
-///TODO: should be placed somewhere else (in its own file)
-template<> Q_INLINE_TEMPLATE QColor _q_interpolate(const QColor &f,const QColor &t, qreal progress)
-{
- return QColor(_q_interpolate(f.red(), t.red(), progress),
- _q_interpolate(f.green(), t.green(), progress),
- _q_interpolate(f.blue(), t.blue(), progress),
- _q_interpolate(f.alpha(), t.alpha(), progress));
-}
-
-
-
-static int qRegisterGuiGetInterpolator()
-{
- qRegisterAnimationInterpolator<QColor>(_q_interpolateVariant<QColor>);
- return 1;
-}
-Q_CONSTRUCTOR_FUNCTION(qRegisterGuiGetInterpolator)
-
-static int qUnregisterGuiGetInterpolator()
-{
- qRegisterAnimationInterpolator<QColor>(0);
- return 1;
-}
-Q_DESTRUCTOR_FUNCTION(qUnregisterGuiGetInterpolator)
-
-QT_END_NAMESPACE
-
-#include "moc_qitemanimation.cpp"
-
-#endif //QT_NO_ANIMATION
diff --git a/src/gui/statemachine/qguistatemachine.cpp b/src/gui/statemachine/qguistatemachine.cpp
index 540036aa84..d30265a970 100644
--- a/src/gui/statemachine/qguistatemachine.cpp
+++ b/src/gui/statemachine/qguistatemachine.cpp
@@ -17,6 +17,7 @@
#include <private/qstatemachine_p.h>
#endif
#include <QtGui/qevent.h>
+#include <QtGui/qgraphicssceneevent.h>
QT_BEGIN_NAMESPACE
@@ -72,12 +73,11 @@ static QEvent *cloneEvent(QEvent *e)
case QEvent::ThreadChange:
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
break;
+
case QEvent::WindowActivate:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
case QEvent::WindowDeactivate:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
+ return new QEvent(*e);
+
case QEvent::ShowToParent:
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
break;
@@ -360,20 +360,41 @@ static QEvent *cloneEvent(QEvent *e)
break;
case QEvent::GraphicsSceneMouseMove:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
case QEvent::GraphicsSceneMousePress:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
case QEvent::GraphicsSceneMouseRelease:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
- case QEvent::GraphicsSceneMouseDoubleClick:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
- case QEvent::GraphicsSceneContextMenu:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
+ case QEvent::GraphicsSceneMouseDoubleClick: {
+ QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent*>(e);
+ QGraphicsSceneMouseEvent *me2 = new QGraphicsSceneMouseEvent(me->type());
+ me2->setWidget(me->widget());
+ me2->setPos(me->pos());
+ me2->setScenePos(me->scenePos());
+ me2->setScreenPos(me->screenPos());
+// ### for all buttons
+ me2->setButtonDownPos(Qt::LeftButton, me->buttonDownPos(Qt::LeftButton));
+ me2->setButtonDownPos(Qt::RightButton, me->buttonDownPos(Qt::RightButton));
+ me2->setButtonDownScreenPos(Qt::LeftButton, me->buttonDownScreenPos(Qt::LeftButton));
+ me2->setButtonDownScreenPos(Qt::RightButton, me->buttonDownScreenPos(Qt::RightButton));
+ me2->setLastPos(me->lastPos());
+ me2->setLastScenePos(me->lastScenePos());
+ me2->setLastScreenPos(me->lastScreenPos());
+ me2->setButtons(me->buttons());
+ me2->setButton(me->button());
+ me2->setModifiers(me->modifiers());
+ return me2;
+ }
+
+ case QEvent::GraphicsSceneContextMenu: {
+ QGraphicsSceneContextMenuEvent *me = static_cast<QGraphicsSceneContextMenuEvent*>(e);
+ QGraphicsSceneContextMenuEvent *me2 = new QGraphicsSceneContextMenuEvent(me->type());
+ me2->setWidget(me->widget());
+ me2->setPos(me->pos());
+ me2->setScenePos(me->scenePos());
+ me2->setScreenPos(me->screenPos());
+ me2->setModifiers(me->modifiers());
+ me2->setReason(me->reason());
+ return me2;
+ }
+
case QEvent::GraphicsSceneHoverEnter:
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
break;
@@ -449,9 +470,14 @@ static QEvent *cloneEvent(QEvent *e)
case QEvent::GraphicsSceneResize:
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
break;
- case QEvent::GraphicsSceneMove:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
+ case QEvent::GraphicsSceneMove: {
+ QGraphicsSceneMoveEvent *me = static_cast<QGraphicsSceneMoveEvent*>(e);
+ QGraphicsSceneMoveEvent *me2 = new QGraphicsSceneMoveEvent();
+ me2->setWidget(me->widget());
+ me2->setNewPos(me->newPos());
+ me2->setOldPos(me->oldPos());
+ return me2;
+ }
case QEvent::CursorChange:
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
@@ -465,17 +491,11 @@ static QEvent *cloneEvent(QEvent *e)
break;
case QEvent::GrabMouse:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
case QEvent::UngrabMouse:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
case QEvent::GrabKeyboard:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
case QEvent::UngrabKeyboard:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
+ return new QEvent(*e);
+
#ifdef QT_MAC_USE_COCOA
case QEvent::CocoaRequestModal:
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
diff --git a/src/gui/statemachine/qkeyeventtransition.cpp b/src/gui/statemachine/qkeyeventtransition.cpp
index 5b0c85755b..88e4adda1f 100644
--- a/src/gui/statemachine/qkeyeventtransition.cpp
+++ b/src/gui/statemachine/qkeyeventtransition.cpp
@@ -25,6 +25,7 @@ QT_BEGIN_NAMESPACE
\brief The QKeyEventTransition class provides a transition for key events.
+ \since 4.6
\ingroup statemachine
QKeyEventTransition is part of \l{The State Machine Framework}.
@@ -119,7 +120,8 @@ Qt::KeyboardModifiers QKeyEventTransition::modifiers() const
}
/*!
- Sets the keyboard modifiers that this key event transition will check for.
+ Sets the keyboard \a modifiers that this key event transition will check
+ for.
*/
void QKeyEventTransition::setModifiers(Qt::KeyboardModifiers modifiers)
{
diff --git a/src/gui/statemachine/qmouseeventtransition.cpp b/src/gui/statemachine/qmouseeventtransition.cpp
index 1621c78266..f5df904915 100644
--- a/src/gui/statemachine/qmouseeventtransition.cpp
+++ b/src/gui/statemachine/qmouseeventtransition.cpp
@@ -26,6 +26,7 @@ QT_BEGIN_NAMESPACE
\brief The QMouseEventTransition class provides a transition for mouse events.
+ \since 4.6
\ingroup statemachine
QMouseEventTransition is part of \l{The State Machine Framework}.
@@ -103,7 +104,7 @@ Qt::MouseButton QMouseEventTransition::button() const
}
/*!
- Sets the button that this mouse event transition will check for.
+ Sets the \a button that this mouse event transition will check for.
*/
void QMouseEventTransition::setButton(Qt::MouseButton button)
{
diff --git a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp
index ff5c3b4694..2952a391ef 100644
--- a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp
+++ b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp
@@ -68,6 +68,8 @@ private slots:
void statesAndSignals();
void setParentAutoAdd();
void beginNestedGroup();
+ void addChildTwice();
+ void loopWithoutStartValue();
};
tst_QAnimationGroup::tst_QAnimationGroup()
@@ -207,7 +209,7 @@ void tst_QAnimationGroup::setCurrentTime()
QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
- a2_s_o1->setIterationCount(3);
+ a2_s_o1->setLoopCount(3);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
@@ -224,7 +226,7 @@ void tst_QAnimationGroup::setCurrentTime()
QVariantAnimation *a1_p_o1 = new QPropertyAnimation(&p_o1, "value");
QVariantAnimation *a1_p_o2 = new QPropertyAnimation(&p_o2, "value");
QVariantAnimation *a1_p_o3 = new QPropertyAnimation(&p_o3, "value");
- a1_p_o2->setIterationCount(3);
+ a1_p_o2->setLoopCount(3);
parallel->addAnimation(a1_p_o1);
parallel->addAnimation(a1_p_o2);
parallel->addAnimation(a1_p_o3);
@@ -233,7 +235,7 @@ void tst_QAnimationGroup::setCurrentTime()
QCOMPARE(notTimeDriven->totalDuration(), -1);
QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value");
- loopsForever->setIterationCount(-1);
+ loopsForever->setLoopCount(-1);
QCOMPARE(loopsForever->totalDuration(), -1);
QParallelAnimationGroup group;
@@ -281,11 +283,11 @@ void tst_QAnimationGroup::setCurrentTime()
QCOMPARE(a1_s_o3->currentTime(), 0);
QCOMPARE(a1_p_o1->currentTime(), 250);
QCOMPARE(a1_p_o2->currentTime(), 0);
- QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
QCOMPARE(a1_p_o3->currentTime(), 250);
QCOMPARE(notTimeDriven->currentTime(), 250);
QCOMPARE(loopsForever->currentTime(), 0);
- QCOMPARE(loopsForever->currentIteration(), 1);
+ QCOMPARE(loopsForever->currentLoop(), 1);
QCOMPARE(sequence->currentAnimation(), a2_s_o1);
// Current time = 251
@@ -294,14 +296,14 @@ void tst_QAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 251);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 1);
- QCOMPARE(a2_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
QCOMPARE(a3_s_o1->currentTime(), 0);
QCOMPARE(sequence2->currentTime(), 251);
QCOMPARE(a1_s_o2->currentTime(), 250);
QCOMPARE(a1_s_o3->currentTime(), 1);
QCOMPARE(a1_p_o1->currentTime(), 250);
QCOMPARE(a1_p_o2->currentTime(), 1);
- QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
QCOMPARE(a1_p_o3->currentTime(), 250);
QCOMPARE(notTimeDriven->currentTime(), 251);
QCOMPARE(loopsForever->currentTime(), 1);
@@ -343,5 +345,69 @@ void tst_QAnimationGroup::beginNestedGroup()
}
}
+void tst_QAnimationGroup::addChildTwice()
+{
+ QPropertyAnimation *subGroup;
+ QPropertyAnimation *subGroup2;
+ QAnimationGroup *parent = new QSequentialAnimationGroup();
+
+ subGroup = new QPropertyAnimation();
+ subGroup->setParent(parent);
+ parent->addAnimation(subGroup);
+ QCOMPARE(parent->animationCount(), 1);
+
+ parent->clearAnimations();
+
+ QCOMPARE(parent->animationCount(), 0);
+
+ // adding the same item twice to a group will remove the item from its current position
+ // and append it to the end
+ subGroup = new QPropertyAnimation(parent);
+ subGroup2 = new QPropertyAnimation(parent);
+
+ QCOMPARE(parent->animationCount(), 2);
+ QCOMPARE(parent->animationAt(0), subGroup);
+ QCOMPARE(parent->animationAt(1), subGroup2);
+
+ parent->addAnimation(subGroup);
+
+ QCOMPARE(parent->animationCount(), 2);
+ QCOMPARE(parent->animationAt(0), subGroup2);
+ QCOMPARE(parent->animationAt(1), subGroup);
+
+ delete parent;
+}
+
+void tst_QAnimationGroup::loopWithoutStartValue()
+{
+ QAnimationGroup *parent = new QSequentialAnimationGroup();
+ QObject o;
+ o.setProperty("ole", 0);
+ QCOMPARE(o.property("ole").toInt(), 0);
+
+ QPropertyAnimation anim1(&o, "ole");
+ anim1.setEndValue(-50);
+ anim1.setDuration(100);
+
+ QPropertyAnimation anim2(&o, "ole");
+ anim2.setEndValue(50);
+ anim2.setDuration(100);
+
+ parent->addAnimation(&anim1);
+ parent->addAnimation(&anim2);
+
+ parent->setLoopCount(-1);
+ parent->start();
+
+ QVERIFY(anim1.startValue().isNull());
+ QCOMPARE(anim1.currentValue().toInt(), 0);
+ QCOMPARE(parent->currentLoop(), 0);
+
+ parent->setCurrentTime(200);
+ QCOMPARE(parent->currentLoop(), 1);
+ QCOMPARE(anim1.currentValue().toInt(), 50);
+ parent->stop();
+}
+
QTEST_MAIN(tst_QAnimationGroup)
#include "tst_qanimationgroup.moc"
diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
index c7f33b7101..f2ab57a175 100644
--- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
+++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -71,8 +71,8 @@ private slots:
void startGroupWithRunningChild();
void zeroDurationAnimation();
void stopUncontrolledAnimations();
- void iterationCount_data();
- void iterationCount();
+ void loopCount_data();
+ void loopCount();
void autoAdd();
};
@@ -194,7 +194,7 @@ void tst_QParallelAnimationGroup::setCurrentTime()
QVariantAnimation *a1_p_o1 = new QPropertyAnimation(&p_o1, "value");
QVariantAnimation *a1_p_o2 = new QPropertyAnimation(&p_o2, "value");
QVariantAnimation *a1_p_o3 = new QPropertyAnimation(&p_o3, "value");
- a1_p_o2->setIterationCount(3);
+ a1_p_o2->setLoopCount(3);
parallel->addAnimation(a1_p_o1);
parallel->addAnimation(a1_p_o2);
parallel->addAnimation(a1_p_o3);
@@ -203,7 +203,7 @@ void tst_QParallelAnimationGroup::setCurrentTime()
QCOMPARE(notTimeDriven->totalDuration(), -1);
QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value");
- loopsForever->setIterationCount(-1);
+ loopsForever->setLoopCount(-1);
QCOMPARE(loopsForever->totalDuration(), -1);
QParallelAnimationGroup group;
@@ -233,18 +233,18 @@ void tst_QParallelAnimationGroup::setCurrentTime()
QCOMPARE(group.currentTime(), 250);
QCOMPARE(a1_p_o1->currentTime(), 250);
QCOMPARE(a1_p_o2->currentTime(), 0);
- QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
QCOMPARE(a1_p_o3->currentTime(), 250);
QCOMPARE(notTimeDriven->currentTime(), 250);
QCOMPARE(loopsForever->currentTime(), 0);
- QCOMPARE(loopsForever->currentIteration(), 1);
+ QCOMPARE(loopsForever->currentLoop(), 1);
// Current time = 251
group.setCurrentTime(251);
QCOMPARE(group.currentTime(), 251);
QCOMPARE(a1_p_o1->currentTime(), 250);
QCOMPARE(a1_p_o2->currentTime(), 1);
- QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
QCOMPARE(a1_p_o3->currentTime(), 250);
QCOMPARE(notTimeDriven->currentTime(), 251);
QCOMPARE(loopsForever->currentTime(), 1);
@@ -589,7 +589,7 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation()
group.stop();
- group.setIterationCount(4);
+ group.setLoopCount(4);
stateChangedSpy1.clear();
stateChangedSpy2.clear();
@@ -625,7 +625,7 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations()
loopsForever.setStartValue(0);
loopsForever.setEndValue(100);
loopsForever.setDuration(100);
- loopsForever.setIterationCount(-1);
+ loopsForever.setLoopCount(-1);
QSignalSpy stateChangedSpy(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
@@ -670,10 +670,10 @@ struct AnimState {
#define Stopped QAbstractAnimation::Stopped
Q_DECLARE_METATYPE(AnimState)
-void tst_QParallelAnimationGroup::iterationCount_data()
+void tst_QParallelAnimationGroup::loopCount_data()
{
QTest::addColumn<bool>("directionBackward");
- QTest::addColumn<int>("setIterationCount");
+ QTest::addColumn<int>("setLoopCount");
QTest::addColumn<int>("initialGroupTime");
QTest::addColumn<int>("currentGroupTime");
QTest::addColumn<AnimState>("expected1");
@@ -742,10 +742,10 @@ void tst_QParallelAnimationGroup::iterationCount_data()
}
-void tst_QParallelAnimationGroup::iterationCount()
+void tst_QParallelAnimationGroup::loopCount()
{
QFETCH(bool, directionBackward);
- QFETCH(int, setIterationCount);
+ QFETCH(int, setLoopCount);
QFETCH(int, initialGroupTime);
QFETCH(int, currentGroupTime);
QFETCH(AnimState, expected1);
@@ -763,7 +763,7 @@ void tst_QParallelAnimationGroup::iterationCount()
anim2.setStartValue(0);
anim2.setEndValue(100);
anim2.setDuration(60); //total 120
- anim2.setIterationCount(2);
+ anim2.setLoopCount(2);
TestAnimation anim3;
anim3.setStartValue(0);
@@ -774,7 +774,7 @@ void tst_QParallelAnimationGroup::iterationCount()
group.addAnimation(&anim2);
group.addAnimation(&anim3);
- group.setIterationCount(setIterationCount);
+ group.setLoopCount(setLoopCount);
if (initialGroupTime >= 0)
group.setCurrentTime(initialGroupTime);
if (directionBackward)
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index f61df495d2..437c86213e 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -42,7 +42,6 @@
#include <QtTest/QtTest>
#include <QtCore/qpropertyanimation.h>
-#include <QtGui/qitemanimation.h>
#include <QtGui/qwidget.h>
//TESTED_CLASS=QPropertyAnimation
@@ -144,7 +143,7 @@ void tst_QPropertyAnimation::construction()
void tst_QPropertyAnimation::setCurrentTime_data()
{
QTest::addColumn<int>("duration");
- QTest::addColumn<int>("iterationCount");
+ QTest::addColumn<int>("loopCount");
QTest::addColumn<int>("currentTime");
QTest::addColumn<int>("testCurrentTime");
QTest::addColumn<int>("testCurrentLoop");
@@ -177,7 +176,7 @@ void tst_QPropertyAnimation::setCurrentTime_data()
void tst_QPropertyAnimation::setCurrentTime()
{
QFETCH(int, duration);
- QFETCH(int, iterationCount);
+ QFETCH(int, loopCount);
QFETCH(int, currentTime);
QFETCH(int, testCurrentTime);
QFETCH(int, testCurrentLoop);
@@ -186,11 +185,11 @@ void tst_QPropertyAnimation::setCurrentTime()
if (duration < 0)
QTest::ignoreMessage(QtWarningMsg, "QVariantAnimation::setDuration: cannot set a negative duration");
animation.setDuration(duration);
- animation.setIterationCount(iterationCount);
+ animation.setLoopCount(loopCount);
animation.setCurrentTime(currentTime);
QCOMPARE(animation.currentTime(), testCurrentTime);
- QCOMPARE(animation.currentIteration(), testCurrentLoop);
+ QCOMPARE(animation.currentLoop(), testCurrentLoop);
}
void tst_QPropertyAnimation::statesAndSignals_data()
@@ -208,7 +207,7 @@ void tst_QPropertyAnimation::statesAndSignals()
QSignalSpy finishedSpy(anim, SIGNAL(finished()));
QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
- QSignalSpy currentLoopSpy(anim, SIGNAL(currentIterationChanged(int)));
+ QSignalSpy currentLoopSpy(anim, SIGNAL(currentLoopChanged(int)));
anim->setCurrentTime(1);
anim->setCurrentTime(100);
@@ -217,23 +216,23 @@ void tst_QPropertyAnimation::statesAndSignals()
QCOMPARE(currentLoopSpy.count(), 0);
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
- anim->setIterationCount(3);
+ anim->setLoopCount(3);
anim->setCurrentTime(101);
if (uncontrolled)
QSKIP("Uncontrolled animations don't handle looping", SkipSingle);
QCOMPARE(currentLoopSpy.count(), 1);
- QCOMPARE(anim->currentIteration(), 1);
+ QCOMPARE(anim->currentLoop(), 1);
anim->setCurrentTime(0);
QCOMPARE(currentLoopSpy.count(), 2);
- QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(anim->currentLoop(), 0);
anim->start();
QCOMPARE(anim->state(), QAnimationGroup::Running);
QCOMPARE(runningSpy.count(), 1); //anim must have started
- QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(anim->currentLoop(), 0);
runningSpy.clear();
anim->stop();
@@ -241,7 +240,7 @@ void tst_QPropertyAnimation::statesAndSignals()
QCOMPARE(runningSpy.count(), 1); //anim must have stopped
QCOMPARE(finishedSpy.count(), 0);
QCOMPARE(anim->currentTime(), 0);
- QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(anim->currentLoop(), 0);
QCOMPARE(currentLoopSpy.count(), 2);
runningSpy.clear();
@@ -252,24 +251,24 @@ void tst_QPropertyAnimation::statesAndSignals()
runningSpy.clear();
QCOMPARE(finishedSpy.count(), 1);
QCOMPARE(anim->currentTime(), 100);
- QCOMPARE(anim->currentIteration(), 2);
+ QCOMPARE(anim->currentLoop(), 2);
QCOMPARE(currentLoopSpy.count(), 4);
anim->start(); // auto-rewinds
QCOMPARE(anim->state(), QAnimationGroup::Running);
QCOMPARE(anim->currentTime(), 0);
- QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(anim->currentLoop(), 0);
QCOMPARE(currentLoopSpy.count(), 5);
QCOMPARE(runningSpy.count(), 1); // anim has started
QCOMPARE(finishedSpy.count(), 1);
- QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(anim->currentLoop(), 0);
runningSpy.clear();
QTest::qWait(1000);
QCOMPARE(currentLoopSpy.count(), 7);
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
- QCOMPARE(anim->currentIteration(), 2);
+ QCOMPARE(anim->currentLoop(), 2);
QCOMPARE(runningSpy.count(), 1); // anim has stopped
QCOMPARE(finishedSpy.count(), 2);
QCOMPARE(anim->currentTime(), 100);
@@ -340,7 +339,7 @@ void tst_QPropertyAnimation::deletion2()
QCOMPARE(runningSpy.count(), 1);
QCOMPARE(finishedSpy.count(), 0);
- //we can't call deletaLater directly because the delete would only happen in the next iteration of _this_ event loop
+ //we can't call deletaLater directly because the delete would only happen in the next loop of _this_ event loop
QTimer::singleShot(0, object, SLOT(deleteLater()));
QTest::qWait(50);
@@ -526,13 +525,14 @@ void tst_QPropertyAnimation::startWithoutStartValue()
anim.setEndValue(110);
anim.start();
current = anim.currentValue().toInt();
- QCOMPARE(current, 42); // the initial default start value
-
+ // the default start value will reevaluate the current property
+ // and set it to the end value of the last iteration
+ QCOMPARE(current, 100);
QTest::qWait(100);
current = anim.currentValue().toInt();
//it is somewhere in the animation
- QVERIFY(current > 42);
- QVERIFY(current < 110);
+ QVERIFY(current >= 100);
+ QVERIFY(current <= 110);
}
void tst_QPropertyAnimation::playForwardBackward()
diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index 18b57b2524..0631343ce9 100644
--- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -173,7 +173,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
- a2_s_o1->setIterationCount(3);
+ a2_s_o1->setLoopCount(3);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
@@ -221,7 +221,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 251);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 1);
- QCOMPARE(a2_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
QCOMPARE(a3_s_o1->currentTime(), 0);
QCOMPARE(sequence2->currentTime(), 0);
QCOMPARE(a1_s_o2->currentTime(), 0);
@@ -233,7 +233,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 750);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 0);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 0);
QCOMPARE(sequence2->currentTime(), 0);
QCOMPARE(a1_s_o2->currentTime(), 0);
@@ -245,7 +245,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1000);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 0);
QCOMPARE(sequence2->currentTime(), 0);
QCOMPARE(a1_s_o2->currentTime(), 0);
@@ -257,7 +257,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1010);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 10);
QCOMPARE(sequence2->currentTime(), 0);
QCOMPARE(a1_s_o2->currentTime(), 0);
@@ -269,7 +269,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 0);
QCOMPARE(a1_s_o2->currentTime(), 0);
@@ -281,7 +281,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 250);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -293,7 +293,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 500);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -305,7 +305,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 500);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -330,7 +330,7 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation()
QCOMPARE(notTimeDriven->totalDuration(), -1);
QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value");
- loopsForever->setIterationCount(-1);
+ loopsForever->setLoopCount(-1);
QCOMPARE(loopsForever->totalDuration(), -1);
QSequentialAnimationGroup group;
@@ -436,7 +436,7 @@ void tst_QSequentialAnimationGroup::seekingForwards()
QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
- a2_s_o1->setIterationCount(3);
+ a2_s_o1->setLoopCount(3);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
@@ -476,7 +476,7 @@ void tst_QSequentialAnimationGroup::seekingForwards()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 250);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -498,7 +498,7 @@ void tst_QSequentialAnimationGroup::seekingForwards()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 500);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -516,7 +516,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
- a2_s_o1->setIterationCount(3);
+ a2_s_o1->setLoopCount(3);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
@@ -540,7 +540,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 350);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -564,7 +564,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
QCOMPARE(a2_s_o1->currentTime(), 0);
QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
"hence they don't reset from their current animation", Continue);
- QCOMPARE(a2_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
"hence they don't reset from their current animation", Continue);
QCOMPARE(a3_s_o1->currentTime(), 0);
@@ -585,7 +585,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 500);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -656,11 +656,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
- a2_s_o1->setIterationCount(2);
+ a2_s_o1->setLoopCount(2);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
- sequence->setIterationCount(2);
+ sequence->setLoopCount(2);
QSignalSpy a1StateChangedSpy(a1_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
QSignalSpy seqStateChangedSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
@@ -675,11 +675,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
group.setCurrentTime(1751);
QCOMPARE(group.currentTime(), 1751);
QCOMPARE(sequence->currentTime(), 751);
- QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(sequence->currentLoop(), 1);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 1);
- QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
QCOMPARE(a3_s_o1->currentTime(), 1);
QCOMPARE(group.state(), QAnimationGroup::Paused);
@@ -723,11 +723,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QVERIFY(group.currentTime() >= 1751);
QVERIFY(sequence->currentTime() >= 751);
- QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(sequence->currentLoop(), 1);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 1);
- QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
QVERIFY(a3_s_o1->currentTime() >= 1);
QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running
@@ -744,11 +744,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QVERIFY(group.currentTime() >= 1751);
QVERIFY(sequence->currentTime() >= 751);
- QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(sequence->currentLoop(), 1);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 1);
- QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
QVERIFY(a3_s_o1->currentTime() >= 1);
QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused
@@ -780,11 +780,11 @@ void tst_QSequentialAnimationGroup::restart()
animsStateChanged[i] = new QSignalSpy(anims[i], SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
}
- anims[1]->setIterationCount(2);
+ anims[1]->setLoopCount(2);
sequence->addAnimation(anims[0]);
sequence->addAnimation(anims[1]);
sequence->addAnimation(anims[2]);
- sequence->setIterationCount(2);
+ sequence->setLoopCount(2);
QSequentialAnimationGroup group;
group.addAnimation(sequence);
@@ -845,17 +845,17 @@ void tst_QSequentialAnimationGroup::looping()
QSignalSpy a3Spy(a3_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
QSignalSpy seqSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
- a2_s_o1->setIterationCount(2);
+ a2_s_o1->setLoopCount(2);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
- sequence->setIterationCount(2);
+ sequence->setLoopCount(2);
QSequentialAnimationGroup group;
QSignalSpy groupSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
group.addAnimation(sequence);
- group.setIterationCount(2);
+ group.setLoopCount(2);
group.start();
group.pause();
@@ -864,12 +864,12 @@ void tst_QSequentialAnimationGroup::looping()
group.setCurrentTime(1750);
QCOMPARE(group.currentTime(), 1750);
QCOMPARE(sequence->currentTime(), 750);
- QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(sequence->currentLoop(), 1);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 1);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
// this animation is at the beginning because it is the current one inside sequence
- QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
QCOMPARE(a3_s_o1->currentTime(), 0);
QCOMPARE(sequence->currentAnimation(), a3_s_o1);
@@ -898,14 +898,14 @@ void tst_QSequentialAnimationGroup::looping()
// Looping, current time = duration + 1
group.setCurrentTime(group.duration() + 1);
QCOMPARE(group.currentTime(), 1);
- QCOMPARE(group.currentIteration(), 1);
+ QCOMPARE(group.currentLoop(), 1);
QCOMPARE(sequence->currentTime(), 1);
- QCOMPARE(sequence->currentIteration(), 0);
+ QCOMPARE(sequence->currentLoop(), 0);
QCOMPARE(a1_s_o1->currentTime(), 1);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 1);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
// this animation is at the end because it was run on the previous loop
- QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(group.state(), QAnimationGroup::Paused);
@@ -1367,7 +1367,7 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation()
group.addAnimation(anim1);
group.addAnimation(anim2);
group.addAnimation(anim3);
- group.setIterationCount(2);
+ group.setLoopCount(2);
group.start();
QCOMPARE(stateChangedSpy.count(), 2);
@@ -1401,7 +1401,7 @@ void tst_QSequentialAnimationGroup::stopUncontrolledAnimations()
loopsForever.setStartValue(0);
loopsForever.setEndValue(100);
loopsForever.setDuration(100);
- loopsForever.setIterationCount(-1);
+ loopsForever.setLoopCount(-1);
group.addAnimation(&notTimeDriven);
group.addAnimation(&loopsForever);
@@ -1592,11 +1592,11 @@ void tst_QSequentialAnimationGroup::currentAnimationWithZeroDuration()
void tst_QSequentialAnimationGroup::insertAnimation()
{
QSequentialAnimationGroup group;
- group.setIterationCount(2);
+ group.setLoopCount(2);
QPropertyAnimation *anim = new QPropertyAnimation(&group);
QCOMPARE(group.duration(), anim->duration());
group.setCurrentTime(300);
- QCOMPARE(group.currentIteration(), 1);
+ QCOMPARE(group.currentLoop(), 1);
//this will crash if the sequential group calls duration on the created animation
new QPropertyAnimation(&group);
diff --git a/tests/auto/qstate/tst_qstate.cpp b/tests/auto/qstate/tst_qstate.cpp
index c4a0050416..f28c3fae8c 100644
--- a/tests/auto/qstate/tst_qstate.cpp
+++ b/tests/auto/qstate/tst_qstate.cpp
@@ -42,15 +42,16 @@ private slots:
#if 0
void test();
#endif
- void setPropertyOnEntry();
- void setPropertyOnEntryTwice();
- void setPropertyOnExit();
- void setPropertyOnExitTwice();
+ void assignProperty();
+ void assignPropertyTwice();
void historyInitialState();
void addEntryAction();
+
+private:
+ bool functionCalled;
};
-tst_QState::tst_QState()
+tst_QState::tst_QState() : functionCalled(false)
{
}
@@ -200,20 +201,36 @@ void tst_QState::test()
}
#endif
+class TestClass: public QObject
+{
+ Q_OBJECT
+public:
+ TestClass() : called(false) {}
+ bool called;
+
+public slots:
+ void slot() { called = true; }
+
+
+};
+
void tst_QState::addEntryAction()
{
QStateMachine sm;
+
+ TestClass testObject;
+
QState *s0 = new QState(sm.rootState());
- s0->addEntryAction(new QStateSetPropertyAction(this, "objectName", "commandTest"));
+ s0->addEntryAction(new QStateInvokeMethodAction(&testObject, "slot"));
sm.setInitialState(s0);
sm.start();
QCoreApplication::processEvents();
- QCOMPARE(this->objectName(), QString::fromLatin1("commandTest"));
+ QCOMPARE(testObject.called, true);
}
-void tst_QState::setPropertyOnEntry()
+void tst_QState::assignProperty()
{
QStateMachine machine;
@@ -221,7 +238,7 @@ void tst_QState::setPropertyOnEntry()
object->setProperty("fooBar", 10);
QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnEntry(object, "fooBar", 20);
+ s1->assignProperty(object, "fooBar", 20);
machine.setInitialState(s1);
machine.start();
@@ -230,7 +247,7 @@ void tst_QState::setPropertyOnEntry()
QCOMPARE(object->property("fooBar").toInt(), 20);
}
-void tst_QState::setPropertyOnEntryTwice()
+void tst_QState::assignPropertyTwice()
{
QStateMachine machine;
@@ -238,8 +255,8 @@ void tst_QState::setPropertyOnEntryTwice()
object->setProperty("fooBar", 10);
QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnEntry(object, "fooBar", 20);
- s1->setPropertyOnEntry(object, "fooBar", 30);
+ s1->assignProperty(object, "fooBar", 20);
+ s1->assignProperty(object, "fooBar", 30);
machine.setInitialState(s1);
machine.start();
@@ -248,56 +265,24 @@ void tst_QState::setPropertyOnEntryTwice()
QCOMPARE(object->property("fooBar").toInt(), 30);
}
-void tst_QState::setPropertyOnExit()
-{
- QStateMachine machine;
-
- QObject *object = new QObject();
- object->setProperty("fooBar", 10);
-
- QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnExit(object, "fooBar", 20);
-
- QState *s2 = new QState(machine.rootState());
- s1->addTransition(new QTransition(QEvent::User), s2);
-
- machine.setInitialState(s1);
- machine.start();
- QCoreApplication::processEvents();
-
- QCOMPARE(object->property("fooBar").toInt(), 10);
-
- machine.postEvent(new QEvent(QEvent::User));
- QCoreApplication::processEvents();
-
- QCOMPARE(object->property("fooBar").toInt(), 20);
-}
-
-void tst_QState::setPropertyOnExitTwice()
+class EventTestTransition: public QTransition
{
- QStateMachine machine;
-
- QObject *object = new QObject();
- object->setProperty("fooBar", 10);
-
- QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnExit(object, "fooBar", 20);
- s1->setPropertyOnExit(object, "fooBar", 30);
-
- QState *s2 = new QState(machine.rootState());
- s1->addTransition(new QTransition(QEvent::User), s2);
+public:
+ EventTestTransition(QEvent::Type type, QState *targetState)
+ : QTransition(QList<QAbstractState*>() << targetState), m_type(type)
+ {
+ }
+
+protected:
+ bool eventTest(QEvent *e) const
+ {
+ return e->type() == m_type;
+ }
+
+private:
+ QEvent::Type m_type;
- machine.setInitialState(s1);
- machine.start();
- QCoreApplication::processEvents();
-
- QCOMPARE(object->property("fooBar").toInt(), 10);
-
- machine.postEvent(new QEvent(QEvent::User));
- QCoreApplication::processEvents();
-
- QCOMPARE(object->property("fooBar").toInt(), 30);
-}
+};
void tst_QState::historyInitialState()
{
@@ -315,9 +300,9 @@ void tst_QState::historyInitialState()
QState *s4 = new QState(s2);
- s1->addTransition(new QTransition(QEvent::User), s2);
- s2->addTransition(new QTransition(QEvent::User), s1);
- s3->addTransition(new QTransition(QEvent::Type(QEvent::User+1)), s4);
+ s1->addTransition(new EventTestTransition(QEvent::User, s2));
+ s2->addTransition(new EventTestTransition(QEvent::User, s1));
+ s3->addTransition(new EventTestTransition(QEvent::Type(QEvent::User+1), s4));
machine.setInitialState(s1);
machine.start();
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 729581e5ff..085d16b2b5 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -3,6 +3,40 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
****************************************************************************/
#include <QtTest/QtTest>
@@ -11,7 +45,7 @@
#include "qstatemachine.h"
#include "qstate.h"
-#include "qtransition.h"
+#include "qactiontransition.h"
#include "qhistorystate.h"
#include "qkeyeventtransition.h"
#include "qmouseeventtransition.h"
@@ -87,7 +121,6 @@ private slots:
void setRestorePolicyToDoNotRestore();
void setGlobalRestorePolicyToGlobalRestore();
void restorePolicyOnChildState();
- void addAnimatedTransition();
void transitionWithParent();
};
@@ -161,11 +194,11 @@ void tst_QStateMachine::cleanup()
qInstallMsgHandler(s_oldHandler);
}
-class EventTransition : public QTransition
+class EventTransition : public QActionTransition
{
public:
EventTransition(QEvent::Type type, QAbstractState *target, QState *parent = 0)
- : QTransition(QList<QAbstractState*>() << target, parent), m_type(type) {}
+ : QActionTransition(QList<QAbstractState*>() << target, parent), m_type(type) {}
protected:
virtual bool eventTest(QEvent *e) const {
return (e->type() == m_type);
@@ -212,21 +245,21 @@ void tst_QStateMachine::transitionEntersParent()
QState *greatGrandParent = new QState();
greatGrandParent->setObjectName("grandParent");
- greatGrandParent->setPropertyOnEntry(entryController, "greatGrandParentEntered", true);
+ greatGrandParent->assignProperty(entryController, "greatGrandParentEntered", true);
machine.addState(greatGrandParent);
machine.setInitialState(greatGrandParent);
QState *grandParent = new QState(greatGrandParent);
grandParent->setObjectName("grandParent");
- grandParent->setPropertyOnEntry(entryController, "grandParentEntered", true);
+ grandParent->assignProperty(entryController, "grandParentEntered", true);
QState *parent = new QState(grandParent);
parent->setObjectName("parent");
- parent->setPropertyOnEntry(entryController, "parentEntered", true);
+ parent->assignProperty(entryController, "parentEntered", true);
QState *state = new QState(parent);
state->setObjectName("state");
- state->setPropertyOnEntry(entryController, "stateEntered", true);
+ state->assignProperty(entryController, "stateEntered", true);
QState *initialStateOfGreatGrandParent = new QState(greatGrandParent);
initialStateOfGreatGrandParent->setObjectName("initialStateOfGreatGrandParent");
@@ -633,21 +666,21 @@ void tst_QStateMachine::errorStateEntersParentFirst()
QState *greatGrandParent = new QState();
greatGrandParent->setObjectName("greatGrandParent");
- greatGrandParent->setPropertyOnEntry(entryController, "greatGrandParentEntered", true);
+ greatGrandParent->assignProperty(entryController, "greatGrandParentEntered", true);
machine.addState(greatGrandParent);
machine.setInitialState(greatGrandParent);
QState *grandParent = new QState(greatGrandParent);
grandParent->setObjectName("grandParent");
- grandParent->setPropertyOnEntry(entryController, "grandParentEntered", true);
+ grandParent->assignProperty(entryController, "grandParentEntered", true);
QState *parent = new QState(grandParent);
parent->setObjectName("parent");
- parent->setPropertyOnEntry(entryController, "parentEntered", true);
+ parent->assignProperty(entryController, "parentEntered", true);
QState *errorState = new QState(parent);
errorState->setObjectName("errorState");
- errorState->setPropertyOnEntry(entryController, "errorStateEntered", true);
+ errorState->assignProperty(entryController, "errorStateEntered", true);
machine.setErrorState(errorState);
QState *initialStateOfGreatGrandParent = new QState(greatGrandParent);
@@ -785,15 +818,15 @@ void tst_QStateMachine::brokenStateIsNeverEntered()
machine.setInitialState(initialState);
QState *errorState = new QState(machine.rootState());
- errorState->setPropertyOnEntry(entryController, "errorStateEntered", true);
+ errorState->assignProperty(entryController, "errorStateEntered", true);
machine.setErrorState(errorState);
QState *brokenState = new QState(machine.rootState());
- brokenState->setPropertyOnEntry(entryController, "brokenStateEntered", true);
+ brokenState->assignProperty(entryController, "brokenStateEntered", true);
brokenState->setObjectName("brokenState");
QState *childState = new QState(brokenState);
- childState->setPropertyOnEntry(entryController, "childStateEntered", true);
+ childState->assignProperty(entryController, "childStateEntered", true);
initialState->addTransition(new EventTransition(QEvent::User, brokenState));
@@ -863,13 +896,13 @@ void tst_QStateMachine::restoreProperties()
QState *S1 = new QState();
S1->setObjectName("S1");
- S1->setPropertyOnEntry(object, "a", 3);
+ S1->assignProperty(object, "a", 3);
S1->setRestorePolicy(QState::RestoreProperties);
machine.addState(S1);
QState *S2 = new QState();
S2->setObjectName("S2");
- S2->setPropertyOnEntry(object, "b", 5);
+ S2->assignProperty(object, "b", 5);
S2->setRestorePolicy(QState::RestoreProperties);
machine.addState(S2);
@@ -1584,30 +1617,6 @@ private:
void tst_QStateMachine::stateActions()
{
- {
- QStateSetPropertyAction act;
- QCOMPARE(act.targetObject(), (QObject*)0);
- QCOMPARE(act.propertyName().length(), 0);
- QCOMPARE(act.value(), QVariant());
-
- act.setTargetObject(this);
- QCOMPARE(act.targetObject(), (QObject*)this);
- QByteArray name("foo");
- act.setPropertyName(name);
- QCOMPARE(act.propertyName(), name);
- QVariant value(123);
- act.setValue(value);
- QCOMPARE(act.value(), value);
- }
- {
- QByteArray name("foo");
- QVariant value(123);
- QStateSetPropertyAction act(this, name, value);
- QCOMPARE(act.targetObject(), (QObject*)this);
- QCOMPARE(act.propertyName(), name);
- QCOMPARE(act.value(), value);
- }
-
QStateMachine machine;
QState *s1 = new QState(machine.rootState());
@@ -1623,47 +1632,15 @@ void tst_QStateMachine::stateActions()
QTest::ignoreMessage(QtWarningMsg, "QActionState::removeExitAction: cannot remove null action");
s1->removeExitAction(0);
- QStateSetPropertyAction *spa = new QStateSetPropertyAction(s1, "objectName", "foo");
- s1->addEntryAction(spa);
- QCOMPARE(s1->entryActions().size(), 1);
- QCOMPARE(s1->entryActions().at(0), (QStateAction*)spa);
- QCOMPARE(spa->parent(), (QObject*)s1);
- QVERIFY(s1->exitActions().isEmpty());
-
- s1->addEntryAction(spa); // add again
- QCOMPARE(s1->entryActions().size(), 1);
-
QFinalState *s2 = new QFinalState(machine.rootState());
s1->addTransition(s2);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
- machine.start();
- QTRY_COMPARE(finishedSpy.count(), 1);
- QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
-
- s1->removeEntryAction(spa);
- QCOMPARE(spa->parent(), (QObject*)0);
- QVERIFY(s1->entryActions().isEmpty());
-
- s1->removeEntryAction(spa); // remove again
-
- s1->setObjectName(QString::fromLatin1("bar"));
- finishedSpy.clear();
- machine.start();
- QTRY_COMPARE(finishedSpy.count(), 1);
- QCOMPARE(s1->objectName(), QString::fromLatin1("bar"));
- s1->addEntryAction(spa);
- finishedSpy.clear();
- machine.start();
- QTRY_COMPARE(finishedSpy.count(), 1);
- QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
-
- s1->removeEntryAction(spa);
- QVERIFY(s1->entryActions().isEmpty());
- QStateInvokeMethodAction *ima = new QStateInvokeMethodAction(spa, "deleteLater");
- QPointer<QStateAction> ptr(spa);
+ QObject *obj = new QObject();
+ QStateInvokeMethodAction *ima = new QStateInvokeMethodAction(obj, "deleteLater");
+ QPointer<QObject> ptr(obj);
QVERIFY(ptr != 0);
s1->addEntryAction(ima);
finishedSpy.clear();
@@ -1674,13 +1651,8 @@ void tst_QStateMachine::stateActions()
s1->removeEntryAction(ima);
- s1->setPropertyOnEntry(s1, "objectName", "bar");
- QCOMPARE(s1->entryActions().size(), 1);
- s1->setPropertyOnEntry(s1, "objectName", "bar");
- QCOMPARE(s1->entryActions().size(), 1);
-
s1->invokeMethodOnEntry(ima, "deleteLater");
- QCOMPARE(s1->entryActions().size(), 2);
+ QCOMPARE(s1->entryActions().size(), 1);
ptr = ima;
QVERIFY(ptr != 0);
@@ -1730,10 +1702,10 @@ void tst_QStateMachine::transitionActions()
QState *s1 = new QState(machine.rootState());
QFinalState *s2 = new QFinalState(machine.rootState());
- QTransition *trans = new EventTransition(QEvent::User, s2);
+ EventTransition *trans = new EventTransition(QEvent::User, s2);
s1->addTransition(trans);
QVERIFY(trans->actions().isEmpty());
- QTest::ignoreMessage(QtWarningMsg, "QTransition::addAction: cannot add null action");
+ QTest::ignoreMessage(QtWarningMsg, "QActionTransition::addAction: cannot add null action");
trans->addAction(0);
QVERIFY(trans->actions().isEmpty());
@@ -1760,7 +1732,6 @@ void tst_QStateMachine::transitionActions()
QTRY_COMPARE(finishedSpy.count(), 1);
QVERIFY(act->didExecute());
- trans->setPropertyOnTransition(s1, "objectName", "foo");
trans->invokeMethodOnTransition(act, "deleteLater");
QPointer<QStateAction> ptr(act);
@@ -1774,7 +1745,6 @@ void tst_QStateMachine::transitionActions()
QTRY_COMPARE(finishedSpy.count(), 1);
QCoreApplication::processEvents();
QVERIFY(ptr == 0);
- QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
}
void tst_QStateMachine::defaultGlobalRestorePolicy()
@@ -1786,10 +1756,10 @@ void tst_QStateMachine::defaultGlobalRestorePolicy()
propertyHolder->setProperty("b", 2);
QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
QState *s2 = new QState(machine.rootState());
- s2->setPropertyOnEntry(propertyHolder, "b", 4);
+ s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(machine.rootState());
@@ -1830,12 +1800,12 @@ void tst_QStateMachine::restorePolicyNotInherited()
QState *s1 = new QState(parentState);
s1->setObjectName("s1");
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
parentState->setInitialState(s1);
QState *s2 = new QState(parentState);
s2->setObjectName("s2");
- s2->setPropertyOnEntry(propertyHolder, "b", 4);
+ s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(parentState);
s3->setObjectName("s3");
@@ -1874,10 +1844,10 @@ void tst_QStateMachine::globalRestorePolicySetToDoNotRestore()
propertyHolder->setProperty("b", 2);
QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
QState *s2 = new QState(machine.rootState());
- s2->setPropertyOnEntry(propertyHolder, "b", 4);
+ s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(machine.rootState());
@@ -1914,13 +1884,13 @@ void tst_QStateMachine::setRestorePolicyToDoNotRestore()
QState *S1 = new QState();
S1->setObjectName("S1");
- S1->setPropertyOnEntry(object, "a", 3);
+ S1->assignProperty(object, "a", 3);
S1->setRestorePolicy(QState::DoNotRestoreProperties);
machine.addState(S1);
QState *S2 = new QState();
S2->setObjectName("S2");
- S2->setPropertyOnEntry(object, "b", 5);
+ S2->assignProperty(object, "b", 5);
S2->setRestorePolicy(QState::DoNotRestoreProperties);
machine.addState(S2);
@@ -1987,13 +1957,13 @@ void tst_QStateMachine::restorePolicyOnChildState()
QState *s1 = new QState(parentState);
s1->setRestorePolicy(QState::RestoreProperties);
s1->setObjectName("s1");
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
parentState->setInitialState(s1);
QState *s2 = new QState(parentState);
s2->setRestorePolicy(QState::RestoreProperties);
s2->setObjectName("s2");
- s2->setPropertyOnEntry(propertyHolder, "b", 4);
+ s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(parentState);
s3->setRestorePolicy(QState::RestoreProperties);
@@ -2032,10 +2002,10 @@ void tst_QStateMachine::globalRestorePolicySetToRestore()
propertyHolder->setProperty("b", 2);
QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
QState *s2 = new QState(machine.rootState());
- s2->setPropertyOnEntry(propertyHolder, "b", 4);
+ s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(machine.rootState());
@@ -2071,19 +2041,19 @@ void tst_QStateMachine::mixedRestoreProperties()
QState *s1 = new QState(machine.rootState());
s1->setRestorePolicy(QState::RestoreProperties);
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
QState *s2 = new QState(machine.rootState());
- s2->setPropertyOnEntry(propertyHolder, "a", 4);
+ s2->assignProperty(propertyHolder, "a", 4);
QState *s3 = new QState(machine.rootState());
QState *s4 = new QState(machine.rootState());
- s4->setPropertyOnEntry(propertyHolder, "a", 5);
+ s4->assignProperty(propertyHolder, "a", 5);
QState *s5 = new QState(machine.rootState());
s5->setRestorePolicy(QState::RestoreProperties);
- s5->setPropertyOnEntry(propertyHolder, "a", 6);
+ s5->assignProperty(propertyHolder, "a", 6);
s1->addTransition(new EventTransition(QEvent::User, s2));
s2->addTransition(new EventTransition(QEvent::User, s3));
@@ -2129,38 +2099,6 @@ void tst_QStateMachine::mixedRestoreProperties()
QCOMPARE(propertyHolder->property("a").toInt(), 5);
}
-void tst_QStateMachine::addAnimatedTransition()
-{
- {
- QStateMachine machine;
- QState *s1 = new QState(machine.rootState());
- QState *s2 = new QState(machine.rootState());
- SignalEmitter emitter;
- QState *as = s1->addAnimatedTransition(&emitter, SIGNAL(signalWithNoArg()), s2);
- QVERIFY(as != 0);
- QCOMPARE(as->parentState(), s2->parentState());
- }
- {
- QStateMachine machine;
- QState *s1 = new QState(machine.rootState());
- QState *s2 = new QState(machine.rootState());
- QState *s21 = new QState(s2);
- SignalEmitter emitter;
- QState *as = s1->addAnimatedTransition(&emitter, SIGNAL(signalWithNoArg()), s21);
- QVERIFY(as != 0);
- QCOMPARE(as->parentState(), s2);
- }
- {
- QStateMachine machine;
- QState *s1 = new QState();
- QState *s2 = new QState();
- SignalEmitter emitter;
- QTest::ignoreMessage(QtWarningMsg, "QState::addAnimatedTransition: cannot add transition to target that doesn't have a parent state");
- QState *as = s1->addAnimatedTransition(&emitter, SIGNAL(signalWithNoArg()), s2);
- QCOMPARE(as, (QState*)0);
- }
-}
-
void tst_QStateMachine::transitionWithParent()
{
QStateMachine machine;