source: trunk/src/gui/statemachine/qkeyeventtransition.cpp@ 605

Last change on this file since 605 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

  • Property svn:eol-style set to native
File size: 5.1 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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
50QT_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::modifierMask
73
74 \brief the keyboard modifier mask that this key event transition checks for
75*/
76
77class QKeyEventTransitionPrivate : public QEventTransitionPrivate
78{
79 Q_DECLARE_PUBLIC(QKeyEventTransition)
80public:
81 QKeyEventTransitionPrivate() {}
82
83 QBasicKeyEventTransition *transition;
84};
85
86/*!
87 Constructs a new key event transition with the given \a sourceState.
88*/
89QKeyEventTransition::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*/
100QKeyEventTransition::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*/
111QKeyEventTransition::~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*/
120int 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*/
129void QKeyEventTransition::setKey(int key)
130{
131 Q_D(QKeyEventTransition);
132 d->transition->setKey(key);
133}
134
135/*!
136 Returns the keyboard modifier mask that this key event transition checks
137 for.
138*/
139Qt::KeyboardModifiers QKeyEventTransition::modifierMask() const
140{
141 Q_D(const QKeyEventTransition);
142 return d->transition->modifierMask();
143}
144
145/*!
146 Sets the keyboard modifier mask that this key event transition will
147 check for to \a modifierMask.
148*/
149void QKeyEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
150{
151 Q_D(QKeyEventTransition);
152 d->transition->setModifierMask(modifierMask);
153}
154
155/*!
156 \reimp
157*/
158bool 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*/
171void QKeyEventTransition::onTransition(QEvent *event)
172{
173 QEventTransition::onTransition(event);
174}
175
176QT_END_NAMESPACE
177
178#endif //QT_NO_STATEMACHINE
Note: See TracBrowser for help on using the repository browser.