diff --git a/Playlist/PlaylistEntry.h b/Playlist/PlaylistEntry.h index 5bccfef88..d27036a35 100644 --- a/Playlist/PlaylistEntry.h +++ b/Playlist/PlaylistEntry.h @@ -41,6 +41,8 @@ - (void)setShuffleIndex:(NSNumber *)si; - (NSNumber *)shuffleIndex; +// Hack for KVC compliance +- (void)setUrl:(NSURL *)u; - (void)setURL:(NSURL *)u; - (NSURL *)url; - (void)setCurrent:(NSNumber *) b; diff --git a/Playlist/PlaylistEntry.m b/Playlist/PlaylistEntry.m index 04e43e732..ccb6f39ab 100644 --- a/Playlist/PlaylistEntry.m +++ b/Playlist/PlaylistEntry.m @@ -98,6 +98,13 @@ return idx; } + +// Hack for kvc compliance - fix this +-(void)setUrl:(NSURL *)u +{ + [self setURL:u]; +} + -(void)setURL:(NSURL *)u { [u retain]; diff --git a/Spotlight/SpotlightPlaylistEntry.m b/Spotlight/SpotlightPlaylistEntry.m index fea850988..7ec9c6bc4 100644 --- a/Spotlight/SpotlightPlaylistEntry.m +++ b/Spotlight/SpotlightPlaylistEntry.m @@ -19,7 +19,7 @@ static NSDictionary *importKeys; { // We need to translate the path string to a full URL NSArray *URLTransform = - [NSArray arrayWithObjects:@"URL", @"StringToURLTransformer", nil]; + [NSArray arrayWithObjects:@"url", @"PathToURLTransformer", nil]; // Extract the artist name from the authors array NSArray *artistTransform = @@ -62,8 +62,7 @@ static NSDictionary *importKeys; [NSValueTransformer valueTransformerForName:[importTarget objectAtIndex:1]]; id transformedValue = [transformer transformedValue: [songAttributes objectForKey:mdKey]]; - [entry setValue: transformedValue - forKey: importKey]; + [entry setValue:transformedValue forKey: importKey]; } // The importKeys dictionary contains something strange... else diff --git a/Spotlight/SpotlightTransformers.h b/Spotlight/SpotlightTransformers.h index 145c9d55e..df12b5c9e 100644 --- a/Spotlight/SpotlightTransformers.h +++ b/Spotlight/SpotlightTransformers.h @@ -20,4 +20,8 @@ @interface AuthorToArtistTransformer: NSValueTransformer {} +@end + +@interface PathToURLTransformer: NSValueTransformer {} + @end \ No newline at end of file diff --git a/Spotlight/SpotlightTransformers.m b/Spotlight/SpotlightTransformers.m index c347aed4f..3f7e841ef 100644 --- a/Spotlight/SpotlightTransformers.m +++ b/Spotlight/SpotlightTransformers.m @@ -48,5 +48,25 @@ static SpotlightWindowController * searchController; - (id)transformedValue:(id)value { return [value objectAtIndex:0]; } +@end + +@implementation PathToURLTransformer + ++ (Class)transformedValueClass { return [NSURL class]; } ++ (BOOL)allowsReverseTransformation { return YES; } + +// Convert from path to NSURL +- (id)transformedValue:(id)value { + if (value == nil) return nil; + + return [NSURL fileURLWithPath:value]; +} + +// Convert from NSURL to path +- (id)reverseTransformedValue:(id)value { + if (value == nil) return nil; + + return [value path]; +} @end \ No newline at end of file diff --git a/Spotlight/SpotlightWindowController.m b/Spotlight/SpotlightWindowController.m index 3b4d55f6b..9624c643c 100644 --- a/Spotlight/SpotlightWindowController.m +++ b/Spotlight/SpotlightWindowController.m @@ -44,6 +44,8 @@ static NSPredicate * musicOnlyPredicate = nil; [NSValueTransformer setValueTransformer:pausingQueryTransformer forName:@"PausingQueryTransformer"]; NSValueTransformer *authorToArtistTransformer = [[[AuthorToArtistTransformer alloc]init]autorelease]; [NSValueTransformer setValueTransformer:authorToArtistTransformer forName:@"AuthorToArtistTransformer"]; + NSValueTransformer *pathToURLTransformer = [[[PathToURLTransformer alloc]init]autorelease]; + [NSValueTransformer setValueTransformer:pathToURLTransformer forName:@"PathToURLTransformers"]; } - (id)init