Album and artist search is now exposed no matter where you click.
parent
3c8b325a00
commit
332a062d93
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#import "IndexFormatter.h"
|
#import "IndexFormatter.h"
|
||||||
#import "SecondsFormatter.h"
|
#import "SecondsFormatter.h"
|
||||||
|
#import "PlaylistEntry.h"
|
||||||
|
|
||||||
@implementation PlaylistView
|
@implementation PlaylistView
|
||||||
|
|
||||||
|
@ -171,30 +172,41 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Add Spotlight search items
|
// Add Spotlight search items
|
||||||
NSMenuItem *spotlightMenuItem = Nil;
|
PlaylistEntry *song = [[playlistController arrangedObjects]objectAtIndex:iRow];
|
||||||
NSPoint menuPoint = [self convertPoint:[event locationInWindow] fromView:nil];
|
NSString *artist = [song artist];
|
||||||
NSInteger iColumn = [self columnAtPoint: menuPoint];
|
NSString *album = [song album];
|
||||||
NSTableColumn *column = [[self tableColumns]objectAtIndex:iColumn];
|
unsigned addedItems = 0; // Count the number of added items, used for separator
|
||||||
NSString *identifier = (NSString *)[column identifier];
|
|
||||||
if ([identifier isEqualToString:@"artist"])
|
|
||||||
{
|
|
||||||
spotlightMenuItem = [NSMenuItem alloc];
|
|
||||||
[spotlightMenuItem initWithTitle:@"Search for songs by artist..."
|
|
||||||
action:@selector(searchByArtist:)
|
|
||||||
keyEquivalent:@""];
|
|
||||||
}
|
|
||||||
else if ([identifier isEqualToString:@"album"])
|
|
||||||
{
|
|
||||||
spotlightMenuItem = [NSMenuItem alloc];
|
|
||||||
[spotlightMenuItem initWithTitle:@"Search for songs by album..."
|
|
||||||
action:@selector(searchByAlbum:)
|
|
||||||
keyEquivalent:@""];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(spotlightMenuItem)
|
if(album)
|
||||||
{
|
{
|
||||||
spotlightMenuItem.target = playlistController;
|
NSMenuItem *albumMenuItem = [NSMenuItem alloc];
|
||||||
[tableViewMenu insertItem:spotlightMenuItem atIndex:0];
|
NSString *title = [NSString
|
||||||
|
stringWithFormat:@"Search for Songs from %@...", album];
|
||||||
|
[albumMenuItem initWithTitle:title
|
||||||
|
action:@selector(searchByAlbum:)
|
||||||
|
keyEquivalent:@""];
|
||||||
|
albumMenuItem.target = playlistController;
|
||||||
|
[tableViewMenu insertItem:albumMenuItem atIndex:0];
|
||||||
|
[albumMenuItem release];
|
||||||
|
addedItems++;
|
||||||
|
}
|
||||||
|
if(artist)
|
||||||
|
{
|
||||||
|
NSMenuItem *artistMenuItem = [NSMenuItem alloc];
|
||||||
|
NSString *title = [NSString
|
||||||
|
stringWithFormat:@"Search for Songs by %@...", artist];
|
||||||
|
[artistMenuItem initWithTitle:title
|
||||||
|
action:@selector(searchByArtist:)
|
||||||
|
keyEquivalent:@""];
|
||||||
|
artistMenuItem.target = playlistController;
|
||||||
|
[tableViewMenu insertItem:artistMenuItem atIndex:0];
|
||||||
|
[artistMenuItem release];
|
||||||
|
addedItems++;
|
||||||
|
}
|
||||||
|
if(addedItems)
|
||||||
|
{
|
||||||
|
// add a separator in the right place
|
||||||
|
[tableViewMenu insertItem:[NSMenuItem separatorItem] atIndex:addedItems];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue