Spotlight sorts by track number properly.

CQTexperiment
matthewleon 2008-03-03 23:02:52 +00:00
parent 9af41d7542
commit 69e802052e
7 changed files with 540 additions and 451 deletions

View File

@ -144,6 +144,7 @@
089C1669FE841209C02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "CoreAudio" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 089C166AFE841209C02AAC07 /* CoreAudio */;
projectDirPath = "";

View File

@ -139,6 +139,7 @@
089C1669FE841209C02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "M3u" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 089C166AFE841209C02AAC07 /* M3u */;
projectDirPath = "";

File diff suppressed because it is too large Load Diff

View File

@ -12,9 +12,11 @@
@interface SpotlightPlaylistEntry : PlaylistEntry {
NSNumber *length;
NSString *spotlightTrack;
}
+ (SpotlightPlaylistEntry *)playlistEntryWithMetadataItem:(NSMetadataItem *)metadataItem;
@property(retain, readwrite) NSNumber *length;
@property(retain) NSString *spotlightTrack;
@end

View File

@ -25,10 +25,14 @@ static NSDictionary *importKeys;
NSArray *artistTransform =
[NSArray arrayWithObjects:@"artist", @"AuthorToArtistTransformer", nil];
// Track numbers must sometimes be converted from NSNumber to NSString
NSArray *trackTransform =
[NSArray arrayWithObjects:@"spotlightTrack", @"NumberToStringTransformer", nil];
importKeys = [[NSDictionary dictionaryWithObjectsAndKeys:
@"title", @"kMDItemTitle",
@"album", @"kMDItemAlbum",
@"track", @"kMDItemAudioTrackNumber",
trackTransform, @"kMDItemAudioTrackNumber",
@"year", @"kMDItemRecordingYear",
@"genre", @"kMDItemMusicalGenre",
@"length", @"kMDItemDurationSeconds",
@ -82,5 +86,6 @@ static NSDictionary *importKeys;
}
@synthesize length;
@synthesize spotlightTrack;
@end

View File

@ -26,3 +26,6 @@
@interface StringToSearchScopeTransformer: NSValueTransformer {}
@end
@interface NumberToStringTransformer: NSValueTransformer {}
@end

View File

@ -85,3 +85,23 @@ static SpotlightWindowController * searchController;
}
@end
@implementation NumberToStringTransformer
+ (Class)transformedValueClass { return [NSString class]; }
+ (BOOL)allowsReverseTransformation { return NO; }
// Convert from NSNumber to NSString
- (id)transformedValue:(id)value {
if (value == nil) return nil;
// If there's an NS/CFNumber hiding in here...
if([value respondsToSelector:@selector(stringValue:)])
{
return [value stringValue];
}
return value;
}
@end