Implement dragging into media table
This commit is contained in:
parent
ec7bb0a476
commit
b1a1104361
|
@ -17,7 +17,7 @@
|
|||
NSFileWrapper * mediaWrapper;
|
||||
}
|
||||
|
||||
- (void)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date;
|
||||
- (MAMedia *)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date;
|
||||
- (MAAnno *)addAnnotationForMedia:(MAMedia *)media location:(QTTime)location;
|
||||
- (MATagDescription *)tagDescriptionForName:(NSString *)name;
|
||||
- (MATagDescription *)tagDescriptionForName:(NSString *)name notes:(NSString *)notes;
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#pragma mark Media management
|
||||
|
||||
- (void)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date
|
||||
- (MAMedia *)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date
|
||||
{
|
||||
NSString * path = [url path];
|
||||
NSNumber * size;
|
||||
|
@ -71,6 +71,8 @@
|
|||
}
|
||||
media.date = fileDate;
|
||||
media.media = path;
|
||||
|
||||
return media;
|
||||
}
|
||||
|
||||
#pragma mark Annotation management
|
||||
|
|
|
@ -41,7 +41,10 @@
|
|||
|
||||
- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard
|
||||
{
|
||||
if (![contents count] || [[contents objectAtIndex:0] class] != [MAMedia class])
|
||||
return [NSArray arrayWithObjects:kMADragType, kUTTypeUTF8PlainText, nil];
|
||||
else
|
||||
return [NSArray arrayWithObjects:kMADragType, NSFilenamesPboardType, nil];
|
||||
}
|
||||
|
||||
- (NSPasteboardWritingOptions)writingOptionsForType:(NSString *)type pasteboard:(NSPasteboard *)pasteboard
|
||||
|
@ -58,6 +61,11 @@
|
|||
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;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
@ -79,7 +87,8 @@
|
|||
|
||||
- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
|
||||
{
|
||||
NSArray * objects = [[annotationController arrangedObjects] objectsAtIndexes:rowIndexes];
|
||||
NSArrayController * controller = tableView==annotationTable ? annotationController : mediaController;
|
||||
NSArray * objects = [[controller arrangedObjects] objectsAtIndexes:rowIndexes];
|
||||
[pboard clearContents];
|
||||
[pboard writeObjects:[NSArray arrayWithObject:[MAPasteboardData pasteboardDataWithArray:objects]]];
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#import <CoreData/CoreData.h>
|
||||
#import <QTKit/QTKit.h>
|
||||
|
||||
@class MAAnno, MAFolder;
|
||||
@class MAAnno, MADocument;
|
||||
|
||||
@interface MAMedia : NSManagedObject {
|
||||
@private
|
||||
|
@ -23,6 +23,8 @@
|
|||
@property (nonatomic, retain) NSSet *annotations;
|
||||
@property (nonatomic) int64_t size;
|
||||
|
||||
- (MAMedia *)copyToDocument:(MADocument *)doc withMedia:(MAMedia *)media;
|
||||
|
||||
@end
|
||||
|
||||
@interface MAMedia (CoreDataGeneratedAccessors)
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
//
|
||||
|
||||
#import "MAMedia.h"
|
||||
#import "MAAnno.h"
|
||||
#import "MADocument.h"
|
||||
|
||||
@implementation MAMedia
|
||||
@dynamic media;
|
||||
|
@ -16,4 +18,15 @@
|
|||
@dynamic annotations;
|
||||
@dynamic size;
|
||||
|
||||
- (MAMedia *)copyToDocument:(MADocument *)doc withMedia:(MAMedia *)m
|
||||
{
|
||||
MAMedia * media = [doc addMediaURL:[NSURL fileURLWithPath:self.media]
|
||||
name:self.name
|
||||
date:[NSDate dateWithTimeIntervalSinceReferenceDate:self.date]];
|
||||
media.notes = self.notes;
|
||||
for (MAAnno * anno in self.annotations)
|
||||
[media addAnnotationsObject:[anno copyToDocument:doc withMedia:media]];
|
||||
return media;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue
Block a user