}
//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
+ (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
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;
}
&& (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];
}
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