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