diff options
author | Gunnar Sletta <gunnar@trolltech.com> | 2009-10-02 09:40:34 (GMT) |
---|---|---|
committer | Gunnar Sletta <gunnar@trolltech.com> | 2009-10-02 09:40:34 (GMT) |
commit | 10183fc00bcb1e7a99af6037936c2b576576bf63 (patch) | |
tree | 2fa47d39a6cfb949e28f7a22e9dc4094cedf9a1a /src | |
parent | cfd31c28f2e30ee725d23c36ea8349f984b57047 (diff) | |
parent | 357dffdffcce1a72711e058c6cfab5b680e2ba10 (diff) | |
download | Qt-10183fc00bcb1e7a99af6037936c2b576576bf63.zip Qt-10183fc00bcb1e7a99af6037936c2b576576bf63.tar.gz Qt-10183fc00bcb1e7a99af6037936c2b576576bf63.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/itemviews/qabstractitemview.cpp | 27 | ||||
-rw-r--r-- | src/gui/itemviews/qabstractitemview.h | 5 | ||||
-rw-r--r-- | src/gui/itemviews/qabstractitemview_p.h | 9 |
3 files changed, 36 insertions, 5 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(); diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h index 7d5c765..b4f0957 100644 --- a/src/gui/itemviews/qabstractitemview.h +++ b/src/gui/itemviews/qabstractitemview.h @@ -74,6 +74,7 @@ class Q_GUI_EXPORT QAbstractItemView : public QAbstractScrollArea Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled) Q_PROPERTY(bool dragDropOverwriteMode READ dragDropOverwriteMode WRITE setDragDropOverwriteMode) Q_PROPERTY(DragDropMode dragDropMode READ dragDropMode WRITE setDragDropMode) + Q_PROPERTY(Qt::DropAction defaultDropAction READ defaultDropAction WRITE setDefaultDropAction) #endif Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors) Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode) @@ -181,7 +182,11 @@ public: void setDragDropMode(DragDropMode behavior); DragDropMode dragDropMode() const; + + void setDefaultDropAction(Qt::DropAction dropAction); + Qt::DropAction defaultDropAction() const; #endif + void setAlternatingRowColors(bool enable); bool alternatingRowColors() const; diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 84c0892..fcf381a 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -117,7 +117,7 @@ public: virtual void _q_columnsInserted(const QModelIndex &parent, int start, int end); virtual void _q_modelDestroyed(); virtual void _q_layoutChanged(); - + void fetchMore(); bool shouldEdit(QAbstractItemView::EditTrigger trigger, const QModelIndex &index) const; @@ -315,7 +315,7 @@ public: } return ref; } - + /** * return true if the index is registered as a QPersistentModelIndex */ @@ -356,8 +356,8 @@ public: Qt::KeyboardModifiers pressedModifiers; QPoint pressedPosition; bool pressedAlreadySelected; - - //forces the next mouseMoveEvent to send the viewportEntered signal + + //forces the next mouseMoveEvent to send the viewportEntered signal //if the mouse is over the viewport and not over an item bool viewportEnteredNeeded; @@ -377,6 +377,7 @@ public: QAbstractItemView::DragDropMode dragDropMode; bool overwrite; QAbstractItemView::DropIndicatorPosition dropIndicatorPosition; + Qt::DropAction defaultDropAction; #endif #ifdef QT_SOFTKEYS_ENABLED |