summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2018-10-18 13:13:29 +0200
committerKatarina Behrens <Katarina.Behrens@cib.de>2018-10-19 14:03:56 +0200
commita261016b9817443878396c745a72e8d2eb644ded (patch)
tree0adf33c82d827fdd9b935f0fe69b4c916d8d6d9a
parentc324644aa098939d651fb0cf7e8e1a0975350ad0 (diff)
Make repeated drag'n'drop possible
Change-Id: If87ceeb8ddc4b2aada8ea0c963385a291622fef6 Reviewed-on: https://gerrit.libreoffice.org/61932 Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de> Tested-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r--vcl/inc/qt5/Qt5DragAndDrop.hxx2
-rw-r--r--vcl/qt5/Qt5DragAndDrop.cxx26
-rw-r--r--vcl/qt5/Qt5Frame.cxx8
3 files changed, 36 insertions, 0 deletions
diff --git a/vcl/inc/qt5/Qt5DragAndDrop.hxx b/vcl/inc/qt5/Qt5DragAndDrop.hxx
index d1116ddfee96..568b64236868 100644
--- a/vcl/inc/qt5/Qt5DragAndDrop.hxx
+++ b/vcl/inc/qt5/Qt5DragAndDrop.hxx
@@ -57,6 +57,7 @@ public:
css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
void dragFailed();
+ void fire_dragEnd();
css::uno::Reference<css::datatransfer::XTransferable> const& GetTransferable() const
{
return m_xTrans;
@@ -108,6 +109,7 @@ public:
css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde);
+ void fire_dragOver(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde);
void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde);
};
diff --git a/vcl/qt5/Qt5DragAndDrop.cxx b/vcl/qt5/Qt5DragAndDrop.cxx
index 569c24f2bdac..6a68273e23be 100644
--- a/vcl/qt5/Qt5DragAndDrop.cxx
+++ b/vcl/qt5/Qt5DragAndDrop.cxx
@@ -86,6 +86,19 @@ void Qt5DragSource::dragFailed()
}
}
+void Qt5DragSource::fire_dragEnd()
+{
+ if (m_xListener.is())
+ {
+ datatransfer::dnd::DragSourceDropEvent aEv;
+ aEv.DropAction = datatransfer::dnd::DNDConstants::ACTION_MOVE;
+ aEv.DropSuccess = true; // FIXME: what if drop didn't work out?
+ auto xListener = m_xListener;
+ m_xListener.clear();
+ xListener->dragDropEnd(aEv);
+ }
+}
+
OUString SAL_CALL Qt5DragSource::getImplementationName()
{
return OUString("com.sun.star.datatransfer.dnd.VclQt5DragSource");
@@ -201,6 +214,19 @@ void Qt5DropTarget::fire_dragEnter(const css::datatransfer::dnd::DropTargetDragE
}
}
+void Qt5DropTarget::fire_dragOver(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde)
+{
+ osl::ClearableGuard<::osl::Mutex> aGuard(m_aMutex);
+ std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners(
+ m_aListeners);
+ aGuard.clear();
+
+ for (auto const& listener : aListeners)
+ {
+ listener->dragOver(dtde);
+ }
+}
+
void Qt5DropTarget::fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde)
{
osl::ClearableGuard<osl::Mutex> aGuard(m_aMutex);
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index a58e7b18d4b4..66272a9f34f6 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -899,6 +899,8 @@ void Qt5Frame::draggingStarted(const int x, const int y)
m_pDropTarget->fire_dragEnter(aEvent);
m_bInDrag = true;
}
+ else
+ m_pDropTarget->fire_dragOver(aEvent);
}
void Qt5Frame::dropping(const int x, const int y)
@@ -918,6 +920,12 @@ void Qt5Frame::dropping(const int x, const int y)
aEvent.Transferable = xTransferable;
m_pDropTarget->fire_drop(aEvent);
+ m_bInDrag = false;
+
+ if (m_pDragSource)
+ {
+ m_pDragSource->fire_dragEnd();
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */