summaryrefslogtreecommitdiffstats
path: root/examples/statemachine/pingpong/main.cpp
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-05-08 07:04:37 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-05-08 07:04:37 (GMT)
commit639004cbf1e9d3f94512d9a07e56aeafef4d93b9 (patch)
tree175c52791fcc0d7bd2c1ef517b705b3d2850fc69 /examples/statemachine/pingpong/main.cpp
parent9dcc7f9fea95d41f82fdde700f1a17da81257451 (diff)
parent15de11bfcd2907e587dff41013fd39b62f0ca869 (diff)
downloadQt-639004cbf1e9d3f94512d9a07e56aeafef4d93b9.zip
Qt-639004cbf1e9d3f94512d9a07e56aeafef4d93b9.tar.gz
Qt-639004cbf1e9d3f94512d9a07e56aeafef4d93b9.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'examples/statemachine/pingpong/main.cpp')
-rw-r--r--examples/statemachine/pingpong/main.cpp39
1 files changed, 14 insertions, 25 deletions
diff --git a/examples/statemachine/pingpong/main.cpp b/examples/statemachine/pingpong/main.cpp
index 00ff643..eb8fd5d 100644
--- a/examples/statemachine/pingpong/main.cpp
+++ b/examples/statemachine/pingpong/main.cpp
@@ -64,58 +64,47 @@ public:
class Pinger : public QState
{
public:
- Pinger(QStateMachine *machine, QState *parent)
- : QState(parent), m_machine(machine) {}
+ Pinger(QState *parent)
+ : QState(parent) {}
protected:
- virtual void onEntry()
+ virtual void onEntry(QEvent *)
{
- m_machine->postEvent(new PingEvent());
+ machine()->postEvent(new PingEvent());
fprintf(stdout, "ping?\n");
}
-
-private:
- QStateMachine *m_machine;
};
class PongTransition : public QAbstractTransition
{
public:
- PongTransition(QStateMachine *machine)
- : QAbstractTransition(), m_machine(machine) {}
+ PongTransition() {}
protected:
virtual bool eventTest(QEvent *e) const {
return (e->type() == QEvent::User+3);
}
- virtual void onTransition()
+ virtual void onTransition(QEvent *)
{
- m_machine->postEvent(new PingEvent(), 500);
+ machine()->postEvent(new PingEvent(), 500);
fprintf(stdout, "ping?\n");
}
-
-private:
- QStateMachine *m_machine;
};
class PingTransition : public QAbstractTransition
{
public:
- PingTransition(QStateMachine *machine)
- : QAbstractTransition(), m_machine(machine) {}
+ PingTransition() {}
protected:
virtual bool eventTest(QEvent *e) const {
return (e->type() == QEvent::User+2);
}
- virtual void onTransition()
+ virtual void onTransition(QEvent *)
{
- m_machine->postEvent(new PongEvent(), 500);
+ machine()->postEvent(new PongEvent(), 500);
fprintf(stdout, "pong!\n");
}
-
-private:
- QStateMachine *m_machine;
};
int main(int argc, char **argv)
@@ -123,16 +112,16 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv);
QStateMachine machine;
- QState *group = new QState(QState::ParallelGroup);
+ QState *group = new QState(QState::ParallelStates);
group->setObjectName("group");
- Pinger *pinger = new Pinger(&machine, group);
+ Pinger *pinger = new Pinger(group);
pinger->setObjectName("pinger");
- pinger->addTransition(new PongTransition(&machine));
+ pinger->addTransition(new PongTransition());
QState *ponger = new QState(group);
ponger->setObjectName("ponger");
- ponger->addTransition(new PingTransition(&machine));
+ ponger->addTransition(new PingTransition());
machine.addState(group);
machine.setInitialState(group);