Changeset 6917


Ignore:
Timestamp:
Oct 16, 2008, 3:44:54 AM (13 years ago)
Author:
livings124
Message:

#1354 Torrent Inspector Activity: Group Ratio

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r6887 r6917  
    4646#import "ExpandedPathToIconTransformer.h"
    4747#import "SpeedLimitToTurtleIconTransformer.h"
    48 #include "utils.h" //tr_getRatio()
     48#include "utils.h"
    4949
    5050#import "UKKQueue.h"
     
    26342634        else
    26352635        {
     2636            TorrentGroup * group = (TorrentGroup *)item;
     2637           
    26362638            if ([fDefaults boolForKey: @"DisplayGroupRowRatio"])
    2637             {
    2638                 uint64_t uploaded = 0, downloaded = 0;
    2639                 NSEnumerator * enumerator = [[item torrents] objectEnumerator];
    2640                 Torrent * torrent;
    2641                 while ((torrent = [enumerator nextObject]))
    2642                 {
    2643                     uploaded += [torrent uploadedTotal];
    2644                     downloaded += [torrent downloadedTotal];
    2645                 }
    2646                
    2647                 return [NSString stringForRatio: tr_getRatio(uploaded, downloaded)];
    2648             }
     2639                return [NSString stringForRatio: [group ratio]];
    26492640            else
    26502641            {
    2651                 BOOL upload = [ident isEqualToString: @"UL"];
    2652                
    2653                 float rate = 0.0;
    2654                 NSEnumerator * enumerator = [[item torrents] objectEnumerator];
    2655                 Torrent * torrent;
    2656                 while ((torrent = [enumerator nextObject]))
    2657                     rate += upload ? [torrent uploadRate] : [torrent downloadRate];
    2658                
     2642                float rate = [ident isEqualToString: @"UL"] ? [group uploadRate] : [group downloadRate];
    26592643                return [NSString stringForSpeed: rate];
    26602644            }
  • trunk/macosx/InfoWindowController.m

    r6887 r6917  
    3131#import "NSApplicationAdditions.h"
    3232#import "NSStringAdditions.h"
     33#include "utils.h" //tr_getRatio()
    3334
    3435#define TAB_INFO_IDENT @"Info"
     
    280281            [fFailedHashField setStringValue: @""];
    281282            [fDateActivityField setStringValue: @""];
     283            [fRatioField setStringValue: @""];
    282284           
    283285            //options fields
     
    336338        [fStateField setStringValue: @""];
    337339        [fProgressField setStringValue: @""];
    338         [fRatioField setStringValue: @""];
    339340       
    340341        [fSwarmSpeedField setStringValue: @""];
     
    13711372        [fPiecesView updateView];
    13721373    }
     1374    else if (numberSelected > 1)
     1375    {
     1376        [fRatioField setStringValue: [NSString stringForRatio: tr_getRatio(uploadedTotal, downloadedTotal)]];
     1377    }
     1378    else;
    13731379}
    13741380
  • trunk/macosx/TorrentGroup.h

    r6359 r6917  
    3636- (NSMutableArray *) torrents;
    3737
     38- (float) ratio;
     39- (float) uploadRate;
     40- (float) downloadRate;
     41
    3842@end
  • trunk/macosx/TorrentGroup.m

    r6276 r6917  
    2424
    2525#import "TorrentGroup.h"
     26#import "Torrent.h"
     27#include "utils.h" //tr_getRatio()
    2628
    2729@implementation TorrentGroup
     
    5355}
    5456
     57- (float) ratio
     58{
     59    uint64_t uploaded = 0, downloaded = 0;
     60    NSEnumerator * enumerator = [fTorrents objectEnumerator];
     61    Torrent * torrent;
     62    while ((torrent = [enumerator nextObject]))
     63    {
     64        uploaded += [torrent uploadedTotal];
     65        downloaded += [torrent downloadedTotal];
     66    }
     67   
     68    return tr_getRatio(uploaded, downloaded);
     69}
     70
     71- (float) uploadRate
     72{
     73    float rate = 0.0;
     74    NSEnumerator * enumerator = [fTorrents objectEnumerator];
     75    Torrent * torrent;
     76    while ((torrent = [enumerator nextObject]))
     77        rate += [torrent uploadRate];
     78   
     79    return rate;
     80}
     81
     82- (float) downloadRate
     83{
     84    float rate = 0.0;
     85    NSEnumerator * enumerator = [fTorrents objectEnumerator];
     86    Torrent * torrent;
     87    while ((torrent = [enumerator nextObject]))
     88        rate += [torrent downloadRate];
     89   
     90    return rate;
     91}
     92
    5593@end
Note: See TracChangeset for help on using the changeset viewer.