From 272e2720eb89320ae633323c62d70a474dcfa078 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Sat, 13 Aug 2011 01:38:18 +0200 Subject: [PATCH] Display and add annotations --- Medianno/MAAnno.h | 4 + Medianno/MAAnno.mm | 33 ++ Medianno/MADocWindow.h | 4 + Medianno/MADocWindow.mm | 13 +- Medianno/MADocument.h | 4 + Medianno/MADocument.mm | 17 +- Medianno/en.lproj/MADocument.xib | 824 ++++++++++++++++--------------- Medianno/en.lproj/MainMenu.xib | 99 +++- 8 files changed, 586 insertions(+), 412 deletions(-) diff --git a/Medianno/MAAnno.h b/Medianno/MAAnno.h index 0d4d0f5..499809f 100644 --- a/Medianno/MAAnno.h +++ b/Medianno/MAAnno.h @@ -18,6 +18,10 @@ @property (nonatomic, retain) NSString * notes; @property (nonatomic, retain) NSSet *tags; @property (nonatomic, retain) NSManagedObject *media; + +- (NSString *)shortLocation; ++ (NSSet *)keyPathsForValuesAffectingShortLocation; + @end @interface MAAnno (CoreDataGeneratedAccessors) diff --git a/Medianno/MAAnno.mm b/Medianno/MAAnno.mm index aa292f5..41bffbc 100644 --- a/Medianno/MAAnno.mm +++ b/Medianno/MAAnno.mm @@ -16,4 +16,37 @@ @dynamic tags; @dynamic media; +- (NSString *)shortLocation +{ + NSString * location = self.location; + NSRange rangeToUse = {0,0}; + // + // Trim leading zeros, up to a point + // + while (rangeToUse.location < 6) { + switch ([location characterAtIndex:rangeToUse.location]) { + case '0': + case ':': + ++rangeToUse.location; + continue; + } + break; + } + // + // Trim fractions of seconds + // + for (rangeToUse.length = [location length]-rangeToUse.location; rangeToUse.length-- > 0; ) + if ([location characterAtIndex:rangeToUse.location+rangeToUse.length] == '.') + break; + if (!rangeToUse.length) + rangeToUse.length = [location length]-rangeToUse.location; + + return [location substringWithRange:rangeToUse]; +} + ++ (NSSet *)keyPathsForValuesAffectingShortLocation +{ + return [NSSet setWithObject:@"location"]; +} + @end diff --git a/Medianno/MADocWindow.h b/Medianno/MADocWindow.h index 5124387..b5e1581 100644 --- a/Medianno/MADocWindow.h +++ b/Medianno/MADocWindow.h @@ -9,9 +9,13 @@ #import @interface MADocWindow : NSWindowController { + IBOutlet NSArrayController* mediaController; + IBOutlet NSArrayController* annotationController; + IBOutlet QTMovieView * movieView; } - (IBAction)addMediaFiles:(id)sender; - (void)addMedia:(NSArray *)urls; +- (IBAction)addAnnotation:(id)sender; @end diff --git a/Medianno/MADocWindow.mm b/Medianno/MADocWindow.mm index 6fac596..31511ac 100644 --- a/Medianno/MADocWindow.mm +++ b/Medianno/MADocWindow.mm @@ -17,9 +17,6 @@ - (id)initWithWindow:(NSWindow *)window { self = [super initWithWindow:window]; - if (self) { - // Initialization code here. - } return self; } @@ -27,8 +24,8 @@ - (void)windowDidLoad { [super windowDidLoad]; - - // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. + [mediaController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]]; + [annotationController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"location" ascending:YES]]]; } #pragma mark Media management @@ -83,4 +80,10 @@ [[[MAAddMediaSheet alloc] init] runWithParentWindow:self media:expandedURLs]; } +- (IBAction)addAnnotation:(id)sender +{ + QTTime location = [[movieView movie] currentTime]; + [[self document] addAnnotationForMedia:[[mediaController selectedObjects] objectAtIndex:0] location:location]; +} + @end diff --git a/Medianno/MADocument.h b/Medianno/MADocument.h index 6ebdd14..522ff6d 100644 --- a/Medianno/MADocument.h +++ b/Medianno/MADocument.h @@ -7,11 +7,15 @@ // #import +#import + +@class MAMedia; @interface MADocument : NSPersistentDocument { NSFileWrapper * mediaWrapper; } - (void)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date copying:(BOOL)copying; +- (void)addAnnotationForMedia:(MAMedia *)media location:(QTTime)location; @end diff --git a/Medianno/MADocument.mm b/Medianno/MADocument.mm index feda324..4214919 100644 --- a/Medianno/MADocument.mm +++ b/Medianno/MADocument.mm @@ -10,6 +10,7 @@ #import "MADocWindow.h" #import "MAFolder.h" #import "MAMedia.h" +#import "MAAnno.h" #pragma mark - #pragma mark MADocument @@ -73,11 +74,23 @@ MAMedia * media = [NSEntityDescription insertNewObjectForEntityForName:@"MAMedia" inManagedObjectContext:moc]; NSString * path = [url path]; media.media = path; - media.date = [date timeIntervalSince1970]; + media.date = [date timeIntervalSinceReferenceDate]; media.name = name; media.notes = @""; media.folder= inbox; - [moc processPendingChanges]; +} + +#pragma mark - +#pragma mark Annotation management + +- (void)addAnnotationForMedia:(MAMedia *)media location:(QTTime)location +{ + NSManagedObjectContext *moc = [self managedObjectContext]; + MAAnno * annotation = [NSEntityDescription insertNewObjectForEntityForName:@"MAAnno" inManagedObjectContext:moc]; + annotation.media = media; + annotation.location = QTStringFromTime(location); + annotation.notes = @""; + [moc processPendingChanges]; } @end diff --git a/Medianno/en.lproj/MADocument.xib b/Medianno/en.lproj/MADocument.xib index 77422de..7dde109 100644 --- a/Medianno/en.lproj/MADocument.xib +++ b/Medianno/en.lproj/MADocument.xib @@ -61,7 +61,7 @@ 15 2 - {{133, 235}, {1279, 809}} + {{133, 235}, {1280, 809}} 1886912512 Window NSWindow @@ -73,39 +73,39 @@ 256 YES - + 274 YES - - + + 292 YES - - + + 2304 YES - - + + 256 {1279, 183} - + - + _NS:1197 YES - - + + 256 {1279, 17} - + - + _NS:1199 - + @@ -115,7 +115,7 @@ YES - + 284.265625 250 500 @@ -128,31 +128,31 @@ 11 3100 - + 3 MC4zMzMzMzI5ODU2AA - + 6 System headerTextColor - + 3 MAA - + 337772096 2048 Text Cell - + LucidaGrande 13 1044 - - + + 6 System controlBackgroundColor @@ -161,19 +161,19 @@ MC42NjY2NjY2NjY3AA - + 6 System controlTextColor - + 3 YES YES - + - + 846.296875 50 5200 @@ -182,24 +182,24 @@ 2048 Notes - - + + - + 337772096 2048 Text Cell - - - - + + + + 3 YES YES - + - + 140 140 140 @@ -208,23 +208,23 @@ 2048 Date - + 6 System headerColor - + 3 MQA - + - + 337772096 -2147481600 Text Cell - - + + YES @@ -247,20 +247,20 @@ yyyy-MM-dd HH:mm NO - - - + + + 3 YES YES - + 3 2 - - + + 6 System gridColor @@ -270,7 +270,7 @@ 17 - -698318848 + -683638784 1 @@ -281,83 +281,82 @@ 1 - {{1, 17}, {1278, 183}} - + {{1, 17}, {1279, 183}} + - + _NS:1195 - - + + 4 - - + + -2147483392 {{224, 17}, {15, 102}} - + - + _NS:1214 - + _doScroller: 37 0.1947367936372757 - - - 256 + + + -2147483392 {{1, 185}, {1278, 15}} - + - + _NS:1216 - YES 1 - + _doScroller: 0.99921813917122748 - - + + 2304 YES - + - {{1, 0}, {1278, 17}} - + {{1, 0}, {1279, 17}} + - + _NS:1200 - - + + 4 - {1280, 201} - + {1281, 201} + - + _NS:1193 - 133810 - - - - + 133682 + + + + QSAAAEEgAABBmAAAQZgAAA - - + + 268 YES - - + + 274 YES - - + + 298 YES @@ -369,45 +368,45 @@ QTMoviePasteboardType - {{0, 581}, {1280, 16}} - + {{0, 581}, {1281, 16}} + - + _NS:46 - + - - + + 310 YES - - + + 2304 YES - - + + 256 - {1359, 564} - + {1279, 564} + - + _NS:1197 YES - - + + 256 - {1359, 17} - + {1279, 17} + - + _NS:1199 - + @@ -417,7 +416,7 @@ YES - + 100 100 100 @@ -426,26 +425,26 @@ 2048 Time - + 3 MC4zMzMzMzI5ODU2AA - + - + 337772096 - 2048 + 67110912 Text Cell - - - - + + + + 3 YES - + - + 550 200 2000 @@ -454,25 +453,25 @@ 2048 Tags - - + + - + 337772096 2048 Text Cell - - - - + + + + 3 YES YES - + - - 700 + + 620 50 3.4028234663852886e+38 @@ -480,30 +479,30 @@ 2048 Notes - - + + - + 337772096 2048 Text Cell - - - - + + + + 3 YES YES - + 3 2 - - + + 17 - -18841600 + -2064384 1 @@ -515,81 +514,80 @@ 1 - {{1, 17}, {1278, 564}} - + {{1, 17}, {1279, 564}} + - + _NS:1195 - - + + 4 - - + + -2147483392 {{224, 17}, {15, 102}} - + - + _NS:1214 - + _doScroller: 0.98210290827740487 - - - 256 - {{1, 566}, {1278, 15}} - + + + -2147483392 + {{1, 566}, {1279, 15}} + _NS:1216 - YES 1 - + _doScroller: - 0.94039735099337751 + 0.99224204809930183 - - + + 2304 YES - + - {{1, 0}, {1278, 17}} - + {{1, 0}, {1279, 17}} + - - - + + + 4 - {{0, -1}, {1280, 582}} - + {{0, -1}, {1281, 582}} + - + _NS:1193 - 133810 - - - - + 133682 + + + + QSAAAEEgAABBmAAAQZgAAA - {1280, 599} - + {1281, 599} + - + _NS:11 - {{0, 211}, {1280, 599}} - + {{0, 211}, {1281, 599}} + - + _NS:9 {0, 0} @@ -601,14 +599,14 @@ 6 System textBackgroundColor - + 3 MCAwLjgwMDAwMDAxMTkAA - + 0 4 0 @@ -616,17 +614,17 @@ - {1280, 810} + {1281, 810} - + 3 - {1279, 809} + {1280, 809} - + {{0, 0}, {2560, 1418}} {94, 108} @@ -636,9 +634,28 @@ NSApplication - + + YES + YES MAMedia + + YES + YES + YES + YES + YES + YES + YES + YES + + + YES + + + YES + + MAFolder YES @@ -646,7 +663,7 @@ 3 valueForKey: - + 1 @@ -672,77 +689,7 @@ 3 valueForKey: - - - YES - - 10 - parent - - - - - 0 - - - - 4 - 0 - NO - 0 - - - - 1 - - - YES - YES - YES - YES - YES - YES - YES - - - YES - - - YES - - MAFolder - - - YES - - - 3 - valueForKey: - - - YES - - 10 - name - - - - - 0 - Inbox - - - 4 - 0 - NO - 0 - - - - - 3 - valueForKey: - + YES @@ -768,7 +715,7 @@ YES - + YES YES @@ -780,6 +727,7 @@ YES YES YES + YES @@ -804,11 +752,11 @@ value: arrangedObjects.name - - + + - - + + value: arrangedObjects.name value arrangedObjects.name @@ -820,11 +768,11 @@ value: arrangedObjects.notes - - + + - - + + value: arrangedObjects.notes value arrangedObjects.notes @@ -836,11 +784,11 @@ value: arrangedObjects.date - - + + - - + + value: arrangedObjects.date value arrangedObjects.date @@ -856,11 +804,11 @@ movie: selection.movie - - + + - - + + movie: selection.movie movie selection.movie @@ -872,11 +820,11 @@ contentSet: selection.contents - - + + - - + + contentSet: selection.contents contentSet selection.contents @@ -892,10 +840,10 @@ managedObjectContext: document.managedObjectContext - + - + managedObjectContext: document.managedObjectContext managedObjectContext @@ -908,11 +856,11 @@ contentSet: selection.annotations - - + + - - + + contentSet: selection.annotations contentSet selection.annotations @@ -925,37 +873,78 @@ 100151 + + + mediaController + + + + 100155 + + + + movieView + + + + 100156 + - value: arrangedObjects.location - - + value: arrangedObjects.shortLocation + + - - - value: arrangedObjects.location + + + value: arrangedObjects.shortLocation value - arrangedObjects.location + arrangedObjects.shortLocation + + YES + + YES + NSConditionallySetsEditable + NSCreatesSortDescriptor + + + YES + + + + 2 - 100153 + 100158 value: arrangedObjects.notes - - + + - - + + value: arrangedObjects.notes value arrangedObjects.notes + + NSCreatesSortDescriptor + + 2 - 100154 + 100159 + + + + annotationController + + + + 100160 @@ -994,7 +983,7 @@ YES - + @@ -1006,220 +995,221 @@ 100086 - + MediaController 100094 - + 100130 - + YES - - + + 100021 - + YES - - - - + + + + - + 100129 - + YES - - + + - + 100034 - + YES - - - - + + + + - + 100033 - - + + Movie View 100035 - - + + 100036 - - + + 100037 - - + + 100038 - + YES - - - + + + - + + Table View 100039 - + YES - + - + 100040 - + YES - + - + 100043 - + YES - + - + 100044 - - + + 100041 - - + + 100042 - - + + 100025 - + YES - - - + + + - + Table View 100024 - - + + 100023 - - + + 100022 - - + + 100030 - + YES - + - + 100027 - + YES - + - + 100026 - + YES - + - + 100029 - - + + 100028 - - + + 100031 - + YES - + - + 100032 - - + + 100143 - + SelectedFolderController 100148 - + AnnotationController @@ -1302,7 +1292,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - name == 'Inbox' AND parent == NULL + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1326,7 +1316,7 @@ - 100154 + 100160 @@ -1335,14 +1325,74 @@ MADocWindow NSWindowController - addMediaFiles: - id + YES + + YES + addAnnotation: + addMediaFiles: + + + YES + id + id + - addMediaFiles: - - addMediaFiles: - id + YES + + YES + addAnnotation: + addMediaFiles: + + + YES + + addAnnotation: + id + + + addMediaFiles: + id + + + + + YES + + YES + annotationController + mediaController + movieView + + + YES + NSArrayController + NSArrayController + QTMovieView + + + + YES + + YES + annotationController + mediaController + movieView + + + YES + + annotationController + NSArrayController + + + mediaController + NSArrayController + + + movieView + QTMovieView + diff --git a/Medianno/en.lproj/MainMenu.xib b/Medianno/en.lproj/MainMenu.xib index 8c14bd1..4c14373 100644 --- a/Medianno/en.lproj/MainMenu.xib +++ b/Medianno/en.lproj/MainMenu.xib @@ -273,6 +273,26 @@ + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Add Media Files… + A + 1048576 + 2147483647 + + + YES @@ -748,22 +768,22 @@ - + - Collection + Annotate 2147483647 submenuAction: - - Collection + + Annotate YES - - - Add Media Files… - A + + + Add Annotation + t 1048576 2147483647 @@ -1258,10 +1278,18 @@ addMediaFiles: - + 539 + + + addAnnotation: + + + + 542 + @@ -1301,7 +1329,7 @@ - + @@ -1356,6 +1384,8 @@ + + @@ -1903,26 +1933,36 @@ 536 - + YES - + 537 - + YES - + - + + + + 540 + + 538 - - + + + + + 541 + + @@ -2011,6 +2051,8 @@ 536.IBPluginDependency 537.IBPluginDependency 538.IBPluginDependency + 540.IBPluginDependency + 541.IBPluginDependency 56.IBPluginDependency 57.IBPluginDependency 58.IBPluginDependency @@ -2123,6 +2165,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin @@ -2137,7 +2181,7 @@ - 539 + 542 @@ -2179,6 +2223,25 @@ ./Classes/MADocWindow.h + + MADocument + NSPersistentDocument + + addAnnotation: + id + + + addAnnotation: + + addAnnotation: + id + + + + IBProjectSource + ./Classes/MADocument.h + + 0