summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2019-02-28 15:03:12 +0100
committerKatarina Behrens <Katarina.Behrens@cib.de>2019-03-05 12:18:11 +0100
commitc3751ed3c98e8ed40100a8073b97c83d9ded0803 (patch)
tree4760d1f71ecab3f06a4f8dde4f09e2991de5b7be
parent98b8fa299f7d7e68d42e322faf64cb0cd9923d95 (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>
-rw-r--r--vcl/inc/qt5/Qt5Frame.hxx3
-rw-r--r--vcl/inc/qt5/Qt5Tools.hxx5
-rw-r--r--vcl/inc/qt5/Qt5Widget.hxx2
-rw-r--r--vcl/qt5/Qt5DragAndDrop.cxx4
-rw-r--r--vcl/qt5/Qt5Frame.cxx7
-rw-r--r--vcl/qt5/Qt5Tools.cxx38
-rw-r--r--vcl/qt5/Qt5Widget.cxx6
7 files changed, 55 insertions, 10 deletions
diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 396e6122b9c3..274a6caac81b 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -139,7 +139,8 @@ public:
virtual void deregisterDragSource(Qt5DragSource const* pDragSource);
virtual void registerDropTarget(Qt5DropTarget* pDropTarget);
virtual void deregisterDropTarget(Qt5DropTarget const* pDropTarget);
- void draggingStarted(const int x, const int y, const QMimeData* pQMimeData);
+ void draggingStarted(const int x, const int y, Qt::DropActions eActions,
+ const QMimeData* pQMimeData);
void dropping(const int x, const int y, const QMimeData* pQMimeData);
virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle) override;
diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx
index 18b48690377b..8863e2496687 100644
--- a/vcl/inc/qt5/Qt5Tools.hxx
+++ b/vcl/inc/qt5/Qt5Tools.hxx
@@ -30,6 +30,7 @@
#include <tools/gen.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
#include <memory>
@@ -64,6 +65,10 @@ inline QColor toQColor(const Color& rColor)
255 - rColor.GetTransparency());
}
+Qt::DropActions toQtDropActions(sal_Int8 dragOperation);
+sal_Int8 toVclDropActions(Qt::DropActions dragOperation);
+Qt::DropAction getPreferredDropAction(sal_Int8 dragOperation);
+
inline QList<int> toQList(const css::uno::Sequence<sal_Int32>& aSequence)
{
QList<int> aList;
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 3e5332bd77dc..d96afa64aeb0 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -72,7 +72,7 @@ public slots:
public:
Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
Qt5Frame* m_pFrame;
- void startDrag();
+ void startDrag(sal_Int8 nSourceActions);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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 81d47c98d39b..d6f0993d8bd9 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -1107,7 +1107,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);
@@ -1116,8 +1117,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->hasFormat(sInternalMimeType))
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 ca2c3ada6a3c..c04564a75e06 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -189,7 +189,7 @@ void Qt5Widget::wheelEvent(QWheelEvent* pEvent)
pEvent->accept();
}
-void Qt5Widget::startDrag()
+void Qt5Widget::startDrag(sal_Int8 nSourceActions)
{
// internal drag source
QMimeData* mimeData = new QMimeData;
@@ -197,7 +197,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)
@@ -212,7 +212,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);
}