]> granicus.if.org Git - transmission/commitdiff
update remaining time string to display "not all available"
authorMitchell Livingston <livings124@transmissionbt.com>
Sun, 6 Apr 2008 14:44:30 +0000 (14:44 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sun, 6 Apr 2008 14:44:30 +0000 (14:44 +0000)
macosx/NSStringAdditions.m
macosx/Torrent.m

index b4eff0ee09178e647e85d365613ad5a009108e5c..c6de97e7db2e20b142386b3cf155148968270bd2 100644 (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
index bdfbc4631d9524278f4b7d8132245f9efc4c2ab9..7dec2b79358986236ffe52461c0c36e5088d9d17 100644 (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