Changeset 10105


Ignore:
Timestamp:
Feb 6, 2010, 2:35:27 AM (12 years ago)
Author:
livings124
Message:

improve how tracker tiers are sent to the inspector code

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r10097 r10105  
    676676    }
    677677    else if (tableView == fTrackerTable)
    678         return [fTrackers objectAtIndex: row];
     678    {
     679        id item = [fTrackers objectAtIndex: row];
     680       
     681        if (![item isKindOfClass: [TrackerNode class]])
     682        {
     683            NSString * tierString = [NSString stringWithFormat: NSLocalizedString(@"Tier %d", "Inspector -> tracker table"),
     684                                        [[item objectForKey: @"Tier"] integerValue]];
     685            if ([fTorrents count] > 1)
     686                tierString = [tierString stringByAppendingFormat: @" - %@", [item objectForKey: @"Name"]];
     687            return tierString;
     688        }
     689        else
     690            return item;
     691    }
    679692    return nil;
    680693}
     
    874887    //reset table with either new or old value
    875888    [fTrackers release];
    876     fTrackers = [[torrent allTrackerStatsWithTransferName: NO] retain];
     889    fTrackers = [[torrent allTrackerStats] retain];
    877890   
    878891    [fTrackerTable setTrackers: fTrackers];
     
    14831496    if ([fTrackerTable editedRow] == -1)
    14841497    {
    1485         const BOOL multiple = [fTorrents count] != 1;
    1486        
    14871498        [fTrackers release];
    1488         fTrackers = [[NSMutableArray alloc] init];
    1489         for (Torrent * torrent in fTorrents)
    1490             [fTrackers addObjectsFromArray: [torrent allTrackerStatsWithTransferName: multiple]];
     1499       
     1500        if ([fTorrents count] == 1)
     1501            fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStats] retain];
     1502        else
     1503        {
     1504            fTrackers = [[NSMutableArray alloc] init];
     1505            for (Torrent * torrent in fTorrents)
     1506                [fTrackers addObjectsFromArray: [torrent allTrackerStats]];
     1507        }
    14911508       
    14921509        [fTrackerTable setTrackers: fTrackers];
     
    15031520           
    15041521            [fTrackers release];
    1505             fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStatsWithTransferName: NO] retain];
     1522            fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStats] retain];
    15061523            [fTrackers addObjectsFromArray: tierAndTrackerBeingAdded];
    15071524           
     
    17841801    //reset table with either new or old value
    17851802    [fTrackers release];
    1786     fTrackers = [[torrent allTrackerStatsWithTransferName: NO] retain];
     1803    fTrackers = [[torrent allTrackerStats] retain];
    17871804   
    17881805    [fTrackerTable setTrackers: fTrackers];
  • trunk/macosx/Torrent.h

    r10097 r10105  
    129129- (uint64_t) sizeLeft;
    130130
    131 - (NSMutableArray *) allTrackerStatsWithTransferName: (BOOL) includeTransferName;
     131- (NSMutableArray *) allTrackerStats;
    132132- (NSArray *) allTrackersFlat; //used by GroupRules
    133133- (BOOL) addTrackerToNewTier: (NSString *) tracker;
  • trunk/macosx/Torrent.m

    r10103 r10105  
    584584}
    585585
    586 - (NSMutableArray *) allTrackerStatsWithTransferName: (BOOL) includeTransferName
     586- (NSMutableArray *) allTrackerStats
    587587{
    588588    int count;
     
    596596        if (stats[i].tier != prevTier)
    597597        {
    598             NSString * tierString = [NSString stringWithFormat: NSLocalizedString(@"Tier %d", "Inspector -> tracker table"),
    599                                         stats[i].tier];
    600             if (includeTransferName)
    601                 tierString = [tierString stringByAppendingFormat: @" - %@", [self name]];
    602            
    603             [trackers addObject: tierString];
     598            [trackers addObject: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInteger: stats[i].tier], @"Tier",
     599                                    [self name], @"Name", nil]];
    604600            prevTier = stats[i].tier;
    605601        }
  • trunk/macosx/TrackerNode.m

    r10104 r10105  
    105105    NSString * baseString;
    106106    if (fStat.hasAnnounced && fStat.lastAnnounceTimedOut)
    107     {
    108107        baseString = [NSLocalizedString(@"Announce timed out", "Tracker last announce") stringByAppendingFormat: @": %@", dateString];
    109     }
    110108    else if (fStat.hasAnnounced && !fStat.lastAnnounceSucceeded)
    111109    {
    112110        baseString = NSLocalizedString(@"Announce error", "Tracker last announce");
     111       
    113112        NSString * errorString = [NSString stringWithUTF8String: fStat.lastAnnounceResult];
    114        
    115113        if ([errorString isEqualToString: @""])
    116114            baseString = [baseString stringByAppendingFormat: @": %@", dateString];
     
    182180    {
    183181        baseString = NSLocalizedString(@"Scrape error", "Tracker last scrape");
     182       
    184183        NSString * errorString = [NSString stringWithUTF8String: fStat.lastScrapeResult];
    185        
    186184        if ([errorString isEqualToString: @""])
    187185            baseString = [baseString stringByAppendingFormat: @": %@", dateString];
Note: See TracChangeset for help on using the changeset viewer.