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)
|
if ([info draggingSource] == tv)
|
||||||
dragOp = NSDragOperationMove;
|
dragOp = NSDragOperationMove;
|
||||||
|
|
||||||
|
NSLog(@"VALIDATING DROP!");
|
||||||
// we want to put the object at, not over,
|
// we want to put the object at, not over,
|
||||||
// the current row (contrast NSTableViewDropOn)
|
// the current row (contrast NSTableViewDropOn)
|
||||||
[tv setDropRow:row dropOperation:NSTableViewDropAbove];
|
[tv setDropRow:row dropOperation:NSTableViewDropAbove];
|
||||||
|
@ -69,10 +70,11 @@ NSString *iTunesDropType = @"CorePasteboardFlavorType 0x6974756E";
|
||||||
|
|
||||||
[self setSelectedObjects:selected];
|
[self setSelectedObjects:selected];
|
||||||
|
|
||||||
|
NSLog(@"ACCEPTING DROP!");
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
NSLog(@"REJECTING DROP!");
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ typedef enum {
|
||||||
@property(retain) PlaylistEntry *currentEntry;
|
@property(retain) PlaylistEntry *currentEntry;
|
||||||
|
|
||||||
//Private Methods
|
//Private Methods
|
||||||
- (void)updateIndexesFromRow:(int) row;
|
|
||||||
- (void)updateTotalTime;
|
- (void)updateTotalTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,13 +69,30 @@
|
||||||
[super dealloc];
|
[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
|
- (void)tableView:(NSTableView *)tableView
|
||||||
didClickTableColumn:(NSTableColumn *)tableColumn
|
didClickTableColumn:(NSTableColumn *)tableColumn
|
||||||
{
|
{
|
||||||
if (shuffle == YES)
|
if (shuffle == YES)
|
||||||
[self resetShuffleList];
|
[self resetShuffleList];
|
||||||
|
|
||||||
[self updateIndexesFromRow:0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)tableView:(NSTableView *)tv toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc row:(int)row mouseLocation:(NSPoint)mouseLocation
|
- (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)
|
if (lowerIndex != NSNotFound)
|
||||||
index = lowerIndex;
|
index = lowerIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self updateIndexesFromRow:index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
|
- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
|
||||||
|
@ -176,7 +191,6 @@
|
||||||
[urls release];
|
[urls release];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self updateIndexesFromRow:row];
|
|
||||||
[self updateTotalTime];
|
[self updateTotalTime];
|
||||||
|
|
||||||
if (shuffle == YES)
|
if (shuffle == YES)
|
||||||
|
@ -212,18 +226,6 @@
|
||||||
return totalTimeDisplay;
|
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
|
- (NSUndoManager *)undoManager
|
||||||
{
|
{
|
||||||
return [entriesController undoManager];
|
return [entriesController undoManager];
|
||||||
|
@ -233,7 +235,6 @@
|
||||||
{
|
{
|
||||||
[super insertObjects:objects atArrangedObjectIndexes:indexes];
|
[super insertObjects:objects atArrangedObjectIndexes:indexes];
|
||||||
|
|
||||||
[self updateIndexesFromRow:[indexes firstIndex]];
|
|
||||||
[self updateTotalTime];
|
[self updateTotalTime];
|
||||||
|
|
||||||
if (shuffle == YES)
|
if (shuffle == YES)
|
||||||
|
@ -269,7 +270,6 @@
|
||||||
|
|
||||||
[super removeObjectsAtArrangedObjectIndexes:indexes];
|
[super removeObjectsAtArrangedObjectIndexes:indexes];
|
||||||
|
|
||||||
[self updateIndexesFromRow:[indexes firstIndex]];
|
|
||||||
[self updateTotalTime];
|
[self updateTotalTime];
|
||||||
|
|
||||||
if (shuffle == YES)
|
if (shuffle == YES)
|
||||||
|
@ -292,7 +292,6 @@
|
||||||
|
|
||||||
[super setSortDescriptors:sortDescriptors];
|
[super setSortDescriptors:sortDescriptors];
|
||||||
[self rearrangeObjects];
|
[self rearrangeObjects];
|
||||||
[self updateIndexesFromRow:0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)sortByPath
|
- (IBAction)sortByPath
|
||||||
|
@ -305,8 +304,6 @@
|
||||||
|
|
||||||
if (shuffle == YES)
|
if (shuffle == YES)
|
||||||
[self resetShuffleList];
|
[self resetShuffleList];
|
||||||
|
|
||||||
[self updateIndexesFromRow:0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)randomizeList
|
- (IBAction)randomizeList
|
||||||
|
@ -316,8 +313,6 @@
|
||||||
[self setContent:[Shuffle shuffleList:[self content]]];
|
[self setContent:[Shuffle shuffleList:[self content]]];
|
||||||
if (shuffle == YES)
|
if (shuffle == YES)
|
||||||
[self resetShuffleList];
|
[self resetShuffleList];
|
||||||
|
|
||||||
[self updateIndexesFromRow:0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)takeShuffleFromObject:(id)sender
|
- (IBAction)takeShuffleFromObject:(id)sender
|
||||||
|
@ -622,8 +617,6 @@
|
||||||
- (void)setFilterPredicate:(NSPredicate *)filterPredicate
|
- (void)setFilterPredicate:(NSPredicate *)filterPredicate
|
||||||
{
|
{
|
||||||
[super setFilterPredicate:filterPredicate];
|
[super setFilterPredicate:filterPredicate];
|
||||||
|
|
||||||
[self updateIndexesFromRow:0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)showEntryInFinder:(id)sender
|
- (IBAction)showEntryInFinder:(id)sender
|
||||||
|
|
Loading…
Reference in New Issue