diff --git a/Medianno/MAColorForURL.mm b/Medianno/MAColorForURL.mm index bb8fbf2..a145718 100644 --- a/Medianno/MAColorForURL.mm +++ b/Medianno/MAColorForURL.mm @@ -8,6 +8,8 @@ #import "MAColorForURL.h" +#import + @implementation MAColorForURL + (Class)transformedValueClass @@ -22,7 +24,8 @@ - (id)transformedValue:(id)value { - if ([[NSFileManager defaultManager] fileExistsAtPath:value]) + NSURL * mediaURL = [NSURL URLWithString:value]; + if ([QTMovie canInitWithURL:mediaURL]) return [NSColor blackColor]; else return [NSColor redColor]; diff --git a/Medianno/MADocWindow.mm b/Medianno/MADocWindow.mm index 1c612ad..992fdf5 100644 --- a/Medianno/MADocWindow.mm +++ b/Medianno/MADocWindow.mm @@ -94,8 +94,9 @@ static const char * kMADocWindowObserver = "MADocWindowObserver"; // Current movie changed // if (MAMedia * currentMedia = [self currentMedia]) { - currentMovie = [[QTMovie alloc] initWithFile:[currentMedia media] error:nil]; - currentMovieTitle = [currentMedia name]; + NSURL * mediaURL = [NSURL URLWithString:[currentMedia media]]; + currentMovie = [[QTMovie alloc] initWithURL:mediaURL error:nil]; + currentMovieTitle = [currentMedia name]; } else { currentMovie = nil; currentMovieTitle = @""; diff --git a/Medianno/MADocument.mm b/Medianno/MADocument.mm index 2598c77..f9f7e9b 100644 --- a/Medianno/MADocument.mm +++ b/Medianno/MADocument.mm @@ -42,7 +42,7 @@ - (MAMedia *)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date { - NSString * path = [url path]; + NSString * path = [url absoluteString]; NSNumber * size; [url getResourceValue:&size forKey:NSURLFileSizeKey error:nil]; int64_t fileSize = [size longLongValue]; diff --git a/Medianno/MADragging.mm b/Medianno/MADragging.mm index 4ecfc11..1b9cb6f 100644 --- a/Medianno/MADragging.mm +++ b/Medianno/MADragging.mm @@ -41,10 +41,13 @@ - (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard { - if (![contents count] || [[contents objectAtIndex:0] class] != [MAMedia class]) + MAMedia * media; + if (![contents count] || [(media = [contents objectAtIndex:0]) class] != [MAMedia class]) return [NSArray arrayWithObjects:kMADragType, kUTTypeUTF8PlainText, nil]; + else if ([[NSURL URLWithString:[media media]] isFileURL]) + return [NSArray arrayWithObjects:kMADragType, kUTTypeFileURL, nil]; else - return [NSArray arrayWithObjects:kMADragType, NSFilenamesPboardType, nil]; + return [NSArray arrayWithObjects:kMADragType, kUTTypeURL, nil]; } - (NSPasteboardWritingOptions)writingOptionsForType:(NSString *)type pasteboard:(NSPasteboard *)pasteboard @@ -61,11 +64,8 @@ for (id obj in contents) [stringBuffer appendFormat:@"%@\n", [obj exportText]]; return stringBuffer; - } else if ([type isEqual:NSFilenamesPboardType]) { - NSMutableArray * urls = [NSMutableArray array]; - for (MAMedia * obj in contents) - [urls addObject:[NSURL fileURLWithPath:[obj media]]]; - return urls; + } else if ([type isEqual:(NSString *)kUTTypeURL] || [type isEqual:(NSString *)kUTTypeFileURL]) { + return [contents count]>0 ? [[contents objectAtIndex:0] media] : nil; } return nil; } @@ -76,8 +76,9 @@ - (void)registerOurDragTypes { + [mediaTable setDraggingSourceOperationMask:NSDragOperationCopy forLocal:NO]; [mediaTable registerForDraggedTypes: - [NSArray arrayWithObjects:kMADragType,NSFilenamesPboardType, nil]]; + [NSArray arrayWithObjects:kMADragType, NSFilenamesPboardType, kUTTypeURL, nil]]; [annotationTable setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO]; [annotationTable setVerticalMotionCanBeginDrag:NO]; @@ -110,7 +111,8 @@ if (tableView == [info draggingSource]) return NSDragOperationNone; NSPasteboard * pb = [info draggingPasteboard]; - if (id drag = [pb propertyListForType:kMADragType]) { + id drag; + if ((drag = [pb propertyListForType:kMADragType])) { // // We don't allow media drops in annotation table // @@ -128,7 +130,17 @@ } } return NSDragOperationCopy; - } + } else if (tableView == mediaTable) { + if ((drag = [pb propertyListForType:NSFilenamesPboardType])) { + [tableView setDropRow:row dropOperation:NSTableViewDropAbove]; + return NSDragOperationLink; + } else if ((drag = [pb stringForType:(NSString *)kUTTypeURL]) + || (drag = [pb stringForType:(NSString *)kUTTypeFileURL]) + ) { + [tableView setDropRow:row dropOperation:NSTableViewDropAbove]; + return NSDragOperationLink; + } + } return NSDragOperationNone; } @@ -145,10 +157,21 @@ if (row >= 0 && row < [allMedia count]) media = [allMedia objectAtIndex:row]; } - - if (id drag = [pb propertyListForType:kMADragType]) + + id drag; + if ((drag = [pb propertyListForType:kMADragType])) { for (id obj in (NSArray *)[drag longValue]) [obj copyToDocument:doc withMedia:media]; + } else if ((drag = [pb propertyListForType:NSFilenamesPboardType])) { + NSMutableArray * urls = [NSMutableArray array]; + for (NSString * path in drag) + [urls addObject:[NSURL fileURLWithPath:path]]; + [self addMedia:urls]; + } else if ((drag = [pb stringForType:(NSString *)kUTTypeURL]) + || (drag = [pb stringForType:(NSString *)kUTTypeFileURL]) + ) { + [self addMedia:[NSArray arrayWithObject:[NSURL URLWithString:drag]]]; + } return YES; } diff --git a/Medianno/MAMedia.mm b/Medianno/MAMedia.mm index 9d3e5c3..37d8197 100644 --- a/Medianno/MAMedia.mm +++ b/Medianno/MAMedia.mm @@ -20,7 +20,7 @@ - (MAMedia *)copyToDocument:(MADocument *)doc withMedia:(MAMedia *)m { - MAMedia * media = [doc addMediaURL:[NSURL fileURLWithPath:self.media] + MAMedia * media = [doc addMediaURL:[NSURL URLWithString:self.media] name:self.name date:[NSDate dateWithTimeIntervalSinceReferenceDate:self.date]]; media.notes = self.notes;