[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - vcl/inc vcl/qt5

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Dec 14 13:29:43 UTC 2018


 vcl/inc/qt5/Qt5DragAndDrop.hxx |    6 +++++-
 vcl/qt5/Qt5DragAndDrop.cxx     |   34 ++++++++++++++++++++++++++++------
 vcl/qt5/Qt5Frame.cxx           |    7 ++++---
 vcl/qt5/Qt5Widget.cxx          |    3 ---
 4 files changed, 37 insertions(+), 13 deletions(-)

New commits:
commit 829c1d83b530224ee6003ee49975904f2cb46e24
Author:     Katarina Behrens <Katarina.Behrens at cib.de>
AuthorDate: Fri Nov 30 10:32:11 2018 +0100
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Fri Dec 14 14:29:20 2018 +0100

    tdf#120781: Proposed DnD operation is not always 'move'
    
    sometimes drop target doesn't accept drops, dragged objects must not
    disappear in such case
    
    Change-Id: I5de3c6c4afc305ea98bd15c7ff55e218364e9475
    Reviewed-on: https://gerrit.libreoffice.org/64338
    Tested-by: Jenkins
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
    (cherry picked from commit 3ac46abde192324fc7e1cbf3f22b7280f15e77df)
    Reviewed-on: https://gerrit.libreoffice.org/65151
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/vcl/inc/qt5/Qt5DragAndDrop.hxx b/vcl/inc/qt5/Qt5DragAndDrop.hxx
index 568b64236868..dc5b52678d0a 100644
--- a/vcl/inc/qt5/Qt5DragAndDrop.hxx
+++ b/vcl/inc/qt5/Qt5DragAndDrop.hxx
@@ -57,7 +57,7 @@ public:
     css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
 
     void dragFailed();
-    void fire_dragEnd();
+    void fire_dragEnd(sal_Int8 nAction);
     css::uno::Reference<css::datatransfer::XTransferable> const& GetTransferable() const
     {
         return m_xTrans;
@@ -72,6 +72,8 @@ class Qt5DropTarget
 {
     osl::Mutex m_aMutex;
     Qt5Frame* m_pFrame;
+    sal_Int8 mnDragAction;
+    sal_Int8 mnDropAction;
     bool m_bActive;
     sal_Int8 m_nDefaultActions;
     std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> m_aListeners;
@@ -111,6 +113,8 @@ public:
     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);
+
+    sal_Int8 proposedDragAction() const { return mnDragAction; }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5DragAndDrop.cxx b/vcl/qt5/Qt5DragAndDrop.cxx
index 6a68273e23be..280763812b72 100644
--- a/vcl/qt5/Qt5DragAndDrop.cxx
+++ b/vcl/qt5/Qt5DragAndDrop.cxx
@@ -86,12 +86,12 @@ void Qt5DragSource::dragFailed()
     }
 }
 
-void Qt5DragSource::fire_dragEnd()
+void Qt5DragSource::fire_dragEnd(sal_Int8 nAction)
 {
     if (m_xListener.is())
     {
         datatransfer::dnd::DragSourceDropEvent aEv;
-        aEv.DropAction = datatransfer::dnd::DNDConstants::ACTION_MOVE;
+        aEv.DropAction = nAction;
         aEv.DropSuccess = true; // FIXME: what if drop didn't work out?
         auto xListener = m_xListener;
         m_xListener.clear();
@@ -168,6 +168,9 @@ void Qt5DropTarget::initialize(const Sequence<Any>& rArguments)
                                static_cast<OWeakObject*>(this));
     }
 
+    mnDragAction = datatransfer::dnd::DNDConstants::ACTION_NONE;
+    mnDropAction = datatransfer::dnd::DNDConstants::ACTION_NONE;
+
     m_pFrame = reinterpret_cast<Qt5Frame*>(nFrame);
     m_pFrame->registerDropTarget(this);
     m_bActive = true;
@@ -240,11 +243,30 @@ void Qt5DropTarget::fire_drop(const css::datatransfer::dnd::DropTargetDropEvent&
     }
 }
 
-void Qt5DropTarget::acceptDrag(sal_Int8 /*dragOperation*/) { return; }
-void Qt5DropTarget::rejectDrag() { return; }
+void Qt5DropTarget::acceptDrag(sal_Int8 dragOperation)
+{
+    mnDragAction = dragOperation;
+    return;
+}
+
+void Qt5DropTarget::rejectDrag()
+{
+    mnDragAction = 0;
+    return;
+}
+
+void Qt5DropTarget::acceptDrop(sal_Int8 dropOperation)
+{
+    mnDropAction = dropOperation;
+    return;
+}
+
+void Qt5DropTarget::rejectDrop()
+{
+    mnDropAction = 0;
+    return;
+}
 
-void Qt5DropTarget::acceptDrop(sal_Int8 /*dropOperation*/) { return; }
-void Qt5DropTarget::rejectDrop() { return; }
 void Qt5DropTarget::dropComplete(sal_Bool /*success*/) { return; }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index ad043ebd3ab8..9304760a47c0 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -1049,7 +1049,7 @@ void Qt5Frame::draggingStarted(const int x, const int y)
     aEvent.Context = static_cast<css::datatransfer::dnd::XDropTargetDragContext*>(m_pDropTarget);
     aEvent.LocationX = x;
     aEvent.LocationY = y;
-    aEvent.DropAction = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; //FIXME
+    aEvent.DropAction = css::datatransfer::dnd::DNDConstants::ACTION_MOVE;
     aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_MOVE;
 
     css::uno::Reference<css::datatransfer::XTransferable> xTransferable;
@@ -1077,7 +1077,8 @@ void Qt5Frame::dropping(const int x, const int y)
     aEvent.Context = static_cast<css::datatransfer::dnd::XDropTargetDropContext*>(m_pDropTarget);
     aEvent.LocationX = x;
     aEvent.LocationY = y;
-    aEvent.DropAction = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; //FIXME
+    aEvent.DropAction = m_pDropTarget->proposedDragAction()
+                        | css::datatransfer::dnd::DNDConstants::ACTION_DEFAULT;
     aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_MOVE;
 
     css::uno::Reference<css::datatransfer::XTransferable> xTransferable;
@@ -1089,7 +1090,7 @@ void Qt5Frame::dropping(const int x, const int y)
 
     if (m_pDragSource)
     {
-        m_pDragSource->fire_dragEnd();
+        m_pDragSource->fire_dragEnd(m_pDropTarget->proposedDragAction());
     }
 }
 
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 1c032e2a75ce..ea0258589ff7 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -197,7 +197,6 @@ void Qt5Widget::startDrag()
 
 void Qt5Widget::dragEnterEvent(QDragEnterEvent* event)
 {
-    SAL_WARN("vcl.qt5", "dragenterevent");
     if (event->source() == this)
         event->accept();
 }
@@ -205,7 +204,6 @@ void Qt5Widget::dragEnterEvent(QDragEnterEvent* event)
 void Qt5Widget::dragMoveEvent(QDragMoveEvent* event)
 {
     QPoint point = event->pos();
-    SAL_WARN("vcl.qt5", "dragmoveevent");
 
     m_pFrame->draggingStarted(point.x(), point.y());
     QWidget::dragMoveEvent(event);
@@ -214,7 +212,6 @@ void Qt5Widget::dragMoveEvent(QDragMoveEvent* event)
 void Qt5Widget::dropEvent(QDropEvent* event)
 {
     QPoint point = event->pos();
-    SAL_WARN("vcl.qt5", "dropevent");
 
     m_pFrame->dropping(point.x(), point.y());
     QWidget::dropEvent(event);


More information about the Libreoffice-commits mailing list