From 77e57387ac7d4f6187867059797a1d6587351ddb Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Thu, 23 Aug 2012 20:27:11 +0200 Subject: OSX: Drag and Drop QMimeData. When dragging and dropping within the same application, the QDropEvent should contain exactly the same instance of QMimeData as it was set to QDrag. This solves the problem in https://bugreports.qt-project.org/browse/QTBUG-26953 Change-Id: I3bc4da845ff4293c509343c1c8c62fc331416ec0 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/cocoa/qnsview.mm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 72b948912a..9b293a7889 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1047,12 +1047,19 @@ static QTouchDevice *touchDevice = 0; NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil]; QPoint qt_windowPoint(windowPoint.x, windowPoint.y); Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]); - QCocoaDropData mimeData([sender draggingPasteboard]); // update these so selecting move/copy/link works QGuiApplicationPrivate::modifier_buttons = [self convertKeyModifiers: [[NSApp currentEvent] modifierFlags]]; - QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_window, &mimeData, qt_windowPoint, qtAllowed); + QPlatformDragQtResponse response(false, Qt::IgnoreAction, QRect()); + if ([sender draggingSource] != nil) { + QCocoaDrag* nativeDrag = static_cast(QGuiApplicationPrivate::platformIntegration()->drag()); + response = QWindowSystemInterface::handleDrag(m_window, nativeDrag->platformDropData(), qt_windowPoint, qtAllowed); + } else { + QCocoaDropData mimeData([sender draggingPasteboard]); + response = QWindowSystemInterface::handleDrag(m_window, &mimeData, qt_windowPoint, qtAllowed); + } + return qt_mac_mapDropAction(response.acceptedAction()); } @@ -1071,9 +1078,15 @@ static QTouchDevice *touchDevice = 0; NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil]; QPoint qt_windowPoint(windowPoint.x, windowPoint.y); Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]); - QCocoaDropData mimeData([sender draggingPasteboard]); - QPlatformDropQtResponse response = QWindowSystemInterface::handleDrop(m_window, &mimeData, qt_windowPoint, qtAllowed); + QPlatformDropQtResponse response(false, Qt::IgnoreAction); + if ([sender draggingSource] != nil) { + QCocoaDrag* nativeDrag = static_cast(QGuiApplicationPrivate::platformIntegration()->drag()); + response = QWindowSystemInterface::handleDrop(m_window, nativeDrag->platformDropData(), qt_windowPoint, qtAllowed); + } else { + QCocoaDropData mimeData([sender draggingPasteboard]); + response = QWindowSystemInterface::handleDrop(m_window, &mimeData, qt_windowPoint, qtAllowed); + } return response.isAccepted(); } -- cgit v1.2.3