From 74773151efa5cd71b39350911525402bed5d2f87 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 21 Apr 2009 11:32:10 +0200 Subject: rename QTransition -> QActionTransition --- src/corelib/statemachine/qabstracttransition.cpp | 3 - src/corelib/statemachine/qactiontransition.cpp | 230 +++++++++++++++++++++ src/corelib/statemachine/qactiontransition.h | 96 +++++++++ src/corelib/statemachine/qactiontransition_p.h | 80 +++++++ src/corelib/statemachine/qeventtransition.cpp | 14 +- src/corelib/statemachine/qeventtransition.h | 8 +- src/corelib/statemachine/qeventtransition_p.h | 4 +- src/corelib/statemachine/qsignaltransition.cpp | 8 +- src/corelib/statemachine/qsignaltransition.h | 6 +- src/corelib/statemachine/qsignaltransition_p.h | 4 +- .../statemachine/qstatefinishedtransition.cpp | 10 +- .../statemachine/qstatefinishedtransition.h | 6 +- src/corelib/statemachine/qtransition.cpp | 230 --------------------- src/corelib/statemachine/qtransition.h | 96 --------- src/corelib/statemachine/qtransition_p.h | 80 ------- src/corelib/statemachine/statemachine.pri | 6 +- 16 files changed, 441 insertions(+), 440 deletions(-) create mode 100644 src/corelib/statemachine/qactiontransition.cpp create mode 100644 src/corelib/statemachine/qactiontransition.h create mode 100644 src/corelib/statemachine/qactiontransition_p.h delete mode 100644 src/corelib/statemachine/qtransition.cpp delete mode 100644 src/corelib/statemachine/qtransition.h delete mode 100644 src/corelib/statemachine/qtransition_p.h diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp index aff7475..dfce310 100644 --- a/src/corelib/statemachine/qabstracttransition.cpp +++ b/src/corelib/statemachine/qabstracttransition.cpp @@ -60,9 +60,6 @@ QT_BEGIN_NAMESPACE QStateMachine. QAbstractTransition is part of \l{The State Machine Framework}. - The QTransition class provides a default (action-based) implementation of - the QAbstractTransition interface. - The sourceState() function returns the source of the transition. The targetStates() function returns the targets of the transition. diff --git a/src/corelib/statemachine/qactiontransition.cpp b/src/corelib/statemachine/qactiontransition.cpp new file mode 100644 index 0000000..7c53e15 --- /dev/null +++ b/src/corelib/statemachine/qactiontransition.cpp @@ -0,0 +1,230 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qactiontransition.h" +#include "qactiontransition_p.h" +#include "qstateaction.h" +#include "qstateaction_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QActionTransition + + \brief The QActionTransition class provides an action-based transition. + + \since 4.6 + \ingroup statemachine + + QActionTransition provides an action-based transition; you add actions with + the addAction() function. The transition executes the actions when the + transition is triggered. QActionTransition is part of \l{The State Machine + Framework}. + + The invokeMethodOnTransition() function is used for defining method + invocations that should be performed when a transition is taken. + + \code + QStateMachine machine; + QState *s1 = new QState(); + machine.addState(s1); + QActionTransition *t1 = new QActionTransition(); + QLabel label; + t1->invokeMethodOnTransition(&label, "clear"); + QState *s2 = new QState(); + machine.addState(s2); + t1->setTargetState(s2); + s1->addTransition(t1); + \endcode + + Actions are executed in the order in which they were added. + + \sa QState::addTransition(), QStateAction +*/ + +QActionTransitionPrivate::QActionTransitionPrivate() +{ +} + +QActionTransitionPrivate::~QActionTransitionPrivate() +{ +} + +QActionTransitionPrivate *QActionTransitionPrivate::get(QActionTransition *q) +{ + return q->d_func(); +} + +const QActionTransitionPrivate *QActionTransitionPrivate::get(const QActionTransition *q) +{ + return q->d_func(); +} + +QList QActionTransitionPrivate::actions() const +{ + QList result; + QList::const_iterator it; +#ifdef QT_STATEMACHINE_SOLUTION + const QObjectList &children = q_func()->children(); +#endif + for (it = children.constBegin(); it != children.constEnd(); ++it) { + QStateAction *s = qobject_cast(*it); + if (s) + result.append(s); + } + return result; +} + +/*! + Constructs a new QActionTransition object with the given \a sourceState. +*/ +QActionTransition::QActionTransition(QState *sourceState) + : QAbstractTransition(*new QActionTransitionPrivate, sourceState) +{ +} + +/*! + Constructs a new QActionTransition object with the given \a targets and \a + sourceState. +*/ +QActionTransition::QActionTransition(const QList &targets, QState *sourceState) + : QAbstractTransition(*new QActionTransitionPrivate, targets, sourceState) +{ +} + +/*! + \internal +*/ +QActionTransition::QActionTransition(QActionTransitionPrivate &dd, QState *parent) + : QAbstractTransition(dd, parent) +{ +} + +/*! + \internal +*/ +QActionTransition::QActionTransition(QActionTransitionPrivate &dd, const QList &targets, QState *parent) + : QAbstractTransition(dd, targets, parent) +{ +} + +/*! + Destroys this transition. +*/ +QActionTransition::~QActionTransition() +{ +} + +/*! + Instructs this QActionTransition to invoke the given \a method of the given \a + object with the given \a arguments when the transition is taken. This + function will create a QStateInvokeMethodAction object and add it to the + actions of the transition. +*/ +void QActionTransition::invokeMethodOnTransition(QObject *object, const char *method, + const QList &arguments) +{ + addAction(new QStateInvokeMethodAction(object, method, arguments)); +} + +/*! + Adds the given \a action to this transition. + The action will be executed when the transition is triggered. + The transition takes ownership of the action. + + \sa removeAction() +*/ +void QActionTransition::addAction(QStateAction *action) +{ + if (!action) { + qWarning("QActionTransition::addAction: cannot add null action"); + return; + } + action->setParent(this); +} + +/*! + Removes the given \a action from this transition. + The transition releases ownership of the action. + + \sa addAction() +*/ +void QActionTransition::removeAction(QStateAction *action) +{ + if (!action) { + qWarning("QActionTransition::removeAction: cannot remove null action"); + return; + } + action->setParent(0); +} + +/*! + Returns this transitions's actions, or an empty list if the transition has + no actions. + + \sa addAction() +*/ +QList QActionTransition::actions() const +{ + Q_D(const QActionTransition); + return d->actions(); +} + +/*! + \reimp +*/ +void QActionTransition::onTransition() +{ + Q_D(QActionTransition); + QList actions = d->actions(); + for (int i = 0; i < actions.size(); ++i) + QStateActionPrivate::get(actions.at(i))->callExecute(); +} + +/*! + \reimp +*/ +bool QActionTransition::event(QEvent *e) +{ + return QAbstractTransition::event(e); +} + +QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qactiontransition.h b/src/corelib/statemachine/qactiontransition.h new file mode 100644 index 0000000..1a779fa --- /dev/null +++ b/src/corelib/statemachine/qactiontransition.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QACTIONTRANSITION_H +#define QACTIONTRANSITION_H + +#ifndef QT_STATEMACHINE_SOLUTION +#include +#else +#include "qabstracttransition.h" +#endif + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Core) + +class QStateAction; + +class QActionTransitionPrivate; +class Q_CORE_EXPORT QActionTransition : public QAbstractTransition +{ + Q_OBJECT +public: + QActionTransition(QState *sourceState = 0); + QActionTransition(const QList &targets, QState *sourceState = 0); + ~QActionTransition(); + + void invokeMethodOnTransition(QObject *object, const char *method, + const QList &args = QList()); + + void addAction(QStateAction *action); + void removeAction(QStateAction *action); + QList actions() const; + +protected: + virtual void onTransition(); + + bool event(QEvent *e); + +protected: + QActionTransition(QActionTransitionPrivate &dd, QState *parent); + QActionTransition(QActionTransitionPrivate &dd, const QList &targets, QState *parent); + +private: + Q_DISABLE_COPY(QActionTransition) + Q_DECLARE_PRIVATE(QActionTransition) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/corelib/statemachine/qactiontransition_p.h b/src/corelib/statemachine/qactiontransition_p.h new file mode 100644 index 0000000..34f80d1 --- /dev/null +++ b/src/corelib/statemachine/qactiontransition_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QACTIONTRANSITION_P_H +#define QACTIONTRANSITION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qabstracttransition_p.h" + +#include + +QT_BEGIN_NAMESPACE + +class QStateAction; + +class QActionTransition; +class Q_CORE_EXPORT QActionTransitionPrivate : public QAbstractTransitionPrivate +{ + Q_DECLARE_PUBLIC(QActionTransition) +public: + QActionTransitionPrivate(); + ~QActionTransitionPrivate(); + + static QActionTransitionPrivate *get(QActionTransition *q); + static const QActionTransitionPrivate *get(const QActionTransition *q); + + QList actions() const; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/corelib/statemachine/qeventtransition.cpp b/src/corelib/statemachine/qeventtransition.cpp index 078253a..87ed77a 100644 --- a/src/corelib/statemachine/qeventtransition.cpp +++ b/src/corelib/statemachine/qeventtransition.cpp @@ -129,7 +129,7 @@ void QEventTransitionPrivate::invalidate() Constructs a new QEventTransition object with the given \a sourceState. */ QEventTransition::QEventTransition(QState *sourceState) - : QTransition(*new QEventTransitionPrivate, sourceState) + : QActionTransition(*new QEventTransitionPrivate, sourceState) { } @@ -139,7 +139,7 @@ QEventTransition::QEventTransition(QState *sourceState) */ QEventTransition::QEventTransition(QObject *object, QEvent::Type type, QState *sourceState) - : QTransition(*new QEventTransitionPrivate, sourceState) + : QActionTransition(*new QEventTransitionPrivate, sourceState) { Q_D(QEventTransition); d->registered = false; @@ -155,7 +155,7 @@ QEventTransition::QEventTransition(QObject *object, QEvent::Type type, QEventTransition::QEventTransition(QObject *object, QEvent::Type type, const QList &targets, QState *sourceState) - : QTransition(*new QEventTransitionPrivate, targets, sourceState) + : QActionTransition(*new QEventTransitionPrivate, targets, sourceState) { Q_D(QEventTransition); d->registered = false; @@ -167,7 +167,7 @@ QEventTransition::QEventTransition(QObject *object, QEvent::Type type, \internal */ QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QState *parent) - : QTransition(dd, parent) + : QActionTransition(dd, parent) { } @@ -176,7 +176,7 @@ QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QState *parent) */ QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object, QEvent::Type type, QState *parent) - : QTransition(dd, parent) + : QActionTransition(dd, parent) { Q_D(QEventTransition); d->registered = false; @@ -190,7 +190,7 @@ QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object, QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object, QEvent::Type type, const QList &targets, QState *parent) - : QTransition(dd, targets, parent) + : QActionTransition(dd, targets, parent) { Q_D(QEventTransition); d->registered = false; @@ -286,7 +286,7 @@ bool QEventTransition::testEventCondition(QEvent *event) const */ bool QEventTransition::event(QEvent *e) { - return QTransition::event(e); + return QActionTransition::event(e); } QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qeventtransition.h b/src/corelib/statemachine/qeventtransition.h index edd7f8a..21a696c 100644 --- a/src/corelib/statemachine/qeventtransition.h +++ b/src/corelib/statemachine/qeventtransition.h @@ -42,7 +42,11 @@ #ifndef QEVENTTRANSITION_H #define QEVENTTRANSITION_H -#include "qtransition.h" +#ifndef QT_STATEMACHINE_SOLUTION +#include +#else +#include "qactiontransition.h" +#endif #include QT_BEGIN_HEADER @@ -52,7 +56,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) class QEventTransitionPrivate; -class Q_CORE_EXPORT QEventTransition : public QTransition +class Q_CORE_EXPORT QEventTransition : public QActionTransition { Q_OBJECT Q_PROPERTY(QObject* object READ eventSource WRITE setEventSource) diff --git a/src/corelib/statemachine/qeventtransition_p.h b/src/corelib/statemachine/qeventtransition_p.h index 568e35e..2bb5aaa 100644 --- a/src/corelib/statemachine/qeventtransition_p.h +++ b/src/corelib/statemachine/qeventtransition_p.h @@ -53,12 +53,12 @@ // We mean it. // -#include "qtransition_p.h" +#include "qactiontransition_p.h" QT_BEGIN_NAMESPACE class QEventTransition; -class Q_CORE_EXPORT QEventTransitionPrivate : public QTransitionPrivate +class Q_CORE_EXPORT QEventTransitionPrivate : public QActionTransitionPrivate { Q_DECLARE_PUBLIC(QEventTransition) public: diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp index 64e2952..32f2d02 100644 --- a/src/corelib/statemachine/qsignaltransition.cpp +++ b/src/corelib/statemachine/qsignaltransition.cpp @@ -137,7 +137,7 @@ void QSignalTransitionPrivate::invalidate() Constructs a new signal transition with the given \a sourceState. */ QSignalTransition::QSignalTransition(QState *sourceState) - : QTransition(*new QSignalTransitionPrivate, sourceState) + : QActionTransition(*new QSignalTransitionPrivate, sourceState) { } @@ -147,7 +147,7 @@ QSignalTransition::QSignalTransition(QState *sourceState) */ QSignalTransition::QSignalTransition(QObject *sender, const char *signal, QState *sourceState) - : QTransition(*new QSignalTransitionPrivate, sourceState) + : QActionTransition(*new QSignalTransitionPrivate, sourceState) { Q_D(QSignalTransition); d->sender = sender; @@ -162,7 +162,7 @@ QSignalTransition::QSignalTransition(QObject *sender, const char *signal, QSignalTransition::QSignalTransition(QObject *sender, const char *signal, const QList &targets, QState *sourceState) - : QTransition(*new QSignalTransitionPrivate, targets, sourceState) + : QActionTransition(*new QSignalTransitionPrivate, targets, sourceState) { Q_D(QSignalTransition); d->sender = sender; @@ -247,7 +247,7 @@ bool QSignalTransition::eventTest(QEvent *event) const */ bool QSignalTransition::event(QEvent *e) { - return QTransition::event(e); + return QActionTransition::event(e); } QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h index ba4af17..c1a41ae 100644 --- a/src/corelib/statemachine/qsignaltransition.h +++ b/src/corelib/statemachine/qsignaltransition.h @@ -43,9 +43,9 @@ #define QSIGNALTRANSITION_H #ifndef QT_STATEMACHINE_SOLUTION -#include +#include #else -#include "qtransition.h" +#include "qactiontransition.h" #endif QT_BEGIN_HEADER @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) class QSignalTransitionPrivate; -class Q_CORE_EXPORT QSignalTransition : public QTransition +class Q_CORE_EXPORT QSignalTransition : public QActionTransition { Q_OBJECT Q_PROPERTY(QObject* object READ senderObject WRITE setSenderObject) diff --git a/src/corelib/statemachine/qsignaltransition_p.h b/src/corelib/statemachine/qsignaltransition_p.h index c5fbcfc..bd815d9 100644 --- a/src/corelib/statemachine/qsignaltransition_p.h +++ b/src/corelib/statemachine/qsignaltransition_p.h @@ -53,12 +53,12 @@ // We mean it. // -#include "qtransition_p.h" +#include "qactiontransition_p.h" QT_BEGIN_NAMESPACE class QSignalTransition; -class QSignalTransitionPrivate : public QTransitionPrivate +class QSignalTransitionPrivate : public QActionTransitionPrivate { Q_DECLARE_PUBLIC(QSignalTransition) public: diff --git a/src/corelib/statemachine/qstatefinishedtransition.cpp b/src/corelib/statemachine/qstatefinishedtransition.cpp index 24d2ca4..33c3d22 100644 --- a/src/corelib/statemachine/qstatefinishedtransition.cpp +++ b/src/corelib/statemachine/qstatefinishedtransition.cpp @@ -41,7 +41,7 @@ #include "qstatefinishedtransition.h" #include "qstatefinishedevent.h" -#include "qtransition_p.h" +#include "qactiontransition_p.h" QT_BEGIN_NAMESPACE @@ -80,7 +80,7 @@ QT_BEGIN_NAMESPACE \brief the state whose QStateFinishedEvent this transition is associated with */ -class QStateFinishedTransitionPrivate : public QTransitionPrivate +class QStateFinishedTransitionPrivate : public QActionTransitionPrivate { Q_DECLARE_PUBLIC(QStateFinishedTransition) public: @@ -106,7 +106,7 @@ QStateFinishedTransitionPrivate *QStateFinishedTransitionPrivate::get(QStateFini sourceState. */ QStateFinishedTransition::QStateFinishedTransition(QState *sourceState) - : QTransition(*new QStateFinishedTransitionPrivate, sourceState) + : QActionTransition(*new QStateFinishedTransitionPrivate, sourceState) { } @@ -116,7 +116,7 @@ QStateFinishedTransition::QStateFinishedTransition(QState *sourceState) */ QStateFinishedTransition::QStateFinishedTransition( QState *state, const QList &targets, QState *sourceState) - : QTransition(*new QStateFinishedTransitionPrivate, targets, sourceState) + : QActionTransition(*new QStateFinishedTransitionPrivate, targets, sourceState) { Q_D(QStateFinishedTransition); d->state = state; @@ -169,7 +169,7 @@ bool QStateFinishedTransition::eventTest(QEvent *event) const */ bool QStateFinishedTransition::event(QEvent *e) { - return QTransition::event(e); + return QActionTransition::event(e); } QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qstatefinishedtransition.h b/src/corelib/statemachine/qstatefinishedtransition.h index eae3143..f9320f5 100644 --- a/src/corelib/statemachine/qstatefinishedtransition.h +++ b/src/corelib/statemachine/qstatefinishedtransition.h @@ -43,9 +43,9 @@ #define QSTATEFINISHEDTRANSITION_H #ifndef QT_STATEMACHINE_SOLUTION -#include +#include #else -#include "qtransition.h" +#include "qactiontransition.h" #endif QT_BEGIN_HEADER @@ -57,7 +57,7 @@ QT_MODULE(Core) class QState; class QStateFinishedTransitionPrivate; -class Q_CORE_EXPORT QStateFinishedTransition : public QTransition +class Q_CORE_EXPORT QStateFinishedTransition : public QActionTransition { Q_OBJECT Q_PROPERTY(QState* state READ state WRITE setState) diff --git a/src/corelib/statemachine/qtransition.cpp b/src/corelib/statemachine/qtransition.cpp deleted file mode 100644 index ec9cc81..0000000 --- a/src/corelib/statemachine/qtransition.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (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 qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtransition.h" -#include "qtransition_p.h" -#include "qstateaction.h" -#include "qstateaction_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QTransition - - \brief The QTransition class provides an action-based transition. - - \since 4.6 - \ingroup statemachine - - QTransition provides an action-based transition; you add actions with the - addAction() function. The transition executes the actions when the - transition is triggered. QTransition is part of \l{The State Machine - Framework}. - - The invokeMethodOnTransition() function is used for defining method - invocations that should be performed when a transition is taken. - - \code - QStateMachine machine; - QState *s1 = new QState(); - machine.addState(s1); - QTransition *t1 = new QTransition(); - QLabel label; - t1->invokeMethodOnTransition(&label, "clear"); - QState *s2 = new QState(); - machine.addState(s2); - t1->setTargetState(s2); - s1->addTransition(t1); - \endcode - - Actions are executed in the order in which they were added. - - \sa QState::addTransition(), QStateAction -*/ - -QTransitionPrivate::QTransitionPrivate() -{ -} - -QTransitionPrivate::~QTransitionPrivate() -{ -} - -QTransitionPrivate *QTransitionPrivate::get(QTransition *q) -{ - return q->d_func(); -} - -const QTransitionPrivate *QTransitionPrivate::get(const QTransition *q) -{ - return q->d_func(); -} - -QList QTransitionPrivate::actions() const -{ - QList result; - QList::const_iterator it; -#ifdef QT_STATEMACHINE_SOLUTION - const QObjectList &children = q_func()->children(); -#endif - for (it = children.constBegin(); it != children.constEnd(); ++it) { - QStateAction *s = qobject_cast(*it); - if (s) - result.append(s); - } - return result; -} - -/*! - Constructs a new QTransition object with the given \a sourceState. -*/ -QTransition::QTransition(QState *sourceState) - : QAbstractTransition(*new QTransitionPrivate, sourceState) -{ -} - -/*! - Constructs a new QTransition object with the given \a targets and \a - sourceState. -*/ -QTransition::QTransition(const QList &targets, QState *sourceState) - : QAbstractTransition(*new QTransitionPrivate, targets, sourceState) -{ -} - -/*! - \internal -*/ -QTransition::QTransition(QTransitionPrivate &dd, QState *parent) - : QAbstractTransition(dd, parent) -{ -} - -/*! - \internal -*/ -QTransition::QTransition(QTransitionPrivate &dd, const QList &targets, QState *parent) - : QAbstractTransition(dd, targets, parent) -{ -} - -/*! - Destroys this transition. -*/ -QTransition::~QTransition() -{ -} - -/*! - Instructs this QTransition to invoke the given \a method of the given \a - object with the given \a arguments when the transition is taken. This - function will create a QStateInvokeMethodAction object and add it to the - actions of the transition. -*/ -void QTransition::invokeMethodOnTransition(QObject *object, const char *method, - const QList &arguments) -{ - addAction(new QStateInvokeMethodAction(object, method, arguments)); -} - -/*! - Adds the given \a action to this transition. - The action will be executed when the transition is triggered. - The transition takes ownership of the action. - - \sa removeAction() -*/ -void QTransition::addAction(QStateAction *action) -{ - if (!action) { - qWarning("QTransition::addAction: cannot add null action"); - return; - } - action->setParent(this); -} - -/*! - Removes the given \a action from this transition. - The transition releases ownership of the action. - - \sa addAction() -*/ -void QTransition::removeAction(QStateAction *action) -{ - if (!action) { - qWarning("QTransition::removeAction: cannot remove null action"); - return; - } - action->setParent(0); -} - -/*! - Returns this transitions's actions, or an empty list if the transition has - no actions. - - \sa addAction() -*/ -QList QTransition::actions() const -{ - Q_D(const QTransition); - return d->actions(); -} - -/*! - \reimp -*/ -void QTransition::onTransition() -{ - Q_D(QTransition); - QList actions = d->actions(); - for (int i = 0; i < actions.size(); ++i) - QStateActionPrivate::get(actions.at(i))->callExecute(); -} - -/*! - \reimp -*/ -bool QTransition::event(QEvent *e) -{ - return QAbstractTransition::event(e); -} - -QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qtransition.h b/src/corelib/statemachine/qtransition.h deleted file mode 100644 index 7eec136..0000000 --- a/src/corelib/statemachine/qtransition.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (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 qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTRANSITION_H -#define QTRANSITION_H - -#ifndef QT_STATEMACHINE_SOLUTION -#include -#else -#include "qabstracttransition.h" -#endif - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Core) - -class QStateAction; - -class QTransitionPrivate; -class Q_CORE_EXPORT QTransition : public QAbstractTransition -{ - Q_OBJECT -public: - QTransition(QState *sourceState = 0); - QTransition(const QList &targets, QState *sourceState = 0); - ~QTransition(); - - void invokeMethodOnTransition(QObject *object, const char *method, - const QList &args = QList()); - - void addAction(QStateAction *action); - void removeAction(QStateAction *action); - QList actions() const; - -protected: - virtual void onTransition(); - - bool event(QEvent *e); - -protected: - QTransition(QTransitionPrivate &dd, QState *parent); - QTransition(QTransitionPrivate &dd, const QList &targets, QState *parent); - -private: - Q_DISABLE_COPY(QTransition) - Q_DECLARE_PRIVATE(QTransition) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/corelib/statemachine/qtransition_p.h b/src/corelib/statemachine/qtransition_p.h deleted file mode 100644 index d43a4d4..0000000 --- a/src/corelib/statemachine/qtransition_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (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 qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTRANSITION_P_H -#define QTRANSITION_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qabstracttransition_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QStateAction; - -class QTransition; -class Q_CORE_EXPORT QTransitionPrivate : public QAbstractTransitionPrivate -{ - Q_DECLARE_PUBLIC(QTransition) -public: - QTransitionPrivate(); - ~QTransitionPrivate(); - - static QTransitionPrivate *get(QTransition *q); - static const QTransitionPrivate *get(const QTransition *q); - - QList actions() const; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/corelib/statemachine/statemachine.pri b/src/corelib/statemachine/statemachine.pri index 9c797e2..4179e45 100644 --- a/src/corelib/statemachine/statemachine.pri +++ b/src/corelib/statemachine/statemachine.pri @@ -14,8 +14,8 @@ HEADERS += $$PWD/qstatemachine.h \ $$PWD/qhistorystate_p.h \ $$PWD/qabstracttransition.h \ $$PWD/qabstracttransition_p.h \ - $$PWD/qtransition.h \ - $$PWD/qtransition_p.h \ + $$PWD/qactiontransition.h \ + $$PWD/qactiontransition_p.h \ $$PWD/qstatefinishedevent.h \ $$PWD/qstatefinishedtransition.h \ $$PWD/qsignalevent.h \ @@ -30,7 +30,7 @@ SOURCES += $$PWD/qstatemachine.cpp \ $$PWD/qfinalstate.cpp \ $$PWD/qhistorystate.cpp \ $$PWD/qabstracttransition.cpp \ - $$PWD/qtransition.cpp \ + $$PWD/qactiontransition.cpp \ $$PWD/qstatefinishedtransition.cpp \ $$PWD/qsignaltransition.cpp -- cgit v0.12