summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-04-29 08:54:10 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-04-29 08:54:10 (GMT)
commit58b74319a639cb471cdec92c0e8a054fc6d4d5f5 (patch)
tree6d6bd21ff8c53636cc51eb8a1d17eb2fd00ebed9 /src
parentf39a905bc75e7ce95294f3584ea8a400ab383861 (diff)
downloadQt-58b74319a639cb471cdec92c0e8a054fc6d4d5f5.zip
Qt-58b74319a639cb471cdec92c0e8a054fc6d4d5f5.tar.gz
Qt-58b74319a639cb471cdec92c0e8a054fc6d4d5f5.tar.bz2
modifiers --> modifiersMask
Result of API review. A == comparison of the modifiers is not useful. The common case is you want to test if one or more modifiers are set, i.e. a mask check.
Diffstat (limited to 'src')
-rw-r--r--src/gui/statemachine/qbasickeyeventtransition.cpp27
-rw-r--r--src/gui/statemachine/qbasickeyeventtransition_p.h7
-rw-r--r--src/gui/statemachine/qbasicmouseeventtransition.cpp22
-rw-r--r--src/gui/statemachine/qbasicmouseeventtransition_p.h3
-rw-r--r--src/gui/statemachine/qkeyeventtransition.cpp21
-rw-r--r--src/gui/statemachine/qkeyeventtransition.h5
-rw-r--r--src/gui/statemachine/qmouseeventtransition.cpp32
-rw-r--r--src/gui/statemachine/qmouseeventtransition.h5
8 files changed, 98 insertions, 24 deletions
diff --git a/src/gui/statemachine/qbasickeyeventtransition.cpp b/src/gui/statemachine/qbasickeyeventtransition.cpp
index 2ce428c..4e3fa11 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;
}
diff --git a/src/gui/statemachine/qbasickeyeventtransition_p.h b/src/gui/statemachine/qbasickeyeventtransition_p.h
index ff52f4d..de49eac 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,8 +51,8 @@ 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;
diff --git a/src/gui/statemachine/qbasicmouseeventtransition.cpp b/src/gui/statemachine/qbasicmouseeventtransition.cpp
index b7583f8..83254dc 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;
diff --git a/src/gui/statemachine/qbasicmouseeventtransition_p.h b/src/gui/statemachine/qbasicmouseeventtransition_p.h
index ee04fc7..77fbd58 100644
--- a/src/gui/statemachine/qbasicmouseeventtransition_p.h
+++ b/src/gui/statemachine/qbasicmouseeventtransition_p.h
@@ -51,6 +51,9 @@ 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);
diff --git a/src/gui/statemachine/qkeyeventtransition.cpp b/src/gui/statemachine/qkeyeventtransition.cpp
index 88e4add..7c1ae8a 100644
--- a/src/gui/statemachine/qkeyeventtransition.cpp
+++ b/src/gui/statemachine/qkeyeventtransition.cpp
@@ -39,6 +39,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)
@@ -111,22 +117,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);
+ d->transition->setModifiersMask(modifiersMask);
}
/*!
diff --git a/src/gui/statemachine/qkeyeventtransition.h b/src/gui/statemachine/qkeyeventtransition.h
index 5bae8d7..ef814db 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,8 +41,8 @@ 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();
diff --git a/src/gui/statemachine/qmouseeventtransition.cpp b/src/gui/statemachine/qmouseeventtransition.cpp
index f5df904..d6d9b62 100644
--- a/src/gui/statemachine/qmouseeventtransition.cpp
+++ b/src/gui/statemachine/qmouseeventtransition.cpp
@@ -34,6 +34,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)
@@ -113,6 +125,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
diff --git a/src/gui/statemachine/qmouseeventtransition.h b/src/gui/statemachine/qmouseeventtransition.h
index 162b1b5..dbd615f 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,6 +44,9 @@ 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);