create file lists lazily

This commit is contained in:
Mitchell Livingston
2010-01-02 02:50:22 +00:00
parent 66983ddc70
commit a641d038af
3 changed files with 13 additions and 12 deletions

View File

@@ -204,9 +204,9 @@
- (void) checkGroupValueForRemoval: (NSNotification *) notification;
- (NSArray *) fileList;
- (NSArray *) flatFileList;
- (NSInteger) fileCount;
- (void) updateFileStat;
- (NSArray *) flatFileList;
//methods require fileStats to have been updated recently to be accurate
- (CGFloat) fileProgress: (FileListNode *) node;

View File

@@ -1257,9 +1257,20 @@ int trashDataFile(const char * filename)
- (NSArray *) fileList
{
if (!fFileList && ![self isMagnet])
[self createFileList];
return fFileList;
}
- (NSArray *) flatFileList
{
if (!fFlatFileList && ![self isMagnet])
[self createFileList];
return fFlatFileList;
}
- (NSInteger) fileCount
{
return fInfo->fileCount;
@@ -1294,11 +1305,6 @@ int trashDataFile(const char * filename)
return (CGFloat)have / [node size];
}
- (NSArray *) flatFileList
{
return fFlatFileList;
}
- (BOOL) canChangeDownloadCheckForFile: (NSUInteger) index
{
NSAssert2(index < [self fileCount], @"Index %d is greater than file count %d", index, [self fileCount]);
@@ -1586,9 +1592,6 @@ int trashDataFile(const char * filename)
fWaitToStart = waitToStart && [waitToStart boolValue];
fResumeOnWake = NO;
if (![self isMagnet])
[self createFileList];
fGroupValue = groupValue ? [groupValue intValue] : [[GroupsController groups] groupIndexForTorrent: self];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(checkGroupValueForRemoval:)
@@ -1737,8 +1740,6 @@ int trashDataFile(const char * filename)
{
fStat = tr_torrentStat(fHandle);
[self createFileList];
[[NSNotificationCenter defaultCenter] postNotificationName: @"ResetInspector" object: self];
}

View File

@@ -135,7 +135,7 @@
const CGFloat totalRowHeight = [self rowHeight] + [self intercellSpacing].height;
NSRect gridRects[(NSInteger)(ceil(visibleRect.size.height / totalRowHeight / 2.0)) + 1]; //add one if partial rows at top and bottom
NSRect gridRects[(NSInteger)(ceil(NSHeight(visibleRect) / totalRowHeight / 2.0)) + 1]; //add one if partial rows at top and bottom
NSInteger rectNum = 0;
if (rows.length > 0)