OpenCoverage

qquickpincharea.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickpincharea.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7QQuickPinch::QQuickPinch()-
8 : m_target(nullptr), m_minScale(1.0), m_maxScale(1.0)-
9 , m_minRotation(0.0), m_maxRotation(0.0)-
10 , m_axis(NoDrag), m_xmin(-3.40282346638528859812e+38F), m_xmax(3.40282346638528859812e+38F)-
11 , m_ymin(-3.40282346638528859812e+38F), m_ymax(3.40282346638528859812e+38F), m_active(false)-
12{-
13}
executed 30 times by 2 tests: end of block
Executed by:
  • tst_qquickpincharea
  • tst_touchmouse
30
14-
15QQuickPinchAreaPrivate::~QQuickPinchAreaPrivate()-
16{-
17 delete pinch;-
18}
executed 32 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickpincharea
  • tst_touchmouse
32
19QQuickPinchArea::QQuickPinchArea(QQuickItem *parent)-
20 : QQuickItem(*(new QQuickPinchAreaPrivate), parent)-
21{-
22 QQuickPinchAreaPrivate * const d = d_func();-
23 d->init();-
24 setAcceptTouchEvents(true);-
25-
26-
27-
28}
executed 32 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickpincharea
  • tst_touchmouse
32
29-
30QQuickPinchArea::~QQuickPinchArea()-
31{-
32}-
33-
34-
35-
36-
37-
38-
39bool QQuickPinchArea::isEnabled() const-
40{-
41 const QQuickPinchAreaPrivate * const d = d_func();-
42 return
never executed: return d->enabled;
d->enabled;
never executed: return d->enabled;
0
43}-
44-
45void QQuickPinchArea::setEnabled(bool a)-
46{-
47 QQuickPinchAreaPrivate * const d = d_func();-
48 if (a != d->enabled
a != d->enabledDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
49 d->enabled = a;-
50 enabledChanged();-
51 }
never executed: end of block
0
52}
never executed: end of block
0
53-
54void QQuickPinchArea::touchEvent(QTouchEvent *event)-
55{-
56 QQuickPinchAreaPrivate * const d = d_func();-
57 if (!d->enabled
!d->enabledDescription
TRUEnever evaluated
FALSEevaluated 88 times by 1 test
Evaluated by:
  • tst_qquickpincharea
|| !isVisible()
!isVisible()Description
TRUEnever evaluated
FALSEevaluated 88 times by 1 test
Evaluated by:
  • tst_qquickpincharea
) {
0-88
58 QQuickItem::touchEvent(event);-
59 return;
never executed: return;
0
60 }-
61 switch (event->type()) {-
62 case
executed 16 times by 1 test: case QEvent::TouchBegin:
Executed by:
  • tst_qquickpincharea
QEvent::TouchBegin:
executed 16 times by 1 test: case QEvent::TouchBegin:
Executed by:
  • tst_qquickpincharea
16
63 case
executed 54 times by 1 test: case QEvent::TouchUpdate:
Executed by:
  • tst_qquickpincharea
QEvent::TouchUpdate:
executed 54 times by 1 test: case QEvent::TouchUpdate:
Executed by:
  • tst_qquickpincharea
54
64 d->touchPoints.clear();-
65 for (int i = 0; i < event->touchPoints().count()
i < event->tou...ints().count()Description
TRUEevaluated 122 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 70 times by 1 test
Evaluated by:
  • tst_qquickpincharea
; ++i) {
70-122
66 if (!(event->touchPoints().at(i).state() & Qt::TouchPointReleased)
!(event->touch...PointReleased)Description
TRUEevaluated 120 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
) {
2-120
67 d->touchPoints << event->touchPoints().at(i);-
68 }
executed 120 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
120
69 }
executed 122 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
122
70 updatePinch();-
71 break;
executed 70 times by 1 test: break;
Executed by:
  • tst_qquickpincharea
70
72 case
executed 14 times by 1 test: case QEvent::TouchEnd:
Executed by:
  • tst_qquickpincharea
QEvent::TouchEnd:
executed 14 times by 1 test: case QEvent::TouchEnd:
Executed by:
  • tst_qquickpincharea
14
73 clearPinch();-
74 break;
executed 14 times by 1 test: break;
Executed by:
  • tst_qquickpincharea
14
75 case
executed 4 times by 1 test: case QEvent::TouchCancel:
Executed by:
  • tst_qquickpincharea
QEvent::TouchCancel:
executed 4 times by 1 test: case QEvent::TouchCancel:
Executed by:
  • tst_qquickpincharea
4
76 cancelPinch();-
77 break;
executed 4 times by 1 test: break;
Executed by:
  • tst_qquickpincharea
4
78 default
never executed: default:
:
never executed: default:
0
79 QQuickItem::touchEvent(event);-
80 }
never executed: end of block
0
81}-
82-
83void QQuickPinchArea::clearPinch()-
84{-
85 QQuickPinchAreaPrivate * const d = d_func();-
86-
87 d->touchPoints.clear();-
88 if (d->inPinch
d->inPinchDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
) {
2-12
89 d->inPinch = false;-
90 QPointF pinchCenter = mapFromScene(d->sceneLastCenter);-
91 QQuickPinchEvent pe(pinchCenter, d->pinchLastScale, d->pinchLastAngle, d->pinchRotation);-
92 pe.setStartCenter(d->pinchStartCenter);-
93 pe.setPreviousCenter(pinchCenter);-
94 pe.setPreviousAngle(d->pinchLastAngle);-
95 pe.setPreviousScale(d->pinchLastScale);-
96 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));-
97 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));-
98 pe.setPoint1(mapFromScene(d->lastPoint1));-
99 pe.setPoint2(mapFromScene(d->lastPoint2));-
100 pinchFinished(&pe);-
101 if (d->pinch
d->pinchDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
&& d->pinch->target()
d->pinch->target()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
)
0-12
102 d->pinch->setActive(false);
executed 12 times by 1 test: d->pinch->setActive(false);
Executed by:
  • tst_qquickpincharea
12
103 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
12
104 d->pinchStartDist = 0;-
105 d->pinchActivated = false;-
106 d->initPinch = false;-
107 d->pinchRejected = false;-
108 d->stealMouse = false;-
109 d->id1 = -1;-
110 QQuickWindow *win = window();-
111 if (win
winDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
&& win->mouseGrabberItem() == this
win->mouseGrab...Item() == thisDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
0-14
112 ungrabMouse();
executed 12 times by 1 test: ungrabMouse();
Executed by:
  • tst_qquickpincharea
12
113 setKeepMouseGrab(false);-
114}
executed 14 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
14
115-
116void QQuickPinchArea::cancelPinch()-
117{-
118 QQuickPinchAreaPrivate * const d = d_func();-
119-
120 d->touchPoints.clear();-
121 if (d->inPinch
d->inPinchDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
) {
2
122 d->inPinch = false;-
123 QPointF pinchCenter = mapFromScene(d->sceneLastCenter);-
124 QQuickPinchEvent pe(d->pinchStartCenter, d->pinchStartScale, d->pinchStartAngle, d->pinchStartRotation);-
125 pe.setStartCenter(d->pinchStartCenter);-
126 pe.setPreviousCenter(pinchCenter);-
127 pe.setPreviousAngle(d->pinchLastAngle);-
128 pe.setPreviousScale(d->pinchLastScale);-
129 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));-
130 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));-
131 pe.setPoint1(pe.startPoint1());-
132 pe.setPoint2(pe.startPoint2());-
133 pinchFinished(&pe);-
134-
135 d->pinchLastScale = d->pinchStartScale;-
136 d->sceneLastCenter = d->sceneStartCenter;-
137 d->pinchLastAngle = d->pinchStartAngle;-
138 d->lastPoint1 = pe.startPoint1();-
139 d->lastPoint2 = pe.startPoint2();-
140 updatePinchTarget();-
141-
142 if (d->pinch
d->pinchDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
&& d->pinch->target()
d->pinch->target()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
)
0-2
143 d->pinch->setActive(false);
executed 2 times by 1 test: d->pinch->setActive(false);
Executed by:
  • tst_qquickpincharea
2
144 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
2
145 d->pinchStartDist = 0;-
146 d->pinchActivated = false;-
147 d->initPinch = false;-
148 d->pinchRejected = false;-
149 d->stealMouse = false;-
150 d->id1 = -1;-
151 QQuickWindow *win = window();-
152 if (win
winDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
&& win->mouseGrabberItem() == this
win->mouseGrab...Item() == thisDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
0-4
153 ungrabMouse();
never executed: ungrabMouse();
0
154 setKeepMouseGrab(false);-
155}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
4
156-
157void QQuickPinchArea::updatePinch()-
158{-
159 QQuickPinchAreaPrivate * const d = d_func();-
160-
161 QQuickWindow *win = window();-
162-
163 if (d->touchPoints.count() < 2
d->touchPoints.count() < 2Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquickpincharea
) {
20-50
164 setKeepMouseGrab(false);-
165 QQuickWindow *c = window();-
166 if (c
cDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
&& c->mouseGrabberItem() == this
c->mouseGrabberItem() == thisDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
0-20
167 ungrabMouse();
executed 2 times by 1 test: ungrabMouse();
Executed by:
  • tst_qquickpincharea
2
168 }
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
20
169-
170 if (d->touchPoints.count() == 0
d->touchPoints.count() == 0Description
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • tst_qquickpincharea
) {
0-70
171 if (d->inPinch
d->inPinchDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
172 d->inPinch = false;-
173 QPointF pinchCenter = mapFromScene(d->sceneLastCenter);-
174 QQuickPinchEvent pe(pinchCenter, d->pinchLastScale, d->pinchLastAngle, d->pinchRotation);-
175 pe.setStartCenter(d->pinchStartCenter);-
176 pe.setPreviousCenter(pinchCenter);-
177 pe.setPreviousAngle(d->pinchLastAngle);-
178 pe.setPreviousScale(d->pinchLastScale);-
179 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));-
180 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));-
181 pe.setPoint1(mapFromScene(d->lastPoint1));-
182 pe.setPoint2(mapFromScene(d->lastPoint2));-
183 pinchFinished(&pe);-
184 d->pinchStartDist = 0;-
185 d->pinchActivated = false;-
186 if (d->pinch
d->pinchDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->pinch->target()
d->pinch->target()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
187 d->pinch->setActive(false);
never executed: d->pinch->setActive(false);
0
188 }
never executed: end of block
0
189 d->initPinch = false;-
190 d->pinchRejected = false;-
191 d->stealMouse = false;-
192 return;
never executed: return;
0
193 }-
194-
195 QTouchEvent::TouchPoint touchPoint1 = d->touchPoints.at(0);-
196 QTouchEvent::TouchPoint touchPoint2 = d->touchPoints.at(d->touchPoints. count() >= 2 ? 1 : 0);-
197-
198 if (touchPoint1.state() == Qt::TouchPointPressed
touchPoint1.st...chPointPressedDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 54 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
16-54
199 d->sceneStartPoint1 = touchPoint1.scenePos();
executed 16 times by 1 test: d->sceneStartPoint1 = touchPoint1.scenePos();
Executed by:
  • tst_qquickpincharea
16
200-
201 if (touchPoint2.state() == Qt::TouchPointPressed
touchPoint2.st...chPointPressedDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
32-38
202 d->sceneStartPoint2 = touchPoint2.scenePos();
executed 32 times by 1 test: d->sceneStartPoint2 = touchPoint2.scenePos();
Executed by:
  • tst_qquickpincharea
32
203-
204 QRectF bounds = clipRect();-
205-
206-
207-
208 if (d->touchPoints.count() == 2
d->touchPoints.count() == 2Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpincharea
20-50
209 && (touchPoint1.state() & Qt::TouchPointPressed
touchPoint1.st...chPointPressedDescription
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquickpincharea
|| touchPoint2.state() & Qt::TouchPointPressed
touchPoint2.st...chPointPressedDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_qquickpincharea
) &&
0-50
210 bounds.contains(touchPoint1.pos())
bounds.contain...hPoint1.pos())Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
&& bounds.contains(touchPoint2.pos())
bounds.contain...hPoint2.pos())Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
) {
0-16
211 d->id1 = touchPoint1.id();-
212 d->pinchActivated = true;-
213 d->initPinch = true;-
214-
215 int touchMouseId = QQuickWindowPrivate::get(win)->touchMouseId;-
216 if (touchPoint1.id() == touchMouseId
touchPoint1.id...= touchMouseIdDescription
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
|| touchPoint2.id() == touchMouseId
touchPoint2.id...= touchMouseIdDescription
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
) {
0-16
217 if (win
winDescription
TRUEnever evaluated
FALSEnever evaluated
&& win->mouseGrabberItem() != this
win->mouseGrab...Item() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
218 grabMouse();-
219 }
never executed: end of block
0
220 }
never executed: end of block
0
221 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
16
222 if (d->pinchActivated
d->pinchActivatedDescription
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickpincharea
&& !d->pinchRejected
!d->pinchRejectedDescription
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
) {
0-52
223 const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();-
224 QPointF p1 = touchPoint1.scenePos();-
225 QPointF p2 = touchPoint2.scenePos();-
226 qreal dx = p1.x() - p2.x();-
227 qreal dy = p1.y() - p2.y();-
228 qreal dist = qSqrt(dx*dx + dy*dy);-
229 QPointF sceneCenter = (p1 + p2)/2;-
230 qreal angle = QLineF(p1, p2).angle();-
231 if (d->touchPoints.count() == 1
d->touchPoints.count() == 1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquickpincharea
) {
2-50
232-
233 if (d->id1 == touchPoint1.id()
d->id1 == touchPoint1.id()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
)
0-2
234 sceneCenter = d->sceneLastCenter + touchPoint1.scenePos() - d->lastPoint1;
executed 2 times by 1 test: sceneCenter = d->sceneLastCenter + touchPoint1.scenePos() - d->lastPoint1;
Executed by:
  • tst_qquickpincharea
2
235 else-
236 sceneCenter = d->sceneLastCenter + touchPoint2.scenePos() - d->lastPoint2;
never executed: sceneCenter = d->sceneLastCenter + touchPoint2.scenePos() - d->lastPoint2;
0
237 angle = d->pinchLastAngle;-
238 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
2
239 d->id1 = touchPoint1.id();-
240 if (angle > 180
angle > 180Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
10-42
241 angle -= 360;
executed 42 times by 1 test: angle -= 360;
Executed by:
  • tst_qquickpincharea
42
242 if (!d->inPinch
!d->inPinchDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickpincharea
|| d->initPinch
d->initPinchDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpincharea
) {
2-30
243 if (d->touchPoints.count() >= 2
d->touchPoints.count() >= 2Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
) {
0-32
244 if (d->initPinch
d->initPinchDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
) {
16
245 if (!d->inPinch
!d->inPinchDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
2-14
246 d->pinchStartDist = dist;
executed 14 times by 1 test: d->pinchStartDist = dist;
Executed by:
  • tst_qquickpincharea
14
247 d->initPinch = false;-
248 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
16
249 d->sceneStartCenter = sceneCenter;-
250 d->sceneLastCenter = sceneCenter;-
251 d->pinchStartCenter = mapFromScene(sceneCenter);-
252 d->pinchStartAngle = angle;-
253 d->pinchLastScale = 1.0;-
254 d->pinchLastAngle = angle;-
255 d->pinchRotation = 0.0;-
256 d->lastPoint1 = p1;-
257 d->lastPoint2 = p2;-
258 if (qAbs(dist - d->pinchStartDist) >= dragThreshold
qAbs(dist - d-... dragThresholdDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpincharea
||
12-20
259 (pinch()->axis() != QQuickPinch::NoDrag
pinch()->axis(...kPinch::NoDragDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
&&
0-20
260 (qAbs(p1.x()-d->sceneStartPoint1.x()) >= dragThreshold
qAbs(p1.x()-d-... dragThresholdDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickpincharea
2-18
261 || qAbs(p1.y()-d->sceneStartPoint1.y()) >= dragThreshold
qAbs(p1.y()-d-... dragThresholdDescription
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickpincharea
0-18
262 || qAbs(p2.x()-d->sceneStartPoint2.x()) >= dragThreshold
qAbs(p2.x()-d-... dragThresholdDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
2-16
263 || qAbs(p2.y()-d->sceneStartPoint2.y()) >= dragThreshold
qAbs(p2.y()-d-... dragThresholdDescription
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
))) {
0-16
264 QQuickPinchEvent pe(d->pinchStartCenter, 1.0, angle, 0.0);-
265 d->pinchStartDist = dist;-
266 pe.setStartCenter(d->pinchStartCenter);-
267 pe.setPreviousCenter(d->pinchStartCenter);-
268 pe.setPreviousAngle(d->pinchLastAngle);-
269 pe.setPreviousScale(d->pinchLastScale);-
270 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));-
271 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));-
272 pe.setPoint1(mapFromScene(d->lastPoint1));-
273 pe.setPoint2(mapFromScene(d->lastPoint2));-
274 pe.setPointCount(d->touchPoints.count());-
275 pinchStarted(&pe);-
276 if (pe.accepted()
pe.accepted()Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
) {
0-16
277 d->inPinch = true;-
278 d->stealMouse = true;-
279 if (win
winDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
&& win->mouseGrabberItem() != this
win->mouseGrab...Item() != thisDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
)
0-16
280 grabMouse();
executed 16 times by 1 test: grabMouse();
Executed by:
  • tst_qquickpincharea
16
281 setKeepMouseGrab(true);-
282 grabTouchPoints(QVector<int>() << touchPoint1.id() << touchPoint2.id());-
283 d->inPinch = true;-
284 d->stealMouse = true;-
285 if (d->pinch
d->pinchDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
&& d->pinch->target()
d->pinch->target()Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
) {
0-16
286 d->pinchStartPos = pinch()->target()->position();-
287 d->pinchStartScale = d->pinch->target()->scale();-
288 d->pinchStartRotation = d->pinch->target()->rotation();-
289 d->pinch->setActive(true);-
290 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
16
291 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
else {
16
292 d->pinchRejected = true;-
293 }
never executed: end of block
0
294 }-
295 }
executed 32 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
32
296 }
executed 32 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
else if (d->pinchStartDist > 0
d->pinchStartDist > 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
) {
0-32
297 qreal scale = dist
distDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
? dist / d->pinchStartDist : d->pinchLastScale;
2-18
298 qreal da = d->pinchLastAngle - angle;-
299 if (da > 180
da > 180Description
TRUEnever evaluated
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
0-20
300 da -= 360;
never executed: da -= 360;
0
301 else if (da < -180
da < -180Description
TRUEnever evaluated
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
0-20
302 da += 360;
never executed: da += 360;
0
303 d->pinchRotation += da;-
304 QPointF pinchCenter = mapFromScene(sceneCenter);-
305 QQuickPinchEvent pe(pinchCenter, scale, angle, d->pinchRotation);-
306 pe.setStartCenter(d->pinchStartCenter);-
307 pe.setPreviousCenter(mapFromScene(d->sceneLastCenter));-
308 pe.setPreviousAngle(d->pinchLastAngle);-
309 pe.setPreviousScale(d->pinchLastScale);-
310 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));-
311 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));-
312 pe.setPoint1(touchPoint1.pos());-
313 pe.setPoint2(touchPoint2.pos());-
314 pe.setPointCount(d->touchPoints.count());-
315 d->pinchLastScale = scale;-
316 d->sceneLastCenter = sceneCenter;-
317 d->pinchLastAngle = angle;-
318 d->lastPoint1 = touchPoint1.scenePos();-
319 d->lastPoint2 = touchPoint2.scenePos();-
320 pinchUpdated(&pe);-
321 updatePinchTarget();-
322 }
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
20
323 }
executed 52 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
52
324}
executed 70 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
70
325-
326void QQuickPinchArea::updatePinchTarget()-
327{-
328 QQuickPinchAreaPrivate * const d = d_func();-
329 if (d->pinch
d->pinchDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
&& d->pinch->target()
d->pinch->target()Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
) {
0-22
330 qreal s = d->pinchStartScale * d->pinchLastScale;-
331 s = qMin(qMax(pinch()->minimumScale(),s), pinch()->maximumScale());-
332 pinch()->target()->setScale(s);-
333 QPointF pos = d->sceneLastCenter - d->sceneStartCenter + d->pinchStartPos;-
334 if (pinch()->axis() & QQuickPinch::XAxis
pinch()->axis(...ckPinch::XAxisDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
) {
0-22
335 qreal x = pos.x();-
336 if (x < pinch()->xmin()
x < pinch()->xmin()Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
0-22
337 x = pinch()->xmin();
never executed: x = pinch()->xmin();
0
338 else if (x > pinch()->xmax()
x > pinch()->xmax()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
2-20
339 x = pinch()->xmax();
executed 2 times by 1 test: x = pinch()->xmax();
Executed by:
  • tst_qquickpincharea
2
340 pinch()->target()->setX(x);-
341 }
executed 22 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
22
342 if (pinch()->axis() & QQuickPinch::YAxis
pinch()->axis(...ckPinch::YAxisDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
) {
0-22
343 qreal y = pos.y();-
344 if (y < pinch()->ymin()
y < pinch()->ymin()Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
0-22
345 y = pinch()->ymin();
never executed: y = pinch()->ymin();
0
346 else if (y > pinch()->ymax()
y > pinch()->ymax()Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
0-22
347 y = pinch()->ymax();
never executed: y = pinch()->ymax();
0
348 pinch()->target()->setY(y);-
349 }
executed 22 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
22
350 if (d->pinchStartRotation >= pinch()->minimumRotation()
d->pinchStartR...imumRotation()Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
0-22
351 && d->pinchStartRotation <= pinch()->maximumRotation()
d->pinchStartR...imumRotation()Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qquickpincharea
FALSEnever evaluated
) {
0-22
352 qreal r = d->pinchRotation + d->pinchStartRotation;-
353 r = qMin(qMax(pinch()->minimumRotation(),r), pinch()->maximumRotation());-
354 pinch()->target()->setRotation(r);-
355 }
executed 22 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
22
356 }
executed 22 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
22
357}
executed 22 times by 1 test: end of block
Executed by:
  • tst_qquickpincharea
22
358-
359bool QQuickPinchArea::childMouseEventFilter(QQuickItem *i, QEvent *e)-
360{-
361 QQuickPinchAreaPrivate * const d = d_func();-
362 if (!d->enabled
!d->enabledDescription
TRUEnever evaluated
FALSEnever evaluated
|| !isVisible()
!isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
363 return
never executed: return QQuickItem::childMouseEventFilter(i, e);
QQuickItem::childMouseEventFilter(i, e);
never executed: return QQuickItem::childMouseEventFilter(i, e);
0
364 switch (e->type()) {-
365 case
never executed: case QEvent::TouchBegin:
QEvent::TouchBegin:
never executed: case QEvent::TouchBegin:
0
366 clearPinch();-
367 (void)0;-
368 case
never executed: case QEvent::TouchUpdate:
QEvent::TouchUpdate:
never executed: case QEvent::TouchUpdate:
code before this statement never executed: case QEvent::TouchUpdate:
{
0
369 QTouchEvent *touch = static_cast<QTouchEvent*>(e);-
370 d->touchPoints.clear();-
371 for (int i = 0; i < touch->touchPoints().count()
i < touch->tou...ints().count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
372 if (!(touch->touchPoints().at(i).state() & Qt::TouchPointReleased)
!(touch->touch...PointReleased)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
373 d->touchPoints << touch->touchPoints().at(i);
never executed: d->touchPoints << touch->touchPoints().at(i);
0
374 updatePinch();-
375 }-
376 e->setAccepted(d->inPinch);-
377 return
never executed: return d->inPinch;
d->inPinch;
never executed: return d->inPinch;
0
378 case
never executed: case QEvent::TouchEnd:
QEvent::TouchEnd:
never executed: case QEvent::TouchEnd:
0
379 clearPinch();-
380 break;
never executed: break;
0
381 default
never executed: default:
:
never executed: default:
0
382 break;
never executed: break;
0
383 }-
384-
385 return
never executed: return QQuickItem::childMouseEventFilter(i, e);
QQuickItem::childMouseEventFilter(i, e);
never executed: return QQuickItem::childMouseEventFilter(i, e);
0
386}-
387-
388void QQuickPinchArea::geometryChanged(const QRectF &newGeometry,-
389 const QRectF &oldGeometry)-
390{-
391 QQuickItem::geometryChanged(newGeometry, oldGeometry);-
392}
executed 36 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickpincharea
  • tst_touchmouse
36
393-
394void QQuickPinchArea::itemChange(ItemChange change, const ItemChangeData &value)-
395{-
396 QQuickItem::itemChange(change, value);-
397}
executed 134 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickpincharea
  • tst_touchmouse
134
398-
399bool QQuickPinchArea::event(QEvent *event)-
400{-
401 QQuickPinchAreaPrivate * const d = d_func();-
402 if (!d->enabled
!d->enabledDescription
TRUEnever evaluated
FALSEevaluated 88 times by 1 test
Evaluated by:
  • tst_qquickpincharea
|| !isVisible()
!isVisible()Description
TRUEnever evaluated
FALSEevaluated 88 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
0-88
403 return
never executed: return QQuickItem::event(event);
QQuickItem::event(event);
never executed: return QQuickItem::event(event);
0
404-
405 switch (event->type()) {-
406-
407 case
never executed: case QEvent::NativeGesture:
QEvent::NativeGesture:
never executed: case QEvent::NativeGesture:
{
0
408 QNativeGestureEvent *gesture = static_cast<QNativeGestureEvent *>(event);-
409 switch (gesture->gestureType()) {-
410 case
never executed: case Qt::BeginNativeGesture:
Qt::BeginNativeGesture:
never executed: case Qt::BeginNativeGesture:
0
411 clearPinch();-
412 d->pinchStartCenter = gesture->localPos();-
413 d->pinchStartAngle = 0.0;-
414 d->pinchStartRotation = 0.0;-
415 d->pinchRotation = 0.0;-
416 d->pinchStartScale = 1.0;-
417 d->pinchLastAngle = 0.0;-
418 d->pinchLastScale = 1.0;-
419 d->sceneStartPoint1 = gesture->windowPos();-
420 d->sceneStartPoint2 = gesture->windowPos();-
421 d->lastPoint1 = gesture->windowPos();-
422 d->lastPoint2 = gesture->windowPos();-
423 if (d->pinch
d->pinchDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->pinch->target()
d->pinch->target()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
424 d->pinchStartPos = d->pinch->target()->position();-
425 d->pinchStartScale = d->pinch->target()->scale();-
426 d->pinchStartRotation = d->pinch->target()->rotation();-
427 d->pinch->setActive(true);-
428 }
never executed: end of block
0
429 break;
never executed: break;
0
430 case
never executed: case Qt::EndNativeGesture:
Qt::EndNativeGesture:
never executed: case Qt::EndNativeGesture:
0
431 clearPinch();-
432 break;
never executed: break;
0
433 case
never executed: case Qt::ZoomNativeGesture:
Qt::ZoomNativeGesture:
never executed: case Qt::ZoomNativeGesture:
{
0
434 qreal scale = d->pinchLastScale * (1.0 + gesture->value());-
435 QQuickPinchEvent pe(d->pinchStartCenter, scale, d->pinchLastAngle, 0.0);-
436 pe.setStartCenter(d->pinchStartCenter);-
437 pe.setPreviousCenter(d->pinchStartCenter);-
438 pe.setPreviousAngle(d->pinchLastAngle);-
439 pe.setPreviousScale(d->pinchLastScale);-
440 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));-
441 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));-
442 pe.setPoint1(mapFromScene(d->lastPoint1));-
443 pe.setPoint2(mapFromScene(d->lastPoint2));-
444 pe.setPointCount(2);-
445 d->pinchLastScale = scale;-
446 if (d->inPinch
d->inPinchDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
447 pinchUpdated(&pe);
never executed: pinchUpdated(&pe);
0
448 else-
449 pinchStarted(&pe);
never executed: pinchStarted(&pe);
0
450 d->inPinch = true;-
451 updatePinchTarget();-
452 } break;
never executed: break;
0
453 case
never executed: case Qt::SmartZoomNativeGesture:
Qt::SmartZoomNativeGesture:
never executed: case Qt::SmartZoomNativeGesture:
{
0
454 if (gesture->value() > 0.0
gesture->value() > 0.0Description
TRUEnever evaluated
FALSEnever evaluated
&& d->pinch
d->pinchDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->pinch->target()
d->pinch->target()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
455 d->pinchStartPos = pinch()->target()->position();-
456 d->pinchStartCenter = mapToItem(pinch()->target()->parentItem(), pinch()->target()->boundingRect().center());-
457 d->pinchStartScale = d->pinch->target()->scale();-
458 d->pinchStartRotation = d->pinch->target()->rotation();-
459 d->pinchLastScale = d->pinchStartScale = d->pinch->target()->scale();-
460 d->pinchLastAngle = d->pinchStartRotation = d->pinch->target()->rotation();-
461 }
never executed: end of block
0
462 QQuickPinchEvent pe(gesture->localPos(), gesture->value(), d->pinchLastAngle, 0.0);-
463 pe.setStartCenter(gesture->localPos());-
464 pe.setPreviousCenter(d->pinchStartCenter);-
465 pe.setPreviousAngle(d->pinchLastAngle);-
466 pe.setPreviousScale(d->pinchLastScale);-
467 pe.setStartPoint1(gesture->localPos());-
468 pe.setStartPoint2(gesture->localPos());-
469 pe.setPoint1(mapFromScene(gesture->windowPos()));-
470 pe.setPoint2(mapFromScene(gesture->windowPos()));-
471 pe.setPointCount(2);-
472 smartZoom(&pe);-
473 } break;
never executed: break;
0
474 case
never executed: case Qt::RotateNativeGesture:
Qt::RotateNativeGesture:
never executed: case Qt::RotateNativeGesture:
{
0
475 qreal angle = d->pinchLastAngle + gesture->value();-
476 QQuickPinchEvent pe(d->pinchStartCenter, d->pinchLastScale, angle, 0.0);-
477 pe.setStartCenter(d->pinchStartCenter);-
478 pe.setPreviousCenter(d->pinchStartCenter);-
479 pe.setPreviousAngle(d->pinchLastAngle);-
480 pe.setPreviousScale(d->pinchLastScale);-
481 pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));-
482 pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));-
483 pe.setPoint1(mapFromScene(d->lastPoint1));-
484 pe.setPoint2(mapFromScene(d->lastPoint2));-
485 pe.setPointCount(2);-
486 d->pinchLastAngle = angle;-
487 if (d->inPinch
d->inPinchDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
488 pinchUpdated(&pe);
never executed: pinchUpdated(&pe);
0
489 else-
490 pinchStarted(&pe);
never executed: pinchStarted(&pe);
0
491 d->inPinch = true;-
492 d->pinchRotation = angle;-
493 updatePinchTarget();-
494 } break;
never executed: break;
0
495 default
never executed: default:
:
never executed: default:
0
496 return
never executed: return QQuickItem::event(event);
QQuickItem::event(event);
never executed: return QQuickItem::event(event);
0
497 }-
498 } break;
never executed: break;
0
499-
500 case
never executed: case QEvent::Wheel:
QEvent::Wheel:
never executed: case QEvent::Wheel:
0
501 event->ignore();-
502 return
never executed: return false;
false;
never executed: return false;
0
503 default
executed 88 times by 1 test: default:
Executed by:
  • tst_qquickpincharea
:
executed 88 times by 1 test: default:
Executed by:
  • tst_qquickpincharea
88
504 return
executed 88 times by 1 test: return QQuickItem::event(event);
Executed by:
  • tst_qquickpincharea
QQuickItem::event(event);
executed 88 times by 1 test: return QQuickItem::event(event);
Executed by:
  • tst_qquickpincharea
88
505 }-
506-
507 return
never executed: return true;
true;
never executed: return true;
0
508}-
509-
510QQuickPinch *QQuickPinchArea::pinch()-
511{-
512 QQuickPinchAreaPrivate * const d = d_func();-
513 if (!d->pinch
!d->pinchDescription
TRUEevaluated 30 times by 2 tests
Evaluated by:
  • tst_qquickpincharea
  • tst_touchmouse
FALSEevaluated 400 times by 1 test
Evaluated by:
  • tst_qquickpincharea
)
30-400
514 d->pinch = new QQuickPinch;
executed 30 times by 2 tests: d->pinch = new QQuickPinch;
Executed by:
  • tst_qquickpincharea
  • tst_touchmouse
30
515 return
executed 430 times by 2 tests: return d->pinch;
Executed by:
  • tst_qquickpincharea
  • tst_touchmouse
d->pinch;
executed 430 times by 2 tests: return d->pinch;
Executed by:
  • tst_qquickpincharea
  • tst_touchmouse
430
516}-
517-
518-
519-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0