| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickdrag.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2016 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 "qquickdrag_p.h" | - | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | #include <private/qguiapplication_p.h> | - | ||||||||||||||||||
| 43 | #include <qpa/qplatformintegration.h> | - | ||||||||||||||||||
| 44 | #include <private/qquickitem_p.h> | - | ||||||||||||||||||
| 45 | #include <QtQuick/private/qquickevents_p_p.h> | - | ||||||||||||||||||
| 46 | #include <private/qquickitemchangelistener_p.h> | - | ||||||||||||||||||
| 47 | #include <private/qquickpixmapcache_p.h> | - | ||||||||||||||||||
| 48 | #include <private/qv8engine_p.h> | - | ||||||||||||||||||
| 49 | #include <private/qv4scopedvalue_p.h> | - | ||||||||||||||||||
| 50 | #include <QtCore/qmimedata.h> | - | ||||||||||||||||||
| 51 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||
| 52 | #include <QtGui/qevent.h> | - | ||||||||||||||||||
| 53 | #include <QtGui/qstylehints.h> | - | ||||||||||||||||||
| 54 | #include <QtGui/qguiapplication.h> | - | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | #if QT_CONFIG(draganddrop) | - | ||||||||||||||||||
| 57 | #include <qpa/qplatformdrag.h> | - | ||||||||||||||||||
| 58 | #include <QtGui/qdrag.h> | - | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | class QQuickDragAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener | - | ||||||||||||||||||
| 63 | { | - | ||||||||||||||||||
| 64 | Q_DECLARE_PUBLIC(QQuickDragAttached) | - | ||||||||||||||||||
| 65 | public: | - | ||||||||||||||||||
| 66 | static QQuickDragAttachedPrivate *get(QQuickDragAttached *attached) { | - | ||||||||||||||||||
| 67 | return static_cast<QQuickDragAttachedPrivate *>(QObjectPrivate::get(attached)); } never executed: return static_cast<QQuickDragAttachedPrivate *>(QObjectPrivate::get(attached)); | 0 | ||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | QQuickDragAttachedPrivate() | - | ||||||||||||||||||
| 70 | : attachedItem(nullptr) | - | ||||||||||||||||||
| 71 | , mimeData(nullptr) | - | ||||||||||||||||||
| 72 | , proposedAction(Qt::MoveAction) | - | ||||||||||||||||||
| 73 | , supportedActions(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction) | - | ||||||||||||||||||
| 74 | , active(false) | - | ||||||||||||||||||
| 75 | , listening(false) | - | ||||||||||||||||||
| 76 | , inEvent(false) | - | ||||||||||||||||||
| 77 | , dragRestarted(false) | - | ||||||||||||||||||
| 78 | , itemMoved(false) | - | ||||||||||||||||||
| 79 | , eventQueued(false) | - | ||||||||||||||||||
| 80 | , overrideActions(false) | - | ||||||||||||||||||
| 81 | , dragType(QQuickDrag::Internal) | - | ||||||||||||||||||
| 82 | { | - | ||||||||||||||||||
| 83 | } executed 390 times by 4 tests: end of blockExecuted by:
| 390 | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override; | - | ||||||||||||||||||
| 86 | void itemParentChanged(QQuickItem *, QQuickItem *parent) override; | - | ||||||||||||||||||
| 87 | void updatePosition(); | - | ||||||||||||||||||
| 88 | void restartDrag(); | - | ||||||||||||||||||
| 89 | void deliverEnterEvent(); | - | ||||||||||||||||||
| 90 | void deliverMoveEvent(); | - | ||||||||||||||||||
| 91 | void deliverLeaveEvent(); | - | ||||||||||||||||||
| 92 | void deliverEvent(QQuickWindow *window, QEvent *event); | - | ||||||||||||||||||
| 93 | void start(Qt::DropActions supportedActions); | - | ||||||||||||||||||
| 94 | Qt::DropAction startDrag(Qt::DropActions supportedActions); | - | ||||||||||||||||||
| 95 | void setTarget(QQuickItem *item); | - | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | QQuickDragGrabber dragGrabber; | - | ||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | QPointer<QObject> source; | - | ||||||||||||||||||
| 100 | QPointer<QObject> target; | - | ||||||||||||||||||
| 101 | QPointer<QQuickWindow> window; | - | ||||||||||||||||||
| 102 | QQuickItem *attachedItem; | - | ||||||||||||||||||
| 103 | QQuickDragMimeData *mimeData; | - | ||||||||||||||||||
| 104 | Qt::DropAction proposedAction; | - | ||||||||||||||||||
| 105 | Qt::DropActions supportedActions; | - | ||||||||||||||||||
| 106 | bool active : 1; | - | ||||||||||||||||||
| 107 | bool listening : 1; | - | ||||||||||||||||||
| 108 | bool inEvent : 1; | - | ||||||||||||||||||
| 109 | bool dragRestarted : 1; | - | ||||||||||||||||||
| 110 | bool itemMoved : 1; | - | ||||||||||||||||||
| 111 | bool eventQueued : 1; | - | ||||||||||||||||||
| 112 | bool overrideActions : 1; | - | ||||||||||||||||||
| 113 | QPointF hotSpot; | - | ||||||||||||||||||
| 114 | QUrl imageSource; | - | ||||||||||||||||||
| 115 | QQuickPixmap pixmapLoader; | - | ||||||||||||||||||
| 116 | QStringList keys; | - | ||||||||||||||||||
| 117 | QVariantMap externalMimeData; | - | ||||||||||||||||||
| 118 | QQuickDrag::DragType dragType; | - | ||||||||||||||||||
| 119 | }; | - | ||||||||||||||||||
| 120 | - | |||||||||||||||||||
| 121 | /*! | - | ||||||||||||||||||
| 122 | \qmltype Drag | - | ||||||||||||||||||
| 123 | \instantiates QQuickDrag | - | ||||||||||||||||||
| 124 | \inqmlmodule QtQuick | - | ||||||||||||||||||
| 125 | \ingroup qtquick-input | - | ||||||||||||||||||
| 126 | \brief For specifying drag and drop events for moved Items. | - | ||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | Using the Drag attached property, any Item can be made a source of drag and drop | - | ||||||||||||||||||
| 129 | events within a scene. | - | ||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | When a drag is \l active on an item, any change in that item's position will | - | ||||||||||||||||||
| 132 | generate a drag event that will be sent to any DropArea that intersects | - | ||||||||||||||||||
| 133 | with the new position of the item. Other items which implement drag and | - | ||||||||||||||||||
| 134 | drop event handlers can also receive these events. | - | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | The following snippet shows how an item can be dragged with a MouseArea. | - | ||||||||||||||||||
| 137 | However, dragging is not limited to mouse drags; anything that can move an item | - | ||||||||||||||||||
| 138 | can generate drag events, including touch events, animations and bindings. | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | \snippet qml/drag.qml 0 | - | ||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | A drag can be terminated either by canceling it with Drag.cancel() or setting | - | ||||||||||||||||||
| 143 | Drag.active to false, or it can be terminated with a drop event by calling | - | ||||||||||||||||||
| 144 | Drag.drop(). If the drop event is accepted, Drag.drop() will return the | - | ||||||||||||||||||
| 145 | \l {supportedActions}{drop action} chosen by the recipient of the event, | - | ||||||||||||||||||
| 146 | otherwise it will return Qt.IgnoreAction. | - | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | \sa {Qt Quick Examples - Drag and Drop}, {Qt Quick Examples - externaldraganddrop} | - | ||||||||||||||||||
| 149 | */ | - | ||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | void QQuickDragAttachedPrivate::itemGeometryChanged(QQuickItem *, QQuickGeometryChange change, | - | ||||||||||||||||||
| 152 | const QRectF &) | - | ||||||||||||||||||
| 153 | { | - | ||||||||||||||||||
| 154 | if (!change.positionChange() || !active || itemMoved)
| 0-214 | ||||||||||||||||||
| 155 | return; executed 24 times by 3 tests: return;Executed by:
| 24 | ||||||||||||||||||
| 156 | updatePosition(); | - | ||||||||||||||||||
| 157 | } executed 190 times by 3 tests: end of blockExecuted by:
| 190 | ||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | void QQuickDragAttachedPrivate::itemParentChanged(QQuickItem *, QQuickItem *) | - | ||||||||||||||||||
| 160 | { | - | ||||||||||||||||||
| 161 | if (!active || dragRestarted)
| 0-82 | ||||||||||||||||||
| 162 | return; executed 82 times by 3 tests: return;Executed by:
| 82 | ||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | QQuickWindow *newWindow = attachedItem->window(); | - | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | if (window != newWindow)
| 6-24 | ||||||||||||||||||
| 167 | restartDrag(); executed 24 times by 2 tests: restartDrag();Executed by:
| 24 | ||||||||||||||||||
| 168 | else if (window)
| 0-6 | ||||||||||||||||||
| 169 | updatePosition(); executed 6 times by 2 tests: updatePosition();Executed by:
| 6 | ||||||||||||||||||
| 170 | } executed 30 times by 3 tests: end of blockExecuted by:
| 30 | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | void QQuickDragAttachedPrivate::updatePosition() | - | ||||||||||||||||||
| 173 | { | - | ||||||||||||||||||
| 174 | Q_Q(QQuickDragAttached); | - | ||||||||||||||||||
| 175 | itemMoved = true; | - | ||||||||||||||||||
| 176 | if (!eventQueued) {
| 4-200 | ||||||||||||||||||
| 177 | eventQueued = true; | - | ||||||||||||||||||
| 178 | QCoreApplication::postEvent(q, new QEvent(QEvent::User)); | - | ||||||||||||||||||
| 179 | } executed 200 times by 3 tests: end of blockExecuted by:
| 200 | ||||||||||||||||||
| 180 | } executed 204 times by 3 tests: end of blockExecuted by:
| 204 | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | void QQuickDragAttachedPrivate::restartDrag() | - | ||||||||||||||||||
| 183 | { | - | ||||||||||||||||||
| 184 | Q_Q(QQuickDragAttached); | - | ||||||||||||||||||
| 185 | dragRestarted = true; | - | ||||||||||||||||||
| 186 | if (!eventQueued) {
| 0-30 | ||||||||||||||||||
| 187 | eventQueued = true; | - | ||||||||||||||||||
| 188 | QCoreApplication::postEvent(q, new QEvent(QEvent::User)); | - | ||||||||||||||||||
| 189 | } executed 30 times by 2 tests: end of blockExecuted by:
| 30 | ||||||||||||||||||
| 190 | } executed 30 times by 2 tests: end of blockExecuted by:
| 30 | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | void QQuickDragAttachedPrivate::deliverEnterEvent() | - | ||||||||||||||||||
| 193 | { | - | ||||||||||||||||||
| 194 | dragRestarted = false; | - | ||||||||||||||||||
| 195 | itemMoved = false; | - | ||||||||||||||||||
| 196 | - | |||||||||||||||||||
| 197 | window = attachedItem->window(); | - | ||||||||||||||||||
| 198 | - | |||||||||||||||||||
| 199 | mimeData->m_source = source; | - | ||||||||||||||||||
| 200 | if (!overrideActions)
| 2-196 | ||||||||||||||||||
| 201 | mimeData->m_supportedActions = supportedActions; executed 196 times by 3 tests: mimeData->m_supportedActions = supportedActions;Executed by:
| 196 | ||||||||||||||||||
| 202 | mimeData->m_keys = keys; | - | ||||||||||||||||||
| 203 | - | |||||||||||||||||||
| 204 | if (window) {
| 4-194 | ||||||||||||||||||
| 205 | QPoint scenePos = attachedItem->mapToScene(hotSpot).toPoint(); | - | ||||||||||||||||||
| 206 | QDragEnterEvent event(scenePos, mimeData->m_supportedActions, mimeData, Qt::NoButton, Qt::NoModifier); | - | ||||||||||||||||||
| 207 | QQuickDropEventEx::setProposedAction(&event, proposedAction); | - | ||||||||||||||||||
| 208 | deliverEvent(window, &event); | - | ||||||||||||||||||
| 209 | } executed 194 times by 3 tests: end of blockExecuted by:
| 194 | ||||||||||||||||||
| 210 | } executed 198 times by 3 tests: end of blockExecuted by:
| 198 | ||||||||||||||||||
| 211 | - | |||||||||||||||||||
| 212 | void QQuickDragAttachedPrivate::deliverMoveEvent() | - | ||||||||||||||||||
| 213 | { | - | ||||||||||||||||||
| 214 | Q_Q(QQuickDragAttached); | - | ||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | itemMoved = false; | - | ||||||||||||||||||
| 217 | if (window) {
| 6-194 | ||||||||||||||||||
| 218 | QPoint scenePos = attachedItem->mapToScene(hotSpot).toPoint(); | - | ||||||||||||||||||
| 219 | QDragMoveEvent event(scenePos, mimeData->m_supportedActions, mimeData, Qt::NoButton, Qt::NoModifier); | - | ||||||||||||||||||
| 220 | QQuickDropEventEx::setProposedAction(&event, proposedAction); | - | ||||||||||||||||||
| 221 | deliverEvent(window, &event); | - | ||||||||||||||||||
| 222 | if (target != dragGrabber.target()) {
| 12-182 | ||||||||||||||||||
| 223 | target = dragGrabber.target(); | - | ||||||||||||||||||
| 224 | emit q->targetChanged(); | - | ||||||||||||||||||
| 225 | } executed 12 times by 2 tests: end of blockExecuted by:
| 12 | ||||||||||||||||||
| 226 | } executed 194 times by 3 tests: end of blockExecuted by:
| 194 | ||||||||||||||||||
| 227 | } executed 200 times by 3 tests: end of blockExecuted by:
| 200 | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | void QQuickDragAttachedPrivate::deliverLeaveEvent() | - | ||||||||||||||||||
| 230 | { | - | ||||||||||||||||||
| 231 | if (window) {
| 4-132 | ||||||||||||||||||
| 232 | QDragLeaveEvent event; | - | ||||||||||||||||||
| 233 | deliverEvent(window, &event); | - | ||||||||||||||||||
| 234 | window = nullptr; | - | ||||||||||||||||||
| 235 | } executed 132 times by 3 tests: end of blockExecuted by:
| 132 | ||||||||||||||||||
| 236 | } executed 136 times by 3 tests: end of blockExecuted by:
| 136 | ||||||||||||||||||
| 237 | - | |||||||||||||||||||
| 238 | void QQuickDragAttachedPrivate::deliverEvent(QQuickWindow *window, QEvent *event) | - | ||||||||||||||||||
| 239 | { | - | ||||||||||||||||||
| 240 | Q_ASSERT(!inEvent); | - | ||||||||||||||||||
| 241 | inEvent = true; | - | ||||||||||||||||||
| 242 | QQuickWindowPrivate::get(window)->deliverDragEvent(&dragGrabber, event); | - | ||||||||||||||||||
| 243 | inEvent = false; | - | ||||||||||||||||||
| 244 | } executed 564 times by 3 tests: end of blockExecuted by:
| 564 | ||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | bool QQuickDragAttached::event(QEvent *event) | - | ||||||||||||||||||
| 247 | { | - | ||||||||||||||||||
| 248 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 249 | - | |||||||||||||||||||
| 250 | if (event->type() == QEvent::User) {
| 0-210 | ||||||||||||||||||
| 251 | d->eventQueued = false; | - | ||||||||||||||||||
| 252 | if (d->dragRestarted) {
| 12-198 | ||||||||||||||||||
| 253 | d->deliverLeaveEvent(); | - | ||||||||||||||||||
| 254 | d->deliverEnterEvent(); | - | ||||||||||||||||||
| 255 | - | |||||||||||||||||||
| 256 | if (d->target != d->dragGrabber.target()) {
| 6 | ||||||||||||||||||
| 257 | d->target = d->dragGrabber.target(); | - | ||||||||||||||||||
| 258 | emit targetChanged(); | - | ||||||||||||||||||
| 259 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||
| 260 | } else if (d->itemMoved) { executed 12 times by 1 test: end of blockExecuted by:
| 2-196 | ||||||||||||||||||
| 261 | d->deliverMoveEvent(); | - | ||||||||||||||||||
| 262 | } executed 196 times by 3 tests: end of blockExecuted by:
| 196 | ||||||||||||||||||
| 263 | return true; executed 210 times by 3 tests: return true;Executed by:
| 210 | ||||||||||||||||||
| 264 | } else { | - | ||||||||||||||||||
| 265 | return QObject::event(event); never executed: return QObject::event(event); | 0 | ||||||||||||||||||
| 266 | } | - | ||||||||||||||||||
| 267 | } | - | ||||||||||||||||||
| 268 | - | |||||||||||||||||||
| 269 | QQuickDragAttached::QQuickDragAttached(QObject *parent) | - | ||||||||||||||||||
| 270 | : QObject(*new QQuickDragAttachedPrivate, parent) | - | ||||||||||||||||||
| 271 | { | - | ||||||||||||||||||
| 272 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 273 | d->attachedItem = qobject_cast<QQuickItem *>(parent); | - | ||||||||||||||||||
| 274 | d->source = d->attachedItem; | - | ||||||||||||||||||
| 275 | } executed 390 times by 4 tests: end of blockExecuted by:
| 390 | ||||||||||||||||||
| 276 | - | |||||||||||||||||||
| 277 | QQuickDragAttached::~QQuickDragAttached() | - | ||||||||||||||||||
| 278 | { | - | ||||||||||||||||||
| 279 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 280 | delete d->mimeData; | - | ||||||||||||||||||
| 281 | } executed 390 times by 4 tests: end of blockExecuted by:
| 390 | ||||||||||||||||||
| 282 | - | |||||||||||||||||||
| 283 | /*! | - | ||||||||||||||||||
| 284 | \qmlattachedproperty bool QtQuick::Drag::active | - | ||||||||||||||||||
| 285 | - | |||||||||||||||||||
| 286 | This property holds whether a drag event sequence is currently active. | - | ||||||||||||||||||
| 287 | - | |||||||||||||||||||
| 288 | Binding this property to the active property of \l MouseArea::drag will | - | ||||||||||||||||||
| 289 | cause \l startDrag to be called when the user starts dragging. | - | ||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | Setting this property to true will also send a QDragEnter event to the scene | - | ||||||||||||||||||
| 292 | with the item's current position. Setting it to false will send a | - | ||||||||||||||||||
| 293 | QDragLeave event. | - | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | While a drag is active any change in an item's position will send a QDragMove | - | ||||||||||||||||||
| 296 | event with item's new position to the scene. | - | ||||||||||||||||||
| 297 | */ | - | ||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | bool QQuickDragAttached::isActive() const | - | ||||||||||||||||||
| 300 | { | - | ||||||||||||||||||
| 301 | Q_D(const QQuickDragAttached); | - | ||||||||||||||||||
| 302 | return d->active; executed 332 times by 3 tests: return d->active;Executed by:
| 332 | ||||||||||||||||||
| 303 | } | - | ||||||||||||||||||
| 304 | - | |||||||||||||||||||
| 305 | void QQuickDragAttached::setActive(bool active) | - | ||||||||||||||||||
| 306 | { | - | ||||||||||||||||||
| 307 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 308 | if (d->active != active) {
| 198-310 | ||||||||||||||||||
| 309 | if (d->inEvent)
| 8-190 | ||||||||||||||||||
| 310 | qmlWarning(this) << "active cannot be changed from within a drag event handler"; executed 8 times by 1 test: qmlWarning(this) << "active cannot be changed from within a drag event handler";Executed by:
| 8 | ||||||||||||||||||
| 311 | else if (active) {
| 74-116 | ||||||||||||||||||
| 312 | if (d->dragType == QQuickDrag::Internal) {
| 2-114 | ||||||||||||||||||
| 313 | d->start(d->supportedActions); | - | ||||||||||||||||||
| 314 | } else { executed 114 times by 3 tests: end of blockExecuted by:
| 114 | ||||||||||||||||||
| 315 | d->active = true; | - | ||||||||||||||||||
| 316 | emit activeChanged(); | - | ||||||||||||||||||
| 317 | if (d->dragType == QQuickDrag::Automatic) {
| 0-2 | ||||||||||||||||||
| 318 | // There are different semantics than start() since startDrag() | - | ||||||||||||||||||
| 319 | // may be called after an internal drag is already started. | - | ||||||||||||||||||
| 320 | d->startDrag(d->supportedActions); | - | ||||||||||||||||||
| 321 | } never executed: end of block | 0 | ||||||||||||||||||
| 322 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 323 | } | - | ||||||||||||||||||
| 324 | else | - | ||||||||||||||||||
| 325 | cancel(); executed 74 times by 3 tests: cancel();Executed by:
| 74 | ||||||||||||||||||
| 326 | } | - | ||||||||||||||||||
| 327 | } executed 508 times by 4 tests: end of blockExecuted by:
| 508 | ||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | /*! | - | ||||||||||||||||||
| 330 | \qmlattachedproperty Object QtQuick::Drag::source | - | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | This property holds an object that is identified to recipients of drag events as | - | ||||||||||||||||||
| 333 | the source of the events. By default this is the item that the Drag | - | ||||||||||||||||||
| 334 | property is attached to. | - | ||||||||||||||||||
| 335 | - | |||||||||||||||||||
| 336 | Changing the source while a drag is active will reset the sequence of drag events by | - | ||||||||||||||||||
| 337 | sending a drag leave event followed by a drag enter event with the new source. | - | ||||||||||||||||||
| 338 | */ | - | ||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | QObject *QQuickDragAttached::source() const | - | ||||||||||||||||||
| 341 | { | - | ||||||||||||||||||
| 342 | Q_D(const QQuickDragAttached); | - | ||||||||||||||||||
| 343 | return d->source; executed 14 times by 1 test: return d->source;Executed by:
| 14 | ||||||||||||||||||
| 344 | } | - | ||||||||||||||||||
| 345 | - | |||||||||||||||||||
| 346 | void QQuickDragAttached::setSource(QObject *item) | - | ||||||||||||||||||
| 347 | { | - | ||||||||||||||||||
| 348 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 349 | if (d->source != item) {
| 0-198 | ||||||||||||||||||
| 350 | d->source = item; | - | ||||||||||||||||||
| 351 | if (d->active)
| 2-196 | ||||||||||||||||||
| 352 | d->restartDrag(); executed 2 times by 1 test: d->restartDrag();Executed by:
| 2 | ||||||||||||||||||
| 353 | emit sourceChanged(); | - | ||||||||||||||||||
| 354 | } executed 198 times by 4 tests: end of blockExecuted by:
| 198 | ||||||||||||||||||
| 355 | } executed 198 times by 4 tests: end of blockExecuted by:
| 198 | ||||||||||||||||||
| 356 | - | |||||||||||||||||||
| 357 | void QQuickDragAttached::resetSource() | - | ||||||||||||||||||
| 358 | { | - | ||||||||||||||||||
| 359 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 360 | if (d->source != d->attachedItem) {
| 0-2 | ||||||||||||||||||
| 361 | d->source = d->attachedItem; | - | ||||||||||||||||||
| 362 | if (d->active)
| 0-2 | ||||||||||||||||||
| 363 | d->restartDrag(); never executed: d->restartDrag(); | 0 | ||||||||||||||||||
| 364 | emit sourceChanged(); | - | ||||||||||||||||||
| 365 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 366 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | /*! | - | ||||||||||||||||||
| 369 | \qmlattachedproperty Object QtQuick::Drag::target | - | ||||||||||||||||||
| 370 | - | |||||||||||||||||||
| 371 | While a drag is active this property holds the last object to accept an | - | ||||||||||||||||||
| 372 | enter event from the dragged item, if the current drag position doesn't | - | ||||||||||||||||||
| 373 | intersect any accepting targets it is null. | - | ||||||||||||||||||
| 374 | - | |||||||||||||||||||
| 375 | When a drag is not active this property holds the object that accepted | - | ||||||||||||||||||
| 376 | the drop event that ended the drag, if no object accepted the drop or | - | ||||||||||||||||||
| 377 | the drag was canceled the target will then be null. | - | ||||||||||||||||||
| 378 | */ | - | ||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | QObject *QQuickDragAttached::target() const | - | ||||||||||||||||||
| 381 | { | - | ||||||||||||||||||
| 382 | Q_D(const QQuickDragAttached); | - | ||||||||||||||||||
| 383 | return d->target; executed 136 times by 1 test: return d->target;Executed by:
| 136 | ||||||||||||||||||
| 384 | } | - | ||||||||||||||||||
| 385 | - | |||||||||||||||||||
| 386 | /*! | - | ||||||||||||||||||
| 387 | \qmlattachedproperty QPointF QtQuick::Drag::hotSpot | - | ||||||||||||||||||
| 388 | - | |||||||||||||||||||
| 389 | This property holds the drag position relative to the top left of the item. | - | ||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | By default this is (0, 0). | - | ||||||||||||||||||
| 392 | - | |||||||||||||||||||
| 393 | Changes to hotSpot trigger a new drag move with the updated position. | - | ||||||||||||||||||
| 394 | */ | - | ||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 | QPointF QQuickDragAttached::hotSpot() const | - | ||||||||||||||||||
| 397 | { | - | ||||||||||||||||||
| 398 | Q_D(const QQuickDragAttached); | - | ||||||||||||||||||
| 399 | return d->hotSpot; executed 390 times by 3 tests: return d->hotSpot;Executed by:
| 390 | ||||||||||||||||||
| 400 | } | - | ||||||||||||||||||
| 401 | - | |||||||||||||||||||
| 402 | void QQuickDragAttached::setHotSpot(const QPointF &hotSpot) | - | ||||||||||||||||||
| 403 | { | - | ||||||||||||||||||
| 404 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 405 | if (d->hotSpot != hotSpot) {
| 60-294 | ||||||||||||||||||
| 406 | d->hotSpot = hotSpot; | - | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | if (d->active)
| 4-290 | ||||||||||||||||||
| 409 | d->updatePosition(); executed 4 times by 1 test: d->updatePosition();Executed by:
| 4 | ||||||||||||||||||
| 410 | - | |||||||||||||||||||
| 411 | emit hotSpotChanged(); | - | ||||||||||||||||||
| 412 | } executed 294 times by 3 tests: end of blockExecuted by:
| 294 | ||||||||||||||||||
| 413 | } executed 354 times by 3 tests: end of blockExecuted by:
| 354 | ||||||||||||||||||
| 414 | - | |||||||||||||||||||
| 415 | /*! | - | ||||||||||||||||||
| 416 | \qmlattachedproperty QUrl QtQuick::Drag::imageSource | - | ||||||||||||||||||
| 417 | \since 5.8 | - | ||||||||||||||||||
| 418 | - | |||||||||||||||||||
| 419 | This property holds the URL of the image which will be used to represent | - | ||||||||||||||||||
| 420 | the data during the drag and drop operation. Changing this property after | - | ||||||||||||||||||
| 421 | the drag operation has started will have no effect. | - | ||||||||||||||||||
| 422 | - | |||||||||||||||||||
| 423 | The example below uses an item's contents as a drag image: | - | ||||||||||||||||||
| 424 | - | |||||||||||||||||||
| 425 | \snippet qml/externaldrag.qml 0 | - | ||||||||||||||||||
| 426 | - | |||||||||||||||||||
| 427 | \sa Item::grabToImage() | - | ||||||||||||||||||
| 428 | */ | - | ||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | QUrl QQuickDragAttached::imageSource() const | - | ||||||||||||||||||
| 431 | { | - | ||||||||||||||||||
| 432 | Q_D(const QQuickDragAttached); | - | ||||||||||||||||||
| 433 | return d->imageSource; never executed: return d->imageSource; | 0 | ||||||||||||||||||
| 434 | } | - | ||||||||||||||||||
| 435 | - | |||||||||||||||||||
| 436 | void QQuickDragAttached::setImageSource(const QUrl &url) | - | ||||||||||||||||||
| 437 | { | - | ||||||||||||||||||
| 438 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 439 | if (d->imageSource != url) {
| 0 | ||||||||||||||||||
| 440 | d->imageSource = url; | - | ||||||||||||||||||
| 441 | - | |||||||||||||||||||
| 442 | if (url.isEmpty()) {
| 0 | ||||||||||||||||||
| 443 | d->pixmapLoader.clear(); | - | ||||||||||||||||||
| 444 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 445 | d->pixmapLoader.load(qmlEngine(this), url); | - | ||||||||||||||||||
| 446 | } never executed: end of block | 0 | ||||||||||||||||||
| 447 | - | |||||||||||||||||||
| 448 | Q_EMIT imageSourceChanged(); | - | ||||||||||||||||||
| 449 | } never executed: end of block | 0 | ||||||||||||||||||
| 450 | } never executed: end of block | 0 | ||||||||||||||||||
| 451 | - | |||||||||||||||||||
| 452 | /*! | - | ||||||||||||||||||
| 453 | \qmlattachedproperty stringlist QtQuick::Drag::keys | - | ||||||||||||||||||
| 454 | - | |||||||||||||||||||
| 455 | This property holds a list of keys that can be used by a DropArea to filter drag events. | - | ||||||||||||||||||
| 456 | - | |||||||||||||||||||
| 457 | Changing the keys while a drag is active will reset the sequence of drag events by | - | ||||||||||||||||||
| 458 | sending a drag leave event followed by a drag enter event with the new source. | - | ||||||||||||||||||
| 459 | */ | - | ||||||||||||||||||
| 460 | - | |||||||||||||||||||
| 461 | QStringList QQuickDragAttached::keys() const | - | ||||||||||||||||||
| 462 | { | - | ||||||||||||||||||
| 463 | Q_D(const QQuickDragAttached); | - | ||||||||||||||||||
| 464 | return d->keys; executed 10 times by 1 test: return d->keys;Executed by:
| 10 | ||||||||||||||||||
| 465 | } | - | ||||||||||||||||||
| 466 | - | |||||||||||||||||||
| 467 | void QQuickDragAttached::setKeys(const QStringList &keys) | - | ||||||||||||||||||
| 468 | { | - | ||||||||||||||||||
| 469 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 470 | if (d->keys != keys) {
| 0-54 | ||||||||||||||||||
| 471 | d->keys = keys; | - | ||||||||||||||||||
| 472 | if (d->active)
| 2-52 | ||||||||||||||||||
| 473 | d->restartDrag(); executed 2 times by 1 test: d->restartDrag();Executed by:
| 2 | ||||||||||||||||||
| 474 | emit keysChanged(); | - | ||||||||||||||||||
| 475 | } executed 54 times by 3 tests: end of blockExecuted by:
| 54 | ||||||||||||||||||
| 476 | } executed 54 times by 3 tests: end of blockExecuted by:
| 54 | ||||||||||||||||||
| 477 | - | |||||||||||||||||||
| 478 | /*! | - | ||||||||||||||||||
| 479 | \qmlattachedproperty stringlist QtQuick::Drag::mimeData | - | ||||||||||||||||||
| 480 | \since 5.2 | - | ||||||||||||||||||
| 481 | - | |||||||||||||||||||
| 482 | This property holds a map of mimeData that is used during startDrag. | - | ||||||||||||||||||
| 483 | */ | - | ||||||||||||||||||
| 484 | - | |||||||||||||||||||
| 485 | QVariantMap QQuickDragAttached::mimeData() const | - | ||||||||||||||||||
| 486 | { | - | ||||||||||||||||||
| 487 | Q_D(const QQuickDragAttached); | - | ||||||||||||||||||
| 488 | return d->externalMimeData; never executed: return d->externalMimeData; | 0 | ||||||||||||||||||
| 489 | } | - | ||||||||||||||||||
| 490 | - | |||||||||||||||||||
| 491 | void QQuickDragAttached::setMimeData(const QVariantMap &mimeData) | - | ||||||||||||||||||
| 492 | { | - | ||||||||||||||||||
| 493 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 494 | if (d->externalMimeData != mimeData) {
| 0-2 | ||||||||||||||||||
| 495 | d->externalMimeData = mimeData; | - | ||||||||||||||||||
| 496 | emit mimeDataChanged(); | - | ||||||||||||||||||
| 497 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 498 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 499 | - | |||||||||||||||||||
| 500 | /*! | - | ||||||||||||||||||
| 501 | \qmlattachedproperty flags QtQuick::Drag::supportedActions | - | ||||||||||||||||||
| 502 | - | |||||||||||||||||||
| 503 | This property holds return values of Drag.drop() supported by the drag source. | - | ||||||||||||||||||
| 504 | - | |||||||||||||||||||
| 505 | Changing the supportedActions while a drag is active will reset the sequence of drag | - | ||||||||||||||||||
| 506 | events by sending a drag leave event followed by a drag enter event with the new source. | - | ||||||||||||||||||
| 507 | */ | - | ||||||||||||||||||
| 508 | - | |||||||||||||||||||
| 509 | Qt::DropActions QQuickDragAttached::supportedActions() const | - | ||||||||||||||||||
| 510 | { | - | ||||||||||||||||||
| 511 | Q_D(const QQuickDragAttached); | - | ||||||||||||||||||
| 512 | return d->supportedActions; executed 16 times by 1 test: return d->supportedActions;Executed by:
| 16 | ||||||||||||||||||
| 513 | } | - | ||||||||||||||||||
| 514 | - | |||||||||||||||||||
| 515 | void QQuickDragAttached::setSupportedActions(Qt::DropActions actions) | - | ||||||||||||||||||
| 516 | { | - | ||||||||||||||||||
| 517 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 518 | if (d->supportedActions != actions) {
| 0-8 | ||||||||||||||||||
| 519 | d->supportedActions = actions; | - | ||||||||||||||||||
| 520 | if (d->active)
| 2-6 | ||||||||||||||||||
| 521 | d->restartDrag(); executed 2 times by 1 test: d->restartDrag();Executed by:
| 2 | ||||||||||||||||||
| 522 | emit supportedActionsChanged(); | - | ||||||||||||||||||
| 523 | } executed 8 times by 3 tests: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 524 | } executed 8 times by 3 tests: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 525 | - | |||||||||||||||||||
| 526 | /*! | - | ||||||||||||||||||
| 527 | \qmlattachedproperty enumeration QtQuick::Drag::proposedAction | - | ||||||||||||||||||
| 528 | - | |||||||||||||||||||
| 529 | This property holds an action that is recommended by the drag source as a | - | ||||||||||||||||||
| 530 | return value from Drag.drop(). | - | ||||||||||||||||||
| 531 | - | |||||||||||||||||||
| 532 | Changes to proposedAction will trigger a move event with the updated proposal. | - | ||||||||||||||||||
| 533 | */ | - | ||||||||||||||||||
| 534 | - | |||||||||||||||||||
| 535 | Qt::DropAction QQuickDragAttached::proposedAction() const | - | ||||||||||||||||||
| 536 | { | - | ||||||||||||||||||
| 537 | Q_D(const QQuickDragAttached); | - | ||||||||||||||||||
| 538 | return d->proposedAction; executed 16 times by 1 test: return d->proposedAction;Executed by:
| 16 | ||||||||||||||||||
| 539 | } | - | ||||||||||||||||||
| 540 | - | |||||||||||||||||||
| 541 | void QQuickDragAttached::setProposedAction(Qt::DropAction action) | - | ||||||||||||||||||
| 542 | { | - | ||||||||||||||||||
| 543 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 544 | if (d->proposedAction != action) {
| 0-8 | ||||||||||||||||||
| 545 | d->proposedAction = action; | - | ||||||||||||||||||
| 546 | // The proposed action shouldn't affect whether a drag is accepted | - | ||||||||||||||||||
| 547 | // so leave/enter events are excessive, but the target should still | - | ||||||||||||||||||
| 548 | // updated. | - | ||||||||||||||||||
| 549 | if (d->active)
| 4 | ||||||||||||||||||
| 550 | d->updatePosition(); executed 4 times by 1 test: d->updatePosition();Executed by:
| 4 | ||||||||||||||||||
| 551 | emit proposedActionChanged(); | - | ||||||||||||||||||
| 552 | } executed 8 times by 2 tests: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 553 | } executed 8 times by 2 tests: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 554 | - | |||||||||||||||||||
| 555 | /*! | - | ||||||||||||||||||
| 556 | \qmlattachedproperty enumeration QtQuick::Drag::dragType | - | ||||||||||||||||||
| 557 | \since 5.2 | - | ||||||||||||||||||
| 558 | - | |||||||||||||||||||
| 559 | This property indicates whether to automatically start drags, do nothing, or | - | ||||||||||||||||||
| 560 | to use backwards compatible internal drags. The default is to use backwards | - | ||||||||||||||||||
| 561 | compatible internal drags. | - | ||||||||||||||||||
| 562 | - | |||||||||||||||||||
| 563 | A drag can also be started manually using \l startDrag. | - | ||||||||||||||||||
| 564 | - | |||||||||||||||||||
| 565 | \list | - | ||||||||||||||||||
| 566 | \li Drag.None - do not start drags automatically | - | ||||||||||||||||||
| 567 | \li Drag.Automatic - start drags automatically | - | ||||||||||||||||||
| 568 | \li Drag.Internal (default) - start backwards compatible drags automatically | - | ||||||||||||||||||
| 569 | \endlist | - | ||||||||||||||||||
| 570 | - | |||||||||||||||||||
| 571 | When using \c Drag.Automatic you should also define \l mimeData and bind the | - | ||||||||||||||||||
| 572 | \l active property to the active property of MouseArea : \l {MouseArea::drag.active} | - | ||||||||||||||||||
| 573 | */ | - | ||||||||||||||||||
| 574 | - | |||||||||||||||||||
| 575 | QQuickDrag::DragType QQuickDragAttached::dragType() const | - | ||||||||||||||||||
| 576 | { | - | ||||||||||||||||||
| 577 | Q_D(const QQuickDragAttached); | - | ||||||||||||||||||
| 578 | return d->dragType; never executed: return d->dragType; | 0 | ||||||||||||||||||
| 579 | } | - | ||||||||||||||||||
| 580 | - | |||||||||||||||||||
| 581 | void QQuickDragAttached::setDragType(QQuickDrag::DragType dragType) | - | ||||||||||||||||||
| 582 | { | - | ||||||||||||||||||
| 583 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 584 | if (d->dragType != dragType) {
| 2-4 | ||||||||||||||||||
| 585 | d->dragType = dragType; | - | ||||||||||||||||||
| 586 | emit dragTypeChanged(); | - | ||||||||||||||||||
| 587 | } executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||
| 588 | } executed 6 times by 2 tests: end of blockExecuted by:
| 6 | ||||||||||||||||||
| 589 | - | |||||||||||||||||||
| 590 | void QQuickDragAttachedPrivate::start(Qt::DropActions supportedActions) | - | ||||||||||||||||||
| 591 | { | - | ||||||||||||||||||
| 592 | Q_Q(QQuickDragAttached); | - | ||||||||||||||||||
| 593 | Q_ASSERT(!active); | - | ||||||||||||||||||
| 594 | - | |||||||||||||||||||
| 595 | if (!mimeData)
| 90-96 | ||||||||||||||||||
| 596 | mimeData = new QQuickDragMimeData; executed 90 times by 3 tests: mimeData = new QQuickDragMimeData;Executed by:
| 90 | ||||||||||||||||||
| 597 | if (!listening) {
| 90-96 | ||||||||||||||||||
| 598 | QQuickItemPrivate::get(attachedItem)->addItemChangeListener( | - | ||||||||||||||||||
| 599 | this, QQuickItemPrivate::Geometry | QQuickItemPrivate::Parent); | - | ||||||||||||||||||
| 600 | listening = true; | - | ||||||||||||||||||
| 601 | } executed 90 times by 3 tests: end of blockExecuted by:
| 90 | ||||||||||||||||||
| 602 | - | |||||||||||||||||||
| 603 | mimeData->m_supportedActions = supportedActions; | - | ||||||||||||||||||
| 604 | active = true; | - | ||||||||||||||||||
| 605 | itemMoved = false; | - | ||||||||||||||||||
| 606 | dragRestarted = false; | - | ||||||||||||||||||
| 607 | - | |||||||||||||||||||
| 608 | deliverEnterEvent(); | - | ||||||||||||||||||
| 609 | - | |||||||||||||||||||
| 610 | if (target != dragGrabber.target()) {
| 36-150 | ||||||||||||||||||
| 611 | target = dragGrabber.target(); | - | ||||||||||||||||||
| 612 | emit q->targetChanged(); | - | ||||||||||||||||||
| 613 | } executed 150 times by 3 tests: end of blockExecuted by:
| 150 | ||||||||||||||||||
| 614 | - | |||||||||||||||||||
| 615 | emit q->activeChanged(); | - | ||||||||||||||||||
| 616 | } executed 186 times by 3 tests: end of blockExecuted by:
| 186 | ||||||||||||||||||
| 617 | - | |||||||||||||||||||
| 618 | /*! | - | ||||||||||||||||||
| 619 | \qmlattachedmethod void QtQuick::Drag::start(flags supportedActions) | - | ||||||||||||||||||
| 620 | - | |||||||||||||||||||
| 621 | Starts sending drag events. Used for starting old-style internal drags. \l startDrag is the | - | ||||||||||||||||||
| 622 | new-style, preferred method of starting drags. | - | ||||||||||||||||||
| 623 | - | |||||||||||||||||||
| 624 | The optional \a supportedActions argument can be used to override the \l supportedActions | - | ||||||||||||||||||
| 625 | property for the started sequence. | - | ||||||||||||||||||
| 626 | */ | - | ||||||||||||||||||
| 627 | - | |||||||||||||||||||
| 628 | void QQuickDragAttached::start(QQmlV4Function *args) | - | ||||||||||||||||||
| 629 | { | - | ||||||||||||||||||
| 630 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 631 | if (d->inEvent) {
| 8-72 | ||||||||||||||||||
| 632 | qmlWarning(this) << "start() cannot be called from within a drag event handler"; | - | ||||||||||||||||||
| 633 | return; executed 8 times by 1 test: return;Executed by:
| 8 | ||||||||||||||||||
| 634 | } | - | ||||||||||||||||||
| 635 | - | |||||||||||||||||||
| 636 | if (d->active)
| 6-66 | ||||||||||||||||||
| 637 | cancel(); executed 6 times by 1 test: cancel();Executed by:
| 6 | ||||||||||||||||||
| 638 | - | |||||||||||||||||||
| 639 | d->overrideActions = false; | - | ||||||||||||||||||
| 640 | Qt::DropActions supportedActions = d->supportedActions; | - | ||||||||||||||||||
| 641 | // check arguments for supportedActions, maybe data? | - | ||||||||||||||||||
| 642 | if (args->length() >= 1) {
| 2-70 | ||||||||||||||||||
| 643 | QV4::Scope scope(args->v4engine()); | - | ||||||||||||||||||
| 644 | QV4::ScopedValue v(scope, (*args)[0]); | - | ||||||||||||||||||
| 645 | if (v->isInt32()) {
| 0-2 | ||||||||||||||||||
| 646 | supportedActions = Qt::DropActions(v->integerValue()); | - | ||||||||||||||||||
| 647 | d->overrideActions = true; | - | ||||||||||||||||||
| 648 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 649 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 650 | - | |||||||||||||||||||
| 651 | d->start(supportedActions); | - | ||||||||||||||||||
| 652 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||
| 653 | - | |||||||||||||||||||
| 654 | /*! | - | ||||||||||||||||||
| 655 | \qmlattachedmethod enumeration QtQuick::Drag::drop() | - | ||||||||||||||||||
| 656 | - | |||||||||||||||||||
| 657 | Ends a drag sequence by sending a drop event to the target item. | - | ||||||||||||||||||
| 658 | - | |||||||||||||||||||
| 659 | Returns the action accepted by the target item. If the target item or a parent doesn't accept | - | ||||||||||||||||||
| 660 | the drop event then Qt.IgnoreAction will be returned. | - | ||||||||||||||||||
| 661 | - | |||||||||||||||||||
| 662 | The returned drop action may be one of: | - | ||||||||||||||||||
| 663 | - | |||||||||||||||||||
| 664 | \list | - | ||||||||||||||||||
| 665 | \li Qt.CopyAction Copy the data to the target | - | ||||||||||||||||||
| 666 | \li Qt.MoveAction Move the data from the source to the target | - | ||||||||||||||||||
| 667 | \li Qt.LinkAction Create a link from the source to the target. | - | ||||||||||||||||||
| 668 | \li Qt.IgnoreAction Ignore the action (do nothing with the data). | - | ||||||||||||||||||
| 669 | \endlist | - | ||||||||||||||||||
| 670 | */ | - | ||||||||||||||||||
| 671 | - | |||||||||||||||||||
| 672 | int QQuickDragAttached::drop() | - | ||||||||||||||||||
| 673 | { | - | ||||||||||||||||||
| 674 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 675 | Qt::DropAction acceptedAction = Qt::IgnoreAction; | - | ||||||||||||||||||
| 676 | - | |||||||||||||||||||
| 677 | if (d->inEvent) {
| 8-46 | ||||||||||||||||||
| 678 | qmlWarning(this) << "drop() cannot be called from within a drag event handler"; | - | ||||||||||||||||||
| 679 | return acceptedAction; executed 8 times by 1 test: return acceptedAction;Executed by:
| 8 | ||||||||||||||||||
| 680 | } | - | ||||||||||||||||||
| 681 | - | |||||||||||||||||||
| 682 | if (d->itemMoved)
| 4-42 | ||||||||||||||||||
| 683 | d->deliverMoveEvent(); executed 4 times by 1 test: d->deliverMoveEvent();Executed by:
| 4 | ||||||||||||||||||
| 684 | - | |||||||||||||||||||
| 685 | if (!d->active)
| 2-44 | ||||||||||||||||||
| 686 | return acceptedAction; executed 2 times by 1 test: return acceptedAction;Executed by:
| 2 | ||||||||||||||||||
| 687 | d->active = false; | - | ||||||||||||||||||
| 688 | - | |||||||||||||||||||
| 689 | QObject *target = nullptr; | - | ||||||||||||||||||
| 690 | - | |||||||||||||||||||
| 691 | if (d->window) {
| 0-44 | ||||||||||||||||||
| 692 | QPoint scenePos = d->attachedItem->mapToScene(d->hotSpot).toPoint(); | - | ||||||||||||||||||
| 693 | - | |||||||||||||||||||
| 694 | QDropEvent event( | - | ||||||||||||||||||
| 695 | scenePos, d->mimeData->m_supportedActions, d->mimeData, Qt::NoButton, Qt::NoModifier); | - | ||||||||||||||||||
| 696 | QQuickDropEventEx::setProposedAction(&event, d->proposedAction); | - | ||||||||||||||||||
| 697 | d->deliverEvent(d->window, &event); | - | ||||||||||||||||||
| 698 | - | |||||||||||||||||||
| 699 | if (event.isAccepted()) {
| 6-38 | ||||||||||||||||||
| 700 | acceptedAction = event.dropAction(); | - | ||||||||||||||||||
| 701 | target = d->dragGrabber.target(); | - | ||||||||||||||||||
| 702 | } executed 38 times by 2 tests: end of blockExecuted by:
| 38 | ||||||||||||||||||
| 703 | } executed 44 times by 2 tests: end of blockExecuted by:
| 44 | ||||||||||||||||||
| 704 | - | |||||||||||||||||||
| 705 | if (d->target != target) {
| 6-38 | ||||||||||||||||||
| 706 | d->target = target; | - | ||||||||||||||||||
| 707 | emit targetChanged(); | - | ||||||||||||||||||
| 708 | } executed 6 times by 2 tests: end of blockExecuted by:
| 6 | ||||||||||||||||||
| 709 | - | |||||||||||||||||||
| 710 | emit activeChanged(); | - | ||||||||||||||||||
| 711 | return acceptedAction; executed 44 times by 2 tests: return acceptedAction;Executed by:
| 44 | ||||||||||||||||||
| 712 | } | - | ||||||||||||||||||
| 713 | - | |||||||||||||||||||
| 714 | /*! | - | ||||||||||||||||||
| 715 | \qmlattachedmethod void QtQuick::Drag::cancel() | - | ||||||||||||||||||
| 716 | - | |||||||||||||||||||
| 717 | Ends a drag sequence. | - | ||||||||||||||||||
| 718 | */ | - | ||||||||||||||||||
| 719 | - | |||||||||||||||||||
| 720 | void QQuickDragAttached::cancel() | - | ||||||||||||||||||
| 721 | { | - | ||||||||||||||||||
| 722 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 723 | - | |||||||||||||||||||
| 724 | if (d->inEvent) {
| 8-126 | ||||||||||||||||||
| 725 | qmlWarning(this) << "cancel() cannot be called from within a drag event handler"; | - | ||||||||||||||||||
| 726 | return; executed 8 times by 1 test: return;Executed by:
| 8 | ||||||||||||||||||
| 727 | } | - | ||||||||||||||||||
| 728 | - | |||||||||||||||||||
| 729 | if (!d->active)
| 2-124 | ||||||||||||||||||
| 730 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||
| 731 | d->active = false; | - | ||||||||||||||||||
| 732 | d->deliverLeaveEvent(); | - | ||||||||||||||||||
| 733 | - | |||||||||||||||||||
| 734 | if (d->target) {
| 16-108 | ||||||||||||||||||
| 735 | d->target = nullptr; | - | ||||||||||||||||||
| 736 | emit targetChanged(); | - | ||||||||||||||||||
| 737 | } executed 108 times by 3 tests: end of blockExecuted by:
| 108 | ||||||||||||||||||
| 738 | - | |||||||||||||||||||
| 739 | emit activeChanged(); | - | ||||||||||||||||||
| 740 | } executed 124 times by 3 tests: end of blockExecuted by:
| 124 | ||||||||||||||||||
| 741 | - | |||||||||||||||||||
| 742 | /*! | - | ||||||||||||||||||
| 743 | \qmlattachedsignal QtQuick::Drag::dragStarted() | - | ||||||||||||||||||
| 744 | - | |||||||||||||||||||
| 745 | This signal is emitted when a drag is started with the \l startDrag() method | - | ||||||||||||||||||
| 746 | or when it is started automatically using the \l dragType property. | - | ||||||||||||||||||
| 747 | - | |||||||||||||||||||
| 748 | The corresponding handler is \c onDragStarted. | - | ||||||||||||||||||
| 749 | */ | - | ||||||||||||||||||
| 750 | - | |||||||||||||||||||
| 751 | /*! | - | ||||||||||||||||||
| 752 | \qmlattachedsignal QtQuick::Drag::dragFinished(DropAction dropAction) | - | ||||||||||||||||||
| 753 | - | |||||||||||||||||||
| 754 | This signal is emitted when a drag finishes and the drag was started with the | - | ||||||||||||||||||
| 755 | \l startDrag() method or started automatically using the \l dragType property. | - | ||||||||||||||||||
| 756 | - | |||||||||||||||||||
| 757 | The corresponding handler is \c onDragFinished. | - | ||||||||||||||||||
| 758 | */ | - | ||||||||||||||||||
| 759 | - | |||||||||||||||||||
| 760 | Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedActions) | - | ||||||||||||||||||
| 761 | { | - | ||||||||||||||||||
| 762 | Q_Q(QQuickDragAttached); | - | ||||||||||||||||||
| 763 | - | |||||||||||||||||||
| 764 | QDrag *drag = new QDrag(source ? source : q); | - | ||||||||||||||||||
| 765 | QMimeData *mimeData = new QMimeData(); | - | ||||||||||||||||||
| 766 | - | |||||||||||||||||||
| 767 | for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
| 0 | ||||||||||||||||||
| 768 | mimeData->setData(it.key(), it.value().toString().toUtf8()); never executed: mimeData->setData(it.key(), it.value().toString().toUtf8()); | 0 | ||||||||||||||||||
| 769 | - | |||||||||||||||||||
| 770 | drag->setMimeData(mimeData); | - | ||||||||||||||||||
| 771 | if (pixmapLoader.isReady()) {
| 0 | ||||||||||||||||||
| 772 | drag->setPixmap(QPixmap::fromImage(pixmapLoader.image())); | - | ||||||||||||||||||
| 773 | } never executed: end of block | 0 | ||||||||||||||||||
| 774 | - | |||||||||||||||||||
| 775 | drag->setHotSpot(hotSpot.toPoint()); | - | ||||||||||||||||||
| 776 | emit q->dragStarted(); | - | ||||||||||||||||||
| 777 | - | |||||||||||||||||||
| 778 | Qt::DropAction dropAction = drag->exec(supportedActions); | - | ||||||||||||||||||
| 779 | - | |||||||||||||||||||
| 780 | if (!QGuiApplicationPrivate::platformIntegration()->drag()->ownsDragObject())
| 0 | ||||||||||||||||||
| 781 | drag->deleteLater(); never executed: drag->deleteLater(); | 0 | ||||||||||||||||||
| 782 | - | |||||||||||||||||||
| 783 | deliverLeaveEvent(); | - | ||||||||||||||||||
| 784 | - | |||||||||||||||||||
| 785 | if (target) {
| 0 | ||||||||||||||||||
| 786 | target = nullptr; | - | ||||||||||||||||||
| 787 | emit q->targetChanged(); | - | ||||||||||||||||||
| 788 | } never executed: end of block | 0 | ||||||||||||||||||
| 789 | - | |||||||||||||||||||
| 790 | emit q->dragFinished(dropAction); | - | ||||||||||||||||||
| 791 | - | |||||||||||||||||||
| 792 | active = false; | - | ||||||||||||||||||
| 793 | emit q->activeChanged(); | - | ||||||||||||||||||
| 794 | - | |||||||||||||||||||
| 795 | return dropAction; never executed: return dropAction; | 0 | ||||||||||||||||||
| 796 | } | - | ||||||||||||||||||
| 797 | - | |||||||||||||||||||
| 798 | - | |||||||||||||||||||
| 799 | /*! | - | ||||||||||||||||||
| 800 | \qmlattachedmethod void QtQuick::Drag::startDrag(flags supportedActions) | - | ||||||||||||||||||
| 801 | - | |||||||||||||||||||
| 802 | Starts sending drag events. | - | ||||||||||||||||||
| 803 | - | |||||||||||||||||||
| 804 | The optional \a supportedActions argument can be used to override the \l supportedActions | - | ||||||||||||||||||
| 805 | property for the started sequence. | - | ||||||||||||||||||
| 806 | */ | - | ||||||||||||||||||
| 807 | - | |||||||||||||||||||
| 808 | void QQuickDragAttached::startDrag(QQmlV4Function *args) | - | ||||||||||||||||||
| 809 | { | - | ||||||||||||||||||
| 810 | Q_D(QQuickDragAttached); | - | ||||||||||||||||||
| 811 | - | |||||||||||||||||||
| 812 | if (d->inEvent) {
| 0 | ||||||||||||||||||
| 813 | qmlWarning(this) << "startDrag() cannot be called from within a drag event handler"; | - | ||||||||||||||||||
| 814 | return; never executed: return; | 0 | ||||||||||||||||||
| 815 | } | - | ||||||||||||||||||
| 816 | - | |||||||||||||||||||
| 817 | if (!d->active) {
| 0 | ||||||||||||||||||
| 818 | qmlWarning(this) << "startDrag() drag must be active"; | - | ||||||||||||||||||
| 819 | return; never executed: return; | 0 | ||||||||||||||||||
| 820 | } | - | ||||||||||||||||||
| 821 | - | |||||||||||||||||||
| 822 | Qt::DropActions supportedActions = d->supportedActions; | - | ||||||||||||||||||
| 823 | - | |||||||||||||||||||
| 824 | // check arguments for supportedActions | - | ||||||||||||||||||
| 825 | if (args->length() >= 1) {
| 0 | ||||||||||||||||||
| 826 | QV4::Scope scope(args->v4engine()); | - | ||||||||||||||||||
| 827 | QV4::ScopedValue v(scope, (*args)[0]); | - | ||||||||||||||||||
| 828 | if (v->isInt32()) {
| 0 | ||||||||||||||||||
| 829 | supportedActions = Qt::DropActions(v->integerValue()); | - | ||||||||||||||||||
| 830 | } never executed: end of block | 0 | ||||||||||||||||||
| 831 | } never executed: end of block | 0 | ||||||||||||||||||
| 832 | - | |||||||||||||||||||
| 833 | Qt::DropAction dropAction = d->startDrag(supportedActions); | - | ||||||||||||||||||
| 834 | - | |||||||||||||||||||
| 835 | args->setReturnValue(QV4::Encode((int)dropAction)); | - | ||||||||||||||||||
| 836 | } never executed: end of block | 0 | ||||||||||||||||||
| 837 | - | |||||||||||||||||||
| 838 | QQuickDrag::QQuickDrag(QObject *parent) | - | ||||||||||||||||||
| 839 | : QObject(parent), _target(nullptr), _axis(XAndYAxis), _xmin(-FLT_MAX), | - | ||||||||||||||||||
| 840 | _xmax(FLT_MAX), _ymin(-FLT_MAX), _ymax(FLT_MAX), _active(false), _filterChildren(false), | - | ||||||||||||||||||
| 841 | _smoothed(true), _threshold(QGuiApplication::styleHints()->startDragDistance()) | - | ||||||||||||||||||
| 842 | { | - | ||||||||||||||||||
| 843 | } executed 452 times by 6 tests: end of blockExecuted by:
| 452 | ||||||||||||||||||
| 844 | - | |||||||||||||||||||
| 845 | QQuickDrag::~QQuickDrag() | - | ||||||||||||||||||
| 846 | { | - | ||||||||||||||||||
| 847 | } | - | ||||||||||||||||||
| 848 | - | |||||||||||||||||||
| 849 | QQuickItem *QQuickDrag::target() const | - | ||||||||||||||||||
| 850 | { | - | ||||||||||||||||||
| 851 | return _target; executed 3208 times by 4 tests: return _target;Executed by:
| 3208 | ||||||||||||||||||
| 852 | } | - | ||||||||||||||||||
| 853 | - | |||||||||||||||||||
| 854 | void QQuickDrag::setTarget(QQuickItem *t) | - | ||||||||||||||||||
| 855 | { | - | ||||||||||||||||||
| 856 | if (_target == t)
| 2-408 | ||||||||||||||||||
| 857 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||
| 858 | _target = t; | - | ||||||||||||||||||
| 859 | emit targetChanged(); | - | ||||||||||||||||||
| 860 | } executed 408 times by 5 tests: end of blockExecuted by:
| 408 | ||||||||||||||||||
| 861 | - | |||||||||||||||||||
| 862 | void QQuickDrag::resetTarget() | - | ||||||||||||||||||
| 863 | { | - | ||||||||||||||||||
| 864 | if (_target == nullptr)
| 2-42 | ||||||||||||||||||
| 865 | return; executed 42 times by 1 test: return;Executed by:
| 42 | ||||||||||||||||||
| 866 | _target = nullptr; | - | ||||||||||||||||||
| 867 | emit targetChanged(); | - | ||||||||||||||||||
| 868 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 869 | - | |||||||||||||||||||
| 870 | QQuickDrag::Axis QQuickDrag::axis() const | - | ||||||||||||||||||
| 871 | { | - | ||||||||||||||||||
| 872 | return _axis; executed 690 times by 4 tests: return _axis;Executed by:
| 690 | ||||||||||||||||||
| 873 | } | - | ||||||||||||||||||
| 874 | - | |||||||||||||||||||
| 875 | void QQuickDrag::setAxis(QQuickDrag::Axis a) | - | ||||||||||||||||||
| 876 | { | - | ||||||||||||||||||
| 877 | if (_axis == a)
| 64-100 | ||||||||||||||||||
| 878 | return; executed 64 times by 2 tests: return;Executed by:
| 64 | ||||||||||||||||||
| 879 | _axis = a; | - | ||||||||||||||||||
| 880 | emit axisChanged(); | - | ||||||||||||||||||
| 881 | } executed 100 times by 2 tests: end of blockExecuted by:
| 100 | ||||||||||||||||||
| 882 | - | |||||||||||||||||||
| 883 | qreal QQuickDrag::xmin() const | - | ||||||||||||||||||
| 884 | { | - | ||||||||||||||||||
| 885 | return _xmin; executed 896 times by 5 tests: return _xmin;Executed by:
| 896 | ||||||||||||||||||
| 886 | } | - | ||||||||||||||||||
| 887 | - | |||||||||||||||||||
| 888 | void QQuickDrag::setXmin(qreal m) | - | ||||||||||||||||||
| 889 | { | - | ||||||||||||||||||
| 890 | if (_xmin == m)
| 2-132 | ||||||||||||||||||
| 891 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||
| 892 | _xmin = m; | - | ||||||||||||||||||
| 893 | emit minimumXChanged(); | - | ||||||||||||||||||
| 894 | } executed 132 times by 2 tests: end of blockExecuted by:
| 132 | ||||||||||||||||||
| 895 | - | |||||||||||||||||||
| 896 | qreal QQuickDrag::xmax() const | - | ||||||||||||||||||
| 897 | { | - | ||||||||||||||||||
| 898 | return _xmax; executed 612 times by 5 tests: return _xmax;Executed by:
| 612 | ||||||||||||||||||
| 899 | } | - | ||||||||||||||||||
| 900 | - | |||||||||||||||||||
| 901 | void QQuickDrag::setXmax(qreal m) | - | ||||||||||||||||||
| 902 | { | - | ||||||||||||||||||
| 903 | if (_xmax == m)
| 66-236 | ||||||||||||||||||
| 904 | return; executed 66 times by 2 tests: return;Executed by:
| 66 | ||||||||||||||||||
| 905 | _xmax = m; | - | ||||||||||||||||||
| 906 | emit maximumXChanged(); | - | ||||||||||||||||||
| 907 | } executed 236 times by 2 tests: end of blockExecuted by:
| 236 | ||||||||||||||||||
| 908 | - | |||||||||||||||||||
| 909 | qreal QQuickDrag::ymin() const | - | ||||||||||||||||||
| 910 | { | - | ||||||||||||||||||
| 911 | return _ymin; executed 322 times by 4 tests: return _ymin;Executed by:
| 322 | ||||||||||||||||||
| 912 | } | - | ||||||||||||||||||
| 913 | - | |||||||||||||||||||
| 914 | void QQuickDrag::setYmin(qreal m) | - | ||||||||||||||||||
| 915 | { | - | ||||||||||||||||||
| 916 | if (_ymin == m)
| 2-52 | ||||||||||||||||||
| 917 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||
| 918 | _ymin = m; | - | ||||||||||||||||||
| 919 | emit minimumYChanged(); | - | ||||||||||||||||||
| 920 | } executed 52 times by 2 tests: end of blockExecuted by:
| 52 | ||||||||||||||||||
| 921 | - | |||||||||||||||||||
| 922 | qreal QQuickDrag::ymax() const | - | ||||||||||||||||||
| 923 | { | - | ||||||||||||||||||
| 924 | return _ymax; executed 322 times by 4 tests: return _ymax;Executed by:
| 322 | ||||||||||||||||||
| 925 | } | - | ||||||||||||||||||
| 926 | - | |||||||||||||||||||
| 927 | void QQuickDrag::setYmax(qreal m) | - | ||||||||||||||||||
| 928 | { | - | ||||||||||||||||||
| 929 | if (_ymax == m)
| 2-52 | ||||||||||||||||||
| 930 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||
| 931 | _ymax = m; | - | ||||||||||||||||||
| 932 | emit maximumYChanged(); | - | ||||||||||||||||||
| 933 | } executed 52 times by 2 tests: end of blockExecuted by:
| 52 | ||||||||||||||||||
| 934 | - | |||||||||||||||||||
| 935 | bool QQuickDrag::smoothed() const | - | ||||||||||||||||||
| 936 | { | - | ||||||||||||||||||
| 937 | return _smoothed; executed 74 times by 4 tests: return _smoothed;Executed by:
| 74 | ||||||||||||||||||
| 938 | } | - | ||||||||||||||||||
| 939 | - | |||||||||||||||||||
| 940 | void QQuickDrag::setSmoothed(bool smooth) | - | ||||||||||||||||||
| 941 | { | - | ||||||||||||||||||
| 942 | if (_smoothed != smooth) {
| 0-2 | ||||||||||||||||||
| 943 | _smoothed = smooth; | - | ||||||||||||||||||
| 944 | emit smoothedChanged(); | - | ||||||||||||||||||
| 945 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 946 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 947 | - | |||||||||||||||||||
| 948 | qreal QQuickDrag::threshold() const | - | ||||||||||||||||||
| 949 | { | - | ||||||||||||||||||
| 950 | return _threshold; executed 682 times by 4 tests: return _threshold;Executed by:
| 682 | ||||||||||||||||||
| 951 | } | - | ||||||||||||||||||
| 952 | - | |||||||||||||||||||
| 953 | void QQuickDrag::setThreshold(qreal value) | - | ||||||||||||||||||
| 954 | { | - | ||||||||||||||||||
| 955 | if (_threshold != value) {
| 2-22 | ||||||||||||||||||
| 956 | _threshold = value; | - | ||||||||||||||||||
| 957 | emit thresholdChanged(); | - | ||||||||||||||||||
| 958 | } executed 22 times by 1 test: end of blockExecuted by:
| 22 | ||||||||||||||||||
| 959 | } executed 24 times by 1 test: end of blockExecuted by:
| 24 | ||||||||||||||||||
| 960 | - | |||||||||||||||||||
| 961 | void QQuickDrag::resetThreshold() | - | ||||||||||||||||||
| 962 | { | - | ||||||||||||||||||
| 963 | setThreshold(QGuiApplication::styleHints()->startDragDistance()); | - | ||||||||||||||||||
| 964 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||
| 965 | - | |||||||||||||||||||
| 966 | bool QQuickDrag::active() const | - | ||||||||||||||||||
| 967 | { | - | ||||||||||||||||||
| 968 | return _active; executed 1562 times by 5 tests: return _active;Executed by:
| 1562 | ||||||||||||||||||
| 969 | } | - | ||||||||||||||||||
| 970 | - | |||||||||||||||||||
| 971 | void QQuickDrag::setActive(bool drag) | - | ||||||||||||||||||
| 972 | { | - | ||||||||||||||||||
| 973 | if (_active == drag)
| 88-120 | ||||||||||||||||||
| 974 | return; executed 88 times by 4 tests: return;Executed by:
| 88 | ||||||||||||||||||
| 975 | _active = drag; | - | ||||||||||||||||||
| 976 | emit activeChanged(); | - | ||||||||||||||||||
| 977 | } executed 120 times by 4 tests: end of blockExecuted by:
| 120 | ||||||||||||||||||
| 978 | - | |||||||||||||||||||
| 979 | bool QQuickDrag::filterChildren() const | - | ||||||||||||||||||
| 980 | { | - | ||||||||||||||||||
| 981 | return _filterChildren; executed 44 times by 2 tests: return _filterChildren;Executed by:
| 44 | ||||||||||||||||||
| 982 | } | - | ||||||||||||||||||
| 983 | - | |||||||||||||||||||
| 984 | void QQuickDrag::setFilterChildren(bool filter) | - | ||||||||||||||||||
| 985 | { | - | ||||||||||||||||||
| 986 | if (_filterChildren == filter)
| 2-18 | ||||||||||||||||||
| 987 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||
| 988 | _filterChildren = filter; | - | ||||||||||||||||||
| 989 | emit filterChildrenChanged(); | - | ||||||||||||||||||
| 990 | } executed 18 times by 3 tests: end of blockExecuted by:
| 18 | ||||||||||||||||||
| 991 | - | |||||||||||||||||||
| 992 | QQuickDragAttached *QQuickDrag::qmlAttachedProperties(QObject *obj) | - | ||||||||||||||||||
| 993 | { | - | ||||||||||||||||||
| 994 | return new QQuickDragAttached(obj); executed 390 times by 4 tests: return new QQuickDragAttached(obj);Executed by:
| 390 | ||||||||||||||||||
| 995 | } | - | ||||||||||||||||||
| 996 | - | |||||||||||||||||||
| 997 | QT_END_NAMESPACE | - | ||||||||||||||||||
| 998 | - | |||||||||||||||||||
| 999 | #include "moc_qquickdrag_p.cpp" | - | ||||||||||||||||||
| 1000 | - | |||||||||||||||||||
| 1001 | #endif // draganddrop | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |