| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/handlers/qquickdraghandler.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | QQuickDragHandler::QQuickDragHandler(QObject *parent) | - | ||||||||||||
| 4 | : QQuickSinglePointHandler(parent) | - | ||||||||||||
| 5 | { | - | ||||||||||||
| 6 | } executed 396 times by 3 tests: end of blockExecuted by:
| 396 | ||||||||||||
| 7 | - | |||||||||||||
| 8 | QQuickDragHandler::~QQuickDragHandler() | - | ||||||||||||
| 9 | { | - | ||||||||||||
| 10 | } | - | ||||||||||||
| 11 | - | |||||||||||||
| 12 | bool QQuickDragHandler::wantsEventPoint(QQuickEventPoint *point) | - | ||||||||||||
| 13 | { | - | ||||||||||||
| 14 | - | |||||||||||||
| 15 | return executed 4376 times by 3 tests: ((point->state() != QQuickEventPoint::Pressed && this->point().id() == point->pointId())return ((point->state() != QQuickEventPoint::Pressed && this->point().id() == point->pointId()) || QQuickSinglePointHandler::wantsEventPoint(point));Executed by:
executed 4376 times by 3 tests: return ((point->state() != QQuickEventPoint::Pressed && this->point().id() == point->pointId()) || QQuickSinglePointHandler::wantsEventPoint(point));Executed by:
| 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:
| 4376 | ||||||||||||
| 17 | } | - | ||||||||||||
| 18 | - | |||||||||||||
| 19 | bool 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: target()->contains(localTargetPosition(point));return target()->contains(localTargetPosition(point));Executed by:
executed 78 times by 3 tests: return target()->contains(localTargetPosition(point));Executed by:
| 78 | ||||||||||||
| 23 | } | - | ||||||||||||
| 24 | - | |||||||||||||
| 25 | QPointF QQuickDragHandler::localTargetPosition(QQuickEventPoint *point) | - | ||||||||||||
| 26 | { | - | ||||||||||||
| 27 | QPointF pos = point->position(); | - | ||||||||||||
| 28 | if (target() != parentItem()
| 210-318 | ||||||||||||
| 29 | pos = parentItem()->mapToItem(target(), pos); executed 210 times by 2 tests: pos = parentItem()->mapToItem(target(), pos);Executed by:
| 210 | ||||||||||||
| 30 | return executed 528 times by 3 tests: pos;return pos;Executed by:
executed 528 times by 3 tests: return pos;Executed by:
| 528 | ||||||||||||
| 31 | } | - | ||||||||||||
| 32 | - | |||||||||||||
| 33 | void QQuickDragHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point) | - | ||||||||||||
| 34 | { | - | ||||||||||||
| 35 | if (grabber == this
| 0-244 | ||||||||||||
| 36 | - | |||||||||||||
| 37 | if (!m_pressedInsideTarget
| 12-62 | ||||||||||||
| 38 | if (target()
| 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:
| 12 | ||||||||||||
| 40 | m_pressScenePos = point->scenePosition(); | - | ||||||||||||
| 41 | } executed 12 times by 1 test: else if (m_pressTargetPos.isNull()end of blockExecuted by:
| 0-62 | ||||||||||||
| 42 | if (target()
| 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 blockExecuted by:
| 74 | ||||||||||||
| 47 | QQuickSinglePointHandler::onGrabChanged(grabber, stateChange, point); | - | ||||||||||||
| 48 | } executed 244 times by 3 tests: end of blockExecuted by:
| 244 | ||||||||||||
| 49 | - | |||||||||||||
| 50 | void QQuickDragHandler::onActiveChanged() | - | ||||||||||||
| 51 | { | - | ||||||||||||
| 52 | if (!active()
| 74 | ||||||||||||
| 53 | m_pressTargetPos = QPointF(); | - | ||||||||||||
| 54 | m_pressScenePos = m_pressTargetPos; | - | ||||||||||||
| 55 | m_pressedInsideTarget = false; | - | ||||||||||||
| 56 | } executed 74 times by 3 tests: end of blockExecuted by:
| 74 | ||||||||||||
| 57 | } executed 148 times by 3 tests: end of blockExecuted by:
| 148 | ||||||||||||
| 58 | - | |||||||||||||
| 59 | void QQuickDragHandler::handleEventPoint(QQuickEventPoint *point) | - | ||||||||||||
| 60 | { | - | ||||||||||||
| 61 | point->setAccepted(); | - | ||||||||||||
| 62 | switch (point->state()) { | - | ||||||||||||
| 63 | case executed 78 times by 3 tests: QQuickEventPoint::Pressed:case QQuickEventPoint::Pressed:Executed by:
executed 78 times by 3 tests: case QQuickEventPoint::Pressed:Executed by:
| 78 | ||||||||||||
| 64 | if (target()
| 0-78 | ||||||||||||
| 65 | m_pressedInsideTarget = targetContains(point); | - | ||||||||||||
| 66 | m_pressTargetPos = localTargetPosition(point); | - | ||||||||||||
| 67 | } executed 78 times by 3 tests: end of blockExecuted by:
| 78 | ||||||||||||
| 68 | m_pressScenePos = point->scenePosition(); | - | ||||||||||||
| 69 | setPassiveGrab(point); | - | ||||||||||||
| 70 | break; executed 78 times by 3 tests: break;Executed by:
| 78 | ||||||||||||
| 71 | case executed 586 times by 3 tests: QQuickEventPoint::Updated:case QQuickEventPoint::Updated:Executed by:
executed 586 times by 3 tests: {case QQuickEventPoint::Updated:Executed by:
| 586 | ||||||||||||
| 72 | QVector2D accumulatedDragDelta = QVector2D(point->scenePosition() - m_pressScenePos); | - | ||||||||||||
| 73 | if (active()
| 214-372 | ||||||||||||
| 74 | - | |||||||||||||
| 75 | if (!m_xAxis.enabled()
| 144-228 | ||||||||||||
| 76 | accumulatedDragDelta.setX(0); executed 228 times by 2 tests: accumulatedDragDelta.setX(0);Executed by:
| 228 | ||||||||||||
| 77 | if (!m_yAxis.enabled()
| 0-372 | ||||||||||||
| 78 | accumulatedDragDelta.setY(0); never executed: accumulatedDragDelta.setY(0); | 0 | ||||||||||||
| 79 | setTranslation(accumulatedDragDelta); | - | ||||||||||||
| 80 | - | |||||||||||||
| 81 | if (target()
| 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()
| 144-228 | ||||||||||||
| 89 | pos.setX(targetItemPos.x()); executed 228 times by 2 tests: pos.setX(targetItemPos.x());Executed by:
| 228 | ||||||||||||
| 90 | if (!m_yAxis.enabled()
| 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 blockExecuted by:
| 372 | ||||||||||||
| 95 | } executed 372 times by 3 tests: else if (!point->exclusiveGrabber()end of blockExecuted by:
| 0-372 | ||||||||||||
| 96 | ((m_xAxis.enabled()
| 30-116 | ||||||||||||
| 97 | (m_yAxis.enabled()
| 0-184 | ||||||||||||
| 98 | setExclusiveGrab(point); | - | ||||||||||||
| 99 | if (auto parent = parentItem()
| 0-74 | ||||||||||||
| 100 | if (point->pointerEvent()->asPointerTouchEvent()
| 10-64 | ||||||||||||
| 101 | parent->setKeepTouchGrab(true); executed 64 times by 3 tests: parent->setKeepTouchGrab(true);Executed by:
| 64 | ||||||||||||
| 102 | - | |||||||||||||
| 103 | - | |||||||||||||
| 104 | - | |||||||||||||
| 105 | parent->setKeepMouseGrab(true); | - | ||||||||||||
| 106 | } executed 74 times by 3 tests: end of blockExecuted by:
| 74 | ||||||||||||
| 107 | } executed 74 times by 3 tests: end of blockExecuted by:
| 74 | ||||||||||||
| 108 | } break; executed 586 times by 3 tests: break;Executed by:
| 586 | ||||||||||||
| 109 | default executed 92 times by 3 tests: :default:Executed by:
executed 92 times by 3 tests: default:Executed by:
| 92 | ||||||||||||
| 110 | break; executed 92 times by 3 tests: break;Executed by:
| 92 | ||||||||||||
| 111 | } | - | ||||||||||||
| 112 | } | - | ||||||||||||
| 113 | - | |||||||||||||
| 114 | void QQuickDragHandler::enforceConstraints() | - | ||||||||||||
| 115 | { | - | ||||||||||||
| 116 | if (!target()
| 0 | ||||||||||||
| 117 | return; never executed: return; | 0 | ||||||||||||
| 118 | QPointF pos = target()->position(); | - | ||||||||||||
| 119 | QPointF copy(pos); | - | ||||||||||||
| 120 | enforceAxisConstraints(&pos); | - | ||||||||||||
| 121 | if (pos != copy
| 0 | ||||||||||||
| 122 | target()->setPosition(pos); never executed: target()->setPosition(pos); | 0 | ||||||||||||
| 123 | } never executed: end of block | 0 | ||||||||||||
| 124 | - | |||||||||||||
| 125 | void QQuickDragHandler::enforceAxisConstraints(QPointF *localPos) | - | ||||||||||||
| 126 | { | - | ||||||||||||
| 127 | if (m_xAxis.enabled()
| 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:
| 144 | ||||||||||||
| 129 | if (m_yAxis.enabled()
| 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:
| 372 | ||||||||||||
| 131 | } executed 372 times by 3 tests: end of blockExecuted by:
| 372 | ||||||||||||
| 132 | - | |||||||||||||
| 133 | void QQuickDragHandler::setTranslation(const QVector2D &trans) | - | ||||||||||||
| 134 | { | - | ||||||||||||
| 135 | if (trans == m_translation
| 4-368 | ||||||||||||
| 136 | return; executed 4 times by 1 test: return;Executed by:
| 4 | ||||||||||||
| 137 | m_translation = trans; | - | ||||||||||||
| 138 | translationChanged(); | - | ||||||||||||
| 139 | } executed 368 times by 3 tests: end of blockExecuted by:
| 368 | ||||||||||||
| 140 | - | |||||||||||||
| Switch to Source code | Preprocessed file |