1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00

#1354 Torrent Inspector Activity: Group Ratio

This commit is contained in:
Mitchell Livingston 2008-10-16 03:44:54 +00:00
parent 919b47bfb1
commit db9f3310d2
4 changed files with 54 additions and 22 deletions

View file

@ -45,7 +45,7 @@
#import "ExpandedPathToPathTransformer.h"
#import "ExpandedPathToIconTransformer.h"
#import "SpeedLimitToTurtleIconTransformer.h"
#include "utils.h" //tr_getRatio()
#include "utils.h"
#import "UKKQueue.h"
#import <Sparkle/Sparkle.h>
@ -2633,29 +2633,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
? @"YingYangGroupTemplate.png" : @"UpArrowGroupTemplate.png"];
else
{
TorrentGroup * group = (TorrentGroup *)item;
if ([fDefaults boolForKey: @"DisplayGroupRowRatio"])
{
uint64_t uploaded = 0, downloaded = 0;
NSEnumerator * enumerator = [[item torrents] objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
{
uploaded += [torrent uploadedTotal];
downloaded += [torrent downloadedTotal];
}
return [NSString stringForRatio: tr_getRatio(uploaded, downloaded)];
}
return [NSString stringForRatio: [group ratio]];
else
{
BOOL upload = [ident isEqualToString: @"UL"];
float rate = 0.0;
NSEnumerator * enumerator = [[item torrents] objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
rate += upload ? [torrent uploadRate] : [torrent downloadRate];
float rate = [ident isEqualToString: @"UL"] ? [group uploadRate] : [group downloadRate];
return [NSString stringForSpeed: rate];
}
}

View file

@ -30,6 +30,7 @@
#import "QuickLookController.h"
#import "NSApplicationAdditions.h"
#import "NSStringAdditions.h"
#include "utils.h" //tr_getRatio()
#define TAB_INFO_IDENT @"Info"
#define TAB_ACTIVITY_IDENT @"Activity"
@ -279,6 +280,7 @@ typedef enum
[fUploadedTotalField setStringValue: @""];
[fFailedHashField setStringValue: @""];
[fDateActivityField setStringValue: @""];
[fRatioField setStringValue: @""];
//options fields
[fUploadLimitPopUp setEnabled: NO];
@ -335,7 +337,6 @@ typedef enum
[fStateField setStringValue: @""];
[fProgressField setStringValue: @""];
[fRatioField setStringValue: @""];
[fSwarmSpeedField setStringValue: @""];
[fErrorMessageView setString: @""];
@ -1370,6 +1371,11 @@ typedef enum
[fPiecesView updateView];
}
else if (numberSelected > 1)
{
[fRatioField setStringValue: [NSString stringForRatio: tr_getRatio(uploadedTotal, downloadedTotal)]];
}
else;
}
#warning reload table when necessary?

View file

@ -35,4 +35,8 @@
- (NSInteger) groupIndex;
- (NSMutableArray *) torrents;
- (float) ratio;
- (float) uploadRate;
- (float) downloadRate;
@end

View file

@ -23,6 +23,8 @@
*****************************************************************************/
#import "TorrentGroup.h"
#import "Torrent.h"
#include "utils.h" //tr_getRatio()
@implementation TorrentGroup
@ -52,4 +54,40 @@
return fTorrents;
}
- (float) ratio
{
uint64_t uploaded = 0, downloaded = 0;
NSEnumerator * enumerator = [fTorrents objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
{
uploaded += [torrent uploadedTotal];
downloaded += [torrent downloadedTotal];
}
return tr_getRatio(uploaded, downloaded);
}
- (float) uploadRate
{
float rate = 0.0;
NSEnumerator * enumerator = [fTorrents objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
rate += [torrent uploadRate];
return rate;
}
- (float) downloadRate
{
float rate = 0.0;
NSEnumerator * enumerator = [fTorrents objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
rate += [torrent downloadRate];
return rate;
}
@end