#import "NSStringAdditions.h"
#import <Quartz/Quartz.h>
-#import "utils.h"
-
#define ROW_SMALL_HEIGHT 18.0
typedef enum
[fOutline setMenu: [self menu]];
- fLock = [[NSRecursiveLock alloc] init];
- [fLock setName: @"File Table"];
-
[self setTorrent: nil];
}
[fFileList release];
[fFilterText release];
- [fLock release];
-
[super dealloc];
}
[fFilterText release];
fFilterText = nil;
- while (![fLock tryLock])
- tr_wait_msec(100);
-
[fOutline reloadData];
[fOutline deselectAll: nil]; //do this after reloading the data #4575
-
- [fLock unlock];
}
- (void) setFilterText: (NSString *) text
const BOOL onLion = [NSApp isOnLionOrBetter];
- while (![fLock tryLock])
- tr_wait_msec(100);
-
if (onLion)
- {
- [[NSAnimationContext currentContext] setCompletionHandler: ^{ [fLock unlock]; }];
- [NSAnimationContext beginGrouping];
-
[fOutline beginUpdates];
- }
NSUInteger currentIndex = 0, totalCount = 0;
NSMutableArray * itemsToAdd = [NSMutableArray array];
[fOutline insertItemsAtIndexes: itemsToAddIndexes inParent: nil withAnimation: NSTableViewAnimationSlideUp];
if (onLion)
- {
[fOutline endUpdates];
-
- [NSAnimationContext endGrouping];
- }
else
- {
[fOutline reloadData];
- [fLock unlock];
- }
-
[fFilterText release];
fFilterText = [text retain];
}
{
[fTorrent updateFileStat];
- while (![fLock tryLock])
- tr_wait_msec(100);
-
[fOutline setNeedsDisplay: YES];
-
- [fLock unlock];
}
- (void) outlineViewSelectionDidChange: (NSNotification *) notification
- (void) setCheck: (id) sender
{
- while (![fLock tryLock])
- tr_wait_msec(100);
-
NSInteger state = [sender tag] == FILE_UNCHECK_TAG ? NSOffState : NSOnState;
NSIndexSet * indexSet = [fOutline selectedRowIndexes];
[fTorrent setFileCheckState: state forIndexes: itemIndexes];
[fOutline setNeedsDisplay: YES];
-
- [fLock unlock];
}
- (void) setOnlySelectedCheck: (id) sender
{
- while (![fLock tryLock])
- tr_wait_msec(100);
-
NSIndexSet * indexSet = [fOutline selectedRowIndexes];
NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet];
for (NSInteger i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
[fTorrent setFileCheckState: NSOffState forIndexes: remainingItemIndexes];
[fOutline setNeedsDisplay: YES];
-
- [fLock unlock];
}
- (void) setPriority: (id) sender
priority = TR_PRI_LOW;
}
- while (![fLock tryLock])
- tr_wait_msec(100);
-
NSIndexSet * indexSet = [fOutline selectedRowIndexes];
NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet];
for (NSInteger i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
[fTorrent setFilePriority: priority forIndexes: itemIndexes];
[fOutline setNeedsDisplay: YES];
-
- [fLock unlock];
}
- (void) revealFile: (id) sender
{
- while (![fLock tryLock])
- tr_wait_msec(100);
-
NSIndexSet * indexes = [fOutline selectedRowIndexes];
NSMutableArray * paths = [NSMutableArray arrayWithCapacity: [indexes count]];
for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
if ([paths count] > 0)
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: paths];
-
- [fLock unlock];
}
#warning make real view controller (Leopard-only) so that Command-R will work