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

New commits:
commit f67e9aeeb1bd6fe82e0c4e851017962c74723213
Author:     Katarina Behrens <katarina.behr...@cib.de>
AuthorDate: Mon Dec 3 16:40:27 2018 +0100
Commit:     Katarina Behrens <katarina.behr...@cib.de>
CommitDate: Tue Dec 4 09:56:25 2018 +0100

    tdf#120775: Implement DnD between 2 SalFrames
    
    still only internal DnD (between multiple frames within 1 LibO
    instance) is supported
    
    Change-Id: I151162ee1075c8b2d71520aae950fc7214d752b7
    Reviewed-on: https://gerrit.libreoffice.org/64477
    Tested-by: Jenkins
    Reviewed-by: Katarina Behrens <katarina.behr...@cib.de>

diff --git a/vcl/inc/qt5/Qt5DragAndDrop.hxx b/vcl/inc/qt5/Qt5DragAndDrop.hxx
index dc5b52678d0a..f5ffac3bb21e 100644
--- a/vcl/inc/qt5/Qt5DragAndDrop.hxx
+++ b/vcl/inc/qt5/Qt5DragAndDrop.hxx
@@ -58,6 +58,9 @@ public:
 
     void dragFailed();
     void fire_dragEnd(sal_Int8 nAction);
+
+    static Qt5DragSource* m_ActiveDragSource;
+
     css::uno::Reference<css::datatransfer::XTransferable> const& 
GetTransferable() const
     {
         return m_xTrans;
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 9d4d535d2e90..9f14d44fd5ef 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -56,6 +56,8 @@ class Qt5Widget : public QWidget
     virtual void wheelEvent(QWheelEvent*) override;
     virtual void closeEvent(QCloseEvent*) override;
 
+    const QString m_InternalMimeType = "application/x-libreoffice-dnditem";
+
 public:
     Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags());
     Qt5Frame* m_pFrame;
diff --git a/vcl/qt5/Qt5DragAndDrop.cxx b/vcl/qt5/Qt5DragAndDrop.cxx
index 280763812b72..092c2b2e10a6 100644
--- a/vcl/qt5/Qt5DragAndDrop.cxx
+++ b/vcl/qt5/Qt5DragAndDrop.cxx
@@ -67,6 +67,7 @@ void Qt5DragSource::startDrag(
     if (m_pFrame)
     {
         Qt5Widget* qw = static_cast<Qt5Widget*>(m_pFrame->GetQWidget());
+        m_ActiveDragSource = this;
         qw->startDrag();
     }
     else
@@ -97,6 +98,7 @@ void Qt5DragSource::fire_dragEnd(sal_Int8 nAction)
         m_xListener.clear();
         xListener->dragDropEnd(aEv);
     }
+    m_ActiveDragSource = nullptr;
 }
 
 OUString SAL_CALL Qt5DragSource::getImplementationName()
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 9304760a47c0..3ab8ead48f50 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -1014,6 +1014,9 @@ void Qt5Frame::SetApplicationID(const OUString&)
 }
 
 // Drag'n'drop foo
+
+Qt5DragSource* Qt5DragSource::m_ActiveDragSource;
+
 void Qt5Frame::registerDragSource(Qt5DragSource* pDragSource)
 {
     assert(!m_pDragSource);
@@ -1053,7 +1056,7 @@ void Qt5Frame::draggingStarted(const int x, const int y)
     aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_MOVE;
 
     css::uno::Reference<css::datatransfer::XTransferable> xTransferable;
-    xTransferable = m_pDragSource->GetTransferable();
+    xTransferable = Qt5DragSource::m_ActiveDragSource->GetTransferable();
 
     if (!m_bInDrag && xTransferable.is())
     {
@@ -1082,7 +1085,7 @@ void Qt5Frame::dropping(const int x, const int y)
     aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_MOVE;
 
     css::uno::Reference<css::datatransfer::XTransferable> xTransferable;
-    xTransferable = m_pDragSource->GetTransferable();
+    xTransferable = Qt5DragSource::m_ActiveDragSource->GetTransferable();
     aEvent.Transferable = xTransferable;
 
     m_pDropTarget->fire_drop(aEvent);
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index ea0258589ff7..2d108fa21cd5 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -187,8 +187,9 @@ void Qt5Widget::wheelEvent(QWheelEvent* pEvent)
 
 void Qt5Widget::startDrag()
 {
+    // internal drag source
     QMimeData* mimeData = new QMimeData;
-    mimeData->setData("application/x-libreoffice-dnditem", nullptr);
+    mimeData->setData(m_InternalMimeType, nullptr);
 
     QDrag* drag = new QDrag(this);
     drag->setMimeData(mimeData);
@@ -197,8 +198,9 @@ void Qt5Widget::startDrag()
 
 void Qt5Widget::dragEnterEvent(QDragEnterEvent* event)
 {
-    if (event->source() == this)
+    if (event->mimeData()->hasFormat(m_InternalMimeType))
         event->accept();
+    // else FIXME: external drag source
 }
 
 void Qt5Widget::dragMoveEvent(QDragMoveEvent* event)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to