Fixed up undo/redo support. Should be working great now.

CQTexperiment
vspader 2008-02-10 22:46:12 +00:00
parent 03cdbd508d
commit 37820a586d
7 changed files with 2597 additions and 2523 deletions

View File

@ -14,6 +14,7 @@
171B57DE0C091F2B00F6AFAF /* m4a.icns in Resources */ = {isa = PBXBuildFile; fileRef = 171B57DA0C091F2B00F6AFAF /* m4a.icns */; };
171B57DF0C091F2B00F6AFAF /* mp3.icns in Resources */ = {isa = PBXBuildFile; fileRef = 171B57DB0C091F2B00F6AFAF /* mp3.icns */; };
171B57E00C091F2B00F6AFAF /* ogg.icns in Resources */ = {isa = PBXBuildFile; fileRef = 171B57DC0C091F2B00F6AFAF /* ogg.icns */; };
173428F50D5FB1C400E8D854 /* EntriesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 173428F40D5FB1C400E8D854 /* EntriesController.m */; };
1755E1F90BA0D2B600CA3560 /* PlaylistLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1755E1F70BA0D2B600CA3560 /* PlaylistLoader.m */; };
1766C6930B911DF1004A7AE4 /* AudioScrobbler.m in Sources */ = {isa = PBXBuildFile; fileRef = 1766C68F0B911DF1004A7AE4 /* AudioScrobbler.m */; };
1766C6950B911DF1004A7AE4 /* AudioScrobblerClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 1766C6910B911DF1004A7AE4 /* AudioScrobblerClient.m */; };
@ -468,6 +469,8 @@
171B57DA0C091F2B00F6AFAF /* m4a.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = m4a.icns; sourceTree = "<group>"; };
171B57DB0C091F2B00F6AFAF /* mp3.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = mp3.icns; sourceTree = "<group>"; };
171B57DC0C091F2B00F6AFAF /* ogg.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ogg.icns; sourceTree = "<group>"; };
173428F30D5FB1C400E8D854 /* EntriesController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EntriesController.h; sourceTree = "<group>"; };
173428F40D5FB1C400E8D854 /* EntriesController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EntriesController.m; sourceTree = "<group>"; };
1755E1F60BA0D2B600CA3560 /* PlaylistLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PlaylistLoader.h; sourceTree = "<group>"; };
1755E1F70BA0D2B600CA3560 /* PlaylistLoader.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PlaylistLoader.m; sourceTree = "<group>"; };
1766C68E0B911DF1004A7AE4 /* AudioScrobbler.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AudioScrobbler.h; sourceTree = "<group>"; };
@ -1144,6 +1147,8 @@
8E9A2E840BA78B500091081B /* SecondsFormatter.m */,
8E9A2ED70BA78D9D0091081B /* IndexFormatter.h */,
8E9A2ED80BA78D9D0091081B /* IndexFormatter.m */,
173428F30D5FB1C400E8D854 /* EntriesController.h */,
173428F40D5FB1C400E8D854 /* EntriesController.m */,
);
path = Playlist;
sourceTree = "<group>";
@ -1622,6 +1627,7 @@
567E73780D5F456D006C6486 /* SpotlightSearchController.m in Sources */,
567E75070D5F71E7006C6486 /* SpotlightTransformers.m in Sources */,
567E75750D5F8E20006C6486 /* SpotlightWindowController.m in Sources */,
173428F50D5FB1C400E8D854 /* EntriesController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -12,16 +12,16 @@
@class PlaylistLoader;
@class PlaylistEntry;
@class EntriesController;
@interface PlaylistController : DNDArrayController {
IBOutlet PlaylistLoader *playlistLoader;
IBOutlet EntriesController *entriesController;
NSString *totalTimeDisplay;
NSMutableArray *shuffleList;
NSUndoManager *undoManager;
PlaylistEntry *currentEntry;
BOOL shuffle;

View File

@ -16,7 +16,6 @@
@implementation PlaylistController
#define SHUFFLE_HISTORY_SIZE 100
#define UNDO_STACK_LIMIT 0
- (id)initWithCoder:(NSCoder *)decoder
{
@ -25,14 +24,18 @@
if (self)
{
shuffleList = [[NSMutableArray alloc] init];
undoManager = [[NSUndoManager alloc] init];
[undoManager setLevelsOfUndo:UNDO_STACK_LIMIT];
}
return self;
}
- (void)dealloc
{
[shuffleList release];
[super dealloc];
}
- (void)tableView:(NSTableView *)tableView
didClickTableColumn:(NSTableColumn *)tableColumn
{
@ -44,21 +47,6 @@
-(void)moveObjectsFromArrangedObjectIndexes:(NSArray *) sources toIndexes:(NSArray *)destinations
{
NSLog(@"MOVING!: %@ %@", sources, destinations);
NSMutableArray *undoSources = [NSMutableArray array];
NSMutableArray *undoDests = [NSMutableArray array];
for (id s in sources)
{
[undoDests insertObject:s atIndex:0];
}
for (id d in destinations)
{
[undoSources insertObject:d atIndex:0];
}
[[[self undoManager] prepareWithInvocationTarget:self] moveObjectsFromArrangedObjectIndexes:undoSources toIndexes:undoDests];
[super moveObjectsFromArrangedObjectIndexes:sources toIndexes:destinations];
NSUInteger firstIndex = (NSUInteger)-1;
@ -191,12 +179,11 @@
- (NSUndoManager *)undoManager
{
return undoManager;
return [entriesController undoManager];
}
- (void)insertObjects:(NSArray *)objects atArrangedObjectIndexes:(NSIndexSet *)indexes
{
[[[self undoManager] prepareWithInvocationTarget:self] removeObjectsAtArrangedObjectIndexes:indexes];
[super insertObjects:objects atArrangedObjectIndexes:indexes];
[self updateIndexesFromRow:[indexes firstIndex]];
@ -206,7 +193,6 @@
[self resetShuffleList];
}
- (void)removeObjectsAtArrangedObjectIndexes:(NSIndexSet *)indexes
{
NSLog(@"Removing indexes: %@", indexes);
@ -235,7 +221,6 @@
NSLog(@"UPDATING INDEX: %@", [currentEntry index]);
}
[[[self undoManager] prepareWithInvocationTarget:self] insertObjects:[[self arrangedObjects] objectsAtIndexes:indexes] atArrangedObjectIndexes:indexes];
[super removeObjectsAtArrangedObjectIndexes:indexes];
[self updateIndexesFromRow:[indexes firstIndex]];
@ -248,7 +233,6 @@
- (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)
@ -533,8 +517,6 @@
- (void)setFilterPredicate:(NSPredicate *)filterPredicate
{
[[[self undoManager] prepareWithInvocationTarget:self] setFilterPredicate:[self filterPredicate]];
[super setFilterPredicate:filterPredicate];
[self updateIndexesFromRow:0];

View File

@ -23,7 +23,7 @@ typedef enum {
- (void)addURLs:(NSArray *)urls sort:(BOOL)sort;
- (void)addURL:(NSURL *)url;
- (void)insertURLs:(NSArray *)urls atIndex:(int)index sort:(BOOL)sort;
- (void)undoAdd:(NSIndexSet *)undoEntries;
//save playlist, auto-determines type based on extension. Uses m3u if it cannot be determined.
- (BOOL)save:(NSString *)filename;
- (BOOL)save:(NSString *)filename asType:(PlaylistType)type;