OpenCoverage

qquickdraghandler.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/handlers/qquickdraghandler.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3QQuickDragHandler::QQuickDragHandler(QObject *parent)-
4 : QQuickSinglePointHandler(parent)-
5{-
6}
executed 396 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
396
7-
8QQuickDragHandler::~QQuickDragHandler()-
9{-
10}-
11-
12bool QQuickDragHandler::wantsEventPoint(QQuickEventPoint *point)-
13{-
14-
15 return
executed 4376 times by 3 tests: return ((point->state() != QQuickEventPoint::Pressed && this->point().id() == point->pointId()) || QQuickSinglePointHandler::wantsEventPoint(point));
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
((point->state() != QQuickEventPoint::Pressed && this->point().id() == point->pointId())
executed 4376 times by 3 tests: return ((point->state() != QQuickEventPoint::Pressed && this->point().id() == point->pointId()) || QQuickSinglePointHandler::wantsEventPoint(point));
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
4376
16 || QQuickSinglePointHandler::wantsEventPoint(point));
executed 4376 times by 3 tests: return ((point->state() != QQuickEventPoint::Pressed && this->point().id() == point->pointId()) || QQuickSinglePointHandler::wantsEventPoint(point));
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
4376
17}-
18-
19bool QQuickDragHandler::targetContains(QQuickEventPoint *point)-
20{-
21 ((parentItem() && target()) ? static_cast<void>(0) : qt_assert("parentItem() && target()", __FILE__, 97));-
22 return
executed 78 times by 3 tests: return target()->contains(localTargetPosition(point));
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
target()->contains(localTargetPosition(point));
executed 78 times by 3 tests: return target()->contains(localTargetPosition(point));
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
78
23}-
24-
25QPointF QQuickDragHandler::localTargetPosition(QQuickEventPoint *point)-
26{-
27 QPointF pos = point->position();-
28 if (target() != parentItem()
target() != parentItem()Description
TRUEevaluated 210 times by 2 tests
Evaluated by:
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEevaluated 318 times by 2 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
)
210-318
29 pos = parentItem()->mapToItem(target(), pos);
executed 210 times by 2 tests: pos = parentItem()->mapToItem(target(), pos);
Executed by:
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
210
30 return
executed 528 times by 3 tests: return pos;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
pos;
executed 528 times by 3 tests: return pos;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
528
31}-
32-
33void QQuickDragHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point)-
34{-
35 if (grabber == this
grabber == thisDescription
TRUEevaluated 244 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEnever evaluated
&& stateChange == QQuickEventPoint::GrabExclusive
stateChange ==...:GrabExclusiveDescription
TRUEevaluated 74 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEevaluated 170 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
) {
0-244
36-
37 if (!m_pressedInsideTarget
!m_pressedInsideTargetDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickdraghandler
FALSEevaluated 62 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
) {
12-62
38 if (target()
target()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickdraghandler
FALSEnever evaluated
)
0-12
39 m_pressTargetPos = QPointF(target()->width(), target()->height()) / 2;
executed 12 times by 1 test: m_pressTargetPos = QPointF(target()->width(), target()->height()) / 2;
Executed by:
  • tst_qquickdraghandler
12
40 m_pressScenePos = point->scenePosition();-
41 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickdraghandler
else if (m_pressTargetPos.isNull()
m_pressTargetPos.isNull()Description
TRUEnever evaluated
FALSEevaluated 62 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
) {
0-62
42 if (target()
target()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
43 m_pressTargetPos = localTargetPosition(point);
never executed: m_pressTargetPos = localTargetPosition(point);
0
44 m_pressScenePos = point->scenePosition();-
45 }
never executed: end of block
0
46 }
executed 74 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
74
47 QQuickSinglePointHandler::onGrabChanged(grabber, stateChange, point);-
48}
executed 244 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
244
49-
50void QQuickDragHandler::onActiveChanged()-
51{-
52 if (!active()
!active()Description
TRUEevaluated 74 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEevaluated 74 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
) {
74
53 m_pressTargetPos = QPointF();-
54 m_pressScenePos = m_pressTargetPos;-
55 m_pressedInsideTarget = false;-
56 }
executed 74 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
74
57}
executed 148 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
148
58-
59void QQuickDragHandler::handleEventPoint(QQuickEventPoint *point)-
60{-
61 point->setAccepted();-
62 switch (point->state()) {-
63 case
executed 78 times by 3 tests: case QQuickEventPoint::Pressed:
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
QQuickEventPoint::Pressed:
executed 78 times by 3 tests: case QQuickEventPoint::Pressed:
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
78
64 if (target()
target()Description
TRUEevaluated 78 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEnever evaluated
) {
0-78
65 m_pressedInsideTarget = targetContains(point);-
66 m_pressTargetPos = localTargetPosition(point);-
67 }
executed 78 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
78
68 m_pressScenePos = point->scenePosition();-
69 setPassiveGrab(point);-
70 break;
executed 78 times by 3 tests: break;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
78
71 case
executed 586 times by 3 tests: case QQuickEventPoint::Updated:
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
QQuickEventPoint::Updated:
executed 586 times by 3 tests: case QQuickEventPoint::Updated:
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
{
586
72 QVector2D accumulatedDragDelta = QVector2D(point->scenePosition() - m_pressScenePos);-
73 if (active()
active()Description
TRUEevaluated 372 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEevaluated 214 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
) {
214-372
74-
75 if (!m_xAxis.enabled()
!m_xAxis.enabled()Description
TRUEevaluated 228 times by 2 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
FALSEevaluated 144 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
)
144-228
76 accumulatedDragDelta.setX(0);
executed 228 times by 2 tests: accumulatedDragDelta.setX(0);
Executed by:
  • tst_flickableinterop
  • tst_qquickdraghandler
228
77 if (!m_yAxis.enabled()
!m_yAxis.enabled()Description
TRUEnever evaluated
FALSEevaluated 372 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
)
0-372
78 accumulatedDragDelta.setY(0);
never executed: accumulatedDragDelta.setY(0);
0
79 setTranslation(accumulatedDragDelta);-
80-
81 if (target()
target()Description
TRUEevaluated 372 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEnever evaluated
&& target()->parentItem()
target()->parentItem()Description
TRUEevaluated 372 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEnever evaluated
) {
0-372
82 const QPointF newTargetTopLeft = localTargetPosition(point) - m_pressTargetPos;-
83 const QPointF xformOrigin = target()->transformOriginPoint();-
84 const QPointF targetXformOrigin = newTargetTopLeft + xformOrigin;-
85 QPointF pos = target()->parentItem()->mapFromItem(target(), targetXformOrigin);-
86 pos -= xformOrigin;-
87 QPointF targetItemPos = target()->position();-
88 if (!m_xAxis.enabled()
!m_xAxis.enabled()Description
TRUEevaluated 228 times by 2 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
FALSEevaluated 144 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
)
144-228
89 pos.setX(targetItemPos.x());
executed 228 times by 2 tests: pos.setX(targetItemPos.x());
Executed by:
  • tst_flickableinterop
  • tst_qquickdraghandler
228
90 if (!m_yAxis.enabled()
!m_yAxis.enabled()Description
TRUEnever evaluated
FALSEevaluated 372 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
)
0-372
91 pos.setY(targetItemPos.y());
never executed: pos.setY(targetItemPos.y());
0
92 enforceAxisConstraints(&pos);-
93 moveTarget(pos, point);-
94 }
executed 372 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
372
95 }
executed 372 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
else if (!point->exclusiveGrabber()
!point->exclusiveGrabber()Description
TRUEevaluated 214 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEnever evaluated
&&
0-372
96 ((m_xAxis.enabled()
m_xAxis.enabled()Description
TRUEevaluated 116 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEevaluated 98 times by 2 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
&& QQuickWindowPrivate::dragOverThreshold(accumulatedDragDelta.x(), Qt::XAxis, point)
QQuickWindowPr...:XAxis, point)Description
TRUEevaluated 30 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEevaluated 86 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
) ||
30-116
97 (m_yAxis.enabled()
m_yAxis.enabled()Description
TRUEevaluated 184 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEnever evaluated
&& QQuickWindowPrivate::dragOverThreshold(accumulatedDragDelta.y(), Qt::YAxis, point)
QQuickWindowPr...:YAxis, point)Description
TRUEevaluated 44 times by 2 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
FALSEevaluated 140 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
))) {
0-184
98 setExclusiveGrab(point);-
99 if (auto parent = parentItem()
auto parent = parentItem()Description
TRUEevaluated 74 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEnever evaluated
) {
0-74
100 if (point->pointerEvent()->asPointerTouchEvent()
point->pointer...erTouchEvent()Description
TRUEevaluated 64 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
)
10-64
101 parent->setKeepTouchGrab(true);
executed 64 times by 3 tests: parent->setKeepTouchGrab(true);
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
64
102-
103-
104-
105 parent->setKeepMouseGrab(true);-
106 }
executed 74 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
74
107 }
executed 74 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
74
108 } break;
executed 586 times by 3 tests: break;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
586
109 default
executed 92 times by 3 tests: default:
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
:
executed 92 times by 3 tests: default:
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
92
110 break;
executed 92 times by 3 tests: break;
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
92
111 }-
112}-
113-
114void QQuickDragHandler::enforceConstraints()-
115{-
116 if (!target()
!target()Description
TRUEnever evaluated
FALSEnever evaluated
|| !target()->parentItem()
!target()->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
117 return;
never executed: return;
0
118 QPointF pos = target()->position();-
119 QPointF copy(pos);-
120 enforceAxisConstraints(&pos);-
121 if (pos != copy
pos != copyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
122 target()->setPosition(pos);
never executed: target()->setPosition(pos);
0
123}
never executed: end of block
0
124-
125void QQuickDragHandler::enforceAxisConstraints(QPointF *localPos)-
126{-
127 if (m_xAxis.enabled()
m_xAxis.enabled()Description
TRUEevaluated 144 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEevaluated 228 times by 2 tests
Evaluated by:
  • tst_flickableinterop
  • tst_qquickdraghandler
)
144-228
128 localPos->setX(qBound(m_xAxis.minimum(), localPos->x(), m_xAxis.maximum()));
executed 144 times by 3 tests: localPos->setX(qBound(m_xAxis.minimum(), localPos->x(), m_xAxis.maximum()));
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
144
129 if (m_yAxis.enabled()
m_yAxis.enabled()Description
TRUEevaluated 372 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
FALSEnever evaluated
)
0-372
130 localPos->setY(qBound(m_yAxis.minimum(), localPos->y(), m_yAxis.maximum()));
executed 372 times by 3 tests: localPos->setY(qBound(m_yAxis.minimum(), localPos->y(), m_yAxis.maximum()));
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
372
131}
executed 372 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
372
132-
133void QQuickDragHandler::setTranslation(const QVector2D &trans)-
134{-
135 if (trans == m_translation
trans == m_translationDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_flickableinterop
FALSEevaluated 368 times by 3 tests
Evaluated by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
)
4-368
136 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_flickableinterop
4
137 m_translation = trans;-
138 translationChanged();-
139}
executed 368 times by 3 tests: end of block
Executed by:
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qquickdraghandler
368
140-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0