don't recreate the file list each view

This commit is contained in:
Mitchell Livingston 2007-01-17 20:50:42 +00:00
parent 091e3c389f
commit 5f5206a1b1
3 changed files with 37 additions and 25 deletions

View File

@ -33,6 +33,7 @@
[[self tableColumnWithIdentifier: @"Name"] setDataCell: browserCell]; [[self tableColumnWithIdentifier: @"Name"] setDataCell: browserCell];
[self setAutoresizesOutlineColumn: NO]; [self setAutoresizesOutlineColumn: NO];
[self setIndentationPerLevel: 14.0];
} }
- (void) mouseDown: (NSEvent *) event - (void) mouseDown: (NSEvent *) event

View File

@ -41,11 +41,12 @@
BOOL fPublicTorrent; BOOL fPublicTorrent;
NSString * fPublicTorrentLocation; NSString * fPublicTorrentLocation;
NSUserDefaults * fDefaults; NSUserDefaults * fDefaults;
NSImage * fIcon, * fIconFlipped, * fIconSmall; NSImage * fIcon, * fIconFlipped, * fIconSmall;
NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString; NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString;
NSArray * fFileList;
int fUploadLimit, fDownloadLimit; int fUploadLimit, fDownloadLimit;
float fRatioLimit; float fRatioLimit;

View File

@ -43,8 +43,9 @@
checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue; waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
- (NSArray *) createFileList;
- (void) insertPath: (NSMutableArray *) components withParent: (NSMutableArray *) parent - (void) insertPath: (NSMutableArray *) components withParent: (NSMutableArray *) parent
previousPath: (NSString *) previousPath fileSize: (uint64_t) size; previousPath: (NSString *) previousPath fileSize: (uint64_t) size;
- (NSImage *) advancedBar; - (NSImage *) advancedBar;
- (void) trashFile: (NSString *) path; - (void) trashFile: (NSString *) path;
@ -197,6 +198,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[fShortStatusString release]; [fShortStatusString release];
[fRemainingTimeString release]; [fRemainingTimeString release];
[fFileList release];
[fBitmap release]; [fBitmap release];
free(fPieces); free(fPieces);
} }
@ -1067,28 +1070,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
- (NSArray *) fileList - (NSArray *) fileList
{ {
int count = [self fileCount], i; return fFileList;
tr_file_t * file;
NSMutableArray * files = [NSMutableArray array], * pathComponents;
NSString * path;
for (i = 0; i < count; i++)
{
file = &fInfo->files[i];
pathComponents = [[[NSString stringWithUTF8String: file->name] pathComponents] mutableCopy];
if (fInfo->multifile)
{
path = [pathComponents objectAtIndex: 0];
[pathComponents removeObjectAtIndex: 0];
}
else
path = @"";
[self insertPath: pathComponents withParent: files previousPath: path fileSize: file->length];
[pathComponents autorelease];
}
return files;
} }
- (int) fileCount - (int) fileCount
@ -1205,6 +1187,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
fShortStatusString = [[NSMutableString alloc] initWithCapacity: 30]; fShortStatusString = [[NSMutableString alloc] initWithCapacity: 30];
fRemainingTimeString = [[NSMutableString alloc] initWithCapacity: 30]; fRemainingTimeString = [[NSMutableString alloc] initWithCapacity: 30];
fFileList = [self createFileList];
//set up advanced bar //set up advanced bar
fBitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: nil fBitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: nil
pixelsWide: MAX_PIECES pixelsHigh: BAR_HEIGHT bitsPerSample: 8 samplesPerPixel: 4 hasAlpha: YES pixelsWide: MAX_PIECES pixelsHigh: BAR_HEIGHT bitsPerSample: 8 samplesPerPixel: 4 hasAlpha: YES
@ -1219,6 +1203,32 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
return self; return self;
} }
- (NSArray *) createFileList
{
int count = [self fileCount], i;
tr_file_t * file;
NSMutableArray * files = [[NSMutableArray alloc] init], * pathComponents;
NSString * path;
for (i = 0; i < count; i++)
{
file = &fInfo->files[i];
pathComponents = [[[NSString stringWithUTF8String: file->name] pathComponents] mutableCopy];
if (fInfo->multifile)
{
path = [pathComponents objectAtIndex: 0];
[pathComponents removeObjectAtIndex: 0];
}
else
path = @"";
[self insertPath: pathComponents withParent: files previousPath: path fileSize: file->length];
[pathComponents autorelease];
}
return files;
}
- (void) insertPath: (NSMutableArray *) components withParent: (NSMutableArray *) parent - (void) insertPath: (NSMutableArray *) components withParent: (NSMutableArray *) parent
previousPath: (NSString *) previousPath fileSize: (uint64_t) size previousPath: (NSString *) previousPath fileSize: (uint64_t) size
{ {