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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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];
Note: See TracChangeset for help on using the changeset viewer.