Changeset 1553


Ignore:
Timestamp:
Mar 8, 2007, 8:15:24 PM (16 years ago)
Author:
livings124
Message:

simplify peer string creation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pex/macosx/InfoWindowController.m

    r1550 r1553  
    386386    if (active)
    387387    {
    388         int left = [torrent totalPeers], count;
    389         NSMutableString * connected = [NSMutableString stringWithFormat:
    390                                         NSLocalizedString(@"%d Connected", "Inspector -> Peers tab -> peers"), left];
    391        
    392         if (left > 0)
     388        int total = [torrent totalPeers];
     389        NSString * connected = [NSString stringWithFormat:
     390                                NSLocalizedString(@"%d Connected", "Inspector -> Peers tab -> peers"), total];
     391       
     392        if (total > 0)
    393393        {
    394             [connected appendString: @": "];
     394            NSMutableArray * components = [NSMutableArray arrayWithCapacity: 4];
     395            int count;
    395396            if ((count = [torrent totalPeersTracker]) > 0)
    396             {
    397                 [connected appendFormat: NSLocalizedString(@"%d tracker", "Inspector -> Peers tab -> peers"), count];
    398                 if ((left -= count) > 0)
    399                     [connected appendString: @", "];
    400             }
    401             if (left > 0 && (count = [torrent totalPeersIncoming]) > 0)
    402             {
    403                 [connected appendFormat: NSLocalizedString(@"%d incoming", "Inspector -> Peers tab -> peers"), count];
    404                 if ((left -= count) > 0)
    405                     [connected appendString: @", "];
    406             }
    407             if (left > 0 && (count = [torrent totalPeersPex]) > 0)
    408             {
    409                 [connected appendFormat: NSLocalizedString(@"%d PEX", "Inspector -> Peers tab -> peers"), count];
    410                 if ((left -= count) > 0)
    411                     [connected appendString: @", "];
    412             }
    413             if (left > 0 && (count = [torrent totalPeersCache]) > 0)
    414                 [connected appendFormat: NSLocalizedString(@"%d cache", "Inspector -> Peers tab -> peers"), count];
     397                [components addObject: [NSString stringWithFormat:
     398                                        NSLocalizedString(@"%d tracker", "Inspector -> Peers tab -> peers"), count]];
     399            if ((count = [torrent totalPeersIncoming]) > 0)
     400                [components addObject: [NSString stringWithFormat:
     401                                        NSLocalizedString(@"%d incoming", "Inspector -> Peers tab -> peers"), count]];
     402            if ((count = [torrent totalPeersPex]) > 0)
     403                [components addObject: [NSString stringWithFormat:
     404                                        NSLocalizedString(@"%d PEX", "Inspector -> Peers tab -> peers"), count]];
     405            if ((count = [torrent totalPeersCache]) > 0)
     406                [components addObject: [NSString stringWithFormat:
     407                                        NSLocalizedString(@"%d cache", "Inspector -> Peers tab -> peers"), count]];
     408           
     409            connected = [NSString stringWithFormat: @"%@: %@", connected, [components componentsJoinedByString: @", "]];
    415410        }
     411       
    416412        [fConnectedPeersField setStringValue: connected];
    417413    }
Note: See TracChangeset for help on using the changeset viewer.