mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
remove state machine code
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
98fa09fde0
commit
763bdaecc2
43 changed files with 4 additions and 7833 deletions
1
README
1
README
|
@ -30,6 +30,7 @@ There are several things you should be aware before considering Katie:
|
|||
- QPictureIO and plugins for it are no longer supported
|
||||
- QML debugger and inspector have been removed, potentially dangerous
|
||||
- no SIMD, zero performance impact with decent compiler
|
||||
- state machine is no more
|
||||
- removed non-open source DB2, OCI, TDS and InterBase database drivers
|
||||
- removed 3rd party sources that are very common nowdays
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ set(CORE_PUBLIC_HEADERS
|
|||
QMultiHash
|
||||
QObjectCleanupHandler
|
||||
QAbstractFileEngine
|
||||
QHistoryState
|
||||
QTranslator
|
||||
QFuture
|
||||
QCryptographicHash
|
||||
|
@ -149,7 +148,6 @@ set(CORE_PUBLIC_HEADERS
|
|||
QFileInfoList
|
||||
QCoreApplication
|
||||
QRegExp
|
||||
QStateMachine
|
||||
QVariantComparisonHelper
|
||||
QMetaObject
|
||||
QPauseAnimation
|
||||
|
@ -185,7 +183,6 @@ set(CORE_PUBLIC_HEADERS
|
|||
QtConcurrentFilter
|
||||
QCache
|
||||
QLatin1String
|
||||
QAbstractState
|
||||
QAbstractEventDispatcher
|
||||
QResource
|
||||
QRunnable
|
||||
|
@ -196,7 +193,6 @@ set(CORE_PUBLIC_HEADERS
|
|||
QtContainerFwd
|
||||
QTimeLine
|
||||
QForeachContainerBase
|
||||
QFinalState
|
||||
QMutableFutureIterator
|
||||
QtPluginInstanceFunction
|
||||
QTextCodec
|
||||
|
@ -209,7 +205,6 @@ set(CORE_PUBLIC_HEADERS
|
|||
QMapPayloadNode
|
||||
QBasicTimer
|
||||
QThread
|
||||
QState
|
||||
QSocketNotifier
|
||||
QJsonArray
|
||||
QJsonDocument
|
||||
|
@ -266,7 +261,6 @@ include(json/json.cmake)
|
|||
include(kernel/kernel.cmake)
|
||||
#include(mimetypes/mimetypes.cmake)
|
||||
include(plugin/plugin.cmake)
|
||||
include(statemachine/statemachine.cmake)
|
||||
include(thread/thread.cmake)
|
||||
include(tools/tools.cmake)
|
||||
include(xml/xml.cmake)
|
||||
|
@ -284,7 +278,6 @@ include_directories(
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/json
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/plugin
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/thread
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/xml
|
||||
|
@ -296,7 +289,6 @@ include_directories(
|
|||
${CMAKE_CURRENT_BINARY_DIR}/json
|
||||
${CMAKE_CURRENT_BINARY_DIR}/kernel
|
||||
${CMAKE_CURRENT_BINARY_DIR}/plugin
|
||||
${CMAKE_CURRENT_BINARY_DIR}/statemachine
|
||||
${CMAKE_CURRENT_BINARY_DIR}/thread
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tools
|
||||
${CMAKE_CURRENT_BINARY_DIR}/xml
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
#define QT_NO_STYLE_WINDOWSVISTA
|
||||
#define QT_NO_STYLE_MAC
|
||||
#define QT_NO_STYLE_S60
|
||||
#define QT_NO_STATEMACHINE
|
||||
|
||||
/* Qt build specs */
|
||||
#ifndef QT_EDITION
|
||||
|
|
|
@ -369,11 +369,6 @@
|
|||
#define QT_NO_SPLITTER
|
||||
#endif
|
||||
|
||||
// State machine
|
||||
#if !defined(QT_NO_STATEMACHINE) && (defined(QT_NO_PROPERTIES))
|
||||
#define QT_NO_STATEMACHINE
|
||||
#endif
|
||||
|
||||
// QCDEStyle
|
||||
#if !defined(QT_NO_STYLE_CDE) && (defined(QT_NO_STYLE_MOTIF))
|
||||
#define QT_NO_STYLE_CDE
|
||||
|
|
|
@ -3007,11 +3007,9 @@ const void *QVariant::constData() const
|
|||
void* QVariant::data()
|
||||
{
|
||||
detach();
|
||||
return const_cast<void *>(constData());
|
||||
return d.is_shared ? d.data.shared->ptr : &d.data.ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
Returns true if this is a NULL variant, false otherwise.
|
||||
*/
|
||||
|
|
|
@ -1,209 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qabstractstate.h"
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include "qabstractstate_p.h"
|
||||
#include "qstate.h"
|
||||
#include "qstate_p.h"
|
||||
#include "qstatemachine.h"
|
||||
#include "qstatemachine_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QAbstractState
|
||||
|
||||
\brief The QAbstractState class is the base class of states of a QStateMachine.
|
||||
|
||||
\since 4.6
|
||||
\ingroup statemachine
|
||||
|
||||
The QAbstractState class is the abstract base class of states that are part
|
||||
of a QStateMachine. It defines the interface that all state objects have in
|
||||
common. QAbstractState is part of \l{The State Machine Framework}.
|
||||
|
||||
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. The machine()
|
||||
function returns the state machine that the state is part of.
|
||||
|
||||
\section1 Subclassing
|
||||
|
||||
The onEntry() function is called when the state is entered; reimplement this
|
||||
function to perform custom processing when the state is entered.
|
||||
|
||||
The onExit() function is called when the state is exited; reimplement this
|
||||
function to perform custom processing when the state is exited.
|
||||
*/
|
||||
|
||||
QAbstractStatePrivate::QAbstractStatePrivate(StateType type)
|
||||
: stateType(type), isMachine(false), parentState(0)
|
||||
{
|
||||
}
|
||||
|
||||
QAbstractStatePrivate *QAbstractStatePrivate::get(QAbstractState *q)
|
||||
{
|
||||
return q->d_func();
|
||||
}
|
||||
|
||||
const QAbstractStatePrivate *QAbstractStatePrivate::get(const QAbstractState *q)
|
||||
{
|
||||
return q->d_func();
|
||||
}
|
||||
|
||||
QStateMachine *QAbstractStatePrivate::machine() const
|
||||
{
|
||||
QObject *par = parent;
|
||||
while (par != 0) {
|
||||
if (QStateMachine *mach = qobject_cast<QStateMachine*>(par))
|
||||
return mach;
|
||||
par = par->parent();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QAbstractStatePrivate::callOnEntry(QEvent *e)
|
||||
{
|
||||
Q_Q(QAbstractState);
|
||||
q->onEntry(e);
|
||||
}
|
||||
|
||||
void QAbstractStatePrivate::callOnExit(QEvent *e)
|
||||
{
|
||||
Q_Q(QAbstractState);
|
||||
q->onExit(e);
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
QAbstractState::QAbstractState(QState *parent)
|
||||
: QObject(*new QAbstractStatePrivate(QAbstractStatePrivate::AbstractState), parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QAbstractState::QAbstractState(QAbstractStatePrivate &dd, QState *parent)
|
||||
: QObject(dd, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this state.
|
||||
*/
|
||||
QAbstractState::~QAbstractState()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns this state's parent state, or 0 if the state has no parent state.
|
||||
*/
|
||||
QState *QAbstractState::parentState() const
|
||||
{
|
||||
Q_D(const QAbstractState);
|
||||
if (d->parentState != parent())
|
||||
d->parentState = qobject_cast<QState*>(parent());
|
||||
return d->parentState;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the state machine that this state is part of, or 0 if the state is
|
||||
not part of a state machine.
|
||||
*/
|
||||
QStateMachine *QAbstractState::machine() const
|
||||
{
|
||||
Q_D(const QAbstractState);
|
||||
return d->machine();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QAbstractState::onExit(QEvent *event)
|
||||
|
||||
This function is called when the state is exited. The given \a event is what
|
||||
caused the state to be exited. Reimplement this function to perform custom
|
||||
processing when the state is exited.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QAbstractState::onEntry(QEvent *event)
|
||||
|
||||
This function is called when the state is entered. The given \a event is
|
||||
what caused the state to be entered. Reimplement this function to perform
|
||||
custom processing when the state is entered.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\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).
|
||||
*/
|
||||
|
||||
#include "moc_qabstractstate.h"
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
|
@ -1,93 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QABSTRACTSTATE_H
|
||||
#define QABSTRACTSTATE_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
class QState;
|
||||
class QStateMachine;
|
||||
|
||||
class QAbstractStatePrivate;
|
||||
class Q_CORE_EXPORT QAbstractState : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
~QAbstractState();
|
||||
|
||||
QState *parentState() const;
|
||||
QStateMachine *machine() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
#if !defined(Q_MOC_RUN)
|
||||
private: // can only be emitted by QAbstractState
|
||||
#endif
|
||||
void entered();
|
||||
void exited();
|
||||
|
||||
protected:
|
||||
QAbstractState(QState *parent = 0);
|
||||
|
||||
virtual void onEntry(QEvent *event) = 0;
|
||||
virtual void onExit(QEvent *event) = 0;
|
||||
|
||||
protected:
|
||||
QAbstractState(QAbstractStatePrivate &dd, QState *parent);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QAbstractState)
|
||||
Q_DECLARE_PRIVATE(QAbstractState)
|
||||
};
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
|
@ -1,95 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QABSTRACTSTATE_P_H
|
||||
#define QABSTRACTSTATE_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 <qobject_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QStateMachine;
|
||||
|
||||
class QAbstractState;
|
||||
class QAbstractStatePrivate : public QObjectPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QAbstractState)
|
||||
|
||||
public:
|
||||
enum StateType {
|
||||
AbstractState,
|
||||
StandardState,
|
||||
FinalState,
|
||||
HistoryState
|
||||
};
|
||||
|
||||
QAbstractStatePrivate(StateType type);
|
||||
|
||||
static QAbstractStatePrivate *get(QAbstractState *q);
|
||||
static const QAbstractStatePrivate *get(const QAbstractState *q);
|
||||
|
||||
QStateMachine *machine() const;
|
||||
|
||||
void callOnEntry(QEvent *e);
|
||||
void callOnExit(QEvent *e);
|
||||
|
||||
void emitEntered();
|
||||
void emitExited();
|
||||
|
||||
uint stateType:31;
|
||||
uint isMachine:1;
|
||||
mutable QState *parentState;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,337 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qabstracttransition.h"
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include "qabstracttransition_p.h"
|
||||
#include "qabstractstate.h"
|
||||
#include "qstate.h"
|
||||
#include "qstatemachine.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QAbstractTransition
|
||||
|
||||
\brief The QAbstractTransition class is the base class of transitions between QAbstractState objects.
|
||||
|
||||
\since 4.6
|
||||
\ingroup statemachine
|
||||
|
||||
The QAbstractTransition class is the abstract base class of transitions
|
||||
between states (QAbstractState objects) of a
|
||||
QStateMachine. QAbstractTransition is part of \l{The State Machine
|
||||
Framework}.
|
||||
|
||||
The sourceState() function returns the source of the transition. The
|
||||
targetStates() function returns the targets of the transition. The machine()
|
||||
function returns the state machine that the transition is part of.
|
||||
|
||||
The triggered() signal is emitted when the transition has been triggered.
|
||||
|
||||
Transitions can cause animations to be played. Use the addAnimation()
|
||||
function to add an animation to the transition.
|
||||
|
||||
\section1 Subclassing
|
||||
|
||||
The eventTest() function is called by the state machine to determine whether
|
||||
an event should trigger the transition. In your reimplementation you
|
||||
typically check the event type and cast the event object to the proper type,
|
||||
and check that one or more properties of the event meet your criteria.
|
||||
|
||||
The onTransition() function is called when the transition is triggered;
|
||||
reimplement this function to perform custom processing for the transition.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QAbstractTransition::sourceState
|
||||
|
||||
\brief the source state (parent) of this transition
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QAbstractTransition::targetState
|
||||
|
||||
\brief the target state of this transition
|
||||
|
||||
If a transition has no target state, the transition may still be
|
||||
triggered, but this will not cause the state machine's configuration to
|
||||
change (i.e. the current state will not be exited and re-entered).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QAbstractTransition::targetStates
|
||||
|
||||
\brief the target states of this transition
|
||||
|
||||
If multiple states are specified, all must be descendants of the same
|
||||
parallel group state.
|
||||
*/
|
||||
|
||||
QAbstractTransitionPrivate::QAbstractTransitionPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
QAbstractTransitionPrivate *QAbstractTransitionPrivate::get(QAbstractTransition *q)
|
||||
{
|
||||
return q->d_func();
|
||||
}
|
||||
|
||||
QStateMachine *QAbstractTransitionPrivate::machine() const
|
||||
{
|
||||
QState *source = sourceState();
|
||||
if (!source)
|
||||
return 0;
|
||||
return source->machine();
|
||||
}
|
||||
|
||||
bool QAbstractTransitionPrivate::callEventTest(QEvent *e)
|
||||
{
|
||||
Q_Q(QAbstractTransition);
|
||||
return q->eventTest(e);
|
||||
}
|
||||
|
||||
void QAbstractTransitionPrivate::callOnTransition(QEvent *e)
|
||||
{
|
||||
Q_Q(QAbstractTransition);
|
||||
q->onTransition(e);
|
||||
}
|
||||
|
||||
QState *QAbstractTransitionPrivate::sourceState() const
|
||||
{
|
||||
return qobject_cast<QState*>(parent);
|
||||
}
|
||||
|
||||
void QAbstractTransitionPrivate::emitTriggered()
|
||||
{
|
||||
Q_Q(QAbstractTransition);
|
||||
emit q->triggered();
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new QAbstractTransition object with the given \a sourceState.
|
||||
*/
|
||||
QAbstractTransition::QAbstractTransition(QState *sourceState)
|
||||
: QObject(*new QAbstractTransitionPrivate, sourceState)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QAbstractTransition::QAbstractTransition(QAbstractTransitionPrivate &dd,
|
||||
QState *parent)
|
||||
: QObject(dd, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this transition.
|
||||
*/
|
||||
QAbstractTransition::~QAbstractTransition()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the source state of this transition, or 0 if this transition has no
|
||||
source state.
|
||||
*/
|
||||
QState *QAbstractTransition::sourceState() const
|
||||
{
|
||||
Q_D(const QAbstractTransition);
|
||||
return d->sourceState();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the target state of this transition, or 0 if the transition has no
|
||||
target.
|
||||
*/
|
||||
QAbstractState *QAbstractTransition::targetState() const
|
||||
{
|
||||
Q_D(const QAbstractTransition);
|
||||
if (d->targetStates.isEmpty())
|
||||
return 0;
|
||||
return d->targetStates.first().data();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a target state of this transition.
|
||||
*/
|
||||
void QAbstractTransition::setTargetState(QAbstractState* target)
|
||||
{
|
||||
Q_D(QAbstractTransition);
|
||||
if (!target)
|
||||
d->targetStates.clear();
|
||||
else
|
||||
setTargetStates(QList<QAbstractState*>() << target);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the target states of this transition, or an empty list if this
|
||||
transition has no target states.
|
||||
*/
|
||||
QList<QAbstractState*> QAbstractTransition::targetStates() const
|
||||
{
|
||||
Q_D(const QAbstractTransition);
|
||||
QList<QAbstractState*> result;
|
||||
for (int i = 0; i < d->targetStates.size(); ++i) {
|
||||
QAbstractState *target = d->targetStates.at(i).data();
|
||||
if (target)
|
||||
result.append(target);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the target states of this transition to be the given \a targets.
|
||||
*/
|
||||
void QAbstractTransition::setTargetStates(const QList<QAbstractState*> &targets)
|
||||
{
|
||||
Q_D(QAbstractTransition);
|
||||
|
||||
for (int i = 0; i < targets.size(); ++i) {
|
||||
QAbstractState *target = targets.at(i);
|
||||
if (!target) {
|
||||
qWarning("QAbstractTransition::setTargetStates: target state(s) cannot be null");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
d->targetStates.clear();
|
||||
for (int i = 0; i < targets.size(); ++i)
|
||||
d->targetStates.append(targets.at(i));
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the state machine that this transition is part of, or 0 if the
|
||||
transition is not part of a state machine.
|
||||
*/
|
||||
QStateMachine *QAbstractTransition::machine() const
|
||||
{
|
||||
Q_D(const QAbstractTransition);
|
||||
return d->machine();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_ANIMATION
|
||||
|
||||
/*!
|
||||
Adds the given \a animation to this transition.
|
||||
The transition does not take ownership of the animation.
|
||||
|
||||
\sa removeAnimation(), animations()
|
||||
*/
|
||||
void QAbstractTransition::addAnimation(QAbstractAnimation *animation)
|
||||
{
|
||||
Q_D(QAbstractTransition);
|
||||
if (!animation) {
|
||||
qWarning("QAbstractTransition::addAnimation: cannot add null animation");
|
||||
return;
|
||||
}
|
||||
d->animations.append(animation);
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes the given \a animation from this transition.
|
||||
|
||||
\sa addAnimation()
|
||||
*/
|
||||
void QAbstractTransition::removeAnimation(QAbstractAnimation *animation)
|
||||
{
|
||||
Q_D(QAbstractTransition);
|
||||
if (!animation) {
|
||||
qWarning("QAbstractTransition::removeAnimation: cannot remove null animation");
|
||||
return;
|
||||
}
|
||||
d->animations.removeOne(animation);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the list of animations associated with this transition, or an empty
|
||||
list if it has no animations.
|
||||
|
||||
\sa addAnimation()
|
||||
*/
|
||||
QList<QAbstractAnimation*> QAbstractTransition::animations() const
|
||||
{
|
||||
Q_D(const QAbstractTransition);
|
||||
return d->animations;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\fn QAbstractTransition::eventTest(QEvent *event)
|
||||
|
||||
This function is called to determine whether the given \a event should cause
|
||||
this transition to trigger. Reimplement this function and return true if the
|
||||
event should trigger the transition, otherwise return false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QAbstractTransition::onTransition(QEvent *event)
|
||||
|
||||
This function is called when the transition is triggered. The given \a event
|
||||
is what caused the transition to trigger. Reimplement this function to
|
||||
perform custom processing when the transition is triggered.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QAbstractTransition::triggered()
|
||||
|
||||
This signal is emitted when the transition has been triggered (after
|
||||
onTransition() has been called).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QAbstractTransition::event(QEvent *e)
|
||||
{
|
||||
return QObject::event(e);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "moc_qabstracttransition.h"
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
|
@ -1,114 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QABSTRACTTRANSITION_H
|
||||
#define QABSTRACTTRANSITION_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
class QEvent;
|
||||
class QAbstractState;
|
||||
class QState;
|
||||
class QStateMachine;
|
||||
|
||||
#ifndef QT_NO_ANIMATION
|
||||
class QAbstractAnimation;
|
||||
#endif
|
||||
|
||||
class QAbstractTransitionPrivate;
|
||||
class Q_CORE_EXPORT QAbstractTransition : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QState* sourceState READ sourceState)
|
||||
Q_PROPERTY(QAbstractState* targetState READ targetState WRITE setTargetState)
|
||||
Q_PROPERTY(QList<QAbstractState*> targetStates READ targetStates WRITE setTargetStates)
|
||||
public:
|
||||
QAbstractTransition(QState *sourceState = 0);
|
||||
virtual ~QAbstractTransition();
|
||||
|
||||
QState *sourceState() const;
|
||||
QAbstractState *targetState() const;
|
||||
void setTargetState(QAbstractState* target);
|
||||
QList<QAbstractState*> targetStates() const;
|
||||
void setTargetStates(const QList<QAbstractState*> &targets);
|
||||
|
||||
QStateMachine *machine() const;
|
||||
|
||||
#ifndef QT_NO_ANIMATION
|
||||
void addAnimation(QAbstractAnimation *animation);
|
||||
void removeAnimation(QAbstractAnimation *animation);
|
||||
QList<QAbstractAnimation*> animations() const;
|
||||
#endif
|
||||
|
||||
Q_SIGNALS:
|
||||
#if !defined(Q_MOC_RUN)
|
||||
private: // can only be emitted by QAbstractTransition
|
||||
#endif
|
||||
void triggered();
|
||||
|
||||
protected:
|
||||
virtual bool eventTest(QEvent *event) = 0;
|
||||
|
||||
virtual void onTransition(QEvent *event) = 0;
|
||||
|
||||
bool event(QEvent *e);
|
||||
|
||||
protected:
|
||||
QAbstractTransition(QAbstractTransitionPrivate &dd, QState *parent);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QAbstractTransition)
|
||||
Q_DECLARE_PRIVATE(QAbstractTransition)
|
||||
};
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
|
@ -1,89 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QABSTRACTTRANSITION_P_H
|
||||
#define QABSTRACTTRANSITION_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 <qobject_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QAbstractState;
|
||||
class QState;
|
||||
class QStateMachine;
|
||||
|
||||
class QAbstractTransition;
|
||||
class Q_CORE_EXPORT QAbstractTransitionPrivate
|
||||
: public QObjectPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QAbstractTransition)
|
||||
public:
|
||||
QAbstractTransitionPrivate();
|
||||
|
||||
static QAbstractTransitionPrivate *get(QAbstractTransition *q);
|
||||
|
||||
bool callEventTest(QEvent *e);
|
||||
virtual void callOnTransition(QEvent *e);
|
||||
QState *sourceState() const;
|
||||
QStateMachine *machine() const;
|
||||
void emitTriggered();
|
||||
|
||||
QList<QWeakPointer<QAbstractState> > targetStates;
|
||||
|
||||
#ifndef QT_NO_ANIMATION
|
||||
QList<QAbstractAnimation*> animations;
|
||||
#endif
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,255 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qeventtransition.h"
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include "qeventtransition_p.h"
|
||||
#include "qstate.h"
|
||||
#include "qstate_p.h"
|
||||
#include "qstatemachine.h"
|
||||
#include "qstatemachine_p.h"
|
||||
#include <qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QEventTransition
|
||||
|
||||
\brief The QEventTransition class provides a QObject-specific transition for Qt events.
|
||||
|
||||
\since 4.6
|
||||
\ingroup statemachine
|
||||
|
||||
A QEventTransition object binds an event to a particular QObject.
|
||||
QEventTransition is part of \l{The State Machine Framework}.
|
||||
|
||||
Example:
|
||||
|
||||
\code
|
||||
QPushButton *button = ...;
|
||||
QState *s1 = ...;
|
||||
QState *s2 = ...;
|
||||
// If in s1 and the button receives an Enter event, transition to s2
|
||||
QEventTransition *enterTransition = new QEventTransition(button, QEvent::Enter);
|
||||
enterTransition->setTargetState(s2);
|
||||
s1->addTransition(enterTransition);
|
||||
// If in s2 and the button receives an Exit event, transition back to s1
|
||||
QEventTransition *leaveTransition = new QEventTransition(button, QEvent::Leave);
|
||||
leaveTransition->setTargetState(s1);
|
||||
s2->addTransition(leaveTransition);
|
||||
\endcode
|
||||
|
||||
\section1 Subclassing
|
||||
|
||||
When reimplementing the eventTest() function, you should first call the base
|
||||
implementation to verify that the event is a QStateMachine::WrappedEvent for
|
||||
the proper object and event type. You may then cast the event to a
|
||||
QStateMachine::WrappedEvent and get the original event by calling
|
||||
QStateMachine::WrappedEvent::event(), and perform additional checks on that
|
||||
object.
|
||||
|
||||
\sa QState::addTransition()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QEventTransition::eventSource
|
||||
|
||||
\brief the event source that this event transition is associated with
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QEventTransition::eventType
|
||||
|
||||
\brief the type of event that this event transition is associated with
|
||||
*/
|
||||
QEventTransitionPrivate::QEventTransitionPrivate()
|
||||
{
|
||||
object = 0;
|
||||
eventType = QEvent::None;
|
||||
registered = false;
|
||||
}
|
||||
|
||||
QEventTransitionPrivate *QEventTransitionPrivate::get(QEventTransition *q)
|
||||
{
|
||||
return q->d_func();
|
||||
}
|
||||
|
||||
void QEventTransitionPrivate::unregister()
|
||||
{
|
||||
Q_Q(QEventTransition);
|
||||
if (!registered || !machine())
|
||||
return;
|
||||
QStateMachinePrivate::get(machine())->unregisterEventTransition(q);
|
||||
}
|
||||
|
||||
void QEventTransitionPrivate::maybeRegister()
|
||||
{
|
||||
Q_Q(QEventTransition);
|
||||
if (!machine() || !machine()->configuration().contains(sourceState()))
|
||||
return;
|
||||
QStateMachinePrivate::get(machine())->registerEventTransition(q);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new QEventTransition object with the given \a sourceState.
|
||||
*/
|
||||
QEventTransition::QEventTransition(QState *sourceState)
|
||||
: QAbstractTransition(*new QEventTransitionPrivate, sourceState)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new QEventTransition object associated with events of the given
|
||||
\a type for the given \a object, and with the given \a sourceState.
|
||||
*/
|
||||
QEventTransition::QEventTransition(QObject *object, QEvent::Type type,
|
||||
QState *sourceState)
|
||||
: QAbstractTransition(*new QEventTransitionPrivate, sourceState)
|
||||
{
|
||||
Q_D(QEventTransition);
|
||||
d->registered = false;
|
||||
d->object = object;
|
||||
d->eventType = type;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QState *parent)
|
||||
: QAbstractTransition(dd, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object,
|
||||
QEvent::Type type, QState *parent)
|
||||
: QAbstractTransition(dd, parent)
|
||||
{
|
||||
Q_D(QEventTransition);
|
||||
d->registered = false;
|
||||
d->object = object;
|
||||
d->eventType = type;
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this QObject event transition.
|
||||
*/
|
||||
QEventTransition::~QEventTransition()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the event type that this event transition is associated with.
|
||||
*/
|
||||
QEvent::Type QEventTransition::eventType() const
|
||||
{
|
||||
Q_D(const QEventTransition);
|
||||
return d->eventType;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the event \a type that this event transition is associated with.
|
||||
*/
|
||||
void QEventTransition::setEventType(QEvent::Type type)
|
||||
{
|
||||
Q_D(QEventTransition);
|
||||
if (d->eventType == type)
|
||||
return;
|
||||
d->unregister();
|
||||
d->eventType = type;
|
||||
d->maybeRegister();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the event source associated with this event transition.
|
||||
*/
|
||||
QObject *QEventTransition::eventSource() const
|
||||
{
|
||||
Q_D(const QEventTransition);
|
||||
return d->object;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the event source associated with this event transition to be the given
|
||||
\a object.
|
||||
*/
|
||||
void QEventTransition::setEventSource(QObject *object)
|
||||
{
|
||||
Q_D(QEventTransition);
|
||||
if (d->object == object)
|
||||
return;
|
||||
d->unregister();
|
||||
d->object = object;
|
||||
d->maybeRegister();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QEventTransition::eventTest(QEvent *event)
|
||||
{
|
||||
Q_D(const QEventTransition);
|
||||
if (event->type() == QEvent::StateMachineWrapped) {
|
||||
QStateMachine::WrappedEvent *we = static_cast<QStateMachine::WrappedEvent*>(event);
|
||||
return (we->object() == d->object)
|
||||
&& (we->event()->type() == d->eventType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QEventTransition::onTransition(QEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "moc_qeventtransition.h"
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QEVENTTRANSITION_H
|
||||
#define QEVENTTRANSITION_H
|
||||
|
||||
#include <QtCore/qabstracttransition.h>
|
||||
#include <QtCore/qcoreevent.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
class QEventTransitionPrivate;
|
||||
class Q_CORE_EXPORT QEventTransition : public QAbstractTransition
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QObject* eventSource READ eventSource WRITE setEventSource)
|
||||
Q_PROPERTY(QEvent::Type eventType READ eventType WRITE setEventType)
|
||||
public:
|
||||
QEventTransition(QState *sourceState = 0);
|
||||
QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = 0);
|
||||
~QEventTransition();
|
||||
|
||||
QObject *eventSource() const;
|
||||
void setEventSource(QObject *object);
|
||||
|
||||
QEvent::Type eventType() const;
|
||||
void setEventType(QEvent::Type type);
|
||||
|
||||
protected:
|
||||
bool eventTest(QEvent *event);
|
||||
void onTransition(QEvent *event);
|
||||
|
||||
protected:
|
||||
QEventTransition(QEventTransitionPrivate &dd, QState *parent);
|
||||
QEventTransition(QEventTransitionPrivate &dd, QObject *object,
|
||||
QEvent::Type type, QState *parent);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QEventTransition)
|
||||
Q_DECLARE_PRIVATE(QEventTransition)
|
||||
};
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
|
@ -1,79 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QEVENTTRANSITION_P_H
|
||||
#define QEVENTTRANSITION_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"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QEventTransition;
|
||||
class Q_CORE_EXPORT QEventTransitionPrivate : public QAbstractTransitionPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QEventTransition)
|
||||
public:
|
||||
QEventTransitionPrivate();
|
||||
|
||||
static QEventTransitionPrivate *get(QEventTransition *q);
|
||||
|
||||
void unregister();
|
||||
void maybeRegister();
|
||||
|
||||
bool registered;
|
||||
QObject *object;
|
||||
QEvent::Type eventType;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,134 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qfinalstate.h"
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include "qabstractstate_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QFinalState
|
||||
|
||||
\brief The QFinalState class provides a final state.
|
||||
|
||||
\since 4.6
|
||||
\ingroup statemachine
|
||||
|
||||
A final state is used to communicate that (part of) a QStateMachine has
|
||||
finished its work. When a final top-level state is entered, the state
|
||||
machine's \l{QStateMachine::finished()}{finished}() signal is emitted. In
|
||||
general, when a final substate (a child of a QState) is entered, the parent
|
||||
state's \l{QState::finished()}{finished}() signal is emitted. QFinalState
|
||||
is part of \l{The State Machine Framework}.
|
||||
|
||||
To use a final state, you create a QFinalState object and add a transition
|
||||
to it from another state. Example:
|
||||
|
||||
\code
|
||||
QPushButton button;
|
||||
|
||||
QStateMachine machine;
|
||||
QState *s1 = new QState();
|
||||
QFinalState *s2 = new QFinalState();
|
||||
s1->addTransition(&button, SIGNAL(clicked()), s2);
|
||||
machine.addState(s1);
|
||||
machine.addState(s2);
|
||||
|
||||
QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit()));
|
||||
machine.setInitialState(s1);
|
||||
machine.start();
|
||||
\endcode
|
||||
|
||||
\sa QState::finished()
|
||||
*/
|
||||
|
||||
class QFinalStatePrivate : public QAbstractStatePrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QFinalState)
|
||||
|
||||
public:
|
||||
QFinalStatePrivate();
|
||||
};
|
||||
|
||||
QFinalStatePrivate::QFinalStatePrivate()
|
||||
: QAbstractStatePrivate(FinalState)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new QFinalState object with the given \a parent state.
|
||||
*/
|
||||
QFinalState::QFinalState(QState *parent)
|
||||
: QAbstractState(*new QFinalStatePrivate, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this final state.
|
||||
*/
|
||||
QFinalState::~QFinalState()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QFinalState::onEntry(QEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QFinalState::onExit(QEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
#include "moc_qfinalstate.h"
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
|
@ -1,77 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QFINALSTATE_H
|
||||
#define QFINALSTATE_H
|
||||
|
||||
#include <QtCore/qabstractstate.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
class QFinalStatePrivate;
|
||||
class Q_CORE_EXPORT QFinalState : public QAbstractState
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QFinalState(QState *parent = 0);
|
||||
~QFinalState();
|
||||
|
||||
protected:
|
||||
void onEntry(QEvent *event);
|
||||
void onExit(QEvent *event);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QFinalState)
|
||||
Q_DECLARE_PRIVATE(QFinalState)
|
||||
};
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
|
@ -1,224 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qhistorystate.h"
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include "qhistorystate_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QHistoryState
|
||||
|
||||
\brief The QHistoryState class provides a means of returning to a previously active substate.
|
||||
|
||||
\since 4.6
|
||||
\ingroup statemachine
|
||||
|
||||
A history state is a pseudo-state that represents the child state that the
|
||||
parent state was in the last time the parent state was exited. A transition
|
||||
with a history state as its target is in fact a transition to one of the
|
||||
other child states of the parent state. QHistoryState is part of \l{The
|
||||
State Machine Framework}.
|
||||
|
||||
Use the setDefaultState() function to set the state that should be entered
|
||||
if the parent state has never been entered. Example:
|
||||
|
||||
\code
|
||||
QStateMachine machine;
|
||||
|
||||
QState *s1 = new QState();
|
||||
QState *s11 = new QState(s1);
|
||||
QState *s12 = new QState(s1);
|
||||
|
||||
QHistoryState *s1h = new QHistoryState(s1);
|
||||
s1h->setDefaultState(s11);
|
||||
|
||||
machine.addState(s1);
|
||||
|
||||
QState *s2 = new QState();
|
||||
machine.addState(s2);
|
||||
|
||||
QPushButton *button = new QPushButton();
|
||||
// Clicking the button will cause the state machine to enter the child state
|
||||
// that s1 was in the last time s1 was exited, or the history state's default
|
||||
// state if s1 has never been entered.
|
||||
s1->addTransition(button, SIGNAL(clicked()), s1h);
|
||||
\endcode
|
||||
|
||||
By default a history state is shallow, meaning that it won't remember nested
|
||||
states. This can be configured through the historyType property.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QHistoryState::defaultState
|
||||
|
||||
\brief the default state of this history state
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QHistoryState::historyType
|
||||
|
||||
\brief the type of history that this history state records
|
||||
|
||||
The default value of this property is QHistoryState::ShallowHistory.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QHistoryState::HistoryType
|
||||
|
||||
This enum specifies the type of history that a QHistoryState records.
|
||||
|
||||
\value ShallowHistory Only the immediate child states of the parent state
|
||||
are recorded. In this case a transition with the history state as its
|
||||
target will end up in the immediate child state that the parent was in the
|
||||
last time it was exited. This is the default.
|
||||
|
||||
\value DeepHistory Nested states are recorded. In this case a transition
|
||||
with the history state as its target will end up in the most deeply nested
|
||||
descendant state the parent was in the last time it was exited.
|
||||
*/
|
||||
|
||||
QHistoryStatePrivate::QHistoryStatePrivate()
|
||||
: QAbstractStatePrivate(HistoryState),
|
||||
defaultState(0), historyType(QHistoryState::ShallowHistory)
|
||||
{
|
||||
}
|
||||
|
||||
QHistoryStatePrivate *QHistoryStatePrivate::get(QHistoryState *q)
|
||||
{
|
||||
return q->d_func();
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new shallow history state with the given \a parent state.
|
||||
*/
|
||||
QHistoryState::QHistoryState(QState *parent)
|
||||
: QAbstractState(*new QHistoryStatePrivate, parent)
|
||||
{
|
||||
}
|
||||
/*!
|
||||
Constructs a new history state of the given \a type, with the given \a
|
||||
parent state.
|
||||
*/
|
||||
QHistoryState::QHistoryState(HistoryType type, QState *parent)
|
||||
: QAbstractState(*new QHistoryStatePrivate, parent)
|
||||
{
|
||||
Q_D(QHistoryState);
|
||||
d->historyType = type;
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this history state.
|
||||
*/
|
||||
QHistoryState::~QHistoryState()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns this history state's default state. The default state indicates the
|
||||
state to transition to if the parent state has never been entered before.
|
||||
*/
|
||||
QAbstractState *QHistoryState::defaultState() const
|
||||
{
|
||||
Q_D(const QHistoryState);
|
||||
return d->defaultState;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets this history state's default state to be the given \a state.
|
||||
\a state must be a sibling of this history state.
|
||||
|
||||
Note that this function does not set \a state as the initial state
|
||||
of its parent.
|
||||
*/
|
||||
void QHistoryState::setDefaultState(QAbstractState *state)
|
||||
{
|
||||
Q_D(QHistoryState);
|
||||
if (state && state->parentState() != parentState()) {
|
||||
qWarning("QHistoryState::setDefaultState: state %p does not belong "
|
||||
"to this history state's group (%p)", state, parentState());
|
||||
return;
|
||||
}
|
||||
d->defaultState = state;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the type of history that this history state records.
|
||||
*/
|
||||
QHistoryState::HistoryType QHistoryState::historyType() const
|
||||
{
|
||||
Q_D(const QHistoryState);
|
||||
return d->historyType;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a type of history that this history state records.
|
||||
*/
|
||||
void QHistoryState::setHistoryType(HistoryType type)
|
||||
{
|
||||
Q_D(QHistoryState);
|
||||
d->historyType = type;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QHistoryState::onEntry(QEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QHistoryState::onExit(QEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
#include "moc_qhistorystate.h"
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
|
@ -1,92 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QHISTORYSTATE_H
|
||||
#define QHISTORYSTATE_H
|
||||
|
||||
#include <QtCore/qabstractstate.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
class QHistoryStatePrivate;
|
||||
class Q_CORE_EXPORT QHistoryState : public QAbstractState
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QAbstractState* defaultState READ defaultState WRITE setDefaultState)
|
||||
Q_PROPERTY(HistoryType historyType READ historyType WRITE setHistoryType)
|
||||
Q_ENUMS(HistoryType)
|
||||
public:
|
||||
enum HistoryType {
|
||||
ShallowHistory,
|
||||
DeepHistory
|
||||
};
|
||||
|
||||
QHistoryState(QState *parent = 0);
|
||||
QHistoryState(HistoryType type, QState *parent = 0);
|
||||
~QHistoryState();
|
||||
|
||||
QAbstractState *defaultState() const;
|
||||
void setDefaultState(QAbstractState *state);
|
||||
|
||||
HistoryType historyType() const;
|
||||
void setHistoryType(HistoryType type);
|
||||
|
||||
protected:
|
||||
void onEntry(QEvent *event);
|
||||
void onExit(QEvent *event);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QHistoryState)
|
||||
Q_DECLARE_PRIVATE(QHistoryState)
|
||||
};
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
|
@ -1,79 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QHISTORYSTATE_P_H
|
||||
#define QHISTORYSTATE_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 <QtCore/qlist.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QHistoryState;
|
||||
class QHistoryStatePrivate : public QAbstractStatePrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QHistoryState)
|
||||
|
||||
public:
|
||||
QHistoryStatePrivate();
|
||||
|
||||
static QHistoryStatePrivate *get(QHistoryState *q);
|
||||
|
||||
QAbstractState *defaultState;
|
||||
QHistoryState::HistoryType historyType;
|
||||
QList<QAbstractState*> configuration;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,78 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSIGNALEVENTGENERATOR_P_H
|
||||
#define QSIGNALEVENTGENERATOR_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 <QtCore/qobject.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QStateMachine;
|
||||
|
||||
class QSignalEventGenerator : public QObject
|
||||
{
|
||||
Q_OBJECT_FAKE
|
||||
public:
|
||||
QSignalEventGenerator(QStateMachine *parent);
|
||||
|
||||
private:
|
||||
// private slots:
|
||||
void execute(void **_a);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QSignalEventGenerator)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,258 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qsignaltransition.h"
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include "qsignaltransition_p.h"
|
||||
#include "qstate.h"
|
||||
#include "qstate_p.h"
|
||||
#include "qstatemachine.h"
|
||||
#include "qstatemachine_p.h"
|
||||
#include <qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QSignalTransition
|
||||
|
||||
\brief The QSignalTransition class provides a transition based on a Qt signal.
|
||||
|
||||
\since 4.6
|
||||
\ingroup statemachine
|
||||
|
||||
Typically you would use the overload of QState::addTransition() that takes a
|
||||
sender and signal as arguments, rather than creating QSignalTransition
|
||||
objects directly. QSignalTransition is part of \l{The State Machine
|
||||
Framework}.
|
||||
|
||||
You can subclass QSignalTransition and reimplement eventTest() to make a
|
||||
signal transition conditional; the event object passed to eventTest() will
|
||||
be a QStateMachine::SignalEvent object. Example:
|
||||
|
||||
\code
|
||||
class CheckedTransition : public QSignalTransition
|
||||
{
|
||||
public:
|
||||
CheckedTransition(QCheckBox *check)
|
||||
: QSignalTransition(check, SIGNAL(stateChanged(int))) {}
|
||||
protected:
|
||||
bool eventTest(QEvent *e) {
|
||||
if (!QSignalTransition::eventTest(e))
|
||||
return false;
|
||||
QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(e);
|
||||
return (se->arguments().at(0).toInt() == Qt::Checked);
|
||||
}
|
||||
};
|
||||
|
||||
...
|
||||
|
||||
QCheckBox *check = new QCheckBox();
|
||||
check->setTristate(true);
|
||||
|
||||
QState *s1 = new QState();
|
||||
QState *s2 = new QState();
|
||||
CheckedTransition *t1 = new CheckedTransition(check);
|
||||
t1->setTargetState(s2);
|
||||
s1->addTransition(t1);
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QSignalTransition::senderObject
|
||||
|
||||
\brief the sender object that this signal transition is associated with
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QSignalTransition::signal
|
||||
|
||||
\brief the signal that this signal transition is associated with
|
||||
*/
|
||||
|
||||
QSignalTransitionPrivate::QSignalTransitionPrivate()
|
||||
{
|
||||
sender = 0;
|
||||
signalIndex = -1;
|
||||
}
|
||||
|
||||
QSignalTransitionPrivate *QSignalTransitionPrivate::get(QSignalTransition *q)
|
||||
{
|
||||
return q->d_func();
|
||||
}
|
||||
|
||||
void QSignalTransitionPrivate::unregister()
|
||||
{
|
||||
Q_Q(QSignalTransition);
|
||||
if ((signalIndex == -1) || !machine())
|
||||
return;
|
||||
QStateMachinePrivate::get(machine())->unregisterSignalTransition(q);
|
||||
}
|
||||
|
||||
void QSignalTransitionPrivate::maybeRegister()
|
||||
{
|
||||
Q_Q(QSignalTransition);
|
||||
if (!machine() || !machine()->configuration().contains(sourceState()))
|
||||
return;
|
||||
QStateMachinePrivate::get(machine())->registerSignalTransition(q);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new signal transition with the given \a sourceState.
|
||||
*/
|
||||
QSignalTransition::QSignalTransition(QState *sourceState)
|
||||
: QAbstractTransition(*new QSignalTransitionPrivate, sourceState)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new signal transition associated with the given \a signal of
|
||||
the given \a sender, and with the given \a sourceState.
|
||||
*/
|
||||
QSignalTransition::QSignalTransition(QObject *sender, const char *signal,
|
||||
QState *sourceState)
|
||||
: QAbstractTransition(*new QSignalTransitionPrivate, sourceState)
|
||||
{
|
||||
Q_D(QSignalTransition);
|
||||
d->sender = sender;
|
||||
d->signal = signal;
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this signal transition.
|
||||
*/
|
||||
QSignalTransition::~QSignalTransition()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the sender object associated with this signal transition.
|
||||
*/
|
||||
QObject *QSignalTransition::senderObject() const
|
||||
{
|
||||
Q_D(const QSignalTransition);
|
||||
return d->sender;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a sender object associated with this signal transition.
|
||||
*/
|
||||
void QSignalTransition::setSenderObject(QObject *sender)
|
||||
{
|
||||
Q_D(QSignalTransition);
|
||||
if (sender == d->sender)
|
||||
return;
|
||||
d->unregister();
|
||||
d->sender = sender;
|
||||
d->maybeRegister();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the signal associated with this signal transition.
|
||||
*/
|
||||
QByteArray QSignalTransition::signal() const
|
||||
{
|
||||
Q_D(const QSignalTransition);
|
||||
return d->signal;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a signal associated with this signal transition.
|
||||
*/
|
||||
void QSignalTransition::setSignal(const QByteArray &signal)
|
||||
{
|
||||
Q_D(QSignalTransition);
|
||||
if (signal == d->signal)
|
||||
return;
|
||||
d->unregister();
|
||||
d->signal = signal;
|
||||
d->maybeRegister();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
|
||||
The default implementation returns true if the \a event is a
|
||||
QStateMachine::SignalEvent object and the event's sender and signal index
|
||||
match this transition, and returns false otherwise.
|
||||
*/
|
||||
bool QSignalTransition::eventTest(QEvent *event)
|
||||
{
|
||||
Q_D(const QSignalTransition);
|
||||
if (event->type() == QEvent::StateMachineSignal) {
|
||||
if (d->signalIndex == -1)
|
||||
return false;
|
||||
QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
|
||||
return (se->sender() == d->sender)
|
||||
&& (se->signalIndex() == d->signalIndex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QSignalTransition::onTransition(QEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
void QSignalTransitionPrivate::callOnTransition(QEvent *e)
|
||||
{
|
||||
Q_Q(QSignalTransition);
|
||||
|
||||
if (e->type() == QEvent::StateMachineSignal) {
|
||||
QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent *>(e);
|
||||
int savedSignalIndex = se->m_signalIndex;
|
||||
se->m_signalIndex = originalSignalIndex;
|
||||
q->onTransition(e);
|
||||
se->m_signalIndex = savedSignalIndex;
|
||||
} else {
|
||||
q->onTransition(e);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_qsignaltransition.h"
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
|
@ -1,87 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSIGNALTRANSITION_H
|
||||
#define QSIGNALTRANSITION_H
|
||||
|
||||
#include <QtCore/qabstracttransition.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
class QSignalTransitionPrivate;
|
||||
class Q_CORE_EXPORT QSignalTransition : public QAbstractTransition
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QObject* senderObject READ senderObject WRITE setSenderObject)
|
||||
Q_PROPERTY(QByteArray signal READ signal WRITE setSignal)
|
||||
public:
|
||||
QSignalTransition(QState *sourceState = 0);
|
||||
QSignalTransition(QObject *sender, const char *signal,
|
||||
QState *sourceState = 0);
|
||||
~QSignalTransition();
|
||||
|
||||
QObject *senderObject() const;
|
||||
void setSenderObject(QObject *sender);
|
||||
|
||||
QByteArray signal() const;
|
||||
void setSignal(const QByteArray &signal);
|
||||
|
||||
protected:
|
||||
bool eventTest(QEvent *event);
|
||||
void onTransition(QEvent *event);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QSignalTransition)
|
||||
Q_DECLARE_PRIVATE(QSignalTransition)
|
||||
};
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
|
@ -1,82 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSIGNALTRANSITION_P_H
|
||||
#define QSIGNALTRANSITION_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"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QSignalTransition;
|
||||
class QSignalTransitionPrivate : public QAbstractTransitionPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QSignalTransition)
|
||||
public:
|
||||
QSignalTransitionPrivate();
|
||||
|
||||
static QSignalTransitionPrivate *get(QSignalTransition *q);
|
||||
|
||||
void unregister();
|
||||
void maybeRegister();
|
||||
|
||||
virtual void callOnTransition(QEvent *e);
|
||||
|
||||
QObject *sender;
|
||||
QByteArray signal;
|
||||
int signalIndex;
|
||||
int originalSignalIndex;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,528 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qstate.h"
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include "qstate_p.h"
|
||||
#include "qhistorystate.h"
|
||||
#include "qhistorystate_p.h"
|
||||
#include "qabstracttransition.h"
|
||||
#include "qabstracttransition_p.h"
|
||||
#include "qsignaltransition.h"
|
||||
#include "qstatemachine.h"
|
||||
#include "qstatemachine_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QState
|
||||
|
||||
\brief The QState class provides a general-purpose state for QStateMachine.
|
||||
|
||||
\since 4.6
|
||||
\ingroup statemachine
|
||||
|
||||
QState objects can have child states, and can have transitions to other
|
||||
states. QState is part of \l{The State Machine Framework}.
|
||||
|
||||
The addTransition() function adds a transition. The removeTransition()
|
||||
function removes a transition. The transitions() function returns the
|
||||
state's outgoing transitions.
|
||||
|
||||
The assignProperty() function is used for defining property assignments that
|
||||
should be performed when a state is entered.
|
||||
|
||||
Top-level states must be passed a QStateMachine object as their parent
|
||||
state, or added to a state machine using QStateMachine::addState().
|
||||
|
||||
\section1 States with Child States
|
||||
|
||||
The childMode property determines how child states are treated. For
|
||||
non-parallel state groups, the setInitialState() function must be called to
|
||||
set the initial state. The child states are mutually exclusive states, and
|
||||
the state machine needs to know which child state to enter when the parent
|
||||
state is the target of a transition.
|
||||
|
||||
The state emits the QState::finished() signal when a final child state
|
||||
(QFinalState) is entered.
|
||||
|
||||
The setErrorState() sets the state's error state. The error state is the
|
||||
state that the state machine will transition to if an error is detected when
|
||||
attempting to enter the state (e.g. because no initial state has been set).
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QState::initialState
|
||||
|
||||
\brief the initial state of this state (one of its child states)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QState::errorState
|
||||
|
||||
\brief the error state of this state
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QState::childMode
|
||||
|
||||
\brief the child mode of this state
|
||||
|
||||
The default value of this property is QState::ExclusiveStates.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QState::ChildMode
|
||||
|
||||
This enum specifies how a state's child states are treated.
|
||||
|
||||
\value ExclusiveStates The child states are mutually exclusive and an
|
||||
initial state must be set by calling QState::setInitialState().
|
||||
|
||||
\value ParallelStates The child states are parallel. When the parent state
|
||||
is entered, all its child states are entered in parallel.
|
||||
*/
|
||||
|
||||
QStatePrivate::QStatePrivate()
|
||||
: QAbstractStatePrivate(StandardState),
|
||||
errorState(0), initialState(0), childMode(QState::ExclusiveStates),
|
||||
childStatesListNeedsRefresh(true), transitionsListNeedsRefresh(true)
|
||||
{
|
||||
}
|
||||
|
||||
QStatePrivate::~QStatePrivate()
|
||||
{
|
||||
}
|
||||
|
||||
void QStatePrivate::emitFinished()
|
||||
{
|
||||
Q_Q(QState);
|
||||
emit q->finished();
|
||||
}
|
||||
|
||||
void QStatePrivate::emitPropertiesAssigned()
|
||||
{
|
||||
Q_Q(QState);
|
||||
emit q->propertiesAssigned();
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new state with the given \a parent state.
|
||||
*/
|
||||
QState::QState(QState *parent)
|
||||
: QAbstractState(*new QStatePrivate, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new state with the given \a childMode and the given \a parent
|
||||
state.
|
||||
*/
|
||||
QState::QState(ChildMode childMode, QState *parent)
|
||||
: QAbstractState(*new QStatePrivate, parent)
|
||||
{
|
||||
Q_D(QState);
|
||||
d->childMode = childMode;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QState::QState(QStatePrivate &dd, QState *parent)
|
||||
: QAbstractState(dd, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this state.
|
||||
*/
|
||||
QState::~QState()
|
||||
{
|
||||
}
|
||||
|
||||
QList<QAbstractState*> QStatePrivate::childStates() const
|
||||
{
|
||||
if (childStatesListNeedsRefresh) {
|
||||
childStatesList.clear();
|
||||
QList<QObject*>::const_iterator it;
|
||||
for (it = children.constBegin(); it != children.constEnd(); ++it) {
|
||||
QAbstractState *s = qobject_cast<QAbstractState*>(*it);
|
||||
if (!s || qobject_cast<QHistoryState*>(s))
|
||||
continue;
|
||||
childStatesList.append(s);
|
||||
}
|
||||
childStatesListNeedsRefresh = false;
|
||||
}
|
||||
return childStatesList;
|
||||
}
|
||||
|
||||
QList<QHistoryState*> QStatePrivate::historyStates() const
|
||||
{
|
||||
QList<QHistoryState*> result;
|
||||
QList<QObject*>::const_iterator it;
|
||||
for (it = children.constBegin(); it != children.constEnd(); ++it) {
|
||||
QHistoryState *h = qobject_cast<QHistoryState*>(*it);
|
||||
if (h)
|
||||
result.append(h);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<QAbstractTransition*> QStatePrivate::transitions() const
|
||||
{
|
||||
if (transitionsListNeedsRefresh) {
|
||||
transitionsList.clear();
|
||||
QList<QObject*>::const_iterator it;
|
||||
for (it = children.constBegin(); it != children.constEnd(); ++it) {
|
||||
QAbstractTransition *t = qobject_cast<QAbstractTransition*>(*it);
|
||||
if (t)
|
||||
transitionsList.append(t);
|
||||
}
|
||||
transitionsListNeedsRefresh = false;
|
||||
}
|
||||
return transitionsList;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_PROPERTIES
|
||||
|
||||
/*!
|
||||
Instructs this state to set the property with the given \a name of the given
|
||||
\a object to the given \a value when the state is entered.
|
||||
|
||||
\sa propertiesAssigned()
|
||||
*/
|
||||
void QState::assignProperty(QObject *object, const char *name,
|
||||
const QVariant &value)
|
||||
{
|
||||
Q_D(QState);
|
||||
if (!object) {
|
||||
qWarning("QState::assignProperty: cannot assign property '%s' of null object", name);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < d->propertyAssignments.size(); ++i) {
|
||||
QPropertyAssignment &assn = d->propertyAssignments[i];
|
||||
if ((assn.object == object) && (assn.propertyName == name)) {
|
||||
assn.value = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
d->propertyAssignments.append(QPropertyAssignment(object, name, value));
|
||||
}
|
||||
|
||||
#endif // QT_NO_PROPERTIES
|
||||
|
||||
/*!
|
||||
Returns this state's error state.
|
||||
|
||||
\sa QStateMachine::error()
|
||||
*/
|
||||
QAbstractState *QState::errorState() const
|
||||
{
|
||||
Q_D(const QState);
|
||||
return d->errorState;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets this state's error state to be the given \a state. If the error state
|
||||
is not set, or if it is set to 0, the state will inherit its parent's error
|
||||
state recursively. If no error state is set for the state itself or any of
|
||||
its ancestors, an error will cause the machine to stop executing and an error
|
||||
will be printed to the console.
|
||||
*/
|
||||
void QState::setErrorState(QAbstractState *state)
|
||||
{
|
||||
Q_D(QState);
|
||||
if (state != 0 && qobject_cast<QStateMachine*>(state)) {
|
||||
qWarning("QStateMachine::setErrorState: root state cannot be error state");
|
||||
return;
|
||||
}
|
||||
if (state != 0 && (!state->machine() || ((state->machine() != machine()) && !qobject_cast<QStateMachine*>(this)))) {
|
||||
qWarning("QState::setErrorState: error state cannot belong "
|
||||
"to a different state machine");
|
||||
return;
|
||||
}
|
||||
|
||||
d->errorState = state;
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds the given \a transition. The transition has this state as the source.
|
||||
This state takes ownership of the transition.
|
||||
*/
|
||||
void QState::addTransition(QAbstractTransition *transition)
|
||||
{
|
||||
Q_D(QState);
|
||||
if (!transition) {
|
||||
qWarning("QState::addTransition: cannot add null transition");
|
||||
return ;
|
||||
}
|
||||
|
||||
transition->setParent(this);
|
||||
const QList<QWeakPointer<QAbstractState> > &targets = QAbstractTransitionPrivate::get(transition)->targetStates;
|
||||
for (int i = 0; i < targets.size(); ++i) {
|
||||
QAbstractState *t = targets.at(i).data();
|
||||
if (!t) {
|
||||
qWarning("QState::addTransition: cannot add transition to null state");
|
||||
return ;
|
||||
}
|
||||
if ((QAbstractStatePrivate::get(t)->machine() != d->machine())
|
||||
&& QAbstractStatePrivate::get(t)->machine() && d->machine()) {
|
||||
qWarning("QState::addTransition: cannot add transition "
|
||||
"to a state in a different state machine");
|
||||
return ;
|
||||
}
|
||||
}
|
||||
if (machine() != 0 && machine()->configuration().contains(this))
|
||||
QStateMachinePrivate::get(machine())->registerTransitions(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds a transition associated with the given \a signal of the given \a sender
|
||||
object, and returns the new QSignalTransition object. The transition has
|
||||
this state as the source, and the given \a target as the target state.
|
||||
*/
|
||||
QSignalTransition *QState::addTransition(QObject *sender, const char *signal,
|
||||
QAbstractState *target)
|
||||
{
|
||||
if (!sender) {
|
||||
qWarning("QState::addTransition: sender cannot be null");
|
||||
return 0;
|
||||
}
|
||||
if (!signal) {
|
||||
qWarning("QState::addTransition: signal cannot be null");
|
||||
return 0;
|
||||
}
|
||||
if (!target) {
|
||||
qWarning("QState::addTransition: cannot add transition to null state");
|
||||
return 0;
|
||||
}
|
||||
int offset = (*signal == '0'+QSIGNAL_CODE) ? 1 : 0;
|
||||
const QMetaObject *meta = sender->metaObject();
|
||||
if (meta->indexOfSignal(signal+offset) == -1) {
|
||||
if (meta->indexOfSignal(QMetaObject::normalizedSignature(signal+offset)) == -1) {
|
||||
qWarning("QState::addTransition: no such signal %s::%s",
|
||||
meta->className(), signal+offset);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
QSignalTransition *trans = new QSignalTransition(sender, signal);
|
||||
trans->setTargetState(target);
|
||||
addTransition(trans);
|
||||
return trans;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// ### Make public?
|
||||
class UnconditionalTransition : public QAbstractTransition
|
||||
{
|
||||
public:
|
||||
UnconditionalTransition(QAbstractState *target)
|
||||
: QAbstractTransition()
|
||||
{ setTargetState(target); }
|
||||
protected:
|
||||
void onTransition(QEvent *) {}
|
||||
bool eventTest(QEvent *) { return true; }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/*!
|
||||
Adds an unconditional transition from this state to the given \a target
|
||||
state, and returns then new transition object.
|
||||
*/
|
||||
QAbstractTransition *QState::addTransition(QAbstractState *target)
|
||||
{
|
||||
if (!target) {
|
||||
qWarning("QState::addTransition: cannot add transition to null state");
|
||||
return 0;
|
||||
}
|
||||
UnconditionalTransition *trans = new UnconditionalTransition(target);
|
||||
addTransition(trans);
|
||||
return trans;
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes the given \a transition from this state. The state releases
|
||||
ownership of the transition.
|
||||
|
||||
\sa addTransition()
|
||||
*/
|
||||
void QState::removeTransition(QAbstractTransition *transition)
|
||||
{
|
||||
Q_D(QState);
|
||||
if (!transition) {
|
||||
qWarning("QState::removeTransition: cannot remove null transition");
|
||||
return;
|
||||
}
|
||||
if (transition->sourceState() != this) {
|
||||
qWarning("QState::removeTransition: transition %p's source state (%p)"
|
||||
" is different from this state (%p)",
|
||||
transition, transition->sourceState(), this);
|
||||
return;
|
||||
}
|
||||
QStateMachinePrivate *mach = QStateMachinePrivate::get(d->machine());
|
||||
if (mach)
|
||||
mach->unregisterTransition(transition);
|
||||
transition->setParent(0);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.7
|
||||
|
||||
Returns this state's outgoing transitions (i.e. transitions where
|
||||
this state is the \l{QAbstractTransition::sourceState()}{source
|
||||
state}), or an empty list if this state has no outgoing transitions.
|
||||
|
||||
\sa addTransition()
|
||||
*/
|
||||
QList<QAbstractTransition*> QState::transitions() const
|
||||
{
|
||||
Q_D(const QState);
|
||||
return d->transitions();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QState::onEntry(QEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QState::onExit(QEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns this state's initial state, or 0 if the state has no initial state.
|
||||
*/
|
||||
QAbstractState *QState::initialState() const
|
||||
{
|
||||
Q_D(const QState);
|
||||
return d->initialState;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets this state's initial state to be the given \a state.
|
||||
\a state has to be a child of this state.
|
||||
*/
|
||||
void QState::setInitialState(QAbstractState *state)
|
||||
{
|
||||
Q_D(QState);
|
||||
if (d->childMode == QState::ParallelStates) {
|
||||
qWarning("QState::setInitialState: ignoring attempt to set initial state "
|
||||
"of parallel state group %p", this);
|
||||
return;
|
||||
}
|
||||
if (state && (state->parentState() != this)) {
|
||||
qWarning("QState::setInitialState: state %p is not a child of this state (%p)",
|
||||
state, this);
|
||||
return;
|
||||
}
|
||||
d->initialState = state;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the child mode of this state.
|
||||
*/
|
||||
QState::ChildMode QState::childMode() const
|
||||
{
|
||||
Q_D(const QState);
|
||||
return d->childMode;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the child \a mode of this state.
|
||||
*/
|
||||
void QState::setChildMode(ChildMode mode)
|
||||
{
|
||||
Q_D(QState);
|
||||
d->childMode = mode;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QState::event(QEvent *e)
|
||||
{
|
||||
Q_D(QState);
|
||||
if ((e->type() == QEvent::ChildAdded) || (e->type() == QEvent::ChildRemoved)) {
|
||||
d->childStatesListNeedsRefresh = true;
|
||||
d->transitionsListNeedsRefresh = true;
|
||||
}
|
||||
return QAbstractState::event(e);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QState::finished()
|
||||
|
||||
This signal is emitted when a final child state of this state is entered.
|
||||
|
||||
\sa QFinalState
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QState::propertiesAssigned()
|
||||
|
||||
This signal is emitted when all properties have been assigned their final value. If the state
|
||||
assigns a value to one or more properties for which an animation exists (either set on the
|
||||
transition or as a default animation on the state machine), then the signal will not be emitted
|
||||
until all such animations have finished playing.
|
||||
|
||||
If there are no relevant animations, or no property assignments defined for the state, then
|
||||
the signal will be emitted immediately before the state is entered.
|
||||
|
||||
\sa QState::assignProperty(), QAbstractTransition::addAnimation()
|
||||
*/
|
||||
|
||||
#include "moc_qstate.h"
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
|
@ -1,119 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSTATE_H
|
||||
#define QSTATE_H
|
||||
|
||||
#include <QtCore/qabstractstate.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
class QAbstractTransition;
|
||||
class QSignalTransition;
|
||||
|
||||
class QStatePrivate;
|
||||
class Q_CORE_EXPORT QState : public QAbstractState
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QAbstractState* initialState READ initialState WRITE setInitialState)
|
||||
Q_PROPERTY(QAbstractState* errorState READ errorState WRITE setErrorState)
|
||||
Q_PROPERTY(ChildMode childMode READ childMode WRITE setChildMode)
|
||||
Q_ENUMS(ChildMode)
|
||||
public:
|
||||
enum ChildMode {
|
||||
ExclusiveStates,
|
||||
ParallelStates
|
||||
};
|
||||
|
||||
QState(QState *parent = 0);
|
||||
QState(ChildMode childMode, QState *parent = 0);
|
||||
~QState();
|
||||
|
||||
QAbstractState *errorState() const;
|
||||
void setErrorState(QAbstractState *state);
|
||||
|
||||
void addTransition(QAbstractTransition *transition);
|
||||
QSignalTransition *addTransition(QObject *sender, const char *signal, QAbstractState *target);
|
||||
QAbstractTransition *addTransition(QAbstractState *target);
|
||||
void removeTransition(QAbstractTransition *transition);
|
||||
QList<QAbstractTransition*> transitions() const;
|
||||
|
||||
QAbstractState *initialState() const;
|
||||
void setInitialState(QAbstractState *state);
|
||||
|
||||
ChildMode childMode() const;
|
||||
void setChildMode(ChildMode mode);
|
||||
|
||||
#ifndef QT_NO_PROPERTIES
|
||||
void assignProperty(QObject *object, const char *name,
|
||||
const QVariant &value);
|
||||
#endif
|
||||
|
||||
Q_SIGNALS:
|
||||
void finished();
|
||||
void propertiesAssigned();
|
||||
|
||||
protected:
|
||||
void onEntry(QEvent *event);
|
||||
void onExit(QEvent *event);
|
||||
|
||||
bool event(QEvent *e);
|
||||
|
||||
protected:
|
||||
QState(QStatePrivate &dd, QState *parent);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QState)
|
||||
Q_DECLARE_PRIVATE(QState)
|
||||
};
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
|
@ -1,108 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSTATE_P_H
|
||||
#define QSTATE_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"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
struct QPropertyAssignment
|
||||
{
|
||||
QPropertyAssignment()
|
||||
: object(0), explicitlySet(true) {}
|
||||
QPropertyAssignment(QObject *o, const QByteArray &n,
|
||||
const QVariant &v, bool es = true)
|
||||
: object(o), propertyName(n), value(v), explicitlySet(es)
|
||||
{}
|
||||
QObject *object;
|
||||
QByteArray propertyName;
|
||||
QVariant value;
|
||||
bool explicitlySet;
|
||||
};
|
||||
|
||||
class QAbstractTransition;
|
||||
class QHistoryState;
|
||||
|
||||
class QState;
|
||||
class Q_AUTOTEST_EXPORT QStatePrivate : public QAbstractStatePrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QState)
|
||||
public:
|
||||
QStatePrivate();
|
||||
~QStatePrivate();
|
||||
|
||||
static QStatePrivate *get(QState *q) { return q ? q->d_func() : 0; }
|
||||
static const QStatePrivate *get(const QState *q) { return q? q->d_func() : 0; }
|
||||
|
||||
QList<QAbstractState*> childStates() const;
|
||||
QList<QHistoryState*> historyStates() const;
|
||||
QList<QAbstractTransition*> transitions() const;
|
||||
|
||||
void emitFinished();
|
||||
void emitPropertiesAssigned();
|
||||
|
||||
QAbstractState *errorState;
|
||||
QAbstractState *initialState;
|
||||
QState::ChildMode childMode;
|
||||
mutable bool childStatesListNeedsRefresh;
|
||||
mutable QList<QAbstractState*> childStatesList;
|
||||
mutable bool transitionsListNeedsRefresh;
|
||||
mutable QList<QAbstractTransition*> transitionsList;
|
||||
|
||||
QList<QPropertyAssignment> propertyAssignments;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -1,194 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSTATEMACHINE_H
|
||||
#define QSTATEMACHINE_H
|
||||
|
||||
#include <QtCore/qstate.h>
|
||||
|
||||
#include <QtCore/qcoreevent.h>
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qset.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
class QStateMachinePrivate;
|
||||
class QAbstractAnimation;
|
||||
class Q_CORE_EXPORT QStateMachine : public QState
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString errorString READ errorString)
|
||||
Q_PROPERTY(RestorePolicy globalRestorePolicy READ globalRestorePolicy WRITE setGlobalRestorePolicy)
|
||||
Q_ENUMS(RestorePolicy)
|
||||
#ifndef QT_NO_ANIMATION
|
||||
Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
|
||||
#endif
|
||||
public:
|
||||
class Q_CORE_EXPORT SignalEvent : public QEvent
|
||||
{
|
||||
public:
|
||||
SignalEvent(QObject *sender, int signalIndex,
|
||||
const QList<QVariant> &arguments);
|
||||
~SignalEvent();
|
||||
|
||||
inline QObject *sender() const { return m_sender; }
|
||||
inline int signalIndex() const { return m_signalIndex; }
|
||||
inline QList<QVariant> arguments() const { return m_arguments; }
|
||||
|
||||
private:
|
||||
QObject *m_sender;
|
||||
int m_signalIndex;
|
||||
QList<QVariant> m_arguments;
|
||||
|
||||
friend class QSignalTransitionPrivate;
|
||||
};
|
||||
|
||||
class Q_CORE_EXPORT WrappedEvent : public QEvent
|
||||
{
|
||||
public:
|
||||
WrappedEvent(QObject *object, QEvent *event);
|
||||
~WrappedEvent();
|
||||
|
||||
inline QObject *object() const { return m_object; }
|
||||
inline QEvent *event() const { return m_event; }
|
||||
|
||||
private:
|
||||
QObject *m_object;
|
||||
QEvent *m_event;
|
||||
};
|
||||
|
||||
enum EventPriority {
|
||||
NormalPriority,
|
||||
HighPriority
|
||||
};
|
||||
|
||||
enum RestorePolicy {
|
||||
DontRestoreProperties,
|
||||
RestoreProperties
|
||||
};
|
||||
|
||||
enum Error {
|
||||
NoError,
|
||||
NoInitialStateError,
|
||||
NoDefaultStateInHistoryStateError,
|
||||
NoCommonAncestorForTransitionError
|
||||
};
|
||||
|
||||
QStateMachine(QObject *parent = 0);
|
||||
~QStateMachine();
|
||||
|
||||
void addState(QAbstractState *state);
|
||||
void removeState(QAbstractState *state);
|
||||
|
||||
Error error() const;
|
||||
QString errorString() const;
|
||||
void clearError();
|
||||
|
||||
bool isRunning() const;
|
||||
|
||||
#ifndef QT_NO_ANIMATION
|
||||
bool isAnimated() const;
|
||||
void setAnimated(bool enabled);
|
||||
|
||||
void addDefaultAnimation(QAbstractAnimation *animation);
|
||||
QList<QAbstractAnimation *> defaultAnimations() const;
|
||||
void removeDefaultAnimation(QAbstractAnimation *animation);
|
||||
#endif // QT_NO_ANIMATION
|
||||
|
||||
QStateMachine::RestorePolicy globalRestorePolicy() const;
|
||||
void setGlobalRestorePolicy(QStateMachine::RestorePolicy restorePolicy);
|
||||
|
||||
void postEvent(QEvent *event, EventPriority priority = NormalPriority);
|
||||
int postDelayedEvent(QEvent *event, int delay);
|
||||
bool cancelDelayedEvent(int id);
|
||||
|
||||
QSet<QAbstractState*> configuration() const;
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE_EVENTFILTER
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
#endif
|
||||
|
||||
public Q_SLOTS:
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
Q_SIGNALS:
|
||||
void started();
|
||||
void stopped();
|
||||
|
||||
protected:
|
||||
void onEntry(QEvent *event);
|
||||
void onExit(QEvent *event);
|
||||
|
||||
virtual void beginSelectTransitions(QEvent *event);
|
||||
virtual void endSelectTransitions(QEvent *event);
|
||||
|
||||
virtual void beginMicrostep(QEvent *event);
|
||||
virtual void endMicrostep(QEvent *event);
|
||||
|
||||
bool event(QEvent *e);
|
||||
|
||||
protected:
|
||||
QStateMachine(QStateMachinePrivate &dd, QObject *parent);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QStateMachine)
|
||||
Q_DECLARE_PRIVATE(QStateMachine)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_start())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_process())
|
||||
#ifndef QT_NO_ANIMATION
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_animationFinished())
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
|
@ -1,246 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSTATEMACHINE_P_H
|
||||
#define QSTATEMACHINE_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 "qstate_p.h"
|
||||
|
||||
#include <QtCore/qcoreevent.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
#include <QtCore/qset.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QEvent;
|
||||
#ifndef QT_NO_STATEMACHINE_EVENTFILTER
|
||||
class QEventTransition;
|
||||
#endif
|
||||
class QSignalEventGenerator;
|
||||
class QSignalTransition;
|
||||
class QAbstractState;
|
||||
class QAbstractTransition;
|
||||
class QFinalState;
|
||||
class QHistoryState;
|
||||
class QState;
|
||||
|
||||
#ifndef QT_NO_ANIMATION
|
||||
class QAbstractAnimation;
|
||||
#endif
|
||||
|
||||
class QStateMachine;
|
||||
class Q_CORE_EXPORT QStateMachinePrivate : public QStatePrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QStateMachine)
|
||||
public:
|
||||
enum State {
|
||||
NotRunning,
|
||||
Starting,
|
||||
Running
|
||||
};
|
||||
enum EventProcessingMode {
|
||||
DirectProcessing,
|
||||
QueuedProcessing
|
||||
};
|
||||
enum StopProcessingReason {
|
||||
EventQueueEmpty,
|
||||
Finished,
|
||||
Stopped
|
||||
};
|
||||
|
||||
QStateMachinePrivate();
|
||||
~QStateMachinePrivate();
|
||||
|
||||
static QStateMachinePrivate *get(QStateMachine *q);
|
||||
|
||||
QState *findLCA(const QList<QAbstractState*> &states) const;
|
||||
|
||||
static bool stateEntryLessThan(QAbstractState *s1, QAbstractState *s2);
|
||||
static bool stateExitLessThan(QAbstractState *s1, QAbstractState *s2);
|
||||
|
||||
QAbstractState *findErrorState(QAbstractState *context);
|
||||
void setError(QStateMachine::Error error, QAbstractState *currentContext);
|
||||
|
||||
// private slots
|
||||
void _q_start();
|
||||
void _q_process();
|
||||
#ifndef QT_NO_ANIMATION
|
||||
void _q_animationFinished();
|
||||
#endif
|
||||
|
||||
QState *rootState() const;
|
||||
|
||||
QState *startState();
|
||||
void removeStartState();
|
||||
|
||||
void clearHistory();
|
||||
|
||||
void microstep(QEvent *event, const QList<QAbstractTransition*> &transitionList);
|
||||
bool isPreempted(const QAbstractState *s, const QSet<QAbstractTransition*> &transitions) const;
|
||||
QSet<QAbstractTransition*> selectTransitions(QEvent *event) const;
|
||||
QList<QAbstractState*> exitStates(QEvent *event, const QList<QAbstractTransition*> &transitionList);
|
||||
void executeTransitionContent(QEvent *event, const QList<QAbstractTransition*> &transitionList);
|
||||
QList<QAbstractState*> enterStates(QEvent *event, const QList<QAbstractTransition*> &enabledTransitions);
|
||||
void addStatesToEnter(QAbstractState *s, QState *root,
|
||||
QSet<QAbstractState*> &statesToEnter,
|
||||
QSet<QAbstractState*> &statesForDefaultEntry);
|
||||
|
||||
void applyProperties(const QList<QAbstractTransition*> &transitionList,
|
||||
const QList<QAbstractState*> &exitedStates,
|
||||
const QList<QAbstractState*> &enteredStates);
|
||||
|
||||
static QState *toStandardState(QAbstractState *state);
|
||||
static const QState *toStandardState(const QAbstractState *state);
|
||||
static QFinalState *toFinalState(QAbstractState *state);
|
||||
static QHistoryState *toHistoryState(QAbstractState *state);
|
||||
|
||||
bool isInFinalState(QAbstractState *s) const;
|
||||
static bool isFinal(const QAbstractState *s);
|
||||
static bool isParallel(const QAbstractState *s);
|
||||
bool isCompound(const QAbstractState *s) const;
|
||||
bool isAtomic(const QAbstractState *s) const;
|
||||
static bool isDescendantOf(const QAbstractState *s, const QAbstractState *other);
|
||||
static QList<QState*> properAncestors(const QAbstractState *s, const QState *upperBound);
|
||||
|
||||
void goToState(QAbstractState *targetState);
|
||||
|
||||
void registerTransitions(QAbstractState *state);
|
||||
void registerSignalTransition(QSignalTransition *transition);
|
||||
void unregisterSignalTransition(QSignalTransition *transition);
|
||||
#ifndef QT_NO_STATEMACHINE_EVENTFILTER
|
||||
void registerEventTransition(QEventTransition *transition);
|
||||
void unregisterEventTransition(QEventTransition *transition);
|
||||
void handleFilteredEvent(QObject *watched, QEvent *event);
|
||||
#endif
|
||||
void unregisterTransition(QAbstractTransition *transition);
|
||||
void unregisterAllTransitions();
|
||||
void handleTransitionSignal(QObject *sender, int signalIndex,
|
||||
void **args);
|
||||
|
||||
void postInternalEvent(QEvent *e);
|
||||
void postExternalEvent(QEvent *e);
|
||||
QEvent *dequeueInternalEvent();
|
||||
QEvent *dequeueExternalEvent();
|
||||
bool isInternalEventQueueEmpty();
|
||||
bool isExternalEventQueueEmpty();
|
||||
void processEvents(EventProcessingMode processingMode);
|
||||
void cancelAllDelayedEvents();
|
||||
|
||||
#ifndef QT_NO_PROPERTIES
|
||||
typedef QPair<QObject *, QByteArray> RestorableId;
|
||||
QHash<RestorableId, QVariant> registeredRestorables;
|
||||
void registerRestorable(QObject *object, const QByteArray &propertyName);
|
||||
void unregisterRestorable(QObject *object, const QByteArray &propertyName);
|
||||
bool hasRestorable(QObject *object, const QByteArray &propertyName) const;
|
||||
QVariant restorableValue(QObject *object, const QByteArray &propertyName) const;
|
||||
QList<QPropertyAssignment> restorablesToPropertyList(const QHash<RestorableId, QVariant> &restorables) const;
|
||||
#endif
|
||||
|
||||
State state;
|
||||
QState *_startState;
|
||||
bool processing;
|
||||
bool processingScheduled;
|
||||
bool stop;
|
||||
StopProcessingReason stopProcessingReason;
|
||||
QSet<QAbstractState*> configuration;
|
||||
QList<QEvent*> internalEventQueue;
|
||||
QList<QEvent*> externalEventQueue;
|
||||
QMutex internalEventMutex;
|
||||
QMutex externalEventMutex;
|
||||
|
||||
QStateMachine::Error error;
|
||||
QStateMachine::RestorePolicy globalRestorePolicy;
|
||||
|
||||
QString errorString;
|
||||
QSet<QAbstractState *> pendingErrorStates;
|
||||
QSet<QAbstractState *> pendingErrorStatesForDefaultEntry;
|
||||
|
||||
#ifndef QT_NO_ANIMATION
|
||||
bool animated;
|
||||
|
||||
QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> >
|
||||
initializeAnimation(QAbstractAnimation *abstractAnimation,
|
||||
const QPropertyAssignment &prop);
|
||||
|
||||
QHash<QAbstractState*, QList<QAbstractAnimation*> > animationsForState;
|
||||
QHash<QAbstractAnimation*, QPropertyAssignment> propertyForAnimation;
|
||||
QHash<QAbstractAnimation*, QAbstractState*> stateForAnimation;
|
||||
QSet<QAbstractAnimation*> resetAnimationEndValues;
|
||||
|
||||
QList<QAbstractAnimation *> defaultAnimations;
|
||||
QMultiHash<QAbstractState *, QAbstractAnimation *> defaultAnimationsForSource;
|
||||
QMultiHash<QAbstractState *, QAbstractAnimation *> defaultAnimationsForTarget;
|
||||
|
||||
#endif // QT_NO_ANIMATION
|
||||
|
||||
QSignalEventGenerator *signalEventGenerator;
|
||||
|
||||
QHash<const QObject*, QVector<int> > connections;
|
||||
#ifndef QT_NO_STATEMACHINE_EVENTFILTER
|
||||
QHash<QObject*, QHash<QEvent::Type, int> > qobjectEvents;
|
||||
#endif
|
||||
QHash<int, QEvent*> delayedEvents;
|
||||
QMutex delayedEventsMutex;
|
||||
|
||||
typedef QEvent* (*f_cloneEvent)(QEvent*);
|
||||
struct Handler {
|
||||
f_cloneEvent cloneEvent;
|
||||
};
|
||||
|
||||
static const Handler *handler;
|
||||
};
|
||||
|
||||
Q_CORE_EXPORT const QStateMachinePrivate::Handler *qcoreStateMachineHandler();
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,34 +0,0 @@
|
|||
set(CORE_HEADERS
|
||||
${CORE_HEADERS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qstatemachine.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qstatemachine_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qsignaleventgenerator_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qabstractstate.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qabstractstate_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qstate.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qstate_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qfinalstate.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qhistorystate.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qhistorystate_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qabstracttransition.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qabstracttransition_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qsignaltransition.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qsignaltransition_p.h
|
||||
# FIXME: only when !QT_NO_STATEMACHINE_EVENTFILTER
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qeventtransition.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qeventtransition_p.h
|
||||
)
|
||||
|
||||
set(CORE_SOURCES
|
||||
${CORE_SOURCES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qstatemachine.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qabstractstate.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qstate.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qfinalstate.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qhistorystate.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qabstracttransition.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qsignaltransition.cpp
|
||||
# FIXME: only when !QT_NO_STATEMACHINE_EVENTFILTER
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qeventtransition.cpp
|
||||
)
|
||||
|
|
@ -408,7 +408,6 @@ include(itemviews/itemviews.cmake)
|
|||
include(kernel/kernel.cmake)
|
||||
include(math3d/math3d.cmake)
|
||||
include(painting/painting.cmake)
|
||||
include(statemachine/statemachine.cmake)
|
||||
include(styles/styles.cmake)
|
||||
include(text/text.cmake)
|
||||
include(util/util.cmake)
|
||||
|
@ -433,7 +432,6 @@ include_directories(
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/kernel
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/math3d
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/painting
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/styles
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/text
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/util
|
||||
|
@ -451,7 +449,6 @@ include_directories(
|
|||
${CMAKE_CURRENT_BINARY_DIR}/kernel
|
||||
${CMAKE_CURRENT_BINARY_DIR}/math3d
|
||||
${CMAKE_CURRENT_BINARY_DIR}/painting
|
||||
${CMAKE_CURRENT_BINARY_DIR}/statemachine
|
||||
${CMAKE_CURRENT_BINARY_DIR}/styles
|
||||
${CMAKE_CURRENT_BINARY_DIR}/text
|
||||
${CMAKE_CURRENT_BINARY_DIR}/util
|
||||
|
|
|
@ -785,10 +785,6 @@ QApplication::QApplication(Display *dpy, int &argc, char **argv,
|
|||
extern void qInitDrawhelperAsm();
|
||||
extern int qRegisterGuiVariant();
|
||||
extern int qUnregisterGuiVariant();
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
extern int qRegisterGuiStateMachine();
|
||||
extern int qUnregisterGuiStateMachine();
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\fn void QApplicationPrivate::initialize()
|
||||
|
@ -810,10 +806,6 @@ void QApplicationPrivate::initialize()
|
|||
(void) QApplication::style(); // trigger creation of application style
|
||||
// trigger registering of QVariant's GUI types
|
||||
qRegisterGuiVariant();
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
// trigger registering of QStateMachine's GUI types
|
||||
qRegisterGuiStateMachine();
|
||||
#endif
|
||||
|
||||
is_app_running = true; // no longer starting up
|
||||
|
||||
|
@ -1013,10 +1005,6 @@ QApplication::~QApplication()
|
|||
QApplicationPrivate::fade_tooltip = false;
|
||||
QApplicationPrivate::widgetCount = false;
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
// trigger unregistering of QStateMachine's GUI types
|
||||
qUnregisterGuiStateMachine();
|
||||
#endif
|
||||
// trigger unregistering of QVariant's GUI types
|
||||
qUnregisterGuiVariant();
|
||||
}
|
||||
|
|
|
@ -1,211 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qbasickeyeventtransition_p.h"
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include <QtGui/qevent.h>
|
||||
#include <qdebug.h>
|
||||
#include <qabstracttransition_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\class QBasicKeyEventTransition
|
||||
\since 4.6
|
||||
\ingroup statemachine
|
||||
|
||||
\brief The QBasicKeyEventTransition class provides a transition for Qt key events.
|
||||
*/
|
||||
|
||||
class QBasicKeyEventTransitionPrivate : public QAbstractTransitionPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QBasicKeyEventTransition)
|
||||
public:
|
||||
QBasicKeyEventTransitionPrivate();
|
||||
|
||||
static QBasicKeyEventTransitionPrivate *get(QBasicKeyEventTransition *q);
|
||||
|
||||
QEvent::Type eventType;
|
||||
int key;
|
||||
Qt::KeyboardModifiers modifierMask;
|
||||
};
|
||||
|
||||
QBasicKeyEventTransitionPrivate::QBasicKeyEventTransitionPrivate()
|
||||
{
|
||||
eventType = QEvent::None;
|
||||
key = 0;
|
||||
modifierMask = Qt::NoModifier;
|
||||
}
|
||||
|
||||
QBasicKeyEventTransitionPrivate *QBasicKeyEventTransitionPrivate::get(QBasicKeyEventTransition *q)
|
||||
{
|
||||
return q->d_func();
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new key event transition with the given \a sourceState.
|
||||
*/
|
||||
QBasicKeyEventTransition::QBasicKeyEventTransition(QState *sourceState)
|
||||
: QAbstractTransition(*new QBasicKeyEventTransitionPrivate, sourceState)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new event transition for events of the given \a type for the
|
||||
given \a key, with the given \a sourceState.
|
||||
*/
|
||||
QBasicKeyEventTransition::QBasicKeyEventTransition(QEvent::Type type, int key,
|
||||
QState *sourceState)
|
||||
: QAbstractTransition(*new QBasicKeyEventTransitionPrivate, sourceState)
|
||||
{
|
||||
Q_D(QBasicKeyEventTransition);
|
||||
d->eventType = type;
|
||||
d->key = key;
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new event transition for events of the given \a type for the
|
||||
given \a key, with the given \a modifierMask and \a sourceState.
|
||||
*/
|
||||
QBasicKeyEventTransition::QBasicKeyEventTransition(QEvent::Type type, int key,
|
||||
Qt::KeyboardModifiers modifierMask,
|
||||
QState *sourceState)
|
||||
: QAbstractTransition(*new QBasicKeyEventTransitionPrivate, sourceState)
|
||||
{
|
||||
Q_D(QBasicKeyEventTransition);
|
||||
d->eventType = type;
|
||||
d->key = key;
|
||||
d->modifierMask = modifierMask;
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this event transition.
|
||||
*/
|
||||
QBasicKeyEventTransition::~QBasicKeyEventTransition()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the event type that this key event transition is associated with.
|
||||
*/
|
||||
QEvent::Type QBasicKeyEventTransition::eventType() const
|
||||
{
|
||||
Q_D(const QBasicKeyEventTransition);
|
||||
return d->eventType;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the event \a type that this key event transition is associated with.
|
||||
*/
|
||||
void QBasicKeyEventTransition::setEventType(QEvent::Type type)
|
||||
{
|
||||
Q_D(QBasicKeyEventTransition);
|
||||
d->eventType = type;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the key that this key event transition checks for.
|
||||
*/
|
||||
int QBasicKeyEventTransition::key() const
|
||||
{
|
||||
Q_D(const QBasicKeyEventTransition);
|
||||
return d->key;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the key that this key event transition will check for.
|
||||
*/
|
||||
void QBasicKeyEventTransition::setKey(int key)
|
||||
{
|
||||
Q_D(QBasicKeyEventTransition);
|
||||
d->key = key;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the keyboard modifier mask that this key event transition checks
|
||||
for.
|
||||
*/
|
||||
Qt::KeyboardModifiers QBasicKeyEventTransition::modifierMask() const
|
||||
{
|
||||
Q_D(const QBasicKeyEventTransition);
|
||||
return d->modifierMask;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the keyboard modifier mask that this key event transition will check
|
||||
for.
|
||||
*/
|
||||
void QBasicKeyEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
|
||||
{
|
||||
Q_D(QBasicKeyEventTransition);
|
||||
d->modifierMask = modifierMask;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QBasicKeyEventTransition::eventTest(QEvent *event)
|
||||
{
|
||||
Q_D(const QBasicKeyEventTransition);
|
||||
if (event->type() == d->eventType) {
|
||||
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
|
||||
return (ke->key() == d->key)
|
||||
&& ((ke->modifiers() & d->modifierMask) == d->modifierMask);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QBasicKeyEventTransition::onTransition(QEvent *)
|
||||
{
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
#include "moc_qbasickeyeventtransition_p.h"
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
|
@ -1,98 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QBASICKEYEVENTTRANSITION_P_H
|
||||
#define QBASICKEYEVENTTRANSITION_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 <QtCore/qabstracttransition.h>
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include <QtGui/qevent.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QBasicKeyEventTransitionPrivate;
|
||||
class Q_AUTOTEST_EXPORT QBasicKeyEventTransition : public QAbstractTransition
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QBasicKeyEventTransition(QState *sourceState = 0);
|
||||
QBasicKeyEventTransition(QEvent::Type type, int key, QState *sourceState = 0);
|
||||
QBasicKeyEventTransition(QEvent::Type type, int key,
|
||||
Qt::KeyboardModifiers modifierMask,
|
||||
QState *sourceState = 0);
|
||||
~QBasicKeyEventTransition();
|
||||
|
||||
QEvent::Type eventType() const;
|
||||
void setEventType(QEvent::Type type);
|
||||
|
||||
int key() const;
|
||||
void setKey(int key);
|
||||
|
||||
Qt::KeyboardModifiers modifierMask() const;
|
||||
void setModifierMask(Qt::KeyboardModifiers modifiers);
|
||||
|
||||
protected:
|
||||
bool eventTest(QEvent *event);
|
||||
void onTransition(QEvent *);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QBasicKeyEventTransition)
|
||||
Q_DECLARE_PRIVATE(QBasicKeyEventTransition)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
#endif
|
|
@ -1,216 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qbasicmouseeventtransition_p.h"
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include <QtGui/qevent.h>
|
||||
#include <QtGui/qpainterpath.h>
|
||||
#include <qdebug.h>
|
||||
#include <qabstracttransition_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\class QBasicMouseEventTransition
|
||||
\since 4.6
|
||||
\ingroup statemachine
|
||||
|
||||
\brief The QBasicMouseEventTransition class provides a transition for Qt mouse events.
|
||||
*/
|
||||
|
||||
class QBasicMouseEventTransitionPrivate : public QAbstractTransitionPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QBasicMouseEventTransition)
|
||||
public:
|
||||
QBasicMouseEventTransitionPrivate();
|
||||
|
||||
static QBasicMouseEventTransitionPrivate *get(QBasicMouseEventTransition *q);
|
||||
|
||||
QEvent::Type eventType;
|
||||
Qt::MouseButton button;
|
||||
Qt::KeyboardModifiers modifierMask;
|
||||
QPainterPath path;
|
||||
};
|
||||
|
||||
QBasicMouseEventTransitionPrivate::QBasicMouseEventTransitionPrivate()
|
||||
{
|
||||
eventType = QEvent::None;
|
||||
button = Qt::NoButton;
|
||||
}
|
||||
|
||||
QBasicMouseEventTransitionPrivate *QBasicMouseEventTransitionPrivate::get(QBasicMouseEventTransition *q)
|
||||
{
|
||||
return q->d_func();
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new mouse event transition with the given \a sourceState.
|
||||
*/
|
||||
QBasicMouseEventTransition::QBasicMouseEventTransition(QState *sourceState)
|
||||
: QAbstractTransition(*new QBasicMouseEventTransitionPrivate, sourceState)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new mouse event transition for events of the given \a type.
|
||||
*/
|
||||
QBasicMouseEventTransition::QBasicMouseEventTransition(QEvent::Type type,
|
||||
Qt::MouseButton button,
|
||||
QState *sourceState)
|
||||
: QAbstractTransition(*new QBasicMouseEventTransitionPrivate, sourceState)
|
||||
{
|
||||
Q_D(QBasicMouseEventTransition);
|
||||
d->eventType = type;
|
||||
d->button = button;
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this mouse event transition.
|
||||
*/
|
||||
QBasicMouseEventTransition::~QBasicMouseEventTransition()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the event type that this mouse event transition is associated with.
|
||||
*/
|
||||
QEvent::Type QBasicMouseEventTransition::eventType() const
|
||||
{
|
||||
Q_D(const QBasicMouseEventTransition);
|
||||
return d->eventType;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the event \a type that this mouse event transition is associated with.
|
||||
*/
|
||||
void QBasicMouseEventTransition::setEventType(QEvent::Type type)
|
||||
{
|
||||
Q_D(QBasicMouseEventTransition);
|
||||
d->eventType = type;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the button that this mouse event transition checks for.
|
||||
*/
|
||||
Qt::MouseButton QBasicMouseEventTransition::button() const
|
||||
{
|
||||
Q_D(const QBasicMouseEventTransition);
|
||||
return d->button;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the button that this mouse event transition will check for.
|
||||
*/
|
||||
void QBasicMouseEventTransition::setButton(Qt::MouseButton button)
|
||||
{
|
||||
Q_D(QBasicMouseEventTransition);
|
||||
d->button = button;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the keyboard modifier mask that this mouse event transition checks
|
||||
for.
|
||||
*/
|
||||
Qt::KeyboardModifiers QBasicMouseEventTransition::modifierMask() const
|
||||
{
|
||||
Q_D(const QBasicMouseEventTransition);
|
||||
return d->modifierMask;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the keyboard modifier mask that this mouse event transition will check
|
||||
for.
|
||||
*/
|
||||
void QBasicMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
|
||||
{
|
||||
Q_D(QBasicMouseEventTransition);
|
||||
d->modifierMask = modifierMask;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the hit test path for this mouse event transition.
|
||||
*/
|
||||
QPainterPath QBasicMouseEventTransition::hitTestPath() const
|
||||
{
|
||||
Q_D(const QBasicMouseEventTransition);
|
||||
return d->path;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the hit test path for this mouse event transition.
|
||||
*/
|
||||
void QBasicMouseEventTransition::setHitTestPath(const QPainterPath &path)
|
||||
{
|
||||
Q_D(QBasicMouseEventTransition);
|
||||
d->path = path;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QBasicMouseEventTransition::eventTest(QEvent *event)
|
||||
{
|
||||
Q_D(const QBasicMouseEventTransition);
|
||||
if (event->type() == d->eventType) {
|
||||
QMouseEvent *me = static_cast<QMouseEvent*>(event);
|
||||
return (me->button() == d->button)
|
||||
&& ((me->modifiers() & d->modifierMask) == d->modifierMask)
|
||||
&& (d->path.isEmpty() || d->path.contains(me->pos()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QBasicMouseEventTransition::onTransition(QEvent *)
|
||||
{
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
#include "moc_qbasicmouseeventtransition_p.h"
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
|
@ -1,101 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QBASICMOUSEEVENTTRANSITION_P_H
|
||||
#define QBASICMOUSEEVENTTRANSITION_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 <QtCore/qabstracttransition.h>
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include <QtGui/qevent.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QPainterPath;
|
||||
|
||||
class QBasicMouseEventTransitionPrivate;
|
||||
class Q_AUTOTEST_EXPORT QBasicMouseEventTransition : public QAbstractTransition
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QBasicMouseEventTransition(QState *sourceState = 0);
|
||||
QBasicMouseEventTransition(QEvent::Type type, Qt::MouseButton button,
|
||||
QState *sourceState = 0);
|
||||
~QBasicMouseEventTransition();
|
||||
|
||||
QEvent::Type eventType() const;
|
||||
void setEventType(QEvent::Type type);
|
||||
|
||||
Qt::MouseButton button() const;
|
||||
void setButton(Qt::MouseButton button);
|
||||
|
||||
Qt::KeyboardModifiers modifierMask() const;
|
||||
void setModifierMask(Qt::KeyboardModifiers modifiers);
|
||||
|
||||
QPainterPath hitTestPath() const;
|
||||
void setHitTestPath(const QPainterPath &path);
|
||||
|
||||
protected:
|
||||
bool eventTest(QEvent *event);
|
||||
void onTransition(QEvent *);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QBasicMouseEventTransition)
|
||||
Q_DECLARE_PRIVATE(QBasicMouseEventTransition)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
#endif
|
|
@ -1,454 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstatemachine.h>
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include <qstatemachine_p.h>
|
||||
#include <QtGui/qevent.h>
|
||||
#include <QtGui/qgraphicssceneevent.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static QEvent *cloneEvent(QEvent *e)
|
||||
{
|
||||
switch (e->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseButtonDblClick:
|
||||
case QEvent::MouseMove:
|
||||
return new QMouseEvent(*static_cast<QMouseEvent*>(e));
|
||||
case QEvent::KeyPress:
|
||||
case QEvent::KeyRelease:
|
||||
return new QKeyEvent(*static_cast<QKeyEvent*>(e));
|
||||
case QEvent::FocusIn:
|
||||
case QEvent::FocusOut:
|
||||
return new QFocusEvent(*static_cast<QFocusEvent*>(e));
|
||||
case QEvent::Enter:
|
||||
case QEvent::Leave:
|
||||
return new QEvent(*e);
|
||||
break;
|
||||
case QEvent::Paint:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
case QEvent::Move:
|
||||
return new QMoveEvent(*static_cast<QMoveEvent*>(e));
|
||||
case QEvent::Resize:
|
||||
return new QResizeEvent(*static_cast<QResizeEvent*>(e));
|
||||
case QEvent::Create:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
case QEvent::Destroy:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
case QEvent::Show:
|
||||
return new QShowEvent(*static_cast<QShowEvent*>(e));
|
||||
case QEvent::Hide:
|
||||
return new QHideEvent(*static_cast<QHideEvent*>(e));
|
||||
case QEvent::Close:
|
||||
return new QCloseEvent(*static_cast<QCloseEvent*>(e));
|
||||
case QEvent::Quit:
|
||||
case QEvent::ParentChange:
|
||||
case QEvent::ParentAboutToChange:
|
||||
case QEvent::ThreadChange:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::WindowActivate:
|
||||
case QEvent::WindowDeactivate:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::ShowToParent:
|
||||
case QEvent::HideToParent:
|
||||
return new QEvent(*e);
|
||||
#ifndef QT_NO_WHEELEVENT
|
||||
case QEvent::Wheel:
|
||||
return new QWheelEvent(*static_cast<QWheelEvent*>(e));
|
||||
#endif //QT_NO_WHEELEVENT
|
||||
case QEvent::WindowTitleChange:
|
||||
case QEvent::WindowIconChange:
|
||||
case QEvent::ApplicationWindowIconChange:
|
||||
case QEvent::ApplicationFontChange:
|
||||
case QEvent::ApplicationLayoutDirectionChange:
|
||||
case QEvent::ApplicationPaletteChange:
|
||||
case QEvent::PaletteChange:
|
||||
return new QEvent(*e);
|
||||
case QEvent::Clipboard:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
case QEvent::Speech:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
case QEvent::MetaCall:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
case QEvent::SockAct:
|
||||
case QEvent::DeferredDelete:
|
||||
return new QEvent(*e);
|
||||
#ifndef QT_NO_DRAGANDDROP
|
||||
case QEvent::DragEnter:
|
||||
return new QDragEnterEvent(*static_cast<QDragEnterEvent*>(e));
|
||||
case QEvent::DragMove:
|
||||
return new QDragMoveEvent(*static_cast<QDragMoveEvent*>(e));
|
||||
case QEvent::DragLeave:
|
||||
return new QDragLeaveEvent(*static_cast<QDragLeaveEvent*>(e));
|
||||
case QEvent::Drop:
|
||||
return new QDropEvent(*static_cast<QDragMoveEvent*>(e));
|
||||
case QEvent::DragResponse:
|
||||
return new QDragResponseEvent(*static_cast<QDragResponseEvent*>(e));
|
||||
#endif
|
||||
case QEvent::ChildAdded:
|
||||
return new QChildEvent(*static_cast<QChildEvent*>(e));
|
||||
case QEvent::ChildPolished:
|
||||
return new QChildEvent(*static_cast<QChildEvent*>(e));
|
||||
case QEvent::ChildRemoved:
|
||||
return new QChildEvent(*static_cast<QChildEvent*>(e));
|
||||
case QEvent::ShowWindowRequest:
|
||||
case QEvent::PolishRequest:
|
||||
case QEvent::Polish:
|
||||
case QEvent::LayoutRequest:
|
||||
case QEvent::UpdateRequest:
|
||||
case QEvent::UpdateLater:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::EmbeddingControl:
|
||||
case QEvent::ActivateControl:
|
||||
case QEvent::DeactivateControl:
|
||||
return new QEvent(*e);
|
||||
|
||||
#ifndef QT_NO_CONTEXTMENU
|
||||
case QEvent::ContextMenu:
|
||||
return new QContextMenuEvent(*static_cast<QContextMenuEvent*>(e));
|
||||
#endif
|
||||
case QEvent::InputMethod:
|
||||
return new QInputMethodEvent(*static_cast<QInputMethodEvent*>(e));
|
||||
case QEvent::AccessibilityPrepare:
|
||||
return new QEvent(*e);
|
||||
#ifndef QT_NO_TABLETEVENT
|
||||
case QEvent::TabletMove:
|
||||
return new QTabletEvent(*static_cast<QTabletEvent*>(e));
|
||||
#endif //QT_NO_TABLETEVENT
|
||||
case QEvent::LocaleChange:
|
||||
case QEvent::LanguageChange:
|
||||
case QEvent::LayoutDirectionChange:
|
||||
case QEvent::Style:
|
||||
return new QEvent(*e);
|
||||
#ifndef QT_NO_TABLETEVENT
|
||||
case QEvent::TabletPress:
|
||||
return new QTabletEvent(*static_cast<QTabletEvent*>(e));
|
||||
case QEvent::TabletRelease:
|
||||
return new QTabletEvent(*static_cast<QTabletEvent*>(e));
|
||||
#endif //QT_NO_TABLETEVENT
|
||||
case QEvent::OkRequest:
|
||||
case QEvent::HelpRequest:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::IconDrag:
|
||||
return new QIconDragEvent(*static_cast<QIconDragEvent*>(e));
|
||||
|
||||
case QEvent::FontChange:
|
||||
case QEvent::EnabledChange:
|
||||
case QEvent::ActivationChange:
|
||||
case QEvent::StyleChange:
|
||||
case QEvent::IconTextChange:
|
||||
case QEvent::ModifiedChange:
|
||||
case QEvent::MouseTrackingChange:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::WindowBlocked:
|
||||
case QEvent::WindowUnblocked:
|
||||
return new QEvent(*e);
|
||||
case QEvent::WindowStateChange:
|
||||
return new QWindowStateChangeEvent(*static_cast<QWindowStateChangeEvent*>(e));
|
||||
|
||||
case QEvent::ToolTip:
|
||||
return new QHelpEvent(*static_cast<QHelpEvent*>(e));
|
||||
case QEvent::WhatsThis:
|
||||
return new QHelpEvent(*static_cast<QHelpEvent*>(e));
|
||||
#ifndef QT_NO_STATUSTIP
|
||||
case QEvent::StatusTip:
|
||||
return new QStatusTipEvent(*static_cast<QStatusTipEvent*>(e));
|
||||
#endif //QT_NO_STATUSTIP
|
||||
#ifndef QT_NO_ACTION
|
||||
case QEvent::ActionChanged:
|
||||
case QEvent::ActionAdded:
|
||||
case QEvent::ActionRemoved:
|
||||
return new QActionEvent(*static_cast<QActionEvent*>(e));
|
||||
#endif
|
||||
case QEvent::FileOpen:
|
||||
return new QFileOpenEvent(*static_cast<QFileOpenEvent*>(e));
|
||||
|
||||
#ifndef QT_NO_SHORTCUT
|
||||
case QEvent::Shortcut:
|
||||
return new QShortcutEvent(*static_cast<QShortcutEvent*>(e));
|
||||
#endif //QT_NO_SHORTCUT
|
||||
case QEvent::ShortcutOverride:
|
||||
return new QKeyEvent(*static_cast<QKeyEvent*>(e));
|
||||
|
||||
|
||||
#ifndef QT_NO_WHATSTHIS
|
||||
case QEvent::WhatsThisClicked:
|
||||
return new QWhatsThisClickedEvent(*static_cast<QWhatsThisClickedEvent*>(e));
|
||||
#endif //QT_NO_WHATSTHIS
|
||||
|
||||
#ifndef QT_NO_TOOLBAR
|
||||
case QEvent::ToolBarChange:
|
||||
return new QToolBarChangeEvent(*static_cast<QToolBarChangeEvent*>(e));
|
||||
#endif //QT_NO_TOOLBAR
|
||||
|
||||
case QEvent::ApplicationActivate:
|
||||
case QEvent::ApplicationDeactivate:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::QueryWhatsThis:
|
||||
return new QHelpEvent(*static_cast<QHelpEvent*>(e));
|
||||
case QEvent::EnterWhatsThisMode:
|
||||
case QEvent::LeaveWhatsThisMode:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::ZOrderChange:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::HoverEnter:
|
||||
case QEvent::HoverLeave:
|
||||
case QEvent::HoverMove:
|
||||
return new QHoverEvent(*static_cast<QHoverEvent*>(e));
|
||||
|
||||
case QEvent::AccessibilityHelp:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
case QEvent::AccessibilityDescription:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
|
||||
#ifdef QT_KEYPAD_NAVIGATION
|
||||
case QEvent::EnterEditFocus:
|
||||
case QEvent::LeaveEditFocus:
|
||||
return new QEvent(*e);
|
||||
#endif
|
||||
case QEvent::AcceptDropsChange:
|
||||
return new QEvent(*e);
|
||||
|
||||
#ifndef QT_NO_GRAPHICSVIEW
|
||||
case QEvent::GraphicsSceneMouseMove:
|
||||
case QEvent::GraphicsSceneMousePress:
|
||||
case QEvent::GraphicsSceneMouseRelease:
|
||||
case QEvent::GraphicsSceneMouseDoubleClick: {
|
||||
QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent*>(e);
|
||||
QGraphicsSceneMouseEvent *me2 = new QGraphicsSceneMouseEvent(me->type());
|
||||
me2->setWidget(me->widget());
|
||||
me2->setPos(me->pos());
|
||||
me2->setScenePos(me->scenePos());
|
||||
me2->setScreenPos(me->screenPos());
|
||||
// ### for all buttons
|
||||
me2->setButtonDownPos(Qt::LeftButton, me->buttonDownPos(Qt::LeftButton));
|
||||
me2->setButtonDownPos(Qt::RightButton, me->buttonDownPos(Qt::RightButton));
|
||||
me2->setButtonDownScreenPos(Qt::LeftButton, me->buttonDownScreenPos(Qt::LeftButton));
|
||||
me2->setButtonDownScreenPos(Qt::RightButton, me->buttonDownScreenPos(Qt::RightButton));
|
||||
me2->setLastPos(me->lastPos());
|
||||
me2->setLastScenePos(me->lastScenePos());
|
||||
me2->setLastScreenPos(me->lastScreenPos());
|
||||
me2->setButtons(me->buttons());
|
||||
me2->setButton(me->button());
|
||||
me2->setModifiers(me->modifiers());
|
||||
return me2;
|
||||
}
|
||||
|
||||
case QEvent::GraphicsSceneContextMenu: {
|
||||
QGraphicsSceneContextMenuEvent *me = static_cast<QGraphicsSceneContextMenuEvent*>(e);
|
||||
QGraphicsSceneContextMenuEvent *me2 = new QGraphicsSceneContextMenuEvent(me->type());
|
||||
me2->setWidget(me->widget());
|
||||
me2->setPos(me->pos());
|
||||
me2->setScenePos(me->scenePos());
|
||||
me2->setScreenPos(me->screenPos());
|
||||
me2->setModifiers(me->modifiers());
|
||||
me2->setReason(me->reason());
|
||||
return me2;
|
||||
}
|
||||
|
||||
case QEvent::GraphicsSceneHoverEnter:
|
||||
case QEvent::GraphicsSceneHoverMove:
|
||||
case QEvent::GraphicsSceneHoverLeave: {
|
||||
QGraphicsSceneHoverEvent *he = static_cast<QGraphicsSceneHoverEvent*>(e);
|
||||
QGraphicsSceneHoverEvent *he2 = new QGraphicsSceneHoverEvent(he->type());
|
||||
he2->setPos(he->pos());
|
||||
he2->setScenePos(he->scenePos());
|
||||
he2->setScreenPos(he->screenPos());
|
||||
he2->setLastPos(he->lastPos());
|
||||
he2->setLastScenePos(he->lastScenePos());
|
||||
he2->setLastScreenPos(he->lastScreenPos());
|
||||
he2->setModifiers(he->modifiers());
|
||||
return he2;
|
||||
}
|
||||
case QEvent::GraphicsSceneHelp:
|
||||
return new QHelpEvent(*static_cast<QHelpEvent*>(e));
|
||||
case QEvent::GraphicsSceneDragEnter:
|
||||
case QEvent::GraphicsSceneDragMove:
|
||||
case QEvent::GraphicsSceneDragLeave:
|
||||
case QEvent::GraphicsSceneDrop: {
|
||||
QGraphicsSceneDragDropEvent *dde = static_cast<QGraphicsSceneDragDropEvent*>(e);
|
||||
QGraphicsSceneDragDropEvent *dde2 = new QGraphicsSceneDragDropEvent(dde->type());
|
||||
dde2->setPos(dde->pos());
|
||||
dde2->setScenePos(dde->scenePos());
|
||||
dde2->setScreenPos(dde->screenPos());
|
||||
dde2->setButtons(dde->buttons());
|
||||
dde2->setModifiers(dde->modifiers());
|
||||
return dde2;
|
||||
}
|
||||
case QEvent::GraphicsSceneWheel: {
|
||||
QGraphicsSceneWheelEvent *we = static_cast<QGraphicsSceneWheelEvent*>(e);
|
||||
QGraphicsSceneWheelEvent *we2 = new QGraphicsSceneWheelEvent(we->type());
|
||||
we2->setPos(we->pos());
|
||||
we2->setScenePos(we->scenePos());
|
||||
we2->setScreenPos(we->screenPos());
|
||||
we2->setButtons(we->buttons());
|
||||
we2->setModifiers(we->modifiers());
|
||||
we2->setOrientation(we->orientation());
|
||||
we2->setDelta(we->delta());
|
||||
return we2;
|
||||
}
|
||||
#endif
|
||||
case QEvent::KeyboardLayoutChange:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::DynamicPropertyChange:
|
||||
return new QDynamicPropertyChangeEvent(*static_cast<QDynamicPropertyChangeEvent*>(e));
|
||||
|
||||
#ifndef QT_NO_TABLETEVENT
|
||||
case QEvent::TabletEnterProximity:
|
||||
case QEvent::TabletLeaveProximity:
|
||||
return new QTabletEvent(*static_cast<QTabletEvent*>(e));
|
||||
#endif //QT_NO_TABLETEVENT
|
||||
|
||||
case QEvent::NonClientAreaMouseMove:
|
||||
case QEvent::NonClientAreaMouseButtonPress:
|
||||
case QEvent::NonClientAreaMouseButtonRelease:
|
||||
case QEvent::NonClientAreaMouseButtonDblClick:
|
||||
return new QMouseEvent(*static_cast<QMouseEvent*>(e));
|
||||
|
||||
case QEvent::ContentsRectChange:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::FutureCallOut:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
#ifndef QT_NO_GRAPHICSVIEW
|
||||
case QEvent::GraphicsSceneResize: {
|
||||
QGraphicsSceneResizeEvent *re = static_cast<QGraphicsSceneResizeEvent*>(e);
|
||||
QGraphicsSceneResizeEvent *re2 = new QGraphicsSceneResizeEvent();
|
||||
re2->setOldSize(re->oldSize());
|
||||
re2->setNewSize(re->newSize());
|
||||
return re2;
|
||||
}
|
||||
case QEvent::GraphicsSceneMove: {
|
||||
QGraphicsSceneMoveEvent *me = static_cast<QGraphicsSceneMoveEvent*>(e);
|
||||
QGraphicsSceneMoveEvent *me2 = new QGraphicsSceneMoveEvent();
|
||||
me2->setWidget(me->widget());
|
||||
me2->setNewPos(me->newPos());
|
||||
me2->setOldPos(me->oldPos());
|
||||
return me2;
|
||||
}
|
||||
#endif
|
||||
case QEvent::CursorChange:
|
||||
case QEvent::ToolTipChange:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::NetworkReplyUpdated:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
|
||||
case QEvent::GrabMouse:
|
||||
case QEvent::UngrabMouse:
|
||||
case QEvent::GrabKeyboard:
|
||||
case QEvent::UngrabKeyboard:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::TouchBegin:
|
||||
case QEvent::TouchUpdate:
|
||||
case QEvent::TouchEnd:
|
||||
return new QTouchEvent(*static_cast<QTouchEvent*>(e));
|
||||
|
||||
#ifndef QT_NO_GESTURES
|
||||
case QEvent::NativeGesture:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
#endif
|
||||
|
||||
case QEvent::RequestSoftwareInputPanel:
|
||||
case QEvent::CloseSoftwareInputPanel:
|
||||
return new QEvent(*e);
|
||||
|
||||
case QEvent::User:
|
||||
case QEvent::MaxUser:
|
||||
Q_ASSERT_X(false, "cloneEvent()", "not implemented");
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
return qcoreStateMachineHandler()->cloneEvent(e);
|
||||
}
|
||||
|
||||
const QStateMachinePrivate::Handler qt_gui_statemachine_handler = {
|
||||
cloneEvent
|
||||
};
|
||||
|
||||
static const QStateMachinePrivate::Handler *qt_guistatemachine_last_handler = 0;
|
||||
int qRegisterGuiStateMachine()
|
||||
{
|
||||
qt_guistatemachine_last_handler = QStateMachinePrivate::handler;
|
||||
QStateMachinePrivate::handler = &qt_gui_statemachine_handler;
|
||||
return 1;
|
||||
}
|
||||
Q_CONSTRUCTOR_FUNCTION(qRegisterGuiStateMachine)
|
||||
|
||||
int qUnregisterGuiStateMachine()
|
||||
{
|
||||
QStateMachinePrivate::handler = qt_guistatemachine_last_handler;
|
||||
return 1;
|
||||
}
|
||||
Q_DESTRUCTOR_FUNCTION(qUnregisterGuiStateMachine)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
|
|
@ -1,181 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qkeyeventtransition.h"
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include "qbasickeyeventtransition_p.h"
|
||||
#include <QtCore/qstatemachine.h>
|
||||
#include <qeventtransition_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QKeyEventTransition
|
||||
|
||||
\brief The QKeyEventTransition class provides a transition for key events.
|
||||
|
||||
\since 4.6
|
||||
\ingroup statemachine
|
||||
|
||||
QKeyEventTransition is part of \l{The State Machine Framework}.
|
||||
|
||||
\sa QState::addTransition()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QKeyEventTransition::key
|
||||
|
||||
\brief the key that this key event transition is associated with
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QKeyEventTransition::modifierMask
|
||||
|
||||
\brief the keyboard modifier mask that this key event transition checks for
|
||||
*/
|
||||
|
||||
class QKeyEventTransitionPrivate : public QEventTransitionPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QKeyEventTransition)
|
||||
public:
|
||||
QKeyEventTransitionPrivate() {}
|
||||
|
||||
QBasicKeyEventTransition *transition;
|
||||
};
|
||||
|
||||
/*!
|
||||
Constructs a new key event transition with the given \a sourceState.
|
||||
*/
|
||||
QKeyEventTransition::QKeyEventTransition(QState *sourceState)
|
||||
: QEventTransition(*new QKeyEventTransitionPrivate, sourceState)
|
||||
{
|
||||
Q_D(QKeyEventTransition);
|
||||
d->transition = new QBasicKeyEventTransition();
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new key event transition for events of the given \a type for
|
||||
the given \a object, with the given \a key and \a sourceState.
|
||||
*/
|
||||
QKeyEventTransition::QKeyEventTransition(QObject *object, QEvent::Type type,
|
||||
int key, QState *sourceState)
|
||||
: QEventTransition(*new QKeyEventTransitionPrivate, object, type, sourceState)
|
||||
{
|
||||
Q_D(QKeyEventTransition);
|
||||
d->transition = new QBasicKeyEventTransition(type, key);
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this key event transition.
|
||||
*/
|
||||
QKeyEventTransition::~QKeyEventTransition()
|
||||
{
|
||||
Q_D(QKeyEventTransition);
|
||||
delete d->transition;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the key that this key event transition checks for.
|
||||
*/
|
||||
int QKeyEventTransition::key() const
|
||||
{
|
||||
Q_D(const QKeyEventTransition);
|
||||
return d->transition->key();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the key that this key event transition will check for.
|
||||
*/
|
||||
void QKeyEventTransition::setKey(int key)
|
||||
{
|
||||
Q_D(QKeyEventTransition);
|
||||
d->transition->setKey(key);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the keyboard modifier mask that this key event transition checks
|
||||
for.
|
||||
*/
|
||||
Qt::KeyboardModifiers QKeyEventTransition::modifierMask() const
|
||||
{
|
||||
Q_D(const QKeyEventTransition);
|
||||
return d->transition->modifierMask();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the keyboard modifier mask that this key event transition will
|
||||
check for to \a modifierMask.
|
||||
*/
|
||||
void QKeyEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
|
||||
{
|
||||
Q_D(QKeyEventTransition);
|
||||
d->transition->setModifierMask(modifierMask);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QKeyEventTransition::eventTest(QEvent *event)
|
||||
{
|
||||
Q_D(const QKeyEventTransition);
|
||||
if (!QEventTransition::eventTest(event))
|
||||
return false;
|
||||
QStateMachine::WrappedEvent *we = static_cast<QStateMachine::WrappedEvent*>(event);
|
||||
d->transition->setEventType(we->event()->type());
|
||||
return QAbstractTransitionPrivate::get(d->transition)->callEventTest(we->event());
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QKeyEventTransition::onTransition(QEvent *event)
|
||||
{
|
||||
QEventTransition::onTransition(event);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
#include "moc_qkeyeventtransition.h"
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
|
@ -1,87 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QKEYEVENTTRANSITION_H
|
||||
#define QKEYEVENTTRANSITION_H
|
||||
|
||||
#include <QtCore/qeventtransition.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
class QKeyEventTransitionPrivate;
|
||||
class Q_GUI_EXPORT QKeyEventTransition : public QEventTransition
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int key READ key WRITE setKey)
|
||||
Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask)
|
||||
public:
|
||||
QKeyEventTransition(QState *sourceState = 0);
|
||||
QKeyEventTransition(QObject *object, QEvent::Type type, int key,
|
||||
QState *sourceState = 0);
|
||||
~QKeyEventTransition();
|
||||
|
||||
int key() const;
|
||||
void setKey(int key);
|
||||
|
||||
Qt::KeyboardModifiers modifierMask() const;
|
||||
void setModifierMask(Qt::KeyboardModifiers modifiers);
|
||||
|
||||
protected:
|
||||
void onTransition(QEvent *event);
|
||||
bool eventTest(QEvent *event);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QKeyEventTransition)
|
||||
Q_DECLARE_PRIVATE(QKeyEventTransition)
|
||||
};
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
|
@ -1,209 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmouseeventtransition.h"
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
#include "qbasicmouseeventtransition_p.h"
|
||||
#include <QtCore/qstatemachine.h>
|
||||
#include <QtGui/qpainterpath.h>
|
||||
#include <qeventtransition_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QMouseEventTransition
|
||||
|
||||
\brief The QMouseEventTransition class provides a transition for mouse events.
|
||||
|
||||
\since 4.6
|
||||
\ingroup statemachine
|
||||
|
||||
QMouseEventTransition is part of \l{The State Machine Framework}.
|
||||
|
||||
\sa QState::addTransition()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QMouseEventTransition::button
|
||||
|
||||
\brief the button that this mouse event transition is associated with
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QMouseEventTransition::modifierMask
|
||||
|
||||
\brief the keyboard modifier mask that this mouse event transition checks for
|
||||
*/
|
||||
|
||||
class QMouseEventTransitionPrivate : public QEventTransitionPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QMouseEventTransition)
|
||||
public:
|
||||
QMouseEventTransitionPrivate();
|
||||
|
||||
QBasicMouseEventTransition *transition;
|
||||
};
|
||||
|
||||
QMouseEventTransitionPrivate::QMouseEventTransitionPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new mouse event transition with the given \a sourceState.
|
||||
*/
|
||||
QMouseEventTransition::QMouseEventTransition(QState *sourceState)
|
||||
: QEventTransition(*new QMouseEventTransitionPrivate, sourceState)
|
||||
{
|
||||
Q_D(QMouseEventTransition);
|
||||
d->transition = new QBasicMouseEventTransition();
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new mouse event transition for events of the given \a type for
|
||||
the given \a object, with the given \a button and \a sourceState.
|
||||
*/
|
||||
QMouseEventTransition::QMouseEventTransition(QObject *object, QEvent::Type type,
|
||||
Qt::MouseButton button,
|
||||
QState *sourceState)
|
||||
: QEventTransition(*new QMouseEventTransitionPrivate, object, type, sourceState)
|
||||
{
|
||||
Q_D(QMouseEventTransition);
|
||||
d->transition = new QBasicMouseEventTransition(type, button);
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this mouse event transition.
|
||||
*/
|
||||
QMouseEventTransition::~QMouseEventTransition()
|
||||
{
|
||||
Q_D(QMouseEventTransition);
|
||||
delete d->transition;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the button that this mouse event transition checks for.
|
||||
*/
|
||||
Qt::MouseButton QMouseEventTransition::button() const
|
||||
{
|
||||
Q_D(const QMouseEventTransition);
|
||||
return d->transition->button();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a button that this mouse event transition will check for.
|
||||
*/
|
||||
void QMouseEventTransition::setButton(Qt::MouseButton button)
|
||||
{
|
||||
Q_D(QMouseEventTransition);
|
||||
d->transition->setButton(button);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the keyboard modifier mask that this mouse event transition checks
|
||||
for.
|
||||
*/
|
||||
Qt::KeyboardModifiers QMouseEventTransition::modifierMask() const
|
||||
{
|
||||
Q_D(const QMouseEventTransition);
|
||||
return d->transition->modifierMask();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the keyboard modifier mask that this mouse event transition will
|
||||
check for to \a modifierMask.
|
||||
*/
|
||||
void QMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
|
||||
{
|
||||
Q_D(QMouseEventTransition);
|
||||
d->transition->setModifierMask(modifierMask);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the hit test path for this mouse event transition.
|
||||
*/
|
||||
QPainterPath QMouseEventTransition::hitTestPath() const
|
||||
{
|
||||
Q_D(const QMouseEventTransition);
|
||||
return d->transition->hitTestPath();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the hit test path for this mouse event transition to \a path.
|
||||
If a valid path has been set, the transition will only trigger if the mouse
|
||||
event position (QMouseEvent::pos()) is inside the path.
|
||||
|
||||
\sa QPainterPath::contains()
|
||||
*/
|
||||
void QMouseEventTransition::setHitTestPath(const QPainterPath &path)
|
||||
{
|
||||
Q_D(QMouseEventTransition);
|
||||
d->transition->setHitTestPath(path);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
bool QMouseEventTransition::eventTest(QEvent *event)
|
||||
{
|
||||
Q_D(const QMouseEventTransition);
|
||||
if (!QEventTransition::eventTest(event))
|
||||
return false;
|
||||
QStateMachine::WrappedEvent *we = static_cast<QStateMachine::WrappedEvent*>(event);
|
||||
d->transition->setEventType(we->event()->type());
|
||||
return QAbstractTransitionPrivate::get(d->transition)->callEventTest(we->event());
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QMouseEventTransition::onTransition(QEvent *event)
|
||||
{
|
||||
QEventTransition::onTransition(event);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
#include "moc_qmouseeventtransition.h"
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
|
@ -1,91 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** 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 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMOUSEEVENTTRANSITION_H
|
||||
#define QMOUSEEVENTTRANSITION_H
|
||||
|
||||
#include <QtCore/qeventtransition.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
||||
class QMouseEventTransitionPrivate;
|
||||
class QPainterPath;
|
||||
class Q_GUI_EXPORT QMouseEventTransition : public QEventTransition
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Qt::MouseButton button READ button WRITE setButton)
|
||||
Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask)
|
||||
public:
|
||||
QMouseEventTransition(QState *sourceState = 0);
|
||||
QMouseEventTransition(QObject *object, QEvent::Type type,
|
||||
Qt::MouseButton button, QState *sourceState = 0);
|
||||
~QMouseEventTransition();
|
||||
|
||||
Qt::MouseButton button() const;
|
||||
void setButton(Qt::MouseButton button);
|
||||
|
||||
Qt::KeyboardModifiers modifierMask() const;
|
||||
void setModifierMask(Qt::KeyboardModifiers modifiers);
|
||||
|
||||
QPainterPath hitTestPath() const;
|
||||
void setHitTestPath(const QPainterPath &path);
|
||||
|
||||
protected:
|
||||
void onTransition(QEvent *event);
|
||||
bool eventTest(QEvent *event);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QMouseEventTransition)
|
||||
Q_DECLARE_PRIVATE(QMouseEventTransition)
|
||||
};
|
||||
|
||||
#endif //QT_NO_STATEMACHINE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
|
@ -1,21 +0,0 @@
|
|||
set(GUI_SOURCES
|
||||
${GUI_SOURCES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qguistatemachine.cpp
|
||||
)
|
||||
|
||||
# TODO: !contains(DEFINES, QT_NO_STATEMACHINE_EVENTFILTER) {
|
||||
set(GUI_HEADERS
|
||||
${GUI_HEADERS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qkeyeventtransition.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qmouseeventtransition.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qbasickeyeventtransition_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qbasicmouseeventtransition_p.h
|
||||
)
|
||||
|
||||
set(GUI_SOURCES
|
||||
${GUI_SOURCES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qkeyeventtransition.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qmouseeventtransition.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qbasickeyeventtransition.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/statemachine/qbasicmouseeventtransition.cpp
|
||||
)
|
|
@ -112,16 +112,6 @@ static const ClassInfoEntry qclass_lib_map[] = {
|
|||
{ "QThread", "QtCore/qthread.h"},
|
||||
{ "QThreadStorageData", "QtCore/qthreadstorage.h"},
|
||||
{ "QWaitCondition", "QtCore/qwaitcondition.h"},
|
||||
{ "QAbstractState", "QtCore/qabstractstate.h"},
|
||||
{ "QAbstractTransition", "QtCore/qabstracttransition.h"},
|
||||
{ "QEventTransition", "QtCore/qeventtransition.h"},
|
||||
{ "QFinalState", "QtCore/qfinalstate.h"},
|
||||
{ "QHistoryState", "QtCore/qhistorystate.h"},
|
||||
{ "QSignalTransition", "QtCore/qsignaltransition.h"},
|
||||
{ "QState", "QtCore/qstate.h"},
|
||||
{ "QStateMachine", "QtCore/qstatemachine.h"},
|
||||
{ "SignalEvent", "QtCore/qstatemachine.h"},
|
||||
{ "WrappedEvent", "QtCore/qstatemachine.h"},
|
||||
{ "QFactoryInterface", "QtCore/qfactoryinterface.h"},
|
||||
{ "QLibrary", "QtCore/qlibrary.h"},
|
||||
{ "QPluginLoader", "QtCore/qpluginloader.h"},
|
||||
|
@ -370,8 +360,6 @@ static const ClassInfoEntry qclass_lib_map[] = {
|
|||
{ "QAccessibleFactoryInterface", "QtGui/qaccessibleplugin.h"},
|
||||
{ "QAccessiblePlugin", "QtGui/qaccessibleplugin.h"},
|
||||
{ "QAccessibleWidget", "QtGui/qaccessiblewidget.h"},
|
||||
{ "QKeyEventTransition", "QtGui/qkeyeventtransition.h"},
|
||||
{ "QMouseEventTransition", "QtGui/qmouseeventtransition.h"},
|
||||
{ "QBrush", "QtGui/qbrush.h"},
|
||||
{ "QGradient", "QtGui/qbrush.h"},
|
||||
{ "QLinearGradient", "QtGui/qbrush.h"},
|
||||
|
@ -736,6 +724,6 @@ static const ClassInfoEntry qclass_lib_map[] = {
|
|||
{ "QSslKey", "QtNetwork/qsslkey.h"},
|
||||
{ "QSslSocket", "QtNetwork/qsslsocket.h"},
|
||||
};
|
||||
static const int qclass_lib_count = 730;
|
||||
static const int qclass_lib_count = 718;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue