Changeset 10314


Ignore:
Timestamp:
Mar 7, 2010, 1:40:32 AM (12 years ago)
Author:
livings124
Message:

make sure a info tab is loaded the first time it's shown

Location:
trunk/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoActivityViewController.m

    r10309 r10314  
    3232#define PIECES_CONTROL_AVAILABLE 1
    3333
    34 @interface InfoActivityViewController (Private)
    35 
    36 - (void) resetInfo;
    37 
    38 @end
    39 
    4034@implementation InfoActivityViewController
    4135
     
    6155    fTorrents = [torrents retain];
    6256   
    63     [self resetInfo];
     57    const NSUInteger count = [fTorrents count];
     58    if (count != 1)
     59    {
     60        if (count == 0)
     61        {
     62            [fHaveField setStringValue: @""];
     63            [fDownloadedTotalField setStringValue: @""];
     64            [fUploadedTotalField setStringValue: @""];
     65            [fFailedHashField setStringValue: @""];
     66            [fDateActivityField setStringValue: @""];
     67            [fRatioField setStringValue: @""];
     68        }
     69   
     70        [fStateField setStringValue: @""];
     71        [fProgressField setStringValue: @""];
     72       
     73        [fErrorMessageView setString: @""];
     74       
     75        [fDateAddedField setStringValue: @""];
     76        [fDateCompletedField setStringValue: @""];
     77       
     78        [fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_AVAILABLE];
     79        [fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_PROGRESS];
     80        [fPiecesControl setEnabled: NO];
     81        [fPiecesView setTorrent: nil];
     82    }
     83    else
     84    {
     85        Torrent * torrent = [fTorrents objectAtIndex: 0];
     86        [fDateAddedField setObjectValue: [torrent dateAdded]];
     87    }
    6488}
    6589
     
    152176
    153177@end
    154 
    155 @implementation InfoActivityViewController (Private)
    156 
    157 - (void) resetInfo
    158 {
    159     const NSUInteger count = [fTorrents count];
    160     if (count != 1)
    161     {
    162         if (count == 0)
    163         {
    164             [fHaveField setStringValue: @""];
    165             [fDownloadedTotalField setStringValue: @""];
    166             [fUploadedTotalField setStringValue: @""];
    167             [fFailedHashField setStringValue: @""];
    168             [fDateActivityField setStringValue: @""];
    169             [fRatioField setStringValue: @""];
    170         }
    171    
    172         [fStateField setStringValue: @""];
    173         [fProgressField setStringValue: @""];
    174        
    175         [fErrorMessageView setString: @""];
    176        
    177         [fDateAddedField setStringValue: @""];
    178         [fDateCompletedField setStringValue: @""];
    179        
    180         [fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_AVAILABLE];
    181         [fPiecesControl setSelected: NO forSegment: PIECES_CONTROL_PROGRESS];
    182         [fPiecesControl setEnabled: NO];
    183         [fPiecesView setTorrent: nil];
    184     }
    185     else
    186     {
    187         Torrent * torrent = [fTorrents objectAtIndex: 0];
    188         [fDateAddedField setObjectValue: [torrent dateAdded]];
    189     }
    190 }
    191 
    192 @end
  • trunk/macosx/InfoFileViewController.m

    r10312 r10314  
    3030
    3131@interface InfoFileViewController (Private)
    32 
    33 - (void) resetInfo;
    3432
    3533- (BOOL) canQuickLookFile: (FileListNode *) item;
     
    6563    fTorrents = [torrents retain];
    6664   
    67     [self resetInfo];
     65    [fFileFilterField setStringValue: @""];
     66   
     67    if ([fTorrents count] == 1)
     68    {
     69        Torrent * torrent = [fTorrents objectAtIndex: 0];
     70       
     71        [fFileController setTorrent: torrent];
     72        [fFileFilterField setEnabled: [torrent isFolder]];
     73    }
     74    else
     75    {
     76        [fFileController setTorrent: nil];
     77        [fFileFilterField setEnabled: NO];
     78    }
    6879}
    6980
     
    148159@implementation InfoFileViewController (Private)
    149160
    150 - (void) resetInfo
    151 {
    152     [fFileFilterField setStringValue: @""];
    153    
    154     if ([fTorrents count] == 1)
    155     {
    156         Torrent * torrent = [fTorrents objectAtIndex: 0];
    157        
    158         [fFileController setTorrent: torrent];
    159         [fFileFilterField setEnabled: [torrent isFolder]];
    160     }
    161     else
    162     {
    163         [fFileController setTorrent: nil];
    164         [fFileFilterField setEnabled: NO];
    165     }
    166 }
    167 
    168161- (BOOL) canQuickLookFile: (FileListNode *) item
    169162{
  • trunk/macosx/InfoGeneralViewController.m

    r10309 r10314  
    2727#import "NSStringAdditions.h"
    2828#import "Torrent.h"
    29 
    30 @interface InfoGeneralViewController (Private)
    31 
    32 - (void) resetInfo;
    33 
    34 @end
    3529
    3630@implementation InfoGeneralViewController
     
    7569    fTorrents = [torrents retain];
    7670   
    77     [self resetInfo];
    78 }
    79 
    80 - (void) updateInfo
    81 {   
    82     if ([fTorrents count] != 1)
    83         return;
    84    
    85     Torrent * torrent = [fTorrents objectAtIndex: 0];
    86    
    87     NSString * location = [torrent dataLocation];
    88     [fDataLocationField setStringValue: location ? [location stringByAbbreviatingWithTildeInPath] : @""];
    89     [fDataLocationField setToolTip: location ? location : @""];
    90    
    91     [fRevealDataButton setHidden: !location];
    92 }
    93 
    94 - (void) revealDataFile: (id) sender
    95 {
    96     Torrent * torrent = [fTorrents objectAtIndex: 0];
    97     NSString * location = [torrent dataLocation];
    98     if (!location)
    99         return;
    100    
    101     if ([NSApp isOnSnowLeopardOrBetter])
    102     {
    103         NSURL * file = [NSURL fileURLWithPath: location];
    104         [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: [NSArray arrayWithObject: file]];
    105     }
    106     else
    107         [[NSWorkspace sharedWorkspace] selectFile: location inFileViewerRootedAtPath: nil];
    108 }
    109 
    110 @end
    111 
    112 @implementation InfoGeneralViewController (Private)
    113 
    114 - (void) resetInfo
    115 {
    11671    if ([fTorrents count] == 1)
    11772    {
     
    154109}
    155110
     111- (void) updateInfo
     112{   
     113    if ([fTorrents count] != 1)
     114        return;
     115   
     116    Torrent * torrent = [fTorrents objectAtIndex: 0];
     117   
     118    NSString * location = [torrent dataLocation];
     119    [fDataLocationField setStringValue: location ? [location stringByAbbreviatingWithTildeInPath] : @""];
     120    [fDataLocationField setToolTip: location ? location : @""];
     121   
     122    [fRevealDataButton setHidden: !location];
     123}
     124
     125- (void) revealDataFile: (id) sender
     126{
     127    Torrent * torrent = [fTorrents objectAtIndex: 0];
     128    NSString * location = [torrent dataLocation];
     129    if (!location)
     130        return;
     131   
     132    if ([NSApp isOnSnowLeopardOrBetter])
     133    {
     134        NSURL * file = [NSURL fileURLWithPath: location];
     135        [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: [NSArray arrayWithObject: file]];
     136    }
     137    else
     138        [[NSWorkspace sharedWorkspace] selectFile: location inFileViewerRootedAtPath: nil];
     139}
     140
    156141@end
  • trunk/macosx/InfoOptionsViewController.m

    r10309 r10314  
    3636#define INVALID -99
    3737
    38 @interface InfoOptionsViewController (Private)
    39 
    40 - (void) resetInfo;
    41 
    42 @end
    43 
    4438@implementation InfoOptionsViewController
    4539
     
    6559    fTorrents = [torrents retain];
    6660   
    67     [self resetInfo];
     61    if ([fTorrents count] == 0)
     62    {
     63        [fUploadLimitCheck setEnabled: NO];
     64        [fUploadLimitCheck setState: NSOffState];
     65        [fUploadLimitField setEnabled: NO];
     66        [fUploadLimitLabel setEnabled: NO];
     67        [fUploadLimitField setStringValue: @""];
     68       
     69        [fDownloadLimitCheck setEnabled: NO];
     70        [fDownloadLimitCheck setState: NSOffState];
     71        [fDownloadLimitField setEnabled: NO];
     72        [fDownloadLimitLabel setEnabled: NO];
     73        [fDownloadLimitField setStringValue: @""];
     74       
     75        [fGlobalLimitCheck setEnabled: NO];
     76        [fGlobalLimitCheck setState: NSOffState];
     77       
     78        [fPriorityPopUp setEnabled: NO];
     79        [fPriorityPopUp selectItemAtIndex: -1];
     80       
     81        [fRatioPopUp setEnabled: NO];
     82        [fRatioPopUp selectItemAtIndex: -1];
     83        [fRatioLimitField setHidden: YES];
     84        [fRatioLimitField setStringValue: @""];
     85       
     86        [fPeersConnectField setEnabled: NO];
     87        [fPeersConnectField setStringValue: @""];
     88        [fPeersConnectLabel setEnabled: NO];
     89    }
     90    else
     91        [self updateOptions];
    6892}
    6993
     
    352376@implementation InfoOptionsViewController (Private)
    353377
    354 - (void) resetInfo
    355 {
    356     if ([fTorrents count] == 0)
    357     {
    358         [fUploadLimitCheck setEnabled: NO];
    359         [fUploadLimitCheck setState: NSOffState];
    360         [fUploadLimitField setEnabled: NO];
    361         [fUploadLimitLabel setEnabled: NO];
    362         [fUploadLimitField setStringValue: @""];
    363        
    364         [fDownloadLimitCheck setEnabled: NO];
    365         [fDownloadLimitCheck setState: NSOffState];
    366         [fDownloadLimitField setEnabled: NO];
    367         [fDownloadLimitLabel setEnabled: NO];
    368         [fDownloadLimitField setStringValue: @""];
    369        
    370         [fGlobalLimitCheck setEnabled: NO];
    371         [fGlobalLimitCheck setState: NSOffState];
    372        
    373         [fPriorityPopUp setEnabled: NO];
    374         [fPriorityPopUp selectItemAtIndex: -1];
    375        
    376         [fRatioPopUp setEnabled: NO];
    377         [fRatioPopUp selectItemAtIndex: -1];
    378         [fRatioLimitField setHidden: YES];
    379         [fRatioLimitField setStringValue: @""];
    380        
    381         [fPeersConnectField setEnabled: NO];
    382         [fPeersConnectField setStringValue: @""];
    383         [fPeersConnectLabel setEnabled: NO];
    384     }
    385     else
    386         [self updateOptions];
    387 }
    388 
    389378@end
  • trunk/macosx/InfoPeersViewController.m

    r10312 r10314  
    452452        [fPeerTable reloadData];
    453453       
    454         #warning should be reset when != to 1?
    455454        [fConnectedPeersField setStringValue: @""];
    456455    }
     
    553552    if (useSecond)
    554553    {
    555         #warning when 10.6-only, replate with sortDescriptorWithKey:ascending:selector:
     554        #warning when 10.6-only, replace with sortDescriptorWithKey:ascending:selector:
    556555        NSSortDescriptor * secondDescriptor = [[NSSortDescriptor alloc] initWithKey: @"IP" ascending: asc
    557556                                                                        selector: @selector(compareNumeric:)];
  • trunk/macosx/InfoTrackersViewController.m

    r10309 r10314  
    3737@interface InfoTrackersViewController (Private)
    3838
    39 - (void) resetInfo;
    40 
    4139- (void) addTrackers;
    4240- (void) removeTrackers;
     
    7371    fTorrents = [torrents retain];
    7472   
    75     [self resetInfo];
     73    const NSUInteger numberSelected = [fTorrents count];
     74    if (numberSelected != 1)
     75    {
     76        if (numberSelected == 0)
     77        {
     78            [fTrackers release];
     79            fTrackers = nil;
     80           
     81            [fTrackerTable setTrackers: nil];
     82            [fTrackerTable reloadData];
     83        }
     84       
     85        [fTrackerTable setTorrent: nil];
     86       
     87        [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_ADD_TAG];
     88        [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
     89    }
     90    else
     91    {
     92        [fTrackerTable setTorrent: [fTorrents objectAtIndex: 0]];
     93       
     94        [fTrackerAddRemoveControl setEnabled: YES forSegment: TRACKER_ADD_TAG];
     95        [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
     96    }
     97   
     98    [fTrackerTable deselectAll: self];
    7699}
    77100
     
    223246
    224247@implementation InfoTrackersViewController (Private)
    225 
    226 - (void) resetInfo
    227 {
    228     const NSUInteger numberSelected = [fTorrents count];
    229     if (numberSelected != 1)
    230     {
    231         if (numberSelected == 0)
    232         {
    233             [fTrackers release];
    234             fTrackers = nil;
    235            
    236             [fTrackerTable setTrackers: nil];
    237             [fTrackerTable reloadData];
    238         }
    239        
    240         [fTrackerTable setTorrent: nil];
    241        
    242         [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_ADD_TAG];
    243         [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
    244     }
    245     else
    246     {
    247         [fTrackerTable setTorrent: [fTorrents objectAtIndex: 0]];
    248        
    249         [fTrackerAddRemoveControl setEnabled: YES forSegment: TRACKER_ADD_TAG];
    250         [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG];
    251     }
    252    
    253     [fTrackerTable deselectAll: self];
    254 }
    255248
    256249#warning doesn't like blank addresses
  • trunk/macosx/InfoWindowController.m

    r10312 r10314  
    6969- (id) init
    7070{
    71     if ((self = [super initWithWindowNibName: @"InfoWindow"]))
    72     {
    73         fGeneralViewController = [[InfoGeneralViewController alloc] init];
    74         fActivityViewController = [[InfoActivityViewController alloc] init];
    75         fTrackersViewController = [[InfoTrackersViewController alloc] init];
    76         fPeersViewController = [[InfoPeersViewController alloc] init];
    77         fFileViewController = [[InfoFileViewController alloc] init];
    78         fOptionsViewController = [[InfoOptionsViewController alloc] init];
    79     }
    80    
     71    self = [super initWithWindowNibName: @"InfoWindow"];
    8172    return self;
    8273}
     
    244235        return;
    245236   
    246     [self updateInfoStats];
    247    
    248237    //take care of old view
    249238    CGFloat oldHeight = 0;
     
    288277   
    289278    //set new tab item
    290     NSView * view = [self tabViewForTag: fCurrentTabTag];
    291    
    292279    #warning get titles from view controller?
    293280    NSString * resizeSaveKey = nil;
     
    296283    {
    297284        case TAB_GENERAL_TAG:
     285            if (!fGeneralViewController)
     286                fGeneralViewController = [[InfoGeneralViewController alloc] init];
     287           
    298288            identifier = TAB_INFO_IDENT;
    299289            title = NSLocalizedString(@"General Info", "Inspector -> title");
    300290            break;
    301291        case TAB_ACTIVITY_TAG:
     292            if (!fActivityViewController)
     293                fActivityViewController = [[InfoActivityViewController alloc] init];
     294           
    302295            identifier = TAB_ACTIVITY_IDENT;
    303296            title = NSLocalizedString(@"Activity", "Inspector -> title");
    304297            break;
    305298        case TAB_TRACKERS_TAG:
     299            if (!fTrackersViewController)
     300                fTrackersViewController = [[InfoTrackersViewController alloc] init];
     301           
    306302            identifier = TAB_TRACKER_IDENT;
    307303            title = NSLocalizedString(@"Trackers", "Inspector -> title");
     
    309305            break;
    310306        case TAB_PEERS_TAG:
     307            if (!fPeersViewController)
     308                fPeersViewController = [[InfoPeersViewController alloc] init];
     309           
    311310            identifier = TAB_PEERS_IDENT;
    312311            title = NSLocalizedString(@"Peers", "Inspector -> title");
     
    314313            break;
    315314        case TAB_FILE_TAG:
     315            if (!fFileViewController)
     316                fFileViewController = [[InfoFileViewController alloc] init];
     317           
    316318            identifier = TAB_FILES_IDENT;
    317319            title = NSLocalizedString(@"Files", "Inspector -> title");
     
    319321            break;
    320322        case TAB_OPTIONS_TAG:
     323            if (!fOptionsViewController)
     324                fOptionsViewController = [[InfoOptionsViewController alloc] init];
     325           
    321326            identifier = TAB_OPTIONS_IDENT;
    322327            title = NSLocalizedString(@"Options", "Inspector -> title");
     
    336341    [(InfoTabButtonCell *)[fTabMatrix selectedCell] setSelectedTab: YES];
    337342   
     343    NSView * view = [self tabViewForTag: fCurrentTabTag];
     344   
     345    //if view was just loaded - has to be a better way
     346    [fGeneralViewController setInfoForTorrents: fTorrents];
     347    [fActivityViewController setInfoForTorrents: fTorrents];
     348    [fTrackersViewController setInfoForTorrents: fTorrents];
     349    [fPeersViewController setInfoForTorrents: fTorrents];
     350    [fFileViewController setInfoForTorrents: fTorrents];
     351    [fOptionsViewController setInfoForTorrents: fTorrents];
     352   
     353    [self updateInfoStats];
     354   
    338355    NSRect windowRect = [window frame], viewRect = [view frame];
    339356   
     
    368385    [window setFrame: windowRect display: YES animate: oldTabTag != INVALID];
    369386    [[window contentView] addSubview: view];
     387   
    370388    [view setHidden: NO];
    371389   
Note: See TracChangeset for help on using the changeset viewer.