Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickevents_p_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2017 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
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 https://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at https://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 3 as published by the Free Software | - | ||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
24 | ** | - | ||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
35 | ** | - | ||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||
37 | ** | - | ||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||
39 | - | |||||||||||||
40 | #ifndef QQUICKEVENTS_P_P_H | - | ||||||||||||
41 | #define QQUICKEVENTS_P_P_H | - | ||||||||||||
42 | - | |||||||||||||
43 | // | - | ||||||||||||
44 | // W A R N I N G | - | ||||||||||||
45 | // ------------- | - | ||||||||||||
46 | // | - | ||||||||||||
47 | // This file is not part of the Qt API. It exists purely as an | - | ||||||||||||
48 | // implementation detail. This header file may change from version to | - | ||||||||||||
49 | // version without notice, or even be removed. | - | ||||||||||||
50 | // | - | ||||||||||||
51 | // We mean it. | - | ||||||||||||
52 | // | - | ||||||||||||
53 | - | |||||||||||||
54 | #include <private/qtquickglobal_p.h> | - | ||||||||||||
55 | #include <qqml.h> | - | ||||||||||||
56 | - | |||||||||||||
57 | #include <QtCore/qobject.h> | - | ||||||||||||
58 | #include <QtCore/qpointer.h> | - | ||||||||||||
59 | #include <QtGui/qvector2d.h> | - | ||||||||||||
60 | #include <QtGui/qevent.h> | - | ||||||||||||
61 | #include <QtGui/qkeysequence.h> | - | ||||||||||||
62 | #include <QtQuick/qquickitem.h> | - | ||||||||||||
63 | - | |||||||||||||
64 | QT_BEGIN_NAMESPACE | - | ||||||||||||
65 | - | |||||||||||||
66 | class QQuickPointerDevice; | - | ||||||||||||
67 | class QQuickPointerEvent; | - | ||||||||||||
68 | class QQuickPointerMouseEvent; | - | ||||||||||||
69 | #if QT_CONFIG(gestures) | - | ||||||||||||
70 | class QQuickPointerNativeGestureEvent; | - | ||||||||||||
71 | #endif | - | ||||||||||||
72 | class QQuickPointerScrollEvent; | - | ||||||||||||
73 | class QQuickPointerTabletEvent; | - | ||||||||||||
74 | class QQuickPointerTouchEvent; | - | ||||||||||||
75 | class QQuickPointerHandler; | - | ||||||||||||
76 | - | |||||||||||||
77 | class QQuickKeyEvent : public QObject | - | ||||||||||||
78 | { | - | ||||||||||||
79 | Q_OBJECT | - | ||||||||||||
80 | Q_PROPERTY(int key READ key) | - | ||||||||||||
81 | Q_PROPERTY(QString text READ text) | - | ||||||||||||
82 | Q_PROPERTY(int modifiers READ modifiers) | - | ||||||||||||
83 | Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat) | - | ||||||||||||
84 | Q_PROPERTY(int count READ count) | - | ||||||||||||
85 | Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode) | - | ||||||||||||
86 | Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) | - | ||||||||||||
87 | - | |||||||||||||
88 | public: | - | ||||||||||||
89 | QQuickKeyEvent() | - | ||||||||||||
90 | : event(QEvent::None, 0, nullptr) | - | ||||||||||||
91 | {} executed 320 times by 8 tests: end of block Executed by:
| 320 | ||||||||||||
92 | - | |||||||||||||
93 | void reset(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, | - | ||||||||||||
94 | const QString &text = QString(), bool autorep = false, ushort count = 1) | - | ||||||||||||
95 | { | - | ||||||||||||
96 | event = QKeyEvent(type, key, modifiers, text, autorep, count); | - | ||||||||||||
97 | event.setAccepted(false); | - | ||||||||||||
98 | } never executed: end of block | 0 | ||||||||||||
99 | - | |||||||||||||
100 | void reset(const QKeyEvent &ke) | - | ||||||||||||
101 | { | - | ||||||||||||
102 | event = ke; | - | ||||||||||||
103 | event.setAccepted(false); | - | ||||||||||||
104 | } executed 156 times by 3 tests: end of block Executed by:
| 156 | ||||||||||||
105 | - | |||||||||||||
106 | int key() const { return event.key(); } executed 88 times by 2 tests: return event.key(); Executed by:
| 88 | ||||||||||||
107 | QString text() const { return event.text(); } executed 18 times by 1 test: return event.text(); Executed by:
| 18 | ||||||||||||
108 | int modifiers() const { return event.modifiers(); } executed 24 times by 1 test: return event.modifiers(); Executed by:
| 24 | ||||||||||||
109 | bool isAutoRepeat() const { return event.isAutoRepeat(); } never executed: return event.isAutoRepeat(); | 0 | ||||||||||||
110 | int count() const { return event.count(); } never executed: return event.count(); | 0 | ||||||||||||
111 | quint32 nativeScanCode() const { return event.nativeScanCode(); } executed 2 times by 1 test: return event.nativeScanCode(); Executed by:
| 2 | ||||||||||||
112 | - | |||||||||||||
113 | bool isAccepted() { return event.isAccepted(); } executed 244 times by 3 tests: return event.isAccepted(); Executed by:
| 244 | ||||||||||||
114 | void setAccepted(bool accepted) { event.setAccepted(accepted); } executed 48 times by 3 tests: end of block Executed by:
| 48 | ||||||||||||
115 | - | |||||||||||||
116 | #if QT_CONFIG(shortcut) | - | ||||||||||||
117 | Q_REVISION(2) Q_INVOKABLE bool matches(QKeySequence::StandardKey key) const { return event.matches(key); } executed 24 times by 1 test: return event.matches(key); Executed by:
| 24 | ||||||||||||
118 | #endif | - | ||||||||||||
119 | - | |||||||||||||
120 | private: | - | ||||||||||||
121 | QKeyEvent event; | - | ||||||||||||
122 | }; | - | ||||||||||||
123 | - | |||||||||||||
124 | // used in Qt Location | - | ||||||||||||
125 | class Q_QUICK_PRIVATE_EXPORT QQuickMouseEvent : public QObject | - | ||||||||||||
126 | { | - | ||||||||||||
127 | Q_OBJECT | - | ||||||||||||
128 | Q_PROPERTY(qreal x READ x) | - | ||||||||||||
129 | Q_PROPERTY(qreal y READ y) | - | ||||||||||||
130 | Q_PROPERTY(int button READ button) | - | ||||||||||||
131 | Q_PROPERTY(int buttons READ buttons) | - | ||||||||||||
132 | Q_PROPERTY(int modifiers READ modifiers) | - | ||||||||||||
133 | Q_PROPERTY(int source READ source REVISION 7) | - | ||||||||||||
134 | Q_PROPERTY(bool wasHeld READ wasHeld) | - | ||||||||||||
135 | Q_PROPERTY(bool isClick READ isClick) | - | ||||||||||||
136 | Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) | - | ||||||||||||
137 | Q_REVISION(11) Q_PROPERTY(int flags READ flags) | - | ||||||||||||
138 | - | |||||||||||||
139 | public: | - | ||||||||||||
140 | QQuickMouseEvent() | - | ||||||||||||
141 | : _buttons(Qt::NoButton), _modifiers(Qt::NoModifier) | - | ||||||||||||
142 | , _wasHeld(false), _isClick(false), _accepted(false) | - | ||||||||||||
143 | , _flags(Qt::MouseEventFlags(nullptr)) | - | ||||||||||||
144 | {} executed 2016 times by 24 tests: end of block Executed by:
| 2016 | ||||||||||||
145 | - | |||||||||||||
146 | void reset(qreal x, qreal y, Qt::MouseButton button, Qt::MouseButtons buttons, | - | ||||||||||||
147 | Qt::KeyboardModifiers modifiers, bool isClick = false, bool wasHeld = false, | - | ||||||||||||
148 | Qt::MouseEventFlags flags = nullptr) | - | ||||||||||||
149 | { | - | ||||||||||||
150 | _x = x; | - | ||||||||||||
151 | _y = y; | - | ||||||||||||
152 | _button = button; | - | ||||||||||||
153 | _buttons = buttons; | - | ||||||||||||
154 | _modifiers = modifiers; | - | ||||||||||||
155 | _source = Qt::MouseEventNotSynthesized; | - | ||||||||||||
156 | _wasHeld = wasHeld; | - | ||||||||||||
157 | _isClick = isClick; | - | ||||||||||||
158 | _accepted = true; | - | ||||||||||||
159 | _flags = flags; | - | ||||||||||||
160 | } executed 1005 times by 9 tests: end of block Executed by:
| 1005 | ||||||||||||
161 | - | |||||||||||||
162 | qreal x() const { return _x; } executed 26 times by 1 test: return _x; Executed by:
| 26 | ||||||||||||
163 | qreal y() const { return _y; } executed 26 times by 1 test: return _y; Executed by:
| 26 | ||||||||||||
164 | int button() const { return _button; } executed 18 times by 1 test: return _button; Executed by:
| 18 | ||||||||||||
165 | int buttons() const { return _buttons; } never executed: return _buttons; | 0 | ||||||||||||
166 | int modifiers() const { return _modifiers; } never executed: return _modifiers; | 0 | ||||||||||||
167 | int source() const { return _source; } executed 16 times by 1 test: return _source; Executed by:
| 16 | ||||||||||||
168 | bool wasHeld() const { return _wasHeld; } never executed: return _wasHeld; | 0 | ||||||||||||
169 | bool isClick() const { return _isClick; } never executed: return _isClick; | 0 | ||||||||||||
170 | - | |||||||||||||
171 | // only for internal usage | - | ||||||||||||
172 | void setX(qreal x) { _x = x; } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||
173 | void setY(qreal y) { _y = y; } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||
174 | void setPosition(const QPointF &point) { _x = point.x(); _y = point.y(); } executed 1668 times by 9 tests: end of block Executed by:
| 1668 | ||||||||||||
175 | void setSource(Qt::MouseEventSource s) { _source = s; } executed 971 times by 7 tests: end of block Executed by:
| 971 | ||||||||||||
176 | - | |||||||||||||
177 | bool isAccepted() { return _accepted; } executed 1044 times by 7 tests: return _accepted; Executed by:
| 1044 | ||||||||||||
178 | void setAccepted(bool accepted) { _accepted = accepted; } executed 248 times by 4 tests: end of block Executed by:
| 248 | ||||||||||||
179 | int flags() const { return _flags; } never executed: return _flags; | 0 | ||||||||||||
180 | private: | - | ||||||||||||
181 | qreal _x = 0; | - | ||||||||||||
182 | qreal _y = 0; | - | ||||||||||||
183 | Qt::MouseButton _button = Qt::NoButton; | - | ||||||||||||
184 | Qt::MouseButtons _buttons; | - | ||||||||||||
185 | Qt::KeyboardModifiers _modifiers; | - | ||||||||||||
186 | Qt::MouseEventSource _source = Qt::MouseEventNotSynthesized; | - | ||||||||||||
187 | bool _wasHeld : 1; | - | ||||||||||||
188 | bool _isClick : 1; | - | ||||||||||||
189 | bool _accepted : 1; | - | ||||||||||||
190 | Qt::MouseEventFlags _flags; | - | ||||||||||||
191 | }; | - | ||||||||||||
192 | - | |||||||||||||
193 | class QQuickWheelEvent : public QObject | - | ||||||||||||
194 | { | - | ||||||||||||
195 | Q_OBJECT | - | ||||||||||||
196 | Q_PROPERTY(qreal x READ x) | - | ||||||||||||
197 | Q_PROPERTY(qreal y READ y) | - | ||||||||||||
198 | Q_PROPERTY(QPoint angleDelta READ angleDelta) | - | ||||||||||||
199 | Q_PROPERTY(QPoint pixelDelta READ pixelDelta) | - | ||||||||||||
200 | Q_PROPERTY(int buttons READ buttons) | - | ||||||||||||
201 | Q_PROPERTY(int modifiers READ modifiers) | - | ||||||||||||
202 | Q_PROPERTY(bool inverted READ inverted) | - | ||||||||||||
203 | Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) | - | ||||||||||||
204 | - | |||||||||||||
205 | public: | - | ||||||||||||
206 | QQuickWheelEvent() | - | ||||||||||||
207 | : _buttons(Qt::NoButton), _modifiers(Qt::NoModifier) | - | ||||||||||||
208 | {} executed 2016 times by 24 tests: end of block Executed by:
| 2016 | ||||||||||||
209 | - | |||||||||||||
210 | void reset(qreal x, qreal y, const QPoint &angleDelta, const QPoint &pixelDelta, | - | ||||||||||||
211 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, bool inverted) | - | ||||||||||||
212 | { | - | ||||||||||||
213 | _x = x; | - | ||||||||||||
214 | _y = y; | - | ||||||||||||
215 | _angleDelta = angleDelta; | - | ||||||||||||
216 | _pixelDelta = pixelDelta; | - | ||||||||||||
217 | _buttons = buttons; | - | ||||||||||||
218 | _modifiers = modifiers; | - | ||||||||||||
219 | _accepted = true; | - | ||||||||||||
220 | _inverted = inverted; | - | ||||||||||||
221 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
222 | - | |||||||||||||
223 | qreal x() const { return _x; } executed 2 times by 1 test: return _x; Executed by:
| 2 | ||||||||||||
224 | qreal y() const { return _y; } executed 2 times by 1 test: return _y; Executed by:
| 2 | ||||||||||||
225 | QPoint angleDelta() const { return _angleDelta; } executed 2 times by 1 test: return _angleDelta; Executed by:
| 2 | ||||||||||||
226 | QPoint pixelDelta() const { return _pixelDelta; } never executed: return _pixelDelta; | 0 | ||||||||||||
227 | int buttons() const { return _buttons; } never executed: return _buttons; | 0 | ||||||||||||
228 | int modifiers() const { return _modifiers; } executed 2 times by 1 test: return _modifiers; Executed by:
| 2 | ||||||||||||
229 | bool inverted() const { return _inverted; } never executed: return _inverted; | 0 | ||||||||||||
230 | bool isAccepted() { return _accepted; } executed 2 times by 1 test: return _accepted; Executed by:
| 2 | ||||||||||||
231 | void setAccepted(bool accepted) { _accepted = accepted; } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
232 | - | |||||||||||||
233 | private: | - | ||||||||||||
234 | qreal _x = 0; | - | ||||||||||||
235 | qreal _y = 0; | - | ||||||||||||
236 | QPoint _angleDelta; | - | ||||||||||||
237 | QPoint _pixelDelta; | - | ||||||||||||
238 | Qt::MouseButtons _buttons; | - | ||||||||||||
239 | Qt::KeyboardModifiers _modifiers; | - | ||||||||||||
240 | bool _inverted = false; | - | ||||||||||||
241 | bool _accepted = false; | - | ||||||||||||
242 | }; | - | ||||||||||||
243 | - | |||||||||||||
244 | class Q_QUICK_PRIVATE_EXPORT QQuickCloseEvent : public QObject | - | ||||||||||||
245 | { | - | ||||||||||||
246 | Q_OBJECT | - | ||||||||||||
247 | Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) | - | ||||||||||||
248 | - | |||||||||||||
249 | public: | - | ||||||||||||
250 | QQuickCloseEvent() {} | - | ||||||||||||
251 | - | |||||||||||||
252 | bool isAccepted() { return _accepted; } executed 12 times by 1 test: return _accepted; Executed by:
| 12 | ||||||||||||
253 | void setAccepted(bool accepted) { _accepted = accepted; } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||
254 | - | |||||||||||||
255 | private: | - | ||||||||||||
256 | bool _accepted = true; | - | ||||||||||||
257 | }; | - | ||||||||||||
258 | - | |||||||||||||
259 | class Q_QUICK_PRIVATE_EXPORT QQuickEventPoint : public QObject | - | ||||||||||||
260 | { | - | ||||||||||||
261 | Q_OBJECT | - | ||||||||||||
262 | Q_PROPERTY(QQuickPointerEvent *event READ pointerEvent) | - | ||||||||||||
263 | Q_PROPERTY(QPointF position READ position) | - | ||||||||||||
264 | Q_PROPERTY(QPointF scenePosition READ scenePosition) | - | ||||||||||||
265 | Q_PROPERTY(QPointF scenePressPosition READ scenePressPosition) | - | ||||||||||||
266 | Q_PROPERTY(QPointF sceneGrabPosition READ sceneGrabPosition) | - | ||||||||||||
267 | Q_PROPERTY(State state READ state) | - | ||||||||||||
268 | Q_PROPERTY(int pointId READ pointId) | - | ||||||||||||
269 | Q_PROPERTY(qreal timeHeld READ timeHeld) | - | ||||||||||||
270 | Q_PROPERTY(QVector2D velocity READ velocity) | - | ||||||||||||
271 | Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) | - | ||||||||||||
272 | Q_PROPERTY(QObject *exclusiveGrabber READ exclusiveGrabber WRITE setExclusiveGrabber) | - | ||||||||||||
273 | - | |||||||||||||
274 | public: | - | ||||||||||||
275 | enum State { | - | ||||||||||||
276 | Pressed = Qt::TouchPointPressed, | - | ||||||||||||
277 | Updated = Qt::TouchPointMoved, | - | ||||||||||||
278 | Stationary = Qt::TouchPointStationary, | - | ||||||||||||
279 | Released = Qt::TouchPointReleased | - | ||||||||||||
280 | }; | - | ||||||||||||
281 | Q_DECLARE_FLAGS(States, State) | - | ||||||||||||
282 | Q_FLAG(States) | - | ||||||||||||
283 | - | |||||||||||||
284 | enum GrabState { | - | ||||||||||||
285 | GrabPassive = 0x01, | - | ||||||||||||
286 | UngrabPassive = 0x02, | - | ||||||||||||
287 | CancelGrabPassive = 0x03, | - | ||||||||||||
288 | OverrideGrabPassive = 0x04, | - | ||||||||||||
289 | GrabExclusive = 0x10, | - | ||||||||||||
290 | UngrabExclusive = 0x20, | - | ||||||||||||
291 | CancelGrabExclusive = 0x30, | - | ||||||||||||
292 | }; | - | ||||||||||||
293 | Q_ENUM(GrabState) | - | ||||||||||||
294 | - | |||||||||||||
295 | QQuickEventPoint(QQuickPointerEvent *parent); | - | ||||||||||||
296 | - | |||||||||||||
297 | void reset(Qt::TouchPointState state, const QPointF &scenePosition, int pointId, ulong timestamp, const QVector2D &velocity = QVector2D()); | - | ||||||||||||
298 | void localizePosition(QQuickItem *target); | - | ||||||||||||
299 | - | |||||||||||||
300 | QQuickPointerEvent *pointerEvent() const; | - | ||||||||||||
301 | QPointF position() const { return m_pos; } executed 2377 times by 6 tests: return m_pos; Executed by:
| 2377 | ||||||||||||
302 | QPointF scenePosition() const { return m_scenePos; } executed 96491 times by 19 tests: return m_scenePos; Executed by:
| 96491 | ||||||||||||
303 | QPointF scenePressPosition() const { return m_scenePressPos; } executed 4172 times by 11 tests: return m_scenePressPos; Executed by:
| 4172 | ||||||||||||
304 | QPointF sceneGrabPosition() const { return m_sceneGrabPos; } executed 1972 times by 11 tests: return m_sceneGrabPos; Executed by:
| 1972 | ||||||||||||
305 | QVector2D velocity() const { return m_velocity; } executed 1359 times by 4 tests: return m_velocity; Executed by:
| 1359 | ||||||||||||
306 | State state() const { return m_state; } executed 37108 times by 19 tests: return m_state; Executed by:
| 37108 | ||||||||||||
307 | int pointId() const { return m_pointId; } executed 23446 times by 11 tests: return m_pointId; Executed by:
| 23446 | ||||||||||||
308 | qreal timeHeld() const { return (m_timestamp - m_pressTimestamp) / 1000.0; } executed 64 times by 2 tests: return (m_timestamp - m_pressTimestamp) / 1000.0; Executed by:
| 64 | ||||||||||||
309 | bool isAccepted() const { return m_accept; } executed 20675 times by 17 tests: return m_accept; Executed by:
| 20675 | ||||||||||||
310 | void setAccepted(bool accepted = true); | - | ||||||||||||
311 | QObject *exclusiveGrabber() const; | - | ||||||||||||
312 | void setExclusiveGrabber(QObject *exclusiveGrabber); | - | ||||||||||||
313 | - | |||||||||||||
314 | QQuickItem *grabberItem() const; | - | ||||||||||||
315 | void setGrabberItem(QQuickItem *exclusiveGrabber); | - | ||||||||||||
316 | - | |||||||||||||
317 | QQuickPointerHandler *grabberPointerHandler() const; | - | ||||||||||||
318 | void setGrabberPointerHandler(QQuickPointerHandler *exclusiveGrabber, bool exclusive = false); | - | ||||||||||||
319 | - | |||||||||||||
320 | void cancelExclusiveGrab(); | - | ||||||||||||
321 | void cancelPassiveGrab(QQuickPointerHandler *handler); | - | ||||||||||||
322 | bool removePassiveGrabber(QQuickPointerHandler *handler); | - | ||||||||||||
323 | void cancelAllGrabs(QQuickPointerHandler *handler); | - | ||||||||||||
324 | - | |||||||||||||
325 | QVector<QPointer <QQuickPointerHandler> > passiveGrabbers() const { return m_passiveGrabbers; } executed 11650 times by 19 tests: return m_passiveGrabbers; Executed by:
| 11650 | ||||||||||||
326 | void setPassiveGrabbers(const QVector<QPointer <QQuickPointerHandler> > &grabbers) { m_passiveGrabbers = grabbers; } never executed: end of block | 0 | ||||||||||||
327 | void clearPassiveGrabbers() { m_passiveGrabbers.clear(); } executed 4184 times by 17 tests: end of block Executed by:
| 4184 | ||||||||||||
328 | - | |||||||||||||
329 | protected: | - | ||||||||||||
330 | void cancelExclusiveGrabImpl(QTouchEvent *cancelEvent = nullptr); | - | ||||||||||||
331 | - | |||||||||||||
332 | private: | - | ||||||||||||
333 | QVector2D estimatedVelocity() const; | - | ||||||||||||
334 | - | |||||||||||||
335 | protected: | - | ||||||||||||
336 | QPointF m_pos; | - | ||||||||||||
337 | QPointF m_scenePos; | - | ||||||||||||
338 | QPointF m_scenePressPos; | - | ||||||||||||
339 | QPointF m_sceneGrabPos; | - | ||||||||||||
340 | QVector2D m_velocity; | - | ||||||||||||
341 | int m_pointId; | - | ||||||||||||
342 | QPointer<QObject> m_exclusiveGrabber; | - | ||||||||||||
343 | QVector<QPointer <QQuickPointerHandler> > m_passiveGrabbers; | - | ||||||||||||
344 | ulong m_timestamp; | - | ||||||||||||
345 | ulong m_pressTimestamp; | - | ||||||||||||
346 | State m_state; | - | ||||||||||||
347 | bool m_accept : 1; | - | ||||||||||||
348 | bool m_grabberIsHandler : 1; | - | ||||||||||||
349 | int m_reserved : 29; | - | ||||||||||||
350 | - | |||||||||||||
351 | friend class QQuickPointerTouchEvent; | - | ||||||||||||
352 | friend class QQuickWindowPrivate; | - | ||||||||||||
353 | - | |||||||||||||
354 | Q_DISABLE_COPY(QQuickEventPoint) | - | ||||||||||||
355 | }; | - | ||||||||||||
356 | - | |||||||||||||
357 | class Q_QUICK_PRIVATE_EXPORT QQuickEventTouchPoint : public QQuickEventPoint | - | ||||||||||||
358 | { | - | ||||||||||||
359 | Q_OBJECT | - | ||||||||||||
360 | Q_PROPERTY(qreal rotation READ rotation) | - | ||||||||||||
361 | Q_PROPERTY(qreal pressure READ pressure) | - | ||||||||||||
362 | Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters) | - | ||||||||||||
363 | Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId) | - | ||||||||||||
364 | - | |||||||||||||
365 | public: | - | ||||||||||||
366 | QQuickEventTouchPoint(QQuickPointerTouchEvent *parent); | - | ||||||||||||
367 | - | |||||||||||||
368 | void reset(const QTouchEvent::TouchPoint &tp, ulong timestamp); | - | ||||||||||||
369 | - | |||||||||||||
370 | qreal rotation() const { return m_rotation; } executed 1320 times by 4 tests: return m_rotation; Executed by:
| 1320 | ||||||||||||
371 | qreal pressure() const { return m_pressure; } executed 1413 times by 4 tests: return m_pressure; Executed by:
| 1413 | ||||||||||||
372 | QSizeF ellipseDiameters() const { return m_ellipseDiameters; } executed 1413 times by 4 tests: return m_ellipseDiameters; Executed by:
| 1413 | ||||||||||||
373 | QPointingDeviceUniqueId uniqueId() const { return m_uniqueId; } executed 1320 times by 4 tests: return m_uniqueId; Executed by:
| 1320 | ||||||||||||
374 | - | |||||||||||||
375 | private: | - | ||||||||||||
376 | qreal m_rotation; | - | ||||||||||||
377 | qreal m_pressure; | - | ||||||||||||
378 | QSizeF m_ellipseDiameters; | - | ||||||||||||
379 | QPointingDeviceUniqueId m_uniqueId; | - | ||||||||||||
380 | - | |||||||||||||
381 | friend class QQuickPointerTouchEvent; | - | ||||||||||||
382 | - | |||||||||||||
383 | Q_DISABLE_COPY(QQuickEventTouchPoint) | - | ||||||||||||
384 | }; | - | ||||||||||||
385 | - | |||||||||||||
386 | class Q_QUICK_PRIVATE_EXPORT QQuickPointerEvent : public QObject | - | ||||||||||||
387 | { | - | ||||||||||||
388 | Q_OBJECT | - | ||||||||||||
389 | Q_PROPERTY(const QQuickPointerDevice *device READ device) | - | ||||||||||||
390 | Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers) | - | ||||||||||||
391 | Q_PROPERTY(Qt::MouseButtons button READ button) | - | ||||||||||||
392 | Q_PROPERTY(Qt::MouseButtons buttons READ buttons) | - | ||||||||||||
393 | - | |||||||||||||
394 | public: | - | ||||||||||||
395 | QQuickPointerEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr) | - | ||||||||||||
396 | : QObject(parent) | - | ||||||||||||
397 | , m_device(device) | - | ||||||||||||
398 | , m_pressedButtons(Qt::NoButton) | - | ||||||||||||
399 | {} executed 692 times by 19 tests: end of block Executed by:
| 692 | ||||||||||||
400 | - | |||||||||||||
401 | ~QQuickPointerEvent() override; | - | ||||||||||||
402 | - | |||||||||||||
403 | public: // property accessors | - | ||||||||||||
404 | QQuickPointerDevice *device() const { return m_device; } executed 102197 times by 19 tests: return m_device; Executed by:
| 102197 | ||||||||||||
405 | Qt::KeyboardModifiers modifiers() const { return m_event ? m_event->modifiers() : Qt::NoModifier; } executed 1553 times by 6 tests: return m_event ? m_event->modifiers() : Qt::NoModifier; Executed by:
| 1553 | ||||||||||||
406 | Qt::MouseButton button() const { return m_button; } executed 10261 times by 15 tests: return m_button; Executed by:
| 10261 | ||||||||||||
407 | Qt::MouseButtons buttons() const { return m_pressedButtons; } executed 7529 times by 18 tests: return m_pressedButtons; Executed by:
| 7529 | ||||||||||||
408 | - | |||||||||||||
409 | public: // helpers for C++ only (during event delivery) | - | ||||||||||||
410 | virtual QQuickPointerEvent *reset(QEvent *ev) = 0; | - | ||||||||||||
411 | virtual void localize(QQuickItem *target) = 0; | - | ||||||||||||
412 | - | |||||||||||||
413 | virtual bool isPressEvent() const = 0; | - | ||||||||||||
414 | virtual bool isDoubleClickEvent() const { return false; } executed 2692 times by 11 tests: return false; Executed by:
| 2692 | ||||||||||||
415 | virtual bool isUpdateEvent() const = 0; | - | ||||||||||||
416 | virtual bool isReleaseEvent() const = 0; | - | ||||||||||||
417 | virtual QQuickPointerMouseEvent *asPointerMouseEvent() { return nullptr; } executed 5001 times by 11 tests: return nullptr; Executed by:
| 5001 | ||||||||||||
418 | virtual QQuickPointerTouchEvent *asPointerTouchEvent() { return nullptr; } executed 1824 times by 15 tests: return nullptr; Executed by:
| 1824 | ||||||||||||
419 | virtual QQuickPointerTabletEvent *asPointerTabletEvent() { return nullptr; } never executed: return nullptr; | 0 | ||||||||||||
420 | #if QT_CONFIG(gestures) | - | ||||||||||||
421 | virtual QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() { return nullptr; } executed 151 times by 2 tests: return nullptr; Executed by:
| 151 | ||||||||||||
422 | #endif | - | ||||||||||||
423 | virtual QQuickPointerScrollEvent *asPointerScrollEvent() { return nullptr; } never executed: return nullptr; | 0 | ||||||||||||
424 | virtual const QQuickPointerMouseEvent *asPointerMouseEvent() const { return nullptr; } never executed: return nullptr; | 0 | ||||||||||||
425 | virtual const QQuickPointerTouchEvent *asPointerTouchEvent() const { return nullptr; } executed 192 times by 3 tests: return nullptr; Executed by:
| 192 | ||||||||||||
426 | virtual const QQuickPointerTabletEvent *asPointerTabletEvent() const { return nullptr; } executed 192 times by 3 tests: return nullptr; Executed by:
| 192 | ||||||||||||
427 | #if QT_CONFIG(gestures) | - | ||||||||||||
428 | virtual const QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() const { return nullptr; } never executed: return nullptr; | 0 | ||||||||||||
429 | #endif | - | ||||||||||||
430 | virtual const QQuickPointerScrollEvent *asPointerScrollEvent() const { return nullptr; } never executed: return nullptr; | 0 | ||||||||||||
431 | virtual bool allPointsAccepted() const = 0; | - | ||||||||||||
432 | virtual bool allUpdatedPointsAccepted() const = 0; | - | ||||||||||||
433 | virtual bool allPointsGrabbed() const = 0; | - | ||||||||||||
434 | bool isAccepted() { return m_event ? m_event->isAccepted() : false; } executed 19 times by 2 tests: return m_event ? m_event->isAccepted() : false; Executed by:
| 19 | ||||||||||||
435 | void setAccepted(bool accepted) { if (m_event) m_event->setAccepted(accepted); } executed 1924 times by 17 tests: end of block Executed by:
executed 1924 times by 17 tests: m_event->setAccepted(accepted); Executed by:
| 0-1924 | ||||||||||||
436 | QVector<QPointF> unacceptedPressedPointScenePositions() const; | - | ||||||||||||
437 | - | |||||||||||||
438 | virtual int pointCount() const = 0; | - | ||||||||||||
439 | virtual QQuickEventPoint *point(int i) const = 0; | - | ||||||||||||
440 | virtual QQuickEventPoint *pointById(int pointId) const = 0; | - | ||||||||||||
441 | virtual QVector<QObject *> exclusiveGrabbers() const = 0; | - | ||||||||||||
442 | virtual void clearGrabbers() const = 0; | - | ||||||||||||
443 | virtual bool hasExclusiveGrabber(const QQuickPointerHandler *handler) const = 0; | - | ||||||||||||
444 | - | |||||||||||||
445 | ulong timestamp() const { return m_event ? m_event->timestamp() : 0; } executed 70 times by 4 tests: return m_event ? m_event->timestamp() : 0; Executed by:
| 70 | ||||||||||||
446 | - | |||||||||||||
447 | protected: | - | ||||||||||||
448 | QQuickPointerDevice *m_device; | - | ||||||||||||
449 | QInputEvent *m_event = nullptr; // original event as received by QQuickWindow | - | ||||||||||||
450 | Qt::MouseButton m_button = Qt::NoButton; | - | ||||||||||||
451 | Qt::MouseButtons m_pressedButtons; | - | ||||||||||||
452 | - | |||||||||||||
453 | Q_DISABLE_COPY(QQuickPointerEvent) | - | ||||||||||||
454 | }; | - | ||||||||||||
455 | - | |||||||||||||
456 | class Q_QUICK_PRIVATE_EXPORT QQuickSinglePointEvent : public QQuickPointerEvent | - | ||||||||||||
457 | { | - | ||||||||||||
458 | Q_OBJECT | - | ||||||||||||
459 | public: | - | ||||||||||||
460 | QQuickSinglePointEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr) | - | ||||||||||||
461 | : QQuickPointerEvent(parent, device), m_point(new QQuickEventPoint(this)) { } executed 540 times by 18 tests: end of block Executed by:
| 540 | ||||||||||||
462 | - | |||||||||||||
463 | void localize(QQuickItem *target) override; | - | ||||||||||||
464 | int pointCount() const override { return 1; } executed 42736 times by 18 tests: return 1; Executed by:
| 42736 | ||||||||||||
465 | QQuickEventPoint *point(int i) const override; | - | ||||||||||||
466 | QQuickEventPoint *pointById(int pointId) const override; | - | ||||||||||||
467 | bool allPointsAccepted() const override; | - | ||||||||||||
468 | bool allUpdatedPointsAccepted() const override; | - | ||||||||||||
469 | bool allPointsGrabbed() const override; | - | ||||||||||||
470 | QVector<QObject *> exclusiveGrabbers() const override; | - | ||||||||||||
471 | void clearGrabbers() const override; | - | ||||||||||||
472 | bool hasExclusiveGrabber(const QQuickPointerHandler *handler) const override; | - | ||||||||||||
473 | - | |||||||||||||
474 | protected: | - | ||||||||||||
475 | QQuickEventPoint *m_point; | - | ||||||||||||
476 | - | |||||||||||||
477 | Q_DISABLE_COPY(QQuickSinglePointEvent) | - | ||||||||||||
478 | }; | - | ||||||||||||
479 | - | |||||||||||||
480 | class Q_QUICK_PRIVATE_EXPORT QQuickPointerMouseEvent : public QQuickSinglePointEvent | - | ||||||||||||
481 | { | - | ||||||||||||
482 | Q_OBJECT | - | ||||||||||||
483 | public: | - | ||||||||||||
484 | QQuickPointerMouseEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr) | - | ||||||||||||
485 | : QQuickSinglePointEvent(parent, device) { } executed 530 times by 18 tests: end of block Executed by:
| 530 | ||||||||||||
486 | - | |||||||||||||
487 | QQuickPointerEvent *reset(QEvent *) override; | - | ||||||||||||
488 | bool isPressEvent() const override; | - | ||||||||||||
489 | bool isDoubleClickEvent() const override; | - | ||||||||||||
490 | bool isUpdateEvent() const override; | - | ||||||||||||
491 | bool isReleaseEvent() const override; | - | ||||||||||||
492 | QQuickPointerMouseEvent *asPointerMouseEvent() override { return this; } executed 25709 times by 17 tests: return this; Executed by:
| 25709 | ||||||||||||
493 | const QQuickPointerMouseEvent *asPointerMouseEvent() const override { return this; } never executed: return this; | 0 | ||||||||||||
494 | - | |||||||||||||
495 | QMouseEvent *asMouseEvent(const QPointF& localPos) const; | - | ||||||||||||
496 | - | |||||||||||||
497 | Q_DISABLE_COPY(QQuickPointerMouseEvent) | - | ||||||||||||
498 | }; | - | ||||||||||||
499 | - | |||||||||||||
500 | class Q_QUICK_PRIVATE_EXPORT QQuickPointerTouchEvent : public QQuickPointerEvent | - | ||||||||||||
501 | { | - | ||||||||||||
502 | Q_OBJECT | - | ||||||||||||
503 | public: | - | ||||||||||||
504 | QQuickPointerTouchEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr) | - | ||||||||||||
505 | : QQuickPointerEvent(parent, device) | - | ||||||||||||
506 | , m_synthMouseEvent(QEvent::MouseMove, QPointF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier) | - | ||||||||||||
507 | {} executed 152 times by 11 tests: end of block Executed by:
| 152 | ||||||||||||
508 | - | |||||||||||||
509 | QQuickPointerEvent *reset(QEvent *) override; | - | ||||||||||||
510 | void localize(QQuickItem *target) override; | - | ||||||||||||
511 | bool isPressEvent() const override; | - | ||||||||||||
512 | bool isUpdateEvent() const override; | - | ||||||||||||
513 | bool isReleaseEvent() const override; | - | ||||||||||||
514 | QQuickPointerTouchEvent *asPointerTouchEvent() override { return this; } executed 5338 times by 11 tests: return this; Executed by:
| 5338 | ||||||||||||
515 | const QQuickPointerTouchEvent *asPointerTouchEvent() const override { return this; } executed 1351 times by 4 tests: return this; Executed by:
| 1351 | ||||||||||||
516 | int pointCount() const override { return m_pointCount; } executed 14913 times by 11 tests: return m_pointCount; Executed by:
| 14913 | ||||||||||||
517 | QQuickEventPoint *point(int i) const override; | - | ||||||||||||
518 | QQuickEventPoint *pointById(int pointId) const override; | - | ||||||||||||
519 | const QTouchEvent::TouchPoint *touchPointById(int pointId) const; | - | ||||||||||||
520 | bool allPointsAccepted() const override; | - | ||||||||||||
521 | bool allUpdatedPointsAccepted() const override; | - | ||||||||||||
522 | bool allPointsGrabbed() const override; | - | ||||||||||||
523 | QVector<QObject *> exclusiveGrabbers() const override; | - | ||||||||||||
524 | void clearGrabbers() const override; | - | ||||||||||||
525 | bool hasExclusiveGrabber(const QQuickPointerHandler *handler) const override; | - | ||||||||||||
526 | - | |||||||||||||
527 | QMouseEvent *syntheticMouseEvent(int pointID, QQuickItem *relativeTo) const; | - | ||||||||||||
528 | QTouchEvent *touchEventForItem(QQuickItem *item, bool isFiltering = false) const; | - | ||||||||||||
529 | - | |||||||||||||
530 | QTouchEvent *asTouchEvent() const; | - | ||||||||||||
531 | - | |||||||||||||
532 | private: | - | ||||||||||||
533 | Qt::TouchPointStates touchPointStates() const; | - | ||||||||||||
534 | - | |||||||||||||
535 | int m_pointCount = 0; | - | ||||||||||||
536 | QVector<QQuickEventTouchPoint *> m_touchPoints; | - | ||||||||||||
537 | mutable QMouseEvent m_synthMouseEvent; | - | ||||||||||||
538 | - | |||||||||||||
539 | Q_DISABLE_COPY(QQuickPointerTouchEvent) | - | ||||||||||||
540 | }; | - | ||||||||||||
541 | - | |||||||||||||
542 | #if QT_CONFIG(gestures) | - | ||||||||||||
543 | class Q_QUICK_PRIVATE_EXPORT QQuickPointerNativeGestureEvent : public QQuickSinglePointEvent | - | ||||||||||||
544 | { | - | ||||||||||||
545 | Q_OBJECT | - | ||||||||||||
546 | Q_PROPERTY(Qt::NativeGestureType type READ type CONSTANT) | - | ||||||||||||
547 | Q_PROPERTY(qreal value READ value CONSTANT) | - | ||||||||||||
548 | - | |||||||||||||
549 | public: | - | ||||||||||||
550 | QQuickPointerNativeGestureEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr) | - | ||||||||||||
551 | : QQuickSinglePointEvent(parent, device) { } never executed: end of block | 0 | ||||||||||||
552 | - | |||||||||||||
553 | QQuickPointerEvent *reset(QEvent *) override; | - | ||||||||||||
554 | bool isPressEvent() const override; | - | ||||||||||||
555 | bool isUpdateEvent() const override; | - | ||||||||||||
556 | bool isReleaseEvent() const override; | - | ||||||||||||
557 | QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() override { return this; } never executed: return this; | 0 | ||||||||||||
558 | const QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() const override { return this; } never executed: return this; | 0 | ||||||||||||
559 | Qt::NativeGestureType type() const; | - | ||||||||||||
560 | qreal value() const; | - | ||||||||||||
561 | - | |||||||||||||
562 | Q_DISABLE_COPY(QQuickPointerNativeGestureEvent) | - | ||||||||||||
563 | }; | - | ||||||||||||
564 | #endif // QT_CONFIG(gestures) | - | ||||||||||||
565 | - | |||||||||||||
566 | class Q_QUICK_PRIVATE_EXPORT QQuickPointerScrollEvent : public QQuickSinglePointEvent | - | ||||||||||||
567 | { | - | ||||||||||||
568 | Q_OBJECT | - | ||||||||||||
569 | Q_PROPERTY(QVector2D angleDelta READ angleDelta CONSTANT) | - | ||||||||||||
570 | Q_PROPERTY(QVector2D pixelDelta READ pixelDelta CONSTANT) | - | ||||||||||||
571 | Q_PROPERTY(bool hasAngleDelta READ hasAngleDelta CONSTANT) | - | ||||||||||||
572 | Q_PROPERTY(bool hasPixelDelta READ hasPixelDelta CONSTANT) | - | ||||||||||||
573 | Q_PROPERTY(bool inverted READ isInverted CONSTANT) | - | ||||||||||||
574 | - | |||||||||||||
575 | public: | - | ||||||||||||
576 | QQuickPointerScrollEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr) | - | ||||||||||||
577 | : QQuickSinglePointEvent(parent, device) { } executed 10 times by 2 tests: end of block Executed by:
| 10 | ||||||||||||
578 | - | |||||||||||||
579 | QQuickPointerEvent *reset(QEvent *) override; | - | ||||||||||||
580 | void localize(QQuickItem *target) override; | - | ||||||||||||
581 | bool isPressEvent() const override; | - | ||||||||||||
582 | bool isUpdateEvent() const override; | - | ||||||||||||
583 | bool isReleaseEvent() const override; | - | ||||||||||||
584 | QQuickPointerScrollEvent *asPointerScrollEvent() override { return this; } executed 10 times by 2 tests: return this; Executed by:
| 10 | ||||||||||||
585 | const QQuickPointerScrollEvent *asPointerScrollEvent() const override { return this; } never executed: return this; | 0 | ||||||||||||
586 | QVector2D angleDelta() const { return m_angleDelta; } executed 10 times by 2 tests: return m_angleDelta; Executed by:
| 10 | ||||||||||||
587 | QVector2D pixelDelta() const { return m_pixelDelta; } executed 10 times by 2 tests: return m_pixelDelta; Executed by:
| 10 | ||||||||||||
588 | bool hasAngleDelta() const { return !angleDelta().isNull(); } never executed: return !angleDelta().isNull(); | 0 | ||||||||||||
589 | bool hasPixelDelta() const { return !pixelDelta().isNull(); } never executed: return !pixelDelta().isNull(); | 0 | ||||||||||||
590 | bool isInverted() const { return m_inverted; } executed 10 times by 2 tests: return m_inverted; Executed by:
| 10 | ||||||||||||
591 | Qt::ScrollPhase phase() const { return m_phase; } executed 10 times by 2 tests: return m_phase; Executed by:
| 10 | ||||||||||||
592 | - | |||||||||||||
593 | private: | - | ||||||||||||
594 | // TODO add QQuickPointerDevice source() whenever QInputEvent is extended to have a source device | - | ||||||||||||
595 | // then maybe Qt::MouseEventSource synthSource() will be obsolete... that's why it's not public now | - | ||||||||||||
596 | Qt::MouseEventSource synthSource() const { return m_synthSource; } executed 10 times by 2 tests: return m_synthSource; Executed by:
| 10 | ||||||||||||
597 | - | |||||||||||||
598 | private: | - | ||||||||||||
599 | QVector2D m_angleDelta; | - | ||||||||||||
600 | QVector2D m_pixelDelta; | - | ||||||||||||
601 | Qt::ScrollPhase m_phase = Qt::NoScrollPhase; | - | ||||||||||||
602 | Qt::MouseEventSource m_synthSource = Qt::MouseEventNotSynthesized; | - | ||||||||||||
603 | bool m_inverted = false; | - | ||||||||||||
604 | - | |||||||||||||
605 | friend class QQuickWindowPrivate; | - | ||||||||||||
606 | - | |||||||||||||
607 | Q_DISABLE_COPY(QQuickPointerScrollEvent) | - | ||||||||||||
608 | }; | - | ||||||||||||
609 | - | |||||||||||||
610 | - | |||||||||||||
611 | // ### Qt 6: move this to qtbase, replace QTouchDevice and the enums in QTabletEvent | - | ||||||||||||
612 | class Q_QUICK_PRIVATE_EXPORT QQuickPointerDevice : public QObject | - | ||||||||||||
613 | { | - | ||||||||||||
614 | Q_OBJECT | - | ||||||||||||
615 | Q_PROPERTY(DeviceType type READ type CONSTANT) | - | ||||||||||||
616 | Q_PROPERTY(PointerType pointerType READ pointerType CONSTANT) | - | ||||||||||||
617 | Q_PROPERTY(Capabilities capabilities READ capabilities CONSTANT) | - | ||||||||||||
618 | Q_PROPERTY(int maximumTouchPoints READ maximumTouchPoints CONSTANT) | - | ||||||||||||
619 | Q_PROPERTY(int buttonCount READ buttonCount CONSTANT) | - | ||||||||||||
620 | Q_PROPERTY(QString name READ name CONSTANT) | - | ||||||||||||
621 | Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId CONSTANT) | - | ||||||||||||
622 | - | |||||||||||||
623 | public: | - | ||||||||||||
624 | enum DeviceType : qint16 { | - | ||||||||||||
625 | UnknownDevice = 0x0000, | - | ||||||||||||
626 | Mouse = 0x0001, | - | ||||||||||||
627 | TouchScreen = 0x0002, | - | ||||||||||||
628 | TouchPad = 0x0004, | - | ||||||||||||
629 | Puck = 0x0008, | - | ||||||||||||
630 | Stylus = 0x0010, | - | ||||||||||||
631 | Airbrush = 0x0020, | - | ||||||||||||
632 | AllDevices = 0x7FFF | - | ||||||||||||
633 | }; | - | ||||||||||||
634 | Q_DECLARE_FLAGS(DeviceTypes, DeviceType) | - | ||||||||||||
635 | Q_ENUM(DeviceType) | - | ||||||||||||
636 | Q_FLAG(DeviceTypes) | - | ||||||||||||
637 | - | |||||||||||||
638 | enum PointerType : qint16 { | - | ||||||||||||
639 | GenericPointer = 0x0001, | - | ||||||||||||
640 | Finger = 0x0002, | - | ||||||||||||
641 | Pen = 0x0004, | - | ||||||||||||
642 | Eraser = 0x0008, | - | ||||||||||||
643 | Cursor = 0x0010, | - | ||||||||||||
644 | AllPointerTypes = 0x7FFF | - | ||||||||||||
645 | }; | - | ||||||||||||
646 | Q_DECLARE_FLAGS(PointerTypes, PointerType) | - | ||||||||||||
647 | Q_ENUM(PointerType) | - | ||||||||||||
648 | Q_FLAG(PointerTypes) | - | ||||||||||||
649 | - | |||||||||||||
650 | enum CapabilityFlag : qint16 { | - | ||||||||||||
651 | Position = QTouchDevice::Position, | - | ||||||||||||
652 | Area = QTouchDevice::Area, | - | ||||||||||||
653 | Pressure = QTouchDevice::Pressure, | - | ||||||||||||
654 | Velocity = QTouchDevice::Velocity, | - | ||||||||||||
655 | MouseEmulation = QTouchDevice::MouseEmulation, | - | ||||||||||||
656 | // some bits reserved in case we need more of QTouchDevice::Capabilities | - | ||||||||||||
657 | Scroll = 0x0100, // mouse has a wheel, or there is OS-level scroll gesture recognition (dubious?) | - | ||||||||||||
658 | Hover = 0x0200, | - | ||||||||||||
659 | Rotation = 0x0400, | - | ||||||||||||
660 | XTilt = 0x0800, | - | ||||||||||||
661 | YTilt = 0x1000 | - | ||||||||||||
662 | }; | - | ||||||||||||
663 | Q_DECLARE_FLAGS(Capabilities, CapabilityFlag) | - | ||||||||||||
664 | Q_ENUM(CapabilityFlag) | - | ||||||||||||
665 | Q_FLAG(Capabilities) | - | ||||||||||||
666 | - | |||||||||||||
667 | DeviceType type() const { return m_deviceType; } executed 5931 times by 19 tests: return m_deviceType; Executed by:
| 5931 | ||||||||||||
668 | PointerType pointerType() const { return m_pointerType; } executed 5293 times by 4 tests: return m_pointerType; Executed by:
| 5293 | ||||||||||||
669 | Capabilities capabilities() const { return static_cast<Capabilities>(m_capabilities); } never executed: return static_cast<Capabilities>(m_capabilities); | 0 | ||||||||||||
670 | bool hasCapability(CapabilityFlag cap) { return m_capabilities & cap; } never executed: return m_capabilities & cap; | 0 | ||||||||||||
671 | int maximumTouchPoints() const { return m_maximumTouchPoints; } never executed: return m_maximumTouchPoints; | 0 | ||||||||||||
672 | int buttonCount() const { return m_buttonCount; } never executed: return m_buttonCount; | 0 | ||||||||||||
673 | QString name() const { return m_name; } never executed: return m_name; | 0 | ||||||||||||
674 | QPointingDeviceUniqueId uniqueId() const { return m_uniqueId; } executed 192 times by 3 tests: return m_uniqueId; Executed by:
| 192 | ||||||||||||
675 | const QTouchDevice *qTouchDevice() const; | - | ||||||||||||
676 | - | |||||||||||||
677 | static QQuickPointerDevice *touchDevice(const QTouchDevice *d); | - | ||||||||||||
678 | static QList<QQuickPointerDevice *> touchDevices(); | - | ||||||||||||
679 | static QQuickPointerDevice *genericMouseDevice(); | - | ||||||||||||
680 | static QQuickPointerDevice *tabletDevice(qint64); | - | ||||||||||||
681 | - | |||||||||||||
682 | QVector<QQuickPointerHandler *> &eventDeliveryTargets() { return m_eventDeliveryTargets; } executed 31683 times by 19 tests: return m_eventDeliveryTargets; Executed by:
| 31683 | ||||||||||||
683 | - | |||||||||||||
684 | private: | - | ||||||||||||
685 | QQuickPointerDevice(DeviceType devType, PointerType pType, Capabilities caps, int maxPoints, int buttonCount, const QString &name, qint64 uniqueId = 0) | - | ||||||||||||
686 | : m_deviceType(devType), m_pointerType(pType), m_capabilities(static_cast<qint16>(caps)) | - | ||||||||||||
687 | , m_maximumTouchPoints(static_cast<qint8>(maxPoints)), m_buttonCount(static_cast<qint8>(buttonCount)), m_name(name) | - | ||||||||||||
688 | , m_uniqueId(QPointingDeviceUniqueId::fromNumericId(uniqueId)) | - | ||||||||||||
689 | { | - | ||||||||||||
690 | } executed 218 times by 91 tests: end of block Executed by:
| 218 | ||||||||||||
691 | ~QQuickPointerDevice() override { } | - | ||||||||||||
692 | - | |||||||||||||
693 | private: | - | ||||||||||||
694 | // begin 64-bit field | - | ||||||||||||
695 | DeviceType m_deviceType; | - | ||||||||||||
696 | PointerType m_pointerType; | - | ||||||||||||
697 | qint16 m_capabilities; | - | ||||||||||||
698 | qint8 m_maximumTouchPoints; | - | ||||||||||||
699 | qint8 m_buttonCount; | - | ||||||||||||
700 | // end 64-bit field | - | ||||||||||||
701 | QString m_name; | - | ||||||||||||
702 | QPointingDeviceUniqueId m_uniqueId; | - | ||||||||||||
703 | QVector<QQuickPointerHandler *> m_eventDeliveryTargets; // during delivery, handlers which have already seen the event | - | ||||||||||||
704 | - | |||||||||||||
705 | Q_DISABLE_COPY(QQuickPointerDevice) | - | ||||||||||||
706 | friend struct ConstructableQQuickPointerDevice; | - | ||||||||||||
707 | }; | - | ||||||||||||
708 | - | |||||||||||||
709 | Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPointerDevice::DeviceTypes) | - | ||||||||||||
710 | Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPointerDevice::PointerTypes) | - | ||||||||||||
711 | Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPointerDevice::Capabilities) | - | ||||||||||||
712 | - | |||||||||||||
713 | Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug, const QQuickPointerDevice *); | - | ||||||||||||
714 | Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug, const QQuickPointerEvent *); | - | ||||||||||||
715 | Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug, const QQuickEventPoint *); | - | ||||||||||||
716 | //Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug, const QQuickEventTouchPoint *); TODO maybe | - | ||||||||||||
717 | - | |||||||||||||
718 | QT_END_NAMESPACE | - | ||||||||||||
719 | - | |||||||||||||
720 | QML_DECLARE_TYPE(QQuickKeyEvent) never executed: return id; never executed: return newId; never executed: return id; never executed: return newId;
| 0 | ||||||||||||
721 | QML_DECLARE_TYPE(QQuickMouseEvent) never executed: return id; never executed: return newId; never executed: return id; never executed: return newId;
| 0 | ||||||||||||
722 | QML_DECLARE_TYPE(QQuickWheelEvent) never executed: return id; never executed: return newId; never executed: return id; never executed: return newId;
| 0 | ||||||||||||
723 | QML_DECLARE_TYPE(QQuickCloseEvent) never executed: return id; never executed: return newId; never executed: return id; never executed: return newId;
| 0 | ||||||||||||
724 | QML_DECLARE_TYPE(QQuickPointerDevice) never executed: return id; never executed: return newId; never executed: return id; never executed: return newId;
| 0 | ||||||||||||
725 | QML_DECLARE_TYPE(QPointingDeviceUniqueId) never executed: return id; never executed: return newId; never executed: return id; never executed: return newId;
| 0 | ||||||||||||
726 | QML_DECLARE_TYPE(QQuickPointerEvent) never executed: return id; never executed: return newId; never executed: return id; never executed: return newId;
| 0 | ||||||||||||
727 | - | |||||||||||||
728 | #endif // QQUICKEVENTS_P_P_H | - | ||||||||||||
Source code | Switch to Preprocessed file |