summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-09-28 11:13:47 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-09-28 11:21:50 (GMT)
commit587c004ce82844980c679547f86109174cbe6202 (patch)
tree5614136a0a10622fb7a119772e545d4c26aa9af4 /src
parent9021dd294b4d998192ed9b06ce86be6ed8ffddf2 (diff)
downloadQt-587c004ce82844980c679547f86109174cbe6202.zip
Qt-587c004ce82844980c679547f86109174cbe6202.tar.gz
Qt-587c004ce82844980c679547f86109174cbe6202.tar.bz2
Make QSignalEvent and QWrappedEvent inner classes of QStateMachine
Those two classes are specific to the state machine framework, but their names were so generic that we felt they were polluting the Q-namespace. They are now QStateMachine::SignalEvent and QStateMachine::WrappedEvent. Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qcoreevent.cpp4
-rw-r--r--src/corelib/statemachine/qeventtransition.cpp12
-rw-r--r--src/corelib/statemachine/qsignalevent.h83
-rw-r--r--src/corelib/statemachine/qsignaltransition.cpp15
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp49
-rw-r--r--src/corelib/statemachine/qstatemachine.h36
-rw-r--r--src/corelib/statemachine/qwrappedevent.h80
-rw-r--r--src/corelib/statemachine/statemachine.pri4
-rw-r--r--src/gui/statemachine/qkeyeventtransition.cpp4
-rw-r--r--src/gui/statemachine/qmouseeventtransition.cpp4
10 files changed, 78 insertions, 213 deletions
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index a7a3b5d..185c305 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -192,6 +192,7 @@ QT_BEGIN_NAMESPACE
\value ShortcutOverride Key press in child, for overriding shortcut key handling (QKeyEvent).
\value Show Widget was shown on screen (QShowEvent).
\value ShowToParent A child widget has been shown.
+ \value Signal A signal delivered to a state machine (QStateMachine::SignalEvent).
\value SockAct Socket activated, used to implement QSocketNotifier.
\value StatusTip A status tip is requested (QStatusTipEvent).
\value StyleChange Widget's style has been changed.
@@ -220,7 +221,7 @@ QT_BEGIN_NAMESPACE
\value WindowStateChange The \l{QWidget::windowState()}{window's state} (minimized, maximized or full-screen) has changed (QWindowStateChangeEvent).
\value WindowTitleChange The window title has changed.
\value WindowUnblocked The window is unblocked after a modal dialog exited.
- \value Wrapped The event is a wrapper for, i.e., contains, another event (QWrappedEvent).
+ \value Wrapped The event is a wrapper for, i.e., contains, another event (QStateMachine::WrappedEvent).
\value ZOrderChange The widget's z-order has changed. This event is never sent to top level windows.
\value KeyboardLayoutChange The keyboard layout has changed.
\value DynamicPropertyChange A dynamic property was added, changed or removed from the object.
@@ -269,7 +270,6 @@ QT_BEGIN_NAMESPACE
\omitvalue NetworkReplyUpdated
\omitvalue FutureCallOut
\omitvalue CocoaRequestModal
- \omitvalue Signal
\omitvalue SymbianDeferredFocusChanged
\omitvalue UpdateSoftKeys
\omitvalue NativeGesture
diff --git a/src/corelib/statemachine/qeventtransition.cpp b/src/corelib/statemachine/qeventtransition.cpp
index 2ce7b4a..f278371 100644
--- a/src/corelib/statemachine/qeventtransition.cpp
+++ b/src/corelib/statemachine/qeventtransition.cpp
@@ -44,7 +44,6 @@
#ifndef QT_NO_STATEMACHINE
#include "qeventtransition_p.h"
-#include "qwrappedevent.h"
#include "qstate.h"
#include "qstate_p.h"
#include "qstatemachine.h"
@@ -83,10 +82,11 @@ QT_BEGIN_NAMESPACE
\section1 Subclassing
When reimplementing the eventTest() function, you should first call the base
- implementation to verify that the event is a QWrappedEvent for the proper
- object and event type. You may then cast the event to a QWrappedEvent and
- get the original event by calling QWrappedEvent::event(), and perform
- additional checks on that object.
+ 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()
*/
@@ -232,7 +232,7 @@ bool QEventTransition::eventTest(QEvent *event)
{
Q_D(const QEventTransition);
if (event->type() == QEvent::Wrapped) {
- QWrappedEvent *we = static_cast<QWrappedEvent*>(event);
+ QStateMachine::WrappedEvent *we = static_cast<QStateMachine::WrappedEvent*>(event);
return (we->object() == d->object)
&& (we->event()->type() == d->eventType);
}
diff --git a/src/corelib/statemachine/qsignalevent.h b/src/corelib/statemachine/qsignalevent.h
deleted file mode 100644
index 6d2bd63..0000000
--- a/src/corelib/statemachine/qsignalevent.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSIGNALEVENT_H
-#define QSIGNALEVENT_H
-
-#include <QtCore/qcoreevent.h>
-
-#include <QtCore/qlist.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Core)
-
-#ifndef QT_NO_STATEMACHINE
-
-class Q_CORE_EXPORT QSignalEvent : public QEvent
-{
-public:
- QSignalEvent(QObject *sender, int signalIndex,
- const QList<QVariant> &arguments);
- ~QSignalEvent();
-
- 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;
-};
-
-#endif //QT_NO_STATEMACHINE
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp
index 74655e6..9811725 100644
--- a/src/corelib/statemachine/qsignaltransition.cpp
+++ b/src/corelib/statemachine/qsignaltransition.cpp
@@ -44,7 +44,6 @@
#ifndef QT_NO_STATEMACHINE
#include "qsignaltransition_p.h"
-#include "qsignalevent.h"
#include "qstate.h"
#include "qstate_p.h"
#include "qstatemachine.h"
@@ -68,7 +67,7 @@ QT_BEGIN_NAMESPACE
You can subclass QSignalTransition and reimplement eventTest() to make a
signal transition conditional; the event object passed to eventTest() will
- be a QSignalEvent object. Example:
+ be a QStateMachine::SignalEvent object. Example:
\code
class CheckedTransition : public QSignalTransition
@@ -80,7 +79,7 @@ QT_BEGIN_NAMESPACE
bool eventTest(QEvent *e) const {
if (!QSignalTransition::eventTest(e))
return false;
- QSignalEvent *se = static_cast<QSignalEvent*>(e);
+ QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(e);
return (se->arguments().at(0).toInt() == Qt::Checked);
}
};
@@ -212,9 +211,9 @@ void QSignalTransition::setSignal(const QByteArray &signal)
/*!
\reimp
- The \a event is a QSignalEvent object. The default implementation returns
- true if the event's sender and signal index match this transition, and
- returns false otherwise.
+ 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)
{
@@ -222,7 +221,7 @@ bool QSignalTransition::eventTest(QEvent *event)
if (event->type() == QEvent::Signal) {
if (d->signalIndex == -1)
return false;
- QSignalEvent *se = static_cast<QSignalEvent*>(event);
+ QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
return (se->sender() == d->sender)
&& (se->signalIndex() == d->signalIndex);
}
@@ -250,7 +249,7 @@ void QSignalTransitionPrivate::callOnTransition(QEvent *e)
Q_Q(QSignalTransition);
if (e->type() == QEvent::Signal) {
- QSignalEvent *se = static_cast<QSignalEvent *>(e);
+ QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent *>(e);
int savedSignalIndex = se->m_signalIndex;
se->m_signalIndex = originalSignalIndex;
q->onTransition(e);
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 7876d43..503eec0 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -50,7 +50,6 @@
#include "qabstracttransition_p.h"
#include "qsignaltransition.h"
#include "qsignaltransition_p.h"
-#include "qsignalevent.h"
#include "qsignaleventgenerator_p.h"
#include "qabstractstate.h"
#include "qabstractstate_p.h"
@@ -63,7 +62,6 @@
#ifndef QT_NO_STATEMACHINE_EVENTFILTER
#include "qeventtransition.h"
#include "qeventtransition_p.h"
-#include "qwrappedevent.h"
#endif
#ifndef QT_NO_ANIMATION
@@ -1534,7 +1532,7 @@ void QStateMachinePrivate::handleTransitionSignal(QObject *sender, int signalInd
qDebug() << q_func() << ": sending signal event ( sender =" << sender
<< ", signal =" << sender->metaObject()->method(signalIndex).signature() << ')';
#endif
- internalEventQueue.append(new QSignalEvent(sender, signalIndex, vargs));
+ internalEventQueue.append(new QStateMachine::SignalEvent(sender, signalIndex, vargs));
scheduleProcess();
}
@@ -1880,7 +1878,7 @@ bool QStateMachine::eventFilter(QObject *watched, QEvent *event)
Q_D(QStateMachine);
Q_ASSERT(d->qobjectEvents.contains(watched));
if (d->qobjectEvents[watched].contains(event->type()))
- postEvent(new QWrappedEvent(watched, d->handler->cloneEvent(event)));
+ postEvent(new QStateMachine::WrappedEvent(watched, d->handler->cloneEvent(event)));
return false;
}
#endif
@@ -2076,16 +2074,16 @@ QSignalEventGenerator::QSignalEventGenerator(QStateMachine *parent)
}
/*!
- \class QSignalEvent
+ \class QStateMachine::SignalEvent
- \brief The QSignalEvent class represents a Qt signal event.
+ \brief The SignalEvent class represents a Qt signal event.
\since 4.6
\ingroup statemachine
A signal event is generated by a QStateMachine in response to a Qt
signal. The QSignalTransition class provides a transition associated with a
- signal event. QSignalEvent is part of \l{The State Machine Framework}.
+ signal event. QStateMachine::SignalEvent is part of \l{The State Machine Framework}.
The sender() function returns the object that generated the signal. The
signalIndex() function returns the index of the signal. The arguments()
@@ -2097,25 +2095,25 @@ QSignalEventGenerator::QSignalEventGenerator(QStateMachine *parent)
/*!
\internal
- Constructs a new QSignalEvent object with the given \a sender, \a
+ Constructs a new SignalEvent object with the given \a sender, \a
signalIndex and \a arguments.
*/
-QSignalEvent::QSignalEvent(QObject *sender, int signalIndex,
- const QList<QVariant> &arguments)
+QStateMachine::SignalEvent::SignalEvent(QObject *sender, int signalIndex,
+ const QList<QVariant> &arguments)
: QEvent(QEvent::Signal), m_sender(sender),
m_signalIndex(signalIndex), m_arguments(arguments)
{
}
/*!
- Destroys this QSignalEvent.
+ Destroys this SignalEvent.
*/
-QSignalEvent::~QSignalEvent()
+QStateMachine::SignalEvent::~SignalEvent()
{
}
/*!
- \fn QSignalEvent::sender() const
+ \fn QStateMachine::SignalEvent::sender() const
Returns the object that emitted the signal.
@@ -2123,7 +2121,7 @@ QSignalEvent::~QSignalEvent()
*/
/*!
- \fn QSignalEvent::signalIndex() const
+ \fn QStateMachine::SignalEvent::signalIndex() const
Returns the index of the signal.
@@ -2131,23 +2129,24 @@ QSignalEvent::~QSignalEvent()
*/
/*!
- \fn QSignalEvent::arguments() const
+ \fn QStateMachine::SignalEvent::arguments() const
Returns the arguments of the signal.
*/
/*!
- \class QWrappedEvent
+ \class QStateMachine::WrappedEvent
- \brief The QWrappedEvent class holds a clone of an event associated with a QObject.
+ \brief The WrappedEvent class holds a clone of an event associated with a QObject.
\since 4.6
\ingroup statemachine
A wrapped event is generated by a QStateMachine in response to a Qt
event. The QEventTransition class provides a transition associated with a
- such an event. QWrappedEvent is part of \l{The State Machine Framework}.
+ such an event. QStateMachine::WrappedEvent is part of \l{The State Machine
+ Framework}.
The object() function returns the object that generated the event. The
event() function returns a clone of the original event.
@@ -2158,32 +2157,32 @@ QSignalEvent::~QSignalEvent()
/*!
\internal
- Constructs a new QWrappedEvent object with the given \a object
+ Constructs a new WrappedEvent object with the given \a object
and \a event.
- The QWrappedEvent object takes ownership of \a event.
+ The WrappedEvent object takes ownership of \a event.
*/
-QWrappedEvent::QWrappedEvent(QObject *object, QEvent *event)
+QStateMachine::WrappedEvent::WrappedEvent(QObject *object, QEvent *event)
: QEvent(QEvent::Wrapped), m_object(object), m_event(event)
{
}
/*!
- Destroys this QWrappedEvent.
+ Destroys this WrappedEvent.
*/
-QWrappedEvent::~QWrappedEvent()
+QStateMachine::WrappedEvent::~WrappedEvent()
{
delete m_event;
}
/*!
- \fn QWrappedEvent::object() const
+ \fn QStateMachine::WrappedEvent::object() const
Returns the object that the event is associated with.
*/
/*!
- \fn QWrappedEvent::event() const
+ \fn QStateMachine::WrappedEvent::event() const
Returns a clone of the original event.
*/
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index dd524dd..a0b2b14 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -44,6 +44,7 @@
#include <QtCore/qstate.h>
+#include <QtCore/qcoreevent.h>
#include <QtCore/qlist.h>
#include <QtCore/qobject.h>
#include <QtCore/qset.h>
@@ -56,8 +57,6 @@ QT_MODULE(Core)
#ifndef QT_NO_STATEMACHINE
-class QEvent;
-
class QStateMachinePrivate;
class QAbstractAnimation;
class Q_CORE_EXPORT QStateMachine : public QState
@@ -70,6 +69,39 @@ class Q_CORE_EXPORT QStateMachine : public QState
Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled)
#endif
public:
+ class 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 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 RestorePolicy {
DoNotRestoreProperties,
RestoreProperties
diff --git a/src/corelib/statemachine/qwrappedevent.h b/src/corelib/statemachine/qwrappedevent.h
deleted file mode 100644
index e0a131b..0000000
--- a/src/corelib/statemachine/qwrappedevent.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWRAPPEDEVENT_H
-#define QWRAPPEDEVENT_H
-
-#include <QtCore/qcoreevent.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Core)
-
-#ifndef QT_NO_STATEMACHINE
-
-class QObject;
-
-class Q_CORE_EXPORT QWrappedEvent : public QEvent
-{
-public:
- QWrappedEvent(QObject *object, QEvent *event);
- ~QWrappedEvent();
-
- inline QObject *object() const { return m_object; }
- inline QEvent *event() const { return m_event; }
-
-private:
- QObject *m_object;
- QEvent *m_event;
-
-private:
- Q_DISABLE_COPY(QWrappedEvent)
-};
-
-#endif //QT_NO_STATEMACHINE
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/corelib/statemachine/statemachine.pri b/src/corelib/statemachine/statemachine.pri
index 5b19bc1..910cf5e 100644
--- a/src/corelib/statemachine/statemachine.pri
+++ b/src/corelib/statemachine/statemachine.pri
@@ -10,7 +10,6 @@ HEADERS += $$PWD/qstatemachine.h \
$$PWD/qhistorystate_p.h \
$$PWD/qabstracttransition.h \
$$PWD/qabstracttransition_p.h \
- $$PWD/qsignalevent.h \
$$PWD/qsignaltransition.h \
$$PWD/qsignaltransition_p.h
@@ -23,8 +22,7 @@ SOURCES += $$PWD/qstatemachine.cpp \
$$PWD/qsignaltransition.cpp
!contains(DEFINES, QT_NO_STATEMACHINE_EVENTFILTER) {
-HEADERS += $$PWD/qwrappedevent.h \
- $$PWD/qeventtransition.h \
+HEADERS += $$PWD/qeventtransition.h \
$$PWD/qeventtransition_p.h
SOURCES += $$PWD/qeventtransition.cpp
}
diff --git a/src/gui/statemachine/qkeyeventtransition.cpp b/src/gui/statemachine/qkeyeventtransition.cpp
index 825b2ec..dee3168 100644
--- a/src/gui/statemachine/qkeyeventtransition.cpp
+++ b/src/gui/statemachine/qkeyeventtransition.cpp
@@ -44,7 +44,7 @@
#ifndef QT_NO_STATEMACHINE
#include "qbasickeyeventtransition_p.h"
-#include <QtCore/qwrappedevent.h>
+#include <QtCore/qstatemachine.h>
#include <private/qeventtransition_p.h>
QT_BEGIN_NAMESPACE
@@ -160,7 +160,7 @@ bool QKeyEventTransition::eventTest(QEvent *event)
Q_D(const QKeyEventTransition);
if (!QEventTransition::eventTest(event))
return false;
- QWrappedEvent *we = static_cast<QWrappedEvent*>(event);
+ QStateMachine::WrappedEvent *we = static_cast<QStateMachine::WrappedEvent*>(event);
d->transition->setEventType(we->event()->type());
return QAbstractTransitionPrivate::get(d->transition)->callEventTest(we->event());
}
diff --git a/src/gui/statemachine/qmouseeventtransition.cpp b/src/gui/statemachine/qmouseeventtransition.cpp
index 564c8d2..86cacf7 100644
--- a/src/gui/statemachine/qmouseeventtransition.cpp
+++ b/src/gui/statemachine/qmouseeventtransition.cpp
@@ -44,7 +44,7 @@
#ifndef QT_NO_STATEMACHINE
#include "qbasicmouseeventtransition_p.h"
-#include <QtCore/qwrappedevent.h>
+#include <QtCore/qstatemachine.h>
#include <QtGui/qpainterpath.h>
#include <private/qeventtransition_p.h>
@@ -188,7 +188,7 @@ bool QMouseEventTransition::eventTest(QEvent *event)
Q_D(const QMouseEventTransition);
if (!QEventTransition::eventTest(event))
return false;
- QWrappedEvent *we = static_cast<QWrappedEvent*>(event);
+ QStateMachine::WrappedEvent *we = static_cast<QStateMachine::WrappedEvent*>(event);
d->transition->setEventType(we->event()->type());
return QAbstractTransitionPrivate::get(d->transition)->callEventTest(we->event());
}