diff options
Diffstat (limited to 'src/gui/itemviews/qabstractitemview.cpp')
-rw-r--r-- | src/gui/itemviews/qabstractitemview.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 0fae959..18cab13 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -87,6 +87,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() dragDropMode(QAbstractItemView::NoDragDrop), overwrite(false), dropIndicatorPosition(QAbstractItemView::OnItem), + defaultDropAction(Qt::IgnoreAction), #endif #ifdef QT_SOFTKEYS_ENABLED doneSoftKey(0), @@ -1371,6 +1372,28 @@ QAbstractItemView::DragDropMode QAbstractItemView::dragDropMode() const return NoDragDrop; } +/*! + \property QAbstractItemView::defaultDropAction + \brief the drop action that will be used by default in QAbstractItemView::drag() + + If the property is not set, the drop action is CopyAction when the supported + actions support CopyAction. + + \since 4.6 + \sa showDropIndicator dragDropOverwriteMode +*/ +void QAbstractItemView::setDefaultDropAction(Qt::DropAction dropAction) +{ + Q_D(QAbstractItemView); + d->defaultDropAction = dropAction; +} + +Qt::DropAction QAbstractItemView::defaultDropAction() const +{ + Q_D(const QAbstractItemView); + return d->defaultDropAction; +} + #endif // QT_NO_DRAGANDDROP /*! @@ -3297,7 +3320,9 @@ void QAbstractItemView::startDrag(Qt::DropActions supportedActions) drag->setMimeData(data); drag->setHotSpot(d->pressedPosition - rect.topLeft()); Qt::DropAction defaultDropAction = Qt::IgnoreAction; - if (supportedActions & Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove) + if (d->defaultDropAction != Qt::IgnoreAction && (supportedActions & d->defaultDropAction)) + defaultDropAction = d->defaultDropAction; + else if (supportedActions & Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove) defaultDropAction = Qt::CopyAction; if (drag->exec(supportedActions, defaultDropAction) == Qt::MoveAction) d->clearOrRemove(); |