Fixed Spotlight import.
parent
d23b6b4ee5
commit
aa3b716e09
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -20,4 +20,8 @@
|
|||
|
||||
@interface AuthorToArtistTransformer: NSValueTransformer {}
|
||||
|
||||
@end
|
||||
|
||||
@interface PathToURLTransformer: NSValueTransformer {}
|
||||
|
||||
@end
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue