Changed undo/redo menuitems back to firstResponder. Modified PlaylistView to validate undo/redo items.

CQTexperiment
vspader 2008-02-10 17:13:30 +00:00
parent ecf7f30fb4
commit 299285f0cd
7 changed files with 2221 additions and 2214 deletions

View File

@ -460,5 +460,4 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
[playbackController next:nil]; [playbackController next:nil];
} }
@end @end

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -46,8 +46,6 @@
- (NSUndoManager *)undoManager; - (NSUndoManager *)undoManager;
- (void)undoDelete:(NSMutableArray *)undoEntries; - (void)undoDelete:(NSMutableArray *)undoEntries;
- (void)undoMove:(NSMutableArray *) undoEntries; - (void)undoMove:(NSMutableArray *) undoEntries;
- (void)doUndo:(id)sender;
- (void)doRedo:(id)sender;
- (IBAction)takeShuffleFromObject:(id)sender; - (IBAction)takeShuffleFromObject:(id)sender;
- (IBAction)takeRepeatFromObject:(id)sender; - (IBAction)takeRepeatFromObject:(id)sender;

View File

@ -27,7 +27,7 @@
{ {
shuffleList = [[NSMutableArray alloc] init]; shuffleList = [[NSMutableArray alloc] init];
undoManager = [[NSUndoManager alloc] init]; undoManager = [[NSUndoManager alloc] init];
[undoManager setLevelsOfUndo:UNDO_STACK_LIMIT]; [undoManager setLevelsOfUndo:UNDO_STACK_LIMIT];
} }
@ -90,7 +90,7 @@
[undoEntries addObject: undoEntry]; [undoEntries addObject: undoEntry];
} }
[undoManager registerUndoWithTarget:self [[self undoManager] registerUndoWithTarget:self
selector:@selector(undoMove:) selector:@selector(undoMove:)
object:undoEntries]; object:undoEntries];
@ -228,7 +228,7 @@
// register an undo for the undo with the undoManager, // register an undo for the undo with the undoManager,
// so it knows what to do if a redo is requested // so it knows what to do if a redo is requested
[undoManager registerUndoWithTarget:self [[self undoManager] registerUndoWithTarget:self
selector:@selector(undoMove:) selector:@selector(undoMove:)
object:undoEntries]; object:undoEntries];
@ -240,7 +240,7 @@
// originally moved entry up the list // originally moved entry up the list
if (([current origin] > [current movedTo])) if (([current origin] > [current movedTo]))
{ {
if ([undoManager isUndoing]) // we are undoing if ([[self undoManager] isUndoing]) // we are undoing
{ {
playlistLocation = ([current origin] - (len - 1)) + iterations++; playlistLocation = ([current origin] - (len - 1)) + iterations++;
object = [objects objectAtIndex: playlistLocation]; object = [objects objectAtIndex: playlistLocation];
@ -261,7 +261,7 @@
// originally moved entry down the list // originally moved entry down the list
else else
{ {
if ([undoManager isUndoing]) if ([[self undoManager] isUndoing])
{ {
object = [objects objectAtIndex: [current origin]]; object = [objects objectAtIndex: [current origin]];
[object retain]; [object retain];
@ -290,18 +290,6 @@
return undoManager; return undoManager;
} }
- (void)doUndo:(id)sender
{
[undoManager undo];
}
- (void)doRedo:(id)sender
{
[undoManager redo];
}
- (void)removeObjectsAtArrangedObjectIndexes:(NSIndexSet *)indexes - (void)removeObjectsAtArrangedObjectIndexes:(NSIndexSet *)indexes
{ {
int i; // loop counter int i; // loop counter
@ -331,7 +319,7 @@
} }
// register the removals with the undoManager // register the removals with the undoManager
[undoManager registerUndoWithTarget:self [[self undoManager] registerUndoWithTarget:self
selector:@selector(undoDelete:) selector:@selector(undoDelete:)
object:undoEntries]; object:undoEntries];

View File

@ -25,5 +25,4 @@
- (IBAction)scrollToCurrentEntry:(id)sender; - (IBAction)scrollToCurrentEntry:(id)sender;
@end @end

View File

@ -231,4 +231,27 @@
[playlistController randomizeList]; [playlistController randomizeList];
} }
- (IBAction)undo:(id)sender
{
[[playlistController undoManager] undo];
}
- (IBAction)redo:(id)sender
{
[[playlistController undoManager] redo];
}
-(BOOL)validateMenuItem:(NSMenuItem*)menuItem
{
SEL action = [menuItem action];
if (action == @selector(undo:) && [[playlistController undoManager] canUndo])
return YES;
if (action == @selector(redo:) && [[playlistController undoManager] canRedo])
return YES;
return NO;
}
@end @end