OpenCoverage

qquickpointerdevicehandler.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/handlers/qquickpointerdevicehandler.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 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#include "qquickpointerdevicehandler_p_p.h"-
41#include <private/qquickitem_p.h>-
42#include <QMouseEvent>-
43#include <QDebug>-
44-
45QT_BEGIN_NAMESPACE-
46-
47/*!-
48 \qmltype PointerDeviceHandler-
49 \qmlabstract-
50 \since 5.10-
51 \preliminary-
52 \instantiates QQuickPointerDeviceHandler-
53 \inherits PointerHandler-
54 \inqmlmodule Qt.labs.handlers-
55 \ingroup qtquick-handlers-
56 \brief Abstract handler for pointer events with device-specific constraints.-
57-
58 An intermediate class (not registered as a QML type) for handlers which-
59 allow filtering based on device type, pointer type, or keyboard modifiers.-
60*/-
61QQuickPointerDeviceHandler::QQuickPointerDeviceHandler(QObject *parent)-
62 : QQuickPointerHandler(*(new QQuickPointerDeviceHandlerPrivate), parent)-
63{-
64}
executed 1004 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1004
65-
66QQuickPointerDeviceHandler::QQuickPointerDeviceHandler(QQuickPointerDeviceHandlerPrivate &dd, QObject *parent)-
67 : QQuickPointerHandler(dd, parent)-
68{-
69}
never executed: end of block
0
70-
71QQuickPointerDeviceHandler::~QQuickPointerDeviceHandler()-
72{-
73}-
74-
75QQuickPointerDevice::DeviceTypes QQuickPointerDeviceHandler::acceptedDevices() const-
76{-
77 Q_D(const QQuickPointerDeviceHandler);-
78 return d->acceptedDevices;
never executed: return d->acceptedDevices;
0
79}-
80-
81QQuickPointerDevice::PointerTypes QQuickPointerDeviceHandler::acceptedPointerTypes() const-
82{-
83 Q_D(const QQuickPointerDeviceHandler);-
84 return d->acceptedPointerTypes;
never executed: return d->acceptedPointerTypes;
0
85}-
86-
87/*!-
88 \qmlproperty int QtQuick::PointerDeviceHandler::acceptedButtons-
89-
90 The mouse buttons which can activate this Pointer Handler.-
91-
92 By default, this property is set to \l {QtQuick::MouseEvent::button} {Qt.LeftButton}.-
93 It can be set to an OR combination of mouse buttons, and will ignore events-
94 from other buttons.-
95-
96 For example, a control could be made to respond to left and right clicks-
97 in different ways, with two handlers:-
98-
99 \qml-
100 Item {-
101 TapHandler {-
102 onTapped: console.log("left clicked")-
103 }-
104 TapHandler {-
105 acceptedButtons: Qt.RightButton-
106 onTapped: console.log("right clicked")-
107 }-
108 }-
109 \endqml-
110-
111 \note Tapping on a touchscreen or tapping the stylus on a graphics tablet-
112 emulates clicking the left mouse button. This behavior can be altered via-
113 \l {PointerDeviceHandler::acceptedDevices}{acceptedDevices} or-
114 \l {PointerDeviceHandler::acceptedPointerTypes}{acceptedPointerTypes}.-
115*/-
116Qt::MouseButtons QQuickPointerDeviceHandler::acceptedButtons() const-
117{-
118 Q_D(const QQuickPointerDeviceHandler);-
119 return d->acceptedButtons;
executed 490 times by 3 tests: return d->acceptedButtons;
Executed by:
  • tst_flickableinterop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
490
120}-
121-
122void QQuickPointerDeviceHandler::setAcceptedButtons(Qt::MouseButtons buttons)-
123{-
124 Q_D(QQuickPointerDeviceHandler);-
125 if (d->acceptedButtons == buttons)
d->acceptedButtons == buttonsDescription
TRUEnever evaluated
FALSEnever evaluated
0
126 return;
never executed: return;
0
127-
128 d->acceptedButtons = buttons;-
129 emit acceptedButtonsChanged();-
130}
never executed: end of block
0
131-
132Qt::KeyboardModifiers QQuickPointerDeviceHandler::acceptedModifiers() const-
133{-
134 Q_D(const QQuickPointerDeviceHandler);-
135 return d->acceptedModifiers;
never executed: return d->acceptedModifiers;
0
136}-
137-
138/*!-
139 \qmlproperty int PointerDeviceHandler::acceptedDevices-
140-
141 The types of pointing devices that can activate this Pointer Handler.-
142-
143 By default, this property is set to-
144 \l{QtQuick::PointerDevice::type} {PointerDevice.AllDevices}.-
145 If you set it to an OR combination of device types, it will ignore events-
146 from non-matching devices.-
147-
148 For example, a control could be made to respond to mouse and stylus clicks-
149 in one way, and touchscreen taps in another way, with two handlers:-
150-
151 \qml-
152 Item {-
153 TapHandler {-
154 acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus-
155 onTapped: console.log("clicked")-
156 }-
157 TapHandler {-
158 acceptedDevices: PointerDevice.TouchScreen-
159 onTapped: console.log("tapped")-
160 }-
161 }-
162 \endqml-
163*/-
164void QQuickPointerDeviceHandler::setAcceptedDevices(QQuickPointerDevice::DeviceTypes acceptedDevices)-
165{-
166 Q_D(QQuickPointerDeviceHandler);-
167 if (d->acceptedDevices == acceptedDevices)
d->acceptedDev...cceptedDevicesDescription
TRUEnever evaluated
FALSEnever evaluated
0
168 return;
never executed: return;
0
169-
170 d->acceptedDevices = acceptedDevices;-
171 emit acceptedDevicesChanged();-
172}
never executed: end of block
0
173-
174/*!-
175 \qmlproperty int PointerDeviceHandler::acceptedPointerTypes-
176-
177 The types of pointing instruments (finger, stylus, eraser, etc.)-
178 that can activate this Pointer Handler.-
179-
180 By default, this property is set to-
181 \l {QtQuick::PointerDevice::pointerType} {PointerDevice.AllPointerTypes}.-
182 If you set it to an OR combination of device types, it will ignore events-
183 from non-matching events.-
184-
185 For example, a control could be made to respond to mouse, touch, and stylus clicks-
186 in some way, but delete itself if tapped with an eraser tool on a graphics tablet,-
187 with two handlers:-
188-
189 \qml-
190 Rectangle {-
191 id: rect-
192 TapHandler {-
193 acceptedPointerTypes: PointerDevice.GenericPointer | PointerDevice.Finger | PointerDevice.Pen-
194 onTapped: console.log("clicked")-
195 }-
196 TapHandler {-
197 acceptedPointerTypes: PointerDevice.Eraser-
198 onTapped: rect.destroy()-
199 }-
200 }-
201 \endqml-
202*/-
203void QQuickPointerDeviceHandler::setAcceptedPointerTypes(QQuickPointerDevice::PointerTypes acceptedPointerTypes)-
204{-
205 Q_D(QQuickPointerDeviceHandler);-
206 if (d->acceptedPointerTypes == acceptedPointerTypes)
d->acceptedPoi...edPointerTypesDescription
TRUEnever evaluated
FALSEnever evaluated
0
207 return;
never executed: return;
0
208-
209 d->acceptedPointerTypes = acceptedPointerTypes;-
210 emit acceptedPointerTypesChanged();-
211}
never executed: end of block
0
212-
213/*!-
214 \qmlproperty int PointerDeviceHandler::acceptedModifiers-
215-
216 If this property is set, it will require the given keyboard modifiers to-
217 be pressed in order to react to pointer events, and otherwise ignore them.-
218-
219 If this property is set to \c Qt.KeyboardModifierMask (the default value),-
220 then the PointerHandler ignores the modifier keys.-
221-
222 For example, an \l [QML] Item could have two handlers of the same type,-
223 one of which is enabled only if the required keyboard modifiers are-
224 pressed:-
225-
226 \qml-
227 Item {-
228 TapHandler {-
229 acceptedModifiers: Qt.ControlModifier-
230 onTapped: console.log("control-tapped")-
231 }-
232 TapHandler {-
233 acceptedModifiers: Qt.NoModifier-
234 onTapped: console.log("tapped")-
235 }-
236 }-
237 \endqml-
238*/-
239void QQuickPointerDeviceHandler::setAcceptedModifiers(Qt::KeyboardModifiers acceptedModifiers)-
240{-
241 Q_D(QQuickPointerDeviceHandler);-
242 if (d->acceptedModifiers == acceptedModifiers)
d->acceptedMod...eptedModifiersDescription
TRUEnever evaluated
FALSEnever evaluated
0
243 return;
never executed: return;
0
244-
245 d->acceptedModifiers = acceptedModifiers;-
246 emit acceptedModifiersChanged();-
247}
never executed: end of block
0
248-
249bool QQuickPointerDeviceHandler::wantsPointerEvent(QQuickPointerEvent *event)-
250{-
251 Q_D(QQuickPointerDeviceHandler);-
252 if (!QQuickPointerHandler::wantsPointerEvent(event))
!QQuickPointer...erEvent(event)Description
TRUEnever evaluated
FALSEevaluated 2688 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
0-2688
253 return false;
never executed: return false;
0
254 qCDebug(lcPointerHandlerDispatch) << objectName()
never executed: QMessageLogger(__FILE__, 254, __PRETTY_FUNCTION__, lcPointerHandlerDispatch().categoryName()).debug() << objectName() << "checking device type" << d->acceptedDevices << "pointer type" << d->acceptedPointerTypes << "modifiers" << d->acceptedModifiers;
qt_category_enabledDescription
TRUEnever evaluated
FALSEevaluated 2688 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
0-2688
255 << "checking device type" << d->acceptedDevices
never executed: QMessageLogger(__FILE__, 254, __PRETTY_FUNCTION__, lcPointerHandlerDispatch().categoryName()).debug() << objectName() << "checking device type" << d->acceptedDevices << "pointer type" << d->acceptedPointerTypes << "modifiers" << d->acceptedModifiers;
0
256 << "pointer type" << d->acceptedPointerTypes
never executed: QMessageLogger(__FILE__, 254, __PRETTY_FUNCTION__, lcPointerHandlerDispatch().categoryName()).debug() << objectName() << "checking device type" << d->acceptedDevices << "pointer type" << d->acceptedPointerTypes << "modifiers" << d->acceptedModifiers;
0
257 << "modifiers" << d->acceptedModifiers;
never executed: QMessageLogger(__FILE__, 254, __PRETTY_FUNCTION__, lcPointerHandlerDispatch().categoryName()).debug() << objectName() << "checking device type" << d->acceptedDevices << "pointer type" << d->acceptedPointerTypes << "modifiers" << d->acceptedModifiers;
0
258 if ((event->device()->type() & d->acceptedDevices) == 0)
(event->device...dDevices) == 0Description
TRUEnever evaluated
FALSEevaluated 2688 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
0-2688
259 return false;
never executed: return false;
0
260 if ((event->device()->pointerType() & d->acceptedPointerTypes) == 0)
(event->device...terTypes) == 0Description
TRUEnever evaluated
FALSEevaluated 2688 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
0-2688
261 return false;
never executed: return false;
0
262 if (d->acceptedModifiers != Qt::KeyboardModifierMask && event->modifiers() != d->acceptedModifiers)
d->acceptedMod...rdModifierMaskDescription
TRUEnever evaluated
FALSEevaluated 2688 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
event->modifie...eptedModifiersDescription
TRUEnever evaluated
FALSEnever evaluated
0-2688
263 return false;
never executed: return false;
0
264 return true;
executed 2688 times by 4 tests: return true;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
2688
265}-
266-
267QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0