From 5f5206a1b1c2f7a765e5e3daa7d9f809b9d6fd9d Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Wed, 17 Jan 2007 20:50:42 +0000 Subject: [PATCH] don't recreate the file list each view --- macosx/FileOutlineView.m | 1 + macosx/Torrent.h | 5 ++-- macosx/Torrent.m | 56 +++++++++++++++++++++++----------------- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/macosx/FileOutlineView.m b/macosx/FileOutlineView.m index 73b6b005b..2c90c36cb 100644 --- a/macosx/FileOutlineView.m +++ b/macosx/FileOutlineView.m @@ -33,6 +33,7 @@ [[self tableColumnWithIdentifier: @"Name"] setDataCell: browserCell]; [self setAutoresizesOutlineColumn: NO]; + [self setIndentationPerLevel: 14.0]; } - (void) mouseDown: (NSEvent *) event diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 1f75416e2..4ad2cf0bd 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -41,11 +41,12 @@ BOOL fPublicTorrent; NSString * fPublicTorrentLocation; - NSUserDefaults * fDefaults; + NSUserDefaults * fDefaults; - NSImage * fIcon, * fIconFlipped, * fIconSmall; + NSImage * fIcon, * fIconFlipped, * fIconSmall; NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString; + NSArray * fFileList; int fUploadLimit, fDownloadLimit; float fRatioLimit; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 732a33fcf..4fcf90b35 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -43,8 +43,9 @@ checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue; +- (NSArray *) createFileList; - (void) insertPath: (NSMutableArray *) components withParent: (NSMutableArray *) parent - previousPath: (NSString *) previousPath fileSize: (uint64_t) size; + previousPath: (NSString *) previousPath fileSize: (uint64_t) size; - (NSImage *) advancedBar; - (void) trashFile: (NSString *) path; @@ -197,6 +198,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 [fShortStatusString release]; [fRemainingTimeString release]; + [fFileList release]; + [fBitmap release]; free(fPieces); } @@ -1067,28 +1070,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 - (NSArray *) fileList { - int count = [self fileCount], i; - 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; + return fFileList; } - (int) fileCount @@ -1205,6 +1187,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 fShortStatusString = [[NSMutableString alloc] initWithCapacity: 30]; fRemainingTimeString = [[NSMutableString alloc] initWithCapacity: 30]; + fFileList = [self createFileList]; + //set up advanced bar fBitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: nil 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; } +- (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 previousPath: (NSString *) previousPath fileSize: (uint64_t) size {