diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2019-02-28 15:03:12 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2019-03-13 00:02:50 +0100 |
commit | 66b352eca973c72bc40239591addabb5fd0b49c0 (patch) | |
tree | 1de8e8973931301e10b8cb31510abae8fdb41255 /vcl/qt5 | |
parent | cda7159937be6f88eeb5826dcbdc72d64788779c (diff) |
tdf#120783: take suggested/preferred DnD ops into account
use those for drag operation start in Qt5Widget and eventually
to construct DropTargetDragEnterEvent
Change-Id: I3a92cbe722dadc64f8a210f7fd4016c8eb17216b
Reviewed-on: https://gerrit.libreoffice.org/68675
Tested-by: Jenkins
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
(cherry picked from commit c3751ed3c98e8ed40100a8073b97c83d9ded0803)
Reviewed-on: https://gerrit.libreoffice.org/69122
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r-- | vcl/qt5/Qt5DragAndDrop.cxx | 4 | ||||
-rw-r--r-- | vcl/qt5/Qt5Frame.cxx | 7 | ||||
-rw-r--r-- | vcl/qt5/Qt5Tools.cxx | 38 | ||||
-rw-r--r-- | vcl/qt5/Qt5Widget.cxx | 6 |
4 files changed, 47 insertions, 8 deletions
diff --git a/vcl/qt5/Qt5DragAndDrop.cxx b/vcl/qt5/Qt5DragAndDrop.cxx index fcd65fe39049..adc7a94fa0c2 100644 --- a/vcl/qt5/Qt5DragAndDrop.cxx +++ b/vcl/qt5/Qt5DragAndDrop.cxx @@ -128,7 +128,7 @@ void Qt5DragSource::initialize(const css::uno::Sequence<css::uno::Any>& rArgumen } void Qt5DragSource::startDrag( - const datatransfer::dnd::DragGestureEvent& /*rEvent*/, sal_Int8 /*sourceActions*/, + const datatransfer::dnd::DragGestureEvent& /*rEvent*/, sal_Int8 sourceActions, sal_Int32 /*cursor*/, sal_Int32 /*image*/, const css::uno::Reference<css::datatransfer::XTransferable>& rTrans, const css::uno::Reference<css::datatransfer::dnd::XDragSourceListener>& rListener) @@ -140,7 +140,7 @@ void Qt5DragSource::startDrag( { Qt5Widget* qw = static_cast<Qt5Widget*>(m_pFrame->GetQWidget()); m_ActiveDragSource = this; - qw->startDrag(); + qw->startDrag(sourceActions); } else dragFailed(); diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index acf7c6da7266..27f331ce2f05 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -1078,7 +1078,8 @@ void Qt5Frame::deregisterDropTarget(Qt5DropTarget const* pDropTarget) m_pDropTarget = nullptr; } -void Qt5Frame::draggingStarted(const int x, const int y, const QMimeData* pQMimeData) +void Qt5Frame::draggingStarted(const int x, const int y, Qt::DropActions eActions, + const QMimeData* pQMimeData) { assert(m_pDropTarget); @@ -1087,8 +1088,8 @@ void Qt5Frame::draggingStarted(const int x, const int y, const QMimeData* pQMime aEvent.Context = static_cast<css::datatransfer::dnd::XDropTargetDragContext*>(m_pDropTarget); aEvent.LocationX = x; aEvent.LocationY = y; - aEvent.DropAction = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; - aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; + aEvent.DropAction = getPreferredDropAction(eActions); + aEvent.SourceActions = toVclDropActions(eActions); css::uno::Reference<css::datatransfer::XTransferable> xTransferable; if (pQMimeData) diff --git a/vcl/qt5/Qt5Tools.cxx b/vcl/qt5/Qt5Tools.cxx index 54ac3f99e26f..94bb03d1797f 100644 --- a/vcl/qt5/Qt5Tools.cxx +++ b/vcl/qt5/Qt5Tools.cxx @@ -51,4 +51,42 @@ sal_uInt16 GetMouseModCode(Qt::MouseButtons eButtons) return nCode; } +Qt::DropActions toQtDropActions(sal_Int8 dragOperation) +{ + Qt::DropActions eRet = Qt::IgnoreAction; + if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_COPY) + eRet |= Qt::CopyAction; + if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_MOVE) + eRet |= Qt::MoveAction; + if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_LINK) + eRet |= Qt::LinkAction; + return eRet; +} + +sal_Int8 toVclDropActions(Qt::DropActions dragOperation) +{ + sal_Int8 nRet(0); + if (dragOperation & Qt::CopyAction) + nRet |= css::datatransfer::dnd::DNDConstants::ACTION_COPY; + if (dragOperation & Qt::MoveAction) + nRet |= css::datatransfer::dnd::DNDConstants::ACTION_MOVE; + if (dragOperation & Qt::LinkAction) + nRet |= css::datatransfer::dnd::DNDConstants::ACTION_LINK; + return nRet; +} + +Qt::DropAction getPreferredDropAction(sal_Int8 dragOperation) +{ + Qt::DropAction eAct = Qt::IgnoreAction; + + if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_MOVE) + eAct = Qt::MoveAction; + else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_COPY) + eAct = Qt::CopyAction; + else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_LINK) + eAct = Qt::LinkAction; + + return eAct; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index 6d44262b38e8..4335a2bcff76 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -188,7 +188,7 @@ void Qt5Widget::wheelEvent(QWheelEvent* pEvent) pEvent->accept(); } -void Qt5Widget::startDrag() +void Qt5Widget::startDrag(sal_Int8 nSourceActions) { // internal drag source QMimeData* mimeData = new QMimeData; @@ -196,7 +196,7 @@ void Qt5Widget::startDrag() QDrag* drag = new QDrag(this); drag->setMimeData(mimeData); - drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::MoveAction); + drag->exec(toQtDropActions(nSourceActions), Qt::MoveAction); } void Qt5Widget::dragEnterEvent(QDragEnterEvent* event) @@ -211,7 +211,7 @@ void Qt5Widget::dragMoveEvent(QDragMoveEvent* event) { QPoint point = event->pos(); - m_pFrame->draggingStarted(point.x(), point.y(), event->mimeData()); + m_pFrame->draggingStarted(point.x(), point.y(), event->possibleActions(), event->mimeData()); QWidget::dragMoveEvent(event); } |