summaryrefslogtreecommitdiffstats
path: root/examples/statemachine
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-04-29 14:36:19 (GMT)
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-04-29 14:36:19 (GMT)
commit085c0bcc85cea0d44a2a63fd7f8ebf6c4bfcaf4c (patch)
tree1969327edac4dd604581c4dfffd8fdbcebb49d56 /examples/statemachine
parent146a63c8025d4b5a20554e067d0246df9be3e68a (diff)
downloadQt-085c0bcc85cea0d44a2a63fd7f8ebf6c4bfcaf4c.zip
Qt-085c0bcc85cea0d44a2a63fd7f8ebf6c4bfcaf4c.tar.gz
Qt-085c0bcc85cea0d44a2a63fd7f8ebf6c4bfcaf4c.tar.bz2
Kill gameOver signal as it was only used when you clicked the stop action
Diffstat (limited to 'examples/statemachine')
-rw-r--r--examples/statemachine/errorstate/mainwindow.cpp14
-rw-r--r--examples/statemachine/errorstate/mainwindow.h1
2 files changed, 6 insertions, 9 deletions
diff --git a/examples/statemachine/errorstate/mainwindow.cpp b/examples/statemachine/errorstate/mainwindow.cpp
index f5edf60..8a15e8b 100644
--- a/examples/statemachine/errorstate/mainwindow.cpp
+++ b/examples/statemachine/errorstate/mainwindow.cpp
@@ -110,44 +110,41 @@ void MainWindow::init()
QAction *quitAction = menuBar()->addAction("&Quit");
connect(addTankAction, SIGNAL(triggered()), this, SLOT(addTank()));
- connect(stopGameAction, SIGNAL(triggered()), this, SIGNAL(gameOver()));
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
m_machine = new QStateMachine(this);
m_machine->setGlobalRestorePolicy(QStateMachine::RestoreProperties);
- QState *stoppedState = new QState(m_machine->rootState());
+ QState *stoppedState = new QState(m_machine->rootState());
stoppedState->setObjectName("stoppedState");
-
stoppedState->assignProperty(runGameAction, "enabled", true);
stoppedState->assignProperty(stopGameAction, "enabled", false);
stoppedState->assignProperty(this, "started", false);
m_machine->setInitialState(stoppedState);
QState *spawnsAvailable = new QState(stoppedState);
- spawnsAvailable->assignProperty(addTankAction, "enabled", true);
spawnsAvailable->setObjectName("spawnsAvailable");
+ spawnsAvailable->assignProperty(addTankAction, "enabled", true);
QState *noSpawnsAvailable = new QState(stoppedState);
+ noSpawnsAvailable->setObjectName("noSpawnsAvailable");
noSpawnsAvailable->assignProperty(addTankAction, "enabled", false);
spawnsAvailable->addTransition(this, SIGNAL(mapFull()), noSpawnsAvailable);
QHistoryState *hs = new QHistoryState(stoppedState);
- hs->setObjectName("hs");
hs->setDefaultState(spawnsAvailable);
stoppedState->setInitialState(hs);
m_runningState = new QState(QState::ParallelGroup, m_machine->rootState());
+ m_runningState->setObjectName("runningState");
m_runningState->assignProperty(addTankAction, "enabled", false);
m_runningState->assignProperty(runGameAction, "enabled", false);
m_runningState->assignProperty(stopGameAction, "enabled", true);
stoppedState->addTransition(runGameAction, SIGNAL(triggered()), m_runningState);
- m_runningState->addTransition(this, SIGNAL(gameOver()), stoppedState);
-
- m_machine->start();
+ m_runningState->addTransition(stopGameAction, SIGNAL(triggered()), stoppedState);
QTimer *timer = new QTimer(this);
timer->setInterval(100);
@@ -155,6 +152,7 @@ void MainWindow::init()
connect(m_runningState, SIGNAL(entered()), timer, SLOT(start()));
connect(m_runningState, SIGNAL(exited()), timer, SLOT(stop()));
+ m_machine->start();
m_time.start();
}
diff --git a/examples/statemachine/errorstate/mainwindow.h b/examples/statemachine/errorstate/mainwindow.h
index 33122eb..622dabe 100644
--- a/examples/statemachine/errorstate/mainwindow.h
+++ b/examples/statemachine/errorstate/mainwindow.h
@@ -25,7 +25,6 @@ public slots:
void runStep();
signals:
- void gameOver();
void mapFull();
private: