Changeset 1512


Ignore:
Timestamp:
Feb 23, 2007, 1:40:30 PM (15 years ago)
Author:
livings124
Message:

show individual file progress in inspector

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileBrowserCell.m

    r1411 r1512  
    6161                        paragraphStyle, NSParagraphStyleAttributeName, nil];
    6262       
    63         NSString * statusString = [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]];
     63        NSString * statusString = [NSString stringWithFormat: @"%.2f%% of %@",
     64                                    100.0 * [[item objectForKey: @"Progress"] floatValue],
     65                                    [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]]];
    6466       
    6567        NSRect statusTextRect = nameTextRect;
  • trunk/macosx/InfoWindowController.m

    r1501 r1512  
    5555- (void) updateInfoActivity;
    5656- (void) updateInfoPeers;
     57- (void) updateInfoFiles;
    5758- (void) updateInfoSettings;
    5859
     
    274275        fFiles = [[torrent fileList] retain];
    275276       
     277        [self updateInfoFiles];
     278       
    276279        int fileCount = [torrent fileCount];
    277280        if (fileCount != 1)
     
    301304    else if ([ident isEqualToString: TAB_INFO_IDENT])
    302305        [self updateInfoGeneral];
     306    else if ([ident isEqualToString: TAB_FILES_IDENT])
     307        [self updateInfoFiles];
    303308    else;
    304309}
     
    388393   
    389394    [fPeerTable reloadData];
     395}
     396
     397- (void) updateInfoFiles
     398{
     399    if ([fTorrents count] != 1)
     400        return;
     401   
     402    [[fTorrents objectAtIndex: 0] updateFileProgress];
     403    [fFileOutline reloadData];
    390404}
    391405
  • trunk/macosx/Torrent.h

    r1453 r1512  
    4747    NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString;
    4848   
    49     NSArray * fFileList;
     49    NSArray * fFileList, * fFileFlatList;
    5050   
    5151    int     fUploadLimit, fDownloadLimit;
     
    173173- (float)       swarmSpeed;
    174174
     175- (void) updateFileProgress;
     176
    175177- (NSNumber *) orderValue;
    176178- (void) setOrderValue: (int) orderValue;
  • trunk/macosx/Torrent.m

    r1490 r1512  
    4242        waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
    4343
    44 - (NSArray *) createFileList;
     44- (void) createFileList;
    4545- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
    4646        withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath
    47         fileSize: (uint64_t) size state: (int) state;
     47        fileSize: (uint64_t) size state: (int) state flatList: (NSMutableArray *) flatList;
    4848- (NSImage *) advancedBar;
    4949- (void) trashFile: (NSString *) path;
     
    196196       
    197197        [fFileList release];
     198        [fFileFlatList release];
    198199       
    199200        [fBitmap release];
     
    10431044}
    10441045
     1046- (void) updateFileProgress
     1047{
     1048    float * progress = tr_torrentCompletion( fHandle );
     1049   
     1050    int i, fileCount = [self fileCount];
     1051    for (i = 0; i < fileCount; i++)
     1052        [[fFileFlatList objectAtIndex: i] setObject: [NSNumber numberWithFloat: progress[i]] forKey: @"Progress"];
     1053   
     1054    free(progress);
     1055}
     1056
    10451057- (NSNumber *) orderValue
    10461058{
     
    11671179    fRemainingTimeString = [[NSMutableString alloc] initWithCapacity: 30];
    11681180   
    1169     fFileList = [self createFileList];
     1181    [self createFileList];
    11701182   
    11711183    //set up advanced bar
     
    11831195}
    11841196
    1185 - (NSArray *) createFileList
     1197- (void) createFileList
    11861198{
    11871199    int count = [self fileCount], i;
    11881200    tr_file_t * file;
    1189     NSMutableArray * files = [[NSMutableArray alloc] init], * pathComponents;
     1201    NSMutableArray * pathComponents;
    11901202    NSString * path;
     1203   
     1204    NSMutableArray * fileList = [[NSMutableArray alloc] init],
     1205                    * fileFlatList = [[NSMutableArray alloc] initWithCapacity: count];
    11911206   
    11921207    for (i = 0; i < count; i++)
     
    12031218            path = @"";
    12041219       
    1205         [self insertPath: pathComponents forSiblings: files withParent: nil previousPath: path
    1206                 fileSize: file->length state: NSOnState];
     1220        [self insertPath: pathComponents forSiblings: fileList withParent: nil previousPath: path
     1221                fileSize: file->length state: NSOnState flatList: fileFlatList];
    12071222        [pathComponents autorelease];
    12081223    }
    1209     return files;
     1224   
     1225    fFileList = [[NSArray alloc] initWithArray: fileList];
     1226    [fileList release];
     1227    fFileFlatList = [[NSArray alloc] initWithArray: fileFlatList];
     1228    [fileFlatList release];
    12101229}
    12111230
    12121231- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
    12131232        withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath
    1214         fileSize: (uint64_t) size state: (int) state
     1233        fileSize: (uint64_t) size state: (int) state flatList: (NSMutableArray *) flatList
    12151234{
    12161235    NSString * name = [components objectAtIndex: 0];
     
    12341253                                [NSNumber numberWithBool: isFolder], @"IsFolder",
    12351254                                currentPath, @"Path", nil];
     1255       
     1256        [siblings addObject: dict];
     1257       
    12361258        if (isFolder)
    12371259            [dict setObject: [NSMutableArray array] forKey: @"Children"];
    12381260        else
     1261        {
     1262            [flatList addObject: dict];
    12391263            [dict setObject: [NSNumber numberWithUnsignedLongLong: size] forKey: @"Size"];
     1264        }
    12401265       
    12411266        if (parent)
    12421267            [dict setObject: parent forKey: @"Parent"];
    12431268        [dict setObject: [NSNumber numberWithInt: state] forKey: @"Check"];
    1244        
    1245         [siblings addObject: dict];
    12461269    }
    12471270    else
     
    12561279        [components removeObjectAtIndex: 0];
    12571280        [self insertPath: components forSiblings: [dict objectForKey: @"Children"]
    1258                 withParent: dict previousPath: currentPath fileSize: size state: state];
     1281            withParent: dict previousPath: currentPath fileSize: size state: state flatList: flatList];
    12591282    }
    12601283}
Note: See TracChangeset for help on using the changeset viewer.