#1354 Torrent Inspector Activity: Group Ratio
This commit is contained in:
parent
919b47bfb1
commit
db9f3310d2
|
@ -45,7 +45,7 @@
|
||||||
#import "ExpandedPathToPathTransformer.h"
|
#import "ExpandedPathToPathTransformer.h"
|
||||||
#import "ExpandedPathToIconTransformer.h"
|
#import "ExpandedPathToIconTransformer.h"
|
||||||
#import "SpeedLimitToTurtleIconTransformer.h"
|
#import "SpeedLimitToTurtleIconTransformer.h"
|
||||||
#include "utils.h" //tr_getRatio()
|
#include "utils.h"
|
||||||
|
|
||||||
#import "UKKQueue.h"
|
#import "UKKQueue.h"
|
||||||
#import <Sparkle/Sparkle.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"];
|
? @"YingYangGroupTemplate.png" : @"UpArrowGroupTemplate.png"];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
TorrentGroup * group = (TorrentGroup *)item;
|
||||||
|
|
||||||
if ([fDefaults boolForKey: @"DisplayGroupRowRatio"])
|
if ([fDefaults boolForKey: @"DisplayGroupRowRatio"])
|
||||||
{
|
return [NSString stringForRatio: [group ratio]];
|
||||||
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)];
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOL upload = [ident isEqualToString: @"UL"];
|
float rate = [ident isEqualToString: @"UL"] ? [group uploadRate] : [group downloadRate];
|
||||||
|
|
||||||
float rate = 0.0;
|
|
||||||
NSEnumerator * enumerator = [[item torrents] objectEnumerator];
|
|
||||||
Torrent * torrent;
|
|
||||||
while ((torrent = [enumerator nextObject]))
|
|
||||||
rate += upload ? [torrent uploadRate] : [torrent downloadRate];
|
|
||||||
|
|
||||||
return [NSString stringForSpeed: rate];
|
return [NSString stringForSpeed: rate];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#import "QuickLookController.h"
|
#import "QuickLookController.h"
|
||||||
#import "NSApplicationAdditions.h"
|
#import "NSApplicationAdditions.h"
|
||||||
#import "NSStringAdditions.h"
|
#import "NSStringAdditions.h"
|
||||||
|
#include "utils.h" //tr_getRatio()
|
||||||
|
|
||||||
#define TAB_INFO_IDENT @"Info"
|
#define TAB_INFO_IDENT @"Info"
|
||||||
#define TAB_ACTIVITY_IDENT @"Activity"
|
#define TAB_ACTIVITY_IDENT @"Activity"
|
||||||
|
@ -279,6 +280,7 @@ typedef enum
|
||||||
[fUploadedTotalField setStringValue: @""];
|
[fUploadedTotalField setStringValue: @""];
|
||||||
[fFailedHashField setStringValue: @""];
|
[fFailedHashField setStringValue: @""];
|
||||||
[fDateActivityField setStringValue: @""];
|
[fDateActivityField setStringValue: @""];
|
||||||
|
[fRatioField setStringValue: @""];
|
||||||
|
|
||||||
//options fields
|
//options fields
|
||||||
[fUploadLimitPopUp setEnabled: NO];
|
[fUploadLimitPopUp setEnabled: NO];
|
||||||
|
@ -335,7 +337,6 @@ typedef enum
|
||||||
|
|
||||||
[fStateField setStringValue: @""];
|
[fStateField setStringValue: @""];
|
||||||
[fProgressField setStringValue: @""];
|
[fProgressField setStringValue: @""];
|
||||||
[fRatioField setStringValue: @""];
|
|
||||||
|
|
||||||
[fSwarmSpeedField setStringValue: @""];
|
[fSwarmSpeedField setStringValue: @""];
|
||||||
[fErrorMessageView setString: @""];
|
[fErrorMessageView setString: @""];
|
||||||
|
@ -1370,6 +1371,11 @@ typedef enum
|
||||||
|
|
||||||
[fPiecesView updateView];
|
[fPiecesView updateView];
|
||||||
}
|
}
|
||||||
|
else if (numberSelected > 1)
|
||||||
|
{
|
||||||
|
[fRatioField setStringValue: [NSString stringForRatio: tr_getRatio(uploadedTotal, downloadedTotal)]];
|
||||||
|
}
|
||||||
|
else;
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning reload table when necessary?
|
#warning reload table when necessary?
|
||||||
|
|
|
@ -35,4 +35,8 @@
|
||||||
- (NSInteger) groupIndex;
|
- (NSInteger) groupIndex;
|
||||||
- (NSMutableArray *) torrents;
|
- (NSMutableArray *) torrents;
|
||||||
|
|
||||||
|
- (float) ratio;
|
||||||
|
- (float) uploadRate;
|
||||||
|
- (float) downloadRate;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#import "TorrentGroup.h"
|
#import "TorrentGroup.h"
|
||||||
|
#import "Torrent.h"
|
||||||
|
#include "utils.h" //tr_getRatio()
|
||||||
|
|
||||||
@implementation TorrentGroup
|
@implementation TorrentGroup
|
||||||
|
|
||||||
|
@ -52,4 +54,40 @@
|
||||||
return fTorrents;
|
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
|
@end
|
||||||
|
|
Loading…
Reference in New Issue