Changeset 10190


Ignore:
Timestamp:
Feb 13, 2010, 4:30:47 AM (12 years ago)
Author:
livings124
Message:

add the ability to remove trackers when multiple torrents are selected

Location:
trunk/macosx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r10144 r10190  
    762762{
    763763    if ([notification object] == fTrackerTable)
    764         [fTrackerAddRemoveControl setEnabled: [fTorrents count] == 1 && [fTrackerTable numberOfSelectedRows] > 0
    765             forSegment: TRACKER_REMOVE_TAG];
     764        [fTrackerAddRemoveControl setEnabled: [fTrackerTable numberOfSelectedRows] > 0 forSegment: TRACKER_REMOVE_TAG];
    766765}
    767766
     
    17951794- (void) removeTrackers
    17961795{
    1797     NSMutableIndexSet * removeIdentifiers = [NSMutableIndexSet indexSet];
     1796    NSMutableDictionary * removeIdentifiers = [NSMutableDictionary dictionary];
    17981797   
    17991798    NSIndexSet * selectedIndexes = [fTrackerTable selectedRowIndexes];
     
    18051804        {
    18061805            if (groupSelected || [selectedIndexes containsIndex: i])
    1807                 [removeIdentifiers addIndex: [(TrackerNode *)object identifier]];
     1806            {
     1807                Torrent * torrent = [(TrackerNode *)object torrent];
     1808                NSMutableIndexSet * removeIndexSet;
     1809                if (!(removeIndexSet = [removeIdentifiers objectForKey: torrent]))
     1810                {
     1811                    removeIndexSet = [NSMutableIndexSet indexSet];
     1812                    [removeIdentifiers setObject: removeIndexSet forKey: torrent];
     1813                }
     1814               
     1815                [removeIndexSet addIndex: [(TrackerNode *)object identifier]];
     1816            }
    18081817        }
    18091818        else
     
    18491858    }
    18501859   
    1851     Torrent * torrent = [fTorrents objectAtIndex: 0];
    1852     [torrent removeTrackersWithIdentifiers: removeIdentifiers];
     1860    for (Torrent * torrent in removeIdentifiers)
     1861        [torrent removeTrackersWithIdentifiers: [removeIdentifiers objectForKey: torrent]];
    18531862   
    18541863    //reset table with either new or old value
    18551864    [fTrackers release];
    1856     fTrackers = [[torrent allTrackerStats] retain];
     1865    fTrackers = [[NSMutableArray alloc] init];
     1866    for (Torrent * torrent in fTorrents)
     1867        [fTrackers addObjectsFromArray: [torrent allTrackerStats]];
    18571868   
    18581869    [fTrackerTable setTrackers: fTrackers];
  • trunk/macosx/Torrent.h

    r10105 r10190  
    3030
    3131#warning uncomment
    32 @interface Torrent : NSObject //<QLPreviewItem>
     32@interface Torrent : NSObject <NSCopying>//, QLPreviewItem>
    3333{
    3434    tr_torrent * fHandle;
  • trunk/macosx/Torrent.m

    r10189 r10190  
    198198}
    199199
     200- (id) copyWithZone: (NSZone *) zone
     201{
     202    return [self retain];
     203}
     204
    200205- (void) closeRemoveTorrent
    201206{
     
    601606        }
    602607       
    603         TrackerNode * tracker = [[TrackerNode alloc] initWithTrackerStat: &stats[i]];
     608        TrackerNode * tracker = [[TrackerNode alloc] initWithTrackerStat: &stats[i] torrent: self];
    604609        [trackers addObject: tracker];
    605610        [tracker release];
  • trunk/macosx/TrackerNode.h

    r9931 r10190  
    2626#import <transmission.h>
    2727
     28@class Torrent;
     29
    2830@interface TrackerNode : NSObject
    2931{
    3032    tr_tracker_stat fStat;
     33   
     34    Torrent * fTorrent; //weak reference
    3135}
    3236
    33 - (id) initWithTrackerStat: (tr_tracker_stat *) stat;
     37- (id) initWithTrackerStat: (tr_tracker_stat *) stat torrent: (Torrent *) torrent;
    3438
    3539- (NSString *) host;
     
    3943
    4044- (NSUInteger) identifier;
     45
     46- (Torrent *) torrent;
    4147
    4248- (NSInteger) totalSeeders;
  • trunk/macosx/TrackerNode.m

    r10167 r10190  
    2929@implementation TrackerNode
    3030
    31 - (id) initWithTrackerStat: (tr_tracker_stat *) stat
     31- (id) initWithTrackerStat: (tr_tracker_stat *) stat torrent: (Torrent *) torrent
    3232{
    3333    if ((self = [super init]))
    3434    {
    3535        fStat = *stat;
     36        fTorrent = torrent;
    3637    }
    3738   
     
    6869{
    6970    return fStat.id;
     71}
     72
     73- (Torrent *) torrent
     74{
     75    return fTorrent;
    7076}
    7177
Note: See TracChangeset for help on using the changeset viewer.