Qt 4.8
qeventtransition.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qeventtransition.h"
43 
44 #ifndef QT_NO_STATEMACHINE
45 
46 #include "qeventtransition_p.h"
47 #include "qstate.h"
48 #include "qstate_p.h"
49 #include "qstatemachine.h"
50 #include "qstatemachine_p.h"
51 #include <qdebug.h>
52 
54 
115 {
116  object = 0;
118  registered = false;
119 }
120 
122 {
123  return q->d_func();
124 }
125 
127 {
129  if (!registered || !machine())
130  return;
132 }
133 
135 {
137  if (!machine() || !machine()->configuration().contains(sourceState()))
138  return;
140 }
141 
146  : QAbstractTransition(*new QEventTransitionPrivate, sourceState)
147 {
148 }
149 
156  : QAbstractTransition(*new QEventTransitionPrivate, sourceState)
157 {
159  d->registered = false;
160  d->object = object;
161  d->eventType = type;
162 }
163 
168  : QAbstractTransition(dd, parent)
169 {
170 }
171 
177  : QAbstractTransition(dd, parent)
178 {
180  d->registered = false;
181  d->object = object;
182  d->eventType = type;
183 }
184 
189 {
190 }
191 
196 {
197  Q_D(const QEventTransition);
198  return d->eventType;
199 }
200 
205 {
207  if (d->eventType == type)
208  return;
209  d->unregister();
210  d->eventType = type;
211  d->maybeRegister();
212 }
213 
218 {
219  Q_D(const QEventTransition);
220  return d->object;
221 }
222 
228 {
230  if (d->object == object)
231  return;
232  d->unregister();
233  d->object = object;
234  d->maybeRegister();
235 }
236 
241 {
242  Q_D(const QEventTransition);
243  if (event->type() == QEvent::StateMachineWrapped) {
245  return (we->object() == d->object)
246  && (we->event()->type() == d->eventType);
247  }
248  return false;
249 }
250 
255 {
256  Q_UNUSED(event);
257 }
258 
263 {
264  return QAbstractTransition::event(e);
265 }
266 
268 
269 #endif //QT_NO_STATEMACHINE
double d
Definition: qnumeric_p.h:62
static QEventTransitionPrivate * get(QEventTransition *q)
int type
Definition: qmetatype.cpp:239
The WrappedEvent class inherits QEvent and holds a clone of an event associated with a QObject...
Definition: qstatemachine.h:92
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QAbstractTransition class is the base class of transitions between QAbstractState objects...
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
The QState class provides a general-purpose state for QStateMachine.
Definition: qstate.h:61
#define Q_Q(Class)
Definition: qglobal.h:2483
QObject * object() const
Returns the object that the event is associated with.
Definition: qstatemachine.h:98
void unregisterEventTransition(QEventTransition *transition)
bool event(QEvent *e)
Reimplemented Function
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static QStateMachinePrivate * get(QStateMachine *q)
The QEventTransition class provides a QObject-specific transition for Qt events.
~QEventTransition()
Destroys this QObject event transition.
QState * sourceState() const
bool eventTest(QEvent *event)
Reimplemented Function
void registerEventTransition(QEventTransition *transition)
QEventTransition(QState *sourceState=0)
Constructs a new QEventTransition object with the given sourceState.
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
QObject * eventSource() const
QStateMachine * machine() const
void onTransition(QEvent *event)
Reimplemented Function
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
bool event(QEvent *e)
Reimplemented Function
void setEventType(QEvent::Type type)
Sets the event type that this event transition is associated with.
void setEventSource(QObject *object)
Sets the event source associated with this event transition to be the given object.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QEvent::Type eventType() const
QEvent * event() const
Returns a clone of the original event.
Definition: qstatemachine.h:99