]> Some of my projects - anidbudpclient.git/commitdiff
- Port to the State machine classes from 4.6.0.
authorAPTX <mail@example.com>
Wed, 23 Sep 2009 13:14:43 +0000 (15:14 +0200)
committerAPTX <mail@example.com>
Wed, 23 Sep 2009 13:14:43 +0000 (15:14 +0200)
- Remove qtstatemachine-solution lib.

anidbudpclient.pro
client.cpp
client.h

index 957596014edd01b59d8631683c640aab129bf990..9f2968b625e02bab6bbea21b4946728ed7150198 100644 (file)
@@ -57,5 +57,3 @@ CONV_HEADERS += include/AniDBUdpClient/Client \
        include/AniDBUdpClient/UptimeCommand \
        include/AniDBUdpClient/Hash \
     include/AniDBUdpClient/UptimeCommand \
-
-include(../../lib/qtstatemachine/src/qtstatemachine.pri)
index 151d856827e06192f648e193c3fb9da54f703b02..4acb117b3f84e89e662069e97da3016215b3c7b6 100644 (file)
@@ -1,9 +1,8 @@
 #include "client.h"
 
-#include <QtStateMachine>
-#include <QtActionState>
-#include <QtHistoryState>
-#include <QtState>
+#include <QStateMachine>
+#include <QHistoryState>
+#include <QState>
 
 #include <QCoreApplication>
 #include <QUdpSocket>
@@ -52,20 +51,20 @@ qDebug() << "Api instance init!";
 
        setFloodInterval(5);
 
-       stateMachine = new QtStateMachine(this);
-
-       errorState = new QtState;
-       disconnectedState = new QtState;
-       connectingState = new QtState;
-       connectedState = new QtState;
-       authenticatingState = new QtState(connectedState);
-       idleState = new QtState(connectedState);
-       idleTimeoutState = new QtState(connectedState);
-       sendState = new QtState(connectedState);
-       waitState = new QtState(connectedState);
-       recieveState = new QtState;
-       recieveFailState = new QtState;
-       connectedHistoryState = connectedState->addHistoryState();
+       stateMachine = new QStateMachine(this);
+
+       errorState = new QState;
+       disconnectedState = new QState;
+       connectingState = new QState;
+       connectedState = new QState;
+       authenticatingState = new QState(connectedState);
+       idleState = new QState(connectedState);
+       idleTimeoutState = new QState(connectedState);
+       sendState = new QState(connectedState);
+       waitState = new QState(connectedState);
+       recieveState = new QState;
+       recieveFailState = new QState;
+       connectedHistoryState = new QHistoryState(connectedState);
 
        stateMachine->addState(errorState);
        stateMachine->addState(disconnectedState);
@@ -111,19 +110,19 @@ qDebug() << "Api instance init!";
        // ------------ END Transitions -------------------
 
        // ------------- Methods ---------------------
-       errorState->invokeMethodOnEntry(this, "enterErrorState");
-       disconnectedState->invokeMethodOnEntry(this, "enterDisconnectedState");
-       connectingState->invokeMethodOnEntry(this, "enterConnectingState");
-       connectedState->invokeMethodOnEntry(this, "enterConnectedState");
-       authenticatingState->invokeMethodOnEntry(this, "enterAuthenticatingState");
-       sendState->invokeMethodOnEntry(this, "enterSendState");
-       waitState->invokeMethodOnEntry(this, "enterWaitState");
-       idleState->invokeMethodOnEntry(this, "enterIdleState");
-       idleState->invokeMethodOnExit(this, "exitIdleState");
-       idleTimeoutState->invokeMethodOnEntry(this, "enterIdleTiemoutState");
-
-       recieveState->invokeMethodOnEntry(this, "enterRecieveState");
-       recieveFailState->invokeMethodOnEntry(this, "enterRecieveFailState");
+       QObject::connect(errorState, SIGNAL(entered()), this, SLOT(enterErrorState()));
+       QObject::connect(disconnectedState, SIGNAL(entered()), this, SLOT(enterDisconnectedState()));
+       QObject::connect(connectingState, SIGNAL(entered()), this, SLOT(enterConnectingState()));
+       QObject::connect(connectedState, SIGNAL(entered()), this, SLOT(enterConnectedState()));
+       QObject::connect(authenticatingState, SIGNAL(entered()), this, SLOT(enterAuthenticatingState()));
+       QObject::connect(sendState, SIGNAL(entered()), this, SLOT(enterSendState()));
+       QObject::connect(waitState, SIGNAL(entered()), this, SLOT(enterWaitState()));
+       QObject::connect(idleState, SIGNAL(entered()), this, SLOT(enterIdleState()));
+       QObject::connect(idleState, SIGNAL(exited()), this, SLOT(exitIdleState()));
+       QObject::connect(idleTimeoutState, SIGNAL(entered()), this, SLOT(enterIdleTiemoutState()));
+
+       QObject::connect(recieveState, SIGNAL(entered()), this, SLOT(enterRecieveState()));
+       QObject::connect(recieveFailState, SIGNAL(entered()), this, SLOT(enterRecieveFailState()));
        // ------------ END Methods -------------------
 
        stateMachine->start();
index 728ba491f0f037daed4d4a914e5d176b0a89ec9a..6f5b85419cd3dfcb6b176e0c749bcc277fe9f924 100644 (file)
--- a/client.h
+++ b/client.h
@@ -12,9 +12,9 @@
 #include "anidbudpclient_global.h"
 #include "authcommand.h"
 
-class QtStateMachine;
-class QtState;
-class QtHistoryState;
+class QStateMachine;
+class QState;
+class QHistoryState;
 
 class QUdpSocket;
 class QTimer;
@@ -208,22 +208,22 @@ private:
 
        static const int UDP_API_COMMAND_TIMEOUT = 10;
 
-       QtStateMachine *stateMachine;
-       QtState *errorState;
-       QtState *disconnectedState;
-       QtState *connectingState;
-       QtState *connectedState;
-       QtState *authenticatingState;
+       QStateMachine *stateMachine;
+       QState *errorState;
+       QState *disconnectedState;
+       QState *connectingState;
+       QState *connectedState;
+       QState *authenticatingState;
 
-       QtState *idleState;
-       QtState *idleTimeoutState;
-       QtState *sendState;
-       QtState *waitState;
+       QState *idleState;
+       QState *idleTimeoutState;
+       QState *sendState;
+       QState *waitState;
 
-       QtState *recieveState;
-       QtState *recieveFailState;
+       QState *recieveState;
+       QState *recieveFailState;
 
-       QtHistoryState *connectedHistoryState;
+       QHistoryState *connectedHistoryState;
 };
 
 class CommandData : QObject