| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickmultipointtoucharea.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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 "qquickmultipointtoucharea_p.h" | - | ||||||||||||||||||||||||||||||
| 41 | #include <QtQuick/qquickwindow.h> | - | ||||||||||||||||||||||||||||||
| 42 | #include <private/qsgadaptationlayer_p.h> | - | ||||||||||||||||||||||||||||||
| 43 | #include <private/qquickitem_p.h> | - | ||||||||||||||||||||||||||||||
| 44 | #include <private/qguiapplication_p.h> | - | ||||||||||||||||||||||||||||||
| 45 | #include <QEvent> | - | ||||||||||||||||||||||||||||||
| 46 | #include <QMouseEvent> | - | ||||||||||||||||||||||||||||||
| 47 | #include <QDebug> | - | ||||||||||||||||||||||||||||||
| 48 | #include <qpa/qplatformnativeinterface.h> | - | ||||||||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||||||||
| 50 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||||||||
| 52 | DEFINE_BOOL_CONFIG_OPTION(qmlVisualTouchDebugging, QML_VISUAL_TOUCH_DEBUGGING) never executed: status = Yes;never executed: end of blockexecuted 8 times by 4 tests: end of blockExecuted by:
executed 62 times by 4 tests: return status == Yes;Executed by:
| 0-62 | ||||||||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||||||||
| 54 | /*! | - | ||||||||||||||||||||||||||||||
| 55 | \qmltype TouchPoint | - | ||||||||||||||||||||||||||||||
| 56 | \instantiates QQuickTouchPoint | - | ||||||||||||||||||||||||||||||
| 57 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 58 | \ingroup qtquick-input-events | - | ||||||||||||||||||||||||||||||
| 59 | \brief Describes a touch point in a MultiPointTouchArea. | - | ||||||||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||||||||
| 61 | The TouchPoint type contains information about a touch point, such as the current | - | ||||||||||||||||||||||||||||||
| 62 | position, pressure, and area. | - | ||||||||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||||||||
| 64 | \image touchpoint-metrics.png | - | ||||||||||||||||||||||||||||||
| 65 | */ | - | ||||||||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||||||||
| 67 | /*! | - | ||||||||||||||||||||||||||||||
| 68 | \qmlproperty int QtQuick::TouchPoint::pointId | - | ||||||||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||||||||
| 70 | This property holds the point id of the touch point. | - | ||||||||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||||||||
| 72 | Each touch point within a MultiPointTouchArea will have a unique id. | - | ||||||||||||||||||||||||||||||
| 73 | */ | - | ||||||||||||||||||||||||||||||
| 74 | void QQuickTouchPoint::setPointId(int id) | - | ||||||||||||||||||||||||||||||
| 75 | { | - | ||||||||||||||||||||||||||||||
| 76 | if (_id == id)
| 70-186 | ||||||||||||||||||||||||||||||
| 77 | return; executed 70 times by 3 tests: return;Executed by:
| 70 | ||||||||||||||||||||||||||||||
| 78 | _id = id; | - | ||||||||||||||||||||||||||||||
| 79 | emit pointIdChanged(); | - | ||||||||||||||||||||||||||||||
| 80 | } executed 186 times by 3 tests: end of blockExecuted by:
| 186 | ||||||||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||||||||
| 82 | /*! | - | ||||||||||||||||||||||||||||||
| 83 | \qmlproperty real QtQuick::TouchPoint::x | - | ||||||||||||||||||||||||||||||
| 84 | \qmlproperty real QtQuick::TouchPoint::y | - | ||||||||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||||||||
| 86 | These properties hold the current position of the touch point. | - | ||||||||||||||||||||||||||||||
| 87 | */ | - | ||||||||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||||||||
| 89 | void QQuickTouchPoint::setX(qreal x) | - | ||||||||||||||||||||||||||||||
| 90 | { | - | ||||||||||||||||||||||||||||||
| 91 | if (_x == x)
| 214-284 | ||||||||||||||||||||||||||||||
| 92 | return; executed 214 times by 2 tests: return;Executed by:
| 214 | ||||||||||||||||||||||||||||||
| 93 | _x = x; | - | ||||||||||||||||||||||||||||||
| 94 | emit xChanged(); | - | ||||||||||||||||||||||||||||||
| 95 | } executed 284 times by 2 tests: end of blockExecuted by:
| 284 | ||||||||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||||||||
| 97 | void QQuickTouchPoint::setY(qreal y) | - | ||||||||||||||||||||||||||||||
| 98 | { | - | ||||||||||||||||||||||||||||||
| 99 | if (_y == y)
| 244-254 | ||||||||||||||||||||||||||||||
| 100 | return; executed 244 times by 2 tests: return;Executed by:
| 244 | ||||||||||||||||||||||||||||||
| 101 | _y = y; | - | ||||||||||||||||||||||||||||||
| 102 | emit yChanged(); | - | ||||||||||||||||||||||||||||||
| 103 | } executed 254 times by 2 tests: end of blockExecuted by:
| 254 | ||||||||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||||||||
| 105 | /*! | - | ||||||||||||||||||||||||||||||
| 106 | \qmlproperty size QtQuick::TouchPoint::ellipseDiameters | - | ||||||||||||||||||||||||||||||
| 107 | \since 5.9 | - | ||||||||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||||||||
| 109 | This property holds the major and minor axes of the ellipse representing | - | ||||||||||||||||||||||||||||||
| 110 | the covered area of the touch point. | - | ||||||||||||||||||||||||||||||
| 111 | */ | - | ||||||||||||||||||||||||||||||
| 112 | void QQuickTouchPoint::setEllipseDiameters(const QSizeF &d) | - | ||||||||||||||||||||||||||||||
| 113 | { | - | ||||||||||||||||||||||||||||||
| 114 | if (_ellipseDiameters == d)
| 106-380 | ||||||||||||||||||||||||||||||
| 115 | return; executed 380 times by 2 tests: return;Executed by:
| 380 | ||||||||||||||||||||||||||||||
| 116 | _ellipseDiameters = d; | - | ||||||||||||||||||||||||||||||
| 117 | emit ellipseDiametersChanged(); | - | ||||||||||||||||||||||||||||||
| 118 | } executed 106 times by 2 tests: end of blockExecuted by:
| 106 | ||||||||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||||||||
| 120 | /*! | - | ||||||||||||||||||||||||||||||
| 121 | \qmlproperty real QtQuick::TouchPoint::pressure | - | ||||||||||||||||||||||||||||||
| 122 | \qmlproperty vector2d QtQuick::TouchPoint::velocity | - | ||||||||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||||||||
| 124 | These properties hold additional information about the current state of the touch point. | - | ||||||||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||||||||
| 126 | \list | - | ||||||||||||||||||||||||||||||
| 127 | \li \c pressure is a value in the range of 0.0 to 1.0. | - | ||||||||||||||||||||||||||||||
| 128 | \li \c velocity is a vector with magnitude reported in pixels per second. | - | ||||||||||||||||||||||||||||||
| 129 | \endlist | - | ||||||||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||||||||
| 131 | Not all touch devices support velocity. If velocity is not supported, it will be reported | - | ||||||||||||||||||||||||||||||
| 132 | as 0,0. | - | ||||||||||||||||||||||||||||||
| 133 | */ | - | ||||||||||||||||||||||||||||||
| 134 | void QQuickTouchPoint::setPressure(qreal pressure) | - | ||||||||||||||||||||||||||||||
| 135 | { | - | ||||||||||||||||||||||||||||||
| 136 | if (_pressure == pressure)
| 200-286 | ||||||||||||||||||||||||||||||
| 137 | return; executed 286 times by 2 tests: return;Executed by:
| 286 | ||||||||||||||||||||||||||||||
| 138 | _pressure = pressure; | - | ||||||||||||||||||||||||||||||
| 139 | emit pressureChanged(); | - | ||||||||||||||||||||||||||||||
| 140 | } executed 200 times by 2 tests: end of blockExecuted by:
| 200 | ||||||||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||||||||
| 142 | /*! | - | ||||||||||||||||||||||||||||||
| 143 | \qmlproperty real QtQuick::TouchPoint::rotation | - | ||||||||||||||||||||||||||||||
| 144 | \since 5.9 | - | ||||||||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||||||||
| 146 | This property holds the angular orientation of this touch point. The return | - | ||||||||||||||||||||||||||||||
| 147 | value is in degrees, where zero (the default) indicates the finger or token | - | ||||||||||||||||||||||||||||||
| 148 | is pointing upwards, a negative angle means it's rotated to the left, and a | - | ||||||||||||||||||||||||||||||
| 149 | positive angle means it's rotated to the right. Most touchscreens do not | - | ||||||||||||||||||||||||||||||
| 150 | detect rotation, so zero is the most common value. | - | ||||||||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||||||||
| 152 | \sa QTouchEvent::TouchPoint::rotation() | - | ||||||||||||||||||||||||||||||
| 153 | */ | - | ||||||||||||||||||||||||||||||
| 154 | void QQuickTouchPoint::setRotation(qreal r) | - | ||||||||||||||||||||||||||||||
| 155 | { | - | ||||||||||||||||||||||||||||||
| 156 | if (_rotation == r)
| 0-486 | ||||||||||||||||||||||||||||||
| 157 | return; executed 486 times by 2 tests: return;Executed by:
| 486 | ||||||||||||||||||||||||||||||
| 158 | _rotation = r; | - | ||||||||||||||||||||||||||||||
| 159 | emit rotationChanged(); | - | ||||||||||||||||||||||||||||||
| 160 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||||||||
| 162 | void QQuickTouchPoint::setVelocity(const QVector2D &velocity) | - | ||||||||||||||||||||||||||||||
| 163 | { | - | ||||||||||||||||||||||||||||||
| 164 | if (_velocity == velocity)
| 0-486 | ||||||||||||||||||||||||||||||
| 165 | return; executed 486 times by 2 tests: return;Executed by:
| 486 | ||||||||||||||||||||||||||||||
| 166 | _velocity = velocity; | - | ||||||||||||||||||||||||||||||
| 167 | emit velocityChanged(); | - | ||||||||||||||||||||||||||||||
| 168 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||||||||
| 170 | /*! | - | ||||||||||||||||||||||||||||||
| 171 | \deprecated | - | ||||||||||||||||||||||||||||||
| 172 | \qmlproperty rectangle QtQuick::TouchPoint::area | - | ||||||||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||||||||
| 174 | A rectangle covering the area of the touch point, centered on the current | - | ||||||||||||||||||||||||||||||
| 175 | position of the touch point. | - | ||||||||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||||||||
| 177 | It is deprecated because a touch point is more correctly modeled as an ellipse, | - | ||||||||||||||||||||||||||||||
| 178 | whereas this rectangle represents the outer bounds of the ellipse after \l rotation. | - | ||||||||||||||||||||||||||||||
| 179 | */ | - | ||||||||||||||||||||||||||||||
| 180 | void QQuickTouchPoint::setArea(const QRectF &area) | - | ||||||||||||||||||||||||||||||
| 181 | { | - | ||||||||||||||||||||||||||||||
| 182 | if (_area == area)
| 166-320 | ||||||||||||||||||||||||||||||
| 183 | return; executed 166 times by 2 tests: return;Executed by:
| 166 | ||||||||||||||||||||||||||||||
| 184 | _area = area; | - | ||||||||||||||||||||||||||||||
| 185 | emit areaChanged(); | - | ||||||||||||||||||||||||||||||
| 186 | } executed 320 times by 2 tests: end of blockExecuted by:
| 320 | ||||||||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||||||||
| 188 | /*! | - | ||||||||||||||||||||||||||||||
| 189 | \qmlproperty bool QtQuick::TouchPoint::pressed | - | ||||||||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||||||||
| 191 | This property holds whether the touch point is currently pressed. | - | ||||||||||||||||||||||||||||||
| 192 | */ | - | ||||||||||||||||||||||||||||||
| 193 | void QQuickTouchPoint::setPressed(bool pressed) | - | ||||||||||||||||||||||||||||||
| 194 | { | - | ||||||||||||||||||||||||||||||
| 195 | if (_pressed == pressed)
| 0-288 | ||||||||||||||||||||||||||||||
| 196 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 197 | _pressed = pressed; | - | ||||||||||||||||||||||||||||||
| 198 | emit pressedChanged(); | - | ||||||||||||||||||||||||||||||
| 199 | } executed 288 times by 2 tests: end of blockExecuted by:
| 288 | ||||||||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||||||||
| 201 | /*! | - | ||||||||||||||||||||||||||||||
| 202 | \qmlproperty real QtQuick::TouchPoint::startX | - | ||||||||||||||||||||||||||||||
| 203 | \qmlproperty real QtQuick::TouchPoint::startY | - | ||||||||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||||||||
| 205 | These properties hold the starting position of the touch point. | - | ||||||||||||||||||||||||||||||
| 206 | */ | - | ||||||||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||||||||
| 208 | void QQuickTouchPoint::setStartX(qreal startX) | - | ||||||||||||||||||||||||||||||
| 209 | { | - | ||||||||||||||||||||||||||||||
| 210 | if (_startX == startX)
| 144-354 | ||||||||||||||||||||||||||||||
| 211 | return; executed 354 times by 2 tests: return;Executed by:
| 354 | ||||||||||||||||||||||||||||||
| 212 | _startX = startX; | - | ||||||||||||||||||||||||||||||
| 213 | emit startXChanged(); | - | ||||||||||||||||||||||||||||||
| 214 | } executed 144 times by 2 tests: end of blockExecuted by:
| 144 | ||||||||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||||||||
| 216 | void QQuickTouchPoint::setStartY(qreal startY) | - | ||||||||||||||||||||||||||||||
| 217 | { | - | ||||||||||||||||||||||||||||||
| 218 | if (_startY == startY)
| 138-360 | ||||||||||||||||||||||||||||||
| 219 | return; executed 360 times by 2 tests: return;Executed by:
| 360 | ||||||||||||||||||||||||||||||
| 220 | _startY = startY; | - | ||||||||||||||||||||||||||||||
| 221 | emit startYChanged(); | - | ||||||||||||||||||||||||||||||
| 222 | } executed 138 times by 2 tests: end of blockExecuted by:
| 138 | ||||||||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||||||||
| 224 | /*! | - | ||||||||||||||||||||||||||||||
| 225 | \qmlproperty real QtQuick::TouchPoint::previousX | - | ||||||||||||||||||||||||||||||
| 226 | \qmlproperty real QtQuick::TouchPoint::previousY | - | ||||||||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||||||||
| 228 | These properties hold the previous position of the touch point. | - | ||||||||||||||||||||||||||||||
| 229 | */ | - | ||||||||||||||||||||||||||||||
| 230 | void QQuickTouchPoint::setPreviousX(qreal previousX) | - | ||||||||||||||||||||||||||||||
| 231 | { | - | ||||||||||||||||||||||||||||||
| 232 | if (_previousX == previousX)
| 248-250 | ||||||||||||||||||||||||||||||
| 233 | return; executed 250 times by 2 tests: return;Executed by:
| 250 | ||||||||||||||||||||||||||||||
| 234 | _previousX = previousX; | - | ||||||||||||||||||||||||||||||
| 235 | emit previousXChanged(); | - | ||||||||||||||||||||||||||||||
| 236 | } executed 248 times by 2 tests: end of blockExecuted by:
| 248 | ||||||||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||||||||
| 238 | void QQuickTouchPoint::setPreviousY(qreal previousY) | - | ||||||||||||||||||||||||||||||
| 239 | { | - | ||||||||||||||||||||||||||||||
| 240 | if (_previousY == previousY)
| 220-278 | ||||||||||||||||||||||||||||||
| 241 | return; executed 278 times by 2 tests: return;Executed by:
| 278 | ||||||||||||||||||||||||||||||
| 242 | _previousY = previousY; | - | ||||||||||||||||||||||||||||||
| 243 | emit previousYChanged(); | - | ||||||||||||||||||||||||||||||
| 244 | } executed 220 times by 2 tests: end of blockExecuted by:
| 220 | ||||||||||||||||||||||||||||||
| 245 | - | |||||||||||||||||||||||||||||||
| 246 | /*! | - | ||||||||||||||||||||||||||||||
| 247 | \qmlproperty real QtQuick::TouchPoint::sceneX | - | ||||||||||||||||||||||||||||||
| 248 | \qmlproperty real QtQuick::TouchPoint::sceneY | - | ||||||||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||||||||
| 250 | These properties hold the current position of the touch point in scene coordinates. | - | ||||||||||||||||||||||||||||||
| 251 | */ | - | ||||||||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||||||||
| 253 | void QQuickTouchPoint::setSceneX(qreal sceneX) | - | ||||||||||||||||||||||||||||||
| 254 | { | - | ||||||||||||||||||||||||||||||
| 255 | if (_sceneX == sceneX)
| 214-284 | ||||||||||||||||||||||||||||||
| 256 | return; executed 214 times by 2 tests: return;Executed by:
| 214 | ||||||||||||||||||||||||||||||
| 257 | _sceneX = sceneX; | - | ||||||||||||||||||||||||||||||
| 258 | emit sceneXChanged(); | - | ||||||||||||||||||||||||||||||
| 259 | } executed 284 times by 2 tests: end of blockExecuted by:
| 284 | ||||||||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||||||||
| 261 | void QQuickTouchPoint::setSceneY(qreal sceneY) | - | ||||||||||||||||||||||||||||||
| 262 | { | - | ||||||||||||||||||||||||||||||
| 263 | if (_sceneY == sceneY)
| 244-254 | ||||||||||||||||||||||||||||||
| 264 | return; executed 244 times by 2 tests: return;Executed by:
| 244 | ||||||||||||||||||||||||||||||
| 265 | _sceneY = sceneY; | - | ||||||||||||||||||||||||||||||
| 266 | emit sceneYChanged(); | - | ||||||||||||||||||||||||||||||
| 267 | } executed 254 times by 2 tests: end of blockExecuted by:
| 254 | ||||||||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||||||||
| 269 | /*! | - | ||||||||||||||||||||||||||||||
| 270 | \qmlproperty PointingDeviceUniqueId QtQuick::TouchPoint::uniqueId | - | ||||||||||||||||||||||||||||||
| 271 | \since 5.9 | - | ||||||||||||||||||||||||||||||
| 272 | - | |||||||||||||||||||||||||||||||
| 273 | This property holds the unique ID of the touch point or token. | - | ||||||||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||||||||
| 275 | It is normally empty, because touchscreens cannot uniquely identify fingers. | - | ||||||||||||||||||||||||||||||
| 276 | But when it is set, it is expected to uniquely identify a specific token | - | ||||||||||||||||||||||||||||||
| 277 | (fiducial object). | - | ||||||||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||||||||
| 279 | Interpreting the contents of this ID requires knowledge of the hardware and | - | ||||||||||||||||||||||||||||||
| 280 | drivers in use (e.g. various TUIO-based touch surfaces). | - | ||||||||||||||||||||||||||||||
| 281 | */ | - | ||||||||||||||||||||||||||||||
| 282 | void QQuickTouchPoint::setUniqueId(const QPointingDeviceUniqueId &id) | - | ||||||||||||||||||||||||||||||
| 283 | { | - | ||||||||||||||||||||||||||||||
| 284 | _uniqueId = id; | - | ||||||||||||||||||||||||||||||
| 285 | emit uniqueIdChanged(); | - | ||||||||||||||||||||||||||||||
| 286 | } executed 486 times by 2 tests: end of blockExecuted by:
| 486 | ||||||||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||||||||
| 289 | /*! | - | ||||||||||||||||||||||||||||||
| 290 | \qmltype GestureEvent | - | ||||||||||||||||||||||||||||||
| 291 | \instantiates QQuickGrabGestureEvent | - | ||||||||||||||||||||||||||||||
| 292 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 293 | \ingroup qtquick-input-events | - | ||||||||||||||||||||||||||||||
| 294 | \brief The parameter given with the gestureStarted signal. | - | ||||||||||||||||||||||||||||||
| 295 | - | |||||||||||||||||||||||||||||||
| 296 | The GestureEvent object has the current touch points, which you may choose | - | ||||||||||||||||||||||||||||||
| 297 | to interpret as a gesture, and an invokable method to grab the involved | - | ||||||||||||||||||||||||||||||
| 298 | points exclusively. | - | ||||||||||||||||||||||||||||||
| 299 | */ | - | ||||||||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||||||||
| 301 | /*! | - | ||||||||||||||||||||||||||||||
| 302 | \qmlproperty real QtQuick::GestureEvent::dragThreshold | - | ||||||||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||||||||
| 304 | This property holds the system setting for the distance a finger must move | - | ||||||||||||||||||||||||||||||
| 305 | before it is interpreted as a drag. It comes from | - | ||||||||||||||||||||||||||||||
| 306 | QStyleHints::startDragDistance(). | - | ||||||||||||||||||||||||||||||
| 307 | */ | - | ||||||||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||||||||
| 309 | /*! | - | ||||||||||||||||||||||||||||||
| 310 | \qmlproperty list<TouchPoint> QtQuick::GestureEvent::touchPoints | - | ||||||||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||||||||
| 312 | This property holds the set of current touch points. | - | ||||||||||||||||||||||||||||||
| 313 | */ | - | ||||||||||||||||||||||||||||||
| 314 | - | |||||||||||||||||||||||||||||||
| 315 | /*! | - | ||||||||||||||||||||||||||||||
| 316 | \qmlmethod QtQuick::GestureEvent::grab() | - | ||||||||||||||||||||||||||||||
| 317 | - | |||||||||||||||||||||||||||||||
| 318 | Acquires an exclusive grab of the mouse and all the \l touchPoints, and | - | ||||||||||||||||||||||||||||||
| 319 | calls \l {QQuickItem::setKeepTouchGrab()}{setKeepTouchGrab()} and | - | ||||||||||||||||||||||||||||||
| 320 | \l {QQuickItem::setKeepMouseGrab()}{setKeepMouseGrab()} so that any | - | ||||||||||||||||||||||||||||||
| 321 | parent Item that \l {QQuickItem::filtersChildMouseEvents()}{filters} its | - | ||||||||||||||||||||||||||||||
| 322 | children's events will not be allowed to take over the grabs. | - | ||||||||||||||||||||||||||||||
| 323 | */ | - | ||||||||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||||||||
| 325 | /*! | - | ||||||||||||||||||||||||||||||
| 326 | \qmltype MultiPointTouchArea | - | ||||||||||||||||||||||||||||||
| 327 | \instantiates QQuickMultiPointTouchArea | - | ||||||||||||||||||||||||||||||
| 328 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 329 | \inherits Item | - | ||||||||||||||||||||||||||||||
| 330 | \ingroup qtquick-input | - | ||||||||||||||||||||||||||||||
| 331 | \brief Enables handling of multiple touch points. | - | ||||||||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||||||||
| 334 | A MultiPointTouchArea is an invisible item that is used to track multiple touch points. | - | ||||||||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||||||||
| 336 | The \l Item::enabled property is used to enable and disable touch handling. When disabled, | - | ||||||||||||||||||||||||||||||
| 337 | the touch area becomes transparent to mouse and touch events. | - | ||||||||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||||||||
| 339 | By default, the mouse will be handled the same way as a single touch point, | - | ||||||||||||||||||||||||||||||
| 340 | and items under the touch area will not receive mouse events because the | - | ||||||||||||||||||||||||||||||
| 341 | touch area is handling them. But if the \l mouseEnabled property is set to | - | ||||||||||||||||||||||||||||||
| 342 | false, it becomes transparent to mouse events so that another | - | ||||||||||||||||||||||||||||||
| 343 | mouse-sensitive Item (such as a MouseArea) can be used to handle mouse | - | ||||||||||||||||||||||||||||||
| 344 | interaction separately. | - | ||||||||||||||||||||||||||||||
| 345 | - | |||||||||||||||||||||||||||||||
| 346 | MultiPointTouchArea can be used in two ways: | - | ||||||||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||||||||
| 348 | \list | - | ||||||||||||||||||||||||||||||
| 349 | \li setting \c touchPoints to provide touch point objects with properties that can be bound to | - | ||||||||||||||||||||||||||||||
| 350 | \li using the onTouchUpdated or onPressed, onUpdated and onReleased handlers | - | ||||||||||||||||||||||||||||||
| 351 | \endlist | - | ||||||||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||||||||
| 353 | While a MultiPointTouchArea \e can take exclusive ownership of certain touch points, it is also possible to have | - | ||||||||||||||||||||||||||||||
| 354 | multiple MultiPointTouchAreas active at the same time, each operating on a different set of touch points. | - | ||||||||||||||||||||||||||||||
| 355 | - | |||||||||||||||||||||||||||||||
| 356 | \sa TouchPoint | - | ||||||||||||||||||||||||||||||
| 357 | */ | - | ||||||||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||||||||
| 359 | /*! | - | ||||||||||||||||||||||||||||||
| 360 | \qmlsignal QtQuick::MultiPointTouchArea::pressed(list<TouchPoint> touchPoints) | - | ||||||||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||||||||
| 362 | This signal is emitted when new touch points are added. \a touchPoints is a list of these new points. | - | ||||||||||||||||||||||||||||||
| 363 | - | |||||||||||||||||||||||||||||||
| 364 | If minimumTouchPoints is set to a value greater than one, this signal will not be emitted until the minimum number | - | ||||||||||||||||||||||||||||||
| 365 | of required touch points has been reached. | - | ||||||||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||||||||
| 367 | The corresponding handler is \c onPressed. | - | ||||||||||||||||||||||||||||||
| 368 | */ | - | ||||||||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||||||||
| 370 | /*! | - | ||||||||||||||||||||||||||||||
| 371 | \qmlsignal QtQuick::MultiPointTouchArea::updated(list<TouchPoint> touchPoints) | - | ||||||||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||||||||
| 373 | This signal is emitted when existing touch points are updated. \a touchPoints is a list of these updated points. | - | ||||||||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||||||||
| 375 | The corresponding handler is \c onUpdated. | - | ||||||||||||||||||||||||||||||
| 376 | */ | - | ||||||||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||||||||
| 378 | /*! | - | ||||||||||||||||||||||||||||||
| 379 | \qmlsignal QtQuick::MultiPointTouchArea::released(list<TouchPoint> touchPoints) | - | ||||||||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||||||||
| 381 | This signal is emitted when existing touch points are removed. \a touchPoints is a list of these removed points. | - | ||||||||||||||||||||||||||||||
| 382 | - | |||||||||||||||||||||||||||||||
| 383 | The corresponding handler is \c onReleased. | - | ||||||||||||||||||||||||||||||
| 384 | */ | - | ||||||||||||||||||||||||||||||
| 385 | - | |||||||||||||||||||||||||||||||
| 386 | /*! | - | ||||||||||||||||||||||||||||||
| 387 | \qmlsignal QtQuick::MultiPointTouchArea::canceled(list<TouchPoint> touchPoints) | - | ||||||||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||||||||
| 389 | This signal is emitted when new touch events have been canceled because another item stole the touch event handling. | - | ||||||||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||||||||
| 391 | This signal is for advanced use: it is useful when there is more than one MultiPointTouchArea | - | ||||||||||||||||||||||||||||||
| 392 | that is handling input, or when there is a MultiPointTouchArea inside a \l Flickable. In the latter | - | ||||||||||||||||||||||||||||||
| 393 | case, if you execute some logic in the \c onPressed signal handler and then start dragging, the | - | ||||||||||||||||||||||||||||||
| 394 | \l Flickable may steal the touch handling from the MultiPointTouchArea. In these cases, to reset | - | ||||||||||||||||||||||||||||||
| 395 | the logic when the MultiPointTouchArea has lost the touch handling to the \l Flickable, | - | ||||||||||||||||||||||||||||||
| 396 | \c canceled should be handled in addition to \l released. | - | ||||||||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||||||||
| 398 | \a touchPoints is the list of canceled points. | - | ||||||||||||||||||||||||||||||
| 399 | - | |||||||||||||||||||||||||||||||
| 400 | The corresponding handler is \c onCanceled. | - | ||||||||||||||||||||||||||||||
| 401 | */ | - | ||||||||||||||||||||||||||||||
| 402 | - | |||||||||||||||||||||||||||||||
| 403 | /*! | - | ||||||||||||||||||||||||||||||
| 404 | \qmlsignal QtQuick::MultiPointTouchArea::gestureStarted(GestureEvent gesture) | - | ||||||||||||||||||||||||||||||
| 405 | - | |||||||||||||||||||||||||||||||
| 406 | This signal is emitted when the global drag threshold has been reached. | - | ||||||||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||||||||
| 408 | This signal is typically used when a MultiPointTouchArea has been nested in a Flickable or another MultiPointTouchArea. | - | ||||||||||||||||||||||||||||||
| 409 | When the threshold has been reached and the signal is handled, you can determine whether or not the touch | - | ||||||||||||||||||||||||||||||
| 410 | area should grab the current touch points. By default they will not be grabbed; to grab them call \c gesture.grab(). If the | - | ||||||||||||||||||||||||||||||
| 411 | gesture is not grabbed, the nesting Flickable, for example, would also have an opportunity to grab. | - | ||||||||||||||||||||||||||||||
| 412 | - | |||||||||||||||||||||||||||||||
| 413 | The gesture object also includes information on the current set of \c touchPoints and the \c dragThreshold. | - | ||||||||||||||||||||||||||||||
| 414 | - | |||||||||||||||||||||||||||||||
| 415 | The corresponding handler is \c onGestureStarted. | - | ||||||||||||||||||||||||||||||
| 416 | */ | - | ||||||||||||||||||||||||||||||
| 417 | - | |||||||||||||||||||||||||||||||
| 418 | /*! | - | ||||||||||||||||||||||||||||||
| 419 | \qmlsignal QtQuick::MultiPointTouchArea::touchUpdated(list<TouchPoint> touchPoints) | - | ||||||||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||||||||
| 421 | This signal is emitted when the touch points handled by the MultiPointTouchArea change. This includes adding new touch points, | - | ||||||||||||||||||||||||||||||
| 422 | removing or canceling previous touch points, as well as updating current touch point data. \a touchPoints is the list of all current touch | - | ||||||||||||||||||||||||||||||
| 423 | points. | - | ||||||||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||||||||
| 425 | The corresponding handler is \c onTouchUpdated. | - | ||||||||||||||||||||||||||||||
| 426 | */ | - | ||||||||||||||||||||||||||||||
| 427 | - | |||||||||||||||||||||||||||||||
| 428 | /*! | - | ||||||||||||||||||||||||||||||
| 429 | \qmlproperty list<TouchPoint> QtQuick::MultiPointTouchArea::touchPoints | - | ||||||||||||||||||||||||||||||
| 430 | - | |||||||||||||||||||||||||||||||
| 431 | This property holds a set of user-defined touch point objects that can be bound to. | - | ||||||||||||||||||||||||||||||
| 432 | - | |||||||||||||||||||||||||||||||
| 433 | If mouseEnabled is true (the default) and the left mouse button is pressed | - | ||||||||||||||||||||||||||||||
| 434 | while the mouse is over the touch area, the current mouse position will be | - | ||||||||||||||||||||||||||||||
| 435 | one of these touch points. | - | ||||||||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||||||||
| 437 | In the following example, we have two small rectangles that follow our touch points. | - | ||||||||||||||||||||||||||||||
| 438 | - | |||||||||||||||||||||||||||||||
| 439 | \snippet qml/multipointtoucharea/multipointtoucharea.qml 0 | - | ||||||||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||||||||
| 441 | By default this property holds an empty list. | - | ||||||||||||||||||||||||||||||
| 442 | - | |||||||||||||||||||||||||||||||
| 443 | \sa TouchPoint | - | ||||||||||||||||||||||||||||||
| 444 | */ | - | ||||||||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||||||||
| 446 | QQuickMultiPointTouchArea::QQuickMultiPointTouchArea(QQuickItem *parent) | - | ||||||||||||||||||||||||||||||
| 447 | : QQuickItem(parent), | - | ||||||||||||||||||||||||||||||
| 448 | _minimumTouchPoints(0), | - | ||||||||||||||||||||||||||||||
| 449 | _maximumTouchPoints(INT_MAX), | - | ||||||||||||||||||||||||||||||
| 450 | _stealMouse(false), | - | ||||||||||||||||||||||||||||||
| 451 | _mouseEnabled(true) | - | ||||||||||||||||||||||||||||||
| 452 | { | - | ||||||||||||||||||||||||||||||
| 453 | setAcceptedMouseButtons(Qt::LeftButton); | - | ||||||||||||||||||||||||||||||
| 454 | setFiltersChildMouseEvents(true); | - | ||||||||||||||||||||||||||||||
| 455 | if (qmlVisualTouchDebugging()) {
| 0-62 | ||||||||||||||||||||||||||||||
| 456 | setFlag(QQuickItem::ItemHasContents); | - | ||||||||||||||||||||||||||||||
| 457 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 458 | setAcceptTouchEvents(true); | - | ||||||||||||||||||||||||||||||
| 459 | #ifdef Q_OS_OSX | - | ||||||||||||||||||||||||||||||
| 460 | setAcceptHoverEvents(true); // needed to enable touch events on mouse hover. | - | ||||||||||||||||||||||||||||||
| 461 | #endif | - | ||||||||||||||||||||||||||||||
| 462 | } executed 62 times by 4 tests: end of blockExecuted by:
| 62 | ||||||||||||||||||||||||||||||
| 463 | - | |||||||||||||||||||||||||||||||
| 464 | QQuickMultiPointTouchArea::~QQuickMultiPointTouchArea() | - | ||||||||||||||||||||||||||||||
| 465 | { | - | ||||||||||||||||||||||||||||||
| 466 | clearTouchLists(); | - | ||||||||||||||||||||||||||||||
| 467 | for (QObject *obj : qAsConst(_touchPoints)) { | - | ||||||||||||||||||||||||||||||
| 468 | QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj); | - | ||||||||||||||||||||||||||||||
| 469 | if (!dtp->isQmlDefined())
| 0-8 | ||||||||||||||||||||||||||||||
| 470 | delete dtp; never executed: delete dtp; | 0 | ||||||||||||||||||||||||||||||
| 471 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||||||||
| 472 | } executed 62 times by 4 tests: end of blockExecuted by:
| 62 | ||||||||||||||||||||||||||||||
| 473 | - | |||||||||||||||||||||||||||||||
| 474 | /*! | - | ||||||||||||||||||||||||||||||
| 475 | \qmlproperty int QtQuick::MultiPointTouchArea::minimumTouchPoints | - | ||||||||||||||||||||||||||||||
| 476 | \qmlproperty int QtQuick::MultiPointTouchArea::maximumTouchPoints | - | ||||||||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||||||||
| 478 | These properties hold the range of touch points to be handled by the touch area. | - | ||||||||||||||||||||||||||||||
| 479 | - | |||||||||||||||||||||||||||||||
| 480 | These are convenience that allow you to, for example, have nested MultiPointTouchAreas, | - | ||||||||||||||||||||||||||||||
| 481 | one handling two finger touches, and another handling three finger touches. | - | ||||||||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||||||||
| 483 | By default, all touch points within the touch area are handled. | - | ||||||||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||||||||
| 485 | If mouseEnabled is true, the mouse acts as a touch point, so it is also | - | ||||||||||||||||||||||||||||||
| 486 | subject to these constraints: for example if maximumTouchPoints is two, you | - | ||||||||||||||||||||||||||||||
| 487 | can use the mouse as one touch point and a finger as another touch point | - | ||||||||||||||||||||||||||||||
| 488 | for a total of two. | - | ||||||||||||||||||||||||||||||
| 489 | */ | - | ||||||||||||||||||||||||||||||
| 490 | - | |||||||||||||||||||||||||||||||
| 491 | int QQuickMultiPointTouchArea::minimumTouchPoints() const | - | ||||||||||||||||||||||||||||||
| 492 | { | - | ||||||||||||||||||||||||||||||
| 493 | return _minimumTouchPoints; executed 2 times by 1 test: return _minimumTouchPoints;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 494 | } | - | ||||||||||||||||||||||||||||||
| 495 | - | |||||||||||||||||||||||||||||||
| 496 | void QQuickMultiPointTouchArea::setMinimumTouchPoints(int num) | - | ||||||||||||||||||||||||||||||
| 497 | { | - | ||||||||||||||||||||||||||||||
| 498 | if (_minimumTouchPoints == num)
| 0-30 | ||||||||||||||||||||||||||||||
| 499 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 500 | _minimumTouchPoints = num; | - | ||||||||||||||||||||||||||||||
| 501 | emit minimumTouchPointsChanged(); | - | ||||||||||||||||||||||||||||||
| 502 | } executed 30 times by 2 tests: end of blockExecuted by:
| 30 | ||||||||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||||||||
| 504 | int QQuickMultiPointTouchArea::maximumTouchPoints() const | - | ||||||||||||||||||||||||||||||
| 505 | { | - | ||||||||||||||||||||||||||||||
| 506 | return _maximumTouchPoints; executed 2 times by 1 test: return _maximumTouchPoints;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 507 | } | - | ||||||||||||||||||||||||||||||
| 508 | - | |||||||||||||||||||||||||||||||
| 509 | void QQuickMultiPointTouchArea::setMaximumTouchPoints(int num) | - | ||||||||||||||||||||||||||||||
| 510 | { | - | ||||||||||||||||||||||||||||||
| 511 | if (_maximumTouchPoints == num)
| 0-52 | ||||||||||||||||||||||||||||||
| 512 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 513 | _maximumTouchPoints = num; | - | ||||||||||||||||||||||||||||||
| 514 | emit maximumTouchPointsChanged(); | - | ||||||||||||||||||||||||||||||
| 515 | } executed 52 times by 2 tests: end of blockExecuted by:
| 52 | ||||||||||||||||||||||||||||||
| 516 | - | |||||||||||||||||||||||||||||||
| 517 | /*! | - | ||||||||||||||||||||||||||||||
| 518 | \qmlproperty bool QtQuick::MultiPointTouchArea::mouseEnabled | - | ||||||||||||||||||||||||||||||
| 519 | - | |||||||||||||||||||||||||||||||
| 520 | This property controls whether the MultiPointTouchArea will handle mouse | - | ||||||||||||||||||||||||||||||
| 521 | events too. If it is true (the default), the touch area will treat the | - | ||||||||||||||||||||||||||||||
| 522 | mouse the same as a single touch point; if it is false, the touch area will | - | ||||||||||||||||||||||||||||||
| 523 | ignore mouse events and allow them to "pass through" so that they can be | - | ||||||||||||||||||||||||||||||
| 524 | handled by other items underneath. | - | ||||||||||||||||||||||||||||||
| 525 | */ | - | ||||||||||||||||||||||||||||||
| 526 | void QQuickMultiPointTouchArea::setMouseEnabled(bool arg) | - | ||||||||||||||||||||||||||||||
| 527 | { | - | ||||||||||||||||||||||||||||||
| 528 | if (_mouseEnabled != arg) {
| 0-4 | ||||||||||||||||||||||||||||||
| 529 | _mouseEnabled = arg; | - | ||||||||||||||||||||||||||||||
| 530 | if (_mouseTouchPoint && !arg)
| 0 | ||||||||||||||||||||||||||||||
| 531 | _mouseTouchPoint = nullptr; never executed: _mouseTouchPoint = nullptr; | 0 | ||||||||||||||||||||||||||||||
| 532 | emit mouseEnabledChanged(); | - | ||||||||||||||||||||||||||||||
| 533 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 534 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||||||||
| 536 | void QQuickMultiPointTouchArea::touchEvent(QTouchEvent *event) | - | ||||||||||||||||||||||||||||||
| 537 | { | - | ||||||||||||||||||||||||||||||
| 538 | switch (event->type()) { | - | ||||||||||||||||||||||||||||||
| 539 | case QEvent::TouchBegin: executed 66 times by 1 test: case QEvent::TouchBegin:Executed by:
| 66 | ||||||||||||||||||||||||||||||
| 540 | case QEvent::TouchUpdate: executed 106 times by 2 tests: case QEvent::TouchUpdate:Executed by:
| 106 | ||||||||||||||||||||||||||||||
| 541 | case QEvent::TouchEnd: { executed 32 times by 1 test: case QEvent::TouchEnd:Executed by:
| 32 | ||||||||||||||||||||||||||||||
| 542 | //if e.g. a parent Flickable has the mouse grab, don't process the touch events | - | ||||||||||||||||||||||||||||||
| 543 | QQuickWindow *c = window(); | - | ||||||||||||||||||||||||||||||
| 544 | QQuickItem *grabber = c ? c->mouseGrabberItem() : nullptr;
| 0-204 | ||||||||||||||||||||||||||||||
| 545 | if (grabber && grabber != this && grabber->keepMouseGrab() && grabber->isEnabled()) {
| 0-142 | ||||||||||||||||||||||||||||||
| 546 | QQuickItem *item = this; | - | ||||||||||||||||||||||||||||||
| 547 | while ((item = item->parentItem())) {
| 2-4 | ||||||||||||||||||||||||||||||
| 548 | if (item == grabber)
| 0-4 | ||||||||||||||||||||||||||||||
| 549 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 550 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 551 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 552 | updateTouchData(event); | - | ||||||||||||||||||||||||||||||
| 553 | if (event->type() == QEvent::TouchEnd)
| 32-172 | ||||||||||||||||||||||||||||||
| 554 | ungrab(); executed 32 times by 1 test: ungrab();Executed by:
| 32 | ||||||||||||||||||||||||||||||
| 555 | break; executed 204 times by 2 tests: break;Executed by:
| 204 | ||||||||||||||||||||||||||||||
| 556 | } | - | ||||||||||||||||||||||||||||||
| 557 | case QEvent::TouchCancel: never executed: case QEvent::TouchCancel: | 0 | ||||||||||||||||||||||||||||||
| 558 | ungrab(); | - | ||||||||||||||||||||||||||||||
| 559 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 560 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 561 | QQuickItem::touchEvent(event); | - | ||||||||||||||||||||||||||||||
| 562 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 563 | } | - | ||||||||||||||||||||||||||||||
| 564 | } | - | ||||||||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||||||||
| 566 | void QQuickMultiPointTouchArea::grabGesture() | - | ||||||||||||||||||||||||||||||
| 567 | { | - | ||||||||||||||||||||||||||||||
| 568 | _stealMouse = true; | - | ||||||||||||||||||||||||||||||
| 569 | - | |||||||||||||||||||||||||||||||
| 570 | grabMouse(); | - | ||||||||||||||||||||||||||||||
| 571 | setKeepMouseGrab(true); | - | ||||||||||||||||||||||||||||||
| 572 | - | |||||||||||||||||||||||||||||||
| 573 | QVector<int> ids; | - | ||||||||||||||||||||||||||||||
| 574 | ids.reserve(_touchPoints.size()); | - | ||||||||||||||||||||||||||||||
| 575 | for (auto it = _touchPoints.keyBegin(), end = _touchPoints.keyEnd(); it != end; ++it) {
| 6-16 | ||||||||||||||||||||||||||||||
| 576 | if (*it != -1) // -1 might be the mouse-point, but we already grabbed the mouse above.
| 2-14 | ||||||||||||||||||||||||||||||
| 577 | ids.append(*it); executed 14 times by 1 test: ids.append(*it);Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 578 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||||||||||||||
| 579 | grabTouchPoints(ids); | - | ||||||||||||||||||||||||||||||
| 580 | setKeepTouchGrab(true); | - | ||||||||||||||||||||||||||||||
| 581 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||
| 582 | - | |||||||||||||||||||||||||||||||
| 583 | void QQuickMultiPointTouchArea::updateTouchData(QEvent *event) | - | ||||||||||||||||||||||||||||||
| 584 | { | - | ||||||||||||||||||||||||||||||
| 585 | bool ended = false; | - | ||||||||||||||||||||||||||||||
| 586 | bool moved = false; | - | ||||||||||||||||||||||||||||||
| 587 | bool started = false; | - | ||||||||||||||||||||||||||||||
| 588 | bool isMouseEvent = false; | - | ||||||||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||||||||
| 590 | clearTouchLists(); | - | ||||||||||||||||||||||||||||||
| 591 | QList<QTouchEvent::TouchPoint> touchPoints; | - | ||||||||||||||||||||||||||||||
| 592 | - | |||||||||||||||||||||||||||||||
| 593 | switch (event->type()) { | - | ||||||||||||||||||||||||||||||
| 594 | case QEvent::TouchBegin: executed 78 times by 1 test: case QEvent::TouchBegin:Executed by:
| 78 | ||||||||||||||||||||||||||||||
| 595 | case QEvent::TouchUpdate: executed 128 times by 2 tests: case QEvent::TouchUpdate:Executed by:
| 128 | ||||||||||||||||||||||||||||||
| 596 | case QEvent::TouchEnd: executed 36 times by 1 test: case QEvent::TouchEnd:Executed by:
| 36 | ||||||||||||||||||||||||||||||
| 597 | touchPoints = static_cast<QTouchEvent*>(event)->touchPoints(); | - | ||||||||||||||||||||||||||||||
| 598 | break; executed 242 times by 2 tests: break;Executed by:
| 242 | ||||||||||||||||||||||||||||||
| 599 | case QEvent::MouseButtonPress: executed 12 times by 1 test: case QEvent::MouseButtonPress:Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 600 | case QEvent::MouseMove: executed 34 times by 1 test: case QEvent::MouseMove:Executed by:
| 34 | ||||||||||||||||||||||||||||||
| 601 | case QEvent::MouseButtonRelease: { executed 10 times by 1 test: case QEvent::MouseButtonRelease:Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 602 | QMouseEvent *me = static_cast<QMouseEvent*>(event); | - | ||||||||||||||||||||||||||||||
| 603 | _mouseQpaTouchPoint.setPos(me->localPos()); | - | ||||||||||||||||||||||||||||||
| 604 | _mouseQpaTouchPoint.setScenePos(me->windowPos()); | - | ||||||||||||||||||||||||||||||
| 605 | _mouseQpaTouchPoint.setScreenPos(me->screenPos()); | - | ||||||||||||||||||||||||||||||
| 606 | if (event->type() == QEvent::MouseMove)
| 22-34 | ||||||||||||||||||||||||||||||
| 607 | _mouseQpaTouchPoint.setState(Qt::TouchPointMoved); executed 34 times by 1 test: _mouseQpaTouchPoint.setState(Qt::TouchPointMoved);Executed by:
| 34 | ||||||||||||||||||||||||||||||
| 608 | else if (event->type() == QEvent::MouseButtonRelease)
| 10-12 | ||||||||||||||||||||||||||||||
| 609 | _mouseQpaTouchPoint.setState(Qt::TouchPointReleased); executed 10 times by 1 test: _mouseQpaTouchPoint.setState(Qt::TouchPointReleased);Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 610 | else { // QEvent::MouseButtonPress | - | ||||||||||||||||||||||||||||||
| 611 | addTouchPoint(me); | - | ||||||||||||||||||||||||||||||
| 612 | started = true; | - | ||||||||||||||||||||||||||||||
| 613 | _mouseQpaTouchPoint.setState(Qt::TouchPointPressed); | - | ||||||||||||||||||||||||||||||
| 614 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||||||||
| 615 | touchPoints << _mouseQpaTouchPoint; | - | ||||||||||||||||||||||||||||||
| 616 | isMouseEvent = true; | - | ||||||||||||||||||||||||||||||
| 617 | break; executed 56 times by 1 test: break;Executed by:
| 56 | ||||||||||||||||||||||||||||||
| 618 | } | - | ||||||||||||||||||||||||||||||
| 619 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 620 | qWarning("updateTouchData: unhandled event type %d", event->type()); | - | ||||||||||||||||||||||||||||||
| 621 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 622 | } | - | ||||||||||||||||||||||||||||||
| 623 | - | |||||||||||||||||||||||||||||||
| 624 | if (!isMouseEvent && _mouseTouchPoint) {
| 56-242 | ||||||||||||||||||||||||||||||
| 625 | QQuickWindow *c = window(); | - | ||||||||||||||||||||||||||||||
| 626 | if (c && c->mouseGrabberItem() == this)
| 0-28 | ||||||||||||||||||||||||||||||
| 627 | touchPoints << _mouseQpaTouchPoint; executed 28 times by 1 test: touchPoints << _mouseQpaTouchPoint;Executed by:
| 28 | ||||||||||||||||||||||||||||||
| 628 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||||||||||||||||||||||||||
| 629 | int numTouchPoints = touchPoints.count(); | - | ||||||||||||||||||||||||||||||
| 630 | //always remove released touches, and make sure we handle all releases before adds. | - | ||||||||||||||||||||||||||||||
| 631 | for (const QTouchEvent::TouchPoint &p : qAsConst(touchPoints)) { | - | ||||||||||||||||||||||||||||||
| 632 | Qt::TouchPointState touchPointState = p.state(); | - | ||||||||||||||||||||||||||||||
| 633 | int id = p.id(); | - | ||||||||||||||||||||||||||||||
| 634 | if (touchPointState & Qt::TouchPointReleased) {
| 96-494 | ||||||||||||||||||||||||||||||
| 635 | QQuickTouchPoint* dtp = static_cast<QQuickTouchPoint*>(_touchPoints.value(id)); | - | ||||||||||||||||||||||||||||||
| 636 | if (!dtp)
| 14-82 | ||||||||||||||||||||||||||||||
| 637 | continue; executed 14 times by 1 test: continue;Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 638 | updateTouchPoint(dtp, &p); | - | ||||||||||||||||||||||||||||||
| 639 | dtp->setPressed(false); | - | ||||||||||||||||||||||||||||||
| 640 | _releasedTouchPoints.append(dtp); | - | ||||||||||||||||||||||||||||||
| 641 | _touchPoints.remove(id); | - | ||||||||||||||||||||||||||||||
| 642 | ended = true; | - | ||||||||||||||||||||||||||||||
| 643 | } executed 82 times by 2 tests: end of blockExecuted by:
| 82 | ||||||||||||||||||||||||||||||
| 644 | } executed 576 times by 2 tests: end of blockExecuted by:
| 576 | ||||||||||||||||||||||||||||||
| 645 | if (numTouchPoints >= _minimumTouchPoints && numTouchPoints <= _maximumTouchPoints) {
| 10-250 | ||||||||||||||||||||||||||||||
| 646 | for (const QTouchEvent::TouchPoint &p : qAsConst(touchPoints)) { | - | ||||||||||||||||||||||||||||||
| 647 | Qt::TouchPointState touchPointState = p.state(); | - | ||||||||||||||||||||||||||||||
| 648 | int id = p.id(); | - | ||||||||||||||||||||||||||||||
| 649 | if (touchPointState & Qt::TouchPointReleased) {
| 84-404 | ||||||||||||||||||||||||||||||
| 650 | //handled above | - | ||||||||||||||||||||||||||||||
| 651 | } else if (!_touchPoints.contains(id)) { //could be pressed, moved, or stationary executed 84 times by 2 tests: end of blockExecuted by:
| 84-268 | ||||||||||||||||||||||||||||||
| 652 | // (we may have just obtained enough points to start tracking them -- in that case moved or stationary count as newly pressed) | - | ||||||||||||||||||||||||||||||
| 653 | addTouchPoint(&p); | - | ||||||||||||||||||||||||||||||
| 654 | started = true; | - | ||||||||||||||||||||||||||||||
| 655 | } else if (touchPointState & Qt::TouchPointMoved) { executed 136 times by 2 tests: end of blockExecuted by:
| 56-212 | ||||||||||||||||||||||||||||||
| 656 | QQuickTouchPoint* dtp = static_cast<QQuickTouchPoint*>(_touchPoints.value(id)); | - | ||||||||||||||||||||||||||||||
| 657 | Q_ASSERT(dtp); | - | ||||||||||||||||||||||||||||||
| 658 | _movedTouchPoints.append(dtp); | - | ||||||||||||||||||||||||||||||
| 659 | updateTouchPoint(dtp,&p); | - | ||||||||||||||||||||||||||||||
| 660 | moved = true; | - | ||||||||||||||||||||||||||||||
| 661 | } else { executed 212 times by 2 tests: end of blockExecuted by:
| 212 | ||||||||||||||||||||||||||||||
| 662 | QQuickTouchPoint* dtp = static_cast<QQuickTouchPoint*>(_touchPoints.value(id)); | - | ||||||||||||||||||||||||||||||
| 663 | Q_ASSERT(dtp); | - | ||||||||||||||||||||||||||||||
| 664 | updateTouchPoint(dtp,&p); | - | ||||||||||||||||||||||||||||||
| 665 | } executed 56 times by 1 test: end of blockExecuted by:
| 56 | ||||||||||||||||||||||||||||||
| 666 | } | - | ||||||||||||||||||||||||||||||
| 667 | - | |||||||||||||||||||||||||||||||
| 668 | //see if we should be grabbing the gesture | - | ||||||||||||||||||||||||||||||
| 669 | if (!_stealMouse /* !ignoring gesture*/) {
| 22-218 | ||||||||||||||||||||||||||||||
| 670 | bool offerGrab = false; | - | ||||||||||||||||||||||||||||||
| 671 | const int dragThreshold = QGuiApplication::styleHints()->startDragDistance(); | - | ||||||||||||||||||||||||||||||
| 672 | for (const QTouchEvent::TouchPoint &p : qAsConst(touchPoints)) { | - | ||||||||||||||||||||||||||||||
| 673 | if (p.state() == Qt::TouchPointReleased)
| 68-280 | ||||||||||||||||||||||||||||||
| 674 | continue; executed 68 times by 1 test: continue;Executed by:
| 68 | ||||||||||||||||||||||||||||||
| 675 | const QPointF ¤tPos = p.scenePos(); | - | ||||||||||||||||||||||||||||||
| 676 | const QPointF &startPos = p.startScenePos(); | - | ||||||||||||||||||||||||||||||
| 677 | if (qAbs(currentPos.x() - startPos.x()) > dragThreshold)
| 66-214 | ||||||||||||||||||||||||||||||
| 678 | offerGrab = true; executed 66 times by 2 tests: offerGrab = true;Executed by:
| 66 | ||||||||||||||||||||||||||||||
| 679 | else if (qAbs(currentPos.y() - startPos.y()) > dragThreshold)
| 16-198 | ||||||||||||||||||||||||||||||
| 680 | offerGrab = true; executed 16 times by 1 test: offerGrab = true;Executed by:
| 16 | ||||||||||||||||||||||||||||||
| 681 | if (offerGrab)
| 82-198 | ||||||||||||||||||||||||||||||
| 682 | break; executed 82 times by 2 tests: break;Executed by:
| 82 | ||||||||||||||||||||||||||||||
| 683 | } executed 198 times by 2 tests: end of blockExecuted by:
| 198 | ||||||||||||||||||||||||||||||
| 684 | - | |||||||||||||||||||||||||||||||
| 685 | if (offerGrab) {
| 82-136 | ||||||||||||||||||||||||||||||
| 686 | QQuickGrabGestureEvent event; | - | ||||||||||||||||||||||||||||||
| 687 | event._touchPoints = _touchPoints.values(); | - | ||||||||||||||||||||||||||||||
| 688 | emit gestureStarted(&event); | - | ||||||||||||||||||||||||||||||
| 689 | if (event.wantsGrab())
| 6-76 | ||||||||||||||||||||||||||||||
| 690 | grabGesture(); executed 6 times by 1 test: grabGesture();Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 691 | } executed 82 times by 2 tests: end of blockExecuted by:
| 82 | ||||||||||||||||||||||||||||||
| 692 | } executed 218 times by 2 tests: end of blockExecuted by:
| 218 | ||||||||||||||||||||||||||||||
| 693 | - | |||||||||||||||||||||||||||||||
| 694 | if (ended)
| 50-190 | ||||||||||||||||||||||||||||||
| 695 | emit released(_releasedTouchPoints); executed 50 times by 2 tests: released(_releasedTouchPoints);Executed by:
| 50 | ||||||||||||||||||||||||||||||
| 696 | if (moved)
| 98-142 | ||||||||||||||||||||||||||||||
| 697 | emit updated(_movedTouchPoints); executed 98 times by 2 tests: updated(_movedTouchPoints);Executed by:
| 98 | ||||||||||||||||||||||||||||||
| 698 | if (started)
| 102-138 | ||||||||||||||||||||||||||||||
| 699 | emit pressed(_pressedTouchPoints); executed 102 times by 2 tests: pressed(_pressedTouchPoints);Executed by:
| 102 | ||||||||||||||||||||||||||||||
| 700 | if (ended || moved || started) emit touchUpdated(_touchPoints.values()); executed 232 times by 2 tests: touchUpdated(_touchPoints.values());Executed by:
| 8-232 | ||||||||||||||||||||||||||||||
| 701 | } executed 240 times by 2 tests: end of blockExecuted by:
| 240 | ||||||||||||||||||||||||||||||
| 702 | } executed 298 times by 2 tests: end of blockExecuted by:
| 298 | ||||||||||||||||||||||||||||||
| 703 | - | |||||||||||||||||||||||||||||||
| 704 | void QQuickMultiPointTouchArea::clearTouchLists() | - | ||||||||||||||||||||||||||||||
| 705 | { | - | ||||||||||||||||||||||||||||||
| 706 | for (QObject *obj : qAsConst(_releasedTouchPoints)) { | - | ||||||||||||||||||||||||||||||
| 707 | QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj); | - | ||||||||||||||||||||||||||||||
| 708 | if (!dtp->isQmlDefined()) {
| 20-54 | ||||||||||||||||||||||||||||||
| 709 | _touchPoints.remove(dtp->pointId()); | - | ||||||||||||||||||||||||||||||
| 710 | delete dtp; | - | ||||||||||||||||||||||||||||||
| 711 | } else { executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||||||||
| 712 | dtp->setInUse(false); | - | ||||||||||||||||||||||||||||||
| 713 | } executed 54 times by 2 tests: end of blockExecuted by:
| 54 | ||||||||||||||||||||||||||||||
| 714 | } | - | ||||||||||||||||||||||||||||||
| 715 | _releasedTouchPoints.clear(); | - | ||||||||||||||||||||||||||||||
| 716 | _pressedTouchPoints.clear(); | - | ||||||||||||||||||||||||||||||
| 717 | _movedTouchPoints.clear(); | - | ||||||||||||||||||||||||||||||
| 718 | } executed 396 times by 4 tests: end of blockExecuted by:
| 396 | ||||||||||||||||||||||||||||||
| 719 | - | |||||||||||||||||||||||||||||||
| 720 | void QQuickMultiPointTouchArea::addTouchPoint(const QTouchEvent::TouchPoint *p) | - | ||||||||||||||||||||||||||||||
| 721 | { | - | ||||||||||||||||||||||||||||||
| 722 | QQuickTouchPoint *dtp = nullptr; | - | ||||||||||||||||||||||||||||||
| 723 | for (QQuickTouchPoint* tp : qAsConst(_touchPrototypes)) { | - | ||||||||||||||||||||||||||||||
| 724 | if (!tp->inUse()) {
| 78-90 | ||||||||||||||||||||||||||||||
| 725 | tp->setInUse(true); | - | ||||||||||||||||||||||||||||||
| 726 | dtp = tp; | - | ||||||||||||||||||||||||||||||
| 727 | break; executed 90 times by 2 tests: break;Executed by:
| 90 | ||||||||||||||||||||||||||||||
| 728 | } | - | ||||||||||||||||||||||||||||||
| 729 | } executed 78 times by 2 tests: end of blockExecuted by:
| 78 | ||||||||||||||||||||||||||||||
| 730 | - | |||||||||||||||||||||||||||||||
| 731 | if (dtp == nullptr)
| 46-90 | ||||||||||||||||||||||||||||||
| 732 | dtp = new QQuickTouchPoint(false); executed 46 times by 1 test: dtp = new QQuickTouchPoint(false);Executed by:
| 46 | ||||||||||||||||||||||||||||||
| 733 | dtp->setPointId(p->id()); | - | ||||||||||||||||||||||||||||||
| 734 | updateTouchPoint(dtp,p); | - | ||||||||||||||||||||||||||||||
| 735 | dtp->setPressed(true); | - | ||||||||||||||||||||||||||||||
| 736 | _touchPoints.insert(p->id(),dtp); | - | ||||||||||||||||||||||||||||||
| 737 | _pressedTouchPoints.append(dtp); | - | ||||||||||||||||||||||||||||||
| 738 | } executed 136 times by 2 tests: end of blockExecuted by:
| 136 | ||||||||||||||||||||||||||||||
| 739 | - | |||||||||||||||||||||||||||||||
| 740 | void QQuickMultiPointTouchArea::addTouchPoint(const QMouseEvent *e) | - | ||||||||||||||||||||||||||||||
| 741 | { | - | ||||||||||||||||||||||||||||||
| 742 | QQuickTouchPoint *dtp = nullptr; | - | ||||||||||||||||||||||||||||||
| 743 | for (QQuickTouchPoint *tp : qAsConst(_touchPrototypes)) | - | ||||||||||||||||||||||||||||||
| 744 | if (!tp->inUse()) {
| 4-8 | ||||||||||||||||||||||||||||||
| 745 | tp->setInUse(true); | - | ||||||||||||||||||||||||||||||
| 746 | dtp = tp; | - | ||||||||||||||||||||||||||||||
| 747 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 748 | } | - | ||||||||||||||||||||||||||||||
| 749 | - | |||||||||||||||||||||||||||||||
| 750 | if (dtp == nullptr)
| 4-8 | ||||||||||||||||||||||||||||||
| 751 | dtp = new QQuickTouchPoint(false); executed 4 times by 1 test: dtp = new QQuickTouchPoint(false);Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 752 | updateTouchPoint(dtp, e); | - | ||||||||||||||||||||||||||||||
| 753 | dtp->setPressed(true); | - | ||||||||||||||||||||||||||||||
| 754 | _touchPoints.insert(-1, dtp); | - | ||||||||||||||||||||||||||||||
| 755 | _pressedTouchPoints.append(dtp); | - | ||||||||||||||||||||||||||||||
| 756 | _mouseTouchPoint = dtp; | - | ||||||||||||||||||||||||||||||
| 757 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||||||||
| 758 | - | |||||||||||||||||||||||||||||||
| 759 | #ifdef Q_OS_OSX | - | ||||||||||||||||||||||||||||||
| 760 | void QQuickMultiPointTouchArea::hoverEnterEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||||||||
| 761 | { | - | ||||||||||||||||||||||||||||||
| 762 | Q_UNUSED(event); | - | ||||||||||||||||||||||||||||||
| 763 | setTouchEventsEnabled(true); | - | ||||||||||||||||||||||||||||||
| 764 | } | - | ||||||||||||||||||||||||||||||
| 765 | - | |||||||||||||||||||||||||||||||
| 766 | void QQuickMultiPointTouchArea::hoverLeaveEvent(QHoverEvent *event) | - | ||||||||||||||||||||||||||||||
| 767 | { | - | ||||||||||||||||||||||||||||||
| 768 | Q_UNUSED(event); | - | ||||||||||||||||||||||||||||||
| 769 | setTouchEventsEnabled(false); | - | ||||||||||||||||||||||||||||||
| 770 | } | - | ||||||||||||||||||||||||||||||
| 771 | - | |||||||||||||||||||||||||||||||
| 772 | void QQuickMultiPointTouchArea::setTouchEventsEnabled(bool enable) | - | ||||||||||||||||||||||||||||||
| 773 | { | - | ||||||||||||||||||||||||||||||
| 774 | // Resolve function for enabling touch events from the (cocoa) platform plugin. | - | ||||||||||||||||||||||||||||||
| 775 | typedef void (*RegisterTouchWindowFunction)(QWindow *, bool); | - | ||||||||||||||||||||||||||||||
| 776 | RegisterTouchWindowFunction registerTouchWindow = reinterpret_cast<RegisterTouchWindowFunction>( | - | ||||||||||||||||||||||||||||||
| 777 | QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow")); | - | ||||||||||||||||||||||||||||||
| 778 | if (!registerTouchWindow) | - | ||||||||||||||||||||||||||||||
| 779 | return; // Not necessarily an error, Qt might be using a different platform plugin. | - | ||||||||||||||||||||||||||||||
| 780 | - | |||||||||||||||||||||||||||||||
| 781 | registerTouchWindow(window(), enable); | - | ||||||||||||||||||||||||||||||
| 782 | } | - | ||||||||||||||||||||||||||||||
| 783 | #endif // Q_OS_OSX | - | ||||||||||||||||||||||||||||||
| 784 | - | |||||||||||||||||||||||||||||||
| 785 | void QQuickMultiPointTouchArea::addTouchPrototype(QQuickTouchPoint *prototype) | - | ||||||||||||||||||||||||||||||
| 786 | { | - | ||||||||||||||||||||||||||||||
| 787 | int id = _touchPrototypes.count(); | - | ||||||||||||||||||||||||||||||
| 788 | prototype->setPointId(id); | - | ||||||||||||||||||||||||||||||
| 789 | _touchPrototypes.insert(id, prototype); | - | ||||||||||||||||||||||||||||||
| 790 | } executed 120 times by 3 tests: end of blockExecuted by:
| 120 | ||||||||||||||||||||||||||||||
| 791 | - | |||||||||||||||||||||||||||||||
| 792 | void QQuickMultiPointTouchArea::updateTouchPoint(QQuickTouchPoint *dtp, const QTouchEvent::TouchPoint *p) | - | ||||||||||||||||||||||||||||||
| 793 | { | - | ||||||||||||||||||||||||||||||
| 794 | //TODO: if !qmlDefined, could bypass setters. | - | ||||||||||||||||||||||||||||||
| 795 | // also, should only emit signals after all values have been set | - | ||||||||||||||||||||||||||||||
| 796 | dtp->setUniqueId(p->uniqueId()); | - | ||||||||||||||||||||||||||||||
| 797 | dtp->setX(p->pos().x()); | - | ||||||||||||||||||||||||||||||
| 798 | dtp->setY(p->pos().y()); | - | ||||||||||||||||||||||||||||||
| 799 | dtp->setEllipseDiameters(p->ellipseDiameters()); | - | ||||||||||||||||||||||||||||||
| 800 | dtp->setPressure(p->pressure()); | - | ||||||||||||||||||||||||||||||
| 801 | dtp->setRotation(p->rotation()); | - | ||||||||||||||||||||||||||||||
| 802 | dtp->setVelocity(p->velocity()); | - | ||||||||||||||||||||||||||||||
| 803 | dtp->setArea(p->rect()); | - | ||||||||||||||||||||||||||||||
| 804 | dtp->setStartX(p->startPos().x()); | - | ||||||||||||||||||||||||||||||
| 805 | dtp->setStartY(p->startPos().y()); | - | ||||||||||||||||||||||||||||||
| 806 | dtp->setPreviousX(p->lastPos().x()); | - | ||||||||||||||||||||||||||||||
| 807 | dtp->setPreviousY(p->lastPos().y()); | - | ||||||||||||||||||||||||||||||
| 808 | dtp->setSceneX(p->scenePos().x()); | - | ||||||||||||||||||||||||||||||
| 809 | dtp->setSceneY(p->scenePos().y()); | - | ||||||||||||||||||||||||||||||
| 810 | } executed 486 times by 2 tests: end of blockExecuted by:
| 486 | ||||||||||||||||||||||||||||||
| 811 | - | |||||||||||||||||||||||||||||||
| 812 | void QQuickMultiPointTouchArea::updateTouchPoint(QQuickTouchPoint *dtp, const QMouseEvent *e) | - | ||||||||||||||||||||||||||||||
| 813 | { | - | ||||||||||||||||||||||||||||||
| 814 | dtp->setPreviousX(dtp->x()); | - | ||||||||||||||||||||||||||||||
| 815 | dtp->setPreviousY(dtp->y()); | - | ||||||||||||||||||||||||||||||
| 816 | dtp->setX(e->localPos().x()); | - | ||||||||||||||||||||||||||||||
| 817 | dtp->setY(e->localPos().y()); | - | ||||||||||||||||||||||||||||||
| 818 | if (e->type() == QEvent::MouseButtonPress) {
| 0-12 | ||||||||||||||||||||||||||||||
| 819 | dtp->setStartX(e->localPos().x()); | - | ||||||||||||||||||||||||||||||
| 820 | dtp->setStartY(e->localPos().y()); | - | ||||||||||||||||||||||||||||||
| 821 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||||||||
| 822 | dtp->setSceneX(e->windowPos().x()); | - | ||||||||||||||||||||||||||||||
| 823 | dtp->setSceneY(e->windowPos().y()); | - | ||||||||||||||||||||||||||||||
| 824 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||||||||
| 825 | - | |||||||||||||||||||||||||||||||
| 826 | void QQuickMultiPointTouchArea::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
| 827 | { | - | ||||||||||||||||||||||||||||||
| 828 | if (!isEnabled() || !_mouseEnabled || event->button() != Qt::LeftButton) {
| 0-44 | ||||||||||||||||||||||||||||||
| 829 | QQuickItem::mousePressEvent(event); | - | ||||||||||||||||||||||||||||||
| 830 | return; executed 4 times by 1 test: return;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 831 | } | - | ||||||||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||||||||
| 833 | _stealMouse = false; | - | ||||||||||||||||||||||||||||||
| 834 | setKeepMouseGrab(false); | - | ||||||||||||||||||||||||||||||
| 835 | event->setAccepted(true); | - | ||||||||||||||||||||||||||||||
| 836 | _mousePos = event->localPos(); | - | ||||||||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||||||||
| 838 | if (event->source() != Qt::MouseEventNotSynthesized)
| 16-24 | ||||||||||||||||||||||||||||||
| 839 | return; executed 24 times by 1 test: return;Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 840 | - | |||||||||||||||||||||||||||||||
| 841 | if (_touchPoints.count() >= _minimumTouchPoints - 1 && _touchPoints.count() < _maximumTouchPoints) {
| 0-16 | ||||||||||||||||||||||||||||||
| 842 | updateTouchData(event); | - | ||||||||||||||||||||||||||||||
| 843 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||||||||
| 844 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||||||||||||||
| 845 | - | |||||||||||||||||||||||||||||||
| 846 | void QQuickMultiPointTouchArea::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
| 847 | { | - | ||||||||||||||||||||||||||||||
| 848 | if (!isEnabled() || !_mouseEnabled) {
| 0-42 | ||||||||||||||||||||||||||||||
| 849 | QQuickItem::mouseMoveEvent(event); | - | ||||||||||||||||||||||||||||||
| 850 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 851 | } | - | ||||||||||||||||||||||||||||||
| 852 | - | |||||||||||||||||||||||||||||||
| 853 | if (event->source() != Qt::MouseEventNotSynthesized)
| 8-34 | ||||||||||||||||||||||||||||||
| 854 | return; executed 8 times by 1 test: return;Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 855 | - | |||||||||||||||||||||||||||||||
| 856 | _movedTouchPoints.clear(); | - | ||||||||||||||||||||||||||||||
| 857 | updateTouchData(event); | - | ||||||||||||||||||||||||||||||
| 858 | } executed 34 times by 1 test: end of blockExecuted by:
| 34 | ||||||||||||||||||||||||||||||
| 859 | - | |||||||||||||||||||||||||||||||
| 860 | void QQuickMultiPointTouchArea::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
| 861 | { | - | ||||||||||||||||||||||||||||||
| 862 | _stealMouse = false; | - | ||||||||||||||||||||||||||||||
| 863 | if (!isEnabled() || !_mouseEnabled) {
| 0-22 | ||||||||||||||||||||||||||||||
| 864 | QQuickItem::mouseReleaseEvent(event); | - | ||||||||||||||||||||||||||||||
| 865 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 866 | } | - | ||||||||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||||||||
| 868 | if (event->source() != Qt::MouseEventNotSynthesized)
| 6-16 | ||||||||||||||||||||||||||||||
| 869 | return; executed 6 times by 1 test: return;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 870 | - | |||||||||||||||||||||||||||||||
| 871 | if (_mouseTouchPoint) {
| 6-10 | ||||||||||||||||||||||||||||||
| 872 | updateTouchData(event); | - | ||||||||||||||||||||||||||||||
| 873 | _mouseTouchPoint->setInUse(false); | - | ||||||||||||||||||||||||||||||
| 874 | _releasedTouchPoints.removeAll(_mouseTouchPoint); | - | ||||||||||||||||||||||||||||||
| 875 | _mouseTouchPoint = nullptr; | - | ||||||||||||||||||||||||||||||
| 876 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 877 | - | |||||||||||||||||||||||||||||||
| 878 | QQuickWindow *c = window(); | - | ||||||||||||||||||||||||||||||
| 879 | if (c && c->mouseGrabberItem() == this)
| 0-16 | ||||||||||||||||||||||||||||||
| 880 | ungrabMouse(); executed 16 times by 1 test: ungrabMouse();Executed by:
| 16 | ||||||||||||||||||||||||||||||
| 881 | setKeepMouseGrab(false); | - | ||||||||||||||||||||||||||||||
| 882 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||||||||||||||
| 883 | - | |||||||||||||||||||||||||||||||
| 884 | void QQuickMultiPointTouchArea::ungrab() | - | ||||||||||||||||||||||||||||||
| 885 | { | - | ||||||||||||||||||||||||||||||
| 886 | _stealMouse = false; | - | ||||||||||||||||||||||||||||||
| 887 | setKeepMouseGrab(false); | - | ||||||||||||||||||||||||||||||
| 888 | setKeepTouchGrab(false); | - | ||||||||||||||||||||||||||||||
| 889 | ungrabTouchPoints(); | - | ||||||||||||||||||||||||||||||
| 890 | - | |||||||||||||||||||||||||||||||
| 891 | if (_touchPoints.count()) {
| 36-96 | ||||||||||||||||||||||||||||||
| 892 | for (QObject *obj : qAsConst(_touchPoints)) | - | ||||||||||||||||||||||||||||||
| 893 | static_cast<QQuickTouchPoint*>(obj)->setPressed(false); executed 58 times by 2 tests: static_cast<QQuickTouchPoint*>(obj)->setPressed(false);Executed by:
| 58 | ||||||||||||||||||||||||||||||
| 894 | emit canceled(_touchPoints.values()); | - | ||||||||||||||||||||||||||||||
| 895 | clearTouchLists(); | - | ||||||||||||||||||||||||||||||
| 896 | for (QObject *obj : qAsConst(_touchPoints)) { | - | ||||||||||||||||||||||||||||||
| 897 | QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj); | - | ||||||||||||||||||||||||||||||
| 898 | if (!dtp->isQmlDefined())
| 28-30 | ||||||||||||||||||||||||||||||
| 899 | delete dtp; executed 28 times by 1 test: delete dtp;Executed by:
| 28 | ||||||||||||||||||||||||||||||
| 900 | else | - | ||||||||||||||||||||||||||||||
| 901 | dtp->setInUse(false); executed 30 times by 2 tests: dtp->setInUse(false);Executed by:
| 30 | ||||||||||||||||||||||||||||||
| 902 | } | - | ||||||||||||||||||||||||||||||
| 903 | _touchPoints.clear(); | - | ||||||||||||||||||||||||||||||
| 904 | emit touchUpdated(QList<QObject*>()); | - | ||||||||||||||||||||||||||||||
| 905 | } executed 36 times by 2 tests: end of blockExecuted by:
| 36 | ||||||||||||||||||||||||||||||
| 906 | } executed 132 times by 2 tests: end of blockExecuted by:
| 132 | ||||||||||||||||||||||||||||||
| 907 | - | |||||||||||||||||||||||||||||||
| 908 | void QQuickMultiPointTouchArea::mouseUngrabEvent() | - | ||||||||||||||||||||||||||||||
| 909 | { | - | ||||||||||||||||||||||||||||||
| 910 | ungrab(); | - | ||||||||||||||||||||||||||||||
| 911 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||||||||
| 912 | - | |||||||||||||||||||||||||||||||
| 913 | void QQuickMultiPointTouchArea::touchUngrabEvent() | - | ||||||||||||||||||||||||||||||
| 914 | { | - | ||||||||||||||||||||||||||||||
| 915 | ungrab(); | - | ||||||||||||||||||||||||||||||
| 916 | } executed 66 times by 2 tests: end of blockExecuted by:
| 66 | ||||||||||||||||||||||||||||||
| 917 | - | |||||||||||||||||||||||||||||||
| 918 | bool QQuickMultiPointTouchArea::sendMouseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||||||||
| 919 | { | - | ||||||||||||||||||||||||||||||
| 920 | QPointF localPos = mapFromScene(event->windowPos()); | - | ||||||||||||||||||||||||||||||
| 921 | - | |||||||||||||||||||||||||||||||
| 922 | QQuickWindow *c = window(); | - | ||||||||||||||||||||||||||||||
| 923 | QQuickItem *grabber = c ? c->mouseGrabberItem() : nullptr;
| 0-42 | ||||||||||||||||||||||||||||||
| 924 | bool stealThisEvent = _stealMouse; | - | ||||||||||||||||||||||||||||||
| 925 | if ((stealThisEvent || contains(localPos)) && (!grabber || !grabber->keepMouseGrab())) {
| 0-42 | ||||||||||||||||||||||||||||||
| 926 | QMouseEvent mouseEvent(event->type(), localPos, event->windowPos(), event->screenPos(), | - | ||||||||||||||||||||||||||||||
| 927 | event->button(), event->buttons(), event->modifiers()); | - | ||||||||||||||||||||||||||||||
| 928 | mouseEvent.setAccepted(false); | - | ||||||||||||||||||||||||||||||
| 929 | QGuiApplicationPrivate::setMouseEventCapsAndVelocity(&mouseEvent, | - | ||||||||||||||||||||||||||||||
| 930 | QGuiApplicationPrivate::mouseEventCaps(event), | - | ||||||||||||||||||||||||||||||
| 931 | QGuiApplicationPrivate::mouseEventVelocity(event)); | - | ||||||||||||||||||||||||||||||
| 932 | QGuiApplicationPrivate::setMouseEventSource(&mouseEvent, Qt::MouseEventSynthesizedByQt); | - | ||||||||||||||||||||||||||||||
| 933 | - | |||||||||||||||||||||||||||||||
| 934 | switch (mouseEvent.type()) { | - | ||||||||||||||||||||||||||||||
| 935 | case QEvent::MouseMove: executed 8 times by 1 test: case QEvent::MouseMove:Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 936 | mouseMoveEvent(&mouseEvent); | - | ||||||||||||||||||||||||||||||
| 937 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 938 | case QEvent::MouseButtonPress: executed 24 times by 1 test: case QEvent::MouseButtonPress:Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 939 | mousePressEvent(&mouseEvent); | - | ||||||||||||||||||||||||||||||
| 940 | break; executed 24 times by 1 test: break;Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 941 | case QEvent::MouseButtonRelease: executed 6 times by 1 test: case QEvent::MouseButtonRelease:Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 942 | mouseReleaseEvent(&mouseEvent); | - | ||||||||||||||||||||||||||||||
| 943 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 944 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 945 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 946 | } | - | ||||||||||||||||||||||||||||||
| 947 | grabber = c ? c->mouseGrabberItem() : nullptr;
| 0-38 | ||||||||||||||||||||||||||||||
| 948 | if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this)
| 0-24 | ||||||||||||||||||||||||||||||
| 949 | grabMouse(); never executed: grabMouse(); | 0 | ||||||||||||||||||||||||||||||
| 950 | - | |||||||||||||||||||||||||||||||
| 951 | return stealThisEvent; executed 38 times by 1 test: return stealThisEvent;Executed by:
| 38 | ||||||||||||||||||||||||||||||
| 952 | } | - | ||||||||||||||||||||||||||||||
| 953 | if (event->type() == QEvent::MouseButtonRelease) {
| 2 | ||||||||||||||||||||||||||||||
| 954 | _stealMouse = false; | - | ||||||||||||||||||||||||||||||
| 955 | if (c && c->mouseGrabberItem() == this)
| 0-2 | ||||||||||||||||||||||||||||||
| 956 | ungrabMouse(); never executed: ungrabMouse(); | 0 | ||||||||||||||||||||||||||||||
| 957 | setKeepMouseGrab(false); | - | ||||||||||||||||||||||||||||||
| 958 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 959 | return false; executed 4 times by 1 test: return false;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 960 | } | - | ||||||||||||||||||||||||||||||
| 961 | - | |||||||||||||||||||||||||||||||
| 962 | bool QQuickMultiPointTouchArea::childMouseEventFilter(QQuickItem *receiver, QEvent *event) | - | ||||||||||||||||||||||||||||||
| 963 | { | - | ||||||||||||||||||||||||||||||
| 964 | if (!isEnabled() || !isVisible())
| 0-84 | ||||||||||||||||||||||||||||||
| 965 | return QQuickItem::childMouseEventFilter(receiver, event); never executed: return QQuickItem::childMouseEventFilter(receiver, event); | 0 | ||||||||||||||||||||||||||||||
| 966 | switch (event->type()) { | - | ||||||||||||||||||||||||||||||
| 967 | case QEvent::MouseButtonPress: executed 24 times by 1 test: case QEvent::MouseButtonPress:Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 968 | case QEvent::MouseMove: executed 10 times by 1 test: case QEvent::MouseMove:Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 969 | case QEvent::MouseButtonRelease: executed 8 times by 1 test: case QEvent::MouseButtonRelease:Executed by:
| 8 | ||||||||||||||||||||||||||||||
| 970 | return sendMouseEvent(static_cast<QMouseEvent *>(event)); executed 42 times by 1 test: return sendMouseEvent(static_cast<QMouseEvent *>(event));Executed by:
| 42 | ||||||||||||||||||||||||||||||
| 971 | break; dead code: break; | - | ||||||||||||||||||||||||||||||
| 972 | case QEvent::TouchBegin: executed 12 times by 1 test: case QEvent::TouchBegin:Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 973 | case QEvent::TouchUpdate: executed 24 times by 1 test: case QEvent::TouchUpdate:Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 974 | if (!shouldFilter(event))
| 2-34 | ||||||||||||||||||||||||||||||
| 975 | return false; executed 2 times by 1 test: return false;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 976 | updateTouchData(event); | - | ||||||||||||||||||||||||||||||
| 977 | return _stealMouse; executed 34 times by 1 test: return _stealMouse;Executed by:
| 34 | ||||||||||||||||||||||||||||||
| 978 | case QEvent::TouchEnd: { executed 6 times by 1 test: case QEvent::TouchEnd:Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 979 | if (!shouldFilter(event))
| 2-4 | ||||||||||||||||||||||||||||||
| 980 | return false; executed 2 times by 1 test: return false;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 981 | updateTouchData(event); | - | ||||||||||||||||||||||||||||||
| 982 | ungrab(); | - | ||||||||||||||||||||||||||||||
| 983 | } | - | ||||||||||||||||||||||||||||||
| 984 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 985 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 986 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 987 | } | - | ||||||||||||||||||||||||||||||
| 988 | return QQuickItem::childMouseEventFilter(receiver, event); executed 4 times by 1 test: return QQuickItem::childMouseEventFilter(receiver, event);Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 989 | } | - | ||||||||||||||||||||||||||||||
| 990 | - | |||||||||||||||||||||||||||||||
| 991 | bool QQuickMultiPointTouchArea::shouldFilter(QEvent *event) | - | ||||||||||||||||||||||||||||||
| 992 | { | - | ||||||||||||||||||||||||||||||
| 993 | QQuickWindow *c = window(); | - | ||||||||||||||||||||||||||||||
| 994 | QQuickItem *grabber = c ? c->mouseGrabberItem() : nullptr;
| 0-42 | ||||||||||||||||||||||||||||||
| 995 | bool disabledItem = grabber && !grabber->isEnabled();
| 0-22 | ||||||||||||||||||||||||||||||
| 996 | bool stealThisEvent = _stealMouse; | - | ||||||||||||||||||||||||||||||
| 997 | bool containsPoint = false; | - | ||||||||||||||||||||||||||||||
| 998 | if (!stealThisEvent) {
| 0-42 | ||||||||||||||||||||||||||||||
| 999 | switch (event->type()) { | - | ||||||||||||||||||||||||||||||
| 1000 | case QEvent::MouseButtonPress: never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||||||||||||||||||||
| 1001 | case QEvent::MouseMove: never executed: case QEvent::MouseMove: | 0 | ||||||||||||||||||||||||||||||
| 1002 | case QEvent::MouseButtonRelease: { never executed: case QEvent::MouseButtonRelease: | 0 | ||||||||||||||||||||||||||||||
| 1003 | QMouseEvent *me = static_cast<QMouseEvent*>(event); | - | ||||||||||||||||||||||||||||||
| 1004 | containsPoint = contains(mapFromScene(me->windowPos())); | - | ||||||||||||||||||||||||||||||
| 1005 | } | - | ||||||||||||||||||||||||||||||
| 1006 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1007 | case QEvent::TouchBegin: executed 12 times by 1 test: case QEvent::TouchBegin:Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 1008 | case QEvent::TouchUpdate: executed 24 times by 1 test: case QEvent::TouchUpdate:Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 1009 | case QEvent::TouchEnd: { executed 6 times by 1 test: case QEvent::TouchEnd:Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 1010 | QTouchEvent *te = static_cast<QTouchEvent*>(event); | - | ||||||||||||||||||||||||||||||
| 1011 | for (const QTouchEvent::TouchPoint &point : te->touchPoints()) { | - | ||||||||||||||||||||||||||||||
| 1012 | if (contains(mapFromScene(point.scenePos()))) {
| 0-42 | ||||||||||||||||||||||||||||||
| 1013 | containsPoint = true; | - | ||||||||||||||||||||||||||||||
| 1014 | break; executed 42 times by 1 test: break;Executed by:
| 42 | ||||||||||||||||||||||||||||||
| 1015 | } | - | ||||||||||||||||||||||||||||||
| 1016 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1017 | } | - | ||||||||||||||||||||||||||||||
| 1018 | break; executed 42 times by 1 test: break;Executed by:
| 42 | ||||||||||||||||||||||||||||||
| 1019 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 1020 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1021 | } | - | ||||||||||||||||||||||||||||||
| 1022 | } | - | ||||||||||||||||||||||||||||||
| 1023 | if ((stealThisEvent || containsPoint) && (!grabber || !grabber->keepMouseGrab() || disabledItem)) {
| 0-42 | ||||||||||||||||||||||||||||||
| 1024 | return true; executed 38 times by 1 test: return true;Executed by:
| 38 | ||||||||||||||||||||||||||||||
| 1025 | } | - | ||||||||||||||||||||||||||||||
| 1026 | ungrab(); | - | ||||||||||||||||||||||||||||||
| 1027 | return false; executed 4 times by 1 test: return false;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 1028 | } | - | ||||||||||||||||||||||||||||||
| 1029 | - | |||||||||||||||||||||||||||||||
| 1030 | QSGNode *QQuickMultiPointTouchArea::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) | - | ||||||||||||||||||||||||||||||
| 1031 | { | - | ||||||||||||||||||||||||||||||
| 1032 | Q_UNUSED(data); | - | ||||||||||||||||||||||||||||||
| 1033 | - | |||||||||||||||||||||||||||||||
| 1034 | if (!qmlVisualTouchDebugging())
| 0 | ||||||||||||||||||||||||||||||
| 1035 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||||||||
| 1036 | - | |||||||||||||||||||||||||||||||
| 1037 | QSGInternalRectangleNode *rectangle = static_cast<QSGInternalRectangleNode *>(oldNode); | - | ||||||||||||||||||||||||||||||
| 1038 | if (!rectangle) rectangle = QQuickItemPrivate::get(this)->sceneGraphContext()->createInternalRectangleNode(); never executed: rectangle = QQuickItemPrivate::get(this)->sceneGraphContext()->createInternalRectangleNode();
| 0 | ||||||||||||||||||||||||||||||
| 1039 | - | |||||||||||||||||||||||||||||||
| 1040 | rectangle->setRect(QRectF(0, 0, width(), height())); | - | ||||||||||||||||||||||||||||||
| 1041 | rectangle->setColor(QColor(255, 0, 0, 50)); | - | ||||||||||||||||||||||||||||||
| 1042 | rectangle->update(); | - | ||||||||||||||||||||||||||||||
| 1043 | return rectangle; never executed: return rectangle; | 0 | ||||||||||||||||||||||||||||||
| 1044 | } | - | ||||||||||||||||||||||||||||||
| 1045 | - | |||||||||||||||||||||||||||||||
| 1046 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 1047 | - | |||||||||||||||||||||||||||||||
| 1048 | #include "moc_qquickmultipointtoucharea_p.cpp" | - | ||||||||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |