Spotlight gets all necessary tags from metadata now. Some interface tweaks.

CQTexperiment
matthewleon 2008-02-11 16:39:19 +00:00
parent d8ac96afbf
commit 0e6a9ee966
6 changed files with 684 additions and 682 deletions

View File

@ -104,7 +104,6 @@
17F561400C3BD4F30019975C /* CogAudio.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17F561330C3BD4DC0019975C /* CogAudio.framework */; };
17F562390C3BD91B0019975C /* General.preferencePane in Resources */ = {isa = PBXBuildFile; fileRef = 17F5622E0C3BD8FB0019975C /* General.preferencePane */; };
5604D4550D603430004F5C5D /* SpotlightSearchController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5604D4510D603430004F5C5D /* SpotlightSearchController.m */; };
5604D4560D603430004F5C5D /* SpotlightTransformers.m in Sources */ = {isa = PBXBuildFile; fileRef = 5604D4530D603430004F5C5D /* SpotlightTransformers.m */; };
5604D4580D603459004F5C5D /* SpotlightPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5604D4570D603459004F5C5D /* SpotlightPanel.xib */; };
5604D45B0D60349B004F5C5D /* SpotlightWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5604D4590D60349B004F5C5D /* SpotlightWindowController.m */; };
5604D4F60D60726E004F5C5D /* SpotlightPlaylistEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = 5604D4F50D60726E004F5C5D /* SpotlightPlaylistEntry.m */; };
@ -592,8 +591,6 @@
32CA4F630368D1EE00C91783 /* Cog_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cog_Prefix.pch; sourceTree = "<group>"; };
5604D4510D603430004F5C5D /* SpotlightSearchController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SpotlightSearchController.m; path = Spotlight/SpotlightSearchController.m; sourceTree = "<group>"; };
5604D4520D603430004F5C5D /* SpotlightSearchController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SpotlightSearchController.h; path = Spotlight/SpotlightSearchController.h; sourceTree = "<group>"; };
5604D4530D603430004F5C5D /* SpotlightTransformers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SpotlightTransformers.m; path = Spotlight/SpotlightTransformers.m; sourceTree = "<group>"; };
5604D4540D603430004F5C5D /* SpotlightTransformers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SpotlightTransformers.h; path = Spotlight/SpotlightTransformers.h; sourceTree = "<group>"; };
5604D4570D603459004F5C5D /* SpotlightPanel.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = SpotlightPanel.xib; path = Spotlight/SpotlightPanel.xib; sourceTree = "<group>"; };
5604D4590D60349B004F5C5D /* SpotlightWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SpotlightWindowController.m; path = Spotlight/SpotlightWindowController.m; sourceTree = "<group>"; };
5604D45A0D60349B004F5C5D /* SpotlightWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SpotlightWindowController.h; path = Spotlight/SpotlightWindowController.h; sourceTree = "<group>"; };
@ -1092,8 +1089,6 @@
5604D45A0D60349B004F5C5D /* SpotlightWindowController.h */,
5604D4510D603430004F5C5D /* SpotlightSearchController.m */,
5604D4520D603430004F5C5D /* SpotlightSearchController.h */,
5604D4530D603430004F5C5D /* SpotlightTransformers.m */,
5604D4540D603430004F5C5D /* SpotlightTransformers.h */,
5604D4F40D60726E004F5C5D /* SpotlightPlaylistEntry.h */,
5604D4F50D60726E004F5C5D /* SpotlightPlaylistEntry.m */,
);
@ -1631,7 +1626,6 @@
17BBE5BC0CD95CFA00258F7A /* InvertedToolbarWindow.m in Sources */,
173428F50D5FB1C400E8D854 /* EntriesController.m in Sources */,
5604D4550D603430004F5C5D /* SpotlightSearchController.m in Sources */,
5604D4560D603430004F5C5D /* SpotlightTransformers.m in Sources */,
5604D45B0D60349B004F5C5D /* SpotlightWindowController.m in Sources */,
5604D4F60D60726E004F5C5D /* SpotlightPlaylistEntry.m in Sources */,
);

File diff suppressed because it is too large Load Diff

View File

@ -10,8 +10,12 @@
#import "PlaylistEntry.h"
@interface SpotlightPlaylistEntry : PlaylistEntry
@interface SpotlightPlaylistEntry : PlaylistEntry {
NSNumber *length;
}
+(SpotlightPlaylistEntry *)playlistEntryWithMetadataItem:(NSMetadataItem *)metadataItem;
@property(copy) NSNumber *length;
@end

View File

@ -16,6 +16,9 @@ static NSArray * entryKeys;
// extramdKeys represents those keys that require additional processing
static NSArray * extramdKeys;
// allmdKeys is a combined array of both mdKeys and entryKeys
static NSArray * allmdKeys;
// And the dictionary that matches them
static NSDictionary * tags;
@ -26,23 +29,25 @@ static NSDictionary * tags;
{
mdKeys = [NSArray arrayWithObjects:
@"kMDItemTitle",
@"kMDItemAuthors",
@"kMDItemAlbum",
@"kMDItemAudioTrackNumber",
@"kMDItemRecordingYear",
@"kMDItemMusicalGenre",
@"kMDItemDurationSeconds",
nil];
entryKeys = [NSArray arrayWithObjects:
@"title",
@"artist",
@"album",
@"track",
@"year",
@"genre",
@"length",
nil];
extramdKeys = [NSArray arrayWithObjects:
@"kMDItemPath",
@"kMDItemAuthors",
nil];
allmdKeys = [mdKeys arrayByAddingObjectsFromArray:extramdKeys];
tags = [NSDictionary dictionaryWithObjects:entryKeys forKeys:mdKeys];
}
@ -50,15 +55,17 @@ static NSDictionary * tags;
{
// use the matching tag sets to generate a playlist entry
SpotlightPlaylistEntry *entry = [[[SpotlightPlaylistEntry alloc] init] autorelease];
NSDictionary *songAttributes = [metadataItem valuesForAttributes:mdKeys];
NSDictionary *extraAttributes = [metadataItem valuesForAttributes:extramdKeys];
NSDictionary *songAttributes = [metadataItem valuesForAttributes:allmdKeys];
for (NSString * mdKey in tags) {
[entry setValue: [songAttributes objectForKey:mdKey]
forKey:[tags objectForKey:mdKey]];
}
// URL needs to be generated from the simple path stored in kMDItemPath
[entry setURL: [NSURL fileURLWithPath: [extraAttributes objectForKey:@"kMDItemPath"]]];
[entry setURL: [NSURL fileURLWithPath: [songAttributes objectForKey:@"kMDItemPath"]]];
// Authors is an array, but we only care about the first item in it
[entry setArtist: [[songAttributes objectForKey:@"kMDItemAuthors"] objectAtIndex:0]];
return entry;
}
@ -66,8 +73,10 @@ static NSDictionary * tags;
{
if (self = [super init])
{
length = nil;
}
return self;
}
@synthesize length;
@end

View File

@ -1,16 +0,0 @@
//
// SpotlightTransformers.h
// Cog
//
// Created by Matthew Grinshpun on 10/02/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface SpotlightArtistTransformer : NSValueTransformer{
}
@end

View File

@ -1,27 +0,0 @@
//
// SpotlightTransformers.m
// Cog
//
// Created by Matthew Grinshpun on 10/02/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "SpotlightTransformers.h"
// kMDItemAuthor is an array of values.
// For music, the first value is the artist
@implementation SpotlightArtistTransformer
+ (Class)transformedValueClass {
return [NSString class];
}
- (id)transformedValue:(id)value {
NSString * artistString = @"";
if (value != nil) {
artistString = [NSString stringWithString:
(NSString *)[value objectAtIndex:0]];
}
return artistString;
}
@end