Changeset 6885


Ignore:
Timestamp:
Oct 12, 2008, 1:22:13 PM (13 years ago)
Author:
livings124
Message:

In the file inspector tab, show progress and size for folders

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r6883 r6885  
    1010- Mac
    1111   + Option to automatically update the blocklist weekly
     12   + In the file inspector tab, show progress and size for folders
    1213   + Sparkle updated to 1.5
    1314- GTK+
  • trunk/macosx/FileNameCell.m

    r5915 r6885  
    3636#define PADDING_ABOVE_TITLE_FILE 2.0
    3737#define PADDING_BELOW_STATUS_FILE 2.0
     38#define PADDING_BETWEEN_NAME_AND_FOLDER_STATUS 4.0
    3839
    3940@interface FileNameCell (Private)
    4041
    4142- (NSRect) rectForTitleWithString: (NSAttributedString *) string inBounds: (NSRect) bounds;
    42 - (NSRect) rectForStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds;
     43- (NSRect) rectForStatusWithString: (NSAttributedString *) string withTitleRect: (NSRect) titleRect inBounds: (NSRect) bounds;
    4344
    4445- (NSAttributedString *) attributedTitleWithColor: (NSColor *) color;
     
    130131- (NSRect) statusRectForBounds: (NSRect) bounds
    131132{
    132     return [self rectForStatusWithString: [self attributedStatusWithColor: nil] inBounds: bounds];
     133    return [self rectForStatusWithString: [self attributedStatusWithColor: nil]
     134            withTitleRect: [(FileListNode *)[self objectValue] isFolder] ? [self titleRectForBounds: bounds] : NSZeroRect
     135            inBounds: bounds];
    133136}
    134137
     
    143146            && [[self highlightColorWithFrame: cellFrame inView: controlView] isEqual: [NSColor alternateSelectedControlColor]])
    144147        specialColor = [NSColor whiteColor];
    145     else if ([[(FileOutlineView *)[self controlView] torrent] checkForFiles:
    146                 [(FileListNode *)[self objectValue] indexes]] == NSOffState)
     148    else if ([[(FileOutlineView *)[self controlView] torrent] checkForFiles: [(FileListNode *)[self objectValue] indexes]] == NSOffState)
    147149        specialColor = [NSColor disabledControlTextColor];
    148150    else;
     
    153155   
    154156    //status
    155     if (![(FileListNode *)[self objectValue] isFolder])
    156     {
    157         NSAttributedString * statusString = [self attributedStatusWithColor: specialColor ? specialColor : [NSColor darkGrayColor]];
    158         NSRect statusRect = [self rectForStatusWithString: statusString inBounds: cellFrame];
    159         [statusString drawInRect: statusRect];
    160     }
     157    NSAttributedString * statusString = [self attributedStatusWithColor: specialColor ? specialColor : [NSColor darkGrayColor]];
     158    NSRect statusRect = [self rectForStatusWithString: statusString withTitleRect: titleRect inBounds: cellFrame];
     159    [statusString drawInRect: statusRect];
    161160}
    162161
     
    187186}
    188187
    189 - (NSRect) rectForStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds
    190 {
    191     if ([(FileListNode *)[self objectValue] isFolder])
    192         return NSZeroRect;
    193    
     188- (NSRect) rectForStatusWithString: (NSAttributedString *) string withTitleRect: (NSRect) titleRect inBounds: (NSRect) bounds;
     189{
    194190    NSSize statusSize = [string size];
    195191   
    196     NSRect result = bounds;
    197    
    198     result.origin.x += PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
    199     result.origin.y += result.size.height - PADDING_BELOW_STATUS_FILE - statusSize.height;
    200    
     192    NSRect result;
     193   
     194    if (![(FileListNode *)[self objectValue] isFolder])
     195    {
     196        result = bounds;
     197        result.origin.x += PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
     198        result.origin.y += result.size.height - PADDING_BELOW_STATUS_FILE - statusSize.height;
     199    }
     200    else
     201    {
     202        result.origin.x = NSMaxX(titleRect) + PADDING_BETWEEN_NAME_AND_FOLDER_STATUS;
     203        result.origin.y = NSMaxY(titleRect) - statusSize.height - 1.0;
     204    }
     205       
    201206    result.size = statusSize;
    202207    result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONAL);
     
    221226    Torrent * torrent = [(FileOutlineView *)[self controlView] torrent];
    222227    FileListNode * node = (FileListNode *)[self objectValue];
    223     float percent = [torrent fileProgress: [[node indexes] firstIndex]] * 100.0;
    224    
    225     NSString * status = [NSString localizedStringWithFormat: NSLocalizedString(@"%.2f%% of %@",
    226                             "Inspector -> Files tab -> file status string"), percent, [NSString stringForFileSize: [node size]]];
     228   
     229    NSString * percentString;
     230    float progress = [torrent fileProgress: node];
     231    percentString = progress == 1.0 ? @"100%" : [NSString localizedStringWithFormat: @"%.2f%%", progress * 100.0];
     232   
     233   
     234    NSString * status = [NSString localizedStringWithFormat: NSLocalizedString(@"%@ of %@",
     235                            "Inspector -> Files tab -> file status string"), percentString, [NSString stringForFileSize: [node size]]];
    227236   
    228237    return [[[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes] autorelease];
  • trunk/macosx/InfoWindowController.m

    r6325 r6885  
    16321632        return NO;
    16331633   
    1634     return [item isFolder] || [torrent fileProgress: [[item indexes] firstIndex]] == 1.0;
     1634    return [item isFolder] || [torrent fileProgress: item] == 1.0;
    16351635}
    16361636
  • trunk/macosx/Torrent.h

    r6511 r6885  
    2525#import <Cocoa/Cocoa.h>
    2626#import <transmission.h>
     27
     28@class FileListNode;
    2729
    2830#define INVALID -99
     
    241243
    242244//methods require fileStats to have been updated recently to be accurate
    243 - (float) fileProgress: (int) index;
     245- (float) fileProgress: (FileListNode *) node;
    244246- (BOOL) canChangeDownloadCheckForFile: (int) index;
    245247- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet;
  • trunk/macosx/Torrent.m

    r6864 r6885  
    14361436}
    14371437
    1438 - (float) fileProgress: (int) index
    1439 {
     1438- (float) fileProgress: (FileListNode *) node
     1439{
     1440    if ([self isComplete])
     1441        return 1.0;
     1442   
    14401443    if (!fFileStat)
    14411444        [self updateFileStat];
    1442        
    1443     return fFileStat[index].progress;
     1445   
     1446    NSIndexSet * indexSet = [node indexes];
     1447   
     1448    if (![node isFolder])
     1449        return fFileStat[[indexSet firstIndex]].progress;
     1450   
     1451    uint64_t have = 0;
     1452    int index;
     1453    for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
     1454        have += fFileStat[index].bytesCompleted;
     1455   
     1456    return (float)have / [node size];
    14441457}
    14451458
Note: See TracChangeset for help on using the changeset viewer.