Changeset 3250


Ignore:
Timestamp:
Oct 1, 2007, 11:34:01 AM (15 years ago)
Author:
livings124
Message:

remove "connected dot" from peer inspector, and append speed string properly to torrents with errors

Location:
trunk/macosx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.h

    r3190 r3250  
    3232{
    3333    NSArray * fTorrents, * fPeers, * fFiles;
    34     NSImage * fAppIcon, * fDotGreen, * fDotRed, * fLockImage;
     34    NSImage * fAppIcon, * fLockImage;
    3535   
    3636    BOOL fCanResizeVertical;
  • trunk/macosx/InfoWindowController.m

    r3190 r3250  
    6868    //get images
    6969    fAppIcon = [NSImage imageNamed: @"NSApplicationIcon"];
    70     fDotGreen = [NSImage imageNamed: @"GreenDot.tiff"];
    71     fDotRed = [NSImage imageNamed: @"RedDot.tiff"];
    7270   
    7371    //window location and size
     
    799797        NSDictionary * peer = [fPeers objectAtIndex: row];
    800798       
    801         if ([ident isEqualToString: @"Connected"])
    802             return [[peer objectForKey: @"Connected"] boolValue] ? fDotGreen : fDotRed;
    803         else if ([ident isEqualToString: @"Encryption"])
     799        if ([ident isEqualToString: @"Encryption"])
    804800        {
    805801            if ([[peer objectForKey: @"Encryption"] boolValue])
     
    815811            return [peer objectForKey: @"Client"];
    816812        else if  ([ident isEqualToString: @"Progress"])
    817             return [peer objectForKey: @"Progress"]; //returning nil is fine
     813            return [peer objectForKey: @"Progress"];
    818814        else if ([ident isEqualToString: @"UL To"])
    819815        {
     
    830826    }
    831827    return nil;
    832 }
    833 
    834 - (void) tableView: (NSTableView *) tableView willDisplayCell: (id) cell forTableColumn: (NSTableColumn *) tableColumn row: (int) row
    835 {
    836     if (tableView == fPeerTable)
    837     {
    838         if ([[tableColumn identifier] isEqualToString: @"Progress"])
    839             [cell setHidden: ![[[fPeers objectAtIndex: row] objectForKey: @"Connected"] boolValue]];
    840     }
    841828}
    842829
     
    855842}
    856843
    857 - (BOOL) tableView: (NSTableView *) tableView shouldSelectRow:(int) row
     844- (BOOL) tableView: (NSTableView *) tableView shouldSelectRow: (int) row
    858845{
    859846    return tableView != fPeerTable;
     
    868855        NSMutableArray * components = [NSMutableArray arrayWithCapacity: 4];
    869856       
    870         if ([[peer objectForKey: @"Connected"] boolValue])
    871         {
    872             [components addObject: [NSString stringWithFormat:
    873                                     NSLocalizedString(@"Progress: %.1f%%", "Inspector -> Peers tab -> table row tooltip"),
    874                                     [[peer objectForKey: @"Progress"] floatValue] * 100.0]];
    875            
    876             if ([[peer objectForKey: @"Encryption"] boolValue])
    877                 [components addObject: NSLocalizedString(@"Encrypted Connection", "Inspector -> Peers tab -> table row tooltip")];
    878         }
     857        [components addObject: [NSString stringWithFormat:
     858                                NSLocalizedString(@"Progress: %.1f%%", "Inspector -> Peers tab -> table row tooltip"),
     859                                [[peer objectForKey: @"Progress"] floatValue] * 100.0]];
     860       
     861        if ([[peer objectForKey: @"Encryption"] boolValue])
     862            [components addObject: NSLocalizedString(@"Encrypted Connection", "Inspector -> Peers tab -> table row tooltip")];
    879863       
    880864        int port;
     
    902886- (NSArray *) peerSortDescriptors
    903887{
    904     NSMutableArray * descriptors = [NSMutableArray array];
     888    NSMutableArray * descriptors = [NSMutableArray arrayWithCapacity: 2];
    905889   
    906890    NSArray * oldDescriptors = [fPeerTable sortDescriptors];
  • trunk/macosx/NSStringAdditions.h

    r3083 r3250  
    3636
    3737- (NSComparisonResult) compareIP: (NSString *) string;
    38 - (NSComparisonResult) clientCompare: (NSString *) string;
    3938
    4039@end
  • trunk/macosx/NSStringAdditions.m

    r3186 r3250  
    123123}
    124124
    125 - (NSComparisonResult) clientCompare: (NSString *) string
    126 {
    127     BOOL selfBlank = [self isEqualToString: @""],
    128         newBlank = [string isEqualToString: @""];
    129    
    130     if (selfBlank && newBlank)
    131         return NSOrderedSame;
    132     else if (selfBlank)
    133         return NSOrderedDescending;
    134     else if (newBlank)
    135         return NSOrderedAscending;
    136     else
    137         return [self caseInsensitiveCompare: string];
    138 }
    139 
    140125@end
  • trunk/macosx/Torrent.m

    r3241 r3250  
    804804       
    805805        dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:
    806             [NSNumber numberWithBool: peer->isConnected], @"Connected",
    807806            [NSNumber numberWithInt: peer->from], @"From",
    808807            [NSString stringWithCString: (char *) peer->addr encoding: NSUTF8StringEncoding], @"IP",
    809             [NSNumber numberWithInt: peer->port], @"Port", nil];
    810        
    811         if (peer->isConnected)
    812         {
    813             [dic setObject: [NSNumber numberWithFloat: peer->progress] forKey: @"Progress"];
    814            
    815             if (peer->isDownloading)
    816                 [dic setObject: [NSNumber numberWithFloat: peer->uploadToRate] forKey: @"UL To Rate"];
    817             if (peer->isUploading)
    818                 [dic setObject: [NSNumber numberWithFloat: peer->downloadFromRate] forKey: @"DL From Rate"];
    819            
    820             [dic setObject: [NSNumber numberWithBool: peer->isEncrypted] forKey: @"Encryption"];
    821            
    822             [dic setObject: [NSString stringWithCString: (char *)peer->client encoding: NSUTF8StringEncoding] forKey: @"Client"];
    823         }
    824         else
    825             [dic setObject: @"" forKey: @"Client"]; //needed to be set here for client sort
     808            [NSNumber numberWithInt: peer->port], @"Port",
     809            [NSNumber numberWithFloat: peer->progress], @"Progress",
     810            [NSNumber numberWithBool: peer->isEncrypted], @"Encryption",
     811            [NSString stringWithCString: (char *)peer->client encoding: NSUTF8StringEncoding], @"Client", nil];
     812       
     813        if (peer->isDownloading)
     814            [dic setObject: [NSNumber numberWithFloat: peer->uploadToRate] forKey: @"UL To Rate"];
     815        if (peer->isUploading)
     816            [dic setObject: [NSNumber numberWithFloat: peer->downloadFromRate] forKey: @"DL From Rate"];
    826817       
    827818        [peerDics addObject: dic];
     
    946937        if (fStalled)
    947938            string = [NSLocalizedString(@"Stalled, ", "Torrent -> status string") stringByAppendingString: string];
    948        
    949         //append even if error
    950         if ([self isActive] && ![self isChecking])
    951         {
    952             if (fStat->status == TR_STATUS_DOWNLOAD)
    953                 string = [string stringByAppendingFormat: @" - DL: %@, UL: %@",
    954                         [NSString stringForSpeed: [self downloadRate]], [NSString stringForSpeed: [self uploadRate]]];
    955             else
    956                 string = [string stringByAppendingFormat: @" - UL: %@", [NSString stringForSpeed: [self uploadRate]]];
    957         }
     939    }
     940   
     941    //append even if error
     942    if ([self isActive] && ![self isChecking])
     943    {
     944        if (fStat->status == TR_STATUS_DOWNLOAD)
     945            string = [string stringByAppendingFormat: @" - DL: %@, UL: %@",
     946                    [NSString stringForSpeed: [self downloadRate]], [NSString stringForSpeed: [self uploadRate]]];
     947        else
     948            string = [string stringByAppendingFormat: @" - UL: %@", [NSString stringForSpeed: [self uploadRate]]];
    958949    }
    959950   
Note: See TracChangeset for help on using the changeset viewer.