Tag editing works
This commit is contained in:
parent
0db88816a4
commit
7b527121b3
|
@ -64,7 +64,11 @@
|
|||
- (void)setTagDescriptions:(NSArray *)tagDescriptions
|
||||
{
|
||||
NSManagedObjectContext *moc = [self managedObjectContext];
|
||||
|
||||
|
||||
NSSet * prevTags = self.tags;
|
||||
for (MATag * tag in prevTags)
|
||||
[moc deleteObject:tag];
|
||||
|
||||
int seqNo = 0;
|
||||
std::vector<MATag *> tags;
|
||||
for (MATagDescription * tagDesc in tagDescriptions) {
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface MADocWindow : NSWindowController {
|
||||
@interface MADocWindow : NSWindowController <NSTokenFieldCellDelegate> {
|
||||
IBOutlet NSArrayController* mediaController;
|
||||
IBOutlet NSArrayController* annotationController;
|
||||
IBOutlet QTMovieView * movieView;
|
||||
IBOutlet NSTokenField * tokenFieldProto;
|
||||
IBOutlet NSTableColumn * tokenColumn;
|
||||
}
|
||||
|
||||
- (IBAction)addMediaFiles:(id)sender;
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
[super windowDidLoad];
|
||||
[mediaController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES]]];
|
||||
[annotationController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"location" ascending:YES]]];
|
||||
NSCell * tokenCell = [tokenFieldProto cell];
|
||||
[tokenColumn setDataCell:tokenCell];
|
||||
}
|
||||
|
||||
#pragma mark Media management
|
||||
|
@ -86,4 +88,21 @@
|
|||
[[self document] addAnnotationForMedia:[[mediaController selectedObjects] objectAtIndex:0] location:location];
|
||||
}
|
||||
|
||||
#pragma mark Tag token manipulation
|
||||
|
||||
- (NSString *)tokenFieldCell:(NSTokenFieldCell *)tokenFieldCell displayStringForRepresentedObject:(id)representedObject
|
||||
{
|
||||
return [representedObject name];
|
||||
}
|
||||
|
||||
- (NSArray *)tokenFieldCell:(NSTokenFieldCell *)tokenFieldCell completionsForSubstring:(NSString *)substring indexOfToken:(NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex
|
||||
{
|
||||
return [[self document] tagNamesMatchingPrefix:substring];
|
||||
}
|
||||
|
||||
- (id)tokenFieldCell:(NSTokenFieldCell *)tokenFieldCell representedObjectForEditingString:(NSString *)editingString
|
||||
{
|
||||
return [[self document] tagDescriptionForName:editingString];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#import <QTKit/QTKit.h>
|
||||
|
||||
@class MAMedia;
|
||||
@class MATagDescription;
|
||||
|
||||
@interface MADocument : NSPersistentDocument {
|
||||
NSFileWrapper * mediaWrapper;
|
||||
|
@ -17,5 +18,7 @@
|
|||
|
||||
- (void)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date copying:(BOOL)copying;
|
||||
- (void)addAnnotationForMedia:(MAMedia *)media location:(QTTime)location;
|
||||
- (MATagDescription *)tagDescriptionForName:(NSString *)name;
|
||||
- (NSArray *)tagNamesMatchingPrefix:(NSString *)prefix;
|
||||
|
||||
@end
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#import "MAFolder.h"
|
||||
#import "MAMedia.h"
|
||||
#import "MAAnno.h"
|
||||
#import "MATagDescription.h"
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark MADocument
|
||||
|
||||
@implementation MADocument
|
||||
|
@ -53,7 +53,6 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Folder management
|
||||
|
||||
- (MAFolder *)inboxFolder
|
||||
|
@ -64,7 +63,6 @@
|
|||
return [[moc executeFetchRequest:inbox error:nil] objectAtIndex:0];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Media management
|
||||
|
||||
- (void)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date copying:(BOOL)copying
|
||||
|
@ -80,7 +78,6 @@
|
|||
media.folder= inbox;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Annotation management
|
||||
|
||||
- (void)addAnnotationForMedia:(MAMedia *)media location:(QTTime)location
|
||||
|
@ -93,4 +90,36 @@
|
|||
[moc processPendingChanges];
|
||||
}
|
||||
|
||||
#pragma mark Tag management
|
||||
|
||||
- (MATagDescription *)tagDescriptionForName:(NSString *)name
|
||||
{
|
||||
NSManagedObjectContext *moc = [self managedObjectContext];
|
||||
NSFetchRequest * fetch = [NSFetchRequest fetchRequestWithEntityName:@"MATagDescription"];
|
||||
[fetch setPredicate:[NSPredicate predicateWithFormat:@"name == %@", name]];
|
||||
NSArray * found = [moc executeFetchRequest:fetch error:nil];
|
||||
if (found && [found count]) {
|
||||
return [found objectAtIndex:0];
|
||||
} else {
|
||||
MATagDescription * tagDesc = [NSEntityDescription insertNewObjectForEntityForName:@"MATagDescription" inManagedObjectContext:moc];
|
||||
tagDesc.name = name;
|
||||
tagDesc.notes= @"";
|
||||
|
||||
return tagDesc;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)tagNamesMatchingPrefix:(NSString *)prefix
|
||||
{
|
||||
NSManagedObjectContext *moc = [self managedObjectContext];
|
||||
NSFetchRequest * fetch = [NSFetchRequest fetchRequestWithEntityName:@"MATagDescription"];
|
||||
[fetch setPredicate:[NSPredicate predicateWithFormat:@"name BEGINSWITH %@", prefix]];
|
||||
|
||||
NSArray * descs = [moc executeFetchRequest:fetch error:nil];
|
||||
NSMutableArray * names = [NSMutableArray arrayWithCapacity:[descs count]];
|
||||
for (MATagDescription * desc in descs)
|
||||
[names addObject:[desc name]];
|
||||
return names;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
@interface MATag : NSManagedObject {
|
||||
@private
|
||||
}
|
||||
@property (nonatomic) int seqNo;
|
||||
@property (nonatomic) int16_t seqNo;
|
||||
@property (nonatomic, retain) NSManagedObject *tag;
|
||||
@property (nonatomic, retain) NSManagedObject *annotation;
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
<string>NSBox</string>
|
||||
<string>NSDateFormatter</string>
|
||||
<string>NSTableView</string>
|
||||
<string>NSTokenField</string>
|
||||
<string>NSTokenFieldCell</string>
|
||||
<string>NSCustomObject</string>
|
||||
<string>NSView</string>
|
||||
<string>NSWindowTemplate</string>
|
||||
|
@ -58,6 +60,57 @@
|
|||
<object class="NSCustomObject" id="613418571">
|
||||
<string key="NSClassName">FirstResponder</string>
|
||||
</object>
|
||||
<object class="NSTokenField" id="33968723">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">-2147483380</int>
|
||||
<object class="NSMutableSet" key="NSDragTypes">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="set.sortedObjects">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSStringPboardType</string>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{550, 22}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:3123</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTokenFieldCell" key="NSCell" id="788762554">
|
||||
<int key="NSCellFlags">341966336</int>
|
||||
<int key="NSCellFlags2">0</int>
|
||||
<object class="NSFont" key="NSSupport">
|
||||
<string key="NSName">LucidaGrande</string>
|
||||
<double key="NSSize">10</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
</object>
|
||||
<string key="NSCellIdentifier">_NS:3123</string>
|
||||
<reference key="NSControlView" ref="33968723"/>
|
||||
<bool key="NSDrawsBackground">YES</bool>
|
||||
<object class="NSColor" key="NSBackgroundColor" id="638397430">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">textBackgroundColor</string>
|
||||
<object class="NSColor" key="NSColor" id="436396164">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSColor" key="NSTextColor" id="288648873">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlTextColor</string>
|
||||
<object class="NSColor" key="NSColor" id="1064784368">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MAA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<reference key="NSDelegate" ref="33968723"/>
|
||||
<double key="NSCompletionDelay">0.0</double>
|
||||
<int key="NSTokenStyle">0</int>
|
||||
</object>
|
||||
<int key="NSTokenFieldVersion">2</int>
|
||||
</object>
|
||||
<object class="NSWindowTemplate" id="275939982">
|
||||
<int key="NSWindowStyleMask">15</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
|
@ -136,10 +189,7 @@
|
|||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">headerTextColor</string>
|
||||
<object class="NSColor" key="NSColor" id="1064784368">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MAA</bytes>
|
||||
</object>
|
||||
<reference key="NSColor" ref="1064784368"/>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSTextFieldCell" key="NSDataCell" id="833593490">
|
||||
|
@ -161,12 +211,7 @@
|
|||
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSColor" key="NSTextColor" id="288648873">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlTextColor</string>
|
||||
<reference key="NSColor" ref="1064784368"/>
|
||||
</object>
|
||||
<reference key="NSTextColor" ref="288648873"/>
|
||||
</object>
|
||||
<int key="NSResizingMask">3</int>
|
||||
<bool key="NSIsResizeable">YES</bool>
|
||||
|
@ -212,10 +257,7 @@
|
|||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">headerColor</string>
|
||||
<object class="NSColor" key="NSColor" id="436396164">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
</object>
|
||||
<reference key="NSColor" ref="436396164"/>
|
||||
</object>
|
||||
<reference key="NSTextColor" ref="284725230"/>
|
||||
</object>
|
||||
|
@ -499,7 +541,7 @@
|
|||
<double key="NSIntercellSpacingHeight">2</double>
|
||||
<reference key="NSBackgroundColor" ref="436396164"/>
|
||||
<reference key="NSGridColor" ref="837522117"/>
|
||||
<double key="NSRowHeight">17</double>
|
||||
<double key="NSRowHeight">19</double>
|
||||
<int key="NSTvFlags">-2064384</int>
|
||||
<reference key="NSDelegate"/>
|
||||
<reference key="NSDataSource"/>
|
||||
|
@ -572,7 +614,7 @@
|
|||
<reference key="NSHScroller" ref="387598056"/>
|
||||
<reference key="NSContentView" ref="51131752"/>
|
||||
<reference key="NSHeaderClipView" ref="794153134"/>
|
||||
<bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
|
||||
<bytes key="NSScrollAmts">QSAAAEEgAABBqAAAQagAAA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{1281, 599}</string>
|
||||
|
@ -593,12 +635,7 @@
|
|||
<int key="NSCellFlags2">0</int>
|
||||
<string key="NSContents">Box</string>
|
||||
<reference key="NSSupport" ref="26"/>
|
||||
<object class="NSColor" key="NSBackgroundColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">textBackgroundColor</string>
|
||||
<reference key="NSColor" ref="436396164"/>
|
||||
</object>
|
||||
<reference key="NSBackgroundColor" ref="638397430"/>
|
||||
<object class="NSColor" key="NSTextColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MCAwLjgwMDAwMDAxMTkAA</bytes>
|
||||
|
@ -942,6 +979,46 @@
|
|||
</object>
|
||||
<int key="connectionID">100160</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBBindingConnection" key="connection">
|
||||
<string key="label">value: arrangedObjects.tagDescriptions</string>
|
||||
<reference key="source" ref="995592652"/>
|
||||
<reference key="destination" ref="603895450"/>
|
||||
<object class="NSNibBindingConnector" key="connector">
|
||||
<reference key="NSSource" ref="995592652"/>
|
||||
<reference key="NSDestination" ref="603895450"/>
|
||||
<string key="NSLabel">value: arrangedObjects.tagDescriptions</string>
|
||||
<string key="NSBinding">value</string>
|
||||
<string key="NSKeyPath">arrangedObjects.tagDescriptions</string>
|
||||
<int key="NSNibBindingConnectorVersion">2</int>
|
||||
</object>
|
||||
</object>
|
||||
<int key="connectionID">100172</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">tokenFieldProto</string>
|
||||
<reference key="source" ref="512844837"/>
|
||||
<reference key="destination" ref="33968723"/>
|
||||
</object>
|
||||
<int key="connectionID">100173</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">tokenColumn</string>
|
||||
<reference key="source" ref="512844837"/>
|
||||
<reference key="destination" ref="995592652"/>
|
||||
</object>
|
||||
<int key="connectionID">100174</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
<reference key="source" ref="788762554"/>
|
||||
<reference key="destination" ref="512844837"/>
|
||||
</object>
|
||||
<int key="connectionID">100175</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
|
@ -1113,6 +1190,7 @@
|
|||
<int key="objectID">100041</int>
|
||||
<reference key="object" ref="103524730"/>
|
||||
<reference key="parent" ref="995592652"/>
|
||||
<string key="objectName">Token Field Cell - Text Cell</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">100042</int>
|
||||
|
@ -1209,6 +1287,20 @@
|
|||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">AnnotationController</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">100161</int>
|
||||
<reference key="object" ref="33968723"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="788762554"/>
|
||||
</object>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">100162</int>
|
||||
<reference key="object" ref="788762554"/>
|
||||
<reference key="parent" ref="33968723"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
|
@ -1239,7 +1331,6 @@
|
|||
<string>100038.IBPluginDependency</string>
|
||||
<string>100039.IBPluginDependency</string>
|
||||
<string>100040.IBPluginDependency</string>
|
||||
<string>100041.CustomClassName</string>
|
||||
<string>100041.IBPluginDependency</string>
|
||||
<string>100042.IBPluginDependency</string>
|
||||
<string>100043.IBPluginDependency</string>
|
||||
|
@ -1252,6 +1343,8 @@
|
|||
<string>100143.IBPluginDependency</string>
|
||||
<string>100143.ibExternalFetchPredicateFormat</string>
|
||||
<string>100148.IBPluginDependency</string>
|
||||
<string>100161.IBPluginDependency</string>
|
||||
<string>100162.IBPluginDependency</string>
|
||||
<string>5.IBPluginDependency</string>
|
||||
<string>5.IBWindowTemplateEditedContentRect</string>
|
||||
<string>6.IBPluginDependency</string>
|
||||
|
@ -1282,7 +1375,6 @@
|
|||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>NSTokenFieldCell</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
|
@ -1293,7 +1385,9 @@
|
|||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>name=='Inbox' AND parent==NULL</string>
|
||||
<string>name == "Inbox" AND parent == nil</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{133, 170}, {507, 413}}</string>
|
||||
|
@ -1312,7 +1406,7 @@
|
|||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">100160</int>
|
||||
<int key="maxID">100175</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
@ -1359,12 +1453,16 @@
|
|||
<string>annotationController</string>
|
||||
<string>mediaController</string>
|
||||
<string>movieView</string>
|
||||
<string>tokenColumn</string>
|
||||
<string>tokenFieldProto</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSArrayController</string>
|
||||
<string>NSArrayController</string>
|
||||
<string>QTMovieView</string>
|
||||
<string>NSTableColumn</string>
|
||||
<string>NSTokenField</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
|
@ -1374,6 +1472,8 @@
|
|||
<string>annotationController</string>
|
||||
<string>mediaController</string>
|
||||
<string>movieView</string>
|
||||
<string>tokenColumn</string>
|
||||
<string>tokenFieldProto</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
|
@ -1389,6 +1489,14 @@
|
|||
<string key="name">movieView</string>
|
||||
<string key="candidateClassName">QTMovieView</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">tokenColumn</string>
|
||||
<string key="candidateClassName">NSTableColumn</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">tokenFieldProto</string>
|
||||
<string key="candidateClassName">NSTokenField</string>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
|
|
Loading…
Reference in New Issue
Block a user