Changeset 5156


Ignore:
Timestamp:
Feb 28, 2008, 2:17:17 AM (14 years ago)
Author:
livings124
Message:

clicking on the group speed rates will toggle with ratio

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r5148 r5156  
    4343#import "ExpandedPathToIconTransformer.h"
    4444#import "SpeedLimitToTurtleIconTransformer.h"
     45#include "utils.h" //tr_getRatio()
    4546
    4647#import <Sparkle/Sparkle.h>
     
    24962497                                : [NSImage imageNamed: NSImageNameStopProgressTemplate];
    24972498        }
     2499        else if ([ident isEqualToString: @"DL Image"])
     2500            return ![fDefaults boolForKey: @"DisplayGroupRowRatio"] ? [NSImage imageNamed: @"DownArrowGroupTemplate.png"] : nil;
    24982501        else if ([ident isEqualToString: @"UL Image"])
    2499             return [NSImage imageNamed: @"UpArrowGroupTemplate.png"];
    2500         else if ([ident isEqualToString: @"DL Image"])
    2501             return [NSImage imageNamed: @"DownArrowGroupTemplate.png"];
     2502            return [NSImage imageNamed: [fDefaults boolForKey: @"DisplayGroupRowRatio"]
     2503                                        ? @"YingYangTemplate.png" : @"UpArrowGroupTemplate.png"];
    25022504        else
    25032505        {
    25042506            BOOL upload = [ident isEqualToString: @"UL"];
    2505            
    2506             float rate = 0.0;
    2507             NSEnumerator * enumerator = [[item objectForKey: @"Torrents"] objectEnumerator];
    2508             Torrent * torrent;
    2509             while ((torrent = [enumerator nextObject]))
    2510                 rate += upload ? [torrent uploadRate] : [torrent downloadRate];
    2511            
    2512             return [NSString stringForSpeed: rate];
     2507            if ([fDefaults boolForKey: @"DisplayGroupRowRatio"])
     2508            {
     2509                if (!upload)
     2510                    return nil;
     2511               
     2512                uint64_t uploaded = 0, downloaded = 0;
     2513                NSEnumerator * enumerator = [[item objectForKey: @"Torrents"] objectEnumerator];
     2514                Torrent * torrent;
     2515                while ((torrent = [enumerator nextObject]))
     2516                {
     2517                    uploaded += [torrent uploadedTotal];
     2518                    downloaded += [torrent downloadedTotal];
     2519                }
     2520               
     2521                return [NSString stringForRatio: tr_getRatio(uploaded, downloaded)];
     2522            }
     2523            else
     2524            {
     2525                float rate = 0.0;
     2526                NSEnumerator * enumerator = [[item objectForKey: @"Torrents"] objectEnumerator];
     2527                Torrent * torrent;
     2528                while ((torrent = [enumerator nextObject]))
     2529                    rate += upload ? [torrent uploadRate] : [torrent downloadRate];
     2530               
     2531                return [NSString stringForSpeed: rate];
     2532            }
    25132533        }
    25142534    }
  • trunk/macosx/Defaults.plist

    r4752 r5156  
    3434        <string>~/Desktop</string>
    3535        <key>DeleteOriginalTorrent</key>
     36        <false/>
     37        <key>DisplayGroupRowRatio</key>
    3638        <false/>
    3739        <key>DisplayPeerProgressBarNumber</key>
  • trunk/macosx/TorrentTableView.m

    r5128 r5156  
    4646- (BOOL) pointInProgressRect: (NSPoint) point;
    4747- (BOOL) pointInMinimalStatusRect: (NSPoint) point;
     48
     49- (BOOL) pointInGroupStatusRect: (NSPoint) point;
     50
    4851- (void) updateFileMenu: (NSMenu *) menu forFiles: (NSArray *) files;
    4952
     
    338341{
    339342    NSPoint point = [self convertPoint: [event locationInWindow] fromView: nil];
     343   
     344    //check to toggle group status before anything else
     345    if ([self pointInGroupStatusRect: point])
     346    {
     347        [fDefaults setBool: ![fDefaults boolForKey: @"DisplayGroupRowRatio"] forKey: @"DisplayGroupRowRatio"];
     348        [self reloadData];
     349        return;
     350    }
    340351   
    341352    BOOL pushed = [self pointInControlRect: point] || [self pointInRevealRect: point] || [self pointInActionRect: point]
     
    752763    }
    753764    return NSPointInRect(point, [cell minimalStatusRectForBounds: [self rectOfRow: row]]);
     765}
     766
     767- (BOOL) pointInGroupStatusRect: (NSPoint) point
     768{
     769    int row = [self rowAtPoint: point];
     770    if (row < 0 || [[self itemAtRow: row] isKindOfClass: [Torrent class]])
     771        return NO;
     772   
     773    NSString * ident = [[[self tableColumns] objectAtIndex: [self columnAtPoint: point]] identifier];
     774    return [ident isEqualToString: @"UL"] || [ident isEqualToString: @"UL Image"]
     775            || (([ident isEqualToString: @"DL"] || [ident isEqualToString: @"DL Image"])
     776            && ![fDefaults boolForKey: @"DisplayGroupRowRatio"]);
    754777}
    755778
Note: See TracChangeset for help on using the changeset viewer.