summaryrefslogtreecommitdiffstats
path: root/src/gui/statemachine
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/statemachine')
-rw-r--r--src/gui/statemachine/qbasickeyeventtransition.cpp29
-rw-r--r--src/gui/statemachine/qbasickeyeventtransition_p.h9
-rw-r--r--src/gui/statemachine/qbasicmouseeventtransition.cpp24
-rw-r--r--src/gui/statemachine/qbasicmouseeventtransition_p.h5
-rw-r--r--src/gui/statemachine/qkeyeventtransition.cpp44
-rw-r--r--src/gui/statemachine/qkeyeventtransition.h8
-rw-r--r--src/gui/statemachine/qmouseeventtransition.cpp57
-rw-r--r--src/gui/statemachine/qmouseeventtransition.h8
-rw-r--r--src/gui/statemachine/statemachine.pri3
9 files changed, 125 insertions, 62 deletions
diff --git a/src/gui/statemachine/qbasickeyeventtransition.cpp b/src/gui/statemachine/qbasickeyeventtransition.cpp
index 2ce428c..7821feb 100644
--- a/src/gui/statemachine/qbasickeyeventtransition.cpp
+++ b/src/gui/statemachine/qbasickeyeventtransition.cpp
@@ -39,14 +39,14 @@ public:
QEvent::Type eventType;
int key;
- Qt::KeyboardModifiers modifiers;
+ Qt::KeyboardModifiers modifiersMask;
};
QBasicKeyEventTransitionPrivate::QBasicKeyEventTransitionPrivate()
{
eventType = QEvent::None;
key = 0;
- modifiers = Qt::NoModifier;
+ modifiersMask = Qt::NoModifier;
}
QBasicKeyEventTransitionPrivate *QBasicKeyEventTransitionPrivate::get(QBasicKeyEventTransition *q)
@@ -77,17 +77,17 @@ QBasicKeyEventTransition::QBasicKeyEventTransition(QEvent::Type type, int key,
/*!
Constructs a new event transition for events of the given \a type for the
- given \a key, with the given \a modifiers and \a sourceState.
+ given \a key, with the given \a modifiersMask and \a sourceState.
*/
QBasicKeyEventTransition::QBasicKeyEventTransition(QEvent::Type type, int key,
- Qt::KeyboardModifiers modifiers,
+ Qt::KeyboardModifiers modifiersMask,
QState *sourceState)
: QAbstractTransition(*new QBasicKeyEventTransitionPrivate, sourceState)
{
Q_D(QBasicKeyEventTransition);
d->eventType = type;
d->key = key;
- d->modifiers = modifiers;
+ d->modifiersMask = modifiersMask;
}
/*!
@@ -134,21 +134,23 @@ void QBasicKeyEventTransition::setKey(int key)
}
/*!
- Returns the keyboard modifiers that this key event transition checks for.
+ Returns the keyboard modifiers mask that this key event transition checks
+ for.
*/
-Qt::KeyboardModifiers QBasicKeyEventTransition::modifiers() const
+Qt::KeyboardModifiers QBasicKeyEventTransition::modifiersMask() const
{
Q_D(const QBasicKeyEventTransition);
- return d->modifiers;
+ return d->modifiersMask;
}
/*!
- Sets the keyboard modifiers that this key event transition will check for.
+ Sets the keyboard modifiers mask that this key event transition will check
+ for.
*/
-void QBasicKeyEventTransition::setModifiers(Qt::KeyboardModifiers modifiers)
+void QBasicKeyEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
{
Q_D(QBasicKeyEventTransition);
- d->modifiers = modifiers;
+ d->modifiersMask = modifiersMask;
}
/*!
@@ -159,7 +161,8 @@ bool QBasicKeyEventTransition::eventTest(QEvent *event) const
Q_D(const QBasicKeyEventTransition);
if (event->type() == d->eventType) {
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
- return (ke->key() == d->key) && (ke->modifiers() == d->modifiers);
+ return (ke->key() == d->key)
+ && ((ke->modifiers() & d->modifiersMask) == d->modifiersMask);
}
return false;
}
@@ -167,7 +170,7 @@ bool QBasicKeyEventTransition::eventTest(QEvent *event) const
/*!
\reimp
*/
-void QBasicKeyEventTransition::onTransition()
+void QBasicKeyEventTransition::onTransition(QEvent *)
{
}
diff --git a/src/gui/statemachine/qbasickeyeventtransition_p.h b/src/gui/statemachine/qbasickeyeventtransition_p.h
index ff52f4d..0d08da0 100644
--- a/src/gui/statemachine/qbasickeyeventtransition_p.h
+++ b/src/gui/statemachine/qbasickeyeventtransition_p.h
@@ -41,7 +41,8 @@ public:
QBasicKeyEventTransition(QState *sourceState = 0);
QBasicKeyEventTransition(QEvent::Type type, int key, QState *sourceState = 0);
QBasicKeyEventTransition(QEvent::Type type, int key,
- Qt::KeyboardModifiers modifiers, QState *sourceState = 0);
+ Qt::KeyboardModifiers modifiersMask,
+ QState *sourceState = 0);
~QBasicKeyEventTransition();
QEvent::Type eventType() const;
@@ -50,12 +51,12 @@ public:
int key() const;
void setKey(int key);
- Qt::KeyboardModifiers modifiers() const;
- void setModifiers(Qt::KeyboardModifiers modifiers);
+ Qt::KeyboardModifiers modifiersMask() const;
+ void setModifiersMask(Qt::KeyboardModifiers modifiers);
protected:
bool eventTest(QEvent *event) const;
- void onTransition();
+ void onTransition(QEvent *);
private:
Q_DISABLE_COPY(QBasicKeyEventTransition)
diff --git a/src/gui/statemachine/qbasicmouseeventtransition.cpp b/src/gui/statemachine/qbasicmouseeventtransition.cpp
index b7583f8..0cb727e 100644
--- a/src/gui/statemachine/qbasicmouseeventtransition.cpp
+++ b/src/gui/statemachine/qbasicmouseeventtransition.cpp
@@ -39,6 +39,7 @@ public:
QEvent::Type eventType;
Qt::MouseButton button;
+ Qt::KeyboardModifiers modifiersMask;
QPainterPath path;
};
@@ -118,6 +119,26 @@ void QBasicMouseEventTransition::setButton(Qt::MouseButton button)
}
/*!
+ Returns the keyboard modifiers mask that this mouse event transition checks
+ for.
+*/
+Qt::KeyboardModifiers QBasicMouseEventTransition::modifiersMask() const
+{
+ Q_D(const QBasicMouseEventTransition);
+ return d->modifiersMask;
+}
+
+/*!
+ Sets the keyboard modifiers mask that this mouse event transition will check
+ for.
+*/
+void QBasicMouseEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
+{
+ Q_D(QBasicMouseEventTransition);
+ d->modifiersMask = modifiersMask;
+}
+
+/*!
Returns the path for this mouse event transition.
*/
QPainterPath QBasicMouseEventTransition::path() const
@@ -144,6 +165,7 @@ bool QBasicMouseEventTransition::eventTest(QEvent *event) const
if (event->type() == d->eventType) {
QMouseEvent *me = static_cast<QMouseEvent*>(event);
return (me->button() == d->button)
+ && ((me->modifiers() & d->modifiersMask) == d->modifiersMask)
&& (d->path.isEmpty() || d->path.contains(me->pos()));
}
return false;
@@ -152,7 +174,7 @@ bool QBasicMouseEventTransition::eventTest(QEvent *event) const
/*!
\reimp
*/
-void QBasicMouseEventTransition::onTransition()
+void QBasicMouseEventTransition::onTransition(QEvent *)
{
}
diff --git a/src/gui/statemachine/qbasicmouseeventtransition_p.h b/src/gui/statemachine/qbasicmouseeventtransition_p.h
index ee04fc7..20c7f8f 100644
--- a/src/gui/statemachine/qbasicmouseeventtransition_p.h
+++ b/src/gui/statemachine/qbasicmouseeventtransition_p.h
@@ -51,12 +51,15 @@ public:
Qt::MouseButton button() const;
void setButton(Qt::MouseButton button);
+ Qt::KeyboardModifiers modifiersMask() const;
+ void setModifiersMask(Qt::KeyboardModifiers modifiers);
+
QPainterPath path() const;
void setPath(const QPainterPath &path);
protected:
bool eventTest(QEvent *event) const;
- void onTransition();
+ void onTransition(QEvent *);
private:
Q_DISABLE_COPY(QBasicMouseEventTransition)
diff --git a/src/gui/statemachine/qkeyeventtransition.cpp b/src/gui/statemachine/qkeyeventtransition.cpp
index a4e882d..e6ab11b 100644
--- a/src/gui/statemachine/qkeyeventtransition.cpp
+++ b/src/gui/statemachine/qkeyeventtransition.cpp
@@ -11,6 +11,7 @@
#include "qkeyeventtransition.h"
#include "qbasickeyeventtransition_p.h"
+#include <QtCore/qwrappedevent.h>
#if defined(QT_EXPERIMENTAL_SOLUTION)
# include "qeventtransition_p.h"
@@ -25,6 +26,7 @@ QT_BEGIN_NAMESPACE
\brief The QKeyEventTransition class provides a transition for key events.
+ \since 4.6
\ingroup statemachine
QKeyEventTransition is part of \l{The State Machine Framework}.
@@ -38,6 +40,12 @@ QT_BEGIN_NAMESPACE
\brief the key that this key event transition is associated with
*/
+/*!
+ \property QKeyEventTransition::modifiersMask
+
+ \brief the keyboard modifiers mask that this key event transition checks for
+*/
+
class QKeyEventTransitionPrivate : public QEventTransitionPrivate
{
Q_DECLARE_PUBLIC(QKeyEventTransition)
@@ -110,32 +118,23 @@ void QKeyEventTransition::setKey(int key)
}
/*!
- Returns the keyboard modifiers that this key event transition checks for.
+ Returns the keyboard modifiers mask that this key event transition checks
+ for.
*/
-Qt::KeyboardModifiers QKeyEventTransition::modifiers() const
+Qt::KeyboardModifiers QKeyEventTransition::modifiersMask() const
{
Q_D(const QKeyEventTransition);
- return d->transition->modifiers();
+ return d->transition->modifiersMask();
}
/*!
- Sets the keyboard \a modifiers that this key event transition will check
- for.
+ Sets the keyboard \a modifiers mask that this key event transition will
+ check for.
*/
-void QKeyEventTransition::setModifiers(Qt::KeyboardModifiers modifiers)
+void QKeyEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
{
Q_D(QKeyEventTransition);
- d->transition->setModifiers(modifiers);
-}
-
-/*!
- \reimp
-*/
-bool QKeyEventTransition::testEventCondition(QEvent *event) const
-{
- Q_D(const QKeyEventTransition);
- d->transition->setEventType(event->type());
- return QAbstractTransitionPrivate::get(d->transition)->callEventTest(event);
+ d->transition->setModifiersMask(modifiersMask);
}
/*!
@@ -143,15 +142,20 @@ bool QKeyEventTransition::testEventCondition(QEvent *event) const
*/
bool QKeyEventTransition::eventTest(QEvent *event) const
{
- return QEventTransition::eventTest(event);
+ Q_D(const QKeyEventTransition);
+ if (!QEventTransition::eventTest(event))
+ return false;
+ QWrappedEvent *we = static_cast<QWrappedEvent*>(event);
+ d->transition->setEventType(we->event()->type());
+ return QAbstractTransitionPrivate::get(d->transition)->callEventTest(we->event());
}
/*!
\reimp
*/
-void QKeyEventTransition::onTransition()
+void QKeyEventTransition::onTransition(QEvent *event)
{
- QEventTransition::onTransition();
+ QEventTransition::onTransition(event);
}
QT_END_NAMESPACE
diff --git a/src/gui/statemachine/qkeyeventtransition.h b/src/gui/statemachine/qkeyeventtransition.h
index 5bae8d7..3f797f1 100644
--- a/src/gui/statemachine/qkeyeventtransition.h
+++ b/src/gui/statemachine/qkeyeventtransition.h
@@ -28,6 +28,7 @@ class Q_GUI_EXPORT QKeyEventTransition : public QEventTransition
{
Q_OBJECT
Q_PROPERTY(int key READ key WRITE setKey)
+ Q_PROPERTY(Qt::KeyboardModifiers modifiersMask READ modifiersMask WRITE setModifiersMask)
public:
QKeyEventTransition(QState *sourceState = 0);
QKeyEventTransition(QObject *object, QEvent::Type type, int key,
@@ -40,13 +41,12 @@ public:
int key() const;
void setKey(int key);
- Qt::KeyboardModifiers modifiers() const;
- void setModifiers(Qt::KeyboardModifiers modifiers);
+ Qt::KeyboardModifiers modifiersMask() const;
+ void setModifiersMask(Qt::KeyboardModifiers modifiers);
protected:
- void onTransition();
+ void onTransition(QEvent *event);
bool eventTest(QEvent *event) const;
- bool testEventCondition(QEvent *event) const;
private:
Q_DISABLE_COPY(QKeyEventTransition)
diff --git a/src/gui/statemachine/qmouseeventtransition.cpp b/src/gui/statemachine/qmouseeventtransition.cpp
index 1621c78..3191a2f 100644
--- a/src/gui/statemachine/qmouseeventtransition.cpp
+++ b/src/gui/statemachine/qmouseeventtransition.cpp
@@ -11,6 +11,7 @@
#include "qmouseeventtransition.h"
#include "qbasicmouseeventtransition_p.h"
+#include <QtCore/qwrappedevent.h>
#include <QtGui/qpainterpath.h>
#if defined(QT_EXPERIMENTAL_SOLUTION)
@@ -26,6 +27,7 @@ QT_BEGIN_NAMESPACE
\brief The QMouseEventTransition class provides a transition for mouse events.
+ \since 4.6
\ingroup statemachine
QMouseEventTransition is part of \l{The State Machine Framework}.
@@ -33,6 +35,18 @@ QT_BEGIN_NAMESPACE
\sa QState::addTransition()
*/
+/*!
+ \property QMouseEventTransition::button
+
+ \brief the button that this mouse event transition is associated with
+*/
+
+/*!
+ \property QMouseEventTransition::modifiersMask
+
+ \brief the keyboard modifiers mask that this mouse event transition checks for
+*/
+
class QMouseEventTransitionPrivate : public QEventTransitionPrivate
{
Q_DECLARE_PUBLIC(QMouseEventTransition)
@@ -103,7 +117,7 @@ Qt::MouseButton QMouseEventTransition::button() const
}
/*!
- Sets the button that this mouse event transition will check for.
+ Sets the \a button that this mouse event transition will check for.
*/
void QMouseEventTransition::setButton(Qt::MouseButton button)
{
@@ -112,6 +126,26 @@ void QMouseEventTransition::setButton(Qt::MouseButton button)
}
/*!
+ Returns the keyboard modifiers mask that this mouse event transition checks
+ for.
+*/
+Qt::KeyboardModifiers QMouseEventTransition::modifiersMask() const
+{
+ Q_D(const QMouseEventTransition);
+ return d->transition->modifiersMask();
+}
+
+/*!
+ Sets the keyboard \a modifiers mask that this mouse event transition will
+ check for.
+*/
+void QMouseEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
+{
+ Q_D(QMouseEventTransition);
+ d->transition->setModifiersMask(modifiersMask);
+}
+
+/*!
Returns the path for this mouse event transition.
*/
QPainterPath QMouseEventTransition::path() const
@@ -136,27 +170,22 @@ void QMouseEventTransition::setPath(const QPainterPath &path)
/*!
\reimp
*/
-bool QMouseEventTransition::testEventCondition(QEvent *event) const
-{
- Q_D(const QMouseEventTransition);
- d->transition->setEventType(event->type());
- return QAbstractTransitionPrivate::get(d->transition)->callEventTest(event);
-}
-
-/*!
- \reimp
-*/
bool QMouseEventTransition::eventTest(QEvent *event) const
{
- return QEventTransition::eventTest(event);
+ Q_D(const QMouseEventTransition);
+ if (!QEventTransition::eventTest(event))
+ return false;
+ QWrappedEvent *we = static_cast<QWrappedEvent*>(event);
+ d->transition->setEventType(we->event()->type());
+ return QAbstractTransitionPrivate::get(d->transition)->callEventTest(we->event());
}
/*!
\reimp
*/
-void QMouseEventTransition::onTransition()
+void QMouseEventTransition::onTransition(QEvent *event)
{
- QEventTransition::onTransition();
+ QEventTransition::onTransition(event);
}
QT_END_NAMESPACE
diff --git a/src/gui/statemachine/qmouseeventtransition.h b/src/gui/statemachine/qmouseeventtransition.h
index 162b1b5..eee971e 100644
--- a/src/gui/statemachine/qmouseeventtransition.h
+++ b/src/gui/statemachine/qmouseeventtransition.h
@@ -29,6 +29,8 @@ class QPainterPath;
class Q_GUI_EXPORT QMouseEventTransition : public QEventTransition
{
Q_OBJECT
+ Q_PROPERTY(Qt::MouseButton button READ button WRITE setButton)
+ Q_PROPERTY(Qt::KeyboardModifiers modifiersMask READ modifiersMask WRITE setModifiersMask)
public:
QMouseEventTransition(QState *sourceState = 0);
QMouseEventTransition(QObject *object, QEvent::Type type,
@@ -42,13 +44,15 @@ public:
Qt::MouseButton button() const;
void setButton(Qt::MouseButton button);
+ Qt::KeyboardModifiers modifiersMask() const;
+ void setModifiersMask(Qt::KeyboardModifiers modifiers);
+
QPainterPath path() const;
void setPath(const QPainterPath &path);
protected:
- void onTransition();
+ void onTransition(QEvent *event);
bool eventTest(QEvent *event) const;
- bool testEventCondition(QEvent *event) const;
private:
Q_DISABLE_COPY(QMouseEventTransition)
diff --git a/src/gui/statemachine/statemachine.pri b/src/gui/statemachine/statemachine.pri
index 24de458..2eb1e05 100644
--- a/src/gui/statemachine/statemachine.pri
+++ b/src/gui/statemachine/statemachine.pri
@@ -1,6 +1,3 @@
-INCLUDEPATH += $$PWD
-DEPENDPATH += $$PWD
-
SOURCES += $$PWD/qguistatemachine.cpp
!contains(DEFINES, QT_NO_STATEMACHINE_EVENTFILTER) {
HEADERS += \