Changeset 6885
- Timestamp:
- Oct 12, 2008, 1:22:13 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEWS
r6883 r6885 10 10 - Mac 11 11 + Option to automatically update the blocklist weekly 12 + In the file inspector tab, show progress and size for folders 12 13 + Sparkle updated to 1.5 13 14 - GTK+ -
trunk/macosx/FileNameCell.m
r5915 r6885 36 36 #define PADDING_ABOVE_TITLE_FILE 2.0 37 37 #define PADDING_BELOW_STATUS_FILE 2.0 38 #define PADDING_BETWEEN_NAME_AND_FOLDER_STATUS 4.0 38 39 39 40 @interface FileNameCell (Private) 40 41 41 42 - (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; 43 44 44 45 - (NSAttributedString *) attributedTitleWithColor: (NSColor *) color; … … 130 131 - (NSRect) statusRectForBounds: (NSRect) bounds 131 132 { 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]; 133 136 } 134 137 … … 143 146 && [[self highlightColorWithFrame: cellFrame inView: controlView] isEqual: [NSColor alternateSelectedControlColor]]) 144 147 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) 147 149 specialColor = [NSColor disabledControlTextColor]; 148 150 else; … … 153 155 154 156 //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]; 161 160 } 162 161 … … 187 186 } 188 187 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 { 194 190 NSSize statusSize = [string size]; 195 191 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 201 206 result.size = statusSize; 202 207 result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONAL); … … 221 226 Torrent * torrent = [(FileOutlineView *)[self controlView] torrent]; 222 227 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]]]; 227 236 228 237 return [[[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes] autorelease]; -
trunk/macosx/InfoWindowController.m
r6325 r6885 1632 1632 return NO; 1633 1633 1634 return [item isFolder] || [torrent fileProgress: [[item indexes] firstIndex]] == 1.0;1634 return [item isFolder] || [torrent fileProgress: item] == 1.0; 1635 1635 } 1636 1636 -
trunk/macosx/Torrent.h
r6511 r6885 25 25 #import <Cocoa/Cocoa.h> 26 26 #import <transmission.h> 27 28 @class FileListNode; 27 29 28 30 #define INVALID -99 … … 241 243 242 244 //methods require fileStats to have been updated recently to be accurate 243 - (float) fileProgress: ( int) index;245 - (float) fileProgress: (FileListNode *) node; 244 246 - (BOOL) canChangeDownloadCheckForFile: (int) index; 245 247 - (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet; -
trunk/macosx/Torrent.m
r6864 r6885 1436 1436 } 1437 1437 1438 - (float) fileProgress: (int) index 1439 { 1438 - (float) fileProgress: (FileListNode *) node 1439 { 1440 if ([self isComplete]) 1441 return 1.0; 1442 1440 1443 if (!fFileStat) 1441 1444 [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]; 1444 1457 } 1445 1458
Note: See TracChangeset
for help on using the changeset viewer.