use a function for the progress towards the stop ratio

This commit is contained in:
Mitchell Livingston 2007-05-28 18:17:31 +00:00
parent 78afc2f205
commit 4c1151556d
3 changed files with 15 additions and 20 deletions

View File

@ -101,6 +101,7 @@
- (float) ratioLimit;
- (void) setRatioLimit: (float) limit;
- (float) actualStopRatio; //returns INVALID if will not stop
- (float) progressStopRatio;
- (int) checkUpload;
- (void) setCheckUpload: (int) setting;

View File

@ -522,8 +522,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
if ([self isSeeding])
{
[info setObject: [NSNumber numberWithFloat: [self ratio]] forKey: @"Ratio"];
[info setObject: [NSNumber numberWithFloat: [self actualStopRatio]] forKey: @"StopRatio"];
[info setObject: [NSNumber numberWithFloat: [self progressStopRatio]] forKey: @"ProgressStopRatio"];
}
if (![fDefaults boolForKey: @"SmallView"])
@ -652,6 +651,17 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
return INVALID;
}
- (float) progressStopRatio
{
float stopRatio, ratio;
if ((stopRatio = [self actualStopRatio]) == INVALID || (ratio = [self ratio]) > stopRatio)
return 1.0;
else if (stopRatio > 0 && ratio > 0)
return ratio / stopRatio;
else
return 0;
}
- (int) checkUpload
{
return fCheckUpload;
@ -1409,17 +1419,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
- (NSNumber *) progressSortKey
{
#warning make separate method?
float progress;
if ((progress = [self progress]) >= 1.0)
{
float stopRatio, ratio;
if ((stopRatio = [self actualStopRatio]) == INVALID)
progress = 3.0;
else if (stopRatio > 0 && (ratio = [self ratio]) >= 0 && ratio <= stopRatio)
progress += ratio / stopRatio;
else;
}
progress += [self progressStopRatio];
return [NSNumber numberWithFloat: progress];
}

View File

@ -83,15 +83,7 @@
if ([[info objectForKey: @"Seeding"] boolValue])
{
float stopRatio, ratio;
if ((stopRatio = [[info objectForKey: @"StopRatio"] floatValue]) != INVALID
&& (ratio = [[info objectForKey: @"Ratio"] floatValue]) < stopRatio
&& stopRatio != 0)
{
if (ratio < 0)
ratio = 0;
completeBounds.size.width = width * ratio / stopRatio;
}
completeBounds.size.width = width * [[info objectForKey: @"ProgressStopRatio"] floatValue];
if (completeBounds.size.width < barBounds.size.width)
[fLightGreenGradient fillRect: barBounds angle: -90];