summaryrefslogtreecommitdiffstats
path: root/examples/animation
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-04-22 17:20:19 +0200
committerKent Hansen <khansen@trolltech.com>2009-04-22 17:20:19 +0200
commitf87641584424deed25e2abdadea08c3be94b9ce1 (patch)
treea185687744e724a8db896970416f23d20f5cad38 /examples/animation
parent31f5348ea1691a7664b6abc04cf425dd02637b33 (diff)
kill the stateactions api
It just didn't give us that much. Typically you just reimplement onEntry/onExit/onTransition when you want to do something. We go back to the signals-and-slots approach: states have entered() and exited() signals that you can connect to. It's still possible to have an action-based API, but then you build it on top of the core API, which is OK. Replacing 4 public classes (and one layer in the hierarchy) with 2 signals feels good.
Diffstat (limited to 'examples/animation')
-rw-r--r--examples/animation/example/mainwindow.cpp6
-rw-r--r--examples/animation/moveblocks/main.cpp2
-rw-r--r--examples/animation/stickman/lifecycle.cpp4
3 files changed, 6 insertions, 6 deletions
diff --git a/examples/animation/example/mainwindow.cpp b/examples/animation/example/mainwindow.cpp
index 2b0e035fa..bec755c7a 100644
--- a/examples/animation/example/mainwindow.cpp
+++ b/examples/animation/example/mainwindow.cpp
@@ -173,9 +173,9 @@ MainWindow::MainWindow() : QMainWindow(0)
setCentralWidget(view);
- state3->invokeMethodOnEntry(this, "onEnterState3");
- state2->invokeMethodOnEntry(this, "onEnterState2");
- state1->invokeMethodOnEntry(this, "onEnterState1");
+ QObject::connect(state3, SIGNAL(entered()), this, SLOT(onEnterState3()));
+ QObject::connect(state2, SIGNAL(entered()), this, SLOT(onEnterState2()));
+ QObject::connect(state1, SIGNAL(entered()), this, SLOT(onEnterState1()));
connect(listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemClicked(QListWidgetItem*)));
connect(button3, SIGNAL(clicked()), this, SLOT(onRemoveClicked()));
diff --git a/examples/animation/moveblocks/main.cpp b/examples/animation/moveblocks/main.cpp
index 1f253f3b1..639fff3f2 100644
--- a/examples/animation/moveblocks/main.cpp
+++ b/examples/animation/moveblocks/main.cpp
@@ -172,7 +172,7 @@ int main(int argc, char **argv)
QTimer timer;
timer.setInterval(1250);
timer.setSingleShot(true);
- group->invokeMethodOnEntry(&timer, "start");
+ QObject::connect(group, SIGNAL(entered()), &timer, SLOT(start()));
QState *state1;
QState *state2;
diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp
index 923376053..e67b32dfa 100644
--- a/examples/animation/stickman/lifecycle.cpp
+++ b/examples/animation/stickman/lifecycle.cpp
@@ -86,8 +86,8 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
QTimer *timer = new QTimer(lightningBlink);
timer->setSingleShot(true);
timer->setInterval(100);
- lightningBlink->invokeMethodOnEntry(timer, "start");
- lightningBlink->invokeMethodOnExit(timer, "stop");
+ QObject::connect(lightningBlink, SIGNAL(entered()), timer, SLOT(start()));
+ QObject::connect(lightningBlink, SIGNAL(exited()), timer, SLOT(stop()));
m_dead = new QState(m_machine->rootState());
m_dead->setRestorePolicy(QState::DoNotRestoreProperties);