OpenCoverage

qquicksinglepointhandler.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/handlers/qquicksinglepointhandler.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2018 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 "qquicksinglepointhandler_p.h"-
41-
42QT_BEGIN_NAMESPACE-
43Q_DECLARE_LOGGING_CATEGORY(DBG_TOUCH_TARGET)-
44-
45/*!-
46 \qmltype SinglePointHandler-
47 \qmlabstract-
48 \preliminary-
49 \instantiates QQuickSinglePointHandler-
50 \inherits PointerDeviceHandler-
51 \inqmlmodule Qt.labs.handlers-
52 \ingroup qtquick-handlers-
53 \brief Abstract handler for single-point Pointer Events.-
54-
55 An intermediate class (not registered as a QML type)-
56 for the most common handlers: those which expect only a single point.-
57 wantsPointerEvent() will choose the first point which is inside the-
58 \l target item, and return true as long as the event contains that point.-
59 Override handleEventPoint() to implement a single-point handler.-
60*/-
61-
62QQuickSinglePointHandler::QQuickSinglePointHandler(QObject *parent)-
63 : QQuickPointerDeviceHandler(parent)-
64 , m_ignoreAdditionalPoints(false)-
65{-
66}
executed 1000 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1000
67-
68bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event)-
69{-
70 if (!QQuickPointerDeviceHandler::wantsPointerEvent(event))
!QQuickPointer...erEvent(event)Description
TRUEnever evaluated
FALSEevaluated 2605 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
0-2605
71 return false;
never executed: return false;
0
72 if (event->device()->pointerType() != QQuickPointerDevice::Finger &&
event->device(...Device::FingerDescription
TRUEevaluated 310 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 2295 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
310-2295
73 (event->buttons() & acceptedButtons()) == 0 && (event->button() & acceptedButtons()) == 0)
(event->button...uttons()) == 0Description
TRUEevaluated 58 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 252 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
(event->button...uttons()) == 0Description
TRUEnever evaluated
FALSEevaluated 58 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
0-252
74 return false;
never executed: return false;
0
75-
76 if (m_pointInfo.m_id) {
m_pointInfo.m_idDescription
TRUEevaluated 1570 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 1035 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1035-1570
77 // We already know which one we want, so check whether it's there.-
78 // It's expected to be an update or a release.-
79 // If we no longer want it, cancel the grab.-
80 int candidatePointCount = 0;-
81 bool missing = true;-
82 QQuickEventPoint *point = nullptr;-
83 int c = event->pointCount();-
84 for (int i = 0; i < c; ++i) {
i < cDescription
TRUEevaluated 2532 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 1570 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1570-2532
85 QQuickEventPoint *p = event->point(i);-
86 const bool found = (p->pointId() == m_pointInfo.m_id);-
87 if (found)
foundDescription
TRUEevaluated 1570 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 962 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
962-1570
88 missing = false;
executed 1570 times by 4 tests: missing = false;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1570
89 if (wantsEventPoint(p)) {
wantsEventPoint(p)Description
TRUEevaluated 1348 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 1184 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1184-1348
90 ++candidatePointCount;-
91 if (found)
foundDescription
TRUEevaluated 1286 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 62 times by 2 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
62-1286
92 point = p;
executed 1286 times by 4 tests: point = p;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1286
93 }
executed 1348 times by 4 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1348
94 }
executed 2532 times by 4 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
2532
95 if (missing)
missingDescription
TRUEnever evaluated
FALSEevaluated 1570 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
0-1570
96 qCWarning(DBG_TOUCH_TARGET) << this << "pointId" << hex << m_pointInfo.m_id
never executed: QMessageLogger(__FILE__, 96, __PRETTY_FUNCTION__, DBG_TOUCH_TARGET().categoryName()).warning() << this << "pointId" << hex << m_pointInfo.m_id << "is missing from current event, but was neither canceled nor released";
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
97 << "is missing from current event, but was neither canceled nor released";
never executed: QMessageLogger(__FILE__, 96, __PRETTY_FUNCTION__, DBG_TOUCH_TARGET().categoryName()).warning() << this << "pointId" << hex << m_pointInfo.m_id << "is missing from current event, but was neither canceled nor released";
0
98 if (point) {
pointDescription
TRUEevaluated 1286 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 284 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
284-1286
99 if (candidatePointCount == 1 || (candidatePointCount > 1 && m_ignoreAdditionalPoints)) {
candidatePointCount == 1Description
TRUEevaluated 1260 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
candidatePointCount > 1Description
TRUEevaluated 26 times by 2 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEnever evaluated
m_ignoreAdditionalPointsDescription
TRUEnever evaluated
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
0-1260
100 point->setAccepted();-
101 return true;
executed 1260 times by 4 tests: return true;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1260
102 } else {-
103 point->cancelAllGrabs(this);-
104 }
executed 26 times by 2 tests: end of block
Executed by:
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
26
105 } else {-
106 return false;
executed 284 times by 3 tests: return false;
Executed by:
  • tst_flickableinterop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
284
107 }-
108 } else {-
109 // We have not yet chosen a point; choose the first one for which wantsEventPoint() returns true.-
110 int candidatePointCount = 0;-
111 int c = event->pointCount();-
112 QQuickEventPoint *chosen = nullptr;-
113 for (int i = 0; i < c; ++i) {
i < cDescription
TRUEevaluated 1937 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 1035 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1035-1937
114 QQuickEventPoint *p = event->point(i);-
115 if (!p->exclusiveGrabber() && wantsEventPoint(p)) {
!p->exclusiveGrabber()Description
TRUEevaluated 1506 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 431 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
wantsEventPoint(p)Description
TRUEevaluated 856 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 650 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
431-1506
116 if (!chosen)
!chosenDescription
TRUEevaluated 592 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 264 times by 2 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
264-592
117 chosen = p;
executed 592 times by 4 tests: chosen = p;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
592
118 ++candidatePointCount;-
119 }
executed 856 times by 4 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
856
120 }
executed 1937 times by 4 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1937
121 if (chosen && candidatePointCount == 1) {
chosenDescription
TRUEevaluated 592 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 443 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
candidatePointCount == 1Description
TRUEevaluated 452 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 140 times by 2 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
140-592
122 setPointId(chosen->pointId());-
123 chosen->setAccepted();-
124 }
executed 452 times by 4 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
452
125 }
executed 1035 times by 4 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1035
126 return m_pointInfo.m_id;
executed 1061 times by 4 tests: return m_pointInfo.m_id;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1061
127}-
128-
129void QQuickSinglePointHandler::handlePointerEventImpl(QQuickPointerEvent *event)-
130{-
131 QQuickPointerDeviceHandler::handlePointerEventImpl(event);-
132 QQuickEventPoint *currentPoint = event->pointById(m_pointInfo.m_id);-
133 Q_ASSERT(currentPoint);-
134 if (!m_pointInfo.m_id || !currentPoint->isAccepted()) {
!m_pointInfo.m_idDescription
TRUEnever evaluated
FALSEevaluated 1712 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
!currentPoint->isAccepted()Description
TRUEnever evaluated
FALSEevaluated 1712 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
0-1712
135 reset();-
136 } else {
never executed: end of block
0
137 m_pointInfo.reset(currentPoint);-
138 handleEventPoint(currentPoint);-
139 if (currentPoint->state() == QQuickEventPoint::Released) {
currentPoint->...oint::ReleasedDescription
TRUEevaluated 200 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
FALSEevaluated 1512 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
200-1512
140 setExclusiveGrab(currentPoint, false);-
141 reset();-
142 }
executed 200 times by 4 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
200
143 emit pointChanged();-
144 }
executed 1712 times by 4 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
1712
145}-
146-
147void QQuickSinglePointHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point)-
148{-
149 if (grabber != this)
grabber != thisDescription
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
FALSEevaluated 498 times by 4 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
22-498
150 return;
executed 22 times by 2 tests: return;
Executed by:
  • tst_flickableinterop
  • tst_qquickdraghandler
22
151 switch (stateChange) {-
152 case QQuickEventPoint::GrabExclusive:
executed 124 times by 4 tests: case QQuickEventPoint::GrabExclusive:
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
124
153 m_pointInfo.m_sceneGrabPosition = point->sceneGrabPosition();-
154 setActive(true);-
155 QQuickPointerHandler::onGrabChanged(grabber, stateChange, point);-
156 break;
executed 124 times by 4 tests: break;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
124
157 case QQuickEventPoint::GrabPassive:
executed 176 times by 4 tests: case QQuickEventPoint::GrabPassive:
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
176
158 m_pointInfo.m_sceneGrabPosition = point->sceneGrabPosition();-
159 QQuickPointerHandler::onGrabChanged(grabber, stateChange, point);-
160 break;
executed 176 times by 4 tests: break;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
176
161 case QQuickEventPoint::OverrideGrabPassive:
executed 50 times by 2 tests: case QQuickEventPoint::OverrideGrabPassive:
Executed by:
  • tst_flickableinterop
  • tst_qquickdraghandler
50
162 return; // don't emit
executed 50 times by 2 tests: return;
Executed by:
  • tst_flickableinterop
  • tst_qquickdraghandler
50
163 case QQuickEventPoint::UngrabPassive:
never executed: case QQuickEventPoint::UngrabPassive:
0
164 case QQuickEventPoint::UngrabExclusive:
executed 114 times by 4 tests: case QQuickEventPoint::UngrabExclusive:
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
114
165 case QQuickEventPoint::CancelGrabPassive:
executed 26 times by 2 tests: case QQuickEventPoint::CancelGrabPassive:
Executed by:
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
26
166 case QQuickEventPoint::CancelGrabExclusive:
executed 8 times by 1 test: case QQuickEventPoint::CancelGrabExclusive:
Executed by:
  • tst_flickableinterop
8
167 // the grab is lost or relinquished, so the point is no longer relevant-
168 QQuickPointerHandler::onGrabChanged(grabber, stateChange, point);-
169 reset();-
170 break;
executed 148 times by 4 tests: break;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
148
171 }-
172 emit singlePointGrabChanged();-
173}
executed 448 times by 4 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
448
174-
175void QQuickSinglePointHandler::setIgnoreAdditionalPoints(bool v)-
176{-
177 m_ignoreAdditionalPoints = v;-
178}
never executed: end of block
0
179-
180void QQuickSinglePointHandler::moveTarget(QPointF pos, QQuickEventPoint *point)-
181{-
182 target()->setPosition(pos);-
183 m_pointInfo.m_scenePosition = point->scenePosition();-
184 m_pointInfo.m_position = target()->mapFromScene(m_pointInfo.m_scenePosition);-
185}
executed 372 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
372
186-
187void QQuickSinglePointHandler::setPointId(int id)-
188{-
189 m_pointInfo.m_id = id;-
190}
executed 452 times by 4 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
452
191-
192void QQuickSinglePointHandler::reset()-
193{-
194 setActive(false);-
195 m_pointInfo.reset();-
196}
executed 348 times by 4 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
  • tst_qquicktaphandler
348
197-
198/*!-
199 \readonly-
200 \qmlproperty HandlerPoint QtQuick::SinglePointHandler::point-
201-
202 The event point currently being handled. When no point is currently being-
203 handled, this object is reset to default values (all coordinates are 0).-
204*/-
205-
206QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0