| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickevents.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||||||||||||||
| 3 | ** Copyright (C) 2017 The Qt Company Ltd. | - | ||||||||||||||||||||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||||||||||||||
| 6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||||||||
| 24 | ** | - | ||||||||||||||||||||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||||||||
| 35 | ** | - | ||||||||||||||||||||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||||||||
| 37 | ** | - | ||||||||||||||||||||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||||||||
| 40 | #include "qquickevents_p_p.h" | - | ||||||||||||||||||||||||||||||
| 41 | #include <QtCore/qmap.h> | - | ||||||||||||||||||||||||||||||
| 42 | #include <QtGui/private/qguiapplication_p.h> | - | ||||||||||||||||||||||||||||||
| 43 | #include <QtGui/private/qtouchdevice_p.h> | - | ||||||||||||||||||||||||||||||
| 44 | #include <QtQuick/private/qquickitem_p.h> | - | ||||||||||||||||||||||||||||||
| 45 | #include <QtQuick/private/qquickpointerhandler_p.h> | - | ||||||||||||||||||||||||||||||
| 46 | #include <QtQuick/private/qquickwindow_p.h> | - | ||||||||||||||||||||||||||||||
| 47 | #include <private/qdebug_p.h> | - | ||||||||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||||||||
| 49 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||||||||
| 51 | Q_LOGGING_CATEGORY(lcPointerEvents, "qt.quick.pointer.events") executed 10206 times by 16 tests: return category;Executed by:
| 10206 | ||||||||||||||||||||||||||||||
| 52 | Q_LOGGING_CATEGORY(lcPointerGrab, "qt.quick.pointer.grab") executed 4438 times by 16 tests: return category;Executed by:
| 4438 | ||||||||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||||||||
| 54 | /*! | - | ||||||||||||||||||||||||||||||
| 55 | \qmltype KeyEvent | - | ||||||||||||||||||||||||||||||
| 56 | \instantiates QQuickKeyEvent | - | ||||||||||||||||||||||||||||||
| 57 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 58 | \ingroup qtquick-input-events | - | ||||||||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||||||||
| 60 | \brief Provides information about a key event. | - | ||||||||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||||||||
| 62 | For example, the following changes the Item's state property when the Enter | - | ||||||||||||||||||||||||||||||
| 63 | key is pressed: | - | ||||||||||||||||||||||||||||||
| 64 | \qml | - | ||||||||||||||||||||||||||||||
| 65 | Item { | - | ||||||||||||||||||||||||||||||
| 66 | focus: true | - | ||||||||||||||||||||||||||||||
| 67 | Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; } | - | ||||||||||||||||||||||||||||||
| 68 | } | - | ||||||||||||||||||||||||||||||
| 69 | \endqml | - | ||||||||||||||||||||||||||||||
| 70 | */ | - | ||||||||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||||||||
| 72 | /*! | - | ||||||||||||||||||||||||||||||
| 73 | \qmlproperty int QtQuick::KeyEvent::key | - | ||||||||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||||||||
| 75 | This property holds the code of the key that was pressed or released. | - | ||||||||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||||||||
| 77 | See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. These codes are | - | ||||||||||||||||||||||||||||||
| 78 | independent of the underlying window system. Note that this | - | ||||||||||||||||||||||||||||||
| 79 | function does not distinguish between capital and non-capital | - | ||||||||||||||||||||||||||||||
| 80 | letters; use the \l {KeyEvent::}{text} property for this purpose. | - | ||||||||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||||||||
| 82 | A value of either 0 or \l {Qt::Key_unknown}{Qt.Key_Unknown} means that the event is not | - | ||||||||||||||||||||||||||||||
| 83 | the result of a known key; for example, it may be the result of | - | ||||||||||||||||||||||||||||||
| 84 | a compose sequence, a keyboard macro, or due to key event | - | ||||||||||||||||||||||||||||||
| 85 | compression. | - | ||||||||||||||||||||||||||||||
| 86 | */ | - | ||||||||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||||||||
| 88 | /*! | - | ||||||||||||||||||||||||||||||
| 89 | \qmlproperty string QtQuick::KeyEvent::text | - | ||||||||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||||||||
| 91 | This property holds the Unicode text that the key generated. | - | ||||||||||||||||||||||||||||||
| 92 | The text returned can be an empty string in cases where modifier keys, | - | ||||||||||||||||||||||||||||||
| 93 | such as Shift, Control, Alt, and Meta, are being pressed or released. | - | ||||||||||||||||||||||||||||||
| 94 | In such cases \c key will contain a valid value | - | ||||||||||||||||||||||||||||||
| 95 | */ | - | ||||||||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||||||||
| 97 | /*! | - | ||||||||||||||||||||||||||||||
| 98 | \qmlproperty bool QtQuick::KeyEvent::isAutoRepeat | - | ||||||||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||||||||
| 100 | This property holds whether this event comes from an auto-repeating key. | - | ||||||||||||||||||||||||||||||
| 101 | */ | - | ||||||||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||||||||
| 103 | /*! | - | ||||||||||||||||||||||||||||||
| 104 | \qmlproperty quint32 QtQuick::KeyEvent::nativeScanCode | - | ||||||||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||||||||
| 106 | This property contains the native scan code of the key that was pressed. It is | - | ||||||||||||||||||||||||||||||
| 107 | passed through from QKeyEvent unchanged. | - | ||||||||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||||||||
| 109 | \sa QKeyEvent::nativeScanCode() | - | ||||||||||||||||||||||||||||||
| 110 | */ | - | ||||||||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||||||||
| 112 | /*! | - | ||||||||||||||||||||||||||||||
| 113 | \qmlproperty int QtQuick::KeyEvent::count | - | ||||||||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||||||||
| 115 | This property holds the number of keys involved in this event. If \l KeyEvent::text | - | ||||||||||||||||||||||||||||||
| 116 | is not empty, this is simply the length of the string. | - | ||||||||||||||||||||||||||||||
| 117 | */ | - | ||||||||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||||||||
| 119 | /*! | - | ||||||||||||||||||||||||||||||
| 120 | \qmlproperty bool QtQuick::KeyEvent::accepted | - | ||||||||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||||||||
| 122 | Setting \a accepted to true prevents the key event from being | - | ||||||||||||||||||||||||||||||
| 123 | propagated to the item's parent. | - | ||||||||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||||||||
| 125 | Generally, if the item acts on the key event then it should be accepted | - | ||||||||||||||||||||||||||||||
| 126 | so that ancestor items do not also respond to the same event. | - | ||||||||||||||||||||||||||||||
| 127 | */ | - | ||||||||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||||||||
| 129 | /*! | - | ||||||||||||||||||||||||||||||
| 130 | \qmlproperty int QtQuick::KeyEvent::modifiers | - | ||||||||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||||||||
| 132 | This property holds the keyboard modifier flags that existed immediately | - | ||||||||||||||||||||||||||||||
| 133 | before the event occurred. | - | ||||||||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||||||||
| 135 | It contains a bitwise combination of: | - | ||||||||||||||||||||||||||||||
| 136 | \list | - | ||||||||||||||||||||||||||||||
| 137 | \li \l {Qt::NoModifier} {Qt.NoModifier} - No modifier key is pressed. | - | ||||||||||||||||||||||||||||||
| 138 | \li \l {Qt::ShiftModifier} {Qt.ShiftModifier} - A Shift key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 139 | \li \l {Qt::ControlModifier} {Qt.ControlModifier} - A Ctrl key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 140 | \li \l {Qt::AltModifier} {Qt.AltModifier} - An Alt key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 141 | \li \l {Qt::MetaModifier} {Qt.MetaModifier} - A Meta key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 142 | \li \l {Qt::KeypadModifier} {Qt.KeypadModifier} - A keypad button is pressed. | - | ||||||||||||||||||||||||||||||
| 143 | \li \l {Qt::GroupSwitchModifier} {Qt.GroupSwitchModifier} - X11 only. A Mode_switch key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 144 | \endlist | - | ||||||||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||||||||
| 146 | For example, to react to a Shift key + Enter key combination: | - | ||||||||||||||||||||||||||||||
| 147 | \qml | - | ||||||||||||||||||||||||||||||
| 148 | Item { | - | ||||||||||||||||||||||||||||||
| 149 | focus: true | - | ||||||||||||||||||||||||||||||
| 150 | Keys.onPressed: { | - | ||||||||||||||||||||||||||||||
| 151 | if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier)) | - | ||||||||||||||||||||||||||||||
| 152 | doSomething(); | - | ||||||||||||||||||||||||||||||
| 153 | } | - | ||||||||||||||||||||||||||||||
| 154 | } | - | ||||||||||||||||||||||||||||||
| 155 | \endqml | - | ||||||||||||||||||||||||||||||
| 156 | */ | - | ||||||||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||||||||
| 158 | /*! | - | ||||||||||||||||||||||||||||||
| 159 | \qmlmethod bool QtQuick::KeyEvent::matches(StandardKey key) | - | ||||||||||||||||||||||||||||||
| 160 | \since 5.2 | - | ||||||||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||||||||
| 162 | Returns \c true if the key event matches the given standard \a key; otherwise returns \c false. | - | ||||||||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||||||||
| 164 | \qml | - | ||||||||||||||||||||||||||||||
| 165 | Item { | - | ||||||||||||||||||||||||||||||
| 166 | focus: true | - | ||||||||||||||||||||||||||||||
| 167 | Keys.onPressed: { | - | ||||||||||||||||||||||||||||||
| 168 | if (event.matches(StandardKey.Undo)) | - | ||||||||||||||||||||||||||||||
| 169 | myModel.undo(); | - | ||||||||||||||||||||||||||||||
| 170 | else if (event.matches(StandardKey.Redo)) | - | ||||||||||||||||||||||||||||||
| 171 | myModel.redo(); | - | ||||||||||||||||||||||||||||||
| 172 | } | - | ||||||||||||||||||||||||||||||
| 173 | } | - | ||||||||||||||||||||||||||||||
| 174 | \endqml | - | ||||||||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||||||||
| 176 | \sa QKeySequence::StandardKey | - | ||||||||||||||||||||||||||||||
| 177 | */ | - | ||||||||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||||||||
| 179 | /*! | - | ||||||||||||||||||||||||||||||
| 180 | \qmltype MouseEvent | - | ||||||||||||||||||||||||||||||
| 181 | \instantiates QQuickMouseEvent | - | ||||||||||||||||||||||||||||||
| 182 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 183 | \ingroup qtquick-input-events | - | ||||||||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||||||||
| 185 | \brief Provides information about a mouse event. | - | ||||||||||||||||||||||||||||||
| 186 | - | |||||||||||||||||||||||||||||||
| 187 | The position of the mouse can be found via the \l {Item::x} {x} and \l {Item::y} {y} properties. | - | ||||||||||||||||||||||||||||||
| 188 | The button that caused the event is available via the \l button property. | - | ||||||||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||||||||
| 190 | \sa MouseArea | - | ||||||||||||||||||||||||||||||
| 191 | */ | - | ||||||||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||||||||
| 193 | /*! | - | ||||||||||||||||||||||||||||||
| 194 | \internal | - | ||||||||||||||||||||||||||||||
| 195 | \class QQuickMouseEvent | - | ||||||||||||||||||||||||||||||
| 196 | */ | - | ||||||||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||||||||
| 198 | /*! | - | ||||||||||||||||||||||||||||||
| 199 | \qmlproperty real QtQuick::MouseEvent::x | - | ||||||||||||||||||||||||||||||
| 200 | \qmlproperty real QtQuick::MouseEvent::y | - | ||||||||||||||||||||||||||||||
| 201 | - | |||||||||||||||||||||||||||||||
| 202 | These properties hold the coordinates of the position supplied by the mouse event. | - | ||||||||||||||||||||||||||||||
| 203 | */ | - | ||||||||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||||||||
| 205 | - | |||||||||||||||||||||||||||||||
| 206 | /*! | - | ||||||||||||||||||||||||||||||
| 207 | \qmlproperty bool QtQuick::MouseEvent::accepted | - | ||||||||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||||||||
| 209 | Setting \a accepted to true prevents the mouse event from being | - | ||||||||||||||||||||||||||||||
| 210 | propagated to items below this item. | - | ||||||||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||||||||
| 212 | Generally, if the item acts on the mouse event then it should be accepted | - | ||||||||||||||||||||||||||||||
| 213 | so that items lower in the stacking order do not also respond to the same event. | - | ||||||||||||||||||||||||||||||
| 214 | */ | - | ||||||||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||||||||
| 216 | /*! | - | ||||||||||||||||||||||||||||||
| 217 | \qmlproperty enumeration QtQuick::MouseEvent::button | - | ||||||||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||||||||
| 219 | This property holds the button that caused the event. It can be one of: | - | ||||||||||||||||||||||||||||||
| 220 | \list | - | ||||||||||||||||||||||||||||||
| 221 | \li \l {Qt::LeftButton} {Qt.LeftButton} | - | ||||||||||||||||||||||||||||||
| 222 | \li \l {Qt::RightButton} {Qt.RightButton} | - | ||||||||||||||||||||||||||||||
| 223 | \li \l {Qt::MiddleButton} {Qt.MiddleButton} | - | ||||||||||||||||||||||||||||||
| 224 | \endlist | - | ||||||||||||||||||||||||||||||
| 225 | */ | - | ||||||||||||||||||||||||||||||
| 226 | - | |||||||||||||||||||||||||||||||
| 227 | /*! | - | ||||||||||||||||||||||||||||||
| 228 | \qmlproperty bool QtQuick::MouseEvent::wasHeld | - | ||||||||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||||||||
| 230 | This property is true if the mouse button has been held pressed longer | - | ||||||||||||||||||||||||||||||
| 231 | than the threshold (800ms). | - | ||||||||||||||||||||||||||||||
| 232 | */ | - | ||||||||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||||||||
| 234 | /*! | - | ||||||||||||||||||||||||||||||
| 235 | \qmlproperty int QtQuick::MouseEvent::buttons | - | ||||||||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||||||||
| 237 | This property holds the mouse buttons pressed when the event was generated. | - | ||||||||||||||||||||||||||||||
| 238 | For mouse move events, this is all buttons that are pressed down. For mouse | - | ||||||||||||||||||||||||||||||
| 239 | press and double click events this includes the button that caused the event. | - | ||||||||||||||||||||||||||||||
| 240 | For mouse release events this excludes the button that caused the event. | - | ||||||||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||||||||
| 242 | It contains a bitwise combination of: | - | ||||||||||||||||||||||||||||||
| 243 | \list | - | ||||||||||||||||||||||||||||||
| 244 | \li \l {Qt::LeftButton} {Qt.LeftButton} | - | ||||||||||||||||||||||||||||||
| 245 | \li \l {Qt::RightButton} {Qt.RightButton} | - | ||||||||||||||||||||||||||||||
| 246 | \li \l {Qt::MiddleButton} {Qt.MiddleButton} | - | ||||||||||||||||||||||||||||||
| 247 | \endlist | - | ||||||||||||||||||||||||||||||
| 248 | */ | - | ||||||||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||||||||
| 250 | /*! | - | ||||||||||||||||||||||||||||||
| 251 | \qmlproperty int QtQuick::MouseEvent::modifiers | - | ||||||||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||||||||
| 253 | This property holds the keyboard modifier flags that existed immediately | - | ||||||||||||||||||||||||||||||
| 254 | before the event occurred. | - | ||||||||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||||||||
| 256 | It contains a bitwise combination of: | - | ||||||||||||||||||||||||||||||
| 257 | \list | - | ||||||||||||||||||||||||||||||
| 258 | \li \l {Qt::NoModifier} {Qt.NoModifier} - No modifier key is pressed. | - | ||||||||||||||||||||||||||||||
| 259 | \li \l {Qt::ShiftModifier} {Qt.ShiftModifier} - A Shift key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 260 | \li \l {Qt::ControlModifier} {Qt.ControlModifier} - A Ctrl key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 261 | \li \l {Qt::AltModifier} {Qt.AltModifier} - An Alt key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 262 | \li \l {Qt::MetaModifier} {Qt.MetaModifier} - A Meta key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 263 | \li \l {Qt::KeypadModifier} {Qt.KeypadModifier} - A keypad button is pressed. | - | ||||||||||||||||||||||||||||||
| 264 | \endlist | - | ||||||||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||||||||
| 266 | For example, to react to a Shift key + Left mouse button click: | - | ||||||||||||||||||||||||||||||
| 267 | \qml | - | ||||||||||||||||||||||||||||||
| 268 | MouseArea { | - | ||||||||||||||||||||||||||||||
| 269 | onClicked: { | - | ||||||||||||||||||||||||||||||
| 270 | if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ShiftModifier)) | - | ||||||||||||||||||||||||||||||
| 271 | doSomething(); | - | ||||||||||||||||||||||||||||||
| 272 | } | - | ||||||||||||||||||||||||||||||
| 273 | } | - | ||||||||||||||||||||||||||||||
| 274 | \endqml | - | ||||||||||||||||||||||||||||||
| 275 | */ | - | ||||||||||||||||||||||||||||||
| 276 | - | |||||||||||||||||||||||||||||||
| 277 | /*! | - | ||||||||||||||||||||||||||||||
| 278 | \qmlproperty int QtQuick::MouseEvent::source | - | ||||||||||||||||||||||||||||||
| 279 | \since 5.7 | - | ||||||||||||||||||||||||||||||
| 280 | - | |||||||||||||||||||||||||||||||
| 281 | This property holds the source of the mouse event. | - | ||||||||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||||||||
| 283 | The mouse event source can be used to distinguish between genuine and | - | ||||||||||||||||||||||||||||||
| 284 | artificial mouse events. When using other pointing devices such as | - | ||||||||||||||||||||||||||||||
| 285 | touchscreens and graphics tablets, if the application does not make use of | - | ||||||||||||||||||||||||||||||
| 286 | the actual touch or tablet events, mouse events may be synthesized by the | - | ||||||||||||||||||||||||||||||
| 287 | operating system or by Qt itself. | - | ||||||||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||||||||
| 289 | The value can be one of: | - | ||||||||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||||||||
| 291 | \list | - | ||||||||||||||||||||||||||||||
| 292 | \li \l{Qt::MouseEventNotSynthesized} {Qt.MouseEventNotSynthesized} | - | ||||||||||||||||||||||||||||||
| 293 | - The most common value. On platforms where such information is | - | ||||||||||||||||||||||||||||||
| 294 | available, this value indicates that the event represents a genuine | - | ||||||||||||||||||||||||||||||
| 295 | mouse event from the system. | - | ||||||||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||||||||
| 297 | \li \l{Qt::MouseEventSynthesizedBySystem} {Qt.MouseEventSynthesizedBySystem} - Indicates that the mouse event was | - | ||||||||||||||||||||||||||||||
| 298 | synthesized from a touch or tablet event by the platform. | - | ||||||||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||||||||
| 300 | \li \l{Qt::MouseEventSynthesizedByQt} {Qt.MouseEventSynthesizedByQt} | - | ||||||||||||||||||||||||||||||
| 301 | - Indicates that the mouse event was synthesized from an unhandled | - | ||||||||||||||||||||||||||||||
| 302 | touch or tablet event by Qt. | - | ||||||||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||||||||
| 304 | \li \l{Qt::MouseEventSynthesizedByApplication} {Qt.MouseEventSynthesizedByApplication} | - | ||||||||||||||||||||||||||||||
| 305 | - Indicates that the mouse event was synthesized by the application. | - | ||||||||||||||||||||||||||||||
| 306 | This allows distinguishing application-generated mouse events from | - | ||||||||||||||||||||||||||||||
| 307 | the ones that are coming from the system or are synthesized by Qt. | - | ||||||||||||||||||||||||||||||
| 308 | \endlist | - | ||||||||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||||||||
| 310 | For example, to react only to events which come from an actual mouse: | - | ||||||||||||||||||||||||||||||
| 311 | \qml | - | ||||||||||||||||||||||||||||||
| 312 | MouseArea { | - | ||||||||||||||||||||||||||||||
| 313 | onPressed: if (mouse.source !== Qt.MouseEventNotSynthesized) { | - | ||||||||||||||||||||||||||||||
| 314 | mouse.accepted = false | - | ||||||||||||||||||||||||||||||
| 315 | } | - | ||||||||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||||||||
| 317 | onClicked: doSomething() | - | ||||||||||||||||||||||||||||||
| 318 | } | - | ||||||||||||||||||||||||||||||
| 319 | \endqml | - | ||||||||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||||||||
| 321 | If the handler for the press event rejects the event, it will be propagated | - | ||||||||||||||||||||||||||||||
| 322 | further, and then another Item underneath can handle synthesized events | - | ||||||||||||||||||||||||||||||
| 323 | from touchscreens. For example, if a Flickable is used underneath (and the | - | ||||||||||||||||||||||||||||||
| 324 | MouseArea is not a child of the Flickable), it can be useful for the | - | ||||||||||||||||||||||||||||||
| 325 | MouseArea to handle genuine mouse events in one way, while allowing touch | - | ||||||||||||||||||||||||||||||
| 326 | events to fall through to the Flickable underneath, so that the ability to | - | ||||||||||||||||||||||||||||||
| 327 | flick on a touchscreen is retained. In that case the ability to drag the | - | ||||||||||||||||||||||||||||||
| 328 | Flickable via mouse would be lost, but it does not prevent Flickable from | - | ||||||||||||||||||||||||||||||
| 329 | receiving mouse wheel events. | - | ||||||||||||||||||||||||||||||
| 330 | */ | - | ||||||||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||||||||
| 332 | /*! | - | ||||||||||||||||||||||||||||||
| 333 | \qmlproperty int QtQuick::MouseEvent::flags | - | ||||||||||||||||||||||||||||||
| 334 | \since 5.11 | - | ||||||||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||||||||
| 336 | This property holds the flags that provide additional information about the | - | ||||||||||||||||||||||||||||||
| 337 | mouse event. | - | ||||||||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||||||||
| 339 | \list | - | ||||||||||||||||||||||||||||||
| 340 | \li \l {Qt::MouseEventCreatedDoubleClick} {Qt.MouseEventCreatedDoubleClick} | - | ||||||||||||||||||||||||||||||
| 341 | - Indicates that Qt has created a double click event from this event. | - | ||||||||||||||||||||||||||||||
| 342 | This flag is set in the event originating from a button press, and not | - | ||||||||||||||||||||||||||||||
| 343 | in the resulting double click event. | - | ||||||||||||||||||||||||||||||
| 344 | \endlist | - | ||||||||||||||||||||||||||||||
| 345 | */ | - | ||||||||||||||||||||||||||||||
| 346 | - | |||||||||||||||||||||||||||||||
| 347 | /*! | - | ||||||||||||||||||||||||||||||
| 348 | \qmltype WheelEvent | - | ||||||||||||||||||||||||||||||
| 349 | \instantiates QQuickWheelEvent | - | ||||||||||||||||||||||||||||||
| 350 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 351 | \ingroup qtquick-input-events | - | ||||||||||||||||||||||||||||||
| 352 | \brief Provides information about a mouse wheel event. | - | ||||||||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||||||||
| 354 | The position of the mouse can be found via the | - | ||||||||||||||||||||||||||||||
| 355 | \l {Item::x} {x} and \l {Item::y} {y} properties. | - | ||||||||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||||||||
| 357 | \sa MouseArea | - | ||||||||||||||||||||||||||||||
| 358 | */ | - | ||||||||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||||||||
| 360 | /*! | - | ||||||||||||||||||||||||||||||
| 361 | \internal | - | ||||||||||||||||||||||||||||||
| 362 | \class QQuickWheelEvent | - | ||||||||||||||||||||||||||||||
| 363 | */ | - | ||||||||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||||||||
| 365 | /*! | - | ||||||||||||||||||||||||||||||
| 366 | \qmlproperty real QtQuick::WheelEvent::x | - | ||||||||||||||||||||||||||||||
| 367 | \qmlproperty real QtQuick::WheelEvent::y | - | ||||||||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||||||||
| 369 | These properties hold the coordinates of the position supplied by the wheel event. | - | ||||||||||||||||||||||||||||||
| 370 | */ | - | ||||||||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||||||||
| 372 | /*! | - | ||||||||||||||||||||||||||||||
| 373 | \qmlproperty bool QtQuick::WheelEvent::accepted | - | ||||||||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||||||||
| 375 | Setting \a accepted to true prevents the wheel event from being | - | ||||||||||||||||||||||||||||||
| 376 | propagated to items below this item. | - | ||||||||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||||||||
| 378 | Generally, if the item acts on the wheel event then it should be accepted | - | ||||||||||||||||||||||||||||||
| 379 | so that items lower in the stacking order do not also respond to the same event. | - | ||||||||||||||||||||||||||||||
| 380 | */ | - | ||||||||||||||||||||||||||||||
| 381 | - | |||||||||||||||||||||||||||||||
| 382 | /*! | - | ||||||||||||||||||||||||||||||
| 383 | \qmlproperty int QtQuick::WheelEvent::buttons | - | ||||||||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||||||||
| 385 | This property holds the mouse buttons pressed when the wheel event was generated. | - | ||||||||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||||||||
| 387 | It contains a bitwise combination of: | - | ||||||||||||||||||||||||||||||
| 388 | \list | - | ||||||||||||||||||||||||||||||
| 389 | \li \l {Qt::LeftButton} {Qt.LeftButton} | - | ||||||||||||||||||||||||||||||
| 390 | \li \l {Qt::RightButton} {Qt.RightButton} | - | ||||||||||||||||||||||||||||||
| 391 | \li \l {Qt::MiddleButton} {Qt.MiddleButton} | - | ||||||||||||||||||||||||||||||
| 392 | \endlist | - | ||||||||||||||||||||||||||||||
| 393 | */ | - | ||||||||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||||||||
| 395 | /*! | - | ||||||||||||||||||||||||||||||
| 396 | \qmlproperty point QtQuick::WheelEvent::angleDelta | - | ||||||||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||||||||
| 398 | This property holds the distance that the wheel is rotated in wheel degrees. | - | ||||||||||||||||||||||||||||||
| 399 | The x and y cordinate of this property holds the delta in horizontal and | - | ||||||||||||||||||||||||||||||
| 400 | vertical orientation. | - | ||||||||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||||||||
| 402 | A positive value indicates that the wheel was rotated up/right; | - | ||||||||||||||||||||||||||||||
| 403 | a negative value indicates that the wheel was rotated down/left. | - | ||||||||||||||||||||||||||||||
| 404 | - | |||||||||||||||||||||||||||||||
| 405 | Most mouse types work in steps of 15 degrees, in which case the delta value is a | - | ||||||||||||||||||||||||||||||
| 406 | multiple of 120; i.e., 120 units * 1/8 = 15 degrees. | - | ||||||||||||||||||||||||||||||
| 407 | */ | - | ||||||||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||||||||
| 409 | /*! | - | ||||||||||||||||||||||||||||||
| 410 | \qmlproperty point QtQuick::WheelEvent::pixelDelta | - | ||||||||||||||||||||||||||||||
| 411 | - | |||||||||||||||||||||||||||||||
| 412 | This property holds the delta in screen pixels and is available in platforms that | - | ||||||||||||||||||||||||||||||
| 413 | have high-resolution trackpads, such as \macos. | - | ||||||||||||||||||||||||||||||
| 414 | The x and y cordinate of this property holds the delta in horizontal and | - | ||||||||||||||||||||||||||||||
| 415 | vertical orientation. The value should be used directly to scroll content on screen. | - | ||||||||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||||||||
| 417 | For platforms without high-resolution trackpad support, pixelDelta will always be (0,0), | - | ||||||||||||||||||||||||||||||
| 418 | and angleDelta should be used instead. | - | ||||||||||||||||||||||||||||||
| 419 | */ | - | ||||||||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||||||||
| 421 | /*! | - | ||||||||||||||||||||||||||||||
| 422 | \qmlproperty int QtQuick::WheelEvent::modifiers | - | ||||||||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||||||||
| 424 | This property holds the keyboard modifier flags that existed immediately | - | ||||||||||||||||||||||||||||||
| 425 | before the event occurred. | - | ||||||||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||||||||
| 427 | It contains a bitwise combination of: | - | ||||||||||||||||||||||||||||||
| 428 | \list | - | ||||||||||||||||||||||||||||||
| 429 | \li \l {Qt::NoModifier} {Qt.NoModifier} - No modifier key is pressed. | - | ||||||||||||||||||||||||||||||
| 430 | \li \l {Qt::ShiftModifier} {Qt.ShiftModifier} - A Shift key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 431 | \li \l {Qt::ControlModifier} {Qt.ControlModifier} - A Ctrl key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 432 | \li \l {Qt::AltModifier} {Qt.AltModifier} - An Alt key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 433 | \li \l {Qt::MetaModifier} {Qt.MetaModifier} - A Meta key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 434 | \li \l {Qt::KeypadModifier} {Qt.KeypadModifier} - A keypad button is pressed. | - | ||||||||||||||||||||||||||||||
| 435 | \endlist | - | ||||||||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||||||||
| 437 | For example, to react to a Control key pressed during the wheel event: | - | ||||||||||||||||||||||||||||||
| 438 | \qml | - | ||||||||||||||||||||||||||||||
| 439 | MouseArea { | - | ||||||||||||||||||||||||||||||
| 440 | onWheel: { | - | ||||||||||||||||||||||||||||||
| 441 | if (wheel.modifiers & Qt.ControlModifier) { | - | ||||||||||||||||||||||||||||||
| 442 | adjustZoom(wheel.angleDelta.y / 120); | - | ||||||||||||||||||||||||||||||
| 443 | } | - | ||||||||||||||||||||||||||||||
| 444 | } | - | ||||||||||||||||||||||||||||||
| 445 | } | - | ||||||||||||||||||||||||||||||
| 446 | \endqml | - | ||||||||||||||||||||||||||||||
| 447 | */ | - | ||||||||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||||||||
| 449 | /*! | - | ||||||||||||||||||||||||||||||
| 450 | \qmlproperty int QtQuick::WheelEvent::inverted | - | ||||||||||||||||||||||||||||||
| 451 | - | |||||||||||||||||||||||||||||||
| 452 | Returns whether the delta values delivered with the event are inverted. | - | ||||||||||||||||||||||||||||||
| 453 | - | |||||||||||||||||||||||||||||||
| 454 | Normally, a vertical wheel will produce a WheelEvent with positive delta | - | ||||||||||||||||||||||||||||||
| 455 | values if the top of the wheel is rotating away from the hand operating it. | - | ||||||||||||||||||||||||||||||
| 456 | Similarly, a horizontal wheel movement will produce a QWheelEvent with | - | ||||||||||||||||||||||||||||||
| 457 | positive delta values if the top of the wheel is moved to the left. | - | ||||||||||||||||||||||||||||||
| 458 | - | |||||||||||||||||||||||||||||||
| 459 | However, on some platforms this is configurable, so that the same | - | ||||||||||||||||||||||||||||||
| 460 | operations described above will produce negative delta values (but with the | - | ||||||||||||||||||||||||||||||
| 461 | same magnitude). For instance, in a QML component (such as a tumbler or a | - | ||||||||||||||||||||||||||||||
| 462 | slider) where it is appropriate to synchronize the movement or rotation of | - | ||||||||||||||||||||||||||||||
| 463 | an item with the direction of the wheel, regardless of the system settings, | - | ||||||||||||||||||||||||||||||
| 464 | the wheel event handler can use the inverted property to decide whether to | - | ||||||||||||||||||||||||||||||
| 465 | negate the angleDelta or pixelDelta values. | - | ||||||||||||||||||||||||||||||
| 466 | - | |||||||||||||||||||||||||||||||
| 467 | \note Many platforms provide no such information. On such platforms | - | ||||||||||||||||||||||||||||||
| 468 | \l inverted always returns false. | - | ||||||||||||||||||||||||||||||
| 469 | */ | - | ||||||||||||||||||||||||||||||
| 470 | - | |||||||||||||||||||||||||||||||
| 471 | /*! | - | ||||||||||||||||||||||||||||||
| 472 | \qmltype PointerDevice | - | ||||||||||||||||||||||||||||||
| 473 | \instantiates QQuickPointerDevice | - | ||||||||||||||||||||||||||||||
| 474 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 475 | \ingroup qtquick-input-events | - | ||||||||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||||||||
| 477 | \brief Provides information about a pointing device. | - | ||||||||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||||||||
| 479 | A pointing device can be a mouse, a touchscreen, or a stylus on a graphics | - | ||||||||||||||||||||||||||||||
| 480 | tablet. | - | ||||||||||||||||||||||||||||||
| 481 | - | |||||||||||||||||||||||||||||||
| 482 | \sa PointerEvent, PointerHandler | - | ||||||||||||||||||||||||||||||
| 483 | */ | - | ||||||||||||||||||||||||||||||
| 484 | - | |||||||||||||||||||||||||||||||
| 485 | /*! | - | ||||||||||||||||||||||||||||||
| 486 | \readonly | - | ||||||||||||||||||||||||||||||
| 487 | \qmlproperty enumeration QtQuick::PointerDevice::type | - | ||||||||||||||||||||||||||||||
| 488 | - | |||||||||||||||||||||||||||||||
| 489 | This property holds the type of the pointing device. | - | ||||||||||||||||||||||||||||||
| 490 | - | |||||||||||||||||||||||||||||||
| 491 | Valid values are: | - | ||||||||||||||||||||||||||||||
| 492 | - | |||||||||||||||||||||||||||||||
| 493 | \value DeviceType.UnknownDevice | - | ||||||||||||||||||||||||||||||
| 494 | the device cannot be identified | - | ||||||||||||||||||||||||||||||
| 495 | \value DeviceType.Mouse | - | ||||||||||||||||||||||||||||||
| 496 | a mouse | - | ||||||||||||||||||||||||||||||
| 497 | \value DeviceType.TouchScreen | - | ||||||||||||||||||||||||||||||
| 498 | a touchscreen providing absolute coordinates | - | ||||||||||||||||||||||||||||||
| 499 | \value DeviceType.TouchPad | - | ||||||||||||||||||||||||||||||
| 500 | a trackpad or touchpad providing relative coordinates | - | ||||||||||||||||||||||||||||||
| 501 | \value DeviceType.Stylus | - | ||||||||||||||||||||||||||||||
| 502 | a pen-like device | - | ||||||||||||||||||||||||||||||
| 503 | \value DeviceType.Airbrush | - | ||||||||||||||||||||||||||||||
| 504 | a stylus with a thumbwheel to adjust | - | ||||||||||||||||||||||||||||||
| 505 | \l {QTabletEvent::tangentialPressure}{tangentialPressure} | - | ||||||||||||||||||||||||||||||
| 506 | \value DeviceType.Puck | - | ||||||||||||||||||||||||||||||
| 507 | a device that is similar to a flat mouse with a | - | ||||||||||||||||||||||||||||||
| 508 | transparent circle with cross-hairs | - | ||||||||||||||||||||||||||||||
| 509 | (same as \l {QTabletEvent::Puck} {Puck}) | - | ||||||||||||||||||||||||||||||
| 510 | \value DeviceType.AllDevices | - | ||||||||||||||||||||||||||||||
| 511 | any of the above; used as a default value for construction | - | ||||||||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||||||||
| 513 | \sa QTouchDevice::DeviceType | - | ||||||||||||||||||||||||||||||
| 514 | */ | - | ||||||||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||||||||
| 516 | /*! | - | ||||||||||||||||||||||||||||||
| 517 | \readonly | - | ||||||||||||||||||||||||||||||
| 518 | \qmlproperty enumeration QtQuick::PointerDevice::pointerType | - | ||||||||||||||||||||||||||||||
| 519 | - | |||||||||||||||||||||||||||||||
| 520 | This property holds a value indicating what is interacting with | - | ||||||||||||||||||||||||||||||
| 521 | the device. Think of the device as having a planar 2D surface, and | - | ||||||||||||||||||||||||||||||
| 522 | the value of this property as identifying what interacts with the | - | ||||||||||||||||||||||||||||||
| 523 | device. | - | ||||||||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||||||||
| 525 | There is some redundancy between this property and \l {PointerDevice::type}. | - | ||||||||||||||||||||||||||||||
| 526 | If a tocuchscreen is used, then the device is TouchScreen and | - | ||||||||||||||||||||||||||||||
| 527 | pointerType is Finger (always). | - | ||||||||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||||||||
| 529 | Valid values are: | - | ||||||||||||||||||||||||||||||
| 530 | - | |||||||||||||||||||||||||||||||
| 531 | \value PointerDevice.GenericPointer | - | ||||||||||||||||||||||||||||||
| 532 | a mouse or something acting like a mouse (the core pointer on X11) | - | ||||||||||||||||||||||||||||||
| 533 | \value PointerDevice.Finger | - | ||||||||||||||||||||||||||||||
| 534 | the user's finger | - | ||||||||||||||||||||||||||||||
| 535 | \value PointerDevice.Pen | - | ||||||||||||||||||||||||||||||
| 536 | the drawing end of a stylus | - | ||||||||||||||||||||||||||||||
| 537 | \value PointerDevice.Eraser | - | ||||||||||||||||||||||||||||||
| 538 | the other end of the stylus (if it has a virtual eraser on the other end) | - | ||||||||||||||||||||||||||||||
| 539 | \value PointerDevice.Cursor | - | ||||||||||||||||||||||||||||||
| 540 | a cursor in the pre-computer sense of the word | - | ||||||||||||||||||||||||||||||
| 541 | \value PointerDevice.AllPointerTypes | - | ||||||||||||||||||||||||||||||
| 542 | any of the above (used as a default value in constructors) | - | ||||||||||||||||||||||||||||||
| 543 | */ | - | ||||||||||||||||||||||||||||||
| 544 | - | |||||||||||||||||||||||||||||||
| 545 | - | |||||||||||||||||||||||||||||||
| 546 | /*! | - | ||||||||||||||||||||||||||||||
| 547 | \readonly | - | ||||||||||||||||||||||||||||||
| 548 | \qmlproperty enumeration QtQuick::PointerDevice::capabilities | - | ||||||||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||||||||
| 550 | This property holds a bitwise combination of the capabilities of the | - | ||||||||||||||||||||||||||||||
| 551 | pointing device. It tells you under which conditions events are sent, | - | ||||||||||||||||||||||||||||||
| 552 | and which properties of PointerEvent are expected to be valid. | - | ||||||||||||||||||||||||||||||
| 553 | - | |||||||||||||||||||||||||||||||
| 554 | Valid values are: | - | ||||||||||||||||||||||||||||||
| 555 | - | |||||||||||||||||||||||||||||||
| 556 | \value CapabilityFlag.Position | - | ||||||||||||||||||||||||||||||
| 557 | the \l {QtQuick::EventPoint::position}{position} and | - | ||||||||||||||||||||||||||||||
| 558 | \l {QtQuick::EventPoint::scenePosition}{scenePosition} properties | - | ||||||||||||||||||||||||||||||
| 559 | \value CapabilityFlag.Area | - | ||||||||||||||||||||||||||||||
| 560 | the \l {QtQuick::EventTouchPoint::ellipseDiameters}{ellipseDiameters} property | - | ||||||||||||||||||||||||||||||
| 561 | \value CapabilityFlag.Pressure | - | ||||||||||||||||||||||||||||||
| 562 | the \l {QtQuick::EventTouchPoint::pressure}{pressure} property | - | ||||||||||||||||||||||||||||||
| 563 | \value CapabilityFlag.Velocity | - | ||||||||||||||||||||||||||||||
| 564 | the \l {QtQuick::EventPoint::velocity}{velocity} property | - | ||||||||||||||||||||||||||||||
| 565 | \value CapabilityFlag.Scroll | - | ||||||||||||||||||||||||||||||
| 566 | a \l {QtQuick::PointerDevice::type}{Mouse} has a wheel, or the | - | ||||||||||||||||||||||||||||||
| 567 | operating system recognizes scroll gestures on a | - | ||||||||||||||||||||||||||||||
| 568 | \l {QtQuick::PointerDevice::type}{TouchPad} | - | ||||||||||||||||||||||||||||||
| 569 | \value CapabilityFlag.Hover | - | ||||||||||||||||||||||||||||||
| 570 | events are sent even when no button is pressed, or the finger or stylus | - | ||||||||||||||||||||||||||||||
| 571 | is not in contact with the surface | - | ||||||||||||||||||||||||||||||
| 572 | \value CapabilityFlag.Rotation | - | ||||||||||||||||||||||||||||||
| 573 | the \l {QtQuick::EventTouchPoint::rotation}{rotation} property | - | ||||||||||||||||||||||||||||||
| 574 | \value CapabilityFlag.XTilt | - | ||||||||||||||||||||||||||||||
| 575 | horizontal angle between a stylus and the axis perpendicular to the surface | - | ||||||||||||||||||||||||||||||
| 576 | \value CapabilityFlag.YTilt | - | ||||||||||||||||||||||||||||||
| 577 | vertical angle between a stylus and the axis perpendicular to the surface | - | ||||||||||||||||||||||||||||||
| 578 | - | |||||||||||||||||||||||||||||||
| 579 | \sa QTouchDevice::capabilities | - | ||||||||||||||||||||||||||||||
| 580 | */ | - | ||||||||||||||||||||||||||||||
| 581 | - | |||||||||||||||||||||||||||||||
| 582 | typedef QHash<const QTouchDevice *, QQuickPointerDevice *> PointerDeviceForTouchDeviceHash; | - | ||||||||||||||||||||||||||||||
| 583 | Q_GLOBAL_STATIC(PointerDeviceForTouchDeviceHash, g_touchDevices) executed 192 times by 89 tests: end of blockExecuted by:
executed 192 times by 89 tests: guard.store(QtGlobalStatic::Destroyed);Executed by:
executed 419479 times by 89 tests: return &holder.value;Executed by:
| 0-419479 | ||||||||||||||||||||||||||||||
| 584 | - | |||||||||||||||||||||||||||||||
| 585 | struct ConstructableQQuickPointerDevice : public QQuickPointerDevice | - | ||||||||||||||||||||||||||||||
| 586 | { | - | ||||||||||||||||||||||||||||||
| 587 | ConstructableQQuickPointerDevice(DeviceType devType, PointerType pType, Capabilities caps, | - | ||||||||||||||||||||||||||||||
| 588 | int maxPoints, int buttonCount, const QString &name, | - | ||||||||||||||||||||||||||||||
| 589 | qint64 uniqueId = 0) | - | ||||||||||||||||||||||||||||||
| 590 | : QQuickPointerDevice(devType, pType, caps, maxPoints, buttonCount, name, uniqueId) {} executed 194 times by 90 tests: end of blockExecuted by:
| 194 | ||||||||||||||||||||||||||||||
| 591 | - | |||||||||||||||||||||||||||||||
| 592 | }; | - | ||||||||||||||||||||||||||||||
| 593 | Q_GLOBAL_STATIC_WITH_ARGS(ConstructableQQuickPointerDevice, g_genericMouseDevice, executed 194 times by 90 tests: end of blockExecuted by:
executed 194 times by 90 tests: guard.store(QtGlobalStatic::Destroyed);Executed by:
executed 504071 times by 90 tests: return &holder.value;Executed by:
| 0-504071 | ||||||||||||||||||||||||||||||
| 594 | (QQuickPointerDevice::Mouse, | - | ||||||||||||||||||||||||||||||
| 595 | QQuickPointerDevice::GenericPointer, | - | ||||||||||||||||||||||||||||||
| 596 | QQuickPointerDevice::Position | QQuickPointerDevice::Scroll | QQuickPointerDevice::Hover, | - | ||||||||||||||||||||||||||||||
| 597 | 1, 3, QLatin1String("core pointer"), 0)) | - | ||||||||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||||||||
| 599 | typedef QHash<qint64, QQuickPointerDevice *> PointerDeviceForDeviceIdHash; | - | ||||||||||||||||||||||||||||||
| 600 | Q_GLOBAL_STATIC(PointerDeviceForDeviceIdHash, g_tabletDevices) never executed: end of blocknever executed: guard.store(QtGlobalStatic::Destroyed);never executed: return &holder.value;
| 0 | ||||||||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||||||||
| 602 | // debugging helpers | - | ||||||||||||||||||||||||||||||
| 603 | static const char *pointStateString(const QQuickEventPoint *point) | - | ||||||||||||||||||||||||||||||
| 604 | { | - | ||||||||||||||||||||||||||||||
| 605 | static const QMetaEnum stateMetaEnum = point->metaObject()->enumerator(point->metaObject()->indexOfEnumerator("State")); | - | ||||||||||||||||||||||||||||||
| 606 | return stateMetaEnum.valueToKey(point->state()); never executed: return stateMetaEnum.valueToKey(point->state()); | 0 | ||||||||||||||||||||||||||||||
| 607 | } | - | ||||||||||||||||||||||||||||||
| 608 | - | |||||||||||||||||||||||||||||||
| 609 | static const QString pointDeviceName(const QQuickEventPoint *point) | - | ||||||||||||||||||||||||||||||
| 610 | { | - | ||||||||||||||||||||||||||||||
| 611 | auto device = static_cast<const QQuickPointerEvent *>(point->parent())->device(); | - | ||||||||||||||||||||||||||||||
| 612 | QString deviceName = (device ? device->name() : QLatin1String("null device"));
| 0 | ||||||||||||||||||||||||||||||
| 613 | deviceName.resize(16, ' '); // shorten, and align in case of sequential output | - | ||||||||||||||||||||||||||||||
| 614 | return deviceName; never executed: return deviceName; | 0 | ||||||||||||||||||||||||||||||
| 615 | } | - | ||||||||||||||||||||||||||||||
| 616 | - | |||||||||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||||||||
| 618 | QQuickPointerDevice *QQuickPointerDevice::touchDevice(const QTouchDevice *d) | - | ||||||||||||||||||||||||||||||
| 619 | { | - | ||||||||||||||||||||||||||||||
| 620 | if (g_touchDevices->contains(d))
| 20-2432 | ||||||||||||||||||||||||||||||
| 621 | return g_touchDevices->value(d); executed 2432 times by 10 tests: return g_touchDevices->value(d);Executed by:
| 2432 | ||||||||||||||||||||||||||||||
| 622 | - | |||||||||||||||||||||||||||||||
| 623 | QQuickPointerDevice::DeviceType type = QQuickPointerDevice::TouchScreen; | - | ||||||||||||||||||||||||||||||
| 624 | QString name; | - | ||||||||||||||||||||||||||||||
| 625 | int maximumTouchPoints = 10; | - | ||||||||||||||||||||||||||||||
| 626 | QQuickPointerDevice::Capabilities caps = QQuickPointerDevice::Capabilities(QTouchDevice::Position); | - | ||||||||||||||||||||||||||||||
| 627 | if (d) {
| 0-20 | ||||||||||||||||||||||||||||||
| 628 | caps = static_cast<QQuickPointerDevice::Capabilities>(static_cast<int>(d->capabilities()) & 0xFF); | - | ||||||||||||||||||||||||||||||
| 629 | if (d->type() == QTouchDevice::TouchPad) {
| 0-20 | ||||||||||||||||||||||||||||||
| 630 | type = QQuickPointerDevice::TouchPad; | - | ||||||||||||||||||||||||||||||
| 631 | caps |= QQuickPointerDevice::Scroll; | - | ||||||||||||||||||||||||||||||
| 632 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 633 | name = d->name(); | - | ||||||||||||||||||||||||||||||
| 634 | maximumTouchPoints = d->maximumTouchPoints(); | - | ||||||||||||||||||||||||||||||
| 635 | } else { executed 20 times by 10 tests: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||||||||
| 636 | qWarning() << "QQuickWindowPrivate::touchDevice: creating touch device from nullptr device in QTouchEvent"; | - | ||||||||||||||||||||||||||||||
| 637 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 638 | - | |||||||||||||||||||||||||||||||
| 639 | QQuickPointerDevice *dev = new QQuickPointerDevice(type, QQuickPointerDevice::Finger, | - | ||||||||||||||||||||||||||||||
| 640 | caps, maximumTouchPoints, 0, name, 0); | - | ||||||||||||||||||||||||||||||
| 641 | g_touchDevices->insert(d, dev); | - | ||||||||||||||||||||||||||||||
| 642 | return dev; executed 20 times by 10 tests: return dev;Executed by:
| 20 | ||||||||||||||||||||||||||||||
| 643 | } | - | ||||||||||||||||||||||||||||||
| 644 | - | |||||||||||||||||||||||||||||||
| 645 | const QTouchDevice *QQuickPointerDevice::qTouchDevice() const | - | ||||||||||||||||||||||||||||||
| 646 | { | - | ||||||||||||||||||||||||||||||
| 647 | return g_touchDevices->key(const_cast<QQuickPointerDevice *>(this)); never executed: return g_touchDevices->key(const_cast<QQuickPointerDevice *>(this)); | 0 | ||||||||||||||||||||||||||||||
| 648 | } | - | ||||||||||||||||||||||||||||||
| 649 | - | |||||||||||||||||||||||||||||||
| 650 | QList<QQuickPointerDevice*> QQuickPointerDevice::touchDevices() | - | ||||||||||||||||||||||||||||||
| 651 | { | - | ||||||||||||||||||||||||||||||
| 652 | return g_touchDevices->values(); executed 414575 times by 89 tests: return g_touchDevices->values();Executed by:
| 414575 | ||||||||||||||||||||||||||||||
| 653 | } | - | ||||||||||||||||||||||||||||||
| 654 | - | |||||||||||||||||||||||||||||||
| 655 | QQuickPointerDevice *QQuickPointerDevice::genericMouseDevice() | - | ||||||||||||||||||||||||||||||
| 656 | { | - | ||||||||||||||||||||||||||||||
| 657 | return g_genericMouseDevice; executed 504071 times by 90 tests: return g_genericMouseDevice;Executed by:
| 504071 | ||||||||||||||||||||||||||||||
| 658 | } | - | ||||||||||||||||||||||||||||||
| 659 | - | |||||||||||||||||||||||||||||||
| 660 | QQuickPointerDevice *QQuickPointerDevice::tabletDevice(qint64 id) | - | ||||||||||||||||||||||||||||||
| 661 | { | - | ||||||||||||||||||||||||||||||
| 662 | auto it = g_tabletDevices->find(id); | - | ||||||||||||||||||||||||||||||
| 663 | if (it != g_tabletDevices->end())
| 0 | ||||||||||||||||||||||||||||||
| 664 | return it.value(); never executed: return it.value(); | 0 | ||||||||||||||||||||||||||||||
| 665 | - | |||||||||||||||||||||||||||||||
| 666 | // ### Figure out how to populate the tablet devices | - | ||||||||||||||||||||||||||||||
| 667 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||||||||
| 668 | } | - | ||||||||||||||||||||||||||||||
| 669 | - | |||||||||||||||||||||||||||||||
| 670 | /*! | - | ||||||||||||||||||||||||||||||
| 671 | \qmltype EventPoint | - | ||||||||||||||||||||||||||||||
| 672 | \qmlabstract | - | ||||||||||||||||||||||||||||||
| 673 | \instantiates QQuickEventPoint | - | ||||||||||||||||||||||||||||||
| 674 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 675 | \ingroup qtquick-input-events | - | ||||||||||||||||||||||||||||||
| 676 | \brief Provides information about an individual point within a PointerEvent. | - | ||||||||||||||||||||||||||||||
| 677 | - | |||||||||||||||||||||||||||||||
| 678 | A PointerEvent contains an EventPoint for each point of contact: one corresponding | - | ||||||||||||||||||||||||||||||
| 679 | to the mouse cursor, or one for each finger touching a touchscreen. | - | ||||||||||||||||||||||||||||||
| 680 | - | |||||||||||||||||||||||||||||||
| 681 | \sa PointerEvent, PointerHandler | - | ||||||||||||||||||||||||||||||
| 682 | */ | - | ||||||||||||||||||||||||||||||
| 683 | - | |||||||||||||||||||||||||||||||
| 684 | /*! | - | ||||||||||||||||||||||||||||||
| 685 | \readonly | - | ||||||||||||||||||||||||||||||
| 686 | \qmlproperty point QtQuick::EventPoint::position | - | ||||||||||||||||||||||||||||||
| 687 | - | |||||||||||||||||||||||||||||||
| 688 | This property holds the coordinates of the position supplied by the event, | - | ||||||||||||||||||||||||||||||
| 689 | relative to the upper-left corner of the Item which has the PointerHandler. | - | ||||||||||||||||||||||||||||||
| 690 | If a contact patch is available from the pointing device, this point | - | ||||||||||||||||||||||||||||||
| 691 | represents its centroid. | - | ||||||||||||||||||||||||||||||
| 692 | */ | - | ||||||||||||||||||||||||||||||
| 693 | - | |||||||||||||||||||||||||||||||
| 694 | /*! | - | ||||||||||||||||||||||||||||||
| 695 | \readonly | - | ||||||||||||||||||||||||||||||
| 696 | \qmlproperty point QtQuick::EventPoint::scenePosition | - | ||||||||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||||||||
| 698 | This property holds the coordinates of the position supplied by the event, | - | ||||||||||||||||||||||||||||||
| 699 | relative to the scene. If a contact patch is available from the | - | ||||||||||||||||||||||||||||||
| 700 | \l {QtQuick::PointerEvent::device} {device}, this point represents its centroid. | - | ||||||||||||||||||||||||||||||
| 701 | */ | - | ||||||||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||||||||
| 703 | /*! | - | ||||||||||||||||||||||||||||||
| 704 | \readonly | - | ||||||||||||||||||||||||||||||
| 705 | \qmlproperty point QtQuick::EventPoint::scenePressPosition | - | ||||||||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||||||||
| 707 | This property holds the scene-relative position at which the press event | - | ||||||||||||||||||||||||||||||
| 708 | (on a touch device) or most recent change in QQuickPointerEvent::buttons() | - | ||||||||||||||||||||||||||||||
| 709 | (on a mouse or tablet stylus) occurred. | - | ||||||||||||||||||||||||||||||
| 710 | */ | - | ||||||||||||||||||||||||||||||
| 711 | - | |||||||||||||||||||||||||||||||
| 712 | /*! | - | ||||||||||||||||||||||||||||||
| 713 | \readonly | - | ||||||||||||||||||||||||||||||
| 714 | \qmlproperty point QtQuick::EventPoint::sceneGrabPosition | - | ||||||||||||||||||||||||||||||
| 715 | - | |||||||||||||||||||||||||||||||
| 716 | This property holds the scene-relative position at which the EventPoint was | - | ||||||||||||||||||||||||||||||
| 717 | located when setGrabber() was called most recently. | - | ||||||||||||||||||||||||||||||
| 718 | */ | - | ||||||||||||||||||||||||||||||
| 719 | - | |||||||||||||||||||||||||||||||
| 720 | /*! | - | ||||||||||||||||||||||||||||||
| 721 | \readonly | - | ||||||||||||||||||||||||||||||
| 722 | \qmlproperty vector2d QtQuick::EventPoint::velocity | - | ||||||||||||||||||||||||||||||
| 723 | - | |||||||||||||||||||||||||||||||
| 724 | This property holds average recent velocity: how fast and in which | - | ||||||||||||||||||||||||||||||
| 725 | direction the event point has been moving recently. | - | ||||||||||||||||||||||||||||||
| 726 | */ | - | ||||||||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||||||||
| 728 | /*! | - | ||||||||||||||||||||||||||||||
| 729 | \readonly | - | ||||||||||||||||||||||||||||||
| 730 | \qmlproperty int QtQuick::EventPoint::state | - | ||||||||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||||||||
| 732 | This property tells what the user is currently doing at this point. | - | ||||||||||||||||||||||||||||||
| 733 | - | |||||||||||||||||||||||||||||||
| 734 | It can be one of: | - | ||||||||||||||||||||||||||||||
| 735 | \value Pressed | - | ||||||||||||||||||||||||||||||
| 736 | The user's finger is now pressing a touchscreen, button or stylus | - | ||||||||||||||||||||||||||||||
| 737 | which was not pressed already | - | ||||||||||||||||||||||||||||||
| 738 | \value Updated | - | ||||||||||||||||||||||||||||||
| 739 | The touchpoint or position is being moved, with no change in pressed state | - | ||||||||||||||||||||||||||||||
| 740 | \value Stationary | - | ||||||||||||||||||||||||||||||
| 741 | The touchpoint or position is not being moved, and there is also | - | ||||||||||||||||||||||||||||||
| 742 | no change in pressed state | - | ||||||||||||||||||||||||||||||
| 743 | \value Released | - | ||||||||||||||||||||||||||||||
| 744 | The user's finger has now released a touch point, button or stylus | - | ||||||||||||||||||||||||||||||
| 745 | which was pressed | - | ||||||||||||||||||||||||||||||
| 746 | */ | - | ||||||||||||||||||||||||||||||
| 747 | - | |||||||||||||||||||||||||||||||
| 748 | /*! | - | ||||||||||||||||||||||||||||||
| 749 | \readonly | - | ||||||||||||||||||||||||||||||
| 750 | \qmlproperty int QtQuick::EventPoint::pointId | - | ||||||||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||||||||
| 752 | This property holds the ID of the event, if any. | - | ||||||||||||||||||||||||||||||
| 753 | - | |||||||||||||||||||||||||||||||
| 754 | Touchpoints have automatically-incrementing IDs: each time the user | - | ||||||||||||||||||||||||||||||
| 755 | presses a finger against the touchscreen, it will be a larger number. | - | ||||||||||||||||||||||||||||||
| 756 | In other cases, it will be -1. | - | ||||||||||||||||||||||||||||||
| 757 | - | |||||||||||||||||||||||||||||||
| 758 | \sa {QtQuick::EventTouchPoint::uniqueId}{uniqueId} | - | ||||||||||||||||||||||||||||||
| 759 | */ | - | ||||||||||||||||||||||||||||||
| 760 | - | |||||||||||||||||||||||||||||||
| 761 | /*! | - | ||||||||||||||||||||||||||||||
| 762 | \readonly | - | ||||||||||||||||||||||||||||||
| 763 | \qmlproperty bool QtQuick::EventPoint::accepted | - | ||||||||||||||||||||||||||||||
| 764 | - | |||||||||||||||||||||||||||||||
| 765 | Setting \a accepted to true prevents the event from being propagated to | - | ||||||||||||||||||||||||||||||
| 766 | Items below the PointerHandler's Item. | - | ||||||||||||||||||||||||||||||
| 767 | - | |||||||||||||||||||||||||||||||
| 768 | Generally, if the handler acts on the mouse event, then it should be | - | ||||||||||||||||||||||||||||||
| 769 | accepted so that items lower in the stacking order do not also respond to | - | ||||||||||||||||||||||||||||||
| 770 | the same event. | - | ||||||||||||||||||||||||||||||
| 771 | */ | - | ||||||||||||||||||||||||||||||
| 772 | - | |||||||||||||||||||||||||||||||
| 773 | /*! | - | ||||||||||||||||||||||||||||||
| 774 | \readonly | - | ||||||||||||||||||||||||||||||
| 775 | \qmlproperty real QtQuick::EventPoint::timeHeld | - | ||||||||||||||||||||||||||||||
| 776 | - | |||||||||||||||||||||||||||||||
| 777 | This property holds the amount of time in seconds that the button or touchpoint has | - | ||||||||||||||||||||||||||||||
| 778 | been held. It can be used to detect a "long press", and can drive an | - | ||||||||||||||||||||||||||||||
| 779 | animation to show progress toward activation of the "long press" action. | - | ||||||||||||||||||||||||||||||
| 780 | */ | - | ||||||||||||||||||||||||||||||
| 781 | - | |||||||||||||||||||||||||||||||
| 782 | void QQuickEventPoint::reset(Qt::TouchPointState state, const QPointF &scenePos, int pointId, ulong timestamp, const QVector2D &velocity) | - | ||||||||||||||||||||||||||||||
| 783 | { | - | ||||||||||||||||||||||||||||||
| 784 | m_scenePos = scenePos; | - | ||||||||||||||||||||||||||||||
| 785 | m_pointId = pointId; | - | ||||||||||||||||||||||||||||||
| 786 | m_accept = false; | - | ||||||||||||||||||||||||||||||
| 787 | m_state = static_cast<QQuickEventPoint::State>(state); | - | ||||||||||||||||||||||||||||||
| 788 | m_timestamp = timestamp; | - | ||||||||||||||||||||||||||||||
| 789 | if (state == Qt::TouchPointPressed) {
| 2288-9804 | ||||||||||||||||||||||||||||||
| 790 | m_pressTimestamp = timestamp; | - | ||||||||||||||||||||||||||||||
| 791 | m_scenePressPos = scenePos; | - | ||||||||||||||||||||||||||||||
| 792 | } executed 2288 times by 16 tests: end of blockExecuted by:
| 2288 | ||||||||||||||||||||||||||||||
| 793 | m_velocity = (Q_LIKELY(velocity.isNull()) ? estimatedVelocity() : velocity);
| 0-12092 | ||||||||||||||||||||||||||||||
| 794 | } executed 12092 times by 18 tests: end of blockExecuted by:
| 12092 | ||||||||||||||||||||||||||||||
| 795 | - | |||||||||||||||||||||||||||||||
| 796 | void QQuickEventPoint::localizePosition(QQuickItem *target) | - | ||||||||||||||||||||||||||||||
| 797 | { | - | ||||||||||||||||||||||||||||||
| 798 | if (target)
| 0-14048 | ||||||||||||||||||||||||||||||
| 799 | m_pos = target->mapFromScene(scenePosition()); executed 14048 times by 16 tests: m_pos = target->mapFromScene(scenePosition());Executed by:
| 14048 | ||||||||||||||||||||||||||||||
| 800 | else | - | ||||||||||||||||||||||||||||||
| 801 | m_pos = QPointF(); never executed: m_pos = QPointF(); | 0 | ||||||||||||||||||||||||||||||
| 802 | } | - | ||||||||||||||||||||||||||||||
| 803 | - | |||||||||||||||||||||||||||||||
| 804 | /*! | - | ||||||||||||||||||||||||||||||
| 805 | If this point has an exclusive grabber, returns a pointer to it; else | - | ||||||||||||||||||||||||||||||
| 806 | returns null, if there is no grabber. The grabber could be either | - | ||||||||||||||||||||||||||||||
| 807 | an Item or a PointerHandler. | - | ||||||||||||||||||||||||||||||
| 808 | */ | - | ||||||||||||||||||||||||||||||
| 809 | QObject *QQuickEventPoint::exclusiveGrabber() const | - | ||||||||||||||||||||||||||||||
| 810 | { | - | ||||||||||||||||||||||||||||||
| 811 | return m_exclusiveGrabber.data(); executed 43931 times by 18 tests: return m_exclusiveGrabber.data();Executed by:
| 43931 | ||||||||||||||||||||||||||||||
| 812 | } | - | ||||||||||||||||||||||||||||||
| 813 | - | |||||||||||||||||||||||||||||||
| 814 | /*! | - | ||||||||||||||||||||||||||||||
| 815 | Set the given Item or PointerHandler as the exclusive grabber of this point. | - | ||||||||||||||||||||||||||||||
| 816 | If there was already an exclusive grab, it will be canceled. If there | - | ||||||||||||||||||||||||||||||
| 817 | were passive grabbers, they will continue to lurk, but the exclusive grab | - | ||||||||||||||||||||||||||||||
| 818 | is a behavioral override of the passive grab as long as it remains. | - | ||||||||||||||||||||||||||||||
| 819 | If you already know whether the grabber is to be an Item or a PointerHandler, | - | ||||||||||||||||||||||||||||||
| 820 | you should instead call setGrabberItem() or setGrabberPointerHandler(), | - | ||||||||||||||||||||||||||||||
| 821 | because it is slightly more efficient. | - | ||||||||||||||||||||||||||||||
| 822 | */ | - | ||||||||||||||||||||||||||||||
| 823 | void QQuickEventPoint::setExclusiveGrabber(QObject *grabber) | - | ||||||||||||||||||||||||||||||
| 824 | { | - | ||||||||||||||||||||||||||||||
| 825 | if (QQuickPointerHandler *phGrabber = qmlobject_cast<QQuickPointerHandler *>(grabber))
| 0-2 | ||||||||||||||||||||||||||||||
| 826 | setGrabberPointerHandler(phGrabber, true); never executed: setGrabberPointerHandler(phGrabber, true); | 0 | ||||||||||||||||||||||||||||||
| 827 | else | - | ||||||||||||||||||||||||||||||
| 828 | setGrabberItem(static_cast<QQuickItem *>(grabber)); executed 2 times by 1 test: setGrabberItem(static_cast<QQuickItem *>(grabber));Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 829 | } | - | ||||||||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||||||||
| 831 | /*! | - | ||||||||||||||||||||||||||||||
| 832 | If the exclusive grabber of this point is an Item, returns a | - | ||||||||||||||||||||||||||||||
| 833 | pointer to that Item; else returns null, if there is no grabber or if | - | ||||||||||||||||||||||||||||||
| 834 | the grabber is a PointerHandler. | - | ||||||||||||||||||||||||||||||
| 835 | */ | - | ||||||||||||||||||||||||||||||
| 836 | QQuickItem *QQuickEventPoint::grabberItem() const | - | ||||||||||||||||||||||||||||||
| 837 | { | - | ||||||||||||||||||||||||||||||
| 838 | return (m_grabberIsHandler ? nullptr : static_cast<QQuickItem *>(m_exclusiveGrabber.data())); executed 57262 times by 18 tests: return (m_grabberIsHandler ? nullptr : static_cast<QQuickItem *>(m_exclusiveGrabber.data()));Executed by:
| 57262 | ||||||||||||||||||||||||||||||
| 839 | } | - | ||||||||||||||||||||||||||||||
| 840 | - | |||||||||||||||||||||||||||||||
| 841 | /*! | - | ||||||||||||||||||||||||||||||
| 842 | Set the given Item \a grabber as the exclusive grabber of this point. | - | ||||||||||||||||||||||||||||||
| 843 | If there was already an exclusive grab, it will be canceled. If there | - | ||||||||||||||||||||||||||||||
| 844 | were passive grabbers, they will continue to lurk, but the exclusive grab | - | ||||||||||||||||||||||||||||||
| 845 | is a behavioral override of the passive grab as long as it remains. | - | ||||||||||||||||||||||||||||||
| 846 | */ | - | ||||||||||||||||||||||||||||||
| 847 | void QQuickEventPoint::setGrabberItem(QQuickItem *grabber) | - | ||||||||||||||||||||||||||||||
| 848 | { | - | ||||||||||||||||||||||||||||||
| 849 | if (grabber != m_exclusiveGrabber.data()) {
| 2680-3924 | ||||||||||||||||||||||||||||||
| 850 | QQuickPointerHandler *oldGrabberHandler = grabberPointerHandler(); | - | ||||||||||||||||||||||||||||||
| 851 | if (oldGrabberHandler && !oldGrabberHandler->approveGrabTransition(this, grabber))
| 0-3912 | ||||||||||||||||||||||||||||||
| 852 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 853 | if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) {
| 0-3924 | ||||||||||||||||||||||||||||||
| 854 | qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) never executed: QMessageLogger(__FILE__, 854, __PRETTY_FUNCTION__, lcPointerGrab().categoryName()).debug() << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab" << m_exclusiveGrabber << "->" << grabber;
| 0 | ||||||||||||||||||||||||||||||
| 855 | << ": grab" << m_exclusiveGrabber << "->" << grabber; never executed: QMessageLogger(__FILE__, 854, __PRETTY_FUNCTION__, lcPointerGrab().categoryName()).debug() << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab" << m_exclusiveGrabber << "->" << grabber; | 0 | ||||||||||||||||||||||||||||||
| 856 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 857 | QQuickItem *oldGrabberItem = grabberItem(); | - | ||||||||||||||||||||||||||||||
| 858 | m_exclusiveGrabber = QPointer<QObject>(grabber); | - | ||||||||||||||||||||||||||||||
| 859 | m_grabberIsHandler = false; | - | ||||||||||||||||||||||||||||||
| 860 | m_sceneGrabPos = m_scenePos; | - | ||||||||||||||||||||||||||||||
| 861 | if (oldGrabberHandler) {
| 12-3912 | ||||||||||||||||||||||||||||||
| 862 | oldGrabberHandler->onGrabChanged(oldGrabberHandler, (grabber ? CancelGrabExclusive : UngrabExclusive), this); | - | ||||||||||||||||||||||||||||||
| 863 | } else if (oldGrabberItem && oldGrabberItem != grabber && grabber && grabber->window()) { executed 12 times by 3 tests: end of blockExecuted by:
| 0-2016 | ||||||||||||||||||||||||||||||
| 864 | QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(grabber->window()); | - | ||||||||||||||||||||||||||||||
| 865 | windowPriv->sendUngrabEvent(oldGrabberItem, windowPriv->isDeliveringTouchAsMouse()); | - | ||||||||||||||||||||||||||||||
| 866 | } executed 120 times by 6 tests: end of blockExecuted by:
| 120 | ||||||||||||||||||||||||||||||
| 867 | for (QPointer<QQuickPointerHandler> passiveGrabber : m_passiveGrabbers) | - | ||||||||||||||||||||||||||||||
| 868 | passiveGrabber->onGrabChanged(passiveGrabber, OverrideGrabPassive, this); executed 56 times by 3 tests: passiveGrabber->onGrabChanged(passiveGrabber, OverrideGrabPassive, this);Executed by:
| 56 | ||||||||||||||||||||||||||||||
| 869 | } executed 3924 times by 15 tests: end of blockExecuted by:
| 3924 | ||||||||||||||||||||||||||||||
| 870 | } executed 6604 times by 16 tests: end of blockExecuted by:
| 6604 | ||||||||||||||||||||||||||||||
| 871 | - | |||||||||||||||||||||||||||||||
| 872 | /*! | - | ||||||||||||||||||||||||||||||
| 873 | If the exclusive grabber of this point is a PointerHandler, returns a | - | ||||||||||||||||||||||||||||||
| 874 | pointer to that handler; else returns null, if there is no grabber or if | - | ||||||||||||||||||||||||||||||
| 875 | the grabber is an Item. | - | ||||||||||||||||||||||||||||||
| 876 | */ | - | ||||||||||||||||||||||||||||||
| 877 | QQuickPointerHandler *QQuickEventPoint::grabberPointerHandler() const | - | ||||||||||||||||||||||||||||||
| 878 | { | - | ||||||||||||||||||||||||||||||
| 879 | return (m_grabberIsHandler ? static_cast<QQuickPointerHandler *>(m_exclusiveGrabber.data()) : nullptr); executed 8941 times by 16 tests: return (m_grabberIsHandler ? static_cast<QQuickPointerHandler *>(m_exclusiveGrabber.data()) : nullptr);Executed by:
| 8941 | ||||||||||||||||||||||||||||||
| 880 | } | - | ||||||||||||||||||||||||||||||
| 881 | - | |||||||||||||||||||||||||||||||
| 882 | /*! | - | ||||||||||||||||||||||||||||||
| 883 | Set the given PointerHandler \a grabber as grabber of this point. If \a | - | ||||||||||||||||||||||||||||||
| 884 | exclusive is true, it will override any other grabs; if false, \a grabber | - | ||||||||||||||||||||||||||||||
| 885 | will be added to the list of passive grabbers of this point. | - | ||||||||||||||||||||||||||||||
| 886 | */ | - | ||||||||||||||||||||||||||||||
| 887 | void QQuickEventPoint::setGrabberPointerHandler(QQuickPointerHandler *grabber, bool exclusive) | - | ||||||||||||||||||||||||||||||
| 888 | { | - | ||||||||||||||||||||||||||||||
| 889 | if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) {
| 0-472 | ||||||||||||||||||||||||||||||
| 890 | if (exclusive) {
| 0 | ||||||||||||||||||||||||||||||
| 891 | if (m_exclusiveGrabber != grabber)
| 0 | ||||||||||||||||||||||||||||||
| 892 | qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) never executed: QMessageLogger(__FILE__, 892, __PRETTY_FUNCTION__, lcPointerGrab().categoryName()).debug() << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab (exclusive)" << m_exclusiveGrabber << "->" << grabber;
| 0 | ||||||||||||||||||||||||||||||
| 893 | << ": grab (exclusive)" << m_exclusiveGrabber << "->" << grabber; never executed: QMessageLogger(__FILE__, 892, __PRETTY_FUNCTION__, lcPointerGrab().categoryName()).debug() << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab (exclusive)" << m_exclusiveGrabber << "->" << grabber; | 0 | ||||||||||||||||||||||||||||||
| 894 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 895 | qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) never executed: QMessageLogger(__FILE__, 895, __PRETTY_FUNCTION__, lcPointerGrab().categoryName()).debug() << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab (passive)" << grabber;
| 0 | ||||||||||||||||||||||||||||||
| 896 | << ": grab (passive)" << grabber; never executed: QMessageLogger(__FILE__, 895, __PRETTY_FUNCTION__, lcPointerGrab().categoryName()).debug() << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab (passive)" << grabber; | 0 | ||||||||||||||||||||||||||||||
| 897 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 898 | } | - | ||||||||||||||||||||||||||||||
| 899 | if (exclusive) {
| 182-290 | ||||||||||||||||||||||||||||||
| 900 | if (grabber != m_exclusiveGrabber.data()) {
| 26-264 | ||||||||||||||||||||||||||||||
| 901 | QQuickPointerHandler *oldGrabberHandler = grabberPointerHandler(); | - | ||||||||||||||||||||||||||||||
| 902 | QQuickItem *oldGrabberItem = grabberItem(); | - | ||||||||||||||||||||||||||||||
| 903 | m_exclusiveGrabber = QPointer<QObject>(grabber); | - | ||||||||||||||||||||||||||||||
| 904 | m_grabberIsHandler = true; | - | ||||||||||||||||||||||||||||||
| 905 | m_sceneGrabPos = m_scenePos; | - | ||||||||||||||||||||||||||||||
| 906 | if (grabber) {
| 120-144 | ||||||||||||||||||||||||||||||
| 907 | grabber->onGrabChanged(grabber, GrabExclusive, this); | - | ||||||||||||||||||||||||||||||
| 908 | for (QPointer<QQuickPointerHandler> passiveGrabber : m_passiveGrabbers) { | - | ||||||||||||||||||||||||||||||
| 909 | if (!passiveGrabber.isNull() && passiveGrabber != grabber)
| 0-102 | ||||||||||||||||||||||||||||||
| 910 | passiveGrabber->onGrabChanged(grabber, OverrideGrabPassive, this); executed 24 times by 3 tests: passiveGrabber->onGrabChanged(grabber, OverrideGrabPassive, this);Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 911 | } executed 102 times by 3 tests: end of blockExecuted by:
| 102 | ||||||||||||||||||||||||||||||
| 912 | } executed 144 times by 5 tests: end of blockExecuted by:
| 144 | ||||||||||||||||||||||||||||||
| 913 | if (oldGrabberHandler)
| 120-144 | ||||||||||||||||||||||||||||||
| 914 | oldGrabberHandler->onGrabChanged(oldGrabberHandler, (grabber ? CancelGrabExclusive : UngrabExclusive), this); executed 120 times by 5 tests: oldGrabberHandler->onGrabChanged(oldGrabberHandler, (grabber ? CancelGrabExclusive : UngrabExclusive), this);Executed by:
| 120 | ||||||||||||||||||||||||||||||
| 915 | else if (oldGrabberItem && pointerEvent()->asPointerTouchEvent())
| 0-140 | ||||||||||||||||||||||||||||||
| 916 | oldGrabberItem->touchUngrabEvent(); executed 4 times by 1 test: oldGrabberItem->touchUngrabEvent();Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 917 | // touchUngrabEvent() can result in the grabber being set to null (MPTA does that, for example). | - | ||||||||||||||||||||||||||||||
| 918 | // So set it again to ensure that final state is what we want. | - | ||||||||||||||||||||||||||||||
| 919 | m_exclusiveGrabber = QPointer<QObject>(grabber); | - | ||||||||||||||||||||||||||||||
| 920 | m_grabberIsHandler = true; | - | ||||||||||||||||||||||||||||||
| 921 | m_sceneGrabPos = m_scenePos; | - | ||||||||||||||||||||||||||||||
| 922 | } executed 264 times by 5 tests: end of blockExecuted by:
| 264 | ||||||||||||||||||||||||||||||
| 923 | } else { executed 290 times by 5 tests: end of blockExecuted by:
| 290 | ||||||||||||||||||||||||||||||
| 924 | if (!grabber) {
| 0-182 | ||||||||||||||||||||||||||||||
| 925 | qDebug() << "can't set passive grabber to null"; | - | ||||||||||||||||||||||||||||||
| 926 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 927 | } | - | ||||||||||||||||||||||||||||||
| 928 | auto ptr = QPointer<QQuickPointerHandler>(grabber); | - | ||||||||||||||||||||||||||||||
| 929 | if (!m_passiveGrabbers.contains(ptr)) {
| 0-182 | ||||||||||||||||||||||||||||||
| 930 | m_passiveGrabbers.append(ptr); | - | ||||||||||||||||||||||||||||||
| 931 | grabber->onGrabChanged(grabber, GrabPassive, this); | - | ||||||||||||||||||||||||||||||
| 932 | } executed 182 times by 4 tests: end of blockExecuted by:
| 182 | ||||||||||||||||||||||||||||||
| 933 | } executed 182 times by 4 tests: end of blockExecuted by:
| 182 | ||||||||||||||||||||||||||||||
| 934 | } | - | ||||||||||||||||||||||||||||||
| 935 | - | |||||||||||||||||||||||||||||||
| 936 | /*! | - | ||||||||||||||||||||||||||||||
| 937 | If this point has an existing exclusive grabber (Item or PointerHandler), | - | ||||||||||||||||||||||||||||||
| 938 | inform the grabber that its grab is canceled, and remove it as grabber. | - | ||||||||||||||||||||||||||||||
| 939 | This normally happens when the grab is stolen by another Item. | - | ||||||||||||||||||||||||||||||
| 940 | */ | - | ||||||||||||||||||||||||||||||
| 941 | void QQuickEventPoint::cancelExclusiveGrab() | - | ||||||||||||||||||||||||||||||
| 942 | { | - | ||||||||||||||||||||||||||||||
| 943 | if (m_exclusiveGrabber.isNull())
| 0-12 | ||||||||||||||||||||||||||||||
| 944 | qWarning("cancelGrab: no grabber"); never executed: QMessageLogger(__FILE__, 944, __PRETTY_FUNCTION__).warning("cancelGrab: no grabber"); | 0 | ||||||||||||||||||||||||||||||
| 945 | else | - | ||||||||||||||||||||||||||||||
| 946 | cancelExclusiveGrabImpl(); executed 12 times by 1 test: cancelExclusiveGrabImpl();Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 947 | } | - | ||||||||||||||||||||||||||||||
| 948 | - | |||||||||||||||||||||||||||||||
| 949 | void QQuickEventPoint::cancelExclusiveGrabImpl(QTouchEvent *cancelEvent) | - | ||||||||||||||||||||||||||||||
| 950 | { | - | ||||||||||||||||||||||||||||||
| 951 | if (m_exclusiveGrabber.isNull())
| 0-16 | ||||||||||||||||||||||||||||||
| 952 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 953 | if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) {
| 0-16 | ||||||||||||||||||||||||||||||
| 954 | qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) never executed: QMessageLogger(__FILE__, 954, __PRETTY_FUNCTION__, lcPointerGrab().categoryName()).debug() << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab (exclusive)" << m_exclusiveGrabber << "-> nullptr";
| 0 | ||||||||||||||||||||||||||||||
| 955 | << ": grab (exclusive)" << m_exclusiveGrabber << "-> nullptr"; never executed: QMessageLogger(__FILE__, 954, __PRETTY_FUNCTION__, lcPointerGrab().categoryName()).debug() << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab (exclusive)" << m_exclusiveGrabber << "-> nullptr"; | 0 | ||||||||||||||||||||||||||||||
| 956 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 957 | if (auto handler = grabberPointerHandler()) {
| 4-12 | ||||||||||||||||||||||||||||||
| 958 | handler->onGrabChanged(handler, CancelGrabExclusive, this); | - | ||||||||||||||||||||||||||||||
| 959 | } else if (auto item = grabberItem()) { executed 12 times by 1 test: end of blockExecuted by:
| 0-12 | ||||||||||||||||||||||||||||||
| 960 | if (cancelEvent)
| 0-4 | ||||||||||||||||||||||||||||||
| 961 | QCoreApplication::sendEvent(item, cancelEvent); executed 4 times by 1 test: QCoreApplication::sendEvent(item, cancelEvent);Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 962 | else | - | ||||||||||||||||||||||||||||||
| 963 | item->touchUngrabEvent(); never executed: item->touchUngrabEvent(); | 0 | ||||||||||||||||||||||||||||||
| 964 | } | - | ||||||||||||||||||||||||||||||
| 965 | m_exclusiveGrabber.clear(); | - | ||||||||||||||||||||||||||||||
| 966 | } executed 16 times by 2 tests: end of blockExecuted by:
| 16 | ||||||||||||||||||||||||||||||
| 967 | - | |||||||||||||||||||||||||||||||
| 968 | /*! | - | ||||||||||||||||||||||||||||||
| 969 | If this point has the given \a handler as a passive grabber, | - | ||||||||||||||||||||||||||||||
| 970 | inform the grabber that its grab is canceled, and remove it as grabber. | - | ||||||||||||||||||||||||||||||
| 971 | This normally happens when another Item or PointerHandler does an exclusive grab. | - | ||||||||||||||||||||||||||||||
| 972 | */ | - | ||||||||||||||||||||||||||||||
| 973 | void QQuickEventPoint::cancelPassiveGrab(QQuickPointerHandler *handler) | - | ||||||||||||||||||||||||||||||
| 974 | { | - | ||||||||||||||||||||||||||||||
| 975 | if (removePassiveGrabber(handler)) {
| 0-26 | ||||||||||||||||||||||||||||||
| 976 | if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) {
| 0-26 | ||||||||||||||||||||||||||||||
| 977 | qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) never executed: QMessageLogger(__FILE__, 977, __PRETTY_FUNCTION__, lcPointerGrab().categoryName()).debug() << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab (passive)" << handler << "removed";
| 0 | ||||||||||||||||||||||||||||||
| 978 | << ": grab (passive)" << handler << "removed"; never executed: QMessageLogger(__FILE__, 977, __PRETTY_FUNCTION__, lcPointerGrab().categoryName()).debug() << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab (passive)" << handler << "removed"; | 0 | ||||||||||||||||||||||||||||||
| 979 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 980 | handler->onGrabChanged(handler, CancelGrabPassive, this); | - | ||||||||||||||||||||||||||||||
| 981 | } executed 26 times by 2 tests: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||||||||
| 982 | } executed 26 times by 2 tests: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||||||||
| 983 | - | |||||||||||||||||||||||||||||||
| 984 | /*! | - | ||||||||||||||||||||||||||||||
| 985 | If this point has the given \a handler as a passive grabber, remove it as grabber. | - | ||||||||||||||||||||||||||||||
| 986 | Returns true if it was removed, false if it wasn't a grabber. | - | ||||||||||||||||||||||||||||||
| 987 | */ | - | ||||||||||||||||||||||||||||||
| 988 | bool QQuickEventPoint::removePassiveGrabber(QQuickPointerHandler *handler) | - | ||||||||||||||||||||||||||||||
| 989 | { | - | ||||||||||||||||||||||||||||||
| 990 | return m_passiveGrabbers.removeOne(handler); executed 26 times by 2 tests: return m_passiveGrabbers.removeOne(handler);Executed by:
| 26 | ||||||||||||||||||||||||||||||
| 991 | } | - | ||||||||||||||||||||||||||||||
| 992 | - | |||||||||||||||||||||||||||||||
| 993 | /*! | - | ||||||||||||||||||||||||||||||
| 994 | If the given \a handler is grabbing this point passively, exclusively | - | ||||||||||||||||||||||||||||||
| 995 | or both, cancel the grab and remove it as grabber. | - | ||||||||||||||||||||||||||||||
| 996 | This normally happens when the handler decides that the behavior of this | - | ||||||||||||||||||||||||||||||
| 997 | point can no longer satisfy the handler's behavioral constraints within | - | ||||||||||||||||||||||||||||||
| 998 | the remainder of the gesture which the user is performing: for example | - | ||||||||||||||||||||||||||||||
| 999 | the handler tries to detect a tap but a drag is occurring instead, or | - | ||||||||||||||||||||||||||||||
| 1000 | it tries to detect a drag in one direction but the drag is going in | - | ||||||||||||||||||||||||||||||
| 1001 | another direction. In such cases the handler no longer needs or wants | - | ||||||||||||||||||||||||||||||
| 1002 | to be informed of any further movements of this point. | - | ||||||||||||||||||||||||||||||
| 1003 | */ | - | ||||||||||||||||||||||||||||||
| 1004 | void QQuickEventPoint::cancelAllGrabs(QQuickPointerHandler *handler) | - | ||||||||||||||||||||||||||||||
| 1005 | { | - | ||||||||||||||||||||||||||||||
| 1006 | if (m_exclusiveGrabber == handler) {
| 0-26 | ||||||||||||||||||||||||||||||
| 1007 | handler->onGrabChanged(handler, CancelGrabExclusive, this); | - | ||||||||||||||||||||||||||||||
| 1008 | m_exclusiveGrabber.clear(); | - | ||||||||||||||||||||||||||||||
| 1009 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1010 | cancelPassiveGrab(handler); | - | ||||||||||||||||||||||||||||||
| 1011 | } executed 26 times by 2 tests: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||||||||
| 1012 | - | |||||||||||||||||||||||||||||||
| 1013 | /*! | - | ||||||||||||||||||||||||||||||
| 1014 | Sets this point as \a accepted (true) or rejected (false). | - | ||||||||||||||||||||||||||||||
| 1015 | - | |||||||||||||||||||||||||||||||
| 1016 | During delivery of the current event to the Items in the scene, each Item | - | ||||||||||||||||||||||||||||||
| 1017 | or Pointer Handler should accept the points for which it is taking | - | ||||||||||||||||||||||||||||||
| 1018 | responsibility. As soon as all points within the event are accepted, event | - | ||||||||||||||||||||||||||||||
| 1019 | propagation stops. However accepting the point does not imply any kind of | - | ||||||||||||||||||||||||||||||
| 1020 | grab, passive or exclusive. | - | ||||||||||||||||||||||||||||||
| 1021 | - | |||||||||||||||||||||||||||||||
| 1022 | \sa setExclusiveGrabber, QQuickPointerHandler::setPassiveGrab, QQuickPointerHandler::setExclusiveGrab | - | ||||||||||||||||||||||||||||||
| 1023 | */ | - | ||||||||||||||||||||||||||||||
| 1024 | void QQuickEventPoint::setAccepted(bool accepted) | - | ||||||||||||||||||||||||||||||
| 1025 | { | - | ||||||||||||||||||||||||||||||
| 1026 | if (m_accept != accepted) {
| 3858-10206 | ||||||||||||||||||||||||||||||
| 1027 | qCDebug(lcPointerEvents) << this << m_accept << "->" << accepted; never executed: QMessageLogger(__FILE__, 1027, __PRETTY_FUNCTION__, lcPointerEvents().categoryName()).debug() << this << m_accept << "->" << accepted;
| 0-10206 | ||||||||||||||||||||||||||||||
| 1028 | m_accept = accepted; | - | ||||||||||||||||||||||||||||||
| 1029 | } executed 10206 times by 16 tests: end of blockExecuted by:
| 10206 | ||||||||||||||||||||||||||||||
| 1030 | } executed 14064 times by 16 tests: end of blockExecuted by:
| 14064 | ||||||||||||||||||||||||||||||
| 1031 | - | |||||||||||||||||||||||||||||||
| 1032 | - | |||||||||||||||||||||||||||||||
| 1033 | /*! | - | ||||||||||||||||||||||||||||||
| 1034 | \qmltype EventTouchPoint | - | ||||||||||||||||||||||||||||||
| 1035 | \qmlabstract | - | ||||||||||||||||||||||||||||||
| 1036 | \instantiates QQuickEventTouchPoint | - | ||||||||||||||||||||||||||||||
| 1037 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 1038 | \ingroup qtquick-input-events | - | ||||||||||||||||||||||||||||||
| 1039 | \brief Provides information about an individual touch point within a PointerEvent. | - | ||||||||||||||||||||||||||||||
| 1040 | - | |||||||||||||||||||||||||||||||
| 1041 | \sa PointerEvent, PointerHandler | - | ||||||||||||||||||||||||||||||
| 1042 | */ | - | ||||||||||||||||||||||||||||||
| 1043 | - | |||||||||||||||||||||||||||||||
| 1044 | /*! | - | ||||||||||||||||||||||||||||||
| 1045 | \readonly | - | ||||||||||||||||||||||||||||||
| 1046 | \qmlproperty QPointerUniqueId QtQuick::EventTouchPoint::uniqueId | - | ||||||||||||||||||||||||||||||
| 1047 | - | |||||||||||||||||||||||||||||||
| 1048 | This property holds the unique ID of the fiducial or stylus in use, if any. | - | ||||||||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||||||||
| 1050 | On touchscreens that can track physical objects (such as knobs or game | - | ||||||||||||||||||||||||||||||
| 1051 | pieces) in addition to fingers, each object usually has a unique ID. | - | ||||||||||||||||||||||||||||||
| 1052 | Likewise, each stylus that can be used with a graphics tablet usually has a | - | ||||||||||||||||||||||||||||||
| 1053 | unique serial number. Qt so far only supports numeric IDs. You can get the | - | ||||||||||||||||||||||||||||||
| 1054 | actual number as uniqueId.numeric, but that is a device-specific detail. | - | ||||||||||||||||||||||||||||||
| 1055 | In the future, there may be support for non-numeric IDs, so you should | - | ||||||||||||||||||||||||||||||
| 1056 | not assume that the number is meaningful. | - | ||||||||||||||||||||||||||||||
| 1057 | - | |||||||||||||||||||||||||||||||
| 1058 | If you need to identify specific objects, your application should provide | - | ||||||||||||||||||||||||||||||
| 1059 | UI for registering objects and mapping them to functionality: allow the | - | ||||||||||||||||||||||||||||||
| 1060 | user to select a meaning, virtual tool, or action, prompt the user to bring | - | ||||||||||||||||||||||||||||||
| 1061 | the object into proximity, and store a mapping from uniqueId to its | - | ||||||||||||||||||||||||||||||
| 1062 | purpose, for example in \l Settings. | - | ||||||||||||||||||||||||||||||
| 1063 | */ | - | ||||||||||||||||||||||||||||||
| 1064 | - | |||||||||||||||||||||||||||||||
| 1065 | /*! | - | ||||||||||||||||||||||||||||||
| 1066 | \readonly | - | ||||||||||||||||||||||||||||||
| 1067 | \qmlproperty qreal QtQuick::EventTouchPoint::rotation | - | ||||||||||||||||||||||||||||||
| 1068 | - | |||||||||||||||||||||||||||||||
| 1069 | This property holds the rotation angle of the stylus on a graphics tablet | - | ||||||||||||||||||||||||||||||
| 1070 | or the contact patch of a touchpoint on a touchscreen. | - | ||||||||||||||||||||||||||||||
| 1071 | - | |||||||||||||||||||||||||||||||
| 1072 | It is valid only with certain tablet stylus devices and touchscreens that | - | ||||||||||||||||||||||||||||||
| 1073 | can measure the rotation angle. Otherwise, it will be zero. | - | ||||||||||||||||||||||||||||||
| 1074 | */ | - | ||||||||||||||||||||||||||||||
| 1075 | - | |||||||||||||||||||||||||||||||
| 1076 | /*! | - | ||||||||||||||||||||||||||||||
| 1077 | \readonly | - | ||||||||||||||||||||||||||||||
| 1078 | \qmlproperty qreal QtQuick::EventTouchPoint::pressure | - | ||||||||||||||||||||||||||||||
| 1079 | - | |||||||||||||||||||||||||||||||
| 1080 | This property tells how hard the user is pressing the stylus on a graphics | - | ||||||||||||||||||||||||||||||
| 1081 | tablet or the finger against a touchscreen, in the range from \c 0 (no | - | ||||||||||||||||||||||||||||||
| 1082 | measurable pressure) to \c 1.0 (maximum pressure which the device can | - | ||||||||||||||||||||||||||||||
| 1083 | measure). | - | ||||||||||||||||||||||||||||||
| 1084 | - | |||||||||||||||||||||||||||||||
| 1085 | It is valid only with certain tablets and touchscreens that can measure | - | ||||||||||||||||||||||||||||||
| 1086 | pressure. Otherwise, it will be \c 1.0 when pressed. | - | ||||||||||||||||||||||||||||||
| 1087 | */ | - | ||||||||||||||||||||||||||||||
| 1088 | - | |||||||||||||||||||||||||||||||
| 1089 | /*! | - | ||||||||||||||||||||||||||||||
| 1090 | \readonly | - | ||||||||||||||||||||||||||||||
| 1091 | \qmlproperty size QtQuick::EventTouchPoint::ellipseDiameters | - | ||||||||||||||||||||||||||||||
| 1092 | - | |||||||||||||||||||||||||||||||
| 1093 | This property holds the diameters of the contact patch, if the event | - | ||||||||||||||||||||||||||||||
| 1094 | comes from a touchpoint and the \l {QtQuick::PointerEvent::device} {device} | - | ||||||||||||||||||||||||||||||
| 1095 | provides this information. | - | ||||||||||||||||||||||||||||||
| 1096 | - | |||||||||||||||||||||||||||||||
| 1097 | A touchpoint is modeled as an elliptical area where the finger is | - | ||||||||||||||||||||||||||||||
| 1098 | pressed against the touchscreen. (In fact, it could also be | - | ||||||||||||||||||||||||||||||
| 1099 | modeled as a bitmap; but in that case we expect an elliptical | - | ||||||||||||||||||||||||||||||
| 1100 | bounding estimate to be fitted to the contact patch before the | - | ||||||||||||||||||||||||||||||
| 1101 | event is sent.) The harder the user presses, the larger the | - | ||||||||||||||||||||||||||||||
| 1102 | contact patch; so, these diameters provide an alternate way of | - | ||||||||||||||||||||||||||||||
| 1103 | detecting pressure, in case the device does not include a separate | - | ||||||||||||||||||||||||||||||
| 1104 | pressure sensor. The ellipse is centered on | - | ||||||||||||||||||||||||||||||
| 1105 | \l {QtQuick::EventPoint::scenePosition} {scenePosition} | - | ||||||||||||||||||||||||||||||
| 1106 | (\l {QtQuick::EventPoint::position} {position} in the PointerHandler's | - | ||||||||||||||||||||||||||||||
| 1107 | Item's local coordinates). The \l rotation property provides the | - | ||||||||||||||||||||||||||||||
| 1108 | rotation of the ellipse, if known. It is expected that if the | - | ||||||||||||||||||||||||||||||
| 1109 | \l rotation is zero, the verticalDiameter of the ellipse is the | - | ||||||||||||||||||||||||||||||
| 1110 | larger one (the major axis), because of the usual hand position, | - | ||||||||||||||||||||||||||||||
| 1111 | reaching upward or outward across the surface. | - | ||||||||||||||||||||||||||||||
| 1112 | - | |||||||||||||||||||||||||||||||
| 1113 | If the contact patch is unknown, or the \l {QtQuick::PointerEvent::device} {device} | - | ||||||||||||||||||||||||||||||
| 1114 | is not a touchscreen, these values will be zero. | - | ||||||||||||||||||||||||||||||
| 1115 | */ | - | ||||||||||||||||||||||||||||||
| 1116 | - | |||||||||||||||||||||||||||||||
| 1117 | QQuickEventTouchPoint::QQuickEventTouchPoint(QQuickPointerTouchEvent *parent) | - | ||||||||||||||||||||||||||||||
| 1118 | : QQuickEventPoint(parent), m_rotation(0), m_pressure(0) | - | ||||||||||||||||||||||||||||||
| 1119 | {} executed 272 times by 10 tests: end of blockExecuted by:
| 272 | ||||||||||||||||||||||||||||||
| 1120 | - | |||||||||||||||||||||||||||||||
| 1121 | void QQuickEventTouchPoint::reset(const QTouchEvent::TouchPoint &tp, ulong timestamp) | - | ||||||||||||||||||||||||||||||
| 1122 | { | - | ||||||||||||||||||||||||||||||
| 1123 | QQuickEventPoint::reset(tp.state(), tp.scenePos(), tp.id(), timestamp, tp.velocity()); | - | ||||||||||||||||||||||||||||||
| 1124 | m_exclusiveGrabber.clear(); | - | ||||||||||||||||||||||||||||||
| 1125 | m_passiveGrabbers.clear(); | - | ||||||||||||||||||||||||||||||
| 1126 | m_rotation = tp.rotation(); | - | ||||||||||||||||||||||||||||||
| 1127 | m_pressure = tp.pressure(); | - | ||||||||||||||||||||||||||||||
| 1128 | m_ellipseDiameters = tp.ellipseDiameters(); | - | ||||||||||||||||||||||||||||||
| 1129 | m_uniqueId = tp.uniqueId(); | - | ||||||||||||||||||||||||||||||
| 1130 | } executed 1938 times by 10 tests: end of blockExecuted by:
| 1938 | ||||||||||||||||||||||||||||||
| 1131 | - | |||||||||||||||||||||||||||||||
| 1132 | struct PointVelocityData { | - | ||||||||||||||||||||||||||||||
| 1133 | QVector2D velocity; | - | ||||||||||||||||||||||||||||||
| 1134 | QPointF pos; | - | ||||||||||||||||||||||||||||||
| 1135 | ulong timestamp; | - | ||||||||||||||||||||||||||||||
| 1136 | }; | - | ||||||||||||||||||||||||||||||
| 1137 | - | |||||||||||||||||||||||||||||||
| 1138 | typedef QMap<quint64, PointVelocityData*> PointDataForPointIdMap; | - | ||||||||||||||||||||||||||||||
| 1139 | Q_GLOBAL_STATIC(PointDataForPointIdMap, g_previousPointData) executed 36 times by 18 tests: end of blockExecuted by:
executed 36 times by 18 tests: guard.store(QtGlobalStatic::Destroyed);Executed by:
executed 13218 times by 18 tests: return &holder.value;Executed by:
| 0-13218 | ||||||||||||||||||||||||||||||
| 1140 | static const int PointVelocityAgeLimit = 500; // milliseconds | - | ||||||||||||||||||||||||||||||
| 1141 | - | |||||||||||||||||||||||||||||||
| 1142 | /*! | - | ||||||||||||||||||||||||||||||
| 1143 | \internal | - | ||||||||||||||||||||||||||||||
| 1144 | Estimates the velocity based on a weighted average of all previous velocities. | - | ||||||||||||||||||||||||||||||
| 1145 | The older the velocity is, the less significant it becomes for the estimate. | - | ||||||||||||||||||||||||||||||
| 1146 | */ | - | ||||||||||||||||||||||||||||||
| 1147 | QVector2D QQuickEventPoint::estimatedVelocity() const | - | ||||||||||||||||||||||||||||||
| 1148 | { | - | ||||||||||||||||||||||||||||||
| 1149 | PointVelocityData *prevPoint = g_previousPointData->value(m_pointId); | - | ||||||||||||||||||||||||||||||
| 1150 | if (!prevPoint) {
| 294-11798 | ||||||||||||||||||||||||||||||
| 1151 | // cleanup events older than PointVelocityAgeLimit | - | ||||||||||||||||||||||||||||||
| 1152 | auto end = g_previousPointData->end(); | - | ||||||||||||||||||||||||||||||
| 1153 | for (auto it = g_previousPointData->begin(); it != end; ) {
| 294-349 | ||||||||||||||||||||||||||||||
| 1154 | PointVelocityData *data = it.value(); | - | ||||||||||||||||||||||||||||||
| 1155 | if (m_timestamp - data->timestamp > PointVelocityAgeLimit) {
| 105-244 | ||||||||||||||||||||||||||||||
| 1156 | it = g_previousPointData->erase(it); | - | ||||||||||||||||||||||||||||||
| 1157 | delete data; | - | ||||||||||||||||||||||||||||||
| 1158 | } else { executed 244 times by 8 tests: end of blockExecuted by:
| 244 | ||||||||||||||||||||||||||||||
| 1159 | ++it; | - | ||||||||||||||||||||||||||||||
| 1160 | } executed 105 times by 6 tests: end of blockExecuted by:
| 105 | ||||||||||||||||||||||||||||||
| 1161 | } | - | ||||||||||||||||||||||||||||||
| 1162 | // TODO optimize: stop this dynamic memory thrashing | - | ||||||||||||||||||||||||||||||
| 1163 | prevPoint = new PointVelocityData; | - | ||||||||||||||||||||||||||||||
| 1164 | prevPoint->velocity = QVector2D(); | - | ||||||||||||||||||||||||||||||
| 1165 | prevPoint->timestamp = 0; | - | ||||||||||||||||||||||||||||||
| 1166 | prevPoint->pos = QPointF(); | - | ||||||||||||||||||||||||||||||
| 1167 | g_previousPointData->insert(m_pointId, prevPoint); | - | ||||||||||||||||||||||||||||||
| 1168 | } executed 294 times by 18 tests: end of blockExecuted by:
| 294 | ||||||||||||||||||||||||||||||
| 1169 | const ulong timeElapsed = m_timestamp - prevPoint->timestamp; | - | ||||||||||||||||||||||||||||||
| 1170 | if (timeElapsed == 0) // in case we call estimatedVelocity() twice on the same QQuickEventPoint
| 1040-11052 | ||||||||||||||||||||||||||||||
| 1171 | return m_velocity; executed 1040 times by 13 tests: return m_velocity;Executed by:
| 1040 | ||||||||||||||||||||||||||||||
| 1172 | - | |||||||||||||||||||||||||||||||
| 1173 | QVector2D newVelocity; | - | ||||||||||||||||||||||||||||||
| 1174 | if (prevPoint->timestamp != 0)
| 312-10740 | ||||||||||||||||||||||||||||||
| 1175 | newVelocity = QVector2D(m_scenePos - prevPoint->pos)/timeElapsed; executed 10740 times by 17 tests: newVelocity = QVector2D(m_scenePos - prevPoint->pos)/timeElapsed;Executed by:
| 10740 | ||||||||||||||||||||||||||||||
| 1176 | - | |||||||||||||||||||||||||||||||
| 1177 | // VERY simple kalman filter: does a weighted average | - | ||||||||||||||||||||||||||||||
| 1178 | // where the older velocities get less and less significant | - | ||||||||||||||||||||||||||||||
| 1179 | static const float KalmanGain = 0.7f; | - | ||||||||||||||||||||||||||||||
| 1180 | QVector2D filteredVelocity = newVelocity * KalmanGain + m_velocity * (1.0f - KalmanGain); | - | ||||||||||||||||||||||||||||||
| 1181 | - | |||||||||||||||||||||||||||||||
| 1182 | prevPoint->velocity = filteredVelocity; | - | ||||||||||||||||||||||||||||||
| 1183 | prevPoint->pos = m_scenePos; | - | ||||||||||||||||||||||||||||||
| 1184 | prevPoint->timestamp = m_timestamp; | - | ||||||||||||||||||||||||||||||
| 1185 | return filteredVelocity; executed 11052 times by 17 tests: return filteredVelocity;Executed by:
| 11052 | ||||||||||||||||||||||||||||||
| 1186 | } | - | ||||||||||||||||||||||||||||||
| 1187 | - | |||||||||||||||||||||||||||||||
| 1188 | /*! | - | ||||||||||||||||||||||||||||||
| 1189 | \qmltype PointerEvent | - | ||||||||||||||||||||||||||||||
| 1190 | \instantiates QQuickPointerEvent | - | ||||||||||||||||||||||||||||||
| 1191 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||||||||
| 1192 | \ingroup qtquick-input-events | - | ||||||||||||||||||||||||||||||
| 1193 | - | |||||||||||||||||||||||||||||||
| 1194 | \brief Provides information about an event from a pointing device. | - | ||||||||||||||||||||||||||||||
| 1195 | - | |||||||||||||||||||||||||||||||
| 1196 | A PointerEvent is an event describing contact or movement across a surface, | - | ||||||||||||||||||||||||||||||
| 1197 | provided by a mouse, a touchpoint (single finger on a touchscreen), or a | - | ||||||||||||||||||||||||||||||
| 1198 | stylus on a graphics tablet. The \l {QtQuick::PointerEvent::device} {device} | - | ||||||||||||||||||||||||||||||
| 1199 | property provides more information about where the event came from. | - | ||||||||||||||||||||||||||||||
| 1200 | - | |||||||||||||||||||||||||||||||
| 1201 | \sa PointerHandler | - | ||||||||||||||||||||||||||||||
| 1202 | - | |||||||||||||||||||||||||||||||
| 1203 | \image touchpoint-metrics.png | - | ||||||||||||||||||||||||||||||
| 1204 | */ | - | ||||||||||||||||||||||||||||||
| 1205 | - | |||||||||||||||||||||||||||||||
| 1206 | /*! | - | ||||||||||||||||||||||||||||||
| 1207 | \internal | - | ||||||||||||||||||||||||||||||
| 1208 | \class QQuickPointerEvent | - | ||||||||||||||||||||||||||||||
| 1209 | - | |||||||||||||||||||||||||||||||
| 1210 | QQuickPointerEvent is used as a long-lived object to store data related to | - | ||||||||||||||||||||||||||||||
| 1211 | an event from a pointing device, such as a mouse, touch or tablet event, | - | ||||||||||||||||||||||||||||||
| 1212 | during event delivery. It also provides properties which may be used later | - | ||||||||||||||||||||||||||||||
| 1213 | to expose the event to QML, the same as is done with QQuickMouseEvent, | - | ||||||||||||||||||||||||||||||
| 1214 | QQuickTouchPoint, QQuickKeyEvent, etc. Since only one event can be | - | ||||||||||||||||||||||||||||||
| 1215 | delivered at a time, this class is effectively a singleton. We don't worry | - | ||||||||||||||||||||||||||||||
| 1216 | about the QObject overhead because the instances are long-lived: we don't | - | ||||||||||||||||||||||||||||||
| 1217 | dynamically create and destroy objects of this type for each event. | - | ||||||||||||||||||||||||||||||
| 1218 | */ | - | ||||||||||||||||||||||||||||||
| 1219 | - | |||||||||||||||||||||||||||||||
| 1220 | /*! | - | ||||||||||||||||||||||||||||||
| 1221 | \readonly | - | ||||||||||||||||||||||||||||||
| 1222 | \qmlproperty enumeration QtQuick::PointerEvent::button | - | ||||||||||||||||||||||||||||||
| 1223 | - | |||||||||||||||||||||||||||||||
| 1224 | This property holds the \l {Qt::MouseButton}{button} that caused the event, | - | ||||||||||||||||||||||||||||||
| 1225 | if any. If the \l {QtQuick::PointerEvent::device} {device} does not have | - | ||||||||||||||||||||||||||||||
| 1226 | buttons, or the event is a hover event, it will be \c Qt.NoButton. | - | ||||||||||||||||||||||||||||||
| 1227 | */ | - | ||||||||||||||||||||||||||||||
| 1228 | - | |||||||||||||||||||||||||||||||
| 1229 | /*! | - | ||||||||||||||||||||||||||||||
| 1230 | \readonly | - | ||||||||||||||||||||||||||||||
| 1231 | \qmlproperty int QtQuick::PointerEvent::buttons | - | ||||||||||||||||||||||||||||||
| 1232 | - | |||||||||||||||||||||||||||||||
| 1233 | This property holds the combination of mouse or stylus | - | ||||||||||||||||||||||||||||||
| 1234 | \l {Qt::MouseButton}{buttons} pressed when the event was generated. For move | - | ||||||||||||||||||||||||||||||
| 1235 | events, this is all buttons that are pressed down. For press events, this | - | ||||||||||||||||||||||||||||||
| 1236 | includes the button that caused the event, as well as any others that were | - | ||||||||||||||||||||||||||||||
| 1237 | already held. For release events, this excludes the button that caused the | - | ||||||||||||||||||||||||||||||
| 1238 | event. | - | ||||||||||||||||||||||||||||||
| 1239 | */ | - | ||||||||||||||||||||||||||||||
| 1240 | - | |||||||||||||||||||||||||||||||
| 1241 | /*! | - | ||||||||||||||||||||||||||||||
| 1242 | \readonly | - | ||||||||||||||||||||||||||||||
| 1243 | \qmlproperty int QtQuick::PointerEvent::modifiers | - | ||||||||||||||||||||||||||||||
| 1244 | - | |||||||||||||||||||||||||||||||
| 1245 | This property holds the \l {Qt::KeyboardModifier}{keyboard modifier} flags | - | ||||||||||||||||||||||||||||||
| 1246 | that existed immediately before the event occurred. | - | ||||||||||||||||||||||||||||||
| 1247 | - | |||||||||||||||||||||||||||||||
| 1248 | It contains a bitwise combination of the following flags: | - | ||||||||||||||||||||||||||||||
| 1249 | \value Qt.NoModifier | - | ||||||||||||||||||||||||||||||
| 1250 | No modifier key is pressed. | - | ||||||||||||||||||||||||||||||
| 1251 | \value Qt.ShiftModifier | - | ||||||||||||||||||||||||||||||
| 1252 | A Shift key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 1253 | \value Qt.ControlModifier | - | ||||||||||||||||||||||||||||||
| 1254 | A Ctrl key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 1255 | \value Qt.AltModifier | - | ||||||||||||||||||||||||||||||
| 1256 | An Alt key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 1257 | \value Qt.MetaModifier | - | ||||||||||||||||||||||||||||||
| 1258 | A Meta key on the keyboard is pressed. | - | ||||||||||||||||||||||||||||||
| 1259 | \value Qt.KeypadModifier | - | ||||||||||||||||||||||||||||||
| 1260 | A keypad button is pressed. | - | ||||||||||||||||||||||||||||||
| 1261 | - | |||||||||||||||||||||||||||||||
| 1262 | For example, to react to a Shift key + Left mouse button click: | - | ||||||||||||||||||||||||||||||
| 1263 | \qml | - | ||||||||||||||||||||||||||||||
| 1264 | Item { | - | ||||||||||||||||||||||||||||||
| 1265 | TapHandler { | - | ||||||||||||||||||||||||||||||
| 1266 | onTapped: { | - | ||||||||||||||||||||||||||||||
| 1267 | if ((event.button == Qt.LeftButton) && (event.modifiers & Qt.ShiftModifier)) | - | ||||||||||||||||||||||||||||||
| 1268 | doSomething(); | - | ||||||||||||||||||||||||||||||
| 1269 | } | - | ||||||||||||||||||||||||||||||
| 1270 | } | - | ||||||||||||||||||||||||||||||
| 1271 | } | - | ||||||||||||||||||||||||||||||
| 1272 | \endqml | - | ||||||||||||||||||||||||||||||
| 1273 | */ | - | ||||||||||||||||||||||||||||||
| 1274 | - | |||||||||||||||||||||||||||||||
| 1275 | /*! | - | ||||||||||||||||||||||||||||||
| 1276 | \readonly | - | ||||||||||||||||||||||||||||||
| 1277 | \qmlproperty PointerDevice QtQuick::PointerEvent::device | - | ||||||||||||||||||||||||||||||
| 1278 | - | |||||||||||||||||||||||||||||||
| 1279 | This property holds the device that generated the event. | - | ||||||||||||||||||||||||||||||
| 1280 | */ | - | ||||||||||||||||||||||||||||||
| 1281 | - | |||||||||||||||||||||||||||||||
| 1282 | QQuickPointerEvent::~QQuickPointerEvent() | - | ||||||||||||||||||||||||||||||
| 1283 | {} | - | ||||||||||||||||||||||||||||||
| 1284 | - | |||||||||||||||||||||||||||||||
| 1285 | QQuickPointerEvent *QQuickPointerMouseEvent::reset(QEvent *event) | - | ||||||||||||||||||||||||||||||
| 1286 | { | - | ||||||||||||||||||||||||||||||
| 1287 | auto ev = static_cast<QMouseEvent*>(event); | - | ||||||||||||||||||||||||||||||
| 1288 | m_event = ev; | - | ||||||||||||||||||||||||||||||
| 1289 | if (!event)
| 10144 | ||||||||||||||||||||||||||||||
| 1290 | return this; executed 10144 times by 16 tests: return this;Executed by:
| 10144 | ||||||||||||||||||||||||||||||
| 1291 | - | |||||||||||||||||||||||||||||||
| 1292 | m_device = QQuickPointerDevice::genericMouseDevice(); | - | ||||||||||||||||||||||||||||||
| 1293 | m_device->eventDeliveryTargets().clear(); | - | ||||||||||||||||||||||||||||||
| 1294 | m_button = ev->button(); | - | ||||||||||||||||||||||||||||||
| 1295 | m_pressedButtons = ev->buttons(); | - | ||||||||||||||||||||||||||||||
| 1296 | Qt::TouchPointState state = Qt::TouchPointStationary; | - | ||||||||||||||||||||||||||||||
| 1297 | switch (ev->type()) { | - | ||||||||||||||||||||||||||||||
| 1298 | case QEvent::MouseButtonPress: executed 1798 times by 14 tests: case QEvent::MouseButtonPress:Executed by:
| 1798 | ||||||||||||||||||||||||||||||
| 1299 | m_point->clearPassiveGrabbers(); | - | ||||||||||||||||||||||||||||||
| 1300 | Q_FALLTHROUGH(); | - | ||||||||||||||||||||||||||||||
| 1301 | case QEvent::MouseButtonDblClick: code before this statement executed 1798 times by 14 tests: case QEvent::MouseButtonDblClick:Executed by:
executed 132 times by 3 tests: case QEvent::MouseButtonDblClick:Executed by:
| 132-1798 | ||||||||||||||||||||||||||||||
| 1302 | state = Qt::TouchPointPressed; | - | ||||||||||||||||||||||||||||||
| 1303 | break; executed 1930 times by 14 tests: break;Executed by:
| 1930 | ||||||||||||||||||||||||||||||
| 1304 | case QEvent::MouseButtonRelease: executed 1786 times by 14 tests: case QEvent::MouseButtonRelease:Executed by:
| 1786 | ||||||||||||||||||||||||||||||
| 1305 | state = Qt::TouchPointReleased; | - | ||||||||||||||||||||||||||||||
| 1306 | break; executed 1786 times by 14 tests: break;Executed by:
| 1786 | ||||||||||||||||||||||||||||||
| 1307 | case QEvent::MouseMove: executed 6428 times by 16 tests: case QEvent::MouseMove:Executed by:
| 6428 | ||||||||||||||||||||||||||||||
| 1308 | state = Qt::TouchPointMoved; | - | ||||||||||||||||||||||||||||||
| 1309 | break; executed 6428 times by 16 tests: break;Executed by:
| 6428 | ||||||||||||||||||||||||||||||
| 1310 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 1311 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1312 | } | - | ||||||||||||||||||||||||||||||
| 1313 | m_point->reset(state, ev->windowPos(), quint64(1) << 24, ev->timestamp()); // mouse has device ID 1 | - | ||||||||||||||||||||||||||||||
| 1314 | return this; executed 10144 times by 16 tests: return this;Executed by:
| 10144 | ||||||||||||||||||||||||||||||
| 1315 | } | - | ||||||||||||||||||||||||||||||
| 1316 | - | |||||||||||||||||||||||||||||||
| 1317 | void QQuickSinglePointEvent::localize(QQuickItem *target) | - | ||||||||||||||||||||||||||||||
| 1318 | { | - | ||||||||||||||||||||||||||||||
| 1319 | m_point->localizePosition(target); | - | ||||||||||||||||||||||||||||||
| 1320 | } executed 2493 times by 14 tests: end of blockExecuted by:
| 2493 | ||||||||||||||||||||||||||||||
| 1321 | - | |||||||||||||||||||||||||||||||
| 1322 | QQuickPointerEvent *QQuickPointerTouchEvent::reset(QEvent *event) | - | ||||||||||||||||||||||||||||||
| 1323 | { | - | ||||||||||||||||||||||||||||||
| 1324 | auto ev = static_cast<QTouchEvent*>(event); | - | ||||||||||||||||||||||||||||||
| 1325 | m_event = ev; | - | ||||||||||||||||||||||||||||||
| 1326 | if (!event)
| 1220 | ||||||||||||||||||||||||||||||
| 1327 | return this; executed 1220 times by 10 tests: return this;Executed by:
| 1220 | ||||||||||||||||||||||||||||||
| 1328 | - | |||||||||||||||||||||||||||||||
| 1329 | m_device = QQuickPointerDevice::touchDevice(ev->device()); | - | ||||||||||||||||||||||||||||||
| 1330 | m_device->eventDeliveryTargets().clear(); | - | ||||||||||||||||||||||||||||||
| 1331 | m_button = Qt::NoButton; | - | ||||||||||||||||||||||||||||||
| 1332 | m_pressedButtons = Qt::NoButton; | - | ||||||||||||||||||||||||||||||
| 1333 | - | |||||||||||||||||||||||||||||||
| 1334 | const QList<QTouchEvent::TouchPoint> &tps = ev->touchPoints(); | - | ||||||||||||||||||||||||||||||
| 1335 | int newPointCount = tps.count(); | - | ||||||||||||||||||||||||||||||
| 1336 | m_touchPoints.reserve(newPointCount); | - | ||||||||||||||||||||||||||||||
| 1337 | - | |||||||||||||||||||||||||||||||
| 1338 | for (int i = m_touchPoints.size(); i < newPointCount; ++i)
| 272-1220 | ||||||||||||||||||||||||||||||
| 1339 | m_touchPoints.insert(i, new QQuickEventTouchPoint(this)); executed 272 times by 10 tests: m_touchPoints.insert(i, new QQuickEventTouchPoint(this));Executed by:
| 272 | ||||||||||||||||||||||||||||||
| 1340 | - | |||||||||||||||||||||||||||||||
| 1341 | // Make sure the grabbers and on-pressed values are right from one event to the next | - | ||||||||||||||||||||||||||||||
| 1342 | struct ToPreserve { | - | ||||||||||||||||||||||||||||||
| 1343 | int pointId; // just for double-checking | - | ||||||||||||||||||||||||||||||
| 1344 | ulong pressTimestamp; | - | ||||||||||||||||||||||||||||||
| 1345 | QPointF scenePressPos; | - | ||||||||||||||||||||||||||||||
| 1346 | QPointF sceneGrabPos; | - | ||||||||||||||||||||||||||||||
| 1347 | QObject * grabber; | - | ||||||||||||||||||||||||||||||
| 1348 | QVector <QPointer <QQuickPointerHandler> > passiveGrabbers; | - | ||||||||||||||||||||||||||||||
| 1349 | - | |||||||||||||||||||||||||||||||
| 1350 | ToPreserve() : pointId(0), pressTimestamp(0), grabber(nullptr) {} executed 1938 times by 10 tests: end of blockExecuted by:
| 1938 | ||||||||||||||||||||||||||||||
| 1351 | }; | - | ||||||||||||||||||||||||||||||
| 1352 | QVector<ToPreserve> preserves(newPointCount); // jar of pickled touchpoints, in order of points in the _new_ event | - | ||||||||||||||||||||||||||||||
| 1353 | - | |||||||||||||||||||||||||||||||
| 1354 | // Copy stuff we need to preserve, because the order of points might have changed in the event. | - | ||||||||||||||||||||||||||||||
| 1355 | // The ID is all that we can rely on (release might remove the first point etc). | - | ||||||||||||||||||||||||||||||
| 1356 | for (int i = 0; i < newPointCount; ++i) {
| 1220-1938 | ||||||||||||||||||||||||||||||
| 1357 | int pid = tps.at(i).id(); | - | ||||||||||||||||||||||||||||||
| 1358 | if (auto point = pointById(pid)) {
| 282-1656 | ||||||||||||||||||||||||||||||
| 1359 | preserves[i].pointId = pid; | - | ||||||||||||||||||||||||||||||
| 1360 | preserves[i].pressTimestamp = point->m_pressTimestamp; | - | ||||||||||||||||||||||||||||||
| 1361 | preserves[i].scenePressPos = point->scenePressPosition(); | - | ||||||||||||||||||||||||||||||
| 1362 | preserves[i].sceneGrabPos = point->sceneGrabPosition(); | - | ||||||||||||||||||||||||||||||
| 1363 | preserves[i].grabber = point->exclusiveGrabber(); | - | ||||||||||||||||||||||||||||||
| 1364 | preserves[i].passiveGrabbers = point->passiveGrabbers(); | - | ||||||||||||||||||||||||||||||
| 1365 | } executed 1656 times by 10 tests: end of blockExecuted by:
| 1656 | ||||||||||||||||||||||||||||||
| 1366 | } executed 1938 times by 10 tests: end of blockExecuted by:
| 1938 | ||||||||||||||||||||||||||||||
| 1367 | - | |||||||||||||||||||||||||||||||
| 1368 | for (int i = 0; i < newPointCount; ++i) {
| 1220-1938 | ||||||||||||||||||||||||||||||
| 1369 | auto point = m_touchPoints.at(i); | - | ||||||||||||||||||||||||||||||
| 1370 | point->reset(tps.at(i), ev->timestamp()); | - | ||||||||||||||||||||||||||||||
| 1371 | const auto &preserved = preserves.at(i); | - | ||||||||||||||||||||||||||||||
| 1372 | if (point->state() == QQuickEventPoint::Pressed) {
| 358-1580 | ||||||||||||||||||||||||||||||
| 1373 | if (preserved.grabber)
| 0-358 | ||||||||||||||||||||||||||||||
| 1374 | qWarning() << "TouchPointPressed without previous release event" << point; never executed: QMessageLogger(__FILE__, 1374, __PRETTY_FUNCTION__).warning() << "TouchPointPressed without previous release event" << point; | 0 | ||||||||||||||||||||||||||||||
| 1375 | point->setGrabberItem(nullptr); | - | ||||||||||||||||||||||||||||||
| 1376 | point->clearPassiveGrabbers(); | - | ||||||||||||||||||||||||||||||
| 1377 | } else { executed 358 times by 10 tests: end of blockExecuted by:
| 358 | ||||||||||||||||||||||||||||||
| 1378 | // Restore the grabbers without notifying (don't call onGrabChanged) | - | ||||||||||||||||||||||||||||||
| 1379 | Q_ASSERT(preserved.pointId == 0 || preserved.pointId == point->pointId()); | - | ||||||||||||||||||||||||||||||
| 1380 | point->m_pressTimestamp = preserved.pressTimestamp; | - | ||||||||||||||||||||||||||||||
| 1381 | point->m_scenePressPos = preserved.scenePressPos; | - | ||||||||||||||||||||||||||||||
| 1382 | point->m_sceneGrabPos = preserved.sceneGrabPos; | - | ||||||||||||||||||||||||||||||
| 1383 | point->m_exclusiveGrabber = preserved.grabber; | - | ||||||||||||||||||||||||||||||
| 1384 | point->m_grabberIsHandler = (qmlobject_cast<QQuickPointerHandler *>(point->m_exclusiveGrabber) != nullptr); | - | ||||||||||||||||||||||||||||||
| 1385 | point->m_passiveGrabbers = preserved.passiveGrabbers; | - | ||||||||||||||||||||||||||||||
| 1386 | } executed 1580 times by 10 tests: end of blockExecuted by:
| 1580 | ||||||||||||||||||||||||||||||
| 1387 | } | - | ||||||||||||||||||||||||||||||
| 1388 | m_pointCount = newPointCount; | - | ||||||||||||||||||||||||||||||
| 1389 | return this; executed 1220 times by 10 tests: return this;Executed by:
| 1220 | ||||||||||||||||||||||||||||||
| 1390 | } | - | ||||||||||||||||||||||||||||||
| 1391 | - | |||||||||||||||||||||||||||||||
| 1392 | void QQuickPointerTouchEvent::localize(QQuickItem *target) | - | ||||||||||||||||||||||||||||||
| 1393 | { | - | ||||||||||||||||||||||||||||||
| 1394 | for (auto point : qAsConst(m_touchPoints)) | - | ||||||||||||||||||||||||||||||
| 1395 | point->localizePosition(target); executed 11545 times by 10 tests: point->localizePosition(target);Executed by:
| 11545 | ||||||||||||||||||||||||||||||
| 1396 | } executed 6155 times by 10 tests: end of blockExecuted by:
| 6155 | ||||||||||||||||||||||||||||||
| 1397 | - | |||||||||||||||||||||||||||||||
| 1398 | #if QT_CONFIG(gestures) | - | ||||||||||||||||||||||||||||||
| 1399 | QQuickPointerEvent *QQuickPointerNativeGestureEvent::reset(QEvent *event) | - | ||||||||||||||||||||||||||||||
| 1400 | { | - | ||||||||||||||||||||||||||||||
| 1401 | auto ev = static_cast<QNativeGestureEvent*>(event); | - | ||||||||||||||||||||||||||||||
| 1402 | m_event = ev; | - | ||||||||||||||||||||||||||||||
| 1403 | if (!event)
| 0 | ||||||||||||||||||||||||||||||
| 1404 | return this; never executed: return this; | 0 | ||||||||||||||||||||||||||||||
| 1405 | - | |||||||||||||||||||||||||||||||
| 1406 | m_device = QQuickPointerDevice::touchDevice(ev->device()); | - | ||||||||||||||||||||||||||||||
| 1407 | m_device->eventDeliveryTargets().clear(); | - | ||||||||||||||||||||||||||||||
| 1408 | Qt::TouchPointState state = Qt::TouchPointMoved; | - | ||||||||||||||||||||||||||||||
| 1409 | switch (type()) { | - | ||||||||||||||||||||||||||||||
| 1410 | case Qt::BeginNativeGesture: never executed: case Qt::BeginNativeGesture: | 0 | ||||||||||||||||||||||||||||||
| 1411 | state = Qt::TouchPointPressed; | - | ||||||||||||||||||||||||||||||
| 1412 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1413 | case Qt::EndNativeGesture: never executed: case Qt::EndNativeGesture: | 0 | ||||||||||||||||||||||||||||||
| 1414 | state = Qt::TouchPointReleased; | - | ||||||||||||||||||||||||||||||
| 1415 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1416 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 1417 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1418 | } | - | ||||||||||||||||||||||||||||||
| 1419 | quint64 deviceId = QTouchDevicePrivate::get(const_cast<QTouchDevice *>(ev->device()))->id; // a bit roundabout since QTouchDevice::mTouchDeviceId is protected | - | ||||||||||||||||||||||||||||||
| 1420 | m_point->reset(state, ev->windowPos(), deviceId << 24, ev->timestamp()); | - | ||||||||||||||||||||||||||||||
| 1421 | return this; never executed: return this; | 0 | ||||||||||||||||||||||||||||||
| 1422 | } | - | ||||||||||||||||||||||||||||||
| 1423 | #endif // QT_CONFIG(gestures) | - | ||||||||||||||||||||||||||||||
| 1424 | - | |||||||||||||||||||||||||||||||
| 1425 | QQuickEventPoint *QQuickSinglePointEvent::point(int i) const | - | ||||||||||||||||||||||||||||||
| 1426 | { | - | ||||||||||||||||||||||||||||||
| 1427 | if (i == 0)
| 0-67397 | ||||||||||||||||||||||||||||||
| 1428 | return m_point; executed 67397 times by 17 tests: return m_point;Executed by:
| 67397 | ||||||||||||||||||||||||||||||
| 1429 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||||||||
| 1430 | } | - | ||||||||||||||||||||||||||||||
| 1431 | - | |||||||||||||||||||||||||||||||
| 1432 | QQuickPointerEvent *QQuickPointerScrollEvent::reset(QEvent *event) | - | ||||||||||||||||||||||||||||||
| 1433 | { | - | ||||||||||||||||||||||||||||||
| 1434 | m_event = static_cast<QInputEvent*>(event); | - | ||||||||||||||||||||||||||||||
| 1435 | if (!event)
| 10 | ||||||||||||||||||||||||||||||
| 1436 | return this; executed 10 times by 2 tests: return this;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 1437 | #if QT_CONFIG(wheelevent) | - | ||||||||||||||||||||||||||||||
| 1438 | if (event->type() == QEvent::Wheel) {
| 0-10 | ||||||||||||||||||||||||||||||
| 1439 | auto ev = static_cast<QWheelEvent*>(event); | - | ||||||||||||||||||||||||||||||
| 1440 | m_device = QQuickPointerDevice::genericMouseDevice(); | - | ||||||||||||||||||||||||||||||
| 1441 | m_device->eventDeliveryTargets().clear(); | - | ||||||||||||||||||||||||||||||
| 1442 | // m_button = Qt::NoButton; | - | ||||||||||||||||||||||||||||||
| 1443 | m_pressedButtons = ev->buttons(); | - | ||||||||||||||||||||||||||||||
| 1444 | m_angleDelta = QVector2D(ev->angleDelta()); | - | ||||||||||||||||||||||||||||||
| 1445 | m_pixelDelta = QVector2D(ev->pixelDelta()); | - | ||||||||||||||||||||||||||||||
| 1446 | m_phase = ev->phase(); | - | ||||||||||||||||||||||||||||||
| 1447 | m_synthSource = ev->source(); | - | ||||||||||||||||||||||||||||||
| 1448 | m_inverted = ev->inverted(); | - | ||||||||||||||||||||||||||||||
| 1449 | - | |||||||||||||||||||||||||||||||
| 1450 | m_point->reset(Qt::TouchPointMoved, ev->posF(), quint64(1) << 24, ev->timestamp()); // mouse has device ID 1 | - | ||||||||||||||||||||||||||||||
| 1451 | } executed 10 times by 2 tests: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 1452 | #endif | - | ||||||||||||||||||||||||||||||
| 1453 | // TODO else if (event->type() == QEvent::Scroll) ... | - | ||||||||||||||||||||||||||||||
| 1454 | return this; executed 10 times by 2 tests: return this;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 1455 | } | - | ||||||||||||||||||||||||||||||
| 1456 | - | |||||||||||||||||||||||||||||||
| 1457 | void QQuickPointerScrollEvent::localize(QQuickItem *target) | - | ||||||||||||||||||||||||||||||
| 1458 | { | - | ||||||||||||||||||||||||||||||
| 1459 | m_point->localizePosition(target); | - | ||||||||||||||||||||||||||||||
| 1460 | } executed 10 times by 2 tests: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 1461 | - | |||||||||||||||||||||||||||||||
| 1462 | QQuickEventPoint *QQuickPointerTouchEvent::point(int i) const | - | ||||||||||||||||||||||||||||||
| 1463 | { | - | ||||||||||||||||||||||||||||||
| 1464 | if (i >= 0 && i < m_pointCount)
| 0-17254 | ||||||||||||||||||||||||||||||
| 1465 | return m_touchPoints.at(i); executed 17254 times by 10 tests: return m_touchPoints.at(i);Executed by:
| 17254 | ||||||||||||||||||||||||||||||
| 1466 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||||||||
| 1467 | } | - | ||||||||||||||||||||||||||||||
| 1468 | - | |||||||||||||||||||||||||||||||
| 1469 | QQuickEventPoint::QQuickEventPoint(QQuickPointerEvent *parent) | - | ||||||||||||||||||||||||||||||
| 1470 | : QObject(parent), m_pointId(0), m_exclusiveGrabber(nullptr), m_timestamp(0), m_pressTimestamp(0), | - | ||||||||||||||||||||||||||||||
| 1471 | m_state(QQuickEventPoint::Released), m_accept(false), m_grabberIsHandler(false) | - | ||||||||||||||||||||||||||||||
| 1472 | { | - | ||||||||||||||||||||||||||||||
| 1473 | Q_UNUSED(m_reserved); | - | ||||||||||||||||||||||||||||||
| 1474 | } executed 808 times by 18 tests: end of blockExecuted by:
| 808 | ||||||||||||||||||||||||||||||
| 1475 | - | |||||||||||||||||||||||||||||||
| 1476 | QQuickPointerEvent *QQuickEventPoint::pointerEvent() const | - | ||||||||||||||||||||||||||||||
| 1477 | { | - | ||||||||||||||||||||||||||||||
| 1478 | return static_cast<QQuickPointerEvent *>(parent()); executed 2017 times by 4 tests: return static_cast<QQuickPointerEvent *>(parent());Executed by:
| 2017 | ||||||||||||||||||||||||||||||
| 1479 | } | - | ||||||||||||||||||||||||||||||
| 1480 | - | |||||||||||||||||||||||||||||||
| 1481 | bool QQuickSinglePointEvent::allPointsAccepted() const | - | ||||||||||||||||||||||||||||||
| 1482 | { | - | ||||||||||||||||||||||||||||||
| 1483 | return m_point->isAccepted(); executed 8218 times by 14 tests: return m_point->isAccepted();Executed by:
| 8218 | ||||||||||||||||||||||||||||||
| 1484 | } | - | ||||||||||||||||||||||||||||||
| 1485 | - | |||||||||||||||||||||||||||||||
| 1486 | bool QQuickSinglePointEvent::allUpdatedPointsAccepted() const | - | ||||||||||||||||||||||||||||||
| 1487 | { | - | ||||||||||||||||||||||||||||||
| 1488 | return m_point->state() == QQuickEventPoint::Pressed || m_point->isAccepted(); never executed: return m_point->state() == QQuickEventPoint::Pressed || m_point->isAccepted(); | 0 | ||||||||||||||||||||||||||||||
| 1489 | } | - | ||||||||||||||||||||||||||||||
| 1490 | - | |||||||||||||||||||||||||||||||
| 1491 | bool QQuickSinglePointEvent::allPointsGrabbed() const | - | ||||||||||||||||||||||||||||||
| 1492 | { | - | ||||||||||||||||||||||||||||||
| 1493 | return m_point->exclusiveGrabber() != nullptr; executed 1784 times by 16 tests: return m_point->exclusiveGrabber() != nullptr;Executed by:
| 1784 | ||||||||||||||||||||||||||||||
| 1494 | } | - | ||||||||||||||||||||||||||||||
| 1495 | - | |||||||||||||||||||||||||||||||
| 1496 | QMouseEvent *QQuickPointerMouseEvent::asMouseEvent(const QPointF &localPos) const | - | ||||||||||||||||||||||||||||||
| 1497 | { | - | ||||||||||||||||||||||||||||||
| 1498 | auto event = static_cast<QMouseEvent *>(m_event); | - | ||||||||||||||||||||||||||||||
| 1499 | event->setLocalPos(localPos); | - | ||||||||||||||||||||||||||||||
| 1500 | return event; executed 9770 times by 14 tests: return event;Executed by:
| 9770 | ||||||||||||||||||||||||||||||
| 1501 | } | - | ||||||||||||||||||||||||||||||
| 1502 | - | |||||||||||||||||||||||||||||||
| 1503 | /*! | - | ||||||||||||||||||||||||||||||
| 1504 | Returns the exclusive grabber of this event, if any, in a vector. | - | ||||||||||||||||||||||||||||||
| 1505 | */ | - | ||||||||||||||||||||||||||||||
| 1506 | QVector<QObject *> QQuickSinglePointEvent::exclusiveGrabbers() const | - | ||||||||||||||||||||||||||||||
| 1507 | { | - | ||||||||||||||||||||||||||||||
| 1508 | QVector<QObject *> result; | - | ||||||||||||||||||||||||||||||
| 1509 | if (QObject *grabber = m_point->exclusiveGrabber())
| 0 | ||||||||||||||||||||||||||||||
| 1510 | result << grabber; never executed: result << grabber; | 0 | ||||||||||||||||||||||||||||||
| 1511 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||||||||
| 1512 | } | - | ||||||||||||||||||||||||||||||
| 1513 | - | |||||||||||||||||||||||||||||||
| 1514 | /*! | - | ||||||||||||||||||||||||||||||
| 1515 | Remove all passive and exclusive grabbers of this event, without notifying. | - | ||||||||||||||||||||||||||||||
| 1516 | */ | - | ||||||||||||||||||||||||||||||
| 1517 | void QQuickSinglePointEvent::clearGrabbers() const | - | ||||||||||||||||||||||||||||||
| 1518 | { | - | ||||||||||||||||||||||||||||||
| 1519 | m_point->setGrabberItem(nullptr); | - | ||||||||||||||||||||||||||||||
| 1520 | m_point->clearPassiveGrabbers(); | - | ||||||||||||||||||||||||||||||
| 1521 | } executed 1706 times by 14 tests: end of blockExecuted by:
| 1706 | ||||||||||||||||||||||||||||||
| 1522 | - | |||||||||||||||||||||||||||||||
| 1523 | /*! | - | ||||||||||||||||||||||||||||||
| 1524 | Returns whether the given \a handler is the exclusive grabber of this event. | - | ||||||||||||||||||||||||||||||
| 1525 | */ | - | ||||||||||||||||||||||||||||||
| 1526 | bool QQuickSinglePointEvent::hasExclusiveGrabber(const QQuickPointerHandler *handler) const | - | ||||||||||||||||||||||||||||||
| 1527 | { | - | ||||||||||||||||||||||||||||||
| 1528 | return handler && (m_point->exclusiveGrabber() == handler); executed 124 times by 4 tests: return handler && (m_point->exclusiveGrabber() == handler);Executed by:
| 124 | ||||||||||||||||||||||||||||||
| 1529 | } | - | ||||||||||||||||||||||||||||||
| 1530 | - | |||||||||||||||||||||||||||||||
| 1531 | bool QQuickPointerMouseEvent::isPressEvent() const | - | ||||||||||||||||||||||||||||||
| 1532 | { | - | ||||||||||||||||||||||||||||||
| 1533 | auto me = static_cast<QMouseEvent*>(m_event); | - | ||||||||||||||||||||||||||||||
| 1534 | return ((me->type() == QEvent::MouseButtonPress || me->type() == QEvent::MouseButtonDblClick) && executed 5686 times by 16 tests: return ((me->type() == QEvent::MouseButtonPress || me->type() == QEvent::MouseButtonDblClick) && (me->buttons() & me->button()) == me->buttons());Executed by:
| 5686 | ||||||||||||||||||||||||||||||
| 1535 | (me->buttons() & me->button()) == me->buttons()); executed 5686 times by 16 tests: return ((me->type() == QEvent::MouseButtonPress || me->type() == QEvent::MouseButtonDblClick) && (me->buttons() & me->button()) == me->buttons());Executed by:
| 5686 | ||||||||||||||||||||||||||||||
| 1536 | } | - | ||||||||||||||||||||||||||||||
| 1537 | - | |||||||||||||||||||||||||||||||
| 1538 | bool QQuickPointerMouseEvent::isDoubleClickEvent() const | - | ||||||||||||||||||||||||||||||
| 1539 | { | - | ||||||||||||||||||||||||||||||
| 1540 | auto me = static_cast<QMouseEvent*>(m_event); | - | ||||||||||||||||||||||||||||||
| 1541 | return (me->type() == QEvent::MouseButtonDblClick); executed 2245 times by 14 tests: return (me->type() == QEvent::MouseButtonDblClick);Executed by:
| 2245 | ||||||||||||||||||||||||||||||
| 1542 | } | - | ||||||||||||||||||||||||||||||
| 1543 | - | |||||||||||||||||||||||||||||||
| 1544 | bool QQuickPointerMouseEvent::isUpdateEvent() const | - | ||||||||||||||||||||||||||||||
| 1545 | { | - | ||||||||||||||||||||||||||||||
| 1546 | auto me = static_cast<QMouseEvent*>(m_event); | - | ||||||||||||||||||||||||||||||
| 1547 | return me->type() == QEvent::MouseMove; never executed: return me->type() == QEvent::MouseMove; | 0 | ||||||||||||||||||||||||||||||
| 1548 | } | - | ||||||||||||||||||||||||||||||
| 1549 | - | |||||||||||||||||||||||||||||||
| 1550 | bool QQuickPointerMouseEvent::isReleaseEvent() const | - | ||||||||||||||||||||||||||||||
| 1551 | { | - | ||||||||||||||||||||||||||||||
| 1552 | auto me = static_cast<QMouseEvent*>(m_event); | - | ||||||||||||||||||||||||||||||
| 1553 | return me && me->type() == QEvent::MouseButtonRelease; executed 12139 times by 16 tests: return me && me->type() == QEvent::MouseButtonRelease;Executed by:
| 12139 | ||||||||||||||||||||||||||||||
| 1554 | } | - | ||||||||||||||||||||||||||||||
| 1555 | - | |||||||||||||||||||||||||||||||
| 1556 | bool QQuickPointerTouchEvent::allPointsAccepted() const | - | ||||||||||||||||||||||||||||||
| 1557 | { | - | ||||||||||||||||||||||||||||||
| 1558 | for (int i = 0; i < m_pointCount; ++i) {
| 1773-6174 | ||||||||||||||||||||||||||||||
| 1559 | if (!m_touchPoints.at(i)->isAccepted())
| 3029-3145 | ||||||||||||||||||||||||||||||
| 1560 | return false; executed 3145 times by 10 tests: return false;Executed by:
| 3145 | ||||||||||||||||||||||||||||||
| 1561 | } executed 3029 times by 10 tests: end of blockExecuted by:
| 3029 | ||||||||||||||||||||||||||||||
| 1562 | return true; executed 1773 times by 10 tests: return true;Executed by:
| 1773 | ||||||||||||||||||||||||||||||
| 1563 | } | - | ||||||||||||||||||||||||||||||
| 1564 | - | |||||||||||||||||||||||||||||||
| 1565 | bool QQuickPointerTouchEvent::allUpdatedPointsAccepted() const | - | ||||||||||||||||||||||||||||||
| 1566 | { | - | ||||||||||||||||||||||||||||||
| 1567 | for (int i = 0; i < m_pointCount; ++i) {
| 264-1344 | ||||||||||||||||||||||||||||||
| 1568 | auto point = m_touchPoints.at(i); | - | ||||||||||||||||||||||||||||||
| 1569 | if (point->state() != QQuickEventPoint::Pressed && !point->isAccepted())
| 72-1028 | ||||||||||||||||||||||||||||||
| 1570 | return false; executed 956 times by 10 tests: return false;Executed by:
| 956 | ||||||||||||||||||||||||||||||
| 1571 | } executed 388 times by 10 tests: end of blockExecuted by:
| 388 | ||||||||||||||||||||||||||||||
| 1572 | return true; executed 264 times by 10 tests: return true;Executed by:
| 264 | ||||||||||||||||||||||||||||||
| 1573 | } | - | ||||||||||||||||||||||||||||||
| 1574 | - | |||||||||||||||||||||||||||||||
| 1575 | bool QQuickPointerTouchEvent::allPointsGrabbed() const | - | ||||||||||||||||||||||||||||||
| 1576 | { | - | ||||||||||||||||||||||||||||||
| 1577 | for (int i = 0; i < m_pointCount; ++i) {
| 630-3990 | ||||||||||||||||||||||||||||||
| 1578 | if (!m_touchPoints.at(i)->exclusiveGrabber())
| 1124-2866 | ||||||||||||||||||||||||||||||
| 1579 | return false; executed 2866 times by 9 tests: return false;Executed by:
| 2866 | ||||||||||||||||||||||||||||||
| 1580 | } executed 1124 times by 10 tests: end of blockExecuted by:
| 1124 | ||||||||||||||||||||||||||||||
| 1581 | return true; executed 630 times by 10 tests: return true;Executed by:
| 630 | ||||||||||||||||||||||||||||||
| 1582 | } | - | ||||||||||||||||||||||||||||||
| 1583 | - | |||||||||||||||||||||||||||||||
| 1584 | /*! | - | ||||||||||||||||||||||||||||||
| 1585 | Returns the exclusive grabbers of all points in this event, if any, in a vector. | - | ||||||||||||||||||||||||||||||
| 1586 | */ | - | ||||||||||||||||||||||||||||||
| 1587 | QVector<QObject *> QQuickPointerTouchEvent::exclusiveGrabbers() const | - | ||||||||||||||||||||||||||||||
| 1588 | { | - | ||||||||||||||||||||||||||||||
| 1589 | QVector<QObject *> result; | - | ||||||||||||||||||||||||||||||
| 1590 | for (int i = 0; i < m_pointCount; ++i) {
| 1312-2116 | ||||||||||||||||||||||||||||||
| 1591 | if (QObject *grabber = m_touchPoints.at(i)->exclusiveGrabber()) {
| 780-1336 | ||||||||||||||||||||||||||||||
| 1592 | if (!result.contains(grabber))
| 288-1048 | ||||||||||||||||||||||||||||||
| 1593 | result << grabber; executed 1048 times by 10 tests: result << grabber;Executed by:
| 1048 | ||||||||||||||||||||||||||||||
| 1594 | } executed 1336 times by 10 tests: end of blockExecuted by:
| 1336 | ||||||||||||||||||||||||||||||
| 1595 | } executed 2116 times by 10 tests: end of blockExecuted by:
| 2116 | ||||||||||||||||||||||||||||||
| 1596 | return result; executed 1312 times by 10 tests: return result;Executed by:
| 1312 | ||||||||||||||||||||||||||||||
| 1597 | } | - | ||||||||||||||||||||||||||||||
| 1598 | - | |||||||||||||||||||||||||||||||
| 1599 | /*! | - | ||||||||||||||||||||||||||||||
| 1600 | Remove all passive and exclusive grabbers of all touchpoints in this event, | - | ||||||||||||||||||||||||||||||
| 1601 | without notifying. | - | ||||||||||||||||||||||||||||||
| 1602 | */ | - | ||||||||||||||||||||||||||||||
| 1603 | void QQuickPointerTouchEvent::clearGrabbers() const | - | ||||||||||||||||||||||||||||||
| 1604 | { | - | ||||||||||||||||||||||||||||||
| 1605 | for (auto point: m_touchPoints) { | - | ||||||||||||||||||||||||||||||
| 1606 | point->setGrabberItem(nullptr); | - | ||||||||||||||||||||||||||||||
| 1607 | point->clearPassiveGrabbers(); | - | ||||||||||||||||||||||||||||||
| 1608 | } executed 304 times by 10 tests: end of blockExecuted by:
| 304 | ||||||||||||||||||||||||||||||
| 1609 | } executed 186 times by 10 tests: end of blockExecuted by:
| 186 | ||||||||||||||||||||||||||||||
| 1610 | - | |||||||||||||||||||||||||||||||
| 1611 | Qt::TouchPointStates QQuickPointerTouchEvent::touchPointStates() const | - | ||||||||||||||||||||||||||||||
| 1612 | { | - | ||||||||||||||||||||||||||||||
| 1613 | return m_event executed 4949 times by 10 tests: return m_event ? static_cast<QTouchEvent*>(m_event)->touchPointStates() : Qt::TouchPointStates();Executed by:
| 4949 | ||||||||||||||||||||||||||||||
| 1614 | ? static_cast<QTouchEvent*>(m_event)->touchPointStates() executed 4949 times by 10 tests: return m_event ? static_cast<QTouchEvent*>(m_event)->touchPointStates() : Qt::TouchPointStates();Executed by:
| 4949 | ||||||||||||||||||||||||||||||
| 1615 | : Qt::TouchPointStates(); executed 4949 times by 10 tests: return m_event ? static_cast<QTouchEvent*>(m_event)->touchPointStates() : Qt::TouchPointStates();Executed by:
| 4949 | ||||||||||||||||||||||||||||||
| 1616 | } | - | ||||||||||||||||||||||||||||||
| 1617 | - | |||||||||||||||||||||||||||||||
| 1618 | /*! | - | ||||||||||||||||||||||||||||||
| 1619 | Returns whether the given \a handler is the exclusive grabber of any | - | ||||||||||||||||||||||||||||||
| 1620 | touchpoint within this event. | - | ||||||||||||||||||||||||||||||
| 1621 | */ | - | ||||||||||||||||||||||||||||||
| 1622 | bool QQuickPointerTouchEvent::hasExclusiveGrabber(const QQuickPointerHandler *handler) const | - | ||||||||||||||||||||||||||||||
| 1623 | { | - | ||||||||||||||||||||||||||||||
| 1624 | for (auto point: m_touchPoints) | - | ||||||||||||||||||||||||||||||
| 1625 | if (point->exclusiveGrabber() == handler)
| 58-2416 | ||||||||||||||||||||||||||||||
| 1626 | return true; executed 58 times by 3 tests: return true;Executed by:
| 58 | ||||||||||||||||||||||||||||||
| 1627 | return false; executed 1370 times by 5 tests: return false;Executed by:
| 1370 | ||||||||||||||||||||||||||||||
| 1628 | } | - | ||||||||||||||||||||||||||||||
| 1629 | - | |||||||||||||||||||||||||||||||
| 1630 | bool QQuickPointerTouchEvent::isPressEvent() const | - | ||||||||||||||||||||||||||||||
| 1631 | { | - | ||||||||||||||||||||||||||||||
| 1632 | return touchPointStates() & Qt::TouchPointPressed; executed 1757 times by 10 tests: return touchPointStates() & Qt::TouchPointPressed;Executed by:
| 1757 | ||||||||||||||||||||||||||||||
| 1633 | } | - | ||||||||||||||||||||||||||||||
| 1634 | - | |||||||||||||||||||||||||||||||
| 1635 | bool QQuickPointerTouchEvent::isUpdateEvent() const | - | ||||||||||||||||||||||||||||||
| 1636 | { | - | ||||||||||||||||||||||||||||||
| 1637 | return touchPointStates() & (Qt::TouchPointMoved | Qt::TouchPointStationary); executed 204 times by 10 tests: return touchPointStates() & (Qt::TouchPointMoved | Qt::TouchPointStationary);Executed by:
| 204 | ||||||||||||||||||||||||||||||
| 1638 | } | - | ||||||||||||||||||||||||||||||
| 1639 | - | |||||||||||||||||||||||||||||||
| 1640 | bool QQuickPointerTouchEvent::isReleaseEvent() const | - | ||||||||||||||||||||||||||||||
| 1641 | { | - | ||||||||||||||||||||||||||||||
| 1642 | return touchPointStates() & Qt::TouchPointReleased; executed 2988 times by 10 tests: return touchPointStates() & Qt::TouchPointReleased;Executed by:
| 2988 | ||||||||||||||||||||||||||||||
| 1643 | } | - | ||||||||||||||||||||||||||||||
| 1644 | - | |||||||||||||||||||||||||||||||
| 1645 | QVector<QPointF> QQuickPointerEvent::unacceptedPressedPointScenePositions() const | - | ||||||||||||||||||||||||||||||
| 1646 | { | - | ||||||||||||||||||||||||||||||
| 1647 | QVector<QPointF> points; | - | ||||||||||||||||||||||||||||||
| 1648 | for (int i = 0; i < pointCount(); ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 1649 | if (!point(i)->isAccepted() && point(i)->state() == QQuickEventPoint::Pressed)
| 0 | ||||||||||||||||||||||||||||||
| 1650 | points << point(i)->scenePosition(); never executed: points << point(i)->scenePosition(); | 0 | ||||||||||||||||||||||||||||||
| 1651 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1652 | return points; never executed: return points; | 0 | ||||||||||||||||||||||||||||||
| 1653 | } | - | ||||||||||||||||||||||||||||||
| 1654 | - | |||||||||||||||||||||||||||||||
| 1655 | /*! | - | ||||||||||||||||||||||||||||||
| 1656 | \internal | - | ||||||||||||||||||||||||||||||
| 1657 | Populate the reusable synth-mouse event from one touchpoint. | - | ||||||||||||||||||||||||||||||
| 1658 | It's required that isTouchEvent() be true when this is called. | - | ||||||||||||||||||||||||||||||
| 1659 | If the touchpoint cannot be found, this returns nullptr. | - | ||||||||||||||||||||||||||||||
| 1660 | Ownership of the event is NOT transferred to the caller. | - | ||||||||||||||||||||||||||||||
| 1661 | */ | - | ||||||||||||||||||||||||||||||
| 1662 | QMouseEvent *QQuickPointerTouchEvent::syntheticMouseEvent(int pointID, QQuickItem *relativeTo) const | - | ||||||||||||||||||||||||||||||
| 1663 | { | - | ||||||||||||||||||||||||||||||
| 1664 | const QTouchEvent::TouchPoint *p = touchPointById(pointID); | - | ||||||||||||||||||||||||||||||
| 1665 | if (!p)
| 0 | ||||||||||||||||||||||||||||||
| 1666 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||||||||
| 1667 | QEvent::Type type; | - | ||||||||||||||||||||||||||||||
| 1668 | Qt::MouseButton buttons = Qt::LeftButton; | - | ||||||||||||||||||||||||||||||
| 1669 | switch (p->state()) { | - | ||||||||||||||||||||||||||||||
| 1670 | case Qt::TouchPointPressed: never executed: case Qt::TouchPointPressed: | 0 | ||||||||||||||||||||||||||||||
| 1671 | type = QEvent::MouseButtonPress; | - | ||||||||||||||||||||||||||||||
| 1672 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1673 | case Qt::TouchPointMoved: never executed: case Qt::TouchPointMoved: | 0 | ||||||||||||||||||||||||||||||
| 1674 | case Qt::TouchPointStationary: never executed: case Qt::TouchPointStationary: | 0 | ||||||||||||||||||||||||||||||
| 1675 | type = QEvent::MouseMove; | - | ||||||||||||||||||||||||||||||
| 1676 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1677 | case Qt::TouchPointReleased: never executed: case Qt::TouchPointReleased: | 0 | ||||||||||||||||||||||||||||||
| 1678 | type = QEvent::MouseButtonRelease; | - | ||||||||||||||||||||||||||||||
| 1679 | buttons = Qt::NoButton; | - | ||||||||||||||||||||||||||||||
| 1680 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1681 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 1682 | Q_ASSERT(false); | - | ||||||||||||||||||||||||||||||
| 1683 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||||||||
| 1684 | } | - | ||||||||||||||||||||||||||||||
| 1685 | m_synthMouseEvent = QMouseEvent(type, relativeTo->mapFromScene(p->scenePos()), | - | ||||||||||||||||||||||||||||||
| 1686 | p->scenePos(), p->screenPos(), Qt::LeftButton, buttons, m_event->modifiers()); | - | ||||||||||||||||||||||||||||||
| 1687 | m_synthMouseEvent.setAccepted(true); | - | ||||||||||||||||||||||||||||||
| 1688 | m_synthMouseEvent.setTimestamp(m_event->timestamp()); | - | ||||||||||||||||||||||||||||||
| 1689 | // In the future we will try to always have valid velocity in every QQuickEventPoint. | - | ||||||||||||||||||||||||||||||
| 1690 | // QQuickFlickablePrivate::handleMouseMoveEvent() checks for QTouchDevice::Velocity | - | ||||||||||||||||||||||||||||||
| 1691 | // and if it is set, then it does not need to do its own velocity calculations. | - | ||||||||||||||||||||||||||||||
| 1692 | // That's probably the only usecase for this, so far. Some day Flickable should handle | - | ||||||||||||||||||||||||||||||
| 1693 | // pointer events, and then passing touchpoint velocity via QMouseEvent will be obsolete. | - | ||||||||||||||||||||||||||||||
| 1694 | // Conveniently (by design), QTouchDevice::Velocity == QQuickPointerDevice.Velocity | - | ||||||||||||||||||||||||||||||
| 1695 | // so that we don't need to convert m_device->capabilities(). | - | ||||||||||||||||||||||||||||||
| 1696 | if (m_device)
| 0 | ||||||||||||||||||||||||||||||
| 1697 | QGuiApplicationPrivate::setMouseEventCapsAndVelocity(&m_synthMouseEvent, m_device->capabilities(), p->velocity()); never executed: QGuiApplicationPrivate::setMouseEventCapsAndVelocity(&m_synthMouseEvent, m_device->capabilities(), p->velocity()); | 0 | ||||||||||||||||||||||||||||||
| 1698 | QGuiApplicationPrivate::setMouseEventSource(&m_synthMouseEvent, Qt::MouseEventSynthesizedByQt); | - | ||||||||||||||||||||||||||||||
| 1699 | return &m_synthMouseEvent; never executed: return &m_synthMouseEvent; | 0 | ||||||||||||||||||||||||||||||
| 1700 | } | - | ||||||||||||||||||||||||||||||
| 1701 | - | |||||||||||||||||||||||||||||||
| 1702 | #if QT_CONFIG(gestures) | - | ||||||||||||||||||||||||||||||
| 1703 | bool QQuickPointerNativeGestureEvent::isPressEvent() const | - | ||||||||||||||||||||||||||||||
| 1704 | { | - | ||||||||||||||||||||||||||||||
| 1705 | return type() == Qt::BeginNativeGesture; never executed: return type() == Qt::BeginNativeGesture; | 0 | ||||||||||||||||||||||||||||||
| 1706 | } | - | ||||||||||||||||||||||||||||||
| 1707 | - | |||||||||||||||||||||||||||||||
| 1708 | bool QQuickPointerNativeGestureEvent::isUpdateEvent() const | - | ||||||||||||||||||||||||||||||
| 1709 | { | - | ||||||||||||||||||||||||||||||
| 1710 | switch (type()) { | - | ||||||||||||||||||||||||||||||
| 1711 | case Qt::BeginNativeGesture: never executed: case Qt::BeginNativeGesture: | 0 | ||||||||||||||||||||||||||||||
| 1712 | case Qt::EndNativeGesture: never executed: case Qt::EndNativeGesture: | 0 | ||||||||||||||||||||||||||||||
| 1713 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 1714 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 1715 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 1716 | } | - | ||||||||||||||||||||||||||||||
| 1717 | } | - | ||||||||||||||||||||||||||||||
| 1718 | - | |||||||||||||||||||||||||||||||
| 1719 | bool QQuickPointerNativeGestureEvent::isReleaseEvent() const | - | ||||||||||||||||||||||||||||||
| 1720 | { | - | ||||||||||||||||||||||||||||||
| 1721 | return type() == Qt::EndNativeGesture; never executed: return type() == Qt::EndNativeGesture; | 0 | ||||||||||||||||||||||||||||||
| 1722 | } | - | ||||||||||||||||||||||||||||||
| 1723 | - | |||||||||||||||||||||||||||||||
| 1724 | Qt::NativeGestureType QQuickPointerNativeGestureEvent::type() const | - | ||||||||||||||||||||||||||||||
| 1725 | { | - | ||||||||||||||||||||||||||||||
| 1726 | return static_cast<QNativeGestureEvent *>(m_event)->gestureType(); never executed: return static_cast<QNativeGestureEvent *>(m_event)->gestureType(); | 0 | ||||||||||||||||||||||||||||||
| 1727 | } | - | ||||||||||||||||||||||||||||||
| 1728 | - | |||||||||||||||||||||||||||||||
| 1729 | qreal QQuickPointerNativeGestureEvent::value() const | - | ||||||||||||||||||||||||||||||
| 1730 | { | - | ||||||||||||||||||||||||||||||
| 1731 | return static_cast<QNativeGestureEvent *>(m_event)->value(); never executed: return static_cast<QNativeGestureEvent *>(m_event)->value(); | 0 | ||||||||||||||||||||||||||||||
| 1732 | } | - | ||||||||||||||||||||||||||||||
| 1733 | #endif // QT_CONFIG(gestures) | - | ||||||||||||||||||||||||||||||
| 1734 | - | |||||||||||||||||||||||||||||||
| 1735 | /*! | - | ||||||||||||||||||||||||||||||
| 1736 | Returns whether the scroll event has Qt::ScrollBegin phase. On touchpads | - | ||||||||||||||||||||||||||||||
| 1737 | which provide phase information, this is true when the fingers are placed | - | ||||||||||||||||||||||||||||||
| 1738 | on the touchpad and scrolling begins. On other devices where this | - | ||||||||||||||||||||||||||||||
| 1739 | information is not available, it remains false. | - | ||||||||||||||||||||||||||||||
| 1740 | */ | - | ||||||||||||||||||||||||||||||
| 1741 | bool QQuickPointerScrollEvent::isPressEvent() const | - | ||||||||||||||||||||||||||||||
| 1742 | { | - | ||||||||||||||||||||||||||||||
| 1743 | return phase() == Qt::ScrollBegin; never executed: return phase() == Qt::ScrollBegin; | 0 | ||||||||||||||||||||||||||||||
| 1744 | } | - | ||||||||||||||||||||||||||||||
| 1745 | - | |||||||||||||||||||||||||||||||
| 1746 | /*! | - | ||||||||||||||||||||||||||||||
| 1747 | Returns true when the scroll event has Qt::ScrollUpdate phase, or when the | - | ||||||||||||||||||||||||||||||
| 1748 | phase is unknown. Some multi-touch-capable touchpads and trackpads provide | - | ||||||||||||||||||||||||||||||
| 1749 | phase information; whereas ordinary mouse wheels and other types of | - | ||||||||||||||||||||||||||||||
| 1750 | trackpads do not, and in such cases this is always true. | - | ||||||||||||||||||||||||||||||
| 1751 | */ | - | ||||||||||||||||||||||||||||||
| 1752 | bool QQuickPointerScrollEvent::isUpdateEvent() const | - | ||||||||||||||||||||||||||||||
| 1753 | { | - | ||||||||||||||||||||||||||||||
| 1754 | return phase() == Qt::ScrollUpdate || phase() == Qt::NoScrollPhase; never executed: return phase() == Qt::ScrollUpdate || phase() == Qt::NoScrollPhase; | 0 | ||||||||||||||||||||||||||||||
| 1755 | } | - | ||||||||||||||||||||||||||||||
| 1756 | - | |||||||||||||||||||||||||||||||
| 1757 | /*! | - | ||||||||||||||||||||||||||||||
| 1758 | Returns whether the scroll event has Qt::ScrollBegin phase. On touchpads | - | ||||||||||||||||||||||||||||||
| 1759 | which provide phase information, this is true when the fingers are lifted | - | ||||||||||||||||||||||||||||||
| 1760 | from the touchpad. On other devices where this information is not | - | ||||||||||||||||||||||||||||||
| 1761 | available, it remains false. | - | ||||||||||||||||||||||||||||||
| 1762 | */ | - | ||||||||||||||||||||||||||||||
| 1763 | bool QQuickPointerScrollEvent::isReleaseEvent() const | - | ||||||||||||||||||||||||||||||
| 1764 | { | - | ||||||||||||||||||||||||||||||
| 1765 | return phase() == Qt::ScrollEnd; never executed: return phase() == Qt::ScrollEnd; | 0 | ||||||||||||||||||||||||||||||
| 1766 | } | - | ||||||||||||||||||||||||||||||
| 1767 | - | |||||||||||||||||||||||||||||||
| 1768 | /*! | - | ||||||||||||||||||||||||||||||
| 1769 | \internal | - | ||||||||||||||||||||||||||||||
| 1770 | Returns a pointer to the QQuickEventPoint which has the \a pointId as | - | ||||||||||||||||||||||||||||||
| 1771 | \l {QQuickEventPoint::pointId}{pointId}. | - | ||||||||||||||||||||||||||||||
| 1772 | Returns nullptr if there is no point with that ID. | - | ||||||||||||||||||||||||||||||
| 1773 | - | |||||||||||||||||||||||||||||||
| 1774 | \fn QQuickPointerEvent::pointById(int pointId) const | - | ||||||||||||||||||||||||||||||
| 1775 | */ | - | ||||||||||||||||||||||||||||||
| 1776 | QQuickEventPoint *QQuickSinglePointEvent::pointById(int pointId) const | - | ||||||||||||||||||||||||||||||
| 1777 | { | - | ||||||||||||||||||||||||||||||
| 1778 | if (m_point && pointId == m_point->pointId())
| 0-246 | ||||||||||||||||||||||||||||||
| 1779 | return m_point; executed 246 times by 3 tests: return m_point;Executed by:
| 246 | ||||||||||||||||||||||||||||||
| 1780 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||||||||
| 1781 | } | - | ||||||||||||||||||||||||||||||
| 1782 | - | |||||||||||||||||||||||||||||||
| 1783 | QQuickEventPoint *QQuickPointerTouchEvent::pointById(int pointId) const | - | ||||||||||||||||||||||||||||||
| 1784 | { | - | ||||||||||||||||||||||||||||||
| 1785 | auto it = std::find_if(m_touchPoints.constBegin(), m_touchPoints.constEnd(), | - | ||||||||||||||||||||||||||||||
| 1786 | [pointId](const QQuickEventTouchPoint *tp) { return tp->pointId() == pointId; } ); executed 7133 times by 10 tests: return tp->pointId() == pointId;Executed by:
| 7133 | ||||||||||||||||||||||||||||||
| 1787 | if (it != m_touchPoints.constEnd())
| 282-4637 | ||||||||||||||||||||||||||||||
| 1788 | return *it; executed 4637 times by 10 tests: return *it;Executed by:
| 4637 | ||||||||||||||||||||||||||||||
| 1789 | return nullptr; executed 282 times by 10 tests: return nullptr;Executed by:
| 282 | ||||||||||||||||||||||||||||||
| 1790 | } | - | ||||||||||||||||||||||||||||||
| 1791 | - | |||||||||||||||||||||||||||||||
| 1792 | /*! | - | ||||||||||||||||||||||||||||||
| 1793 | \internal | - | ||||||||||||||||||||||||||||||
| 1794 | Returns a pointer to the original TouchPoint which has the same | - | ||||||||||||||||||||||||||||||
| 1795 | \l {QTouchEvent::TouchPoint::id}{id} as \a pointId, if the original event is a | - | ||||||||||||||||||||||||||||||
| 1796 | QTouchEvent, and if that point is found. Otherwise, returns nullptr. | - | ||||||||||||||||||||||||||||||
| 1797 | */ | - | ||||||||||||||||||||||||||||||
| 1798 | const QTouchEvent::TouchPoint *QQuickPointerTouchEvent::touchPointById(int pointId) const | - | ||||||||||||||||||||||||||||||
| 1799 | { | - | ||||||||||||||||||||||||||||||
| 1800 | const QTouchEvent *ev = asTouchEvent(); | - | ||||||||||||||||||||||||||||||
| 1801 | if (!ev)
| 0-1722 | ||||||||||||||||||||||||||||||
| 1802 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||||||||
| 1803 | const QList<QTouchEvent::TouchPoint> &tps = ev->touchPoints(); | - | ||||||||||||||||||||||||||||||
| 1804 | auto it = std::find_if(tps.constBegin(), tps.constEnd(), | - | ||||||||||||||||||||||||||||||
| 1805 | [pointId](QTouchEvent::TouchPoint const& tp) { return tp.id() == pointId; } ); executed 2472 times by 10 tests: return tp.id() == pointId;Executed by:
| 2472 | ||||||||||||||||||||||||||||||
| 1806 | // return the pointer to the actual TP in QTouchEvent::_touchPoints | - | ||||||||||||||||||||||||||||||
| 1807 | return (it == tps.constEnd() ? nullptr : it.operator->()); executed 1722 times by 10 tests: return (it == tps.constEnd() ? nullptr : it.operator->());Executed by:
| 1722 | ||||||||||||||||||||||||||||||
| 1808 | } | - | ||||||||||||||||||||||||||||||
| 1809 | - | |||||||||||||||||||||||||||||||
| 1810 | /*! | - | ||||||||||||||||||||||||||||||
| 1811 | \internal | - | ||||||||||||||||||||||||||||||
| 1812 | Make a new QTouchEvent, giving it a subset of the original touch points. | - | ||||||||||||||||||||||||||||||
| 1813 | - | |||||||||||||||||||||||||||||||
| 1814 | Returns a nullptr if all points are stationary, or there are no points inside the item, | - | ||||||||||||||||||||||||||||||
| 1815 | or none of the points were pressed inside and the item was not grabbing any of them | - | ||||||||||||||||||||||||||||||
| 1816 | and isFiltering is false. When isFiltering is true, it is assumed that the item | - | ||||||||||||||||||||||||||||||
| 1817 | cares about all points which are inside its bounds, because most filtering items | - | ||||||||||||||||||||||||||||||
| 1818 | need to monitor eventpoint movements until a drag threshold is exceeded or the | - | ||||||||||||||||||||||||||||||
| 1819 | requirements for a gesture to be recognized are met in some other way. | - | ||||||||||||||||||||||||||||||
| 1820 | */ | - | ||||||||||||||||||||||||||||||
| 1821 | QTouchEvent *QQuickPointerTouchEvent::touchEventForItem(QQuickItem *item, bool isFiltering) const | - | ||||||||||||||||||||||||||||||
| 1822 | { | - | ||||||||||||||||||||||||||||||
| 1823 | QList<QTouchEvent::TouchPoint> touchPoints; | - | ||||||||||||||||||||||||||||||
| 1824 | Qt::TouchPointStates eventStates; | - | ||||||||||||||||||||||||||||||
| 1825 | // TODO maybe add QQuickItem::mapVector2DFromScene(QVector2D) to avoid needing QQuickItemPrivate here | - | ||||||||||||||||||||||||||||||
| 1826 | // Or else just document that velocity is always scene-relative and is not scaled and rotated with the item | - | ||||||||||||||||||||||||||||||
| 1827 | // but that would require changing tst_qquickwindow::touchEvent_velocity(): it expects transformed velocity | - | ||||||||||||||||||||||||||||||
| 1828 | - | |||||||||||||||||||||||||||||||
| 1829 | bool anyPressOrReleaseInside = false; | - | ||||||||||||||||||||||||||||||
| 1830 | bool anyGrabber = false; | - | ||||||||||||||||||||||||||||||
| 1831 | QMatrix4x4 transformMatrix(QQuickItemPrivate::get(item)->windowToItemTransform()); | - | ||||||||||||||||||||||||||||||
| 1832 | for (int i = 0; i < m_pointCount; ++i) {
| 1991-3403 | ||||||||||||||||||||||||||||||
| 1833 | auto p = m_touchPoints.at(i); | - | ||||||||||||||||||||||||||||||
| 1834 | if (p->isAccepted())
| 1049-2354 | ||||||||||||||||||||||||||||||
| 1835 | continue; executed 1049 times by 7 tests: continue;Executed by:
| 1049 | ||||||||||||||||||||||||||||||
| 1836 | // include points where item is the grabber | - | ||||||||||||||||||||||||||||||
| 1837 | bool isGrabber = p->exclusiveGrabber() == item; | - | ||||||||||||||||||||||||||||||
| 1838 | if (isGrabber)
| 922-1432 | ||||||||||||||||||||||||||||||
| 1839 | anyGrabber = true; executed 922 times by 8 tests: anyGrabber = true;Executed by:
| 922 | ||||||||||||||||||||||||||||||
| 1840 | // include points inside the bounds if no other item is the grabber or if the item is filtering | - | ||||||||||||||||||||||||||||||
| 1841 | bool isInside = item->contains(item->mapFromScene(p->scenePosition())); | - | ||||||||||||||||||||||||||||||
| 1842 | bool hasAnotherGrabber = p->exclusiveGrabber() && p->exclusiveGrabber() != item;
| 564-1486 | ||||||||||||||||||||||||||||||
| 1843 | - | |||||||||||||||||||||||||||||||
| 1844 | // filtering: (childMouseEventFilter) include points that are grabbed by children of the target item | - | ||||||||||||||||||||||||||||||
| 1845 | bool grabberIsChild = false; | - | ||||||||||||||||||||||||||||||
| 1846 | auto parent = p->grabberItem(); | - | ||||||||||||||||||||||||||||||
| 1847 | while (isFiltering && parent) {
| 214-1768 | ||||||||||||||||||||||||||||||
| 1848 | if (parent == item) {
| 54-160 | ||||||||||||||||||||||||||||||
| 1849 | grabberIsChild = true; | - | ||||||||||||||||||||||||||||||
| 1850 | break; executed 160 times by 2 tests: break;Executed by:
| 160 | ||||||||||||||||||||||||||||||
| 1851 | } | - | ||||||||||||||||||||||||||||||
| 1852 | parent = parent->parentItem(); | - | ||||||||||||||||||||||||||||||
| 1853 | } executed 54 times by 1 test: end of blockExecuted by:
| 54 | ||||||||||||||||||||||||||||||
| 1854 | - | |||||||||||||||||||||||||||||||
| 1855 | bool filterRelevant = isFiltering && grabberIsChild;
| 160-1768 | ||||||||||||||||||||||||||||||
| 1856 | if (!(isGrabber || (isInside && (!hasAnotherGrabber || isFiltering)) || filterRelevant))
| 0-1432 | ||||||||||||||||||||||||||||||
| 1857 | continue; executed 632 times by 7 tests: continue;Executed by:
| 632 | ||||||||||||||||||||||||||||||
| 1858 | if ((p->state() == QQuickEventPoint::Pressed || p->state() == QQuickEventPoint::Released) && isInside)
| 6-1294 | ||||||||||||||||||||||||||||||
| 1859 | anyPressOrReleaseInside = true; executed 674 times by 10 tests: anyPressOrReleaseInside = true;Executed by:
| 674 | ||||||||||||||||||||||||||||||
| 1860 | const QTouchEvent::TouchPoint *tp = touchPointById(p->pointId()); | - | ||||||||||||||||||||||||||||||
| 1861 | if (tp) {
| 0-1722 | ||||||||||||||||||||||||||||||
| 1862 | eventStates |= tp->state(); | - | ||||||||||||||||||||||||||||||
| 1863 | QTouchEvent::TouchPoint tpCopy = *tp; | - | ||||||||||||||||||||||||||||||
| 1864 | tpCopy.setPos(item->mapFromScene(tpCopy.scenePos())); | - | ||||||||||||||||||||||||||||||
| 1865 | tpCopy.setLastPos(item->mapFromScene(tpCopy.lastScenePos())); | - | ||||||||||||||||||||||||||||||
| 1866 | tpCopy.setStartPos(item->mapFromScene(tpCopy.startScenePos())); | - | ||||||||||||||||||||||||||||||
| 1867 | tpCopy.setRect(item->mapRectFromScene(tpCopy.sceneRect())); | - | ||||||||||||||||||||||||||||||
| 1868 | tpCopy.setVelocity(transformMatrix.mapVector(tpCopy.velocity()).toVector2D()); | - | ||||||||||||||||||||||||||||||
| 1869 | touchPoints << tpCopy; | - | ||||||||||||||||||||||||||||||
| 1870 | } executed 1722 times by 10 tests: end of blockExecuted by:
| 1722 | ||||||||||||||||||||||||||||||
| 1871 | } executed 1722 times by 10 tests: end of blockExecuted by:
| 1722 | ||||||||||||||||||||||||||||||
| 1872 | - | |||||||||||||||||||||||||||||||
| 1873 | // Now touchPoints will have only points which are inside the item. | - | ||||||||||||||||||||||||||||||
| 1874 | // But if none of them were just pressed inside, and the item has no other reason to care, ignore them anyway. | - | ||||||||||||||||||||||||||||||
| 1875 | if (eventStates == Qt::TouchPointStationary || touchPoints.isEmpty() || (!anyPressOrReleaseInside && !anyGrabber && !isFiltering))
| 2-1917 | ||||||||||||||||||||||||||||||
| 1876 | return nullptr; executed 777 times by 7 tests: return nullptr;Executed by:
| 777 | ||||||||||||||||||||||||||||||
| 1877 | - | |||||||||||||||||||||||||||||||
| 1878 | // if all points have the same state, set the event type accordingly | - | ||||||||||||||||||||||||||||||
| 1879 | const QTouchEvent &event = *asTouchEvent(); | - | ||||||||||||||||||||||||||||||
| 1880 | QEvent::Type eventType = event.type(); | - | ||||||||||||||||||||||||||||||
| 1881 | switch (eventStates) { | - | ||||||||||||||||||||||||||||||
| 1882 | case Qt::TouchPointPressed: executed 300 times by 9 tests: case Qt::TouchPointPressed:Executed by:
| 300 | ||||||||||||||||||||||||||||||
| 1883 | eventType = QEvent::TouchBegin; | - | ||||||||||||||||||||||||||||||
| 1884 | break; executed 300 times by 9 tests: break;Executed by:
| 300 | ||||||||||||||||||||||||||||||
| 1885 | case Qt::TouchPointReleased: executed 178 times by 9 tests: case Qt::TouchPointReleased:Executed by:
| 178 | ||||||||||||||||||||||||||||||
| 1886 | eventType = QEvent::TouchEnd; | - | ||||||||||||||||||||||||||||||
| 1887 | break; executed 178 times by 9 tests: break;Executed by:
| 178 | ||||||||||||||||||||||||||||||
| 1888 | default: executed 736 times by 8 tests: default:Executed by:
| 736 | ||||||||||||||||||||||||||||||
| 1889 | eventType = QEvent::TouchUpdate; | - | ||||||||||||||||||||||||||||||
| 1890 | break; executed 736 times by 8 tests: break;Executed by:
| 736 | ||||||||||||||||||||||||||||||
| 1891 | } | - | ||||||||||||||||||||||||||||||
| 1892 | - | |||||||||||||||||||||||||||||||
| 1893 | QTouchEvent *touchEvent = new QTouchEvent(eventType); | - | ||||||||||||||||||||||||||||||
| 1894 | touchEvent->setWindow(event.window()); | - | ||||||||||||||||||||||||||||||
| 1895 | touchEvent->setTarget(item); | - | ||||||||||||||||||||||||||||||
| 1896 | touchEvent->setDevice(event.device()); | - | ||||||||||||||||||||||||||||||
| 1897 | touchEvent->setModifiers(event.modifiers()); | - | ||||||||||||||||||||||||||||||
| 1898 | touchEvent->setTouchPoints(touchPoints); | - | ||||||||||||||||||||||||||||||
| 1899 | touchEvent->setTouchPointStates(eventStates); | - | ||||||||||||||||||||||||||||||
| 1900 | touchEvent->setTimestamp(event.timestamp()); | - | ||||||||||||||||||||||||||||||
| 1901 | touchEvent->accept(); | - | ||||||||||||||||||||||||||||||
| 1902 | return touchEvent; executed 1214 times by 10 tests: return touchEvent;Executed by:
| 1214 | ||||||||||||||||||||||||||||||
| 1903 | } | - | ||||||||||||||||||||||||||||||
| 1904 | - | |||||||||||||||||||||||||||||||
| 1905 | QTouchEvent *QQuickPointerTouchEvent::asTouchEvent() const | - | ||||||||||||||||||||||||||||||
| 1906 | { | - | ||||||||||||||||||||||||||||||
| 1907 | return static_cast<QTouchEvent *>(m_event); executed 2936 times by 10 tests: return static_cast<QTouchEvent *>(m_event);Executed by:
| 2936 | ||||||||||||||||||||||||||||||
| 1908 | } | - | ||||||||||||||||||||||||||||||
| 1909 | - | |||||||||||||||||||||||||||||||
| 1910 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||||||||
| 1911 | - | |||||||||||||||||||||||||||||||
| 1912 | Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickPointerDevice *dev) | - | ||||||||||||||||||||||||||||||
| 1913 | { | - | ||||||||||||||||||||||||||||||
| 1914 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||||||||||||||
| 1915 | dbg.nospace(); | - | ||||||||||||||||||||||||||||||
| 1916 | if (!dev) {
| 0 | ||||||||||||||||||||||||||||||
| 1917 | dbg << "QQuickPointerDevice(0)"; | - | ||||||||||||||||||||||||||||||
| 1918 | return dbg; never executed: return dbg; | 0 | ||||||||||||||||||||||||||||||
| 1919 | } | - | ||||||||||||||||||||||||||||||
| 1920 | dbg << "QQuickPointerDevice("<< dev->name() << ' '; | - | ||||||||||||||||||||||||||||||
| 1921 | QtDebugUtils::formatQEnum(dbg, dev->type()); | - | ||||||||||||||||||||||||||||||
| 1922 | dbg << ' '; | - | ||||||||||||||||||||||||||||||
| 1923 | QtDebugUtils::formatQEnum(dbg, dev->pointerType()); | - | ||||||||||||||||||||||||||||||
| 1924 | dbg << " caps:"; | - | ||||||||||||||||||||||||||||||
| 1925 | QtDebugUtils::formatQFlags(dbg, dev->capabilities()); | - | ||||||||||||||||||||||||||||||
| 1926 | if (dev->type() == QQuickPointerDevice::TouchScreen ||
| 0 | ||||||||||||||||||||||||||||||
| 1927 | dev->type() == QQuickPointerDevice::TouchPad)
| 0 | ||||||||||||||||||||||||||||||
| 1928 | dbg << " maxTouchPoints:" << dev->maximumTouchPoints(); never executed: dbg << " maxTouchPoints:" << dev->maximumTouchPoints(); | 0 | ||||||||||||||||||||||||||||||
| 1929 | else | - | ||||||||||||||||||||||||||||||
| 1930 | dbg << " buttonCount:" << dev->buttonCount(); never executed: dbg << " buttonCount:" << dev->buttonCount(); | 0 | ||||||||||||||||||||||||||||||
| 1931 | dbg << ')'; | - | ||||||||||||||||||||||||||||||
| 1932 | return dbg; never executed: return dbg; | 0 | ||||||||||||||||||||||||||||||
| 1933 | } | - | ||||||||||||||||||||||||||||||
| 1934 | - | |||||||||||||||||||||||||||||||
| 1935 | Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickPointerEvent *event) | - | ||||||||||||||||||||||||||||||
| 1936 | { | - | ||||||||||||||||||||||||||||||
| 1937 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||||||||||||||
| 1938 | dbg.nospace(); | - | ||||||||||||||||||||||||||||||
| 1939 | dbg << "QQuickPointerEvent("; | - | ||||||||||||||||||||||||||||||
| 1940 | dbg << event->timestamp(); | - | ||||||||||||||||||||||||||||||
| 1941 | dbg << " dev:"; | - | ||||||||||||||||||||||||||||||
| 1942 | QtDebugUtils::formatQEnum(dbg, event->device()->type()); | - | ||||||||||||||||||||||||||||||
| 1943 | if (event->buttons() != Qt::NoButton) {
| 0 | ||||||||||||||||||||||||||||||
| 1944 | dbg << " buttons:"; | - | ||||||||||||||||||||||||||||||
| 1945 | QtDebugUtils::formatQEnum(dbg, event->buttons()); | - | ||||||||||||||||||||||||||||||
| 1946 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1947 | dbg << " ["; | - | ||||||||||||||||||||||||||||||
| 1948 | int c = event->pointCount(); | - | ||||||||||||||||||||||||||||||
| 1949 | for (int i = 0; i < c; ++i)
| 0 | ||||||||||||||||||||||||||||||
| 1950 | dbg << event->point(i) << ' '; never executed: dbg << event->point(i) << ' '; | 0 | ||||||||||||||||||||||||||||||
| 1951 | dbg << "])"; | - | ||||||||||||||||||||||||||||||
| 1952 | return dbg; never executed: return dbg; | 0 | ||||||||||||||||||||||||||||||
| 1953 | } | - | ||||||||||||||||||||||||||||||
| 1954 | - | |||||||||||||||||||||||||||||||
| 1955 | Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickEventPoint *event) | - | ||||||||||||||||||||||||||||||
| 1956 | { | - | ||||||||||||||||||||||||||||||
| 1957 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||||||||||||||
| 1958 | dbg.nospace(); | - | ||||||||||||||||||||||||||||||
| 1959 | dbg << "QQuickEventPoint(accepted:" << event->isAccepted() | - | ||||||||||||||||||||||||||||||
| 1960 | << " state:"; | - | ||||||||||||||||||||||||||||||
| 1961 | QtDebugUtils::formatQEnum(dbg, event->state()); | - | ||||||||||||||||||||||||||||||
| 1962 | dbg << " scenePos:" << event->scenePosition() << " id:" << hex << event->pointId() << dec | - | ||||||||||||||||||||||||||||||
| 1963 | << " timeHeld:" << event->timeHeld() << ')'; | - | ||||||||||||||||||||||||||||||
| 1964 | return dbg; never executed: return dbg; | 0 | ||||||||||||||||||||||||||||||
| 1965 | } | - | ||||||||||||||||||||||||||||||
| 1966 | - | |||||||||||||||||||||||||||||||
| 1967 | #endif | - | ||||||||||||||||||||||||||||||
| 1968 | - | |||||||||||||||||||||||||||||||
| 1969 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |