Spotlight sorts by track number properly.
parent
9af41d7542
commit
69e802052e
|
@ -144,6 +144,7 @@
|
||||||
089C1669FE841209C02AAC07 /* Project object */ = {
|
089C1669FE841209C02AAC07 /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "CoreAudio" */;
|
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "CoreAudio" */;
|
||||||
|
compatibilityVersion = "Xcode 2.4";
|
||||||
hasScannedForEncodings = 1;
|
hasScannedForEncodings = 1;
|
||||||
mainGroup = 089C166AFE841209C02AAC07 /* CoreAudio */;
|
mainGroup = 089C166AFE841209C02AAC07 /* CoreAudio */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
|
|
|
@ -139,6 +139,7 @@
|
||||||
089C1669FE841209C02AAC07 /* Project object */ = {
|
089C1669FE841209C02AAC07 /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "M3u" */;
|
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "M3u" */;
|
||||||
|
compatibilityVersion = "Xcode 2.4";
|
||||||
hasScannedForEncodings = 1;
|
hasScannedForEncodings = 1;
|
||||||
mainGroup = 089C166AFE841209C02AAC07 /* M3u */;
|
mainGroup = 089C166AFE841209C02AAC07 /* M3u */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,9 +12,11 @@
|
||||||
|
|
||||||
@interface SpotlightPlaylistEntry : PlaylistEntry {
|
@interface SpotlightPlaylistEntry : PlaylistEntry {
|
||||||
NSNumber *length;
|
NSNumber *length;
|
||||||
|
NSString *spotlightTrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (SpotlightPlaylistEntry *)playlistEntryWithMetadataItem:(NSMetadataItem *)metadataItem;
|
+ (SpotlightPlaylistEntry *)playlistEntryWithMetadataItem:(NSMetadataItem *)metadataItem;
|
||||||
|
|
||||||
@property(retain, readwrite) NSNumber *length;
|
@property(retain, readwrite) NSNumber *length;
|
||||||
|
@property(retain) NSString *spotlightTrack;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -25,10 +25,14 @@ static NSDictionary *importKeys;
|
||||||
NSArray *artistTransform =
|
NSArray *artistTransform =
|
||||||
[NSArray arrayWithObjects:@"artist", @"AuthorToArtistTransformer", nil];
|
[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:
|
importKeys = [[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
@"title", @"kMDItemTitle",
|
@"title", @"kMDItemTitle",
|
||||||
@"album", @"kMDItemAlbum",
|
@"album", @"kMDItemAlbum",
|
||||||
@"track", @"kMDItemAudioTrackNumber",
|
trackTransform, @"kMDItemAudioTrackNumber",
|
||||||
@"year", @"kMDItemRecordingYear",
|
@"year", @"kMDItemRecordingYear",
|
||||||
@"genre", @"kMDItemMusicalGenre",
|
@"genre", @"kMDItemMusicalGenre",
|
||||||
@"length", @"kMDItemDurationSeconds",
|
@"length", @"kMDItemDurationSeconds",
|
||||||
|
@ -82,5 +86,6 @@ static NSDictionary *importKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
@synthesize length;
|
@synthesize length;
|
||||||
|
@synthesize spotlightTrack;
|
||||||
|
|
||||||
@end
|
@end
|
|
@ -26,3 +26,6 @@
|
||||||
|
|
||||||
@interface StringToSearchScopeTransformer: NSValueTransformer {}
|
@interface StringToSearchScopeTransformer: NSValueTransformer {}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface NumberToStringTransformer: NSValueTransformer {}
|
||||||
|
@end
|
|
@ -85,3 +85,23 @@ static SpotlightWindowController * searchController;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@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
|
Loading…
Reference in New Issue