Forgot to add these files for undo support.
parent
37820a586d
commit
803a3306a5
|
@ -0,0 +1,23 @@
|
||||||
|
//
|
||||||
|
// EntriesController.h
|
||||||
|
// Cog
|
||||||
|
//
|
||||||
|
// Created by Vincent Spader on 2/10/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import "PlaylistEntry.h"
|
||||||
|
|
||||||
|
@interface EntriesController : NSObject {
|
||||||
|
NSUndoManager *undoManager;
|
||||||
|
NSMutableArray *playlistEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMutableArray *)entries;
|
||||||
|
- (void)setEntries:(NSMutableArray *)array;
|
||||||
|
- (void)insertObject:(PlaylistEntry *)pe inEntriesAtIndex:(int)index;
|
||||||
|
- (void)removeObjectFromEntriesAtIndex:(int)index;
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,72 @@
|
||||||
|
//
|
||||||
|
// EntriesController.m
|
||||||
|
// Cog
|
||||||
|
//
|
||||||
|
// Created by Vincent Spader on 2/10/08.
|
||||||
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "EntriesController.h"
|
||||||
|
|
||||||
|
#define UNDO_STACK_LIMIT 0
|
||||||
|
|
||||||
|
@implementation EntriesController
|
||||||
|
|
||||||
|
- (id)init
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
|
||||||
|
if (self)
|
||||||
|
{
|
||||||
|
playlistEntries = [[NSMutableArray alloc] init];
|
||||||
|
undoManager = [[NSUndoManager alloc] init];
|
||||||
|
|
||||||
|
[undoManager setLevelsOfUndo:UNDO_STACK_LIMIT];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[playlistEntries release];
|
||||||
|
[undoManager release];
|
||||||
|
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSUndoManager *)undoManager
|
||||||
|
{
|
||||||
|
return undoManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMutableArray *)entries
|
||||||
|
{
|
||||||
|
return playlistEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setEntries:(NSMutableArray *)array
|
||||||
|
{
|
||||||
|
if (array == playlistEntries)
|
||||||
|
return;
|
||||||
|
|
||||||
|
[array retain];
|
||||||
|
[playlistEntries release];
|
||||||
|
playlistEntries = array;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)insertObject:(PlaylistEntry *)pe inEntriesAtIndex:(int)index
|
||||||
|
{
|
||||||
|
[[[self undoManager] prepareWithInvocationTarget:self] removeObjectFromEntriesAtIndex:index];
|
||||||
|
[playlistEntries insertObject:pe atIndex:index];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)removeObjectFromEntriesAtIndex:(int)index
|
||||||
|
{
|
||||||
|
[[[self undoManager] prepareWithInvocationTarget:self] insertObject:[playlistEntries objectAtIndex:index] inEntriesAtIndex:index];
|
||||||
|
|
||||||
|
[playlistEntries removeObjectAtIndex:index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in New Issue