summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/snapshot4
-rw-r--r--examples/animation/animatedtiles/main.cpp29
-rw-r--r--examples/animation/appchooser/main.cpp23
-rw-r--r--examples/animation/example/mainwindow.cpp70
-rw-r--r--examples/animation/moveblocks/main.cpp15
-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/graphicsscene.cpp19
-rw-r--r--examples/animation/sub-attaq/qanimationstate.cpp175
-rw-r--r--examples/animation/sub-attaq/qanimationstate.h92
-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.cpp34
-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.cpp34
-rw-r--r--examples/statemachine/trafficlight/main.cpp42
-rw-r--r--examples/statemachine/twowaybutton/main.cpp38
-rw-r--r--src/corelib/statemachine/qabstractstate.cpp114
-rw-r--r--src/corelib/statemachine/qabstractstate.h48
-rw-r--r--src/corelib/statemachine/qabstractstate_p.h49
-rw-r--r--src/corelib/statemachine/qabstracttransition.cpp84
-rw-r--r--src/corelib/statemachine/qabstracttransition.h46
-rw-r--r--src/corelib/statemachine/qabstracttransition_p.h38
-rw-r--r--src/corelib/statemachine/qactionstate.cpp159
-rw-r--r--src/corelib/statemachine/qactionstate.h47
-rw-r--r--src/corelib/statemachine/qactionstate_p.h36
-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.cpp46
-rw-r--r--src/corelib/statemachine/qeventtransition.h37
-rw-r--r--src/corelib/statemachine/qeventtransition_p.h34
-rw-r--r--src/corelib/statemachine/qfinalstate.cpp34
-rw-r--r--src/corelib/statemachine/qfinalstate.h34
-rw-r--r--src/corelib/statemachine/qhistorystate.cpp34
-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.cpp41
-rw-r--r--src/corelib/statemachine/qsignaltransition.h35
-rw-r--r--src/corelib/statemachine/qsignaltransition_p.h34
-rw-r--r--src/corelib/statemachine/qstate.cpp145
-rw-r--r--src/corelib/statemachine/qstate.h54
-rw-r--r--src/corelib/statemachine/qstate_p.h34
-rw-r--r--src/corelib/statemachine/qstateaction.cpp179
-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.cpp41
-rw-r--r--src/corelib/statemachine/qstatefinishedtransition.h35
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp396
-rw-r--r--src/corelib/statemachine/qstatemachine.h47
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h69
-rw-r--r--src/corelib/statemachine/qtransition.cpp65
-rw-r--r--src/corelib/statemachine/qtransition.h36
-rw-r--r--src/corelib/statemachine/qtransition_p.h34
-rw-r--r--src/corelib/statemachine/statemachine.pri5
-rw-r--r--src/gui/statemachine/qguistatemachine.cpp74
-rw-r--r--src/gui/statemachine/qkeyeventtransition.cpp3
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp138
93 files changed, 2964 insertions, 1744 deletions
diff --git a/bin/snapshot b/bin/snapshot
index 8cf3be2..ffad857 100644
--- a/bin/snapshot
+++ b/bin/snapshot
@@ -49,8 +49,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",
@@ -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,7 +260,6 @@ 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;
diff --git a/examples/animation/animatedtiles/main.cpp b/examples/animation/animatedtiles/main.cpp
index e4a774c..cfaa4ce 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 536bbb6..1a43ed7 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/example/mainwindow.cpp b/examples/animation/example/mainwindow.cpp
index dfb5c70..2b0e035 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 f4c754d..1f253f3 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/states/main.cpp b/examples/animation/states/main.cpp
index 5c004a2..da50519 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 0000000..ca0daf0
--- /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 0000000..c144fd8
--- /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 0000000..7ad9edb
--- /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 0000000..158c9b7
--- /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 0000000..279fc07
--- /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 1b6afa9..d4f0e3a 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 9ea2cfb..58ed95b 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 3e92aec..9233760 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 8094a76..437e935 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 a094e28..62860ec 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 f3468d0..5932b60 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 b796774..e9e9190 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 22d48d3..1393836 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 ae406ca..e659cdb 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 136cb44..bfee5b0 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 6824f17..633e1b1 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 b6ae5a3..04310aa 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/graphicsscene.cpp b/examples/animation/sub-attaq/graphicsscene.cpp
index a7f4c1b..5dcc034 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 0000000..70285a8
--- /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/qanimationstate.h b/examples/animation/sub-attaq/qanimationstate.h
new file mode 100644
index 0000000..fda1534
--- /dev/null
+++ b/examples/animation/sub-attaq/qanimationstate.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef QANIMATIONSTATE_H
+#define QANIMATIONSTATE_H
+
+#ifndef QT_STATEMACHINE_SOLUTION
+# include <QtCore/qstate.h>
+# include <QtCore/qabstractanimation.h>
+#else
+# include "qstate.h"
+# include "qabstractanimation.h"
+#endif
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ANIMATION
+
+class QAnimationStatePrivate;
+
+class Q_GUI_EXPORT QAnimationState : public QState
+{
+ Q_OBJECT
+public:
+ QAnimationState(QState *parent = 0);
+ ~QAnimationState();
+
+ void setAnimation(QAbstractAnimation *animation);
+ QAbstractAnimation* animation() const;
+
+Q_SIGNALS:
+ void animationFinished();
+
+protected:
+ void onEntry();
+ void onExit();
+ bool event(QEvent *e);
+
+private:
+ Q_DISABLE_COPY(QAnimationState)
+ Q_DECLARE_PRIVATE(QAnimationState)
+};
+
+#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 32e0bb8..f476f55 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 1001827..52d4ffa 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 d8de6f5..07c4d06 100644
--- a/examples/animation/sub-attaq/sub-attaq.pro
+++ b/examples/animation/sub-attaq/sub-attaq.pro
@@ -21,7 +21,9 @@ HEADERS += boat.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 +34,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 481c748..e64ffdd 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 5aa84b6..354a406 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 4964192..b24948d 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 bcc675a..fc09ef9 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 51180f5..1b2b21e 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 aee1b55..afd6433 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 717b881..db026f5 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 e0ac8bb..ec86509 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 f129c8d..dd23948 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 96f45fc..4d28055 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 a64c17c..c5a3a16 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 e903988..d01822f 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$
**
****************************************************************************/
diff --git a/examples/statemachine/composition/main.cpp b/examples/statemachine/composition/main.cpp
index 892542d..24b823c 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 51b2d82..f564b7e 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 985b09f..9e39ced 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 a124623..13486d4 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 7aed84b..e0ebbff 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 d749076..3272524 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$
**
****************************************************************************/
diff --git a/examples/statemachine/trafficlight/main.cpp b/examples/statemachine/trafficlight/main.cpp
index fbb6b68..528ed00 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 eab0b3d..61a0f32 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/statemachine/qabstractstate.cpp b/src/corelib/statemachine/qabstractstate.cpp
index 68a7fdc..1795bd6 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
@@ -27,6 +58,9 @@ QT_BEGIN_NAMESPACE
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 +72,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()
+*/
+
+/*!
+ \property QAbstractState::restorePolicy
+
+ \brief the restore policy of this state
+*/
+
QAbstractStatePrivate::QAbstractStatePrivate()
+ : restorePolicy(QAbstractState::GlobalRestorePolicy)
{
}
@@ -131,6 +203,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 cbf7ab5..b788a88 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 631d0b4..bf44116 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$
**
****************************************************************************/
@@ -35,6 +65,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 +96,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 d9ca154..36de7f5 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$
**
****************************************************************************/
@@ -35,6 +65,9 @@ QT_BEGIN_NAMESPACE
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 +288,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 4cf7fae..c49731f 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 796af11..a48a09c 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 312465e..77fd036 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$
**
****************************************************************************/
@@ -30,19 +60,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 +73,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,60 +146,6 @@ 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
@@ -238,7 +165,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 +260,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 2af9d4a..517b4b2 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 69343f8..a06dde2 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/qanimationstate.cpp b/src/corelib/statemachine/qanimationstate.cpp
deleted file mode 100644
index b963950..0000000
--- 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 5d11041..0000000
--- 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 5f31372..b641ff3 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 65f0075..b03074d 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$
**
****************************************************************************/
@@ -62,6 +92,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;
@@ -248,13 +283,6 @@ bool QEventTransition::testEventCondition(QEvent *event) const
/*!
\reimp
*/
-void QEventTransition::onTransition()
-{
-}
-
-/*!
- \reimp
-*/
bool QEventTransition::event(QEvent *e)
{
return QTransition::event(e);
diff --git a/src/corelib/statemachine/qeventtransition.h b/src/corelib/statemachine/qeventtransition.h
index ece79e8..edd7f8a 100644
--- a/src/corelib/statemachine/qeventtransition.h
+++ b/src/corelib/statemachine/qeventtransition.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,7 +56,9 @@ class Q_CORE_EXPORT QEventTransition : public QTransition
{
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 +76,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 55ea9e6..568e35e 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$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qfinalstate.cpp b/src/corelib/statemachine/qfinalstate.cpp
index c4dbcc9..5219b1b 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$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qfinalstate.h b/src/corelib/statemachine/qfinalstate.h
index ba69c36..36813f5 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 a3da4be..a0c933c 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$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qhistorystate.h b/src/corelib/statemachine/qhistorystate.h
index a18d064..9cd7f0b 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 1a2461b..84648b5 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 50ac380..5dcabc4 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 1d4e7d7..d18def8 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 48add0d..9c03b94 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$
**
****************************************************************************/
@@ -213,13 +243,6 @@ bool QSignalTransition::eventTest(QEvent *event) const
/*!
\reimp
*/
-void QSignalTransition::onTransition()
-{
-}
-
-/*!
- \reimp
-*/
bool QSignalTransition::event(QEvent *e)
{
return QTransition::event(e);
diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h
index c090bd8..ba4af17 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$
**
****************************************************************************/
@@ -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 d200676..c5fbcfc 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$
**
****************************************************************************/
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index 26dbd89..944ca2c 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
@@ -242,36 +269,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 +319,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 +390,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 ba2d034..4c86e02 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 fe9b24a..17b312a 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 c12b093..b03aa19 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$
**
****************************************************************************/
@@ -112,151 +142,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();
diff --git a/src/corelib/statemachine/qstateaction.h b/src/corelib/statemachine/qstateaction.h
index df1e0f0..6843080 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 54e3a05..4016b74 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 d6a1146..c2f81f7 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 3d8c588..24d2ca4 100644
--- a/src/corelib/statemachine/qstatefinishedtransition.cpp
+++ b/src/corelib/statemachine/qstatefinishedtransition.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$
**
****************************************************************************/
@@ -137,13 +167,6 @@ bool QStateFinishedTransition::eventTest(QEvent *event) const
/*!
\reimp
*/
-void QStateFinishedTransition::onTransition()
-{
-}
-
-/*!
- \reimp
-*/
bool QStateFinishedTransition::event(QEvent *e)
{
return QTransition::event(e);
diff --git a/src/corelib/statemachine/qstatefinishedtransition.h b/src/corelib/statemachine/qstatefinishedtransition.h
index bcd82fa..eae3143 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$
**
****************************************************************************/
@@ -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 208c6a9..90932f6 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
@@ -148,7 +183,6 @@ QT_BEGIN_NAMESPACE
*/
// #define QSTATEMACHINE_DEBUG
-// #define QT_NO_STATEMACHINE_RESTOREPROPERTIES
QStateMachinePrivate::QStateMachinePrivate()
{
@@ -157,7 +191,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 +354,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 +417,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 +431,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 +494,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 +545,7 @@ void QStateMachinePrivate::enterStates(const QList<QAbstractTransition*> &enable
}
}
// qDebug() << "configuration:" << configuration.toList();
+ return statesToEnter_sorted;
}
void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root,
@@ -618,6 +596,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 +783,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 +818,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 +881,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 +1013,7 @@ void QStateMachinePrivate::_q_start()
transitions.append(initialTransition);
executeTransitionContent(transitions);
enterStates(transitions);
+ applyProperties(transitions, QList<QAbstractState*>() << initial);
delete start;
#ifdef QSTATEMACHINE_DEBUG
@@ -911,7 +1049,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 +1066,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 +1213,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 +1226,7 @@ void QStateMachinePrivate::unregisterSignalTransition(QSignalTransition *transit
connections.remove(sender);
QSignalTransitionPrivate::get(transition)->signalIndex = -1;
}
+#endif
}
#ifndef QT_NO_STATEMACHINE_EVENTFILTER
@@ -1174,6 +1314,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 +1490,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 +1722,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
*/
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index e3b09e0..c7de171 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 dfa95e5..04dc71e 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
index ebd972c..3becc3a 100644
--- a/src/corelib/statemachine/qtransition.cpp
+++ b/src/corelib/statemachine/qtransition.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,9 +58,6 @@ QT_BEGIN_NAMESPACE
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.
@@ -40,7 +67,7 @@ QT_BEGIN_NAMESPACE
machine.addState(s1);
QTransition *t1 = new QTransition();
QLabel label;
- t1->setPropertyOnTransition(&label, "text", "Transition t1 was triggered");
+ t1->invokeMethodOnTransition(&label, "clear");
QState *s2 = new QState();
machine.addState(s2);
t1->setTargetState(s2);
@@ -126,32 +153,6 @@ 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
diff --git a/src/corelib/statemachine/qtransition.h b/src/corelib/statemachine/qtransition.h
index 57d9718..7eec136 100644
--- a/src/corelib/statemachine/qtransition.h
+++ b/src/corelib/statemachine/qtransition.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$
**
****************************************************************************/
@@ -38,8 +68,6 @@ public:
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>());
diff --git a/src/corelib/statemachine/qtransition_p.h b/src/corelib/statemachine/qtransition_p.h
index e5da6de..d43a4d4 100644
--- a/src/corelib/statemachine/qtransition_p.h
+++ b/src/corelib/statemachine/qtransition_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/statemachine.pri b/src/corelib/statemachine/statemachine.pri
index 8409b4d..9c797e2 100644
--- a/src/corelib/statemachine/statemachine.pri
+++ b/src/corelib/statemachine/statemachine.pri
@@ -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/statemachine/qguistatemachine.cpp b/src/gui/statemachine/qguistatemachine.cpp
index 540036a..d30265a 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 5b0c857..a4e882d 100644
--- a/src/gui/statemachine/qkeyeventtransition.cpp
+++ b/src/gui/statemachine/qkeyeventtransition.cpp
@@ -119,7 +119,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/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 729581e..c906d53 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>
@@ -87,7 +121,6 @@ private slots:
void setRestorePolicyToDoNotRestore();
void setGlobalRestorePolicyToGlobalRestore();
void restorePolicyOnChildState();
- void addAnimatedTransition();
void transitionWithParent();
};
@@ -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);
@@ -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()
@@ -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;