#3216 Progress Percentage Should Round Down

This commit is contained in:
Mitchell Livingston 2010-05-31 14:06:54 +00:00
parent af2ae0eac4
commit d0bf7ff409
5 changed files with 29 additions and 12 deletions

View File

@ -29,6 +29,9 @@
#import "NSApplicationAdditions.h"
#import "NSStringAdditions.h"
#import "transmission.h" // required by utils.h
#import "utils.h"
#define PADDING_HORIZONAL 2.0
#define IMAGE_FOLDER_SIZE 16.0
#define IMAGE_ICON_SIZE 32.0
@ -203,7 +206,8 @@
FileListNode * node = (FileListNode *)[self objectValue];
const CGFloat progress = [torrent fileProgress: node];
NSString * percentString = progress == 1.0 ? @"100%" : [NSString localizedStringWithFormat: @"%.2f%%", progress * 100.0];
NSString * percentString = progress == 1.0 ? @"100%"
: [NSString localizedStringWithFormat: @"%.2f%%", tr_truncd(progress * 100.0, 2)];
NSString * status = [NSString stringWithFormat: NSLocalizedString(@"%@ of %@",
"Inspector -> Files tab -> file status string"), percentString, [NSString stringForFileSize: [node size]]];

View File

@ -124,11 +124,13 @@
[fStateField setStringValue: [torrent stateString]];
#warning simplify
if ([torrent isFolder])
[fProgressField setStringValue: [NSString localizedStringWithFormat: NSLocalizedString(@"%.2f%% (%.2f%% selected)",
"Inspector -> Activity tab -> progress"), 100.0 * [torrent progress], 100.0 * [torrent progressDone]]];
"Inspector -> Activity tab -> progress"), tr_truncd(100.0 * [torrent progress], 2),
tr_truncd(100.0 * [torrent progressDone], 2)]];
else
[fProgressField setStringValue: [NSString localizedStringWithFormat: @"%.2f%%", 100.0 * [torrent progress]]];
[fProgressField setStringValue: [NSString localizedStringWithFormat: @"%.2f%%", tr_truncd(100.0 * [torrent progress], 2)]];
[fRatioField setStringValue: [NSString stringForRatio: [torrent ratio]]];

View File

@ -28,6 +28,9 @@
#import "PeerProgressIndicatorCell.h"
#import "Torrent.h"
#import "transmission.h" // required by utils.h
#import "utils.h"
@interface InfoPeersViewController (Private)
- (void) setupInfo;
@ -356,7 +359,7 @@
const CGFloat progress = [[peer objectForKey: @"Progress"] floatValue];
NSString * progressString = [NSString localizedStringWithFormat: NSLocalizedString(@"Progress: %.1f%%",
"Inspector -> Peers tab -> table row tooltip"), progress * 100.0];
"Inspector -> Peers tab -> table row tooltip"), tr_truncd(progress * 100.0, 1)];
if (progress < 1.0 && [[peer objectForKey: @"Seed"] boolValue])
progressString = [progressString stringByAppendingFormat: @" (%@)", NSLocalizedString(@"Partial Seed",
"Inspector -> Peers tab -> table row tooltip")];

View File

@ -25,6 +25,9 @@
#import "PeerProgressIndicatorCell.h"
#import "NSApplicationAdditions.h"
#import "transmission.h" // required by utils.h
#import "utils.h"
@implementation PeerProgressIndicatorCell
- (id) copyWithZone: (NSZone *) zone
@ -60,7 +63,8 @@
[paragraphStyle release];
}
[[NSString localizedStringWithFormat: @"%.1f%%", [self floatValue] * 100.0] drawInRect: cellFrame withAttributes: fAttributes];
[[NSString localizedStringWithFormat: @"%.1f%%", tr_truncd([self floatValue] * 100.0, 1)] drawInRect: cellFrame
withAttributes: fAttributes];
}
else
{

View File

@ -767,7 +767,7 @@ int trashDataFile(const char * filename)
- (CGFloat) progress
{
return fStat->percentComplete;
return .9999999;//fStat->percentComplete;
}
- (CGFloat) progressDone
@ -929,7 +929,7 @@ int trashDataFile(const char * filename)
{
NSString * progressString = fStat->metadataPercentComplete > 0.0
? [NSString localizedStringWithFormat: NSLocalizedString(@"%.2f%% of torrent metadata retrieved",
"Torrent -> progress string"), 100.0 * fStat->metadataPercentComplete]
"Torrent -> progress string"), tr_truncd(100.0 * fStat->metadataPercentComplete, 2)]
: NSLocalizedString(@"torrent metadata needed", "Torrent -> progress string");
return [NSString stringWithFormat: @"%@ - %@", NSLocalizedString(@"Magnetized transfer", "Torrent -> progress string"),
@ -954,7 +954,7 @@ int trashDataFile(const char * filename)
progress = 100.0 * [self progress];
}
string = [NSString localizedStringWithFormat: @"%@ (%.2f%%)", string, progress];
string = [NSString localizedStringWithFormat: @"%@ (%.2f%%)", string, tr_truncd(progress, 2)];
}
else
{
@ -969,7 +969,8 @@ int trashDataFile(const char * filename)
downloadString = [NSString stringWithFormat: NSLocalizedString(@"%@ of %@", "Torrent -> progress string"),
[NSString stringForFileSize: [self haveTotal]], [NSString stringForFileSize: [self size]]];
downloadString = [NSString localizedStringWithFormat: @"%@ (%.2f%%)", downloadString, 100.0 * [self progress]];
downloadString = [NSString localizedStringWithFormat: @"%@ (%.2f%%)",
downloadString, tr_truncd(100.0 * [self progress], 2)];
}
}
else
@ -1030,7 +1031,8 @@ int trashDataFile(const char * filename)
case TR_STATUS_CHECK:
string = [NSString localizedStringWithFormat: @"%@ (%.2f%%)",
NSLocalizedString(@"Checking existing data", "Torrent -> status string"), 100.0 * [self checkingProgress]];
NSLocalizedString(@"Checking existing data", "Torrent -> status string"),
tr_truncd(100.0 * [self checkingProgress], 2)];
break;
case TR_STATUS_DOWNLOAD:
@ -1109,7 +1111,8 @@ int trashDataFile(const char * filename)
case TR_STATUS_CHECK:
string = [NSString localizedStringWithFormat: @"%@ (%.2f%%)",
NSLocalizedString(@"Checking existing data", "Torrent -> status string"), 100.0 * [self checkingProgress]];
NSLocalizedString(@"Checking existing data", "Torrent -> status string"),
tr_truncd(100.0 * [self checkingProgress], 2)];
break;
case TR_STATUS_DOWNLOAD:
@ -1162,7 +1165,8 @@ int trashDataFile(const char * filename)
case TR_STATUS_CHECK:
return [NSString localizedStringWithFormat: @"%@ (%.2f%%)",
NSLocalizedString(@"Checking existing data", "Torrent -> status string"), 100.0 * [self checkingProgress]];
NSLocalizedString(@"Checking existing data", "Torrent -> status string"),
tr_truncd(100.0 * [self checkingProgress], 2)];
case TR_STATUS_DOWNLOAD:
return NSLocalizedString(@"Downloading", "Torrent -> status string");