| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickmultipointtoucharea_p.h |
| Source code | Switch to Preprocessed file |
| Line | Source | Count |
|---|---|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - |
| 4 | ** Contact: https://www.qt.io/licensing/ | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 3 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - |
| 24 | ** | - |
| 25 | ** GNU General Public License Usage | - |
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - |
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - |
| 31 | ** included in the packaging of this file. Please review the following | - |
| 32 | ** information to ensure the GNU General Public License requirements will | - |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - |
| 35 | ** | - |
| 36 | ** $QT_END_LICENSE$ | - |
| 37 | ** | - |
| 38 | ****************************************************************************/ | - |
| 39 | - | |
| 40 | #ifndef QQUICKMULTIPOINTTOUCHAREA_H | - |
| 41 | #define QQUICKMULTIPOINTTOUCHAREA_H | - |
| 42 | - | |
| 43 | // | - |
| 44 | // W A R N I N G | - |
| 45 | // ------------- | - |
| 46 | // | - |
| 47 | // This file is not part of the Qt API. It exists purely as an | - |
| 48 | // implementation detail. This header file may change from version to | - |
| 49 | // version without notice, or even be removed. | - |
| 50 | // | - |
| 51 | // We mean it. | - |
| 52 | // | - |
| 53 | - | |
| 54 | #include "qquickitem.h" | - |
| 55 | #include "qevent.h" | - |
| 56 | - | |
| 57 | #include <QPointer> | - |
| 58 | #include <QMap> | - |
| 59 | #include <QList> | - |
| 60 | #include <QtGui/qguiapplication.h> | - |
| 61 | #include <QtGui/qstylehints.h> | - |
| 62 | - | |
| 63 | QT_BEGIN_NAMESPACE | - |
| 64 | - | |
| 65 | class QQuickMultiPointTouchArea; | - |
| 66 | class Q_AUTOTEST_EXPORT QQuickTouchPoint : public QObject | - |
| 67 | { | - |
| 68 | Q_OBJECT | - |
| 69 | Q_PROPERTY(int pointId READ pointId NOTIFY pointIdChanged) | - |
| 70 | Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId NOTIFY uniqueIdChanged REVISION 9) | - |
| 71 | Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged) | - |
| 72 | Q_PROPERTY(qreal x READ x NOTIFY xChanged) | - |
| 73 | Q_PROPERTY(qreal y READ y NOTIFY yChanged) | - |
| 74 | Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters NOTIFY ellipseDiametersChanged REVISION 9) | - |
| 75 | Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged) | - |
| 76 | Q_PROPERTY(qreal rotation READ rotation NOTIFY rotationChanged REVISION 9) | - |
| 77 | Q_PROPERTY(QVector2D velocity READ velocity NOTIFY velocityChanged) | - |
| 78 | Q_PROPERTY(QRectF area READ area NOTIFY areaChanged) | - |
| 79 | - | |
| 80 | Q_PROPERTY(qreal startX READ startX NOTIFY startXChanged) | - |
| 81 | Q_PROPERTY(qreal startY READ startY NOTIFY startYChanged) | - |
| 82 | Q_PROPERTY(qreal previousX READ previousX NOTIFY previousXChanged) | - |
| 83 | Q_PROPERTY(qreal previousY READ previousY NOTIFY previousYChanged) | - |
| 84 | Q_PROPERTY(qreal sceneX READ sceneX NOTIFY sceneXChanged) | - |
| 85 | Q_PROPERTY(qreal sceneY READ sceneY NOTIFY sceneYChanged) | - |
| 86 | - | |
| 87 | public: | - |
| 88 | QQuickTouchPoint(bool qmlDefined = true) | - |
| 89 | : _qmlDefined(qmlDefined) | - |
| 90 | {} executed 170 times by 3 tests: end of blockExecuted by:
| 170 |
| 91 | - | |
| 92 | int pointId() const { return _id; } executed 20 times by 1 test: return _id;Executed by:
| 20 |
| 93 | void setPointId(int id); | - |
| 94 | - | |
| 95 | QPointingDeviceUniqueId uniqueId() const { return _uniqueId; } never executed: return _uniqueId; | 0 |
| 96 | void setUniqueId(const QPointingDeviceUniqueId &id); | - |
| 97 | - | |
| 98 | qreal x() const { return _x; } executed 348 times by 3 tests: return _x;Executed by:
| 348 |
| 99 | void setX(qreal x); | - |
| 100 | - | |
| 101 | qreal y() const { return _y; } executed 334 times by 3 tests: return _y;Executed by:
| 334 |
| 102 | void setY(qreal y); | - |
| 103 | - | |
| 104 | QSizeF ellipseDiameters() const { return _ellipseDiameters; } never executed: return _ellipseDiameters; | 0 |
| 105 | void setEllipseDiameters(const QSizeF &d); | - |
| 106 | - | |
| 107 | qreal pressure() const { return _pressure; } never executed: return _pressure; | 0 |
| 108 | void setPressure(qreal pressure); | - |
| 109 | - | |
| 110 | qreal rotation() const { return _rotation; } executed 16 times by 1 test: return _rotation;Executed by:
| 16 |
| 111 | void setRotation(qreal r); | - |
| 112 | - | |
| 113 | QVector2D velocity() const { return _velocity; } never executed: return _velocity; | 0 |
| 114 | void setVelocity(const QVector2D &velocity); | - |
| 115 | - | |
| 116 | QRectF area() const { return _area; } executed 32 times by 1 test: return _area;Executed by:
| 32 |
| 117 | void setArea(const QRectF &area); | - |
| 118 | - | |
| 119 | bool isQmlDefined() const { return _qmlDefined; } executed 140 times by 2 tests: return _qmlDefined;Executed by:
| 140 |
| 120 | - | |
| 121 | bool inUse() const { return _inUse; } executed 180 times by 2 tests: return _inUse;Executed by:
| 180 |
| 122 | void setInUse(bool inUse) { _inUse = inUse; } executed 192 times by 2 tests: end of blockExecuted by:
| 192 |
| 123 | - | |
| 124 | bool pressed() const { return _pressed; } executed 680 times by 3 tests: return _pressed;Executed by:
| 680 |
| 125 | void setPressed(bool pressed); | - |
| 126 | - | |
| 127 | qreal startX() const { return _startX; } executed 4 times by 1 test: return _startX;Executed by:
| 4 |
| 128 | void setStartX(qreal startX); | - |
| 129 | - | |
| 130 | qreal startY() const { return _startY; } never executed: return _startY; | 0 |
| 131 | void setStartY(qreal startY); | - |
| 132 | - | |
| 133 | qreal previousX() const { return _previousX; } never executed: return _previousX; | 0 |
| 134 | void setPreviousX(qreal previousX); | - |
| 135 | - | |
| 136 | qreal previousY() const { return _previousY; } never executed: return _previousY; | 0 |
| 137 | void setPreviousY(qreal previousY); | - |
| 138 | - | |
| 139 | qreal sceneX() const { return _sceneX; } never executed: return _sceneX; | 0 |
| 140 | void setSceneX(qreal sceneX); | - |
| 141 | - | |
| 142 | qreal sceneY() const { return _sceneY; } never executed: return _sceneY; | 0 |
| 143 | void setSceneY(qreal sceneY); | - |
| 144 | - | |
| 145 | Q_SIGNALS: | - |
| 146 | void pressedChanged(); | - |
| 147 | void pointIdChanged(); | - |
| 148 | Q_REVISION(9) void uniqueIdChanged(); | - |
| 149 | void xChanged(); | - |
| 150 | void yChanged(); | - |
| 151 | Q_REVISION(9) void ellipseDiametersChanged(); | - |
| 152 | void pressureChanged(); | - |
| 153 | Q_REVISION(9) void rotationChanged(); | - |
| 154 | void velocityChanged(); | - |
| 155 | void areaChanged(); | - |
| 156 | void startXChanged(); | - |
| 157 | void startYChanged(); | - |
| 158 | void previousXChanged(); | - |
| 159 | void previousYChanged(); | - |
| 160 | void sceneXChanged(); | - |
| 161 | void sceneYChanged(); | - |
| 162 | - | |
| 163 | private: | - |
| 164 | friend class QQuickMultiPointTouchArea; | - |
| 165 | int _id = 0; | - |
| 166 | qreal _x = 0.0; | - |
| 167 | qreal _y = 0.0; | - |
| 168 | qreal _pressure = 0.0; | - |
| 169 | qreal _rotation = 0; | - |
| 170 | QSizeF _ellipseDiameters; | - |
| 171 | QVector2D _velocity; | - |
| 172 | QRectF _area; | - |
| 173 | bool _qmlDefined; | - |
| 174 | bool _inUse = false; //whether the point is currently in use (only valid when _qmlDefined == true) | - |
| 175 | bool _pressed = false; | - |
| 176 | qreal _startX = 0.0; | - |
| 177 | qreal _startY = 0.0; | - |
| 178 | qreal _previousX = 0.0; | - |
| 179 | qreal _previousY = 0.0; | - |
| 180 | qreal _sceneX = 0.0; | - |
| 181 | qreal _sceneY = 0.0; | - |
| 182 | QPointingDeviceUniqueId _uniqueId; | - |
| 183 | }; | - |
| 184 | - | |
| 185 | class QQuickGrabGestureEvent : public QObject | - |
| 186 | { | - |
| 187 | Q_OBJECT | - |
| 188 | Q_PROPERTY(QQmlListProperty<QObject> touchPoints READ touchPoints) | - |
| 189 | Q_PROPERTY(qreal dragThreshold READ dragThreshold) | - |
| 190 | public: | - |
| 191 | QQuickGrabGestureEvent() : _dragThreshold(QGuiApplication::styleHints()->startDragDistance()) {} executed 82 times by 2 tests: end of blockExecuted by:
| 82 |
| 192 | - | |
| 193 | Q_INVOKABLE void grab() { _grab = true; } executed 6 times by 1 test: end of blockExecuted by:
| 6 |
| 194 | bool wantsGrab() const { return _grab; } executed 82 times by 2 tests: return _grab;Executed by:
| 82 |
| 195 | - | |
| 196 | QQmlListProperty<QObject> touchPoints() { | - |
| 197 | return QQmlListProperty<QObject>(this, _touchPoints); never executed: return QQmlListProperty<QObject>(this, _touchPoints); | 0 |
| 198 | } | - |
| 199 | qreal dragThreshold() const { return _dragThreshold; } executed 4 times by 1 test: return _dragThreshold;Executed by:
| 4 |
| 200 | - | |
| 201 | private: | - |
| 202 | friend class QQuickMultiPointTouchArea; | - |
| 203 | bool _grab = false; | - |
| 204 | qreal _dragThreshold; | - |
| 205 | QList<QObject*> _touchPoints; | - |
| 206 | }; | - |
| 207 | - | |
| 208 | class Q_AUTOTEST_EXPORT QQuickMultiPointTouchArea : public QQuickItem | - |
| 209 | { | - |
| 210 | Q_OBJECT | - |
| 211 | - | |
| 212 | Q_PROPERTY(QQmlListProperty<QQuickTouchPoint> touchPoints READ touchPoints) | - |
| 213 | Q_PROPERTY(int minimumTouchPoints READ minimumTouchPoints WRITE setMinimumTouchPoints NOTIFY minimumTouchPointsChanged) | - |
| 214 | Q_PROPERTY(int maximumTouchPoints READ maximumTouchPoints WRITE setMaximumTouchPoints NOTIFY maximumTouchPointsChanged) | - |
| 215 | Q_PROPERTY(bool mouseEnabled READ mouseEnabled WRITE setMouseEnabled NOTIFY mouseEnabledChanged) | - |
| 216 | - | |
| 217 | public: | - |
| 218 | QQuickMultiPointTouchArea(QQuickItem *parent=nullptr); | - |
| 219 | ~QQuickMultiPointTouchArea(); | - |
| 220 | - | |
| 221 | int minimumTouchPoints() const; | - |
| 222 | void setMinimumTouchPoints(int num); | - |
| 223 | int maximumTouchPoints() const; | - |
| 224 | void setMaximumTouchPoints(int num); | - |
| 225 | bool mouseEnabled() const { return _mouseEnabled; } never executed: return _mouseEnabled; | 0 |
| 226 | void setMouseEnabled(bool arg); | - |
| 227 | - | |
| 228 | QQmlListProperty<QQuickTouchPoint> touchPoints() { | - |
| 229 | return QQmlListProperty<QQuickTouchPoint>(this, nullptr, QQuickMultiPointTouchArea::touchPoint_append, QQuickMultiPointTouchArea::touchPoint_count, QQuickMultiPointTouchArea::touchPoint_at, nullptr); executed 62 times by 3 tests: return QQmlListProperty<QQuickTouchPoint>(this, nullptr, QQuickMultiPointTouchArea::touchPoint_append, QQuickMultiPointTouchArea::touchPoint_count, QQuickMultiPointTouchArea::touchPoint_at, nullptr);Executed by:
| 62 |
| 230 | } | - |
| 231 | - | |
| 232 | static void touchPoint_append(QQmlListProperty<QQuickTouchPoint> *list, QQuickTouchPoint* touch) { | - |
| 233 | QQuickMultiPointTouchArea *q = static_cast<QQuickMultiPointTouchArea*>(list->object); | - |
| 234 | q->addTouchPrototype(touch); | - |
| 235 | } executed 120 times by 3 tests: end of blockExecuted by:
| 120 |
| 236 | - | |
| 237 | static int touchPoint_count(QQmlListProperty<QQuickTouchPoint> *list) { | - |
| 238 | QQuickMultiPointTouchArea *q = static_cast<QQuickMultiPointTouchArea*>(list->object); | - |
| 239 | return q->_touchPrototypes.count(); executed 18 times by 2 tests: return q->_touchPrototypes.count();Executed by:
| 18 |
| 240 | } | - |
| 241 | - | |
| 242 | static QQuickTouchPoint* touchPoint_at(QQmlListProperty<QQuickTouchPoint> *list, int index) { | - |
| 243 | QQuickMultiPointTouchArea *q = static_cast<QQuickMultiPointTouchArea*>(list->object); | - |
| 244 | return q->_touchPrototypes.value(index); executed 198 times by 1 test: return q->_touchPrototypes.value(index);Executed by:
| 198 |
| 245 | } | - |
| 246 | - | |
| 247 | Q_SIGNALS: | - |
| 248 | void pressed(const QList<QObject*> &touchPoints); | - |
| 249 | void updated(const QList<QObject*> &touchPoints); | - |
| 250 | void released(const QList<QObject*> &touchPoints); | - |
| 251 | void canceled(const QList<QObject*> &touchPoints); | - |
| 252 | void gestureStarted(QQuickGrabGestureEvent *gesture); | - |
| 253 | void touchUpdated(const QList<QObject*> &touchPoints); | - |
| 254 | void minimumTouchPointsChanged(); | - |
| 255 | void maximumTouchPointsChanged(); | - |
| 256 | void mouseEnabledChanged(); | - |
| 257 | - | |
| 258 | protected: | - |
| 259 | void touchEvent(QTouchEvent *) override; | - |
| 260 | bool childMouseEventFilter(QQuickItem *receiver, QEvent *event) override; | - |
| 261 | void mousePressEvent(QMouseEvent *event) override; | - |
| 262 | void mouseReleaseEvent(QMouseEvent *event) override; | - |
| 263 | void mouseMoveEvent(QMouseEvent *event) override; | - |
| 264 | void mouseUngrabEvent() override; | - |
| 265 | void touchUngrabEvent() override; | - |
| 266 | - | |
| 267 | void addTouchPrototype(QQuickTouchPoint* prototype); | - |
| 268 | void addTouchPoint(const QTouchEvent::TouchPoint *p); | - |
| 269 | void addTouchPoint(const QMouseEvent *e); | - |
| 270 | void clearTouchLists(); | - |
| 271 | - | |
| 272 | void updateTouchPoint(QQuickTouchPoint*, const QTouchEvent::TouchPoint*); | - |
| 273 | void updateTouchPoint(QQuickTouchPoint *dtp, const QMouseEvent *e); | - |
| 274 | void updateTouchData(QEvent*); | - |
| 275 | - | |
| 276 | bool sendMouseEvent(QMouseEvent *event); | - |
| 277 | bool shouldFilter(QEvent *event); | - |
| 278 | void grabGesture(); | - |
| 279 | QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; | - |
| 280 | #ifdef Q_OS_OSX | - |
| 281 | void hoverEnterEvent(QHoverEvent *event) override; | - |
| 282 | void hoverLeaveEvent(QHoverEvent *event) override; | - |
| 283 | void setTouchEventsEnabled(bool enable); | - |
| 284 | #endif | - |
| 285 | - | |
| 286 | private: | - |
| 287 | void ungrab(); | - |
| 288 | QMap<int,QQuickTouchPoint*> _touchPrototypes; //TouchPoints defined in QML | - |
| 289 | QMap<int,QObject*> _touchPoints; //All current touch points | - |
| 290 | QList<QObject*> _releasedTouchPoints; | - |
| 291 | QList<QObject*> _pressedTouchPoints; | - |
| 292 | QList<QObject*> _movedTouchPoints; | - |
| 293 | int _minimumTouchPoints; | - |
| 294 | int _maximumTouchPoints; | - |
| 295 | QPointer<QQuickTouchPoint> _mouseTouchPoint; // exists when mouse button is down and _mouseEnabled is true; null otherwise | - |
| 296 | QTouchEvent::TouchPoint _mouseQpaTouchPoint; // synthetic QPA touch point to hold state and position of the mouse | - |
| 297 | QPointF _mousePos; | - |
| 298 | bool _stealMouse; | - |
| 299 | bool _mouseEnabled; | - |
| 300 | }; | - |
| 301 | - | |
| 302 | QT_END_NAMESPACE | - |
| 303 | - | |
| 304 | QML_DECLARE_TYPE(QQuickTouchPoint) | - |
| 305 | QML_DECLARE_TYPE(QQuickGrabGestureEvent) | - |
| 306 | QML_DECLARE_TYPE(QQuickMultiPointTouchArea) | - |
| 307 | - | |
| 308 | #endif // QQUICKMULTIPOINTTOUCHAREA_H | - |
| Source code | Switch to Preprocessed file |