Changeset 10097


Ignore:
Timestamp:
Feb 5, 2010, 2:51:42 AM (12 years ago)
Author:
livings124
Message:

#2860 Display trackers for all selected torrents in the inspector

Location:
trunk/macosx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/DragOverlayWindow.m

    r10027 r10097  
    3737- (id) initWithLib: (tr_session *) lib forWindow: (NSWindow *) window
    3838{
    39     if ((self = ([super initWithContentRect: NSZeroRect styleMask: NSBorderlessWindowMask
     39    if ((self = ([super initWithContentRect: [window frame] styleMask: NSBorderlessWindowMask
    4040                    backing: NSBackingStoreBuffered defer: NO])))
    4141    {
     
    6767       
    6868        [window addChildWindow: self ordered: NSWindowAbove];
    69         [self setFrame: [window frame] display: NO];
    7069       
    7170        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(resizeWindow)
  • trunk/macosx/InfoWindowController.m

    r10053 r10097  
    676676    }
    677677    else if (tableView == fTrackerTable)
    678     {
    679         id item = [fTrackers objectAtIndex: row];
    680        
    681         if ([item isKindOfClass: [NSNumber class]])
    682             return [NSString stringWithFormat: NSLocalizedString(@"Tier %d", "Inspector -> tracker table"), [item integerValue]];
    683         else
    684             return item;
    685     }
     678        return [fTrackers objectAtIndex: row];
    686679    return nil;
    687680}
     
    702695    if (tableView == fTrackerTable)
    703696    {
    704         if ([[fTrackers objectAtIndex: row] isKindOfClass: [NSNumber class]])
     697        if (![[fTrackers objectAtIndex: row] isKindOfClass: [TrackerNode class]] && [tableView editedRow] != row)
    705698            return TRACKER_GROUP_SEPARATOR_HEIGHT;
    706699    }
     
    757750{
    758751    if ([notification object] == fTrackerTable)
    759     {
    760         NSInteger numSelected = [fTrackerTable numberOfSelectedRows];
    761         [fTrackerAddRemoveControl setEnabled: numSelected > 0 forSegment: TRACKER_REMOVE_TAG];
    762     }
     752        [fTrackerAddRemoveControl setEnabled: [fTorrents count] == 1 && [fTrackerTable numberOfSelectedRows] > 0
     753            forSegment: TRACKER_REMOVE_TAG];
    763754}
    764755
     
    766757{
    767758    if (tableView == fTrackerTable)
    768         return [[fTrackers objectAtIndex: row] isKindOfClass: [NSNumber class]];
     759        return ![[fTrackers objectAtIndex: row] isKindOfClass: [TrackerNode class]] && [tableView editedRow] != row;
    769760    return NO;
    770761}
     
    858849    {
    859850        id node = [fTrackers objectAtIndex: row];
    860         if (![node isKindOfClass: [NSNumber class]])
     851        if ([node isKindOfClass: [TrackerNode class]])
    861852            return [(TrackerNode *)node fullAnnounceAddress];
    862853    }
     
    883874    //reset table with either new or old value
    884875    [fTrackers release];
    885     fTrackers = [[torrent allTrackerStats] retain];
     876    fTrackers = [[torrent allTrackerStatsWithTransferName: NO] retain];
    886877   
    887878    [fTrackerTable setTrackers: fTrackers];
     
    14861477- (void) updateInfoTracker
    14871478{
    1488     if ([fTorrents count] != 1)
     1479    if ([fTorrents count] == 0)
    14891480        return;
    1490     Torrent * torrent = [fTorrents objectAtIndex: 0];
    14911481   
    14921482    //get updated tracker stats
    14931483    if ([fTrackerTable editedRow] == -1)
    14941484    {
     1485        const BOOL multiple = [fTorrents count] != 1;
     1486       
    14951487        [fTrackers release];
    1496         fTrackers = [[torrent allTrackerStats] retain];
     1488        fTrackers = [[NSMutableArray alloc] init];
     1489        for (Torrent * torrent in fTorrents)
     1490            [fTrackers addObjectsFromArray: [torrent allTrackerStatsWithTransferName: multiple]];
    14971491       
    14981492        [fTrackerTable setTrackers: fTrackers];
     
    15011495    else
    15021496    {
     1497        NSAssert1([fTorrents count] == 1, @"Attempting to add tracker with %d transfers selected", [fTorrents count]);
     1498       
    15031499        if ([NSApp isOnSnowLeopardOrBetter])
    15041500        {
     
    15071503           
    15081504            [fTrackers release];
    1509             fTrackers = [[torrent allTrackerStats] retain];
     1505            fTrackers = [[[fTorrents objectAtIndex: 0] allTrackerStatsWithTransferName: NO] retain];
    15101506            [fTrackers addObjectsFromArray: tierAndTrackerBeingAdded];
    15111507           
     
    17181714    [[self window] makeKeyWindow];
    17191715   
    1720     [fTrackers addObject: [NSNumber numberWithInt: [(TrackerNode *)[fTrackers lastObject] tier]+1]];
     1716    [fTrackers addObject: NSLocalizedString(@"New Tier", "inspector -> add tracker")];
    17211717    [fTrackers addObject: @""];
    17221718   
     
    17361732    {
    17371733        id object = [fTrackers objectAtIndex: i];
    1738         if ([object isKindOfClass: [NSNumber class]])
     1734        if ([object isKindOfClass: [TrackerNode class]])
     1735        {
     1736            if (groupSelected || [selectedIndexes containsIndex: i])
     1737                [removeIdentifiers addIndex: [(TrackerNode *)object identifier]];
     1738        }
     1739        else
    17391740        {
    17401741            groupSelected = [selectedIndexes containsIndex: i];
    17411742            if (!groupSelected && i > [selectedIndexes lastIndex])
    17421743                break;
    1743         }
    1744         else
    1745         {
    1746             if (groupSelected || [selectedIndexes containsIndex: i])
    1747                 [removeIdentifiers addIndex: [(TrackerNode *)object identifier]];
    17481744        }
    17491745    }
     
    17881784    //reset table with either new or old value
    17891785    [fTrackers release];
    1790     fTrackers = [[torrent allTrackerStats] retain];
     1786    fTrackers = [[torrent allTrackerStatsWithTransferName: NO] retain];
    17911787   
    17921788    [fTrackerTable setTrackers: fTrackers];
  • trunk/macosx/Torrent.h

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

    r10084 r10097  
    584584}
    585585
    586 - (NSMutableArray *) allTrackerStats
     586- (NSMutableArray *) allTrackerStatsWithTransferName: (BOOL) includeTransferName
    587587{
    588588    int count;
     
    596596        if (stats[i].tier != prevTier)
    597597        {
    598             [trackers addObject: [NSNumber numberWithInteger: stats[i].tier]];
     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];
    599604            prevTier = stats[i].tier;
    600605        }
  • trunk/macosx/TrackerTableView.m

    r9852 r10097  
    5353    {
    5454        id item = [fTrackers objectAtIndex: i];
    55         if ([item isKindOfClass: [NSNumber class]])
    56         {
    57             for (++i; i < [fTrackers count] && ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]]; ++i)
     55        if (![item isKindOfClass: [TrackerNode class]])
     56        {
     57            for (++i; i < [fTrackers count] && [[fTrackers objectAtIndex: i] isKindOfClass: [TrackerNode class]]; ++i)
    5858                [addresses addObject: [(TrackerNode *)[fTrackers objectAtIndex: i] fullAnnounceAddress]];
    5959            --i;
     
    142142    {
    143143        //determine what the first row color should be
    144         if (![[fTrackers objectAtIndex: rows.location] isKindOfClass: [NSNumber class]])
     144        if ([[fTrackers objectAtIndex: rows.location] isKindOfClass: [TrackerNode class]] || [self editedRow] == rows.location)
    145145        {
    146146            for (NSInteger i = rows.location-1; i>=0; i--)
    147147            {
    148                 if ([[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]])
     148                if (![[fTrackers objectAtIndex: i] isKindOfClass: [TrackerNode class]])
    149149                    break;
    150150                start = !start;
     
    160160        for (i = rows.location; i < NSMaxRange(rows); i++)
    161161        {
    162             if ([[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]])
     162            if (![[fTrackers objectAtIndex: i] isKindOfClass: [TrackerNode class]] && [self editedRow] != i)
    163163            {
    164164                start = YES;
Note: See TracChangeset for help on using the changeset viewer.