Changeset 1453


Ignore:
Timestamp:
Feb 2, 2007, 5:54:24 PM (15 years ago)
Author:
livings124
Message:

same as last change for ratio option

Location:
trunk/macosx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/English.lproj/InfoWindow.nib/classes.nib

    r1452 r1453  
    1010                revealTorrentFile = id;
    1111                setLimitCheck = id;
    12                 setRatioCustom = id;
    1312                setRatioLimit = id;
    1413                setRatioSetting = id;
     
    4140                fPiecesField = NSTextField;
    4241                fPiecesView = PiecesView;
    43                 fRatioCustomCheck = NSButton;
     42                fRatioCheck = NSButton;
    4443                fRatioField = NSTextField;
    4544                fRatioLimitField = NSTextField;
    46                 fRatioStopCheck = NSButton;
    4745                fRevealDataButton = NSButton;
    4846                fRevealTorrentButton = NSButton;
  • trunk/macosx/InfoWindowController.h

    r1452 r1453  
    5757    IBOutlet NSTextField * fFileTableStatusField;
    5858   
    59     IBOutlet NSButton * fRatioCustomCheck, * fRatioStopCheck, * fUploadLimitCheck, * fDownloadLimitCheck;
     59    IBOutlet NSButton * fRatioCheck, * fUploadLimitCheck, * fDownloadLimitCheck;
    6060    IBOutlet NSTextField * fUploadLimitField, * fDownloadLimitField, * fRatioLimitField,
    6161                        * fUploadLimitLabel, * fDownloadLimitLabel;
     
    7575- (void) setSpeedLimit: (id) sender;
    7676
    77 - (void) setRatioCustom: (id) sender;
    7877- (void) setRatioSetting: (id) sender;
    7978- (void) setRatioLimit: (id) sender;
  • trunk/macosx/InfoWindowController.m

    r1452 r1453  
    4242#define TAB_PEERS_HEIGHT 268.0
    4343#define TAB_FILES_HEIGHT 268.0
    44 #define TAB_OPTIONS_HEIGHT 127.0
     44#define TAB_OPTIONS_HEIGHT 112.0
    4545
    4646#define INVALID -99
     
    438438        torrent = [enumerator nextObject]; //first torrent
    439439       
    440         int ratioCustom = [torrent customRatioSetting] ? 1 : 0,
    441             ratioStop = [torrent shouldStopAtRatio];
     440        int ratioSetting = [torrent ratioSetting];
    442441        float ratioLimit = [torrent ratioLimit];
    443442       
    444         while ((ratioCustom != INVALID || ratioStop != INVALID || ratioLimit != INVALID)
     443        while ((ratioSetting != NSMixedState || ratioLimit != INVALID)
    445444                && (torrent = [enumerator nextObject]))
    446445        {
    447             if (ratioCustom != INVALID && ratioCustom != ([torrent customRatioSetting] ? 1 : 0))
    448                 ratioCustom = INVALID;
    449            
    450             if (ratioStop != INVALID && ratioStop != ([torrent shouldStopAtRatio] ? 1 : 0))
    451                 ratioStop = INVALID;
     446            if (ratioSetting != NSMixedState && ratioSetting != [torrent ratioSetting])
     447                ratioSetting = NSMixedState;
    452448           
    453449            if (ratioLimit != INVALID && ratioLimit != [torrent ratioLimit])
     
    455451        }
    456452       
    457         [fRatioCustomCheck setEnabled: YES];
    458         [fRatioCustomCheck setState: ratioCustom == INVALID ? NSMixedState
    459                                 : (ratioCustom == 1 ? NSOnState : NSOffState)];
    460        
    461         [fRatioStopCheck setEnabled: ratioCustom == 1];
    462         [fRatioStopCheck setState: ratioStop == INVALID ? NSMixedState
    463                                 : (ratioStop == 1 ? NSOnState : NSOffState)];
    464        
    465         [fRatioLimitField setEnabled: ratioCustom == 1 && ratioStop == 1];
     453        [fRatioCheck setEnabled: YES];
     454        [fRatioCheck setState: ratioSetting];
     455        [fRatioLimitField setEnabled: ratioSetting == NSOnState];
    466456        if (ratioLimit != INVALID)
    467457            [fRatioLimitField setFloatValue: ratioLimit];
     
    483473        [fDownloadLimitLabel setEnabled: NO];
    484474       
    485         [fRatioCustomCheck setEnabled: NO];
    486         [fRatioCustomCheck setState: NSOffState];
    487         [fRatioStopCheck setEnabled: NO];
    488         [fRatioStopCheck setState: NSOffState];
     475        [fRatioCheck setEnabled: NO];
     476        [fRatioCheck setState: NSOffState];
    489477        [fRatioLimitField setEnabled: NO];
    490478        [fRatioLimitField setStringValue: @""];
     
    831819   
    832820    NSTextField * field = upload ? fUploadLimitField : fDownloadLimitField;
    833    
    834821    [field setEnabled: state == NSOnState];
    835822}
     
    866853}
    867854
    868 - (void) setRatioCustom: (id) sender
    869 {
    870     BOOL custom = [sender state] != NSOffState;
    871     if (custom)
    872         [sender setState: NSOnState];
    873 
     855- (void) setRatioSetting: (id) sender
     856{
     857    int state = [sender state];
     858   
    874859    Torrent * torrent;
    875860    NSEnumerator * enumerator = [fTorrents objectEnumerator];
    876861    while ((torrent = [enumerator nextObject]))
    877         [torrent setCustomRatioSetting: custom];
    878    
    879     [fRatioStopCheck setEnabled: custom];
    880     [fRatioLimitField setEnabled: custom && [fRatioStopCheck state] == NSOnState];
    881 }
    882 
    883 - (void) setRatioSetting: (id) sender
    884 {
    885     BOOL enabled = [sender state] != NSOffState;
    886     if (enabled)
    887         [sender setState: NSOnState];
    888 
    889     Torrent * torrent;
    890     NSEnumerator * enumerator = [fTorrents objectEnumerator];
    891     while ((torrent = [enumerator nextObject]))
    892         [torrent setShouldStopAtRatio: enabled];
    893    
    894     [fRatioLimitField setEnabled: enabled && [fRatioCustomCheck state] == NSOnState];
     862        [torrent setRatioSetting: state];
     863   
     864    [fRatioLimitField setEnabled: state == NSOnState];
    895865}
    896866
  • trunk/macosx/Torrent.h

    r1452 r1453  
    5151    int     fUploadLimit, fDownloadLimit;
    5252    float   fRatioLimit;
    53     int     fCheckUpload, fCheckDownload;
    54     BOOL    fRatioCustom, fShouldStopAtRatio,
    55             fFinishedSeeding, fWaitToStart, fError, fChecking;
     53    int     fCheckUpload, fCheckDownload, fRatioSetting;
     54    BOOL    fFinishedSeeding, fWaitToStart, fError, fChecking;
    5655   
    5756    int fOrderValue;
     
    8786
    8887- (float)       ratio;
    89 - (BOOL)        customRatioSetting;
    90 - (void)        setCustomRatioSetting: (BOOL) setting;
    91 - (BOOL)        shouldStopAtRatio;
    92 - (void)        setShouldStopAtRatio: (BOOL) setting;
     88- (int)         ratioSetting;
     89- (void)        setRatioSetting: (int) setting;
    9390- (float)       ratioLimit;
    9491- (void)        setRatioLimit: (float) limit;
  • trunk/macosx/Torrent.m

    r1452 r1453  
    3636        publicTorrent: (NSNumber *) publicTorrent
    3737        date: (NSDate *) date
    38         stopRatioCustom: (NSNumber *) ratioCustom
    39         shouldStopAtRatio: (NSNumber *) shouldStopAtRatio
    40         ratioLimit: (NSNumber *) ratioLimit
     38        ratioSetting: (NSNumber *) ratioSetting ratioLimit: (NSNumber *) ratioLimit
    4139        limitSpeedCustom: (NSNumber *) limitCustom
    4240        checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
     
    9593                publicTorrent: [history objectForKey: @"PublicCopy"]
    9694                date: [history objectForKey: @"Date"]
    97                 stopRatioCustom: [history objectForKey: @"StopRatioCustom"]
    98                 shouldStopAtRatio: [history objectForKey: @"ShouldStopAtRatio"]
     95                ratioSetting: [history objectForKey: @"RatioSetting"]
    9996                ratioLimit: [history objectForKey: @"RatioLimit"]
    10097                limitSpeedCustom: [history objectForKey: @"LimitSpeedCustom"]
     
    150147                    [self isActive] ? @"NO" : @"YES", @"Paused",
    151148                    [self date], @"Date",
    152                     [NSNumber numberWithBool: fRatioCustom], @"StopRatioCustom",
    153                     [NSNumber numberWithBool: fShouldStopAtRatio], @"ShouldStopAtRatio",
     149                    [NSNumber numberWithBool: fRatioSetting], @"RatioSetting",
    154150                    [NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
    155151                    [NSNumber numberWithInt: fCheckUpload], @"CheckUpload",
     
    268264   
    269265    //check to stop for ratio
    270     if ([self isSeeding] && ((fRatioCustom && fShouldStopAtRatio && [self ratio] >= fRatioLimit)
    271             || (!fRatioCustom && [fDefaults boolForKey: @"RatioCheck"]
     266    if ([self isSeeding] && ((fRatioSetting == NSOnState && [self ratio] >= fRatioLimit)
     267            || (!fRatioSetting == NSMixedState && [fDefaults boolForKey: @"RatioCheck"]
    272268                && [self ratio] >= [fDefaults floatForKey: @"RatioLimit"])))
    273269    {
     
    528524}
    529525
    530 - (BOOL) customRatioSetting
    531 {
    532         return fRatioCustom;
    533 }
    534 
    535 - (void) setCustomRatioSetting: (BOOL) setting
    536 {
    537     fRatioCustom = setting;
    538 }
    539 
    540 - (BOOL) shouldStopAtRatio
    541 {
    542         return fShouldStopAtRatio;
    543 }
    544 
    545 - (void) setShouldStopAtRatio: (BOOL) setting
    546 {
    547     fShouldStopAtRatio = setting;
     526- (int) ratioSetting
     527{
     528        return fRatioSetting;
     529}
     530
     531- (void) setRatioSetting: (int) setting
     532{
     533    fRatioSetting = setting;
    548534}
    549535
     
    11141100        publicTorrent: (NSNumber *) publicTorrent
    11151101        date: (NSDate *) date
    1116         stopRatioCustom: (NSNumber *) ratioCustom
    1117         shouldStopAtRatio: (NSNumber *) shouldStopAtRatio
    1118         ratioLimit: (NSNumber *) ratioLimit
     1102        ratioSetting: (NSNumber *) ratioSetting ratioLimit: (NSNumber *) ratioLimit
    11191103        limitSpeedCustom: (NSNumber *) limitCustom
    11201104        checkUpload: (NSNumber *) checkUpload uploadLimit: (NSNumber *) uploadLimit
     
    11531137    fDate = date ? [date retain] : [[NSDate alloc] init];
    11541138   
    1155     fRatioCustom = ratioCustom ? [ratioCustom boolValue] : NO;
    1156     fShouldStopAtRatio = shouldStopAtRatio ? [shouldStopAtRatio boolValue] : [fDefaults boolForKey: @"RatioCheck"];
     1139    fRatioSetting = ratioSetting ? [ratioSetting intValue] : NSMixedState;
    11571140    fRatioLimit = ratioLimit ? [ratioLimit floatValue] : [fDefaults floatForKey: @"RatioLimit"];
    11581141    fFinishedSeeding = NO;
Note: See TracChangeset for help on using the changeset viewer.