mirror of
https://github.com/transmission/transmission
synced 2025-02-22 14:10:34 +00:00
simplify how the file outline accesses the torrent
This commit is contained in:
parent
af8ca0a2e6
commit
3aa131a3e9
7 changed files with 32 additions and 20 deletions
|
@ -22,8 +22,9 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
#import "FileOutlineView.h"
|
||||
#import "FileNameCell.h"
|
||||
#import "InfoWindowController.h"
|
||||
#import "Torrent.h"
|
||||
#import "NSStringAdditions.h"
|
||||
|
||||
#define PADDING_HORIZONAL 2.0
|
||||
|
@ -89,14 +90,13 @@
|
|||
[[self image] drawInRect: [self imageRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver
|
||||
fraction: 1.0];
|
||||
|
||||
Torrent * torrent = [[[[self controlView] window] windowController] selectedTorrent];
|
||||
|
||||
//title
|
||||
NSColor * specialColor = nil;
|
||||
if ([self isHighlighted]
|
||||
&& [[self highlightColorWithFrame: cellFrame inView: controlView] isEqual: [NSColor alternateSelectedControlColor]])
|
||||
specialColor = [NSColor whiteColor];
|
||||
else if ([torrent checkForFiles: [[self objectValue] objectForKey: @"Indexes"]] == NSOffState)
|
||||
else if ([[(FileOutlineView *)[self controlView] torrent] checkForFiles:
|
||||
[[self objectValue] objectForKey: @"Indexes"]] == NSOffState)
|
||||
specialColor = [NSColor disabledControlTextColor];
|
||||
else;
|
||||
|
||||
|
@ -195,7 +195,7 @@
|
|||
if (color)
|
||||
[fStatusAttributes setObject: color forKey: NSForegroundColorAttributeName];
|
||||
|
||||
Torrent * torrent = [[[[self controlView] window] windowController] selectedTorrent];
|
||||
Torrent * torrent = [(FileOutlineView *)[self controlView] torrent];
|
||||
float percent = [torrent fileProgress: [[[self objectValue] objectForKey: @"Indexes"] firstIndex]] * 100.0;
|
||||
|
||||
NSString * status = [NSString stringWithFormat: NSLocalizedString(@"%.2f%% of %@",
|
||||
|
|
|
@ -24,13 +24,20 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class Torrent;
|
||||
|
||||
@interface FileOutlineView : NSOutlineView
|
||||
{
|
||||
Torrent * fTorrent;
|
||||
|
||||
NSColor * fHighPriorityColor, * fLowPriorityColor, * fMixedPriorityColor;
|
||||
|
||||
int fHoverRow;
|
||||
}
|
||||
|
||||
- (void) setTorrent: (Torrent *) torrent;
|
||||
- (Torrent *) torrent;
|
||||
|
||||
- (void) setHoverRowForEvent: (NSEvent *) event;
|
||||
- (int) hoverRow;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#import "FileOutlineView.h"
|
||||
#import "FileNameCell.h"
|
||||
#import "FilePriorityCell.h"
|
||||
#import "InfoWindowController.h"
|
||||
#import "Torrent.h"
|
||||
|
||||
@implementation FileOutlineView
|
||||
|
@ -59,6 +58,16 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setTorrent: (Torrent *) torrent
|
||||
{
|
||||
fTorrent = torrent;
|
||||
}
|
||||
|
||||
- (Torrent *) torrent
|
||||
{
|
||||
return fTorrent;
|
||||
}
|
||||
|
||||
- (void) mouseDown: (NSEvent *) event
|
||||
{
|
||||
[[self window] makeKeyWindow];
|
||||
|
@ -110,12 +119,11 @@
|
|||
if (![self isRowSelected: row])
|
||||
{
|
||||
NSDictionary * item = [self itemAtRow: row];
|
||||
Torrent * torrent = [(InfoWindowController *)[[self window] windowController] selectedTorrent];
|
||||
NSIndexSet * indexes = [item objectForKey: @"Indexes"];
|
||||
|
||||
if ([torrent checkForFiles: indexes] != NSOffState)
|
||||
if ([fTorrent checkForFiles: indexes] != NSOffState)
|
||||
{
|
||||
NSSet * priorities = [torrent filePrioritiesForIndexes: indexes];
|
||||
NSSet * priorities = [fTorrent filePrioritiesForIndexes: indexes];
|
||||
int count = [priorities count];
|
||||
if (count > 0)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import "FilePriorityCell.h"
|
||||
#import "InfoWindowController.h"
|
||||
#import "FileOutlineView.h"
|
||||
#import "Torrent.h"
|
||||
|
||||
@implementation FilePriorityCell
|
||||
|
@ -51,8 +51,6 @@
|
|||
[super setSelected: flag forSegment: segment];
|
||||
|
||||
//only for when clicking manually
|
||||
Torrent * torrent = [[[[self controlView] window] windowController] selectedTorrent];
|
||||
|
||||
int priority;
|
||||
if (segment == 0)
|
||||
priority = TR_PRI_LOW;
|
||||
|
@ -61,13 +59,14 @@
|
|||
else
|
||||
priority = TR_PRI_NORMAL;
|
||||
|
||||
Torrent * torrent = [(FileOutlineView *)[self controlView] torrent];
|
||||
[torrent setFilePriority: priority forIndexes: [[self representedObject] objectForKey: @"Indexes"]];
|
||||
[(FileOutlineView *)[self controlView] reloadData];
|
||||
}
|
||||
|
||||
- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView
|
||||
{
|
||||
Torrent * torrent = [(InfoWindowController *)[[[self controlView] window] windowController] selectedTorrent];
|
||||
Torrent * torrent = [(FileOutlineView *)[self controlView] torrent];
|
||||
NSDictionary * dict = [self representedObject];
|
||||
NSSet * priorities = [torrent filePrioritiesForIndexes: [dict objectForKey: @"Indexes"]];
|
||||
|
||||
|
|
|
@ -70,7 +70,6 @@
|
|||
}
|
||||
|
||||
- (void) updateInfoForTorrents: (NSArray *) torrents;
|
||||
- (Torrent *) selectedTorrent;
|
||||
- (void) updateInfoStats;
|
||||
|
||||
- (void) setTab: (id) sender;
|
||||
|
|
|
@ -228,6 +228,8 @@ typedef enum
|
|||
[fPexCheck setToolTip: nil];
|
||||
}
|
||||
|
||||
[fFileOutline setTorrent: nil];
|
||||
|
||||
[fImageView setImage: fAppIcon];
|
||||
|
||||
[fNameField setToolTip: nil];
|
||||
|
@ -302,6 +304,8 @@ typedef enum
|
|||
{
|
||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
||||
|
||||
[fFileOutline setTorrent: torrent];
|
||||
|
||||
NSImage * icon = [[torrent icon] copy];
|
||||
[icon setFlipped: NO];
|
||||
[fImageView setImage: icon];
|
||||
|
@ -380,11 +384,6 @@ typedef enum
|
|||
[fFileOutline reloadData];
|
||||
}
|
||||
|
||||
- (Torrent *) selectedTorrent
|
||||
{
|
||||
return fTorrents && [fTorrents count] == 1 ? [fTorrents objectAtIndex: 0] : nil;
|
||||
}
|
||||
|
||||
- (void) updateInfoStats
|
||||
{
|
||||
switch ([fTabMatrix selectedTag])
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<h1>What is Growl? </h1>
|
||||
</div>
|
||||
<p>Growl is a notification system. Lots of applications can interface with it.<br>
|
||||
<a href="http://growl.info">http://growl.info</a>
|
||||
<a href="http://growl.info/">http://growl.info/</a>
|
||||
<p>
|
||||
<div id="pagetitle">
|
||||
<h1>What do the colors mean in the pieces box? </h1>
|
||||
|
|
Loading…
Reference in a new issue