diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 8867e3849..f1168cec1 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -16,7 +16,7 @@ @implementation PlaylistController #define SHUFFLE_HISTORY_SIZE 100 -#define UNDO_STACK_LIMIT 100 +#define UNDO_STACK_LIMIT 0 - (id)initWithCoder:(NSCoder *)decoder { @@ -247,6 +247,9 @@ - (void)setSortDescriptors:(NSArray *)sortDescriptors { + NSLog(@"Current: %@, setting: %@", [self sortDescriptors], sortDescriptors); + [[[self undoManager] prepareWithInvocationTarget:self] setSortDescriptors:[self sortDescriptors]]; + //Cheap hack so the index column isn't sorted if (([sortDescriptors count] != 0) && [[[sortDescriptors objectAtIndex:0] key] caseInsensitiveCompare:@"index"] == NSOrderedSame) { @@ -258,6 +261,8 @@ } [super setSortDescriptors:sortDescriptors]; + [self rearrangeObjects]; + [self updateIndexesFromRow:0]; } - (IBAction)sortByPath @@ -265,7 +270,6 @@ NSSortDescriptor *s = [[NSSortDescriptor alloc] initWithKey:@"url" ascending:YES selector:@selector(compare:)]; [self setSortDescriptors:[NSArray arrayWithObject:s]]; - [self rearrangeObjects]; [s release]; @@ -529,6 +533,8 @@ - (void)setFilterPredicate:(NSPredicate *)filterPredicate { + [[[self undoManager] prepareWithInvocationTarget:self] setFilterPredicate:[self filterPredicate]]; + [super setFilterPredicate:filterPredicate]; [self updateIndexesFromRow:0]; diff --git a/Playlist/PlaylistView.m b/Playlist/PlaylistView.m index 6461cccd9..a837d1631 100644 --- a/Playlist/PlaylistView.m +++ b/Playlist/PlaylistView.m @@ -238,10 +238,20 @@ { SEL action = [anItem action]; - if (action == @selector(undo:) && [[playlistController undoManager] canUndo]) - return YES; - if (action == @selector(redo:) && [[playlistController undoManager] canRedo]) - return YES; + if (action == @selector(undo:)) + { + if ([[playlistController undoManager] canUndo]) + return YES; + else + return NO; + } + if (action == @selector(redo:)) + { + if ([[playlistController undoManager] canRedo]) + return YES; + else + return NO; + } return [super validateUserInterfaceItem:anItem]; }