mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
remove unused field from the tracker inspector tab; merge code for converting time into a string
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -49,8 +49,7 @@
|
||||
IBOutlet NSTextView * fCommentView;
|
||||
IBOutlet NSButton * fRevealDataButton, * fRevealTorrentButton;
|
||||
|
||||
IBOutlet NSTextField * fAnnounceAddressField, * fAnnounceLastField, * fAnnounceResponseField,
|
||||
* fAnnounceNextField, * fAnnounceManualField,
|
||||
IBOutlet NSTextField * fAnnounceAddressField, * fAnnounceLastField, * fAnnounceResponseField, * fAnnounceNextField,
|
||||
* fScrapeAddressField, * fScrapeLastField, * fScrapeResponseField, * fScrapeNextField;
|
||||
|
||||
IBOutlet NSTableView * fPeerTable;
|
||||
|
||||
@@ -293,7 +293,6 @@ typedef enum
|
||||
[fAnnounceResponseField setToolTip: nil];
|
||||
[fAnnounceResponseField setSelectable: NO];
|
||||
[fAnnounceNextField setStringValue: @""];
|
||||
[fAnnounceManualField setStringValue: @""];
|
||||
|
||||
[fScrapeAddressField setStringValue: @""];
|
||||
[fScrapeAddressField setToolTip: nil];
|
||||
@@ -1086,11 +1085,8 @@ typedef enum
|
||||
[fAnnounceResponseField setToolTip: announceResponse];
|
||||
[fAnnounceResponseField setSelectable: ![announceResponse isEqualToString: @""]];
|
||||
|
||||
#warning format into minutes, etc.
|
||||
int announceNext = [torrent nextAnnounceTime];
|
||||
[fAnnounceNextField setStringValue: announceNext > 0 ? [NSString stringWithFormat: @"%d sec", announceNext] : @""];
|
||||
|
||||
[fAnnounceManualField setStringValue: @""];
|
||||
[fAnnounceNextField setStringValue: announceNext > 0 ? [NSString timeString: announceNext showSeconds: YES] : @""];
|
||||
|
||||
//scrape fields
|
||||
NSString * scrapeAddress = [[torrent trackerAddress] stringByAppendingString: [torrent trackerAddressScrape]];
|
||||
@@ -1105,7 +1101,7 @@ typedef enum
|
||||
[fScrapeResponseField setSelectable: ![scrapeResponse isEqualToString: @""]];
|
||||
|
||||
int scrapeNext = [torrent nextScrapeTime];
|
||||
[fScrapeNextField setStringValue: scrapeNext > 0 ? [NSString stringWithFormat: @"%d sec", scrapeNext] : @""];
|
||||
[fScrapeNextField setStringValue: scrapeNext > 0 ? [NSString timeString: scrapeNext showSeconds: YES] : @""];
|
||||
}
|
||||
|
||||
- (void) updateInfoPeers
|
||||
|
||||
@@ -35,6 +35,9 @@
|
||||
+ (NSString *) stringForSpeedAbbrev: (float) speed;
|
||||
+ (NSString *) stringForRatio: (float) ratio;
|
||||
|
||||
+ (NSString *) timeString: (uint64_t) seconds showSeconds: (BOOL) showSeconds;
|
||||
+ (NSString *) timeString: (uint64_t) seconds showSeconds: (BOOL) showSeconds maxDigits: (NSUInteger) max;
|
||||
|
||||
- (NSComparisonResult) compareIP: (NSString *) string;
|
||||
|
||||
@end
|
||||
|
||||
@@ -102,6 +102,44 @@
|
||||
return [NSString stringWithFormat: @"%.0f", ratio];
|
||||
}
|
||||
|
||||
+ (NSString *) timeString: (uint64_t) seconds showSeconds: (BOOL) showSeconds
|
||||
{
|
||||
return [NSString timeString: seconds showSeconds:showSeconds maxDigits: INT_MAX];
|
||||
}
|
||||
|
||||
+ (NSString *) timeString: (uint64_t) seconds showSeconds: (BOOL) showSeconds maxDigits: (NSUInteger) max
|
||||
{
|
||||
NSMutableArray * timeArray = [NSMutableArray arrayWithCapacity: 3];
|
||||
uint64_t remaining = seconds;
|
||||
|
||||
if (seconds >= 86400) //24 * 60 * 60
|
||||
{
|
||||
int days = remaining / 86400;
|
||||
if (days == 1)
|
||||
[timeArray addObject: NSLocalizedString(@"1 day", "time string")];
|
||||
else
|
||||
[timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d days", "time string"), days]];
|
||||
remaining %= 86400;
|
||||
max--;
|
||||
}
|
||||
if (max > 0 && seconds >= 3600) //60 * 60
|
||||
{
|
||||
[timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d hr", "time string"), remaining / 3600]];
|
||||
remaining %= 3600;
|
||||
max--;
|
||||
}
|
||||
if (max > 0 && (!showSeconds || seconds >= 60))
|
||||
{
|
||||
[timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d min", "time string"), remaining / 60]];
|
||||
remaining %= 60;
|
||||
max--;
|
||||
}
|
||||
if (max > 0 && showSeconds)
|
||||
[timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d sec", "time string"), remaining]];
|
||||
|
||||
return [timeArray componentsJoinedByString: @" "];
|
||||
}
|
||||
|
||||
- (NSComparisonResult) compareIP: (NSString *) string
|
||||
{
|
||||
NSArray * selfSections = [self componentsSeparatedByString: @"."],
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
@interface StatsWindowController (Private)
|
||||
|
||||
- (void) updateStats;
|
||||
- (NSString *) timeString: (uint64_t) seconds;
|
||||
|
||||
@end
|
||||
|
||||
@@ -101,8 +100,8 @@ tr_handle * fLib;
|
||||
: NSLocalizedString(@"Total N/A", "stats total");
|
||||
[fRatioAllField setStringValue: totalRatioString];
|
||||
|
||||
[fTimeField setStringValue: [self timeString: statsSession.secondsActive]];
|
||||
[fTimeAllField setStringValue: [[self timeString: statsAll.secondsActive]
|
||||
[fTimeField setStringValue: [NSString timeString: statsSession.secondsActive showSeconds: NO]];
|
||||
[fTimeAllField setStringValue: [[NSString timeString: statsAll.secondsActive showSeconds: NO]
|
||||
stringByAppendingString: NSLocalizedString(@" total", "stats total")]];
|
||||
|
||||
if (statsAll.sessionCount == 1)
|
||||
@@ -112,29 +111,4 @@ tr_handle * fLib;
|
||||
statsAll.sessionCount]];
|
||||
}
|
||||
|
||||
- (NSString *) timeString: (uint64_t) seconds
|
||||
{
|
||||
NSMutableArray * timeArray = [NSMutableArray arrayWithCapacity: 3];
|
||||
uint64_t remaining = seconds;
|
||||
|
||||
if (seconds >= 86400) //24 * 60 * 60
|
||||
{
|
||||
int days = remaining / 86400;
|
||||
if (days == 1)
|
||||
[timeArray addObject: NSLocalizedString(@"1 day", "stats window -> running time")];
|
||||
else
|
||||
[timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d days", "stats window -> running time"), days]];
|
||||
remaining %= 86400;
|
||||
}
|
||||
if (seconds >= 3600) //60 * 60
|
||||
{
|
||||
[timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d hr", "stats window -> running time"),
|
||||
remaining / 3600]];
|
||||
remaining %= 3600;
|
||||
}
|
||||
[timeArray addObject: [NSString stringWithFormat: NSLocalizedString(@"%d min", "stats window -> running time"), remaining / 60]];
|
||||
|
||||
return [timeArray componentsJoinedByString: @" "];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -178,7 +178,6 @@ typedef enum
|
||||
|
||||
- (int) eta;
|
||||
- (int) etaRatio;
|
||||
- (NSString *) etaString: (int) eta;
|
||||
|
||||
- (float) notAvailableDesired;
|
||||
|
||||
|
||||
@@ -855,29 +855,6 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
||||
return (float)MAX([self downloadedTotal], [self haveVerified]) * (stopRatio - ratio) / uploadRate / 1024.0;
|
||||
}
|
||||
|
||||
- (NSString * ) etaString: (int) eta
|
||||
{
|
||||
if (eta < 0)
|
||||
return @"";
|
||||
|
||||
if (eta < 60)
|
||||
return [NSString stringWithFormat: NSLocalizedString(@"%d sec", "Torrent -> remaining time"), eta];
|
||||
else if (eta < 3600) //60 * 60
|
||||
return [NSString stringWithFormat: NSLocalizedString(@"%d min %02d sec", "Torrent -> remaining time"),
|
||||
eta / 60, eta % 60];
|
||||
else if (eta < 86400) //24 * 60 * 60
|
||||
return [NSString stringWithFormat: NSLocalizedString(@"%d hr %02d min", "Torrent -> remaining time"),
|
||||
eta / 3600, (eta / 60) % 60];
|
||||
else
|
||||
{
|
||||
int days = eta / 86400, hours = (eta / 3600) % 24;
|
||||
if (days > 1)
|
||||
return [NSString stringWithFormat: NSLocalizedString(@"%d days %02d hr", "Torrent -> remaining time"), days, hours];
|
||||
else
|
||||
return [NSString stringWithFormat: NSLocalizedString(@"1 day %02d hr", "Torrent -> remaining time"), hours];
|
||||
}
|
||||
}
|
||||
|
||||
- (float) notAvailableDesired
|
||||
{
|
||||
return (float)(fStat->desiredSize - fStat->desiredAvailable) / [self size];
|
||||
@@ -1002,7 +979,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
||||
{
|
||||
int eta = fStat->status == TR_STATUS_DOWNLOAD ? [self eta] : [self etaRatio];
|
||||
string = eta >= 0 ? [string stringByAppendingFormat: NSLocalizedString(@" - %@ remaining", "Torrent -> progress string"),
|
||||
[self etaString: eta]]
|
||||
[NSString timeString: eta showSeconds: YES maxDigits: 2]]
|
||||
: [string stringByAppendingString: NSLocalizedString(@" - remaining time unknown", "Torrent -> progress string")];
|
||||
}
|
||||
|
||||
@@ -1141,7 +1118,8 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
||||
return [self shortStatusString];
|
||||
|
||||
int eta = [self isSeeding] ? [self etaRatio] : [self eta];
|
||||
return eta >= 0 ? [self etaString: eta] : NSLocalizedString(@"Unknown", "Torrent -> remaining time");
|
||||
return eta >= 0 ? [NSString timeString: eta showSeconds: YES maxDigits: 2]
|
||||
: NSLocalizedString(@"Unknown", "Torrent -> remaining time");
|
||||
}
|
||||
|
||||
- (NSString *) stateString
|
||||
|
||||
Reference in New Issue
Block a user