0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtGui module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
#include "qkeyeventtransition.h"
|
|
43 |
|
|
44 |
#ifndef QT_NO_STATEMACHINE
|
|
45 |
|
|
46 |
#include "qbasickeyeventtransition_p.h"
|
|
47 |
#include <QtCore/qstatemachine.h>
|
|
48 |
#include <private/qeventtransition_p.h>
|
|
49 |
|
|
50 |
QT_BEGIN_NAMESPACE
|
|
51 |
|
|
52 |
/*!
|
|
53 |
\class QKeyEventTransition
|
|
54 |
|
|
55 |
\brief The QKeyEventTransition class provides a transition for key events.
|
|
56 |
|
|
57 |
\since 4.6
|
|
58 |
\ingroup statemachine
|
|
59 |
|
|
60 |
QKeyEventTransition is part of \l{The State Machine Framework}.
|
|
61 |
|
|
62 |
\sa QState::addTransition()
|
|
63 |
*/
|
|
64 |
|
|
65 |
/*!
|
|
66 |
\property QKeyEventTransition::key
|
|
67 |
|
|
68 |
\brief the key that this key event transition is associated with
|
|
69 |
*/
|
|
70 |
|
|
71 |
/*!
|
|
72 |
\property QKeyEventTransition::modifiersMask
|
|
73 |
|
|
74 |
\brief the keyboard modifiers mask that this key event transition checks for
|
|
75 |
*/
|
|
76 |
|
|
77 |
class QKeyEventTransitionPrivate : public QEventTransitionPrivate
|
|
78 |
{
|
|
79 |
Q_DECLARE_PUBLIC(QKeyEventTransition)
|
|
80 |
public:
|
|
81 |
QKeyEventTransitionPrivate() {}
|
|
82 |
|
|
83 |
QBasicKeyEventTransition *transition;
|
|
84 |
};
|
|
85 |
|
|
86 |
/*!
|
|
87 |
Constructs a new key event transition with the given \a sourceState.
|
|
88 |
*/
|
|
89 |
QKeyEventTransition::QKeyEventTransition(QState *sourceState)
|
|
90 |
: QEventTransition(*new QKeyEventTransitionPrivate, sourceState)
|
|
91 |
{
|
|
92 |
Q_D(QKeyEventTransition);
|
|
93 |
d->transition = new QBasicKeyEventTransition();
|
|
94 |
}
|
|
95 |
|
|
96 |
/*!
|
|
97 |
Constructs a new key event transition for events of the given \a type for
|
|
98 |
the given \a object, with the given \a key and \a sourceState.
|
|
99 |
*/
|
|
100 |
QKeyEventTransition::QKeyEventTransition(QObject *object, QEvent::Type type,
|
|
101 |
int key, QState *sourceState)
|
|
102 |
: QEventTransition(*new QKeyEventTransitionPrivate, object, type, sourceState)
|
|
103 |
{
|
|
104 |
Q_D(QKeyEventTransition);
|
|
105 |
d->transition = new QBasicKeyEventTransition(type, key);
|
|
106 |
}
|
|
107 |
|
|
108 |
/*!
|
|
109 |
Destroys this key event transition.
|
|
110 |
*/
|
|
111 |
QKeyEventTransition::~QKeyEventTransition()
|
|
112 |
{
|
|
113 |
Q_D(QKeyEventTransition);
|
|
114 |
delete d->transition;
|
|
115 |
}
|
|
116 |
|
|
117 |
/*!
|
|
118 |
Returns the key that this key event transition checks for.
|
|
119 |
*/
|
|
120 |
int QKeyEventTransition::key() const
|
|
121 |
{
|
|
122 |
Q_D(const QKeyEventTransition);
|
|
123 |
return d->transition->key();
|
|
124 |
}
|
|
125 |
|
|
126 |
/*!
|
|
127 |
Sets the key that this key event transition will check for.
|
|
128 |
*/
|
|
129 |
void QKeyEventTransition::setKey(int key)
|
|
130 |
{
|
|
131 |
Q_D(QKeyEventTransition);
|
|
132 |
d->transition->setKey(key);
|
|
133 |
}
|
|
134 |
|
|
135 |
/*!
|
|
136 |
Returns the keyboard modifiers mask that this key event transition checks
|
|
137 |
for.
|
|
138 |
*/
|
|
139 |
Qt::KeyboardModifiers QKeyEventTransition::modifiersMask() const
|
|
140 |
{
|
|
141 |
Q_D(const QKeyEventTransition);
|
|
142 |
return d->transition->modifiersMask();
|
|
143 |
}
|
|
144 |
|
|
145 |
/*!
|
|
146 |
Sets the keyboard \a modifiers mask that this key event transition will
|
|
147 |
check for.
|
|
148 |
*/
|
|
149 |
void QKeyEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
|
|
150 |
{
|
|
151 |
Q_D(QKeyEventTransition);
|
|
152 |
d->transition->setModifiersMask(modifiersMask);
|
|
153 |
}
|
|
154 |
|
|
155 |
/*!
|
|
156 |
\reimp
|
|
157 |
*/
|
|
158 |
bool QKeyEventTransition::eventTest(QEvent *event)
|
|
159 |
{
|
|
160 |
Q_D(const QKeyEventTransition);
|
|
161 |
if (!QEventTransition::eventTest(event))
|
|
162 |
return false;
|
|
163 |
QStateMachine::WrappedEvent *we = static_cast<QStateMachine::WrappedEvent*>(event);
|
|
164 |
d->transition->setEventType(we->event()->type());
|
|
165 |
return QAbstractTransitionPrivate::get(d->transition)->callEventTest(we->event());
|
|
166 |
}
|
|
167 |
|
|
168 |
/*!
|
|
169 |
\reimp
|
|
170 |
*/
|
|
171 |
void QKeyEventTransition::onTransition(QEvent *event)
|
|
172 |
{
|
|
173 |
QEventTransition::onTransition(event);
|
|
174 |
}
|
|
175 |
|
|
176 |
QT_END_NAMESPACE
|
|
177 |
|
|
178 |
#endif //QT_NO_STATEMACHINE
|