Made arranged item remover actually remove the correct arranged items and use the correct indexes
This commit is contained in:
parent
7a9e4a720c
commit
2f5769d668
1 changed files with 12 additions and 3 deletions
|
@ -6,6 +6,7 @@
|
||||||
// Copyright 2005 Vincent Spader All rights reserved.
|
// Copyright 2005 Vincent Spader All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#import "PlaylistController.h"
|
||||||
#import "PlaylistEntry.h"
|
#import "PlaylistEntry.h"
|
||||||
#import "PlaylistLoader.h"
|
#import "PlaylistLoader.h"
|
||||||
#import "PlaybackController.h"
|
#import "PlaybackController.h"
|
||||||
|
@ -310,7 +311,7 @@
|
||||||
|
|
||||||
- (void)removeObjectsAtArrangedObjectIndexes:(NSIndexSet *)indexes
|
- (void)removeObjectsAtArrangedObjectIndexes:(NSIndexSet *)indexes
|
||||||
{
|
{
|
||||||
NSArray *objects = [[self content] objectsAtIndexes:indexes];
|
NSArray *objects = [[self arrangedObjects] objectsAtIndexes:indexes];
|
||||||
[[[self undoManager] prepareWithInvocationTarget:self] insertObjects:objects atArrangedObjectIndexes:indexes];
|
[[[self undoManager] prepareWithInvocationTarget:self] insertObjects:objects atArrangedObjectIndexes:indexes];
|
||||||
NSString *actionName = [NSString stringWithFormat:@"Removing %lu entries", (unsigned long)[indexes count]];
|
NSString *actionName = [NSString stringWithFormat:@"Removing %lu entries", (unsigned long)[indexes count]];
|
||||||
[[self undoManager] setActionName:actionName];
|
[[self undoManager] setActionName:actionName];
|
||||||
|
@ -318,7 +319,13 @@
|
||||||
DLog(@"Removing indexes: %@", indexes);
|
DLog(@"Removing indexes: %@", indexes);
|
||||||
DLog(@"Current index: %i", currentEntry.index);
|
DLog(@"Current index: %i", currentEntry.index);
|
||||||
|
|
||||||
if (currentEntry.index >= 0 && [indexes containsIndex:currentEntry.index])
|
NSMutableIndexSet *unarrangedIndexes = [[NSMutableIndexSet alloc] init];
|
||||||
|
for (PlaylistEntry *pe in objects)
|
||||||
|
{
|
||||||
|
[unarrangedIndexes addIndex:[pe index]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentEntry.index >= 0 && [unarrangedIndexes containsIndex:currentEntry.index])
|
||||||
{
|
{
|
||||||
currentEntry.index = -currentEntry.index - 1;
|
currentEntry.index = -currentEntry.index - 1;
|
||||||
DLog(@"Current removed: %i", currentEntry.index);
|
DLog(@"Current removed: %i", currentEntry.index);
|
||||||
|
@ -331,7 +338,7 @@
|
||||||
int j;
|
int j;
|
||||||
for (j = i - 1; j >= 0; j--)
|
for (j = i - 1; j >= 0; j--)
|
||||||
{
|
{
|
||||||
if ([indexes containsIndex:j]) {
|
if ([unarrangedIndexes containsIndex:j]) {
|
||||||
DLog(@"Removing 1");
|
DLog(@"Removing 1");
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
@ -339,6 +346,8 @@
|
||||||
currentEntry.index = -i - 1;
|
currentEntry.index = -i - 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[unarrangedIndexes release];
|
||||||
|
|
||||||
[super removeObjectsAtArrangedObjectIndexes:indexes];
|
[super removeObjectsAtArrangedObjectIndexes:indexes];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue