rearrange some of the file viewer code
This commit is contained in:
parent
8ad6b7aa3b
commit
f407e44edc
|
@ -64,7 +64,7 @@
|
|||
A21DFF100A292B2B007C5F76 /* Transfers.png in Resources */ = {isa = PBXBuildFile; fileRef = A21DFF0F0A292B2B007C5F76 /* Transfers.png */; };
|
||||
A21F5B890AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A21F5B870AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m */; };
|
||||
A21F5C040AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A21F5C020AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m */; };
|
||||
A2265F420B5EF5F40093DDA5 /* FileBrowserCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A2265F400B5EF5F40093DDA5 /* FileBrowserCell.m */; };
|
||||
A2265F420B5EF5F40093DDA5 /* FileNameCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A2265F400B5EF5F40093DDA5 /* FileNameCell.m */; };
|
||||
A22A8D560AEEAFA5007E9CB9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A22A8D540AEEAFA5007E9CB9 /* Localizable.strings */; };
|
||||
A22BC9A30C5BBCF100F5FB72 /* BottomBorder.png in Resources */ = {isa = PBXBuildFile; fileRef = A22BC9A20C5BBCF100F5FB72 /* BottomBorder.png */; };
|
||||
A232D29E0A70903E00973B12 /* Filter.png in Resources */ = {isa = PBXBuildFile; fileRef = A232D29D0A70903E00973B12 /* Filter.png */; };
|
||||
|
@ -343,8 +343,8 @@
|
|||
A21F5B870AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ActionMenuRatioToDisplayRatioTransformer.m; path = macosx/ActionMenuRatioToDisplayRatioTransformer.m; sourceTree = "<group>"; };
|
||||
A21F5C010AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ActionMenuSpeedToDisplayLimitTransformer.h; path = macosx/ActionMenuSpeedToDisplayLimitTransformer.h; sourceTree = "<group>"; };
|
||||
A21F5C020AF26DD5008CE5CE /* ActionMenuSpeedToDisplayLimitTransformer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ActionMenuSpeedToDisplayLimitTransformer.m; path = macosx/ActionMenuSpeedToDisplayLimitTransformer.m; sourceTree = "<group>"; };
|
||||
A2265F3F0B5EF5F40093DDA5 /* FileBrowserCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FileBrowserCell.h; path = macosx/FileBrowserCell.h; sourceTree = "<group>"; };
|
||||
A2265F400B5EF5F40093DDA5 /* FileBrowserCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = FileBrowserCell.m; path = macosx/FileBrowserCell.m; sourceTree = "<group>"; };
|
||||
A2265F3F0B5EF5F40093DDA5 /* FileNameCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FileNameCell.h; path = macosx/FileNameCell.h; sourceTree = "<group>"; };
|
||||
A2265F400B5EF5F40093DDA5 /* FileNameCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = FileNameCell.m; path = macosx/FileNameCell.m; sourceTree = "<group>"; };
|
||||
A22A7EBB0C627FC200E30364 /* Greek */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Greek; path = macosx/Greek.lproj/AboutWindow.nib; sourceTree = "<group>"; };
|
||||
A22A7EBC0C627FC200E30364 /* Greek */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = Greek; path = macosx/Greek.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
A22A7EBD0C627FC200E30364 /* Greek */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Greek; path = macosx/Greek.lproj/InfoWindow.nib; sourceTree = "<group>"; };
|
||||
|
@ -922,8 +922,8 @@
|
|||
35F372130C2D780600DAA8F2 /* InfoWindow.m */,
|
||||
A2AF1C360A3D0F6200F1575D /* FileOutlineView.h */,
|
||||
A2AF1C370A3D0F6200F1575D /* FileOutlineView.m */,
|
||||
A2265F3F0B5EF5F40093DDA5 /* FileBrowserCell.h */,
|
||||
A2265F400B5EF5F40093DDA5 /* FileBrowserCell.m */,
|
||||
A2265F3F0B5EF5F40093DDA5 /* FileNameCell.h */,
|
||||
A2265F400B5EF5F40093DDA5 /* FileNameCell.m */,
|
||||
A2A1CB770BF29D5500AE959F /* PeerProgressIndicatorCell.h */,
|
||||
A2A1CB780BF29D5500AE959F /* PeerProgressIndicatorCell.m */,
|
||||
A2AA579A0ADFCAB400CA59F6 /* PiecesView.h */,
|
||||
|
@ -1313,7 +1313,7 @@
|
|||
A25E74660AF5097D006F11AE /* ExpandedPathToIconTransformer.m in Sources */,
|
||||
A2BF07910B066E0800757C92 /* SpeedLimitToTurtleIconTransformer.m in Sources */,
|
||||
A24999230B49F1B5001EADA3 /* ActionPopUpButton.m in Sources */,
|
||||
A2265F420B5EF5F40093DDA5 /* FileBrowserCell.m in Sources */,
|
||||
A2265F420B5EF5F40093DDA5 /* FileNameCell.m in Sources */,
|
||||
A2A1CB7A0BF29D5500AE959F /* PeerProgressIndicatorCell.m in Sources */,
|
||||
A2385DD40BFE06C800B24EF6 /* DragOverlayWindow.m in Sources */,
|
||||
A2FB057F0BFEB6800095564D /* DragOverlayView.m in Sources */,
|
||||
|
|
|
@ -24,17 +24,13 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface FileBrowserCell : NSBrowserCell
|
||||
@interface FileNameCell : NSActionCell
|
||||
{
|
||||
NSImage * fFolderImage;
|
||||
|
||||
float fPercent;
|
||||
|
||||
NSMutableDictionary * fTitleAttributes, * fStatusAttributes;
|
||||
}
|
||||
|
||||
- (void) setProgress: (float) progress;
|
||||
|
||||
- (NSRect) imageRectForBounds: (NSRect) bounds;
|
||||
- (NSRect) titleRectForBounds: (NSRect) bounds;
|
||||
- (NSRect) statusRectForBounds: (NSRect) bounds;
|
|
@ -22,7 +22,8 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
#import "FileBrowserCell.h"
|
||||
#import "FileNameCell.h"
|
||||
#import "InfoWindowController.h"
|
||||
#import "StringAdditions.h"
|
||||
|
||||
#define PADDING_HORIZONAL 2.0
|
||||
|
@ -32,44 +33,28 @@
|
|||
#define PADDING_ABOVE_TITLE_FILE 2.0
|
||||
#define PADDING_BELOW_STATUS_FILE 2.0
|
||||
|
||||
@interface FileBrowserCell (Private)
|
||||
@interface FileNameCell (Private)
|
||||
|
||||
- (NSAttributedString *) attributedTitleWithColor: (NSColor *) color;
|
||||
- (NSAttributedString *) attributedStatusWithColor: (NSColor *) color;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FileBrowserCell
|
||||
@implementation FileNameCell
|
||||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
[self setLeaf: YES];
|
||||
}
|
||||
|
||||
- (void) setImage: (NSImage *) image
|
||||
- (NSImage *) image
|
||||
{
|
||||
NSImage * image = [[self objectValue] objectForKey: @"Icon"];
|
||||
if (!image)
|
||||
{
|
||||
if (!fFolderImage)
|
||||
{
|
||||
fFolderImage = [[[NSWorkspace sharedWorkspace] iconForFileType: NSFileTypeForHFSTypeCode('fldr')] copy];
|
||||
[fFolderImage setFlipped: YES];
|
||||
[fFolderImage setScalesWhenResized: YES];
|
||||
}
|
||||
image = fFolderImage;
|
||||
}
|
||||
else
|
||||
{
|
||||
[image setFlipped: YES];
|
||||
[image setScalesWhenResized: YES];
|
||||
}
|
||||
|
||||
[super setImage: image];
|
||||
}
|
||||
|
||||
- (void) setProgress: (float) progress
|
||||
{
|
||||
fPercent = progress * 100.0;
|
||||
return image;
|
||||
}
|
||||
|
||||
- (NSRect) imageRectForBounds: (NSRect) bounds
|
||||
|
@ -130,13 +115,16 @@
|
|||
- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView
|
||||
{
|
||||
//icon
|
||||
[[self image] drawInRect: [self imageRectForBounds: cellFrame] fromRect: NSZeroRect
|
||||
operation: NSCompositeSourceOver fraction: 1.0];
|
||||
NSImage * icon = [self image];
|
||||
NSSize iconSize = [icon size];
|
||||
[icon drawInRect: [self imageRectForBounds: cellFrame] fromRect: NSMakeRect(0, 0, iconSize.width, iconSize.height)
|
||||
operation: NSCompositeSourceOver fraction: 1.0];
|
||||
|
||||
//title
|
||||
BOOL highlighted = [self isHighlighted] && [[self highlightColorWithFrame: cellFrame inView: controlView]
|
||||
isEqual: [NSColor alternateSelectedControlColor]];
|
||||
|
||||
#warning mimic torrent cell
|
||||
[[self attributedTitleWithColor: highlighted ? [NSColor whiteColor] : [NSColor controlTextColor]]
|
||||
drawInRect: [self titleRectForBounds: cellFrame]];
|
||||
|
||||
|
@ -148,7 +136,7 @@
|
|||
|
||||
@end
|
||||
|
||||
@implementation FileBrowserCell (Private)
|
||||
@implementation FileNameCell (Private)
|
||||
|
||||
- (NSAttributedString *) attributedTitleWithColor: (NSColor *) color
|
||||
{
|
||||
|
@ -188,9 +176,11 @@
|
|||
if (color)
|
||||
[fStatusAttributes setObject: color forKey: NSForegroundColorAttributeName];
|
||||
|
||||
#warning fPercent?
|
||||
Torrent * torrent = [[[[self controlView] window] windowController] selectedTorrent];
|
||||
float percent = [torrent fileProgress: [[[self objectValue] objectForKey: @"Indexes"] firstIndex]] * 100.0;
|
||||
|
||||
NSString * status = [NSString stringWithFormat: NSLocalizedString(@"%.2f%% of %@",
|
||||
"Inspector -> Files tab -> file status string"), fPercent,
|
||||
"Inspector -> Files tab -> file status string"), percent,
|
||||
[NSString stringForFileSize: [[[self objectValue] objectForKey: @"Size"] unsignedLongLongValue]]];
|
||||
|
||||
return [[[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes] autorelease];
|
|
@ -23,7 +23,8 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import "FileOutlineView.h"
|
||||
#import "FileBrowserCell.h"
|
||||
#import "FileNameCell.h"
|
||||
#import "FilePriorityCell.h"
|
||||
#import "InfoWindowController.h"
|
||||
#import "Torrent.h"
|
||||
|
||||
|
@ -31,9 +32,13 @@
|
|||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
NSBrowserCell * browserCell = [[FileBrowserCell alloc] init];
|
||||
[[self tableColumnWithIdentifier: @"Name"] setDataCell: browserCell];
|
||||
[browserCell release];
|
||||
FileNameCell * nameCell = [[FileNameCell alloc] init];
|
||||
[[self tableColumnWithIdentifier: @"Name"] setDataCell: nameCell];
|
||||
[nameCell release];
|
||||
|
||||
FilePriorityCell * priorityCell = [[FilePriorityCell alloc] init];
|
||||
[[self tableColumnWithIdentifier: @"Priority"] setDataCell: priorityCell];
|
||||
[priorityCell release];
|
||||
|
||||
[self setAutoresizesOutlineColumn: NO];
|
||||
[self setIndentationPerLevel: 14.0];
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import "InfoWindowController.h"
|
||||
#import "FileBrowserCell.h"
|
||||
#import "FilePriorityCell.h"
|
||||
#import "StringAdditions.h"
|
||||
|
||||
|
@ -98,13 +97,10 @@
|
|||
[fPeerTable setSortDescriptors: [NSArray arrayWithObject: [[fPeerTable tableColumnWithIdentifier: @"IP"]
|
||||
sortDescriptorPrototype]]];
|
||||
|
||||
#warning make button? or just cell?
|
||||
//set file table
|
||||
[fFileOutline setDoubleAction: @selector(revealFile:)];
|
||||
|
||||
//set file outline
|
||||
FilePriorityCell * priorityCell = [[[FilePriorityCell alloc] init] autorelease];
|
||||
[[fFileOutline tableColumnWithIdentifier: @"Priority"] setDataCell: priorityCell];
|
||||
|
||||
//set blank inspector
|
||||
[self updateInfoForTorrents: [NSArray array]];
|
||||
|
||||
|
@ -881,19 +877,9 @@
|
|||
forTableColumn: (NSTableColumn *) tableColumn item: (id) item
|
||||
{
|
||||
NSString * identifier = [tableColumn identifier];
|
||||
if ([identifier isEqualToString: @"Name"])
|
||||
{
|
||||
if ([[item objectForKey: @"IsFolder"] boolValue])
|
||||
[cell setImage: nil];
|
||||
else
|
||||
{
|
||||
[cell setImage: [item objectForKey: @"Icon"]];
|
||||
[(FileBrowserCell *)cell setProgress: [[fTorrents objectAtIndex: 0] fileProgress:
|
||||
[[item objectForKey: @"Indexes"] firstIndex]]];
|
||||
}
|
||||
}
|
||||
else if ([identifier isEqualToString: @"Check"])
|
||||
if ([identifier isEqualToString: @"Check"])
|
||||
[cell setEnabled: [[fTorrents objectAtIndex: 0] canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]]];
|
||||
#warning is this redundant? what about objectValue, and remove import too
|
||||
else if ([identifier isEqualToString: @"Priority"])
|
||||
[(FilePriorityCell *)cell setItem: item];
|
||||
else;
|
||||
|
|
|
@ -1589,7 +1589,10 @@ static int static_lastid = 0;
|
|||
{
|
||||
[dict setObject: [NSIndexSet indexSetWithIndex: index] forKey: @"Indexes"];
|
||||
[dict setObject: [NSNumber numberWithUnsignedLongLong: size] forKey: @"Size"];
|
||||
[dict setObject: [[NSWorkspace sharedWorkspace] iconForFileType: [name pathExtension]] forKey: @"Icon"];
|
||||
|
||||
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFileType: [name pathExtension]];
|
||||
[icon setFlipped: YES];
|
||||
[dict setObject: icon forKey: @"Icon"];
|
||||
|
||||
[flatList addObject: dict];
|
||||
}
|
||||
|
|
|
@ -281,6 +281,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
@implementation TorrentCell (Private)
|
||||
|
||||
#warning don't use image
|
||||
#warning NSDivideRect ?
|
||||
- (NSImage *) simpleBar: (float) width
|
||||
{
|
||||
Torrent * torrent = [self representedObject];
|
||||
|
@ -288,13 +289,15 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
NSImage * bar = [[NSImage alloc] initWithSize: NSMakeSize(width, BAR_HEIGHT)];
|
||||
[bar lockFocus];
|
||||
|
||||
NSRect barBounds = NSMakeRect(0, 0, width, BAR_HEIGHT);
|
||||
|
||||
float progress = [torrent progress], left = [torrent progressLeft];
|
||||
|
||||
if (progress < 1.0)
|
||||
{
|
||||
if (!fWhiteGradient)
|
||||
fWhiteGradient = [[CTGradient progressWhiteGradient] retain];
|
||||
[fWhiteGradient fillRect: NSMakeRect(0, 0, width, BAR_HEIGHT) angle: -90];
|
||||
[fWhiteGradient fillRect: barBounds angle: -90];
|
||||
|
||||
float include = progress + left;
|
||||
if (include < 1.0)
|
||||
|
@ -364,7 +367,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
}
|
||||
|
||||
[fBarOverlayColor set];
|
||||
[NSBezierPath strokeRect: NSInsetRect(NSMakeRect(0, 0, width, BAR_HEIGHT), 0.5, 0.5)];
|
||||
[NSBezierPath strokeRect: NSInsetRect(barBounds, 0.5, 0.5)];
|
||||
|
||||
[bar unlockFocus];
|
||||
|
||||
|
|
Loading…
Reference in New Issue