Changeset 1514


Ignore:
Timestamp:
Feb 23, 2007, 7:17:31 PM (15 years ago)
Author:
livings124
Message:

small efficiency change and some improvements for the invisible file checkboxes

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r1512 r1514  
    108108    [fFileOutline setDoubleAction: @selector(revealFile:)];
    109109   
     110    [[NSNotificationCenter defaultCenter] addObserver: self
     111            selector: @selector(fileFinished:) name: @"FileFinished" object: nil];
     112   
    110113    //set blank inspector
    111114    [self updateInfoForTorrents: [NSArray array]];
     
    114117- (void) dealloc
    115118{
    116     [fTorrents release];
     119    [[NSNotificationCenter defaultCenter] removeObserver: self];
     120   
     121    if (fTorrents)
     122        [fTorrents release];
    117123    if (fPeers)
    118124        [fPeers release];
     
    400406        return;
    401407   
    402     [[fTorrents objectAtIndex: 0] updateFileProgress];
    403     [fFileOutline reloadData];
     408    if ([[fTorrents objectAtIndex: 0] updateFileProgress])
     409        [fFileOutline reloadData];
    404410}
    405411
     
    711717
    712718- (void) outlineView: (NSOutlineView *) outlineView willDisplayCell: (id) cell
    713             forTableColumn: (NSTableColumn *) tableColumn item:(id) item
     719            forTableColumn: (NSTableColumn *) tableColumn item: (id) item
    714720{
    715721    if ([[tableColumn identifier] isEqualToString: @"Name"])
     
    724730    else if ([[tableColumn identifier] isEqualToString: @"Check"])
    725731    {
    726         /*[(NSButtonCell *)cell setImagePosition: item ? NSImageOnly : NSNoImage];
    727         [cell setEnabled: NO];*/
     732        /*if (!item)
     733        {
     734            [(NSButtonCell *)cell setImagePosition: NSNoImage];
     735            [cell setEnabled: NO];
     736            return;
     737        }
     738       
     739        [(NSButtonCell *)cell setImagePosition: NSImageOnly];
     740        [cell setEnabled: [[item objectForKey: @"IsFolder"] boolValue] ? [[item objectForKey: @"Remaining"] intValue] > 0
     741                                                                    : [[item objectForKey: @"Progress"] floatValue] < 1.0];*/
    728742        [(NSButtonCell *)cell setImagePosition: NSNoImage];
    729743    }
     
    737751   
    738752    [self setFileCheckState: state forItem: item];
     753    NSMutableDictionary * topItem = [self resetFileCheckStateForItemParent: item];
     754   
     755    [fFileOutline reloadItem: topItem reloadChildren: YES];
     756}
     757
     758- (void) fileFinished: (NSNotification *) notification
     759{
     760    NSMutableDictionary * item = [notification object];
     761   
     762    [item setObject: [NSNumber numberWithInt: NSOnState] forKey: @"Check"];
    739763    NSMutableDictionary * topItem = [self resetFileCheckStateForItemParent: item];
    740764   
  • trunk/macosx/Torrent.h

    r1512 r1514  
    173173- (float)       swarmSpeed;
    174174
    175 - (void) updateFileProgress;
     175- (BOOL) updateFileProgress;
    176176
    177177- (NSNumber *) orderValue;
  • trunk/macosx/Torrent.m

    r1512 r1514  
    10441044}
    10451045
    1046 - (void) updateFileProgress
    1047 {
    1048     float * progress = tr_torrentCompletion( fHandle );
     1046- (BOOL) updateFileProgress
     1047{
     1048    BOOL change = NO;
     1049    float * progress = tr_torrentCompletion(fHandle);
     1050    NSNumber * progressNum;
     1051    NSMutableDictionary * item, * dict;
    10491052   
    10501053    int i, fileCount = [self fileCount];
    10511054    for (i = 0; i < fileCount; i++)
    1052         [[fFileFlatList objectAtIndex: i] setObject: [NSNumber numberWithFloat: progress[i]] forKey: @"Progress"];
     1055    {
     1056        if (!(progressNum = [[fFileFlatList objectAtIndex: i] objectForKey: @"Progress"])
     1057                || [progressNum floatValue] != progress[i])
     1058        {
     1059            item = [fFileFlatList objectAtIndex: i];
     1060            [item setObject: [NSNumber numberWithFloat: progress[i]] forKey: @"Progress"];
     1061            change = YES;
     1062           
     1063            if (progress[i] == 1.0)
     1064            {
     1065                dict = item;
     1066                while ((dict = [dict objectForKey: @"Parent"]))
     1067                    [dict setObject: [NSNumber numberWithInt: [[dict objectForKey: @"Remaining"] intValue]-1]
     1068                            forKey: @"Remaining"];
     1069               
     1070                [[NSNotificationCenter defaultCenter] postNotificationName: @"FileFinished" object: item];
     1071            }
     1072        }
     1073    }
    10531074   
    10541075    free(progress);
     1076   
     1077    return change;
    10551078}
    10561079
     
    12571280       
    12581281        if (isFolder)
     1282        {
    12591283            [dict setObject: [NSMutableArray array] forKey: @"Children"];
     1284            [dict setObject: [NSNumber numberWithInt: 1] forKey: @"Remaining"];
     1285        }
    12601286        else
    12611287        {
     
    12701296    else
    12711297    {
     1298        if (isFolder)
     1299            [dict setObject: [NSNumber numberWithInt: [[dict objectForKey: @"Remaining"] intValue]+1] forKey: @"Remaining"];
     1300       
    12721301        int dictState = [[dict objectForKey: @"Check"] intValue];
    12731302        if (dictState != NSMixedState && dictState != state)
Note: See TracChangeset for help on using the changeset viewer.