Added header menu for playlist view.
This commit is contained in:
parent
985ab27e1d
commit
44eeab95ee
4 changed files with 28 additions and 11 deletions
|
@ -173,7 +173,7 @@
|
||||||
- (void)setSortDescriptors:(NSArray *)sortDescriptors
|
- (void)setSortDescriptors:(NSArray *)sortDescriptors
|
||||||
{
|
{
|
||||||
//Cheap hack so the index column isn't sorted
|
//Cheap hack so the index column isn't sorted
|
||||||
if (([sortDescriptors count] != 0) && [[[sortDescriptors objectAtIndex:0] key] caseInsensitiveCompare:@"displayIndex"] == NSOrderedSame)
|
if (([sortDescriptors count] != 0) && [[[sortDescriptors objectAtIndex:0] key] caseInsensitiveCompare:@"index"] == NSOrderedSame)
|
||||||
{
|
{
|
||||||
//Remove the sort descriptors
|
//Remove the sort descriptors
|
||||||
[super setSortDescriptors:nil];
|
[super setSortDescriptors:nil];
|
||||||
|
|
|
@ -67,12 +67,4 @@
|
||||||
[super mouseDown: theEvent];
|
[super mouseDown: theEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSMenu*)menuForEvent:(NSEvent*)event
|
|
||||||
{
|
|
||||||
NSString *hi = @"This is a test";
|
|
||||||
//Show a menu!
|
|
||||||
NSLog(@"MENU FOR HEADER!");
|
|
||||||
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -14,9 +14,10 @@
|
||||||
#import "AMRemovableColumnsTableView.h"
|
#import "AMRemovableColumnsTableView.h"
|
||||||
|
|
||||||
@interface PlaylistView : AMRemovableColumnsTableView {
|
@interface PlaylistView : AMRemovableColumnsTableView {
|
||||||
|
|
||||||
IBOutlet PlaybackController *playbackController;
|
IBOutlet PlaybackController *playbackController;
|
||||||
IBOutlet PlaylistController *playlistController;
|
IBOutlet PlaylistController *playlistController;
|
||||||
|
|
||||||
|
NSMenu *headerContextMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)sortByPath:(id)sender;
|
- (IBAction)sortByPath:(id)sender;
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
|
|
||||||
[self setHeaderView:customTableHeaderView];
|
[self setHeaderView:customTableHeaderView];
|
||||||
|
|
||||||
|
//Set up formatters
|
||||||
NSFormatter *secondsFormatter = [[SecondsFormatter alloc] init];
|
NSFormatter *secondsFormatter = [[SecondsFormatter alloc] init];
|
||||||
[[[self tableColumnWithIdentifier:@"length"] dataCell] setFormatter:secondsFormatter];
|
[[[self tableColumnWithIdentifier:@"length"] dataCell] setFormatter:secondsFormatter];
|
||||||
[secondsFormatter release];
|
[secondsFormatter release];
|
||||||
|
@ -51,8 +52,31 @@
|
||||||
NSFormatter *indexFormatter = [[IndexFormatter alloc] init];
|
NSFormatter *indexFormatter = [[IndexFormatter alloc] init];
|
||||||
[[[self tableColumnWithIdentifier:@"index"] dataCell] setFormatter:indexFormatter];
|
[[[self tableColumnWithIdentifier:@"index"] dataCell] setFormatter:indexFormatter];
|
||||||
[indexFormatter release];
|
[indexFormatter release];
|
||||||
|
//end setting up formatters
|
||||||
|
|
||||||
[self setVerticalMotionCanBeginDrag:YES];
|
[self setVerticalMotionCanBeginDrag:YES];
|
||||||
|
|
||||||
|
//Set up header context menu
|
||||||
|
headerContextMenu = [[NSMenu alloc] initWithTitle:@"Playlist Header Context Menu"];
|
||||||
|
|
||||||
|
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"headerCell.title" ascending:YES];
|
||||||
|
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
|
||||||
|
NSEnumerator *e = [[[[self allTableColumns] allObjects] sortedArrayUsingDescriptors: sortDescriptors] objectEnumerator];
|
||||||
|
|
||||||
|
int menuIndex = 0;
|
||||||
|
NSTableColumn *col;
|
||||||
|
while (col = [e nextObject]) {
|
||||||
|
NSMenuItem *contextMenuItem = [headerContextMenu insertItemWithTitle:[[col headerCell] title] action:@selector(toggleColumn:) keyEquivalent:@"" atIndex:menuIndex];
|
||||||
|
|
||||||
|
[contextMenuItem setTarget:self];
|
||||||
|
[contextMenuItem setRepresentedObject:col];
|
||||||
|
[contextMenuItem setState:([[self visibleTableColumns] containsObject:col] ? NSOnState : NSOffState)];
|
||||||
|
|
||||||
|
menuIndex++;
|
||||||
|
}
|
||||||
|
[sortDescriptor release];
|
||||||
|
|
||||||
|
[[self headerView] setMenu:headerContextMenu];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue