update remaining time string to display "not all available"

This commit is contained in:
Mitchell Livingston 2008-04-06 14:44:30 +00:00
parent 9f3f0c03e6
commit 3973647cff
2 changed files with 29 additions and 11 deletions

View File

@ -66,9 +66,8 @@
}
//attempt to have minimum of 3 digits with at least 1 decimal
NSString * formattedSize = convertedSize < 10.0 ? [NSString localizedStringWithFormat: @"%.2f", convertedSize - .005]
: [NSString localizedStringWithFormat: @"%.1f", convertedSize - .05];
return [formattedSize stringByAppendingFormat: @" %@", unit];
return convertedSize < 10.0 ? [NSString localizedStringWithFormat: @"%.2f %@", convertedSize - .005, unit]
: [NSString localizedStringWithFormat: @"%.1f %@", convertedSize - .05, unit];
}
+ (NSString *) stringForSpeed: (float) speed
@ -79,7 +78,7 @@
+ (NSString *) stringForSpeedAbbrev: (float) speed
{
if (speed < 1000.0) //0.0 K to 999.9 K
return [NSString localizedStringWithFormat: @"%.1f K", speed];
return [NSString localizedStringWithFormat: @"%.1f K", speed - .05];
else if (speed < 102400.0) //0.98 M to 99.99 M
return [NSString localizedStringWithFormat: @"%.2f M", (speed / 1024.0) - .005];
else if (speed < 1024000.0) //100.0 M to 999.9 M

View File

@ -870,11 +870,11 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
float uploadRate = [self uploadRate];
if (uploadRate < 0.1)
return -1;
return TR_ETA_UNKNOWN;
float stopRatio = [self actualStopRatio], ratio = [self ratio];
if (stopRatio == INVALID || ratio >= stopRatio)
return -1;
return TR_ETA_UNKNOWN;
return (float)MAX([self downloadedTotal], [self haveVerified]) * (stopRatio - ratio) / uploadRate / 1024.0;
}
@ -1010,9 +1010,19 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
&& (fRatioSetting == NSOnState || (fRatioSetting == NSMixedState && [fDefaults boolForKey: @"RatioCheck"]))))
{
int eta = fStat->status == TR_STATUS_DOWNLOAD ? [self eta] : [self etaRatio];
NSString * etaString = eta >= 0 ? [NSString stringWithFormat: NSLocalizedString(@"%@ remaining", "Torrent -> progress string"),
[NSString timeString: eta showSeconds: YES maxDigits: 2]]
: NSLocalizedString(@"remaining time unknown", "Torrent -> progress string");
NSString * etaString;
switch (eta)
{
case TR_ETA_UNKNOWN:
etaString = NSLocalizedString(@"remaining time unknown", "Torrent -> progress string");
break;
case TR_ETA_NOT_AVAIL:
etaString = NSLocalizedString(@"not all available", "Torrent -> progress string");
break;
default:
etaString = [NSString stringWithFormat: NSLocalizedString(@"%@ remaining", "Torrent -> progress string"),
[NSString timeString: eta showSeconds: YES maxDigits: 2]];
}
string = [string stringByAppendingFormat: @" - %@", etaString];
}
@ -1152,8 +1162,17 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
return [self shortStatusString];
int eta = [self isSeeding] ? [self etaRatio] : [self eta];
return eta >= 0 ? [NSString timeString: eta showSeconds: YES maxDigits: 2]
: NSLocalizedString(@"Unknown", "Torrent -> remaining time");
switch (eta)
{
case TR_ETA_UNKNOWN:
return NSLocalizedString(@"Unknown", "Torrent -> remaining time string");
break;
case TR_ETA_NOT_AVAIL:
return NSLocalizedString(@"Not all available", "Torrent -> remaining time string");
default:
return [NSString stringWithFormat: NSLocalizedString(@"%@ remaining", "Torrent -> remaining time string"),
[NSString timeString: eta showSeconds: YES maxDigits: 2]];
}
}
- (NSString *) stateString