summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qcocoaview_mac.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel/qcocoaview_mac.mm')
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 60ac062..1cbc960 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -199,6 +199,7 @@ extern "C" {
composingText = new QString();
composing = false;
sendKeyEvents = true;
+ currentCustomTypes = 0;
[self setHidden:YES];
return self;
}
@@ -213,10 +214,16 @@ extern "C" {
object:self];
}
--(void)registerDragTypes:(bool)accept
+-(void)registerDragTypes
{
QMacCocoaAutoReleasePool pool;
- if (accept) {
+ // Calling registerForDraggedTypes is slow, so only do it once for each widget
+ // or when the custom types change.
+ const QStringList& customTypes = qEnabledDraggedTypes();
+ if (currentCustomTypes == 0 || *currentCustomTypes != customTypes) {
+ if (currentCustomTypes == 0)
+ currentCustomTypes = new QStringList();
+ *currentCustomTypes = customTypes;
const NSString* mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName";
NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType,
NSFilenamesPboardType, NSStringPboardType,
@@ -228,13 +235,10 @@ extern "C" {
NSFilesPromisePboardType, NSInkTextPboardType,
NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil];
// Add custom types supported by the application.
- const QStringList& customTypes = qEnabledDraggedTypes();
for (int i = 0; i < customTypes.size(); i++) {
[supportedTypes addObject:reinterpret_cast<const NSString *>(QCFString::toCFStringRef(customTypes[i]))];
}
[self registerForDraggedTypes:supportedTypes];
- } else {
- [self unregisterDraggedTypes];
}
}
@@ -283,6 +287,8 @@ extern "C" {
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
+ if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false)
+ return NSDragOperationNone;
[self addDropData:sender];
QMimeData *mimeData = dropData;
if (QDragManager::self()->source())
@@ -416,6 +422,8 @@ extern "C" {
{
delete composingText;
[[NSNotificationCenter defaultCenter] removeObserver:self];
+ delete currentCustomTypes;
+ [self unregisterDraggedTypes];
[super dealloc];
}