diff options
Diffstat (limited to 'scc/examples')
-rw-r--r-- | scc/examples/algotest/algotest.pro | 6 | ||||
-rw-r--r-- | scc/examples/algotest/main.cpp | 56 | ||||
-rw-r--r-- | scc/examples/algotest/test.scxml | 145 | ||||
-rw-r--r-- | scc/examples/animations/animations.pro | 6 | ||||
-rw-r--r-- | scc/examples/animations/animations.scxml | 19 | ||||
-rw-r--r-- | scc/examples/animations/main.cpp | 81 | ||||
-rw-r--r-- | scc/examples/examples.pro | 2 | ||||
-rw-r--r-- | scc/examples/loginmvc/controller.scxml | 105 | ||||
-rw-r--r-- | scc/examples/loginmvc/frame.ui | 123 | ||||
-rw-r--r-- | scc/examples/loginmvc/loginmvc.pro | 8 | ||||
-rw-r--r-- | scc/examples/loginmvc/main.cpp | 193 |
11 files changed, 0 insertions, 744 deletions
diff --git a/scc/examples/algotest/algotest.pro b/scc/examples/algotest/algotest.pro deleted file mode 100644 index e5a1eba..0000000 --- a/scc/examples/algotest/algotest.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = app -SOURCES += main.cpp -OTHER_FILES += test.scxml -STATECHARTS += test.scxml -CONFIG += scc console -QT -= gui diff --git a/scc/examples/algotest/main.cpp b/scc/examples/algotest/main.cpp deleted file mode 100644 index c8b74e1..0000000 --- a/scc/examples/algotest/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtCore 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 http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sc_test.h" -#include <QCoreApplication> -#include <QTimer> -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - SMClass_test stateMachine; - stateMachine.setupStateMachine(); - stateMachine.start(); - QObject::connect(stateMachine.state_Test2Sub1,SIGNAL(entered()),&stateMachine,SIGNAL(event_Event2())); - QObject::connect(&stateMachine,SIGNAL(finished()),&a,SLOT(quit())); - QTimer::singleShot(100,&stateMachine,SIGNAL(event_Event1())); - return a.exec(); -} - diff --git a/scc/examples/algotest/test.scxml b/scc/examples/algotest/test.scxml deleted file mode 100644 index e17f9bf..0000000 --- a/scc/examples/algotest/test.scxml +++ /dev/null @@ -1,145 +0,0 @@ -<?xml version="1.0" encoding="UTF8"?> -<!-- A wrapper state that contains all other states in this file -- it represents the complete state machine --> <scxml xmlns="http://www.w3.org/2005/07/scxml" - version="1.0" - initial="Main"> - <state id="Main"> - <!-- its initial state is Test1 --> - <initial> - <transition target="Test1"/> - </initial> - - <!-- Really simple state showing the basic syntax. --> - <state id="Test1"> - <initial> - <transition target="Test1Sub1"/> - </initial> - <!-- Runs before we go into the substate --> - <onentry> - <log expr=""Inside Test1""/> - </onentry> - - <!-- Here is our first substate --> - <state id="Test1Sub1"> - <onentry> - <log expr=""Inside Test1Sub1.""/> - </onentry> - <onexit> - <log expr=""Leaving Test1Sub1""/> - </onexit> - <!-- Go to Sub2 on Event1 --> - <transition event="Event1" target="Test1Sub2"/> - </state> - - <!-- Here is the second substate - It is final, so Test1 is done when we get here --> - <final id="Test1Sub2"/> - - <!-- We get this event when we reach Test1Sub2. --> - <transition event="done.state.Test1" target="Test2"/> - - <!-- We run this on the way out of Test1 --> - <onexit> - <log expr=""Leaving Test1...""/> - </onexit> - </state> - - <state id="Test2"> - <initial> - <transition target="Test2Sub1"/> - </initial> - - <!-- This time we reference a state - defined in an external file. Note that we could have - loaded the entire file by leaving off the #Test2Sub1, - but in that case we would need to rename one of the - Test2Sub1 states (here or in the external file) to - avoid the name collision --> - <state id="Test2Sub1"> - <onentry> - <log expr=""Inside Test2Sub1""/> - </onentry> - <transition event="Event2" target="Test2Sub2"/> - </state> - <final id="Test2Sub2"/> - - <!-- Test2Sub2 is defined as final, so this - event is generated when we reach it --> - <transition event="done.state.Test2" target="Test3"/> - </state> - - <state id="Test3"> - <initial> - <transition target="Test3Sub1"/> - </initial> - - <state id="Test3Sub1"> - <onentry> - <log expr=""Inside Test3Sub1...""/> - <!-- Send our self an event in 5s --> - <send event="Timer" delay="1500"/> - </onentry> - <!-- Transition on to Test4. - This will exit both us and our parent. --> - <transition event="Timer" target="Test4"/> - <onexit> - <log expr=""Leaving Test3Sub1...""/> - </onexit> - </state> - - <onexit> - <log expr=""Leaving Test3...""/> - </onexit> - </state> - - <state id="Test4"> - <onentry> - <log expr=""Inside Test4...""/> - </onentry> - <initial> - <transition target="Test4Sub1"/> - </initial> - - <state id="Test4Sub1"> - <onexit> - <log expr=""Leaving Test4Sub1...""/> - </onexit> - <!-- This transition causes the state to exit immediately - after entering Test4Sub1. The transition has no event - or guard so it is always active --> - <transition target="Test5"/> - </state> - </state> - - <state id="Test5"> - <onentry> - <log expr=""Inside Test5...""/> - </onentry> - <initial> - <transition target="Test5P"/> - </initial> - - <!-- Fire off our parallel states --> - <parallel id="Test5P"> - <final id="Test5PSub1"/> - <final id="Test5PSub2"/> - <onexit> - <log expr=""all parallel states done""/> - </onexit> - </parallel> - - <!-- The parallel states are all final, so this - event is generated immediately. Although not shown, - compound states (i.e., <state>s with content) - are permitted within <parallel> as well. --> - <transition event="done.state.Test5P" target="Done"/> - </state> - - <!-- This final state is an immediate child of Main - - when we get here, done.state.Main is generated. --> - <final id="Done"/> - <!-- End of Main > --> - <transition event="done.state.Main" target="final" /> - </state> - <final id="final"/> -</scxml> diff --git a/scc/examples/animations/animations.pro b/scc/examples/animations/animations.pro deleted file mode 100644 index d501c13..0000000 --- a/scc/examples/animations/animations.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = app -OTHER_FILES += animations.scxml -STATECHARTS += animations.scxml -CONFIG += scc console -SOURCES += main.cpp -TARGET = animations diff --git a/scc/examples/animations/animations.scxml b/scc/examples/animations/animations.scxml deleted file mode 100644 index 0aabb64..0000000 --- a/scc/examples/animations/animations.scxml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:Qt="http://www.qtsoftware.com scxml-ext" - initial="hist"> - <datamodel> - <data id="anim" Qt:type="QPropertyAnimation*" expr="NULL" /> - <data id="indicator" Qt:type="QObject*" expr="NULL" /> - </datamodel> - <history id="hist" type="deep"> - <transition target="idle" /> - </history> - <state id="idle"> - <Qt:property object="_data.indicator" property="opacity" value="0" /> - <transition target="active" event="ev1()" Qt:animation="_data.anim" /> - </state> - <state id="active"> - <Qt:property object="_data.indicator" property="opacity" value="1" /> - <transition target="idle" event="ev1()" Qt:animation="_data.anim" /> - </state> -</scxml> diff --git a/scc/examples/animations/main.cpp b/scc/examples/animations/main.cpp deleted file mode 100644 index cf816bc..0000000 --- a/scc/examples/animations/main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtCore 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 http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sc_animations.h" -#include <QApplication> -#include <QGraphicsView> -#include <QLabel> -#include <QGraphicsProxyWidget> -#include <QShortcut> -#include <QGraphicsScene> -#include <QPushButton> -#include <QVBoxLayout> -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - SMClass_animations stateMachine; - QGraphicsView* gv = new QGraphicsView(); - QPushButton* b = new QPushButton(); - QWidget* w = new QWidget(); - QVBoxLayout* lyt = new QVBoxLayout(); - lyt->addWidget(gv); - lyt->addWidget(b); - b->setText("Push Me"); - QObject::connect(b,SIGNAL(clicked()),&stateMachine,SIGNAL(event_ev1())); - w->setLayout(lyt); - gv->setScene(new QGraphicsScene()); - gv->setInteractive(true); - gv->setFocus(); - QGraphicsProxyWidget* wdg = gv->scene()->addWidget(new QLabel("Hello World!")); - wdg->setOpacity(0); - QPropertyAnimation* anim = new QPropertyAnimation(); - anim->setPropertyName("opacity"); - anim->setTargetObject(wdg); - anim->setDuration(1000); - anim->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic)); - stateMachine.set_indicator(wdg); - stateMachine.set_anim(anim); - stateMachine.setupStateMachine(); - w->show(); - stateMachine.start(); - return a.exec(); -} - diff --git a/scc/examples/examples.pro b/scc/examples/examples.pro deleted file mode 100644 index 39b6dbb..0000000 --- a/scc/examples/examples.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = loginmvc animations algotest diff --git a/scc/examples/loginmvc/controller.scxml b/scc/examples/loginmvc/controller.scxml deleted file mode 100644 index 8bffc1a..0000000 --- a/scc/examples/loginmvc/controller.scxml +++ /dev/null @@ -1,105 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<scxml xmlns="http://www.w3.org/2005/07/scxml" - xmlns:Qt="http://www.qtsoftware.com scxml-ext" - initial="root"> - <datamodel> - <data id="username" Qt:type="QString" /> - <data id="password" Qt:type="QString" /> - <data id="loginTimeout" Qt:type="int" expr="10000" /> - <data id="firstTime" Qt:type="bool" expr="true" /> - <data id="loginButton" Qt:type="QObject*" expr="NULL" /> - <data id="logoutButton" Qt:type="QObject*" expr="NULL" /> - <data id="cancelButton" Qt:type="QObject*" expr="NULL" /> - </datamodel> - <parallel id="root"> - <state id="business_logic"> - <initial> - <transition target="idle"> - <if cond="_data.firstTime"> - <send event="notify_welcome()" /> - <if cond="!_data.username.isEmpty()"> - <send event="notify_hello(QString)"> - <param expr="_data.username" /> - </send> - </if> - <assign dataid="firstTime" expr="false" /> - </if> - </transition> - </initial> - <state id="idle"> - <onentry><log level="0" label="Info" expr=""Now in Idle"" /><raise event="in_idle" /></onentry> - <onexit><log level="0" label="Info" expr=""Now not in Idle"" /><raise event="not_in_idle" /></onexit> - <transition target="trying_to_login" event="intent_login()" /> - <Qt:property object="_data.cancelButton" property="enabled" value="false" /> - </state> - <state id="trying_to_login"> - <Qt:property object="_data.cancelButton" property="enabled" value="true" /> - <transition event="cancel_login()" target="idle" /> - <transition event="login_timeout()" target="loginTimeout" /> - <onentry> - <log level="0" label="Info" expr=""Trying to log in"" /> - <send event="login_action(QString,QString)"> - <param expr="_data.username" /> - <param expr="_data.password" /> - </send> - <send id="cancel_login_timeout" event="login_timeout()" delay="_data.loginTimeout" /> - </onentry> - <onexit> - <cancel id="cancel_login_timeout" /> - </onexit> - <transition event="login_complete(bool)" cond="_event.data[0].toBool()" target="loggedIn" /> - <transition event="login_complete(bool)" cond="!_event.data[0].toBool()" target="loginError" /> - </state> - <state id="error" initial="loginError"> - <Qt:property object="_data.cancelButton" property="enabled" value="false" /> - <transition event="intent_continue()" target="idle" /> - <onentry> - <raise event="error.login()" /> - </onentry> - <state id="cancelled"> - <onentry> - <send event="notify_cancel()" /> - </onentry> - </state> - <state id="loginError"> - <onentry> - <log label="Error" level="1" expr="_data.username + ' ' + _data.password" /> - <send event="notify_error()" /> - </onentry> - </state> - <state id="loginTimeout"> - <onentry> - <log label="Error" level="1" expr="_data.username + ' ' + _data.password" /> - <send event="notify_timeout()" /> - </onentry> - </state> - </state> - <state id="loggedIn"> - <onentry> - <send event="notify_loggedIn()" /> - </onentry> - <transition event="intent_continue()" target="active" /> - </state> - <state id="active"> - <transition event="intent_logout()" target="idle" /> - <Qt:property object="_data.cancelButton" property="enabled" value="false" /> - </state> - <final id="exit" /> - </state> - <state id="gui" initial="hist"> - <history id="hist" type="deep"> - <transition target="gui_idle" /> - </history> - <state id="gui_idle"> - <Qt:property object="_data.loginButton" property="enabled" value="true" /> - <Qt:property object="_data.logoutButton" property="enabled" value="false" /> - <transition target="gui_active" cond="!In(idle)" /> - </state> - <state id="gui_active"> - <transition target="gui_idle" cond="In(idle)" /> - <Qt:property object="_data.loginButton" property="enabled" value="false" /> - <Qt:property object="_data.logoutButton" property="enabled" value="true" /> - </state> - </state> - </parallel> -</scxml> diff --git a/scc/examples/loginmvc/frame.ui b/scc/examples/loginmvc/frame.ui deleted file mode 100644 index 4b57955..0000000 --- a/scc/examples/loginmvc/frame.ui +++ /dev/null @@ -1,123 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Frame</class> - <widget class="QFrame" name="Frame"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>337</width> - <height>158</height> - </rect> - </property> - <property name="windowTitle"> - <string>Login Workflow</string> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::AllNonFixedFieldsGrow</enum> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Username</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="usernameEdit"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Password</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="passwordEdit"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Timeout</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QSlider" name="timeoutSlider"> - <property name="maximum"> - <number>20000</number> - </property> - <property name="singleStep"> - <number>500</number> - </property> - <property name="pageStep"> - <number>2000</number> - </property> - <property name="value"> - <number>10000</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QWidget" name="widget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="loginButton"> - <property name="text"> - <string>Log In</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="logoutButton"> - <property name="text"> - <string>Logout</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton"> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="5" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"/> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/scc/examples/loginmvc/loginmvc.pro b/scc/examples/loginmvc/loginmvc.pro deleted file mode 100644 index 9af965a..0000000 --- a/scc/examples/loginmvc/loginmvc.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = app -CONFIG += console scc -SOURCES = main.cpp -FORMS += frame.ui -QT += network -STATECHARTS += controller.scxml -OTHER_FILES += controller.scxml -CONFIG -= app_bundle diff --git a/scc/examples/loginmvc/main.cpp b/scc/examples/loginmvc/main.cpp deleted file mode 100644 index 25b68d1..0000000 --- a/scc/examples/loginmvc/main.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtCore 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 http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QApplication> -#include "sc_controller.h" -#include <QLabel> -#include <QMessageBox> -#include "ui_frame.h" -#include <QNetworkAccessManager> -#include <QNetworkReply> -#include <QSslSocket> -class AbstractModel : public QObject -{ - Q_OBJECT - public: - AbstractModel(QObject* o = NULL) : QObject(o) - { - } - public slots: - virtual void login(const QString & u, const QString & p) = 0; - signals: - void loginComplete(bool); -}; - -class DummyModel : public AbstractModel -{ - Q_OBJECT - public: - DummyModel(QObject* o = NULL) : AbstractModel(o) - { - } - public slots: - void test() - { - emit loginComplete(user == "user" && password == "password"); - } - virtual void login(const QString & u, const QString & p) - { - user = u; password = p; - QTimer::singleShot(5000,this,SLOT(test())); - } - signals: - void loginComplete(bool); - private: - QString user,password; - QNetworkAccessManager netAccess; -}; -class GMailModel : public AbstractModel -{ - Q_OBJECT - public: - GMailModel(QObject* o = NULL) : AbstractModel(o) - { - } - public slots: - void loginFinished() - { - QNetworkReply* rep = qobject_cast<QNetworkReply*>(sender()); - rep->deleteLater(); - qDebug() << rep->error() << rep->errorString(); - emit loginComplete(rep->error() == QNetworkReply::NoError); - } - virtual void login(const QString & u, const QString & p) - { - QNetworkRequest req; - QUrl url("https://mail.google.com/mail/feed/atom"); - url.setUserName(u); - url.setPassword(p); - req.setUrl(url); - QNetworkReply* reply = netAccess.get(req); - reply->ignoreSslErrors(); - connect(reply,SIGNAL(finished()),this,SLOT(loginFinished())); - } - private: - QNetworkAccessManager netAccess; -}; - -class MyView : public QFrame, public virtual Ui::Frame -{ - Q_OBJECT - public: - QString welcomeText; - MyView(QWidget* o = NULL) : QFrame(o) - { - setupUi(this); - connect(loginButton,SIGNAL(clicked()),this,SIGNAL(loginIntent())); - connect(logoutButton,SIGNAL(clicked()),this,SIGNAL(logoutIntent())); - connect(cancelButton,SIGNAL(clicked()),this,SIGNAL(cancelIntent())); - } - - public slots: - - void notifyLogin() - { - QMessageBox::information(this,"Logged In","You are now logged in!"); - emit contIntent(); - } - void notifyTimeout() - { - QMessageBox::information(this,"Timeout...","Sorry, login has timed out"); - emit contIntent(); - } - void notifyWelcome() - { - QMessageBox::information(this,"Welcome!",welcomeText); - } - void notifyError() - { - qDebug() << "notifyError"; - QMessageBox::warning(this,"Not Logged in","Login has failed..."); - emit contIntent(); - } - - void notifyHello(const QString & name) - { - QMessageBox::information(this,"Welcome",QString("Hello ") + name); - } - - signals: - void loginIntent(); - void logoutIntent(); - void cancelIntent(); - void contIntent(); -}; -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - bool use_gmail = QSslSocket::supportsSsl () && !a.arguments().contains("--dummy"); - AbstractModel* model = use_gmail ? (AbstractModel*)new GMailModel() : (AbstractModel*)new DummyModel(); - MyView* view = new MyView(); - SMClass_controller *controller = new SMClass_controller(); - controller->setupStateMachine(); - controller->set_loginButton(view->loginButton); - controller->set_logoutButton(view->logoutButton); - controller->set_cancelButton(view->cancelButton); - view->welcomeText = (use_gmail ?"Please enter your GMail user/password":"Username=user, Password=password"); - QObject::connect(controller,SIGNAL(event_login_action(QString,QString)),model,SLOT(login(QString,QString))); - QObject::connect(controller,SIGNAL(event_notify_loggedIn()),view,SLOT(notifyLogin())); - QObject::connect(controller,SIGNAL(event_notify_error()),view,SLOT(notifyError())); - QObject::connect(controller,SIGNAL(event_notify_hello(QString)),view,SLOT(notifyHello(QString))); - QObject::connect(controller,SIGNAL(event_notify_welcome()),view,SLOT(notifyWelcome())); - QObject::connect(controller,SIGNAL(event_notify_timeout()),view,SLOT(notifyTimeout())); - QObject::connect(model,SIGNAL(loginComplete(bool)),controller,SIGNAL(event_login_complete(bool))); - QObject::connect(view,SIGNAL(loginIntent()),controller,SIGNAL(event_intent_login())); - QObject::connect(view,SIGNAL(cancelIntent()),controller,SIGNAL(event_cancel_login())); - QObject::connect(view,SIGNAL(logoutIntent()),controller,SIGNAL(event_intent_logout())); - QObject::connect(view,SIGNAL(contIntent()),controller,SIGNAL(event_intent_continue())); - QObject::connect(view->usernameEdit,SIGNAL(textChanged(QString)),controller,SLOT(set_username(QString))); - QObject::connect(view->passwordEdit,SIGNAL(textChanged(QString)),controller,SLOT(set_password(QString))); - QObject::connect(view->timeoutSlider,SIGNAL(valueChanged(int)),controller,SLOT(set_loginTimeout(int))); - controller->start(); - view->show(); - return a.exec(); -} -#include <main.moc> |