diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-04-22 15:20:19 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-04-22 15:20:19 (GMT) |
commit | f87641584424deed25e2abdadea08c3be94b9ce1 (patch) | |
tree | a185687744e724a8db896970416f23d20f5cad38 /src/corelib/statemachine | |
parent | 31f5348ea1691a7664b6abc04cf425dd02637b33 (diff) | |
download | Qt-f87641584424deed25e2abdadea08c3be94b9ce1.zip Qt-f87641584424deed25e2abdadea08c3be94b9ce1.tar.gz Qt-f87641584424deed25e2abdadea08c3be94b9ce1.tar.bz2 |
kill the stateactions api
It just didn't give us that much.
Typically you just reimplement onEntry/onExit/onTransition
when you want to do something.
We go back to the signals-and-slots approach: states have
entered() and exited() signals that you can connect to.
It's still possible to have an action-based API, but then
you build it on top of the core API, which is OK.
Replacing 4 public classes (and one layer in the hierarchy)
with 2 signals feels good.
Diffstat (limited to 'src/corelib/statemachine')
29 files changed, 112 insertions, 1533 deletions
diff --git a/src/corelib/statemachine/qabstractstate.cpp b/src/corelib/statemachine/qabstractstate.cpp index 89dcff9..030c63c 100644 --- a/src/corelib/statemachine/qabstractstate.cpp +++ b/src/corelib/statemachine/qabstractstate.cpp @@ -62,6 +62,9 @@ QT_BEGIN_NAMESPACE The assignProperty() function is used for defining property assignments that should be performed when a state is entered. + The entered() signal is emitted when the state has been entered. The + exited() signal is emitted when the state has been exited. + The parentState() function returns the state's parent state. \section1 Subclassing @@ -149,6 +152,18 @@ void QAbstractStatePrivate::callOnExit() q->onExit(); } +void QAbstractStatePrivate::emitEntered() +{ + Q_Q(QAbstractState); + emit q->entered(); +} + +void QAbstractStatePrivate::emitExited() +{ + Q_Q(QAbstractState); + emit q->exited(); +} + /*! Constructs a new state with the given \a parent state. */ @@ -256,6 +271,20 @@ QAbstractState::RestorePolicy QAbstractState::restorePolicy() const */ /*! + \fn QAbstractState::entered() + + This signal is emitted when the state has been entered (after onEntry() has + been called). +*/ + +/*! + \fn QAbstractState::exited() + + This signal is emitted when the state has been exited (after onExit() has + been called). +*/ + +/*! \reimp */ bool QAbstractState::event(QEvent *e) diff --git a/src/corelib/statemachine/qabstractstate.h b/src/corelib/statemachine/qabstractstate.h index b788a88..55e9a62 100644 --- a/src/corelib/statemachine/qabstractstate.h +++ b/src/corelib/statemachine/qabstractstate.h @@ -75,6 +75,10 @@ public: void setRestorePolicy(RestorePolicy restorePolicy); RestorePolicy restorePolicy() const; +Q_SIGNALS: + void entered(); + void exited(); + protected: QAbstractState(QState *parent = 0); diff --git a/src/corelib/statemachine/qabstractstate_p.h b/src/corelib/statemachine/qabstractstate_p.h index 7c565f0..e47fbd2 100644 --- a/src/corelib/statemachine/qabstractstate_p.h +++ b/src/corelib/statemachine/qabstractstate_p.h @@ -98,6 +98,9 @@ public: void callOnEntry(); void callOnExit(); + void emitEntered(); + void emitExited(); + QAbstractState::RestorePolicy restorePolicy; QList<QPropertyAssignment> propertyAssignments; diff --git a/src/corelib/statemachine/qactionstate.cpp b/src/corelib/statemachine/qactionstate.cpp deleted file mode 100644 index 1da0350..0000000 --- a/src/corelib/statemachine/qactionstate.cpp +++ /dev/null @@ -1,293 +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 "qactionstate.h" -#include "qactionstate_p.h" -#include "qstateaction.h" -#include "qstateaction_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QActionState - - \brief The QActionState class provides an action-based state. - - \since 4.6 - \ingroup statemachine - - QActionState executes \l{QStateAction}{state actions} when the state is - entered and exited. QActionState is part of \l{The State Machine Framework}. - - You can add actions to a state with the addEntryAction() and addExitAction() - functions. The state executes the actions when the state is entered and - exited, respectively. - - The invokeMethodOnEntry() and invokeMethodOnExit() functions are used for - defining method invocations that should be performed when a state is entered - and exited, respectively. - - \code - QState *s2 = new QState(); - s2->invokeMethodOnEntry(&label, "showMaximized"); - machine.addState(s2); - \endcode - - \sa QStateAction -*/ - -QActionStatePrivate::QActionStatePrivate() -{ -} - -QActionStatePrivate::~QActionStatePrivate() -{ -} - -QActionStatePrivate *QActionStatePrivate::get(QActionState *q) -{ - return q->d_func(); -} - -const QActionStatePrivate *QActionStatePrivate::get(const QActionState *q) -{ - return q->d_func(); -} - -QList<QStateAction*> QActionStatePrivate::entryActions() const -{ - QList<QStateAction*> result; - QList<QObject*>::const_iterator it; -#ifdef QT_STATEMACHINE_SOLUTION - const QObjectList &children = q_func()->children(); -#endif - for (it = children.constBegin(); it != children.constEnd(); ++it) { - QStateAction *act = qobject_cast<QStateAction*>(*it); - if (act && (QStateActionPrivate::get(act)->when == QStateActionPrivate::ExecuteOnEntry)) - result.append(act); - } - return result; -} - -QList<QStateAction*> QActionStatePrivate::exitActions() const -{ - QList<QStateAction*> result; - QList<QObject*>::const_iterator it; -#ifdef QT_STATEMACHINE_SOLUTION - const QObjectList &children = q_func()->children(); -#endif - for (it = children.constBegin(); it != children.constEnd(); ++it) { - QStateAction *act = qobject_cast<QStateAction*>(*it); - if (act && (QStateActionPrivate::get(act)->when == QStateActionPrivate::ExecuteOnExit)) - result.append(act); - } - return result; -} - -/*! - Constructs a new action state with the given \a parent state. -*/ -QActionState::QActionState(QState *parent) - : QAbstractState(*new QActionStatePrivate, parent) -{ -} - -/*! - \internal -*/ -QActionState::QActionState(QActionStatePrivate &dd, - QState *parent) - : QAbstractState(dd, parent) -{ -} - -/*! - Destroys this action state. -*/ -QActionState::~QActionState() -{ -} - -/*! - Instructs this state to invoke the given \a method of the given \a object - with the given \a arguments when the state is entered. This function will - create a QStateInvokeMethodAction object and add it to the entry actions of - the state. - - \sa invokeMethodOnExit(), addEntryAction() -*/ -void QActionState::invokeMethodOnEntry(QObject *object, const char *method, - const QList<QVariant> &arguments) -{ - addEntryAction(new QStateInvokeMethodAction(object, method, arguments)); -} - -/*! - Instructs this state to invoke the given \a method of the given \a object - with the given \a arguments when the state is exited. This function will - create a QStateInvokeMethodAction object and add it to the exit actions of - the state. - - \sa invokeMethodOnEntry(), addExitAction() -*/ -void QActionState::invokeMethodOnExit(QObject *object, const char *method, - const QList<QVariant> &arguments) -{ - addExitAction(new QStateInvokeMethodAction(object, method, arguments)); -} - -/*! - Adds the given \a action to this state. The action will be executed when - this state is entered. The state takes ownership of the action. - - \sa addExitAction(), removeEntryAction() -*/ -void QActionState::addEntryAction(QStateAction *action) -{ - if (!action) { - qWarning("QActionState::addEntryAction: cannot add null action"); - return; - } - action->setParent(this); - QStateActionPrivate::get(action)->when = QStateActionPrivate::ExecuteOnEntry; -} - -/*! - Adds the given \a action to this state. The action will be executed when - this state is exited. The state takes ownership of the action. - - \sa addEntryAction(), removeExitAction() -*/ -void QActionState::addExitAction(QStateAction *action) -{ - if (!action) { - qWarning("QActionState::addExitAction: cannot add null action"); - return; - } - action->setParent(this); - QStateActionPrivate::get(action)->when = QStateActionPrivate::ExecuteOnExit; -} - -/*! - Removes the given entry \a action from this state. The state releases - ownership of the action. - - \sa addEntryAction() -*/ -void QActionState::removeEntryAction(QStateAction *action) -{ - if (!action) { - qWarning("QActionState::removeEntryAction: cannot remove null action"); - return; - } - if (action->parent() == this) - action->setParent(0); -} - -/*! - Removes the given exit \a action from this state. The state releases - ownership of the action. - - \sa addExitAction() -*/ -void QActionState::removeExitAction(QStateAction *action) -{ - if (!action) { - qWarning("QActionState::removeExitAction: cannot remove null action"); - return; - } - if (action->parent() == this) - action->setParent(0); -} - -/*! - Returns this state's entry actions. - - \sa addEntryAction(), exitActions() -*/ -QList<QStateAction*> QActionState::entryActions() const -{ - Q_D(const QActionState); - return d->entryActions(); -} - -/*! - Returns this state's exit actions. - - \sa addExitAction(), entryActions() -*/ -QList<QStateAction*> QActionState::exitActions() const -{ - Q_D(const QActionState); - return d->exitActions(); -} - -/*! - \reimp -*/ -void QActionState::onEntry() -{ - Q_D(QActionState); - QList<QStateAction*> actions = d->entryActions(); - for (int i = 0; i < actions.size(); ++i) - QStateActionPrivate::get(actions.at(i))->callExecute(); -} - -/*! - \reimp -*/ -void QActionState::onExit() -{ - Q_D(QActionState); - QList<QStateAction*> actions = d->exitActions(); - for (int i = 0; i < actions.size(); ++i) - QStateActionPrivate::get(actions.at(i))->callExecute(); -} - -/*! - \reimp -*/ -bool QActionState::event(QEvent *e) -{ - return QAbstractState::event(e); -} - -QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qactionstate.h b/src/corelib/statemachine/qactionstate.h deleted file mode 100644 index 517b4b2..0000000 --- a/src/corelib/statemachine/qactionstate.h +++ /dev/null @@ -1,102 +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 QACTIONSTATE_H -#define QACTIONSTATE_H - -#ifndef QT_STATEMACHINE_SOLUTION -#include <QtCore/qabstractstate.h> -#else -#include "qabstractstate.h" -#endif - -#include <QtCore/qlist.h> -#include <QtCore/qvariant.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Core) - -class QStateAction; - -class QActionStatePrivate; -class Q_CORE_EXPORT QActionState : public QAbstractState -{ - Q_OBJECT -public: - QActionState(QState *parent = 0); - ~QActionState(); - - void invokeMethodOnEntry(QObject *object, const char *method, - const QList<QVariant> &args = QList<QVariant>()); - void invokeMethodOnExit(QObject *object, const char *method, - const QList<QVariant> &args = QList<QVariant>()); - - void addEntryAction(QStateAction *action); - void addExitAction(QStateAction *action); - - void removeEntryAction(QStateAction *action); - void removeExitAction(QStateAction *action); - - QList<QStateAction*> entryActions() const; - QList<QStateAction*> exitActions() const; - -protected: - void onEntry(); - void onExit(); - - bool event(QEvent *e); - -protected: - QActionState(QActionStatePrivate &dd, QState *parent); - -private: - Q_DISABLE_COPY(QActionState) - Q_DECLARE_PRIVATE(QActionState) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/corelib/statemachine/qactionstate_p.h b/src/corelib/statemachine/qactionstate_p.h deleted file mode 100644 index a06dde2..0000000 --- a/src/corelib/statemachine/qactionstate_p.h +++ /dev/null @@ -1,83 +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 QACTIONSTATE_P_H -#define QACTIONSTATE_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 "qabstractstate_p.h" -#include "qactionstate.h" - -#include <QtCore/qlist.h> - -QT_BEGIN_NAMESPACE - -class QStateAction; - -class QActionState; -class Q_CORE_EXPORT QActionStatePrivate : public QAbstractStatePrivate -{ - Q_DECLARE_PUBLIC(QActionState) - -public: - QActionStatePrivate(); - ~QActionStatePrivate(); - - static QActionStatePrivate *get(QActionState *q); - static const QActionStatePrivate *get(const QActionState *q); - - QList<QStateAction*> entryActions() const; - QList<QStateAction*> exitActions() const; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/corelib/statemachine/qactiontransition.cpp b/src/corelib/statemachine/qactiontransition.cpp deleted file mode 100644 index 7c53e15..0000000 --- a/src/corelib/statemachine/qactiontransition.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 "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<QStateAction*> QActionTransitionPrivate::actions() const -{ - QList<QStateAction*> result; - QList<QObject*>::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<QStateAction*>(*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<QAbstractState*> &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<QAbstractState*> &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<QVariant> &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<QStateAction*> QActionTransition::actions() const -{ - Q_D(const QActionTransition); - return d->actions(); -} - -/*! - \reimp -*/ -void QActionTransition::onTransition() -{ - Q_D(QActionTransition); - QList<QStateAction*> 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 deleted file mode 100644 index 1a779fa..0000000 --- a/src/corelib/statemachine/qactiontransition.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 QACTIONTRANSITION_H -#define QACTIONTRANSITION_H - -#ifndef QT_STATEMACHINE_SOLUTION -#include <QtCore/qabstracttransition.h> -#else -#include "qabstracttransition.h" -#endif - -#include <QtCore/qvariant.h> -#include <QtCore/qlist.h> - -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<QAbstractState*> &targets, QState *sourceState = 0); - ~QActionTransition(); - - void invokeMethodOnTransition(QObject *object, const char *method, - const QList<QVariant> &args = QList<QVariant>()); - - void addAction(QStateAction *action); - void removeAction(QStateAction *action); - QList<QStateAction*> actions() const; - -protected: - virtual void onTransition(); - - bool event(QEvent *e); - -protected: - QActionTransition(QActionTransitionPrivate &dd, QState *parent); - QActionTransition(QActionTransitionPrivate &dd, const QList<QAbstractState*> &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 deleted file mode 100644 index 34f80d1..0000000 --- a/src/corelib/statemachine/qactiontransition_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 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 <QtCore/qlist.h> - -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<QStateAction*> actions() const; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/corelib/statemachine/qeventtransition.cpp b/src/corelib/statemachine/qeventtransition.cpp index 87ed77a..09b89f3 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) - : QActionTransition(*new QEventTransitionPrivate, sourceState) + : QAbstractTransition(*new QEventTransitionPrivate, sourceState) { } @@ -139,7 +139,7 @@ QEventTransition::QEventTransition(QState *sourceState) */ QEventTransition::QEventTransition(QObject *object, QEvent::Type type, QState *sourceState) - : QActionTransition(*new QEventTransitionPrivate, sourceState) + : QAbstractTransition(*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<QAbstractState*> &targets, QState *sourceState) - : QActionTransition(*new QEventTransitionPrivate, targets, sourceState) + : QAbstractTransition(*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) - : QActionTransition(dd, parent) + : QAbstractTransition(dd, parent) { } @@ -176,7 +176,7 @@ QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QState *parent) */ QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object, QEvent::Type type, QState *parent) - : QActionTransition(dd, parent) + : QAbstractTransition(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<QAbstractState*> &targets, QState *parent) - : QActionTransition(dd, targets, parent) + : QAbstractTransition(dd, targets, parent) { Q_D(QEventTransition); d->registered = false; @@ -268,6 +268,13 @@ bool QEventTransition::eventTest(QEvent *event) const } /*! + \reimp +*/ +void QEventTransition::onTransition() +{ +} + +/*! Tests an instance of an event associated with this event transition and returns true if the transition should be taken, otherwise returns false. The type of the given \a event will be eventType(). @@ -286,7 +293,7 @@ bool QEventTransition::testEventCondition(QEvent *event) const */ bool QEventTransition::event(QEvent *e) { - return QActionTransition::event(e); + return QAbstractTransition::event(e); } QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qeventtransition.h b/src/corelib/statemachine/qeventtransition.h index 21a696c..e19b5af 100644 --- a/src/corelib/statemachine/qeventtransition.h +++ b/src/corelib/statemachine/qeventtransition.h @@ -43,9 +43,9 @@ #define QEVENTTRANSITION_H #ifndef QT_STATEMACHINE_SOLUTION -#include <QtCore/qactiontransition.h> +#include <QtCore/qabstracttransition.h> #else -#include "qactiontransition.h" +#include "qabstracttransition.h" #endif #include <QtCore/qcoreevent.h> @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) class QEventTransitionPrivate; -class Q_CORE_EXPORT QEventTransition : public QActionTransition +class Q_CORE_EXPORT QEventTransition : public QAbstractTransition { Q_OBJECT Q_PROPERTY(QObject* object READ eventSource WRITE setEventSource) @@ -80,6 +80,7 @@ protected: virtual bool testEventCondition(QEvent *event) const; // ### name bool eventTest(QEvent *event) const; + void onTransition(); bool event(QEvent *e); diff --git a/src/corelib/statemachine/qeventtransition_p.h b/src/corelib/statemachine/qeventtransition_p.h index 2bb5aaa..fca8c0d 100644 --- a/src/corelib/statemachine/qeventtransition_p.h +++ b/src/corelib/statemachine/qeventtransition_p.h @@ -53,12 +53,12 @@ // We mean it. // -#include "qactiontransition_p.h" +#include "qabstracttransition_p.h" QT_BEGIN_NAMESPACE class QEventTransition; -class Q_CORE_EXPORT QEventTransitionPrivate : public QActionTransitionPrivate +class Q_CORE_EXPORT QEventTransitionPrivate : public QAbstractTransitionPrivate { Q_DECLARE_PUBLIC(QEventTransition) public: diff --git a/src/corelib/statemachine/qfinalstate.cpp b/src/corelib/statemachine/qfinalstate.cpp index abf9d2e..16e080e 100644 --- a/src/corelib/statemachine/qfinalstate.cpp +++ b/src/corelib/statemachine/qfinalstate.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qfinalstate.h" -#include "qactionstate_p.h" +#include "qabstractstate_p.h" QT_BEGIN_NAMESPACE @@ -80,7 +80,7 @@ QT_BEGIN_NAMESPACE \sa QStateFinishedTransition */ -class QFinalStatePrivate : public QActionStatePrivate +class QFinalStatePrivate : public QAbstractStatePrivate { Q_DECLARE_PUBLIC(QFinalState) @@ -96,7 +96,7 @@ QFinalStatePrivate::QFinalStatePrivate() Constructs a new QFinalState object with the given \a parent state. */ QFinalState::QFinalState(QState *parent) - : QActionState(*new QFinalStatePrivate, parent) + : QAbstractState(*new QFinalStatePrivate, parent) { } @@ -112,7 +112,6 @@ QFinalState::~QFinalState() */ void QFinalState::onEntry() { - QActionState::onEntry(); } /*! @@ -120,7 +119,6 @@ void QFinalState::onEntry() */ void QFinalState::onExit() { - QActionState::onExit(); } /*! @@ -128,7 +126,7 @@ void QFinalState::onExit() */ bool QFinalState::event(QEvent *e) { - return QActionState::event(e); + return QAbstractState::event(e); } QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qfinalstate.h b/src/corelib/statemachine/qfinalstate.h index 36813f5..726a399 100644 --- a/src/corelib/statemachine/qfinalstate.h +++ b/src/corelib/statemachine/qfinalstate.h @@ -43,9 +43,9 @@ #define QFINALSTATE_H #ifndef QT_STATEMACHINE_SOLUTION -#include <QtCore/qactionstate.h> +#include <QtCore/qabstractstate.h> #else -#include "qactionstate.h" +#include "qabstractstate.h" #endif QT_BEGIN_HEADER @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) class QFinalStatePrivate; -class Q_CORE_EXPORT QFinalState : public QActionState +class Q_CORE_EXPORT QFinalState : public QAbstractState { Q_OBJECT public: diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp index 32f2d02..064ac6e 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) - : QActionTransition(*new QSignalTransitionPrivate, sourceState) + : QAbstractTransition(*new QSignalTransitionPrivate, sourceState) { } @@ -147,7 +147,7 @@ QSignalTransition::QSignalTransition(QState *sourceState) */ QSignalTransition::QSignalTransition(QObject *sender, const char *signal, QState *sourceState) - : QActionTransition(*new QSignalTransitionPrivate, sourceState) + : QAbstractTransition(*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<QAbstractState*> &targets, QState *sourceState) - : QActionTransition(*new QSignalTransitionPrivate, targets, sourceState) + : QAbstractTransition(*new QSignalTransitionPrivate, targets, sourceState) { Q_D(QSignalTransition); d->sender = sender; @@ -245,9 +245,16 @@ bool QSignalTransition::eventTest(QEvent *event) const /*! \reimp */ +void QSignalTransition::onTransition() +{ +} + +/*! + \reimp +*/ bool QSignalTransition::event(QEvent *e) { - return QActionTransition::event(e); + return QAbstractTransition::event(e); } QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h index c1a41ae..4df97cf 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 <QtCore/qactiontransition.h> +#include <QtCore/qabstracttransition.h> #else -#include "qactiontransition.h" +#include "qabstracttransition.h" #endif QT_BEGIN_HEADER @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) class QSignalTransitionPrivate; -class Q_CORE_EXPORT QSignalTransition : public QActionTransition +class Q_CORE_EXPORT QSignalTransition : public QAbstractTransition { Q_OBJECT Q_PROPERTY(QObject* object READ senderObject WRITE setSenderObject) @@ -77,6 +77,7 @@ public: protected: bool eventTest(QEvent *event) const; + void onTransition(); bool event(QEvent *e); diff --git a/src/corelib/statemachine/qsignaltransition_p.h b/src/corelib/statemachine/qsignaltransition_p.h index bd815d9..a23e58c 100644 --- a/src/corelib/statemachine/qsignaltransition_p.h +++ b/src/corelib/statemachine/qsignaltransition_p.h @@ -53,12 +53,12 @@ // We mean it. // -#include "qactiontransition_p.h" +#include "qabstracttransition_p.h" QT_BEGIN_NAMESPACE class QSignalTransition; -class QSignalTransitionPrivate : public QActionTransitionPrivate +class QSignalTransitionPrivate : public QAbstractTransitionPrivate { Q_DECLARE_PUBLIC(QSignalTransition) public: diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index 28c84d5..56a855e 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -138,7 +138,7 @@ const QStatePrivate *QStatePrivate::get(const QState *q) Constructs a new state with the given \a parent state. */ QState::QState(QState *parent) - : QActionState(*new QStatePrivate, parent) + : QAbstractState(*new QStatePrivate, parent) { } @@ -146,7 +146,7 @@ QState::QState(QState *parent) Constructs a new state of the given \a type with the given \a parent state. */ QState::QState(Type type, QState *parent) - : QActionState(*new QStatePrivate, parent) + : QAbstractState(*new QStatePrivate, parent) { Q_D(QState); d->isParallelGroup = (type == ParallelGroup); @@ -156,7 +156,7 @@ QState::QState(Type type, QState *parent) \internal */ QState::QState(QStatePrivate &dd, QState *parent) - : QActionState(dd, parent) + : QAbstractState(dd, parent) { } @@ -385,7 +385,6 @@ QHistoryState *QState::addHistoryState(HistoryType type) */ void QState::onEntry() { - QActionState::onEntry(); } /*! @@ -393,7 +392,6 @@ void QState::onEntry() */ void QState::onExit() { - QActionState::onExit(); } /*! @@ -430,7 +428,7 @@ void QState::setInitialState(QAbstractState *state) */ bool QState::event(QEvent *e) { - return QActionState::event(e); + return QAbstractState::event(e); } QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h index 1ec0896..7c64c80 100644 --- a/src/corelib/statemachine/qstate.h +++ b/src/corelib/statemachine/qstate.h @@ -43,9 +43,9 @@ #define QSTATE_H #ifndef QT_STATEMACHINE_SOLUTION -#include <QtCore/qactionstate.h> +#include <QtCore/qabstractstate.h> #else -#include "qactionstate.h" +#include "qabstractstate.h" #endif QT_BEGIN_HEADER @@ -60,7 +60,7 @@ class QSignalTransition; class QStateFinishedTransition; class QStatePrivate; -class Q_CORE_EXPORT QState : public QActionState +class Q_CORE_EXPORT QState : public QAbstractState { Q_OBJECT public: diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h index 17b312a..8d040d0 100644 --- a/src/corelib/statemachine/qstate_p.h +++ b/src/corelib/statemachine/qstate_p.h @@ -53,14 +53,14 @@ // We mean it. // -#include "qactionstate_p.h" +#include "qabstractstate_p.h" #include <QtCore/qlist.h> QT_BEGIN_NAMESPACE class QState; -class Q_CORE_EXPORT QStatePrivate : public QActionStatePrivate +class Q_CORE_EXPORT QStatePrivate : public QAbstractStatePrivate { Q_DECLARE_PUBLIC(QState) public: diff --git a/src/corelib/statemachine/qstateaction.cpp b/src/corelib/statemachine/qstateaction.cpp deleted file mode 100644 index 569d5d5..0000000 --- a/src/corelib/statemachine/qstateaction.cpp +++ /dev/null @@ -1,356 +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 "qstateaction.h" -#include "qstateaction_p.h" -#include <QtCore/qvarlengtharray.h> -#include <QtCore/qmetaobject.h> - -QT_BEGIN_NAMESPACE - -QStateActionPrivate::QStateActionPrivate() -{ - when = ExecuteOnEntry; -} - -QStateActionPrivate::~QStateActionPrivate() -{ -} - -QStateActionPrivate *QStateActionPrivate::get(QStateAction *q) -{ - return q->d_func(); -} - -void QStateActionPrivate::callExecute() -{ - Q_Q(QStateAction); - q->execute(); -} - -/*! - \class QStateAction - - \brief The QStateAction class is the base class of QState actions. - - \since 4.6 - \ingroup statemachine - - A state action is added to a state by calling QActionState::addEntryAction() - or QActionState::addExitAction(). QStateAction is part of \l{The State - Machine Framework}. - - \section1 Subclassing - - Subclasses must implement the execute() function. -*/ - -/*! - Constructs a new QStateAction object with the given \a parent. -*/ -QStateAction::QStateAction(QObject *parent) - : QObject( -#ifndef QT_STATEMACHINE_SOLUTION - *new QStateActionPrivate, -#endif - parent) -#ifdef QT_STATEMACHINE_SOLUTION - , d_ptr(new QStateActionPrivate) -#endif -{ -#ifdef QT_STATEMACHINE_SOLUTION - d_ptr->q_ptr = this; -#endif -} - -/*! - \internal -*/ -QStateAction::QStateAction(QStateActionPrivate &dd, QObject *parent) - : QObject( -#ifndef QT_STATEMACHINE_SOLUTION - dd, -#endif - parent) -#ifdef QT_STATEMACHINE_SOLUTION - , d_ptr(&dd) -#endif -{ -#ifdef QT_STATEMACHINE_SOLUTION - d_ptr->q_ptr = this; -#endif -} - -/*! - Destroys this QStateAction object. -*/ -QStateAction::~QStateAction() -{ -#ifdef QT_STATEMACHINE_SOLUTION - delete d_ptr; -#endif -} - -/*! - \fn QStateAction::execute() - - Executes this action. -*/ - -/*! - \reimp -*/ -bool QStateAction::event(QEvent *e) -{ - return QObject::event(e); -} - -QStateInvokeMethodActionPrivate *QStateInvokeMethodActionPrivate::get(QStateInvokeMethodAction *q) -{ - return q->d_func(); -} - -/*! - \class QStateInvokeMethodAction - - \brief The QStateInvokeMethodAction class provides an invoke method action for QObjects. - - \since 4.6 - \ingroup statemachine - - The QStateInvokeMethodAction class provides an action that calls a method of - a QObject when a QState is entered or exited. QStateInvokeMethodAction is - part of \l{The State Machine Framework}. - - Typically you don't construct QStateInvokeMethodAction objects directly, but - rather call the QState::invokeMethodOnEntry() function or the - QState::invokeMethodOnExit() function. -*/ - -/*! - \property QStateInvokeMethodAction::arguments - - \brief the arguments to the method this action invokes -*/ - -/*! - \property QStateInvokeMethodAction::methodName - - \brief the name of the method this action invokes -*/ - -/*! - \property QStateInvokeMethodAction::target - - \brief the object on which this action invokes a method -*/ - -/*! - Constructs a new QStateInvokeMethodAction object for the method named \a - methodName of the given \a target object, with the given \a parent. -*/ -QStateInvokeMethodAction::QStateInvokeMethodAction( - QObject *target, const QByteArray &methodName, QObject *parent) - : QStateAction(*new QStateInvokeMethodActionPrivate, parent) -{ - Q_D(QStateInvokeMethodAction); - d->target = target; - d->methodName = methodName; - d->methodIndex = -1; -} - -/*! - Constructs a new QStateInvokeMethodAction object for the method named \a - methodName of the given \a target object, with the given arguments, \a args, - and with the given \a parent. -*/ -QStateInvokeMethodAction::QStateInvokeMethodAction( - QObject *target, const QByteArray &methodName, - const QList<QVariant> &args, QObject *parent) - : QStateAction(*new QStateInvokeMethodActionPrivate, parent) -{ - Q_D(QStateInvokeMethodAction); - d->target = target; - d->methodName = methodName; - d->methodIndex = -1; - d->args = args; -} - -/*! - Constructs a new QStateInvokeMethodAction object with the given \a parent. -*/ -QStateInvokeMethodAction::QStateInvokeMethodAction(QObject *parent) - : QStateAction(*new QStateInvokeMethodActionPrivate, parent) -{ - Q_D(QStateInvokeMethodAction); - d->target = 0; - d->methodIndex = -1; -} - -/*! - Destroys this QStateInvokeMethodAction object. -*/ -QStateInvokeMethodAction::~QStateInvokeMethodAction() -{ -} - -/*! - \reimp -*/ -void QStateInvokeMethodAction::execute() -{ - Q_D(QStateInvokeMethodAction); - if (!d->target) - return; - - if (d->methodIndex == -1) { - QVarLengthArray<char, 512> sig; - int len = d->methodName.length(); - if (len <= 0) - return; - sig.append(d->methodName, len); - sig.append('('); - - int paramCount; - for (paramCount = 0; paramCount < d->args.size() && paramCount < 10; ++paramCount) { - const char *tn = d->args.at(paramCount).typeName(); - len = qstrlen(tn); - if (len <= 0) - break; - sig.append(tn, len); - sig.append(','); - } - if (paramCount == 0) - sig.append(')'); // no parameters - else - sig[sig.size() - 1] = ')'; - sig.append('\0'); - - const QMetaObject *meta = d->target->metaObject(); - int idx = meta->indexOfMethod(sig.constData()); - if (idx < 0) { - QByteArray norm = QMetaObject::normalizedSignature(sig.constData()); - idx = meta->indexOfMethod(norm.constData()); - if ((idx < 0) || (idx >= meta->methodCount())) { - qWarning("InvokeMethodAction: unable to find method '%s' of %s(%p)", - sig.constData(), meta->className(), d->target); - return; - } - } - d->methodIndex = idx; - } - - void *param[11]; - param[0] = 0; // return value - for (int i = 0; i < 10; ++i) - param[i+1] = (i < d->args.size()) ? const_cast<void*>(d->args.at(i).constData()) : (void*)0; - (void)d->target->qt_metacall(QMetaObject::InvokeMetaMethod, d->methodIndex, param); -} - -/*! - Returns the object on which this action invokes a method. -*/ -QObject *QStateInvokeMethodAction::targetObject() const -{ - Q_D(const QStateInvokeMethodAction); - return d->target; -} - -/*! - Sets the object on which this action invokes a method. -*/ -void QStateInvokeMethodAction::setTargetObject(QObject *target) -{ - Q_D(QStateInvokeMethodAction); - d->target = target; -} - -/*! - Returns the name of the method this action will invoke. -*/ -QByteArray QStateInvokeMethodAction::methodName() const -{ - Q_D(const QStateInvokeMethodAction); - return d->methodName; -} - -/*! - Sets the name of the method this action will invoke. -*/ -void QStateInvokeMethodAction::setMethodName(const QByteArray &methodName) -{ - Q_D(QStateInvokeMethodAction); - if (methodName != d->methodName) { - d->methodName = methodName; - d->methodIndex = -1; - } -} - -/*! - Returns the arguments to the method this action will invoke. -*/ -QVariantList QStateInvokeMethodAction::arguments() const -{ - Q_D(const QStateInvokeMethodAction); - return d->args; -} - -/*! - Sets the arguments to the method this action will invoke. -*/ -void QStateInvokeMethodAction::setArguments(const QVariantList &arguments) -{ - Q_D(QStateInvokeMethodAction); - if (d->args != arguments) { - d->args = arguments; - d->methodIndex = -1; - } -} - -/*! - \reimp -*/ -bool QStateInvokeMethodAction::event(QEvent *e) -{ - return QStateAction::event(e); -} - -QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qstateaction.h b/src/corelib/statemachine/qstateaction.h deleted file mode 100644 index 6843080..0000000 --- a/src/corelib/statemachine/qstateaction.h +++ /dev/null @@ -1,119 +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 QSTATEACTION_H -#define QSTATEACTION_H - -#include <QtCore/qobject.h> - -#include <QtCore/qvariant.h> -#include <QtCore/qlist.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Core) - -class QStateActionPrivate; -class Q_CORE_EXPORT QStateAction : public QObject -{ - Q_OBJECT -public: - ~QStateAction(); - -protected: - QStateAction(QObject *parent = 0); - - virtual void execute() = 0; - - bool event(QEvent *e); - -protected: -#ifdef QT_STATEMACHINE_SOLUTION - QStateActionPrivate *d_ptr; -#endif - QStateAction(QStateActionPrivate &dd, QObject *parent); - -private: - Q_DISABLE_COPY(QStateAction) - Q_DECLARE_PRIVATE(QStateAction) -}; - -class QStateInvokeMethodActionPrivate; -class Q_CORE_EXPORT QStateInvokeMethodAction : public QStateAction -{ - Q_OBJECT - Q_PROPERTY(QObject* target READ targetObject WRITE setTargetObject) - Q_PROPERTY(QByteArray methodName READ methodName WRITE setMethodName) - Q_PROPERTY(QVariantList arguments READ arguments WRITE setArguments) -public: - QStateInvokeMethodAction(QObject *target, const QByteArray &methodName, - QObject *parent = 0); - QStateInvokeMethodAction(QObject *target, const QByteArray &methodName, - const QList<QVariant> &args, QObject *parent = 0); - QStateInvokeMethodAction(QObject *parent = 0); - ~QStateInvokeMethodAction(); - - QObject *targetObject() const; - void setTargetObject(QObject *target); - - QByteArray methodName() const; - void setMethodName(const QByteArray &methodName); - - QVariantList arguments() const; - void setArguments(const QVariantList &arguments); - -protected: - void execute(); - - bool event(QEvent *e); - -private: - Q_DISABLE_COPY(QStateInvokeMethodAction) - Q_DECLARE_PRIVATE(QStateInvokeMethodAction) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/corelib/statemachine/qstateaction_p.h b/src/corelib/statemachine/qstateaction_p.h deleted file mode 100644 index 4016b74..0000000 --- a/src/corelib/statemachine/qstateaction_p.h +++ /dev/null @@ -1,107 +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 QSTATEACTION_P_H -#define QSTATEACTION_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. -// - -#ifndef QT_STATEMACHINE_SOLUTION -#include <private/qobject_p.h> -#endif - -QT_BEGIN_NAMESPACE - -class QStateAction; -class QStateActionPrivate -#ifndef QT_STATEMACHINE_SOLUTION - : public QObjectPrivate -#endif -{ - Q_DECLARE_PUBLIC(QStateAction) -public: - QStateActionPrivate(); - ~QStateActionPrivate(); - - static QStateActionPrivate *get(QStateAction *q); - - void callExecute(); - - enum When { - ExecuteOnEntry, - ExecuteOnExit - }; - - When when; - -#ifdef QT_STATEMACHINE_SOLUTION - QStateAction *q_ptr; -#endif -}; - -class QStateInvokeMethodAction; -class QStateInvokeMethodActionPrivate : public QStateActionPrivate -{ - Q_DECLARE_PUBLIC(QStateInvokeMethodAction) -public: - QStateInvokeMethodActionPrivate() {} - ~QStateInvokeMethodActionPrivate() {} - - static QStateInvokeMethodActionPrivate *get(QStateInvokeMethodAction *q); - - QObject *target; - QByteArray methodName; - int methodIndex; - QList<QVariant> args; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/corelib/statemachine/qstatefinishedtransition.cpp b/src/corelib/statemachine/qstatefinishedtransition.cpp index 33c3d22..151a274 100644 --- a/src/corelib/statemachine/qstatefinishedtransition.cpp +++ b/src/corelib/statemachine/qstatefinishedtransition.cpp @@ -41,7 +41,7 @@ #include "qstatefinishedtransition.h" #include "qstatefinishedevent.h" -#include "qactiontransition_p.h" +#include "qabstracttransition_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 QActionTransitionPrivate +class QStateFinishedTransitionPrivate : public QAbstractTransitionPrivate { Q_DECLARE_PUBLIC(QStateFinishedTransition) public: @@ -106,7 +106,7 @@ QStateFinishedTransitionPrivate *QStateFinishedTransitionPrivate::get(QStateFini sourceState. */ QStateFinishedTransition::QStateFinishedTransition(QState *sourceState) - : QActionTransition(*new QStateFinishedTransitionPrivate, sourceState) + : QAbstractTransition(*new QStateFinishedTransitionPrivate, sourceState) { } @@ -116,7 +116,7 @@ QStateFinishedTransition::QStateFinishedTransition(QState *sourceState) */ QStateFinishedTransition::QStateFinishedTransition( QState *state, const QList<QAbstractState*> &targets, QState *sourceState) - : QActionTransition(*new QStateFinishedTransitionPrivate, targets, sourceState) + : QAbstractTransition(*new QStateFinishedTransitionPrivate, targets, sourceState) { Q_D(QStateFinishedTransition); d->state = state; @@ -167,9 +167,16 @@ bool QStateFinishedTransition::eventTest(QEvent *event) const /*! \reimp */ +void QStateFinishedTransition::onTransition() +{ +} + +/*! + \reimp +*/ bool QStateFinishedTransition::event(QEvent *e) { - return QActionTransition::event(e); + return QAbstractTransition::event(e); } QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qstatefinishedtransition.h b/src/corelib/statemachine/qstatefinishedtransition.h index f9320f5..ed86288 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 <QtCore/qactiontransition.h> +#include <QtCore/qabstracttransition.h> #else -#include "qactiontransition.h" +#include "qabstracttransition.h" #endif QT_BEGIN_HEADER @@ -57,7 +57,7 @@ QT_MODULE(Core) class QState; class QStateFinishedTransitionPrivate; -class Q_CORE_EXPORT QStateFinishedTransition : public QActionTransition +class Q_CORE_EXPORT QStateFinishedTransition : public QAbstractTransition { Q_OBJECT Q_PROPERTY(QState* state READ state WRITE setState) @@ -72,6 +72,7 @@ public: protected: bool eventTest(QEvent *event) const; + void onTransition(); bool event(QEvent *e); diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 1f8d8a8..b6ab205 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -49,8 +49,6 @@ #include "qsignaleventgenerator_p.h" #include "qabstractstate.h" #include "qabstractstate_p.h" -#include "qactionstate.h" -#include "qactionstate_p.h" #include "qfinalstate.h" #include "qhistorystate.h" #include "qhistorystate_p.h" @@ -58,8 +56,6 @@ #include "qstatefinishedtransition.h" #include "qstate.h" #include "qstate_p.h" -#include "qstateaction.h" -#include "qstateaction_p.h" #ifndef QT_STATEMACHINE_SOLUTION #include "private/qobject_p.h" #include "private/qthread_p.h" @@ -417,6 +413,7 @@ QList<QAbstractState*> QStateMachinePrivate::exitStates(const QList<QAbstractTra #endif QAbstractStatePrivate::get(s)->callOnExit(); configuration.remove(s); + QAbstractStatePrivate::get(s)->emitExited(); } return statesToExit_sorted; } @@ -504,6 +501,7 @@ QList<QAbstractState*> QStateMachinePrivate::enterStates(const QList<QAbstractTr configuration.insert(s); registerTransitions(s); QAbstractStatePrivate::get(s)->callOnEntry(); + QAbstractStatePrivate::get(s)->emitEntered(); if (statesForDefaultEntry.contains(s)) { // ### executeContent(s.initial.transition.children()) } @@ -1490,9 +1488,9 @@ void QStateMachine::clearError() /*! Returns the global restore policy of the state machine. - \sa QActionState::restorePolicy() + \sa QAbstractState::restorePolicy() */ -QActionState::RestorePolicy QStateMachine::globalRestorePolicy() const +QAbstractState::RestorePolicy QStateMachine::globalRestorePolicy() const { Q_D(const QStateMachine); return d->globalRestorePolicy; diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h index f39efc7..901d160 100644 --- a/src/corelib/statemachine/qstatemachine.h +++ b/src/corelib/statemachine/qstatemachine.h @@ -43,9 +43,9 @@ #define QSTATEMACHINE_H #ifndef QT_STATEMACHINE_SOLUTION -# include <QtCore/qactionstate.h> +# include <QtCore/qabstractstate.h> #else -# include "qactionstate.h" +# include "qabstractstate.h" #endif #include <QtCore/qlist.h> diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index a9fd2de..910b751 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -171,7 +171,7 @@ public: QList<QEvent*> externalEventQueue; QStateMachine::Error error; - QActionState::RestorePolicy globalRestorePolicy; + QAbstractState::RestorePolicy globalRestorePolicy; QString errorString; QSet<QAbstractState *> pendingErrorStates; diff --git a/src/corelib/statemachine/statemachine.pri b/src/corelib/statemachine/statemachine.pri index 4179e45..620c7a0 100644 --- a/src/corelib/statemachine/statemachine.pri +++ b/src/corelib/statemachine/statemachine.pri @@ -1,12 +1,8 @@ HEADERS += $$PWD/qstatemachine.h \ $$PWD/qstatemachine_p.h \ - $$PWD/qstateaction.h \ - $$PWD/qstateaction_p.h \ $$PWD/qsignaleventgenerator_p.h \ $$PWD/qabstractstate.h \ $$PWD/qabstractstate_p.h \ - $$PWD/qactionstate.h \ - $$PWD/qactionstate_p.h \ $$PWD/qstate.h \ $$PWD/qstate_p.h \ $$PWD/qfinalstate.h \ @@ -14,8 +10,6 @@ HEADERS += $$PWD/qstatemachine.h \ $$PWD/qhistorystate_p.h \ $$PWD/qabstracttransition.h \ $$PWD/qabstracttransition_p.h \ - $$PWD/qactiontransition.h \ - $$PWD/qactiontransition_p.h \ $$PWD/qstatefinishedevent.h \ $$PWD/qstatefinishedtransition.h \ $$PWD/qsignalevent.h \ @@ -23,14 +17,11 @@ HEADERS += $$PWD/qstatemachine.h \ $$PWD/qsignaltransition_p.h SOURCES += $$PWD/qstatemachine.cpp \ - $$PWD/qstateaction.cpp \ $$PWD/qabstractstate.cpp \ - $$PWD/qactionstate.cpp \ $$PWD/qstate.cpp \ $$PWD/qfinalstate.cpp \ $$PWD/qhistorystate.cpp \ $$PWD/qabstracttransition.cpp \ - $$PWD/qactiontransition.cpp \ $$PWD/qstatefinishedtransition.cpp \ $$PWD/qsignaltransition.cpp |