OpenCoverage

qquickmultipointhandler.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/handlers/qquickmultipointhandler.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3QQuickMultiPointHandler::QQuickMultiPointHandler(QObject *parent, int minimumPointCount)-
4 : QQuickPointerDeviceHandler(parent)-
5 , m_minimumPointCount(minimumPointCount)-
6 , m_maximumPointCount(-1)-
7{-
8}
executed 4 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
4
9-
10QQuickMultiPointHandler::~QQuickMultiPointHandler()-
11{-
12}-
13-
14bool QQuickMultiPointHandler::wantsPointerEvent(QQuickPointerEvent *event)-
15{-
16 if (!QQuickPointerDeviceHandler::wantsPointerEvent(event)
!QQuickPointer...erEvent(event)Description
TRUEnever evaluated
FALSEevaluated 83 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
)
0-83
17 return
never executed: return false;
false;
never executed: return false;
0
18-
19-
20 if (event->asPointerNativeGestureEvent()
event->asPoint...GestureEvent()Description
TRUEnever evaluated
FALSEevaluated 83 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
)
0-83
21 return
never executed: return true;
true;
never executed: return true;
0
22-
23-
24 if (hasCurrentPoints(event)
hasCurrentPoints(event)Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 56 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
)
27-56
25 return
executed 27 times by 1 test: return true;
Executed by:
  • tst_multipointtoucharea_interop
true;
executed 27 times by 1 test: return true;
Executed by:
  • tst_multipointtoucharea_interop
27
26-
27 const QVector<QQuickEventPoint *> candidatePoints = eligiblePoints(event);-
28 const bool ret = (candidatePoints.size() >= minimumPointCount()
candidatePoint...umPointCount()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
&& candidatePoints.size() <= maximumPointCount()
candidatePoint...umPointCount()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
);
2-50
29 if (ret
retDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 52 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
)
4-52
30 m_currentPoints = candidatePoints;
executed 4 times by 1 test: m_currentPoints = candidatePoints;
Executed by:
  • tst_multipointtoucharea_interop
4
31 return
executed 56 times by 1 test: return ret;
Executed by:
  • tst_multipointtoucharea_interop
ret;
executed 56 times by 1 test: return ret;
Executed by:
  • tst_multipointtoucharea_interop
56
32}-
33-
34void QQuickMultiPointHandler::handlePointerEventImpl(QQuickPointerEvent *event)-
35{-
36 QQuickPointerHandler::handlePointerEventImpl(event);-
37 m_centroid.reset(m_currentPoints);-
38 centroidChanged();-
39}
executed 31 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
31
40-
41void QQuickMultiPointHandler::onActiveChanged()-
42{-
43 if (active()
active()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
) {
4
44 m_centroid.m_sceneGrabPosition = m_centroid.m_scenePosition;-
45 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
4
46}
executed 8 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
8
47-
48QVector<QQuickEventPoint *> QQuickMultiPointHandler::eligiblePoints(QQuickPointerEvent *event)-
49{-
50 QVector<QQuickEventPoint *> ret;-
51 int c = event->pointCount();-
52-
53-
54-
55 bool stealingAllowed = event->isPressEvent()
event->isPressEvent()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 46 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
|| event->isReleaseEvent()
event->isReleaseEvent()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
;
10-46
56 for (int i = 0; i < c
i < cDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 56 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
; ++i) {
56-96
57 QQuickEventPoint *p = event->point(i);-
58 if (!stealingAllowed
!stealingAllowedDescription
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 44 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
) {
44-52
59 QObject *exclusiveGrabber = p->exclusiveGrabber();-
60 if (exclusiveGrabber
exclusiveGrabberDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
&& exclusiveGrabber != this
exclusiveGrabber != thisDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
)
4-34
61 continue;
executed 14 times by 1 test: continue;
Executed by:
  • tst_multipointtoucharea_interop
14
62 }
executed 38 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
38
63 if (p->state() != QQuickEventPoint::Released
p->state() != ...oint::ReleasedDescription
TRUEevaluated 72 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
&& wantsEventPoint(p)
wantsEventPoint(p)Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
)
0-72
64 ret << p;
executed 72 times by 1 test: ret << p;
Executed by:
  • tst_multipointtoucharea_interop
72
65 }
executed 82 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
82
66 return
executed 56 times by 1 test: return ret;
Executed by:
  • tst_multipointtoucharea_interop
ret;
executed 56 times by 1 test: return ret;
Executed by:
  • tst_multipointtoucharea_interop
56
67}-
68void QQuickMultiPointHandler::setMinimumPointCount(int c)-
69{-
70 if (m_minimumPointCount == c
m_minimumPointCount == cDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
)
0-4
71 return;
never executed: return;
0
72-
73 m_minimumPointCount = c;-
74 minimumPointCountChanged();-
75 if (m_maximumPointCount < 0
m_maximumPointCount < 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
)
0-4
76 maximumPointCountChanged();
executed 4 times by 1 test: maximumPointCountChanged();
Executed by:
  • tst_multipointtoucharea_interop
4
77}
executed 4 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
4
78void QQuickMultiPointHandler::setMaximumPointCount(int maximumPointCount)-
79{-
80 if (m_maximumPointCount == maximumPointCount
m_maximumPoint...imumPointCountDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
81 return;
never executed: return;
0
82-
83 m_maximumPointCount = maximumPointCount;-
84 maximumPointCountChanged();-
85}
never executed: end of block
0
86-
87bool QQuickMultiPointHandler::hasCurrentPoints(QQuickPointerEvent *event)-
88{-
89 bool ret = true;-
90 int c = event->pointCount();-
91 if (c < m_currentPoints.size()
c < m_currentPoints.size()Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 49 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
)
34-49
92 return
executed 34 times by 1 test: return false;
Executed by:
  • tst_multipointtoucharea_interop
false;
executed 34 times by 1 test: return false;
Executed by:
  • tst_multipointtoucharea_interop
34
93-
94-
95 for (int i = 0; ret
retDescription
TRUEevaluated 142 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
&& i < c
i < cDescription
TRUEevaluated 115 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 27 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
; ++i) {
16-142
96 if (event->point(i)->state() == QQuickEventPoint::Released
event->point(i...oint::ReleasedDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 109 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
)
6-109
97 return
executed 6 times by 1 test: return false;
Executed by:
  • tst_multipointtoucharea_interop
false;
executed 6 times by 1 test: return false;
Executed by:
  • tst_multipointtoucharea_interop
6
98 bool found = false;-
99 int pointId = event->point(i)->pointId();-
100 for (QQuickEventPoint *o : qAsConst(m_currentPoints))-
101 if (o
oDescription
TRUEevaluated 285 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
&& pointId == o->pointId()
pointId == o->pointId()Description
TRUEevaluated 93 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 192 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
)
0-285
102 found = true;
executed 93 times by 1 test: found = true;
Executed by:
  • tst_multipointtoucharea_interop
93
103 if (!found
!foundDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 93 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
)
16-93
104 ret = false;
executed 16 times by 1 test: ret = false;
Executed by:
  • tst_multipointtoucharea_interop
16
105 }
executed 109 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
109
106 return
executed 43 times by 1 test: return ret;
Executed by:
  • tst_multipointtoucharea_interop
ret;
executed 43 times by 1 test: return ret;
Executed by:
  • tst_multipointtoucharea_interop
43
107}-
108-
109qreal QQuickMultiPointHandler::averageTouchPointDistance(const QPointF &ref)-
110{-
111 qreal ret = 0;-
112 if (__builtin_expect(!!(m_currentPoints.size() == 0), false)
__builtin_expe... == 0), false)Description
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
)
0-33
113 return
never executed: return ret;
ret;
never executed: return ret;
0
114 for (QQuickEventPoint *point : qAsConst(m_currentPoints))-
115 ret += QVector2D(point->scenePosition() - ref).length();
executed 99 times by 1 test: ret += QVector2D(point->scenePosition() - ref).length();
Executed by:
  • tst_multipointtoucharea_interop
99
116 return
executed 33 times by 1 test: return ret / m_currentPoints.size();
Executed by:
  • tst_multipointtoucharea_interop
ret / m_currentPoints.size();
executed 33 times by 1 test: return ret / m_currentPoints.size();
Executed by:
  • tst_multipointtoucharea_interop
33
117}-
118-
119qreal QQuickMultiPointHandler::averageStartingDistance(const QPointF &ref)-
120{-
121-
122 qreal ret = 0;-
123 if (__builtin_expect(!!(m_currentPoints.size() == 0), false)
__builtin_expe... == 0), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
124 return
never executed: return ret;
ret;
never executed: return ret;
0
125 for (QQuickEventPoint *point : qAsConst(m_currentPoints))-
126 ret += QVector2D(point->sceneGrabPosition() - ref).length();
never executed: ret += QVector2D(point->sceneGrabPosition() - ref).length();
0
127 return
never executed: return ret / m_currentPoints.size();
ret / m_currentPoints.size();
never executed: return ret / m_currentPoints.size();
0
128}-
129-
130QVector<QQuickMultiPointHandler::PointData> QQuickMultiPointHandler::angles(const QPointF &ref) const-
131{-
132 QVector<PointData> angles;-
133 angles.reserve(m_currentPoints.count());-
134 for (QQuickEventPoint *point : qAsConst(m_currentPoints)) {-
135 qreal angle = QLineF(ref, point->scenePosition()).angle();-
136 angles.append(PointData(point->pointId(), -angle));-
137 }
executed 99 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
99
138 return
executed 33 times by 1 test: return angles;
Executed by:
  • tst_multipointtoucharea_interop
angles;
executed 33 times by 1 test: return angles;
Executed by:
  • tst_multipointtoucharea_interop
33
139}-
140-
141qreal QQuickMultiPointHandler::averageAngleDelta(const QVector<PointData> &old, const QVector<PointData> &newAngles)-
142{-
143 qreal avgAngleDelta = 0;-
144 int numSamples = 0;-
145-
146 auto oldBegin = old.constBegin();-
147-
148 for (PointData newData : newAngles) {-
149 quint64 id = newData.id;-
150 auto it = std::find_if(oldBegin, old.constEnd(), [id] (PointData pd) { return
executed 87 times by 1 test: return pd.id == id;
Executed by:
  • tst_multipointtoucharea_interop
pd.id == id;
executed 87 times by 1 test: return pd.id == id;
Executed by:
  • tst_multipointtoucharea_interop
});
87
151 qreal angleD = 0;-
152 if (it != old.constEnd()
it != old.constEnd()Description
TRUEevaluated 87 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
) {
0-87
153 PointData oldData = *it;-
154-
155-
156-
157-
158 angleD = remainder(newData.angle - oldData.angle, qreal(360));-
159-
160-
161 if (it == oldBegin
it == oldBeginDescription
TRUEevaluated 87 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
)
0-87
162 ++
executed 87 times by 1 test: ++oldBegin;
Executed by:
  • tst_multipointtoucharea_interop
oldBegin;
executed 87 times by 1 test: ++oldBegin;
Executed by:
  • tst_multipointtoucharea_interop
87
163 numSamples++;-
164 }
executed 87 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
87
165 avgAngleDelta += angleD;-
166 }
executed 87 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
87
167 if (numSamples > 1
numSamples > 1Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
)
0-29
168 avgAngleDelta /= numSamples;
executed 29 times by 1 test: avgAngleDelta /= numSamples;
Executed by:
  • tst_multipointtoucharea_interop
29
169-
170 return
executed 29 times by 1 test: return avgAngleDelta;
Executed by:
  • tst_multipointtoucharea_interop
avgAngleDelta;
executed 29 times by 1 test: return avgAngleDelta;
Executed by:
  • tst_multipointtoucharea_interop
29
171}-
172-
173void QQuickMultiPointHandler::acceptPoints(const QVector<QQuickEventPoint *> &points)-
174{-
175 for (QQuickEventPoint* point : points)-
176 point->setAccepted();
executed 87 times by 1 test: point->setAccepted();
Executed by:
  • tst_multipointtoucharea_interop
87
177}
executed 29 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
29
178-
179bool QQuickMultiPointHandler::grabPoints(QVector<QQuickEventPoint *> points)-
180{-
181 bool allowed = true;-
182 for (QQuickEventPoint* point : points) {-
183 if (!canGrab(point)
!canGrab(point)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
) {
0-12
184 allowed = false;-
185 break;
never executed: break;
0
186 }-
187 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
12
188 if (allowed
allowedDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
) {
0-4
189 for (QQuickEventPoint* point : points)-
190 setExclusiveGrab(point);
executed 12 times by 1 test: setExclusiveGrab(point);
Executed by:
  • tst_multipointtoucharea_interop
12
191 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
4
192 return
executed 4 times by 1 test: return allowed;
Executed by:
  • tst_multipointtoucharea_interop
allowed;
executed 4 times by 1 test: return allowed;
Executed by:
  • tst_multipointtoucharea_interop
4
193}-
194-
195-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0