Index column is now set by observing arrangedObjects instead of the updateIndexesFromRow method.
parent
f451cd1712
commit
a10898f4c9
|
@ -39,6 +39,7 @@ NSString *iTunesDropType = @"CorePasteboardFlavorType 0x6974756E";
|
|||
if ([info draggingSource] == tv)
|
||||
dragOp = NSDragOperationMove;
|
||||
|
||||
NSLog(@"VALIDATING DROP!");
|
||||
// we want to put the object at, not over,
|
||||
// the current row (contrast NSTableViewDropOn)
|
||||
[tv setDropRow:row dropOperation:NSTableViewDropAbove];
|
||||
|
@ -69,10 +70,11 @@ NSString *iTunesDropType = @"CorePasteboardFlavorType 0x6974756E";
|
|||
|
||||
[self setSelectedObjects:selected];
|
||||
|
||||
NSLog(@"ACCEPTING DROP!");
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
NSLog(@"REJECTING DROP!");
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ typedef enum {
|
|||
@property(retain) PlaylistEntry *currentEntry;
|
||||
|
||||
//Private Methods
|
||||
- (void)updateIndexesFromRow:(int) row;
|
||||
- (void)updateTotalTime;
|
||||
|
||||
|
||||
|
|
|
@ -69,13 +69,30 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
|
||||
[self addObserver:self forKeyPath:@"arrangedObjects" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||
{
|
||||
int i;
|
||||
NSArray *arranged = [self arrangedObjects];
|
||||
for (i = 0; i < [arranged count]; i++)
|
||||
{
|
||||
PlaylistEntry *pe = [arranged objectAtIndex:i];
|
||||
if (pe.index != i) //Make sure we don't get into some kind of crazy observing loop...
|
||||
pe.index = i;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(NSTableView *)tableView
|
||||
didClickTableColumn:(NSTableColumn *)tableColumn
|
||||
{
|
||||
if (shuffle == YES)
|
||||
[self resetShuffleList];
|
||||
|
||||
[self updateIndexesFromRow:0];
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(NSTableView *)tv toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc row:(int)row mouseLocation:(NSPoint)mouseLocation
|
||||
|
@ -98,8 +115,6 @@
|
|||
if (lowerIndex != NSNotFound)
|
||||
index = lowerIndex;
|
||||
}
|
||||
|
||||
[self updateIndexesFromRow:index];
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
|
||||
|
@ -176,7 +191,6 @@
|
|||
[urls release];
|
||||
}
|
||||
|
||||
[self updateIndexesFromRow:row];
|
||||
[self updateTotalTime];
|
||||
|
||||
if (shuffle == YES)
|
||||
|
@ -212,18 +226,6 @@
|
|||
return totalTimeDisplay;
|
||||
}
|
||||
|
||||
- (void)updateIndexesFromRow:(int) row
|
||||
{
|
||||
int j;
|
||||
for (j = row; j < [[self arrangedObjects] count]; j++)
|
||||
{
|
||||
PlaylistEntry *p;
|
||||
p = [[self arrangedObjects] objectAtIndex:j];
|
||||
|
||||
p.index = j;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSUndoManager *)undoManager
|
||||
{
|
||||
return [entriesController undoManager];
|
||||
|
@ -233,7 +235,6 @@
|
|||
{
|
||||
[super insertObjects:objects atArrangedObjectIndexes:indexes];
|
||||
|
||||
[self updateIndexesFromRow:[indexes firstIndex]];
|
||||
[self updateTotalTime];
|
||||
|
||||
if (shuffle == YES)
|
||||
|
@ -269,7 +270,6 @@
|
|||
|
||||
[super removeObjectsAtArrangedObjectIndexes:indexes];
|
||||
|
||||
[self updateIndexesFromRow:[indexes firstIndex]];
|
||||
[self updateTotalTime];
|
||||
|
||||
if (shuffle == YES)
|
||||
|
@ -292,7 +292,6 @@
|
|||
|
||||
[super setSortDescriptors:sortDescriptors];
|
||||
[self rearrangeObjects];
|
||||
[self updateIndexesFromRow:0];
|
||||
}
|
||||
|
||||
- (IBAction)sortByPath
|
||||
|
@ -305,8 +304,6 @@
|
|||
|
||||
if (shuffle == YES)
|
||||
[self resetShuffleList];
|
||||
|
||||
[self updateIndexesFromRow:0];
|
||||
}
|
||||
|
||||
- (IBAction)randomizeList
|
||||
|
@ -316,8 +313,6 @@
|
|||
[self setContent:[Shuffle shuffleList:[self content]]];
|
||||
if (shuffle == YES)
|
||||
[self resetShuffleList];
|
||||
|
||||
[self updateIndexesFromRow:0];
|
||||
}
|
||||
|
||||
- (IBAction)takeShuffleFromObject:(id)sender
|
||||
|
@ -622,8 +617,6 @@
|
|||
- (void)setFilterPredicate:(NSPredicate *)filterPredicate
|
||||
{
|
||||
[super setFilterPredicate:filterPredicate];
|
||||
|
||||
[self updateIndexesFromRow:0];
|
||||
}
|
||||
|
||||
- (IBAction)showEntryInFinder:(id)sender
|
||||
|
|
Loading…
Reference in New Issue