Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/statemachine/qmouseeventtransition.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||
5 | ** | - | ||||||
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||
9 | ** Commercial License Usage | - | ||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||
16 | ** | - | ||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||
25 | ** | - | ||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||
29 | ** | - | ||||||
30 | ** $QT_END_LICENSE$ | - | ||||||
31 | ** | - | ||||||
32 | ****************************************************************************/ | - | ||||||
33 | - | |||||||
34 | #include "qmouseeventtransition.h" | - | ||||||
35 | - | |||||||
36 | #ifndef QT_NO_STATEMACHINE | - | ||||||
37 | - | |||||||
38 | #include "qbasicmouseeventtransition_p.h" | - | ||||||
39 | #include <QtCore/qstatemachine.h> | - | ||||||
40 | #include <QtGui/qpainterpath.h> | - | ||||||
41 | #include <private/qeventtransition_p.h> | - | ||||||
42 | - | |||||||
43 | QT_BEGIN_NAMESPACE | - | ||||||
44 | - | |||||||
45 | /*! | - | ||||||
46 | \class QMouseEventTransition | - | ||||||
47 | - | |||||||
48 | \brief The QMouseEventTransition class provides a transition for mouse events. | - | ||||||
49 | - | |||||||
50 | \since 4.6 | - | ||||||
51 | \ingroup statemachine | - | ||||||
52 | \inmodule QtWidgets | - | ||||||
53 | - | |||||||
54 | QMouseEventTransition is part of \l{The State Machine Framework}. | - | ||||||
55 | - | |||||||
56 | \sa QState::addTransition() | - | ||||||
57 | */ | - | ||||||
58 | - | |||||||
59 | /*! | - | ||||||
60 | \property QMouseEventTransition::button | - | ||||||
61 | - | |||||||
62 | \brief the button that this mouse event transition is associated with | - | ||||||
63 | */ | - | ||||||
64 | - | |||||||
65 | /*! | - | ||||||
66 | \property QMouseEventTransition::modifierMask | - | ||||||
67 | - | |||||||
68 | \brief the keyboard modifier mask that this mouse event transition checks for | - | ||||||
69 | */ | - | ||||||
70 | - | |||||||
71 | class QMouseEventTransitionPrivate : public QEventTransitionPrivate | - | ||||||
72 | { | - | ||||||
73 | Q_DECLARE_PUBLIC(QMouseEventTransition) | - | ||||||
74 | public: | - | ||||||
75 | QMouseEventTransitionPrivate(); | - | ||||||
76 | - | |||||||
77 | QBasicMouseEventTransition *transition; | - | ||||||
78 | }; | - | ||||||
79 | - | |||||||
80 | QMouseEventTransitionPrivate::QMouseEventTransitionPrivate() | - | ||||||
81 | { | - | ||||||
82 | } | - | ||||||
83 | - | |||||||
84 | /*! | - | ||||||
85 | Constructs a new mouse event transition with the given \a sourceState. | - | ||||||
86 | */ | - | ||||||
87 | QMouseEventTransition::QMouseEventTransition(QState *sourceState) | - | ||||||
88 | : QEventTransition(*new QMouseEventTransitionPrivate, sourceState) | - | ||||||
89 | { | - | ||||||
90 | Q_D(QMouseEventTransition); | - | ||||||
91 | d->transition = new QBasicMouseEventTransition(); | - | ||||||
92 | } never executed: end of block | 0 | ||||||
93 | - | |||||||
94 | /*! | - | ||||||
95 | Constructs a new mouse event transition for events of the given \a type for | - | ||||||
96 | the given \a object, with the given \a button and \a sourceState. | - | ||||||
97 | */ | - | ||||||
98 | QMouseEventTransition::QMouseEventTransition(QObject *object, QEvent::Type type, | - | ||||||
99 | Qt::MouseButton button, | - | ||||||
100 | QState *sourceState) | - | ||||||
101 | : QEventTransition(*new QMouseEventTransitionPrivate, object, type, sourceState) | - | ||||||
102 | { | - | ||||||
103 | Q_D(QMouseEventTransition); | - | ||||||
104 | d->transition = new QBasicMouseEventTransition(type, button); | - | ||||||
105 | } never executed: end of block | 0 | ||||||
106 | - | |||||||
107 | /*! | - | ||||||
108 | Destroys this mouse event transition. | - | ||||||
109 | */ | - | ||||||
110 | QMouseEventTransition::~QMouseEventTransition() | - | ||||||
111 | { | - | ||||||
112 | Q_D(QMouseEventTransition); | - | ||||||
113 | delete d->transition; | - | ||||||
114 | } never executed: end of block | 0 | ||||||
115 | - | |||||||
116 | /*! | - | ||||||
117 | Returns the button that this mouse event transition checks for. | - | ||||||
118 | */ | - | ||||||
119 | Qt::MouseButton QMouseEventTransition::button() const | - | ||||||
120 | { | - | ||||||
121 | Q_D(const QMouseEventTransition); | - | ||||||
122 | return d->transition->button(); never executed: return d->transition->button(); | 0 | ||||||
123 | } | - | ||||||
124 | - | |||||||
125 | /*! | - | ||||||
126 | Sets the \a button that this mouse event transition will check for. | - | ||||||
127 | */ | - | ||||||
128 | void QMouseEventTransition::setButton(Qt::MouseButton button) | - | ||||||
129 | { | - | ||||||
130 | Q_D(QMouseEventTransition); | - | ||||||
131 | d->transition->setButton(button); | - | ||||||
132 | } never executed: end of block | 0 | ||||||
133 | - | |||||||
134 | /*! | - | ||||||
135 | Returns the keyboard modifier mask that this mouse event transition checks | - | ||||||
136 | for. | - | ||||||
137 | */ | - | ||||||
138 | Qt::KeyboardModifiers QMouseEventTransition::modifierMask() const | - | ||||||
139 | { | - | ||||||
140 | Q_D(const QMouseEventTransition); | - | ||||||
141 | return d->transition->modifierMask(); never executed: return d->transition->modifierMask(); | 0 | ||||||
142 | } | - | ||||||
143 | - | |||||||
144 | /*! | - | ||||||
145 | Sets the keyboard modifier mask that this mouse event transition will | - | ||||||
146 | check for to \a modifierMask. | - | ||||||
147 | */ | - | ||||||
148 | void QMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask) | - | ||||||
149 | { | - | ||||||
150 | Q_D(QMouseEventTransition); | - | ||||||
151 | d->transition->setModifierMask(modifierMask); | - | ||||||
152 | } never executed: end of block | 0 | ||||||
153 | - | |||||||
154 | /*! | - | ||||||
155 | Returns the hit test path for this mouse event transition. | - | ||||||
156 | */ | - | ||||||
157 | QPainterPath QMouseEventTransition::hitTestPath() const | - | ||||||
158 | { | - | ||||||
159 | Q_D(const QMouseEventTransition); | - | ||||||
160 | return d->transition->hitTestPath(); never executed: return d->transition->hitTestPath(); | 0 | ||||||
161 | } | - | ||||||
162 | - | |||||||
163 | /*! | - | ||||||
164 | Sets the hit test path for this mouse event transition to \a path. | - | ||||||
165 | If a valid path has been set, the transition will only trigger if the mouse | - | ||||||
166 | event position (QMouseEvent::pos()) is inside the path. | - | ||||||
167 | - | |||||||
168 | \sa QPainterPath::contains() | - | ||||||
169 | */ | - | ||||||
170 | void QMouseEventTransition::setHitTestPath(const QPainterPath &path) | - | ||||||
171 | { | - | ||||||
172 | Q_D(QMouseEventTransition); | - | ||||||
173 | d->transition->setHitTestPath(path); | - | ||||||
174 | } never executed: end of block | 0 | ||||||
175 | - | |||||||
176 | /*! | - | ||||||
177 | \reimp | - | ||||||
178 | */ | - | ||||||
179 | bool QMouseEventTransition::eventTest(QEvent *event) | - | ||||||
180 | { | - | ||||||
181 | Q_D(const QMouseEventTransition); | - | ||||||
182 | if (!QEventTransition::eventTest(event))
| 0 | ||||||
183 | return false; never executed: return false; | 0 | ||||||
184 | QStateMachine::WrappedEvent *we = static_cast<QStateMachine::WrappedEvent*>(event); | - | ||||||
185 | d->transition->setEventType(we->event()->type()); | - | ||||||
186 | return QAbstractTransitionPrivate::get(d->transition)->callEventTest(we->event()); never executed: return QAbstractTransitionPrivate::get(d->transition)->callEventTest(we->event()); | 0 | ||||||
187 | } | - | ||||||
188 | - | |||||||
189 | /*! | - | ||||||
190 | \reimp | - | ||||||
191 | */ | - | ||||||
192 | void QMouseEventTransition::onTransition(QEvent *event) | - | ||||||
193 | { | - | ||||||
194 | QEventTransition::onTransition(event); | - | ||||||
195 | } never executed: end of block | 0 | ||||||
196 | - | |||||||
197 | QT_END_NAMESPACE | - | ||||||
198 | - | |||||||
199 | #include "moc_qmouseeventtransition.cpp" | - | ||||||
200 | - | |||||||
201 | #endif //QT_NO_STATEMACHINE | - | ||||||
Source code | Switch to Preprocessed file |