source: trunk/macosx/InfoWindowController.m @ 9298

Last change on this file since 9298 was 9298, checked in by livings124, 13 years ago

phase one of moving quicklook into the controller - it's not as pretty code-wise but the behavior is a lot more consistent

  • Property svn:keywords set to Date Rev Author Id
File size: 63.6 KB
Line 
1/******************************************************************************
2 * $Id: InfoWindowController.m 9298 2009-10-11 23:16:46Z livings124 $
3 *
4 * Copyright (c) 2006-2009 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#import "InfoWindowController.h"
26#import "FileListNode.h"
27#import "FileOutlineController.h"
28#import "FileOutlineView.h"
29#import "InfoTabButtonCell.h"
30#import "NSApplicationAdditions.h"
31#import "NSStringAdditions.h"
32#import "PeerProgressIndicatorCell.h"
33#import "PiecesView.h"
34#import "Torrent.h"
35#import "TrackerCell.h"
36#import "TrackerNode.h"
37#import "TrackerTableView.h"
38#include "utils.h" //tr_getRatio()
39
40#define TAB_INFO_IDENT @"Info"
41#define TAB_ACTIVITY_IDENT @"Activity"
42#define TAB_TRACKER_IDENT @"Tracker"
43#define TAB_PEERS_IDENT @"Peers"
44#define TAB_FILES_IDENT @"Files"
45#define TAB_OPTIONS_IDENT @"Options"
46
47#define TAB_MIN_HEIGHT 250
48
49#define TRACKER_GROUP_SEPARATOR_HEIGHT 14.0
50
51#define PIECES_CONTROL_PROGRESS 0
52#define PIECES_CONTROL_AVAILABLE 1
53
54#define OPTION_POPUP_GLOBAL 0
55#define OPTION_POPUP_NO_LIMIT 1
56#define OPTION_POPUP_LIMIT 2
57
58#define OPTION_POPUP_PRIORITY_HIGH 0
59#define OPTION_POPUP_PRIORITY_NORMAL 1
60#define OPTION_POPUP_PRIORITY_LOW 2
61
62#define INVALID -99
63
64#define TRACKER_ADD_TAG 0
65#define TRACKER_REMOVE_TAG 1
66
67typedef enum
68{
69    TAB_INFO_TAG = 0,
70    TAB_ACTIVITY_TAG = 1,
71    TAB_TRACKER_TAG = 2,
72    TAB_PEERS_TAG = 3,
73    TAB_FILES_TAG = 4,
74    TAB_OPTIONS_TAG = 5
75} tabTag;
76
77@interface InfoWindowController (Private)
78
79- (void) updateInfoGeneral;
80- (void) updateInfoActivity;
81- (void) updateInfoTracker;
82- (void) updateInfoPeers;
83- (void) updateInfoFiles;
84
85- (NSView *) tabViewForTag: (NSInteger) tag;
86- (void) setWebSeedTableHidden: (BOOL) hide animate: (BOOL) animate;
87- (NSArray *) peerSortDescriptors;
88
89- (BOOL) canQuickLookFile: (FileListNode *) item;
90
91- (void) addTrackers;
92- (void) removeTrackers;
93
94@end
95
96@implementation InfoWindowController
97
98- (id) init
99{
100    if ((self = [super initWithWindowNibName: @"InfoWindow"]))
101    {
102        fTrackerCell = [[TrackerCell alloc] init];
103    }
104   
105    return self;
106}
107
108- (void) awakeFromNib
109{
110    //window location and size
111    NSPanel * window = (NSPanel *)[self window];
112   
113    CGFloat windowHeight = [window frame].size.height;
114   
115    [window setFrameAutosaveName: @"InspectorWindow"];
116    [window setFrameUsingName: @"InspectorWindow"];
117   
118    NSRect windowRect = [window frame];
119    windowRect.origin.y -= windowHeight - windowRect.size.height;
120    windowRect.size.height = windowHeight;
121    [window setFrame: windowRect display: NO];
122   
123    [window setBecomesKeyOnlyIfNeeded: YES];
124   
125    //set tab images and tooltips
126    [[fTabMatrix cellWithTag: TAB_INFO_TAG] setIcon: [NSImage imageNamed: @"InfoGeneral.png"]];
127    [[fTabMatrix cellWithTag: TAB_ACTIVITY_TAG] setIcon: [NSImage imageNamed: @"InfoActivity.png"]];
128    [[fTabMatrix cellWithTag: TAB_TRACKER_TAG] setIcon: [NSImage imageNamed: @"InfoTracker.png"]];
129    [[fTabMatrix cellWithTag: TAB_PEERS_TAG] setIcon: [NSImage imageNamed: @"InfoPeers.png"]];
130    [[fTabMatrix cellWithTag: TAB_FILES_TAG] setIcon: [NSImage imageNamed: @"InfoFiles.png"]];
131    [[fTabMatrix cellWithTag: TAB_OPTIONS_TAG] setIcon: [NSImage imageNamed: @"InfoOptions.png"]];
132   
133    //set selected tab
134    fCurrentTabTag = INVALID;
135    NSString * identifier = [[NSUserDefaults standardUserDefaults] stringForKey: @"InspectorSelected"];
136    NSInteger tag;
137    if ([identifier isEqualToString: TAB_INFO_IDENT])
138        tag = TAB_INFO_TAG;
139    else if ([identifier isEqualToString: TAB_ACTIVITY_IDENT])
140        tag = TAB_ACTIVITY_TAG;
141    else if ([identifier isEqualToString: TAB_TRACKER_IDENT])
142        tag = TAB_TRACKER_TAG;
143    else if ([identifier isEqualToString: TAB_PEERS_IDENT])
144        tag = TAB_PEERS_TAG;
145    else if ([identifier isEqualToString: TAB_FILES_IDENT])
146        tag = TAB_FILES_TAG;
147    else if ([identifier isEqualToString: TAB_OPTIONS_IDENT])
148        tag = TAB_OPTIONS_TAG;
149    else //safety
150    {
151        [[NSUserDefaults standardUserDefaults] setObject: TAB_INFO_IDENT forKey: @"InspectorSelected"];
152        tag = TAB_INFO_TAG;
153    }
154    [fTabMatrix selectCellWithTag: tag];
155    [self setTab: nil];
156   
157    //reset images for reveal button, since the images are also used in the main table
158    NSImage * revealOn = [[NSImage imageNamed: @"RevealOn.png"] copy],
159            * revealOff = [[NSImage imageNamed: @"RevealOff.png"] copy];
160    if (![NSApp isOnSnowLeopardOrBetter])
161    {
162        [revealOn setFlipped: NO];
163        [revealOff setFlipped: NO];
164    }
165   
166    [fRevealDataButton setImage: revealOff];
167    [fRevealDataButton setAlternateImage: revealOn];
168   
169    [revealOn release];
170    [revealOff release];
171   
172    //initially sort peer table by IP
173    if ([[fPeerTable sortDescriptors] count] == 0)
174        [fPeerTable setSortDescriptors: [NSArray arrayWithObject: [[fPeerTable tableColumnWithIdentifier: @"IP"]
175                                            sortDescriptorPrototype]]];
176   
177    //initially sort webseed table by address
178    if ([[fWebSeedTable sortDescriptors] count] == 0)
179        [fWebSeedTable setSortDescriptors: [NSArray arrayWithObject: [[fWebSeedTable tableColumnWithIdentifier: @"Address"]
180                                            sortDescriptorPrototype]]];
181   
182    //set table header tool tips
183    [[fPeerTable tableColumnWithIdentifier: @"Encryption"] setHeaderToolTip: NSLocalizedString(@"Encrypted Connection",
184                                                                        "inspector -> peer table -> header tool tip")];
185    [[fPeerTable tableColumnWithIdentifier: @"Progress"] setHeaderToolTip: NSLocalizedString(@"Available",
186                                                                        "inspector -> peer table -> header tool tip")];
187    [[fPeerTable tableColumnWithIdentifier: @"UL To"] setHeaderToolTip: NSLocalizedString(@"Uploading To Peer",
188                                                                        "inspector -> peer table -> header tool tip")];
189    [[fPeerTable tableColumnWithIdentifier: @"DL From"] setHeaderToolTip: NSLocalizedString(@"Downloading From Peer",
190                                                                        "inspector -> peer table -> header tool tip")];
191   
192    [[fWebSeedTable tableColumnWithIdentifier: @"DL From"] setHeaderToolTip: NSLocalizedString(@"Downloading From Web Seed",
193                                                                        "inspector -> web seed table -> header tool tip")];
194   
195    //prepare for animating peer table and web seed table
196    NSRect webSeedTableFrame = [[fWebSeedTable enclosingScrollView] frame];
197    fWebSeedTableHeight = webSeedTableFrame.size.height;
198    fSpaceBetweenWebSeedAndPeer = webSeedTableFrame.origin.y - NSMaxY([[fPeerTable enclosingScrollView] frame]);
199   
200    [self setWebSeedTableHidden: YES animate: NO];
201   
202    //set blank inspector
203    [self setInfoForTorrents: [NSArray array]];
204   
205    //allow for update notifications
206    NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
207    [nc addObserver: self selector: @selector(updateInfoStats) name: @"UpdateStats" object: nil];
208    [nc addObserver: self selector: @selector(updateOptions) name: @"UpdateOptions" object: nil];
209}
210
211- (void) dealloc
212{
213    //save resizeable view height
214    NSString * resizeSaveKey = nil;
215    switch (fCurrentTabTag)
216    {
217        case TAB_TRACKER_TAG:
218            resizeSaveKey = @"InspectorContentHeightTracker";
219            break;
220        case TAB_PEERS_TAG:
221            resizeSaveKey = @"InspectorContentHeightPeers";
222            break;
223        case TAB_FILES_TAG:
224            resizeSaveKey = @"InspectorContentHeightFiles";
225            break;
226    }
227    if (resizeSaveKey)
228        [[NSUserDefaults standardUserDefaults] setFloat: [[self tabViewForTag: fCurrentTabTag] frame].size.height forKey: resizeSaveKey];
229   
230    [[NSNotificationCenter defaultCenter] removeObserver: self];
231   
232    [fTorrents release];
233    [fPeers release];
234    [fWebSeeds release];
235    [fTrackers release];
236   
237    [fWebSeedTableAnimation release];
238   
239    [fTrackerCell release];
240   
241    [fPreviewPanel release];
242   
243    [super dealloc];
244}
245
246- (void) setInfoForTorrents: (NSArray *) torrents
247{
248    if (fTorrents && [fTorrents isEqualToArray: torrents])
249        return;
250   
251    [fTorrents release];
252    fTorrents = [torrents retain];
253
254    NSUInteger numberSelected = [fTorrents count];
255    if (numberSelected != 1)
256    {
257        if (numberSelected > 0)
258        {
259            [fImageView setImage: [NSImage imageNamed: NSImageNameMultipleDocuments]];
260           
261            [fNameField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d Torrents Selected",
262                                            "Inspector -> selected torrents"), numberSelected]];
263       
264            uint64_t size = 0;
265            NSInteger fileCount = 0;
266            for (Torrent * torrent in torrents)
267            {
268                size += [torrent size];
269                fileCount += [torrent fileCount];
270            }
271           
272            [fBasicInfoField setStringValue: [NSString stringWithFormat: @"%@, %@",
273                [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> selected torrents"), fileCount],
274                [NSString stringWithFormat: NSLocalizedString(@"%@ total", "Inspector -> selected torrents"),
275                [NSString stringForFileSize: size]]]];
276            [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%llu bytes", "Inspector -> selected torrents"),
277                                            size]];
278        }
279        else
280        {
281            [fImageView setImage: [NSImage imageNamed: @"NSApplicationIcon"]];
282           
283            [fNameField setStringValue: NSLocalizedString(@"No Torrents Selected", "Inspector -> selected torrents")];
284            [fBasicInfoField setStringValue: @""];
285            [fBasicInfoField setToolTip: @""];
286   
287            [fHaveField setStringValue: @""];
288            [fDownloadedTotalField setStringValue: @""];
289            [fUploadedTotalField setStringValue: @""];
290            [fFailedHashField setStringValue: @""];
291            [fDateActivityField setStringValue: @""];
292            [fRatioField setStringValue: @""];
293           
294            //options fields
295            [fUploadLimitCheck setEnabled: NO];
296            [fUploadLimitCheck setState: NSOffState];
297            [fUploadLimitField setEnabled: NO];
298            [fUploadLimitLabel setEnabled: NO];
299            [fUploadLimitField setStringValue: @""];
300           
301            [fDownloadLimitCheck setEnabled: NO];
302            [fDownloadLimitCheck setState: NSOffState];
303            [fDownloadLimitField setEnabled: NO];
304            [fDownloadLimitLabel setEnabled: NO];
305            [fDownloadLimitField setStringValue: @""];
306           
307            [fGlobalLimitCheck setEnabled: NO];
308            [fGlobalLimitCheck setState: NSOffState];
309           
310            [fPriorityPopUp setEnabled: NO];
311            [fPriorityPopUp selectItemAtIndex: -1];
312           
313            [fRatioPopUp setEnabled: NO];
314            [fRatioPopUp selectItemAtIndex: -1];
315            [fRatioLimitField setHidden: YES];
316            [fRatioLimitField setStringValue: @""];
317           
318            [fPeersConnectField setEnabled: NO];
319            [fPeersConnectField setStringValue: @""];
320            [fPeersConnectLabel setEnabled: NO];
321        }
322       
323        [fFileController setTorrent: nil];
324       
325        [fNameField setToolTip: nil];
326
327        [fPiecesField setStringValue: @""];
328        [fHashField setStringValue: @""];
329        [fHashField setToolTip: nil];
330        [fSecureField setStringValue: @""];
331        [fCommentView setString: @""];
332       
333        [fCreatorField setStringValue: @""];
334        [fDateCreatedField setStringValue: @""];
335        [fCommentView setSelectable: NO];
336       
337        [fDataLocationField setStringValue: @""];
338        [fDataLocationField setToolTip: nil];
339       
340        [fRevealDataButton setHidden: YES];
341       
342        //don't allow empty fields to be selected
343        [fHashField setSelectable: NO];
344        [fCreatorField setSelectable: NO];
345        [fDataLocationField setSelectable: NO];
346       
347        [fStateField setStringValue: @""];
348        [fProgressField setStringValue: @""];
349       
350        [fSwarmSpeedField setStringValue: @""];
351        [fErrorMessageView setString: @""];
352        [fErrorMessageView setSelectable: NO];
353       
354        [fConnectedPeersField setStringValue: @""];
355        [fDownloadingFromField setStringValue: @""];
356        [fUploadingToField setStringValue: @""];
357        [fKnownField setStringValue: @""];
358       
359        [fDateAddedField setStringValue: @""];
360        [fDateCompletedField setStringValue: @""];
361       
362        [fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_AVAILABLE];
363        [fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_PROGRESS];
364        [fPiecesControl setEnabled: NO];
365        [fPiecesView setTorrent: nil];
366       
367        [fPeers release];
368        fPeers = nil;
369        [fPeerTable reloadData];
370       
371        [fWebSeeds release];
372        fWebSeeds = nil;
373        [fWebSeedTable reloadData];
374        [self setWebSeedTableHidden: YES animate: YES];
375       
376        [fTrackerTable setTorrent: nil];
377       
378        [fTrackers release];
379        fTrackers = nil;
380       
381        [fTrackerTable setTrackers: fTrackers];
382        [fTrackerTable reloadData];
383       
384        [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_ADD_TAG];
385        [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
386       
387        [fFileFilterField setEnabled: NO];
388    }
389    else
390    {
391        Torrent * torrent = [fTorrents objectAtIndex: 0];
392       
393        [fFileController setTorrent: torrent];
394       
395        if ([NSApp isOnSnowLeopardOrBetter])
396            [fImageView setImage: [torrent icon]];
397        else
398        {
399            NSImage * icon = [[torrent icon] copy];
400            [icon setFlipped: NO];
401            [fImageView setImage: icon];
402            [icon release];
403        }
404       
405        NSString * name = [torrent name];
406        [fNameField setStringValue: name];
407        [fNameField setToolTip: name];
408       
409        NSString * basicString = [NSString stringForFileSize: [torrent size]];
410        if ([torrent isFolder])
411        {
412            NSString * fileString;
413            NSInteger fileCount = [torrent fileCount];
414            if (fileCount == 1)
415                fileString = NSLocalizedString(@"1 file", "Inspector -> selected torrents");
416            else
417                fileString= [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> selected torrents"), fileCount];
418            basicString = [NSString stringWithFormat: @"%@, %@", fileString, basicString];
419        }
420        [fBasicInfoField setStringValue: basicString];
421        [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%llu bytes", "Inspector -> selected torrents"),
422                                        [torrent size]]];
423       
424        NSString * hashString = [torrent hashString];
425        [fPiecesField setStringValue: [NSString stringWithFormat: @"%d, %@", [torrent pieceCount],
426                                        [NSString stringForFileSize: [torrent pieceSize]]]];
427        [fHashField setStringValue: hashString];
428        [fHashField setToolTip: hashString];
429        [fSecureField setStringValue: [torrent privateTorrent]
430                        ? NSLocalizedString(@"Private Torrent, PEX and DHT automatically disabled", "Inspector -> private torrent")
431                        : NSLocalizedString(@"Public Torrent", "Inspector -> private torrent")];
432       
433        NSString * commentString = [torrent comment];
434        [fCommentView setString: commentString];
435       
436        NSString * creatorString = [torrent creator];
437        [fCreatorField setStringValue: creatorString];
438        [fDateCreatedField setObjectValue: [torrent dateCreated]];
439       
440        [fDateAddedField setObjectValue: [torrent dateAdded]];
441       
442        [fRevealDataButton setHidden: NO];
443       
444        //allow these fields to be selected
445        [fHashField setSelectable: YES];
446        [fCommentView setSelectable: ![commentString isEqualToString: @""]];
447        [fCreatorField setSelectable: ![creatorString isEqualToString: @""]];
448        [fDataLocationField setSelectable: YES];
449       
450        //set pieces view
451        BOOL piecesAvailableSegment = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
452        [fPiecesControl setSelected: piecesAvailableSegment forSegment: PIECES_CONTROL_AVAILABLE];
453        [fPiecesControl setSelected: !piecesAvailableSegment forSegment: PIECES_CONTROL_PROGRESS];
454        [fPiecesControl setEnabled: YES];
455        [fPiecesView setTorrent: torrent];
456       
457        //get webseeds for table - if no webseeds for this torrent, clear the table
458        BOOL hasWebSeeds = [torrent webSeedCount] > 0;
459        [self setWebSeedTableHidden: !hasWebSeeds animate: YES];
460        if (!hasWebSeeds)
461        {
462            [fWebSeeds release];
463            fWebSeeds = nil;
464            [fWebSeedTable reloadData];
465        }
466       
467        [fTrackerTable setTorrent: torrent];
468        [fTrackerTable deselectAll: self];
469        [fTrackerAddRemoveControl setEnabled: YES forSegment: TRACKER_ADD_TAG];
470        [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
471
472        [fFileFilterField setEnabled: [torrent isFolder]];
473    }
474   
475    [fFileFilterField setStringValue: @""];
476   
477    //update stats and settings
478    [self updateInfoStats];
479    [self updateOptions];
480}
481
482- (void) updateInfoStats
483{
484    switch ([fTabMatrix selectedTag])
485    {
486        case TAB_INFO_TAG:
487            [self updateInfoGeneral];
488            break;
489        case TAB_ACTIVITY_TAG:
490            [self updateInfoActivity];
491            break;
492        case TAB_TRACKER_TAG:
493            [self updateInfoTracker];
494            break;
495        case TAB_PEERS_TAG:
496            [self updateInfoPeers];
497            break;
498        case TAB_FILES_TAG:
499            [self updateInfoFiles];
500            break;
501    }
502}
503
504- (void) updateOptions
505{
506    if ([fTorrents count] == 0)
507        return;
508   
509    //get bandwidth info
510    NSEnumerator * enumerator = [fTorrents objectEnumerator];
511    Torrent * torrent = [enumerator nextObject]; //first torrent
512   
513    NSInteger uploadUseSpeedLimit = [torrent usesSpeedLimit: YES] ? NSOnState : NSOffState,
514                uploadSpeedLimit = [torrent speedLimit: YES],
515                downloadUseSpeedLimit = [torrent usesSpeedLimit: NO] ? NSOnState : NSOffState,
516                downloadSpeedLimit = [torrent speedLimit: NO],
517                globalUseSpeedLimit = [torrent usesGlobalSpeedLimit] ? NSOnState : NSOffState;
518   
519    while ((torrent = [enumerator nextObject])
520            && (uploadUseSpeedLimit != NSMixedState || uploadSpeedLimit != INVALID
521                || downloadUseSpeedLimit != NSMixedState || downloadSpeedLimit != INVALID
522                || globalUseSpeedLimit != NSMixedState))
523    {
524        if (uploadUseSpeedLimit != NSMixedState && uploadUseSpeedLimit != ([torrent usesSpeedLimit: YES] ? NSOnState : NSOffState))
525            uploadUseSpeedLimit = NSMixedState;
526       
527        if (uploadSpeedLimit != INVALID && uploadSpeedLimit != [torrent speedLimit: YES])
528            uploadSpeedLimit = INVALID;
529       
530        if (downloadUseSpeedLimit != NSMixedState && downloadUseSpeedLimit != ([torrent usesSpeedLimit: NO] ? NSOnState : NSOffState))
531            downloadUseSpeedLimit = NSMixedState;
532       
533        if (downloadSpeedLimit != INVALID && downloadSpeedLimit != [torrent speedLimit: NO])
534            downloadSpeedLimit = INVALID;
535       
536        if (globalUseSpeedLimit != NSMixedState && globalUseSpeedLimit != ([torrent usesGlobalSpeedLimit] ? NSOnState : NSOffState))
537            globalUseSpeedLimit = NSMixedState;
538    }
539   
540    //set upload view
541    [fUploadLimitCheck setState: uploadUseSpeedLimit];
542    [fUploadLimitCheck setEnabled: YES];
543   
544    [fUploadLimitLabel setEnabled: uploadUseSpeedLimit == NSOnState];
545    [fUploadLimitField setEnabled: uploadUseSpeedLimit == NSOnState];
546    if (uploadSpeedLimit != INVALID)
547        [fUploadLimitField setIntValue: uploadSpeedLimit];
548    else
549        [fUploadLimitField setStringValue: @""];
550   
551    //set download view
552    [fDownloadLimitCheck setState: downloadUseSpeedLimit];
553    [fDownloadLimitCheck setEnabled: YES];
554   
555    [fDownloadLimitLabel setEnabled: downloadUseSpeedLimit == NSOnState];
556    [fDownloadLimitField setEnabled: downloadUseSpeedLimit == NSOnState];
557    if (downloadSpeedLimit != INVALID)
558        [fDownloadLimitField setIntValue: downloadSpeedLimit];
559    else
560        [fDownloadLimitField setStringValue: @""];
561   
562    //set global check
563    [fGlobalLimitCheck setState: globalUseSpeedLimit];
564    [fGlobalLimitCheck setEnabled: YES];
565   
566    //get ratio info
567    enumerator = [fTorrents objectEnumerator];
568    torrent = [enumerator nextObject]; //first torrent
569   
570    NSInteger checkRatio = [torrent ratioSetting];
571    CGFloat ratioLimit = [torrent ratioLimit];
572   
573    while ((torrent = [enumerator nextObject]) && (checkRatio != INVALID || ratioLimit != INVALID))
574    {
575        if (checkRatio != INVALID && checkRatio != [torrent ratioSetting])
576            checkRatio = INVALID;
577       
578        if (ratioLimit != INVALID && ratioLimit != [torrent ratioLimit])
579            ratioLimit = INVALID;
580    }
581   
582    //set ratio view
583    NSInteger index;
584    if (checkRatio == TR_RATIOLIMIT_SINGLE)
585        index = OPTION_POPUP_LIMIT;
586    else if (checkRatio == TR_RATIOLIMIT_UNLIMITED)
587        index = OPTION_POPUP_NO_LIMIT;
588    else if (checkRatio == TR_RATIOLIMIT_GLOBAL)
589        index = OPTION_POPUP_GLOBAL;
590    else
591        index = -1;
592    [fRatioPopUp selectItemAtIndex: index];
593    [fRatioPopUp setEnabled: YES];
594   
595    [fRatioLimitField setHidden: checkRatio != TR_RATIOLIMIT_SINGLE];
596    if (ratioLimit != INVALID)
597        [fRatioLimitField setFloatValue: ratioLimit];
598    else
599        [fRatioLimitField setStringValue: @""];
600   
601    //get priority info
602    enumerator = [fTorrents objectEnumerator];
603    torrent = [enumerator nextObject]; //first torrent
604   
605    NSInteger priority = [torrent priority];
606   
607    while ((torrent = [enumerator nextObject]) && priority != INVALID)
608    {
609        if (priority != INVALID && priority != [torrent priority])
610            priority = INVALID;
611    }
612   
613    //set priority view
614    if (priority == TR_PRI_HIGH)
615        index = OPTION_POPUP_PRIORITY_HIGH;
616    else if (priority == TR_PRI_NORMAL)
617        index = OPTION_POPUP_PRIORITY_NORMAL;
618    else if (priority == TR_PRI_LOW)
619        index = OPTION_POPUP_PRIORITY_LOW;
620    else
621        index = -1;
622    [fPriorityPopUp selectItemAtIndex: index];
623    [fPriorityPopUp setEnabled: YES];
624   
625    //get peer info
626    enumerator = [fTorrents objectEnumerator];
627    torrent = [enumerator nextObject]; //first torrent
628   
629    NSInteger maxPeers = [torrent maxPeerConnect];
630   
631    while ((torrent = [enumerator nextObject]))
632    {
633        if (maxPeers != [torrent maxPeerConnect])
634        {
635            maxPeers = INVALID;
636            break;
637        }
638    }
639   
640    //set peer view
641    [fPeersConnectField setEnabled: YES];
642    [fPeersConnectLabel setEnabled: YES];
643    if (maxPeers != INVALID)
644        [fPeersConnectField setIntValue: maxPeers];
645    else
646        [fPeersConnectField setStringValue: @""];
647}
648
649- (NSRect) windowWillUseStandardFrame: (NSWindow *) window defaultFrame: (NSRect) defaultFrame
650{
651    NSRect windowRect = [window frame];
652    windowRect.size.width = [window minSize].width;
653    return windowRect;
654}
655
656- (void) animationDidEnd: (NSAnimation *) animation
657{
658    if (animation == fWebSeedTableAnimation)
659    {
660        [fWebSeedTableAnimation release];
661        fWebSeedTableAnimation = nil;
662    }
663}
664
665- (NSSize) windowWillResize: (NSWindow *) window toSize: (NSSize) proposedFrameSize
666{
667    //this is an edge-case - just stop the animation (stopAnimation jumps to end frame)
668    if (fWebSeedTableAnimation)
669    {
670        [fWebSeedTableAnimation stopAnimation];
671        [fWebSeedTableAnimation release];
672        fWebSeedTableAnimation = nil;
673    }
674   
675    return proposedFrameSize;
676}
677
678- (void) setTab: (id) sender
679{
680    const NSInteger oldTabTag = fCurrentTabTag;
681    fCurrentTabTag = [fTabMatrix selectedTag];
682    if (fCurrentTabTag == oldTabTag)
683        return;
684   
685    [self updateInfoStats];
686   
687    //take care of old view
688    CGFloat oldHeight = 0;
689    NSString * oldResizeSaveKey = nil;
690    if (oldTabTag != INVALID)
691    {
692        //deselect old tab item
693        [(InfoTabButtonCell *)[fTabMatrix cellWithTag: oldTabTag] setSelectedTab: NO];
694       
695        switch (oldTabTag)
696        {
697            case TAB_ACTIVITY_TAG:
698                [fPiecesView clearView];
699                break;
700           
701            case TAB_TRACKER_TAG:
702                oldResizeSaveKey = @"InspectorContentHeightTracker";
703                break;
704           
705            case TAB_PEERS_TAG:
706                //if in the middle of animating, just stop and resize immediately
707                if (fWebSeedTableAnimation)
708                    [self setWebSeedTableHidden: !fWebSeeds animate: NO];
709               
710                [fPeers release];
711                fPeers = nil;
712                [fWebSeeds release];
713                fWebSeeds = nil;
714               
715                oldResizeSaveKey = @"InspectorContentHeightPeers";
716                break;
717           
718            case TAB_FILES_TAG:
719                oldResizeSaveKey = @"InspectorContentHeightFiles";
720                break;
721        }
722       
723        NSView * oldView = [self tabViewForTag: oldTabTag];
724        oldHeight = [oldView frame].size.height;
725        if (oldResizeSaveKey)
726            [[NSUserDefaults standardUserDefaults] setFloat: oldHeight forKey: oldResizeSaveKey];
727       
728        //remove old view
729        [oldView setHidden: YES];
730        [oldView removeFromSuperview];
731    }
732   
733    //set new tab item
734    NSView * view = [self tabViewForTag: fCurrentTabTag];
735   
736    NSString * resizeSaveKey = nil;
737    NSString * identifier, * title;
738    switch (fCurrentTabTag)
739    {
740        case TAB_INFO_TAG:
741            identifier = TAB_INFO_IDENT;
742            title = NSLocalizedString(@"General Info", "Inspector -> title");
743            break;
744        case TAB_ACTIVITY_TAG:
745            identifier = TAB_ACTIVITY_IDENT;
746            title = NSLocalizedString(@"Activity", "Inspector -> title");
747            break;
748        case TAB_TRACKER_TAG:
749            identifier = TAB_TRACKER_IDENT;
750            title = NSLocalizedString(@"Tracker", "Inspector -> title");
751            resizeSaveKey = @"InspectorContentHeightTracker";
752            break;
753        case TAB_PEERS_TAG:
754            identifier = TAB_PEERS_IDENT;
755            title = NSLocalizedString(@"Peers", "Inspector -> title");
756            resizeSaveKey = @"InspectorContentHeightPeers";
757            break;
758        case TAB_FILES_TAG:
759            identifier = TAB_FILES_IDENT;
760            title = NSLocalizedString(@"Files", "Inspector -> title");
761            resizeSaveKey = @"InspectorContentHeightFiles";
762            break;
763        case TAB_OPTIONS_TAG:
764            identifier = TAB_OPTIONS_IDENT;
765            title = NSLocalizedString(@"Options", "Inspector -> title");
766            break;
767        default:
768            NSAssert1(NO, @"Unknown info tab selected: %d", fCurrentTabTag);
769            return;
770    }
771   
772    [[NSUserDefaults standardUserDefaults] setObject: identifier forKey: @"InspectorSelected"];
773   
774    NSWindow * window = [self window];
775   
776    [window setTitle: [NSString stringWithFormat: @"%@ - %@", title, NSLocalizedString(@"Torrent Inspector", "Inspector -> title")]];
777   
778    //selected tab item
779    [(InfoTabButtonCell *)[fTabMatrix selectedCell] setSelectedTab: YES];
780   
781    NSRect windowRect = [window frame], viewRect = [view frame];
782   
783    if (resizeSaveKey)
784    {
785        CGFloat height = [[NSUserDefaults standardUserDefaults] floatForKey: resizeSaveKey];
786        if (height != 0.0)
787            viewRect.size.height = MAX(height, TAB_MIN_HEIGHT);
788    }
789   
790    CGFloat difference = (viewRect.size.height - oldHeight) * [window userSpaceScaleFactor];
791    windowRect.origin.y -= difference;
792    windowRect.size.height += difference;
793   
794    if (resizeSaveKey)
795    {
796        if (!oldResizeSaveKey)
797        {
798            [window setMinSize: NSMakeSize([window minSize].width, windowRect.size.height - viewRect.size.height + TAB_MIN_HEIGHT)];
799            [window setMaxSize: NSMakeSize(FLT_MAX, FLT_MAX)];
800        }
801    }
802    else
803    {
804        [window setMinSize: NSMakeSize([window minSize].width, windowRect.size.height)];
805        [window setMaxSize: NSMakeSize(FLT_MAX, windowRect.size.height)];
806    }
807   
808    viewRect.size.width = windowRect.size.width;
809    [view setFrame: viewRect];
810   
811    [window setFrame: windowRect display: YES animate: oldTabTag != INVALID];
812    [[window contentView] addSubview: view];
813    [view setHidden: NO];
814   
815    #warning take a look at
816    if ([NSApp isOnSnowLeopardOrBetter] && (fCurrentTabTag == TAB_FILES_TAG || oldTabTag == TAB_FILES_TAG)
817        && ([QLPreviewPanelSL sharedPreviewPanelExists] && [[QLPreviewPanelSL sharedPreviewPanel] isVisible]))
818        [[QLPreviewPanelSL sharedPreviewPanel] updateController];
819}
820
821- (void) setNextTab
822{
823    NSInteger tag = [fTabMatrix selectedTag]+1;
824    if (tag >= [fTabMatrix numberOfColumns])
825        tag = 0;
826   
827    [fTabMatrix selectCellWithTag: tag];
828    [self setTab: nil];
829}
830
831- (void) setPreviousTab
832{
833    NSInteger tag = [fTabMatrix selectedTag]-1;
834    if (tag < 0)
835        tag = [fTabMatrix numberOfColumns]-1;
836   
837    [fTabMatrix selectCellWithTag: tag];
838    [self setTab: nil];
839}
840
841- (NSInteger) numberOfRowsInTableView: (NSTableView *) tableView
842{
843    if (tableView == fPeerTable)
844        return fPeers ? [fPeers count] : 0;
845    else if (tableView == fWebSeedTable)
846        return fWebSeeds ? [fWebSeeds count] : 0;
847    else if (tableView == fTrackerTable)
848        return fTrackers ? [fTrackers count] : 0;
849    return 0;
850}
851
852- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (NSInteger) row
853{
854    if (tableView == fPeerTable)
855    {
856        NSString * ident = [column identifier];
857        NSDictionary * peer = [fPeers objectAtIndex: row];
858       
859        if ([ident isEqualToString: @"Encryption"])
860            return [[peer objectForKey: @"Encryption"] boolValue] ? [NSImage imageNamed: @"Lock.png"] : nil;
861        else if ([ident isEqualToString: @"Client"])
862            return [peer objectForKey: @"Client"];
863        else if  ([ident isEqualToString: @"Progress"])
864            return [peer objectForKey: @"Progress"];
865        else if ([ident isEqualToString: @"UL To"])
866        {
867            NSNumber * rate;
868            return (rate = [peer objectForKey: @"UL To Rate"]) ? [NSString stringForSpeedAbbrev: [rate floatValue]] : @"";
869        }
870        else if ([ident isEqualToString: @"DL From"])
871        {
872            NSNumber * rate;
873            return (rate = [peer objectForKey: @"DL From Rate"]) ? [NSString stringForSpeedAbbrev: [rate floatValue]] : @"";
874        }
875        else
876            return [peer objectForKey: @"IP"];
877    }
878    else if (tableView == fWebSeedTable)
879    {
880        NSString * ident = [column identifier];
881        NSDictionary * webSeed = [fWebSeeds objectAtIndex: row];
882       
883        if ([ident isEqualToString: @"DL From"])
884        {
885            NSNumber * rate;
886            return (rate = [webSeed objectForKey: @"DL From Rate"]) ? [NSString stringForSpeedAbbrev: [rate floatValue]] : @"";
887        }
888        else
889            return [webSeed objectForKey: @"Address"];
890    }
891    else if (tableView == fTrackerTable)
892    {
893        id item = [fTrackers objectAtIndex: row];
894       
895        if ([item isKindOfClass: [NSNumber class]])
896            return [NSString stringWithFormat: NSLocalizedString(@"Tier %d", "Inspector -> tracker table"), [item integerValue]];
897        else
898            return item;
899    }
900    return nil;
901}
902
903- (NSCell *) tableView: (NSTableView *) tableView dataCellForTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row
904{
905    if (tableView == fTrackerTable)
906    {
907        const BOOL tracker = [[fTrackers objectAtIndex: row] isKindOfClass: [TrackerNode class]];
908        return tracker ? fTrackerCell : [tableColumn dataCellForRow: row];
909    }
910   
911    return nil;
912}
913
914- (CGFloat) tableView: (NSTableView *) tableView heightOfRow: (NSInteger) row
915{
916    if (tableView == fTrackerTable)
917    {
918        if ([[fTrackers objectAtIndex: row] isKindOfClass: [NSNumber class]])
919            return TRACKER_GROUP_SEPARATOR_HEIGHT;
920    }
921   
922    return [tableView rowHeight];
923}
924
925- (void) tableView: (NSTableView *) tableView willDisplayCell: (id) cell forTableColumn: (NSTableColumn *) tableColumn
926    row: (NSInteger) row
927{
928    if (tableView == fPeerTable)
929    {
930        NSString * ident = [tableColumn identifier];
931       
932        if  ([ident isEqualToString: @"Progress"])
933        {
934            NSDictionary * peer = [fPeers objectAtIndex: row];
935            [(PeerProgressIndicatorCell *)cell setSeed: [[peer objectForKey: @"Seed"] boolValue]];
936        }
937    }
938}
939
940- (void) tableView: (NSTableView *) tableView didClickTableColumn: (NSTableColumn *) tableColumn
941{
942    if (tableView == fPeerTable)
943    {
944        if (fPeers)
945        {
946            NSArray * oldPeers = fPeers;
947            fPeers = [[fPeers sortedArrayUsingDescriptors: [self peerSortDescriptors]] retain];
948            [oldPeers release];
949            [tableView reloadData];
950        }
951    }
952    else if (tableView == fWebSeedTable)
953    {
954        if (fWebSeeds)
955        {
956            NSArray * oldWebSeeds = fWebSeeds;
957            fWebSeeds = [[fWebSeeds sortedArrayUsingDescriptors: [fWebSeedTable sortDescriptors]] retain];
958            [oldWebSeeds release];
959            [tableView reloadData];
960        }
961    }
962    else;
963}
964
965- (BOOL) tableView: (NSTableView *) tableView shouldSelectRow: (NSInteger) row
966{
967    return tableView == fTrackerTable;
968}
969
970- (void) tableViewSelectionDidChange: (NSNotification *) notification
971{
972    if ([notification object] == fTrackerTable)
973    {
974        NSInteger numSelected = [fTrackerTable numberOfSelectedRows];
975        [fTrackerAddRemoveControl setEnabled: numSelected > 0 forSegment: TRACKER_REMOVE_TAG];
976    }
977}
978
979- (BOOL) tableView: (NSTableView *) tableView isGroupRow: (NSInteger) row
980{
981    if (tableView == fTrackerTable)
982        return [[fTrackers objectAtIndex: row] isKindOfClass: [NSNumber class]];
983    return NO;
984}
985
986- (NSString *) tableView: (NSTableView *) tableView toolTipForCell: (NSCell *) cell rect: (NSRectPointer) rect
987                tableColumn: (NSTableColumn *) column row: (NSInteger) row mouseLocation: (NSPoint) mouseLocation
988{
989    if (tableView == fPeerTable)
990    {
991        NSDictionary * peer = [fPeers objectAtIndex: row];
992        NSMutableArray * components = [NSMutableArray arrayWithCapacity: 5];
993       
994        CGFloat progress = [[peer objectForKey: @"Progress"] floatValue];
995        NSString * progressString = [NSString localizedStringWithFormat: NSLocalizedString(@"Progress: %.1f%%",
996                                        "Inspector -> Peers tab -> table row tooltip"), progress * 100.0];
997        if (progress < 1.0 && [[peer objectForKey: @"Seed"] boolValue])
998            progressString = [progressString stringByAppendingFormat: @" (%@)", NSLocalizedString(@"Partial Seed",
999                                "Inspector -> Peers tab -> table row tooltip")];
1000        [components addObject: progressString];
1001       
1002        if ([[peer objectForKey: @"Encryption"] boolValue])
1003            [components addObject: NSLocalizedString(@"Encrypted Connection", "Inspector -> Peers tab -> table row tooltip")];
1004       
1005        NSString * portString;
1006        NSInteger port;
1007        if ((port = [[peer objectForKey: @"Port"] intValue]) > 0)
1008            portString = [NSString stringWithFormat: @"%d", port];
1009        else
1010            portString = NSLocalizedString(@"N/A", "Inspector -> Peers tab -> table row tooltip");
1011        [components addObject: [NSString stringWithFormat: @"%@: %@", NSLocalizedString(@"Port",
1012            "Inspector -> Peers tab -> table row tooltip"), portString]];
1013       
1014        const NSInteger peerFrom = [[peer objectForKey: @"From"] integerValue];
1015        switch (peerFrom)
1016        {
1017            case TR_PEER_FROM_TRACKER:
1018                [components addObject: NSLocalizedString(@"From: tracker", "Inspector -> Peers tab -> table row tooltip")];
1019                break;
1020            case TR_PEER_FROM_INCOMING:
1021                [components addObject: NSLocalizedString(@"From: incoming connection", "Inspector -> Peers tab -> table row tooltip")];
1022                break;
1023            case TR_PEER_FROM_CACHE:
1024                [components addObject: NSLocalizedString(@"From: cache", "Inspector -> Peers tab -> table row tooltip")];
1025                break;
1026            case TR_PEER_FROM_PEX:
1027                [components addObject: NSLocalizedString(@"From: peer exchange", "Inspector -> Peers tab -> table row tooltip")];
1028                break;
1029            case TR_PEER_FROM_DHT:
1030                [components addObject: NSLocalizedString(@"From: distributed hash table", "Inspector -> Peers tab -> table row tooltip")];
1031                break;
1032            default:
1033                NSAssert1(NO, @"Peer from unknown source: %d", peerFrom);
1034        }
1035       
1036        //determing status strings from flags
1037        NSMutableArray * statusArray = [NSMutableArray arrayWithCapacity: 6];
1038        NSString * flags = [peer objectForKey: @"Flags"];
1039       
1040        if ([flags rangeOfString: @"D"].location != NSNotFound)
1041            [statusArray addObject: NSLocalizedString(@"Currently downloading (interested and not choked)",
1042                "Inspector -> peer -> status")];
1043        if ([flags rangeOfString: @"d"].location != NSNotFound)
1044            [statusArray addObject: NSLocalizedString(@"You want to download, but peer does not want to send (interested and choked)",
1045                "Inspector -> peer -> status")];
1046        if ([flags rangeOfString: @"U"].location != NSNotFound)
1047            [statusArray addObject: NSLocalizedString(@"Currently uploading (interested and not choked)",
1048                "Inspector -> peer -> status")];
1049        if ([flags rangeOfString: @"u"].location != NSNotFound)
1050            [statusArray addObject: NSLocalizedString(@"Peer wants you to upload, but you do not want to (interested and choked)",
1051                "Inspector -> peer -> status")];
1052        if ([flags rangeOfString: @"K"].location != NSNotFound)
1053            [statusArray addObject: NSLocalizedString(@"Peer is unchoking you, but you are not interested",
1054                "Inspector -> peer -> status")];
1055        if ([flags rangeOfString: @"?"].location != NSNotFound)
1056            [statusArray addObject: NSLocalizedString(@"You unchoked the peer, but the peer is not interested",
1057                "Inspector -> peer -> status")];
1058       
1059        if ([statusArray count] > 0)
1060        {
1061            NSString * statusStrings = [statusArray componentsJoinedByString: @"\n\n"];
1062            [components addObject: [@"\n" stringByAppendingString: statusStrings]];
1063        }
1064       
1065        return [components componentsJoinedByString: @"\n"];
1066    }
1067    else if (tableView == fTrackerTable)
1068    {
1069        id node = [fTrackers objectAtIndex: row];
1070        if (![node isKindOfClass: [NSNumber class]])
1071            return [(TrackerNode *)node fullAnnounceAddress];
1072    }
1073   
1074    return nil;
1075}
1076
1077- (void) tableView: (NSTableView *) tableView setObjectValue: (id) object forTableColumn: (NSTableColumn *) tableColumn
1078    row: (NSInteger) row
1079{
1080    if (tableView != fTrackerTable)
1081        return;
1082   
1083    Torrent * torrent= [fTorrents objectAtIndex: 0];
1084    if (![torrent addTrackerToNewTier: object])
1085        NSBeep();
1086   
1087    //reset table with either new or old value
1088    [fTrackers release];
1089    fTrackers = [[torrent allTrackerStats] retain];
1090   
1091    [fTrackerTable setTrackers: fTrackers];
1092    [fTrackerTable reloadData];
1093    [fTrackerTable deselectAll: self];
1094   
1095    [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateUI" object: nil]; //incase sort by tracker
1096}
1097
1098- (void) addRemoveTracker: (id) sender
1099{
1100    //don't allow add/remove when currently adding - it leads to weird results
1101    if ([fTrackerTable editedRow] != -1)
1102        return;
1103   
1104    if ([[sender cell] tagForSegment: [sender selectedSegment]] == TRACKER_REMOVE_TAG)
1105        [self removeTrackers];
1106    else
1107        [self addTrackers];
1108}
1109
1110#warning is editing trackers needed?
1111/*- (BOOL) tableView: (NSTableView *) tableView shouldEditTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row
1112{
1113    if (tableView != fTrackerTable)
1114        return NO;
1115   
1116    NSUInteger i;
1117    for (i = row-1; ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]]; i--);
1118   
1119    return [[fTrackers objectAtIndex: i] intValue] == 0;
1120}*/
1121
1122- (NSArray *) quickLookURLs
1123{
1124    FileOutlineView * fileOutlineView = [fFileController outlineView];
1125    Torrent * torrent = [fTorrents objectAtIndex: 0];
1126    NSString * folder = [torrent downloadFolder];
1127    NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
1128    NSMutableArray * urlArray = [NSMutableArray arrayWithCapacity: [indexes count]];
1129   
1130    for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
1131    {
1132        FileListNode * item = [fileOutlineView itemAtRow: i];
1133        if ([self canQuickLookFile: item])
1134            [urlArray addObject: [NSURL fileURLWithPath: [folder stringByAppendingPathComponent: [item fullPath]]]];
1135    }
1136   
1137    return urlArray;
1138}
1139
1140- (BOOL) canQuickLook
1141{
1142    if (fCurrentTabTag != TAB_FILES_TAG || ![NSApp isOnSnowLeopardOrBetter])
1143        return NO;
1144   
1145    if ([fTorrents count] != 1)
1146        return NO;
1147   
1148    Torrent * torrent = [fTorrents objectAtIndex: 0];
1149    if (![torrent isFolder])
1150        return NO;
1151   
1152    FileOutlineView * fileOutlineView = [fFileController outlineView];
1153    NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
1154   
1155    for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
1156        if ([self canQuickLookFile: [fileOutlineView itemAtRow: i]])
1157            return YES;
1158   
1159    return NO;
1160}
1161
1162#warning uncomment (in header too)
1163- (NSRect) quickLookSourceFrameForPreviewItem: (id /*<QLPreviewItem>*/) item
1164{
1165    FileOutlineView * fileOutlineView = [fFileController outlineView];
1166   
1167    NSString * fullPath = [(NSURL *) item path];
1168    NSString * folder = [[fTorrents objectAtIndex: 0] downloadFolder];
1169    NSRange visibleRows = [fileOutlineView rowsInRect: [fileOutlineView bounds]];
1170   
1171    for (NSUInteger row = visibleRows.location; row < NSMaxRange(visibleRows); row++)
1172    {
1173        FileListNode * rowItem = [fileOutlineView itemAtRow: row];
1174        if ([[folder stringByAppendingPathComponent: [rowItem fullPath]] isEqualToString: fullPath])
1175        {
1176            NSRect frame = [fileOutlineView iconRectForRow: row];
1177            frame.origin = [fileOutlineView convertPoint: frame.origin toView: nil];
1178            frame.origin = [[self window] convertBaseToScreen: frame.origin];
1179            frame.origin.y -= frame.size.height;
1180            return frame;
1181        }
1182    }
1183   
1184    return NSZeroRect;
1185}
1186
1187- (void) setPiecesView: (id) sender
1188{
1189    [self setPiecesViewForAvailable: [sender selectedSegment] == PIECES_CONTROL_AVAILABLE];
1190}
1191
1192- (void) setPiecesViewForAvailable: (BOOL) available
1193{
1194    [fPiecesControl setSelected: available forSegment: PIECES_CONTROL_AVAILABLE];
1195    [fPiecesControl setSelected: !available forSegment: PIECES_CONTROL_PROGRESS];
1196   
1197    [[NSUserDefaults standardUserDefaults] setBool: available forKey: @"PiecesViewShowAvailability"];
1198    [fPiecesView updateView];
1199}
1200
1201- (void) revealDataFile: (id) sender
1202{
1203    if ([fTorrents count] > 0)
1204    {
1205        Torrent * torrent = [fTorrents objectAtIndex: 0];
1206        if ([NSApp isOnSnowLeopardOrBetter])
1207        {
1208            NSURL * file = [NSURL fileURLWithPath: [torrent dataLocation]];
1209            [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: [NSArray arrayWithObject: file]];
1210        }
1211        else
1212            [[NSWorkspace sharedWorkspace] selectFile: [torrent dataLocation] inFileViewerRootedAtPath: nil];
1213    }
1214}
1215
1216- (void) setFileFilterText: (id) sender
1217{
1218    [fFileController setFilterText: [sender stringValue]];
1219}
1220
1221- (void) setUseSpeedLimit: (id) sender
1222{
1223    const BOOL upload = sender == fUploadLimitCheck;
1224   
1225    if ([sender state] == NSMixedState)
1226        [sender setState: NSOnState];
1227    const BOOL limit = [sender state] == NSOnState;
1228   
1229    for (Torrent * torrent in fTorrents)
1230        [torrent setUseSpeedLimit: limit upload: upload];
1231   
1232    NSTextField * field = upload ? fUploadLimitField : fDownloadLimitField;
1233    [field setEnabled: limit];
1234    if (limit)
1235    {
1236        [field selectText: self];
1237        [[self window] makeKeyAndOrderFront: self];
1238    }
1239   
1240    NSTextField * label = upload ? fUploadLimitLabel : fDownloadLimitLabel;
1241    [label setEnabled: limit];
1242}
1243
1244- (void) setUseGlobalSpeedLimit: (id) sender
1245{
1246    if ([sender state] == NSMixedState)
1247        [sender setState: NSOnState];
1248    const BOOL limit = [sender state] == NSOnState;
1249   
1250    for (Torrent * torrent in fTorrents)
1251        [torrent setUseGlobalSpeedLimit: limit];
1252}
1253
1254- (void) setSpeedLimit: (id) sender
1255{
1256    const BOOL upload = sender == fUploadLimitField;
1257    const NSInteger limit = [sender intValue];
1258   
1259    for (Torrent * torrent in fTorrents)
1260        [torrent setSpeedLimit: limit upload: upload];
1261}
1262
1263- (void) setRatioSetting: (id) sender
1264{
1265    NSInteger setting;
1266    bool single = NO;
1267    switch ([sender indexOfSelectedItem])
1268    {
1269        case OPTION_POPUP_LIMIT:
1270            setting = TR_RATIOLIMIT_SINGLE;
1271            single = YES;
1272            break;
1273        case OPTION_POPUP_NO_LIMIT:
1274            setting = TR_RATIOLIMIT_UNLIMITED;
1275            break;
1276        case OPTION_POPUP_GLOBAL:
1277            setting = TR_RATIOLIMIT_GLOBAL;
1278            break;
1279        default:
1280            NSAssert1(NO, @"Unknown option selected in ratio popup: %d", [sender indexOfSelectedItem]);
1281            return;
1282    }
1283   
1284    for (Torrent * torrent in fTorrents)
1285        [torrent setRatioSetting: setting];
1286   
1287    [fRatioLimitField setHidden: !single];
1288    if (single)
1289    {
1290        [fRatioLimitField selectText: self];
1291        [[self window] makeKeyAndOrderFront: self];
1292    }
1293}
1294
1295- (void) setRatioLimit: (id) sender
1296{
1297    CGFloat limit = [sender floatValue];
1298   
1299    for (Torrent * torrent in fTorrents)
1300        [torrent setRatioLimit: limit];
1301}
1302
1303- (void) setPriority: (id) sender
1304{
1305    tr_priority_t priority;
1306    switch ([sender indexOfSelectedItem])
1307    {
1308        case OPTION_POPUP_PRIORITY_HIGH:
1309            priority = TR_PRI_HIGH;
1310            break;
1311        case OPTION_POPUP_PRIORITY_NORMAL:
1312            priority = TR_PRI_NORMAL;
1313            break;
1314        case OPTION_POPUP_PRIORITY_LOW:
1315            priority = TR_PRI_LOW;
1316            break;
1317        default:
1318            NSAssert1(NO, @"Unknown option selected in priority popup: %d", [sender indexOfSelectedItem]);
1319            return;
1320    }
1321   
1322    for (Torrent * torrent in fTorrents)
1323        [torrent setPriority: priority];
1324   
1325    [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateUI" object: nil];
1326}
1327
1328- (void) setPeersConnectLimit: (id) sender
1329{
1330    NSInteger limit = [sender intValue];
1331   
1332    for (Torrent * torrent in fTorrents)
1333        [torrent setMaxPeerConnect: limit];
1334}
1335
1336- (BOOL) control: (NSControl *) control textShouldBeginEditing: (NSText *) fieldEditor
1337{
1338    [fInitialString release];
1339    fInitialString = [[control stringValue] retain];
1340   
1341    return YES;
1342}
1343
1344- (BOOL) control: (NSControl *) control didFailToFormatString: (NSString *) string errorDescription: (NSString *) error
1345{
1346    NSBeep();
1347    if (fInitialString)
1348    {
1349        [control setStringValue: fInitialString];
1350        [fInitialString release];
1351        fInitialString = nil;
1352    }
1353    return NO;
1354}
1355
1356@end
1357
1358@implementation InfoWindowController (Private)
1359
1360- (void) updateInfoGeneral
1361{   
1362    if ([fTorrents count] != 1)
1363        return;
1364   
1365    Torrent * torrent = [fTorrents objectAtIndex: 0];
1366   
1367    NSString * location = [torrent dataLocation];
1368    [fDataLocationField setStringValue: [location stringByAbbreviatingWithTildeInPath]];
1369    [fDataLocationField setToolTip: location];
1370}
1371
1372- (void) updateInfoActivity
1373{
1374    NSInteger numberSelected = [fTorrents count];
1375    if (numberSelected == 0)
1376        return;
1377   
1378    uint64_t have = 0, haveVerified = 0, downloadedTotal = 0, uploadedTotal = 0, failedHash = 0;
1379    NSDate * lastActivity = nil;
1380    for (Torrent * torrent in fTorrents)
1381    {
1382        have += [torrent haveTotal];
1383        haveVerified += [torrent haveVerified];
1384        downloadedTotal += [torrent downloadedTotal];
1385        uploadedTotal += [torrent uploadedTotal];
1386        failedHash += [torrent failedHash];
1387       
1388        NSDate * nextLastActivity;
1389        if ((nextLastActivity = [torrent dateActivity]))
1390            lastActivity = lastActivity ? [lastActivity laterDate: nextLastActivity] : nextLastActivity;
1391    }
1392   
1393    if (have == 0)
1394        [fHaveField setStringValue: [NSString stringForFileSize: 0]];
1395    else
1396    {
1397        NSString * verifiedString = [NSString stringWithFormat: NSLocalizedString(@"%@ verified", "Inspector -> Activity tab -> have"),
1398                                        [NSString stringForFileSize: haveVerified]];
1399        if (have == haveVerified)
1400            [fHaveField setStringValue: verifiedString];
1401        else
1402            [fHaveField setStringValue: [NSString stringWithFormat: @"%@ (%@)", [NSString stringForFileSize: have], verifiedString]];
1403    }
1404   
1405    [fDownloadedTotalField setStringValue: [NSString stringForFileSize: downloadedTotal]];
1406    [fUploadedTotalField setStringValue: [NSString stringForFileSize: uploadedTotal]];
1407    [fFailedHashField setStringValue: [NSString stringForFileSize: failedHash]];
1408   
1409    [fDateActivityField setObjectValue: lastActivity];
1410   
1411    if (numberSelected == 1)
1412    {
1413        Torrent * torrent = [fTorrents objectAtIndex: 0];
1414       
1415        [fStateField setStringValue: [torrent stateString]];
1416       
1417        if ([torrent isFolder])
1418            [fProgressField setStringValue: [NSString localizedStringWithFormat: NSLocalizedString(@"%.2f%% (%.2f%% selected)",
1419                "Inspector -> Activity tab -> progress"), 100.0 * [torrent progress], 100.0 * [torrent progressDone]]];
1420        else
1421            [fProgressField setStringValue: [NSString localizedStringWithFormat: @"%.2f%%", 100.0 * [torrent progress]]];
1422           
1423        [fRatioField setStringValue: [NSString stringForRatio: [torrent ratio]]];
1424        [fSwarmSpeedField setStringValue: [torrent isActive] ? [NSString stringForSpeed: [torrent swarmSpeed]] : @""];
1425       
1426        NSString * errorMessage = [torrent errorMessage];
1427        if (![errorMessage isEqualToString: [fErrorMessageView string]])
1428        {
1429            [fErrorMessageView setString: errorMessage];
1430            [fErrorMessageView setSelectable: ![errorMessage isEqualToString: @""]];
1431        }
1432       
1433        [fDateCompletedField setObjectValue: [torrent dateCompleted]];
1434       
1435        [fPiecesView updateView];
1436    }
1437    else if (numberSelected > 1)
1438    {
1439        [fRatioField setStringValue: [NSString stringForRatio: tr_getRatio(uploadedTotal, downloadedTotal)]];
1440    }
1441    else;
1442}
1443
1444- (void) updateInfoTracker
1445{
1446    if ([fTorrents count] != 1)
1447        return;
1448    Torrent * torrent = [fTorrents objectAtIndex: 0];
1449   
1450    //get updated tracker stats
1451    if ([fTrackerTable editedRow] == -1)
1452    {
1453        [fTrackers release];
1454        fTrackers = [[torrent allTrackerStats] retain];
1455       
1456        [fTrackerTable setTrackers: fTrackers];
1457        [fTrackerTable reloadData];
1458    }
1459    else
1460    {
1461        if ([NSApp isOnSnowLeopardOrBetter])
1462        {
1463            NSIndexSet * addedIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange([fTrackers count]-2, 2)];
1464            NSArray * tierAndTrackerBeingAdded = [fTrackers objectsAtIndexes: addedIndexes];
1465           
1466            [fTrackers release];
1467            fTrackers = [[torrent allTrackerStats] retain];
1468            [fTrackers addObjectsFromArray: tierAndTrackerBeingAdded];
1469           
1470            [fTrackerTable setTrackers: fTrackers];
1471           
1472            NSIndexSet * updateIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fTrackers count]-2)],
1473                    * columnIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [[fTrackerTable tableColumns] count])];
1474            [fTrackerTable reloadDataForRowIndexes: updateIndexes columnIndexes: columnIndexes];
1475        }
1476    }
1477}
1478
1479- (void) updateInfoPeers
1480{
1481    if ([fTorrents count] != 1)
1482        return;
1483    Torrent * torrent = [fTorrents objectAtIndex: 0];
1484   
1485    if ([torrent isActive])
1486    {
1487        NSInteger total = [torrent totalPeersConnected];
1488        NSString * connected = [NSString stringWithFormat:
1489                                NSLocalizedString(@"%d Connected", "Inspector -> Peers tab -> peers"), total];
1490       
1491        if (total > 0)
1492        {
1493            NSMutableArray * components = [NSMutableArray arrayWithCapacity: 5];
1494            NSInteger count;
1495            if ((count = [torrent totalPeersTracker]) > 0)
1496                [components addObject: [NSString stringWithFormat:
1497                                        NSLocalizedString(@"%d tracker", "Inspector -> Peers tab -> peers"), count]];
1498            if ((count = [torrent totalPeersIncoming]) > 0)
1499                [components addObject: [NSString stringWithFormat:
1500                                        NSLocalizedString(@"%d incoming", "Inspector -> Peers tab -> peers"), count]];
1501            if ((count = [torrent totalPeersCache]) > 0)
1502                [components addObject: [NSString stringWithFormat:
1503                                        NSLocalizedString(@"%d cache", "Inspector -> Peers tab -> peers"), count]];
1504            if ((count = [torrent totalPeersPex]) > 0)
1505                [components addObject: [NSString stringWithFormat:
1506                                        NSLocalizedString(@"%d PEX", "Inspector -> Peers tab -> peers"), count]];
1507            if ((count = [torrent totalPeersDHT]) > 0)
1508                [components addObject: [NSString stringWithFormat:
1509                                        NSLocalizedString(@"%d DHT", "Inspector -> Peers tab -> peers"), count]];
1510           
1511            connected = [connected stringByAppendingFormat: @": %@", [components componentsJoinedByString: @", "]];
1512        }
1513       
1514        [fConnectedPeersField setStringValue: connected];
1515       
1516        [fDownloadingFromField setIntValue: [torrent peersSendingToUs]];
1517        [fUploadingToField setIntValue: [torrent peersGettingFromUs]];
1518    }
1519    else
1520    {
1521        [fConnectedPeersField setStringValue: @""];
1522        [fDownloadingFromField setStringValue: @""];
1523        [fUploadingToField setStringValue: @""];
1524    }
1525   
1526    [fKnownField setIntValue: [torrent totalPeersKnown]];
1527   
1528    [fPeers release];
1529    fPeers = [[[torrent peers] sortedArrayUsingDescriptors: [self peerSortDescriptors]] retain];
1530    [fPeerTable reloadData];
1531   
1532    if ([torrent webSeedCount] > 0)
1533    {
1534        [fWebSeeds release];
1535        fWebSeeds = [[[torrent webSeeds] sortedArrayUsingDescriptors: [fWebSeedTable sortDescriptors]] retain];
1536        [fWebSeedTable reloadData];
1537    }
1538}
1539
1540- (void) updateInfoFiles
1541{
1542    if ([fTorrents count] == 1)
1543        [fFileController reloadData];
1544}
1545
1546- (NSView *) tabViewForTag: (NSInteger) tag
1547{
1548    switch (tag)
1549    {
1550        case TAB_INFO_TAG:
1551            return fInfoView;
1552        case TAB_ACTIVITY_TAG:
1553            return fActivityView;
1554        case TAB_TRACKER_TAG:
1555            return fTrackerView;
1556        case TAB_PEERS_TAG:
1557            return fPeersView;
1558        case TAB_FILES_TAG:
1559            return fFilesView;
1560        case TAB_OPTIONS_TAG:
1561            return fOptionsView;
1562        default:
1563            NSAssert1(NO, @"Unknown tab view for tag: %d", tag);
1564            return nil;
1565    }
1566}
1567
1568- (void) setWebSeedTableHidden: (BOOL) hide animate: (BOOL) animate
1569{
1570    if (fCurrentTabTag != TAB_PEERS_TAG || ![[self window] isVisible])
1571        animate = NO;
1572   
1573    if (fWebSeedTableAnimation)
1574    {
1575        [fWebSeedTableAnimation stopAnimation];
1576        [fWebSeedTableAnimation release];
1577        fWebSeedTableAnimation = nil;
1578    }
1579   
1580    NSRect webSeedFrame = [[fWebSeedTable enclosingScrollView] frame];
1581    NSRect peerFrame = [[fPeerTable enclosingScrollView] frame];
1582   
1583    if (hide)
1584    {
1585        CGFloat webSeedFrameMaxY = NSMaxY(webSeedFrame);
1586        webSeedFrame.size.height = 0;
1587        webSeedFrame.origin.y = webSeedFrameMaxY;
1588       
1589        peerFrame.size.height = webSeedFrameMaxY - peerFrame.origin.y;
1590    }
1591    else
1592    {
1593        webSeedFrame.origin.y -= fWebSeedTableHeight - webSeedFrame.size.height;
1594        webSeedFrame.size.height = fWebSeedTableHeight;
1595       
1596        peerFrame.size.height = (webSeedFrame.origin.y - fSpaceBetweenWebSeedAndPeer) - peerFrame.origin.y;
1597    }
1598   
1599    [[fWebSeedTable enclosingScrollView] setHidden: NO]; //this is needed for some reason
1600   
1601    //actually resize tables
1602    if (animate)
1603    {
1604        NSDictionary * webSeedDict = [NSDictionary dictionaryWithObjectsAndKeys:
1605                                    [fWebSeedTable enclosingScrollView], NSViewAnimationTargetKey,
1606                                    [NSValue valueWithRect: [[fWebSeedTable enclosingScrollView] frame]], NSViewAnimationStartFrameKey,
1607                                    [NSValue valueWithRect: webSeedFrame], NSViewAnimationEndFrameKey, nil],
1608                    * peerDict = [NSDictionary dictionaryWithObjectsAndKeys:
1609                                    [fPeerTable enclosingScrollView], NSViewAnimationTargetKey,
1610                                    [NSValue valueWithRect: [[fPeerTable enclosingScrollView] frame]], NSViewAnimationStartFrameKey,
1611                                    [NSValue valueWithRect: peerFrame], NSViewAnimationEndFrameKey, nil];
1612       
1613        fWebSeedTableAnimation = [[NSViewAnimation alloc] initWithViewAnimations:
1614                                        [NSArray arrayWithObjects: webSeedDict, peerDict, nil]];
1615        [fWebSeedTableAnimation setDuration: 0.125];
1616        [fWebSeedTableAnimation setAnimationBlockingMode: NSAnimationNonblocking];
1617        [fWebSeedTableAnimation setDelegate: self];
1618       
1619        [fWebSeedTableAnimation startAnimation];
1620    }
1621    else
1622    {
1623        [[fWebSeedTable enclosingScrollView] setFrame: webSeedFrame];
1624        [[fPeerTable enclosingScrollView] setFrame: peerFrame];
1625    }
1626}
1627
1628- (NSArray *) peerSortDescriptors
1629{
1630    NSMutableArray * descriptors = [NSMutableArray arrayWithCapacity: 2];
1631   
1632    NSArray * oldDescriptors = [fPeerTable sortDescriptors];
1633    BOOL useSecond = YES, asc = YES;
1634    if ([oldDescriptors count] > 0)
1635    {
1636        NSSortDescriptor * descriptor = [oldDescriptors objectAtIndex: 0];
1637        [descriptors addObject: descriptor];
1638       
1639        if ((useSecond = ![[descriptor key] isEqualToString: @"IP"]))
1640            asc = [descriptor ascending];
1641    }
1642   
1643    //sort by IP after primary sort
1644    if (useSecond)
1645    {
1646        NSSortDescriptor * secondDescriptor = [[NSSortDescriptor alloc] initWithKey: @"IP" ascending: asc
1647                                                                        selector: @selector(compareNumeric:)];
1648        [descriptors addObject: secondDescriptor];
1649        [secondDescriptor release];
1650    }
1651   
1652    return descriptors;
1653}
1654
1655- (BOOL) canQuickLookFile: (FileListNode *) item
1656{
1657    Torrent * torrent = [fTorrents objectAtIndex: 0];
1658   
1659    if (![[NSFileManager defaultManager] fileExistsAtPath: [[torrent downloadFolder] stringByAppendingPathComponent: [item fullPath]]])
1660        return NO;
1661   
1662    return [item isFolder] || [torrent fileProgress: item] >= 1.0;
1663}
1664
1665#warning doesn't like blank addresses
1666- (void) addTrackers
1667{
1668    [[self window] makeKeyWindow];
1669   
1670    [fTrackers addObject: [NSNumber numberWithInt: [(TrackerNode *)[fTrackers lastObject] tier]+1]];
1671    [fTrackers addObject: @""];
1672   
1673    [fTrackerTable setTrackers: fTrackers];
1674    [fTrackerTable reloadData];
1675    [fTrackerTable selectRowIndexes: [NSIndexSet indexSetWithIndex: [fTrackers count]-1] byExtendingSelection: NO];
1676    [fTrackerTable editColumn: [fTrackerTable columnWithIdentifier: @"Tracker"] row: [fTrackers count]-1 withEvent: nil select: YES];
1677}
1678
1679- (void) removeTrackers
1680{
1681    const NSInteger oldCount = [fTrackers count] - [(TrackerNode *)[fTrackers lastObject] tier];
1682    NSMutableSet * addresses = [NSMutableSet setWithCapacity: oldCount];
1683   
1684    NSIndexSet * indexes = [fTrackerTable selectedRowIndexes];
1685    for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
1686    {
1687        id item = [fTrackers objectAtIndex: i];
1688        if ([item isKindOfClass: [NSNumber class]])
1689        {
1690            for (++i; i < [fTrackers count] && ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]]; ++i)
1691                [addresses addObject: [[fTrackers objectAtIndex: i] fullAnnounceAddress]];
1692            --i;
1693        }
1694        else
1695            [addresses addObject: [(TrackerNode *)item fullAnnounceAddress]];
1696    }
1697   
1698    if (oldCount == [addresses count])
1699    {
1700        NSBeep();
1701        return;
1702    }
1703   
1704    if ([[NSUserDefaults standardUserDefaults] boolForKey: @"WarningRemoveTrackers"])
1705    {
1706        NSAlert * alert = [[NSAlert alloc] init];
1707       
1708        if ([addresses count] > 1)
1709        {
1710            [alert setMessageText: [NSString stringWithFormat: NSLocalizedString(@"Are you sure you want to remove %d trackers?",
1711                                                                "Remove trackers alert -> title"), [addresses count]]];
1712            [alert setInformativeText: NSLocalizedString(@"Once removed, Transmission will no longer attempt to contact them."
1713                                        " This cannot be undone.", "Remove trackers alert -> message")];
1714        }
1715        else
1716        {
1717            [alert setMessageText: NSLocalizedString(@"Are you sure you want to remove this tracker?", "Remove trackers alert -> title")];
1718            [alert setInformativeText: NSLocalizedString(@"Once removed, Transmission will no longer attempt to contact it."
1719                                        " This cannot be undone.", "Remove trackers alert -> message")];
1720        }
1721       
1722        [alert addButtonWithTitle: NSLocalizedString(@"Remove", "Remove trackers alert -> button")];
1723        [alert addButtonWithTitle: NSLocalizedString(@"Cancel", "Remove trackers alert -> button")];
1724       
1725        [alert setShowsSuppressionButton: YES];
1726
1727        NSInteger result = [alert runModal];
1728        if ([[alert suppressionButton] state] == NSOnState)
1729            [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningRemoveTrackers"];
1730        [alert release];
1731       
1732        if (result != NSAlertFirstButtonReturn)
1733            return;
1734    }
1735   
1736    Torrent * torrent = [fTorrents objectAtIndex: 0];
1737    [torrent removeTrackersWithAnnounceAddresses: addresses];
1738   
1739    //reset table with either new or old value
1740    [fTrackers release];
1741    fTrackers = [[torrent allTrackerStats] retain];
1742   
1743    [fTrackerTable setTrackers: fTrackers];
1744    [fTrackerTable reloadData];
1745    [fTrackerTable deselectAll: self];
1746   
1747    [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateUI" object: nil]; //incase sort by tracker
1748}
1749
1750@end
Note: See TracBrowser for help on using the repository browser.