#1354 Torrent Inspector Activity: Group Ratio
This commit is contained in:
parent
919b47bfb1
commit
db9f3310d2
|
@ -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
|
||||
{
|
||||
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];
|
||||
}
|
||||
TorrentGroup * group = (TorrentGroup *)item;
|
||||
|
||||
return [NSString stringForRatio: tr_getRatio(uploaded, downloaded)];
|
||||
}
|
||||
if ([fDefaults boolForKey: @"DisplayGroupRowRatio"])
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -35,4 +35,8 @@
|
|||
- (NSInteger) groupIndex;
|
||||
- (NSMutableArray *) torrents;
|
||||
|
||||
- (float) ratio;
|
||||
- (float) uploadRate;
|
||||
- (float) downloadRate;
|
||||
|
||||
@end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue