Fixed validation for undo/redo menu items. Added sort descriptors and predicates to undo chain.

CQTexperiment
vspader 2008-02-10 20:32:46 +00:00
parent a24149dc10
commit d654c37fe3
2 changed files with 22 additions and 6 deletions

View File

@ -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];

View File

@ -238,10 +238,20 @@
{
SEL action = [anItem action];
if (action == @selector(undo:) && [[playlistController undoManager] canUndo])
if (action == @selector(undo:))
{
if ([[playlistController undoManager] canUndo])
return YES;
if (action == @selector(redo:) && [[playlistController undoManager] canRedo])
else
return NO;
}
if (action == @selector(redo:))
{
if ([[playlistController undoManager] canRedo])
return YES;
else
return NO;
}
return [super validateUserInterfaceItem:anItem];
}