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 //attempt to have minimum of 3 digits with at least 1 decimal
NSString * formattedSize = convertedSize < 10.0 ? [NSString localizedStringWithFormat: @"%.2f", convertedSize - .005] return convertedSize < 10.0 ? [NSString localizedStringWithFormat: @"%.2f %@", convertedSize - .005, unit]
: [NSString localizedStringWithFormat: @"%.1f", convertedSize - .05]; : [NSString localizedStringWithFormat: @"%.1f %@", convertedSize - .05, unit];
return [formattedSize stringByAppendingFormat: @" %@", unit];
} }
+ (NSString *) stringForSpeed: (float) speed + (NSString *) stringForSpeed: (float) speed
@ -79,7 +78,7 @@
+ (NSString *) stringForSpeedAbbrev: (float) speed + (NSString *) stringForSpeedAbbrev: (float) speed
{ {
if (speed < 1000.0) //0.0 K to 999.9 K 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 else if (speed < 102400.0) //0.98 M to 99.99 M
return [NSString localizedStringWithFormat: @"%.2f M", (speed / 1024.0) - .005]; return [NSString localizedStringWithFormat: @"%.2f M", (speed / 1024.0) - .005];
else if (speed < 1024000.0) //100.0 M to 999.9 M 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]; float uploadRate = [self uploadRate];
if (uploadRate < 0.1) if (uploadRate < 0.1)
return -1; return TR_ETA_UNKNOWN;
float stopRatio = [self actualStopRatio], ratio = [self ratio]; float stopRatio = [self actualStopRatio], ratio = [self ratio];
if (stopRatio == INVALID || ratio >= stopRatio) if (stopRatio == INVALID || ratio >= stopRatio)
return -1; return TR_ETA_UNKNOWN;
return (float)MAX([self downloadedTotal], [self haveVerified]) * (stopRatio - ratio) / uploadRate / 1024.0; 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"])))) && (fRatioSetting == NSOnState || (fRatioSetting == NSMixedState && [fDefaults boolForKey: @"RatioCheck"]))))
{ {
int eta = fStat->status == TR_STATUS_DOWNLOAD ? [self eta] : [self etaRatio]; int eta = fStat->status == TR_STATUS_DOWNLOAD ? [self eta] : [self etaRatio];
NSString * etaString = eta >= 0 ? [NSString stringWithFormat: NSLocalizedString(@"%@ remaining", "Torrent -> progress string"), NSString * etaString;
[NSString timeString: eta showSeconds: YES maxDigits: 2]] switch (eta)
: NSLocalizedString(@"remaining time unknown", "Torrent -> progress string"); {
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]; string = [string stringByAppendingFormat: @" - %@", etaString];
} }
@ -1152,8 +1162,17 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
return [self shortStatusString]; return [self shortStatusString];
int eta = [self isSeeding] ? [self etaRatio] : [self eta]; int eta = [self isSeeding] ? [self etaRatio] : [self eta];
return eta >= 0 ? [NSString timeString: eta showSeconds: YES maxDigits: 2] switch (eta)
: NSLocalizedString(@"Unknown", "Torrent -> remaining time"); {
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 - (NSString *) stateString