Changeset 3074


Ignore:
Timestamp:
Sep 15, 2007, 8:29:52 PM (14 years ago)
Author:
livings124
Message:

warnings--

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r3073 r3074  
    158158            [fDownloadedTotalField setStringValue: @""];
    159159            [fUploadedTotalField setStringValue: @""];
     160           
     161            //options fields
     162            [fUploadLimitPopUp setEnabled: NO];
     163            [fUploadLimitPopUp selectItemAtIndex: -1];
     164            [fUploadLimitField setHidden: YES];
     165            [fUploadLimitLabel setHidden: YES];
     166            [fUploadLimitField setStringValue: @""];
     167           
     168            [fDownloadLimitPopUp setEnabled: NO];
     169            [fDownloadLimitPopUp selectItemAtIndex: -1];
     170            [fDownloadLimitField setHidden: YES];
     171            [fDownloadLimitLabel setHidden: YES];
     172            [fDownloadLimitField setStringValue: @""];
     173           
     174            [fRatioPopUp setEnabled: NO];
     175            [fRatioPopUp selectItemAtIndex: -1];
     176            [fRatioLimitField setHidden: YES];
     177            [fRatioLimitField setStringValue: @""];
     178           
     179            [fPexCheck setEnabled: NO];
     180            [fPexCheck setState: NSOffState];
     181            [fPexCheck setToolTip: @""];
    160182        }
    161183       
     
    457479- (void) updateInfoSettings
    458480{
    459     if ([fTorrents count] > 0)
    460     {
    461         Torrent * torrent;
    462        
    463         //get bandwidth info
    464         NSEnumerator * enumerator = [fTorrents objectEnumerator];
    465         torrent = [enumerator nextObject]; //first torrent
    466        
    467         int uploadSpeedMode = [torrent speedMode: YES],
    468             uploadSpeedLimit = [torrent speedLimit: YES],
    469             downloadSpeedMode = [torrent speedMode: NO],
    470             downloadSpeedLimit = [torrent speedLimit: NO];
    471        
    472         while ((uploadSpeedMode != INVALID || uploadSpeedLimit != INVALID
    473                 || downloadSpeedMode != INVALID || downloadSpeedLimit != INVALID)
    474                 && (torrent = [enumerator nextObject]))
    475         {
    476             if (uploadSpeedMode != INVALID && uploadSpeedMode != [torrent speedMode: YES])
    477                 uploadSpeedMode = INVALID;
    478            
    479             if (uploadSpeedLimit != INVALID && uploadSpeedLimit != [torrent speedLimit: YES])
    480                 uploadSpeedLimit = INVALID;
    481            
    482             if (downloadSpeedMode != INVALID && downloadSpeedMode != [torrent speedMode: NO])
    483                 downloadSpeedMode = INVALID;
    484            
    485             if (downloadSpeedLimit != INVALID && downloadSpeedLimit != [torrent speedLimit: NO])
    486                 downloadSpeedLimit = INVALID;
    487         }
    488        
    489         //set upload view
    490         int index;
    491         if (uploadSpeedMode == TR_SPEEDLIMIT_SINGLE)
    492             index = OPTION_POPUP_LIMIT;
    493         else if (uploadSpeedMode == TR_SPEEDLIMIT_UNLIMITED)
    494             index = OPTION_POPUP_NO_LIMIT;
    495         else if (uploadSpeedMode == TR_SPEEDLIMIT_GLOBAL)
    496             index = OPTION_POPUP_GLOBAL;
    497         else
    498             index = -1;
    499         [fUploadLimitPopUp selectItemAtIndex: index];
    500         [fUploadLimitPopUp setEnabled: YES];
    501        
    502         [fUploadLimitLabel setHidden: uploadSpeedMode != TR_SPEEDLIMIT_SINGLE];
    503         [fUploadLimitField setHidden: uploadSpeedMode != TR_SPEEDLIMIT_SINGLE];
    504         if (uploadSpeedLimit != INVALID)
    505             [fUploadLimitField setIntValue: uploadSpeedLimit];
    506         else
    507             [fUploadLimitField setStringValue: @""];
    508        
    509         //set download view
    510         if (downloadSpeedMode == TR_SPEEDLIMIT_SINGLE)
    511             index = OPTION_POPUP_LIMIT;
    512         else if (downloadSpeedMode == TR_SPEEDLIMIT_UNLIMITED)
    513             index = OPTION_POPUP_NO_LIMIT;
    514         else if (downloadSpeedMode == TR_SPEEDLIMIT_GLOBAL)
    515             index = OPTION_POPUP_GLOBAL;
    516         else
    517             index = -1;
    518         [fDownloadLimitPopUp selectItemAtIndex: index];
    519         [fDownloadLimitPopUp setEnabled: YES];
    520        
    521         [fDownloadLimitLabel setHidden: downloadSpeedMode != TR_SPEEDLIMIT_SINGLE];
    522         [fDownloadLimitField setHidden: downloadSpeedMode != TR_SPEEDLIMIT_SINGLE];
    523         if (downloadSpeedLimit != INVALID)
    524             [fDownloadLimitField setIntValue: downloadSpeedLimit];
    525         else
    526             [fDownloadLimitField setStringValue: @""];
    527        
    528         //get ratio info
    529         enumerator = [fTorrents objectEnumerator];
    530         torrent = [enumerator nextObject]; //first torrent
    531        
    532         int checkRatio = [torrent ratioSetting];
    533         float ratioLimit = [torrent ratioLimit];
    534        
    535         while ((checkRatio != INVALID || checkRatio != INVALID)
    536                 && (torrent = [enumerator nextObject]))
    537         {
    538             if (checkRatio != INVALID && checkRatio != [torrent ratioSetting])
    539                 checkRatio = INVALID;
    540            
    541             if (ratioLimit != INVALID && ratioLimit != [torrent ratioLimit])
    542                 ratioLimit = INVALID;
    543         }
    544        
    545         //set ratio view
    546         if (checkRatio == NSOnState)
    547             index = OPTION_POPUP_LIMIT;
    548         else if (checkRatio == NSOffState)
    549             index = OPTION_POPUP_NO_LIMIT;
    550         else if (checkRatio == NSMixedState)
    551             index = OPTION_POPUP_GLOBAL;
    552         else
    553             index = -1;
    554         [fRatioPopUp selectItemAtIndex: index];
    555         [fRatioPopUp setEnabled: YES];
    556        
    557         [fRatioLimitField setHidden: checkRatio != NSOnState];
    558         if (ratioLimit != INVALID)
    559             [fRatioLimitField setFloatValue: ratioLimit];
    560         else
    561             [fRatioLimitField setStringValue: @""];
    562                
    563                 //set pex check
    564                 enumerator = [fTorrents objectEnumerator];
    565         torrent = [enumerator nextObject]; //first torrent
    566                
    567                 BOOL pexEnabled = ![torrent privateTorrent] && [torrent isPaused];
    568                 int pexState = [torrent pex] ? NSOnState : NSOffState;
    569                
    570                 while ((pexEnabled || pexState != NSMixedState)
    571                 && (torrent = [enumerator nextObject]))
    572         {
    573             if (pexEnabled)
    574                 pexEnabled = ![torrent privateTorrent] && [torrent isPaused];
    575            
    576             if (pexState != NSMixedState && pexState != ([torrent pex] ? NSOnState : NSOffState))
    577                 pexState = NSMixedState;
    578         }
    579                
    580                 [fPexCheck setEnabled: pexEnabled];
    581                 [fPexCheck setState: pexState];
    582         [fPexCheck setToolTip: !pexEnabled ? NSLocalizedString(@"PEX can only be toggled on paused public torrents.",
    583                                     "Inspector -> pex check") : @""];
    584     }
    585     else
    586     {
    587         #warning move
    588        
    589         [fUploadLimitPopUp setEnabled: NO];
    590         [fUploadLimitPopUp selectItemAtIndex: -1];
    591         [fUploadLimitField setHidden: YES];
    592         [fUploadLimitLabel setHidden: YES];
     481    if ([fTorrents count] == 0)
     482        return;
     483
     484    Torrent * torrent;
     485   
     486    //get bandwidth info
     487    NSEnumerator * enumerator = [fTorrents objectEnumerator];
     488    torrent = [enumerator nextObject]; //first torrent
     489   
     490    int uploadSpeedMode = [torrent speedMode: YES],
     491        uploadSpeedLimit = [torrent speedLimit: YES],
     492        downloadSpeedMode = [torrent speedMode: NO],
     493        downloadSpeedLimit = [torrent speedLimit: NO];
     494   
     495    while ((torrent = [enumerator nextObject])
     496            && (uploadSpeedMode != INVALID || uploadSpeedLimit != INVALID
     497                || downloadSpeedMode != INVALID || downloadSpeedLimit != INVALID))
     498    {
     499        if (uploadSpeedMode != INVALID && uploadSpeedMode != [torrent speedMode: YES])
     500            uploadSpeedMode = INVALID;
     501       
     502        if (uploadSpeedLimit != INVALID && uploadSpeedLimit != [torrent speedLimit: YES])
     503            uploadSpeedLimit = INVALID;
     504       
     505        if (downloadSpeedMode != INVALID && downloadSpeedMode != [torrent speedMode: NO])
     506            downloadSpeedMode = INVALID;
     507       
     508        if (downloadSpeedLimit != INVALID && downloadSpeedLimit != [torrent speedLimit: NO])
     509            downloadSpeedLimit = INVALID;
     510    }
     511   
     512    //set upload view
     513    int index;
     514    if (uploadSpeedMode == TR_SPEEDLIMIT_SINGLE)
     515        index = OPTION_POPUP_LIMIT;
     516    else if (uploadSpeedMode == TR_SPEEDLIMIT_UNLIMITED)
     517        index = OPTION_POPUP_NO_LIMIT;
     518    else if (uploadSpeedMode == TR_SPEEDLIMIT_GLOBAL)
     519        index = OPTION_POPUP_GLOBAL;
     520    else
     521        index = -1;
     522    [fUploadLimitPopUp selectItemAtIndex: index];
     523    [fUploadLimitPopUp setEnabled: YES];
     524   
     525    [fUploadLimitLabel setHidden: uploadSpeedMode != TR_SPEEDLIMIT_SINGLE];
     526    [fUploadLimitField setHidden: uploadSpeedMode != TR_SPEEDLIMIT_SINGLE];
     527    if (uploadSpeedLimit != INVALID)
     528        [fUploadLimitField setIntValue: uploadSpeedLimit];
     529    else
    593530        [fUploadLimitField setStringValue: @""];
    594        
    595         [fDownloadLimitPopUp setEnabled: NO];
    596         [fDownloadLimitPopUp selectItemAtIndex: -1];
    597         [fDownloadLimitField setHidden: YES];
    598         [fDownloadLimitLabel setHidden: YES];
     531   
     532    //set download view
     533    if (downloadSpeedMode == TR_SPEEDLIMIT_SINGLE)
     534        index = OPTION_POPUP_LIMIT;
     535    else if (downloadSpeedMode == TR_SPEEDLIMIT_UNLIMITED)
     536        index = OPTION_POPUP_NO_LIMIT;
     537    else if (downloadSpeedMode == TR_SPEEDLIMIT_GLOBAL)
     538        index = OPTION_POPUP_GLOBAL;
     539    else
     540        index = -1;
     541    [fDownloadLimitPopUp selectItemAtIndex: index];
     542    [fDownloadLimitPopUp setEnabled: YES];
     543   
     544    [fDownloadLimitLabel setHidden: downloadSpeedMode != TR_SPEEDLIMIT_SINGLE];
     545    [fDownloadLimitField setHidden: downloadSpeedMode != TR_SPEEDLIMIT_SINGLE];
     546    if (downloadSpeedLimit != INVALID)
     547        [fDownloadLimitField setIntValue: downloadSpeedLimit];
     548    else
    599549        [fDownloadLimitField setStringValue: @""];
    600        
    601         [fRatioPopUp setEnabled: NO];
    602         [fRatioPopUp selectItemAtIndex: -1];
    603         [fRatioLimitField setHidden: YES];
     550   
     551    //get ratio info
     552    enumerator = [fTorrents objectEnumerator];
     553    torrent = [enumerator nextObject]; //first torrent
     554   
     555    int checkRatio = [torrent ratioSetting];
     556    float ratioLimit = [torrent ratioLimit];
     557   
     558    while ((torrent = [enumerator nextObject]) && (checkRatio != INVALID || checkRatio != INVALID))
     559    {
     560        if (checkRatio != INVALID && checkRatio != [torrent ratioSetting])
     561            checkRatio = INVALID;
     562       
     563        if (ratioLimit != INVALID && ratioLimit != [torrent ratioLimit])
     564            ratioLimit = INVALID;
     565    }
     566   
     567    //set ratio view
     568    if (checkRatio == NSOnState)
     569        index = OPTION_POPUP_LIMIT;
     570    else if (checkRatio == NSOffState)
     571        index = OPTION_POPUP_NO_LIMIT;
     572    else if (checkRatio == NSMixedState)
     573        index = OPTION_POPUP_GLOBAL;
     574    else
     575        index = -1;
     576    [fRatioPopUp selectItemAtIndex: index];
     577    [fRatioPopUp setEnabled: YES];
     578   
     579    [fRatioLimitField setHidden: checkRatio != NSOnState];
     580    if (ratioLimit != INVALID)
     581        [fRatioLimitField setFloatValue: ratioLimit];
     582    else
    604583        [fRatioLimitField setStringValue: @""];
    605                
    606                 [fPexCheck setEnabled: NO];
    607         [fPexCheck setState: NSOffState];
    608         [fPexCheck setToolTip: @""];
    609     }
     584   
     585    //set pex check
     586    enumerator = [fTorrents objectEnumerator];
     587    torrent = [enumerator nextObject]; //first torrent
     588   
     589    BOOL pexEnabled = ![torrent privateTorrent] && [torrent isPaused];
     590    int pexState = [torrent pex] ? NSOnState : NSOffState;
     591   
     592    while ((torrent = [enumerator nextObject]) && (pexEnabled || pexState != NSMixedState))
     593    {
     594        if (pexEnabled)
     595            pexEnabled = ![torrent privateTorrent] && [torrent isPaused];
     596       
     597        if (pexState != NSMixedState && pexState != ([torrent pex] ? NSOnState : NSOffState))
     598            pexState = NSMixedState;
     599    }
     600   
     601    [fPexCheck setEnabled: pexEnabled];
     602    [fPexCheck setState: pexState];
     603    [fPexCheck setToolTip: !pexEnabled ? NSLocalizedString(@"PEX can only be toggled on paused public torrents.",
     604                                "Inspector -> pex check") : @""];
    610605}
    611606
Note: See TracChangeset for help on using the changeset viewer.