1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

show a checkmark in the peer inspector for partial seeds and reflect that status in the tooltip

This commit is contained in:
Mitchell Livingston 2008-12-03 00:18:18 +00:00
parent b9b67ee2c2
commit 932815e400
4 changed files with 38 additions and 4 deletions

View file

@ -28,6 +28,7 @@
#import "FileOutlineView.h"
#import "FileOutlineController.h"
#import "FileListNode.h"
#import "PeerProgressIndicatorCell.h"
#import "TrackerTableView.h"
#import "PiecesView.h"
#import "QuickLookController.h"
@ -910,6 +911,21 @@ typedef enum
return nil;
}
- (void) tableView: (NSTableView *) tableView willDisplayCell: (id) cell forTableColumn: (NSTableColumn *) tableColumn
row: (NSInteger) row
{
if (tableView == fPeerTable)
{
NSString * ident = [tableColumn identifier];
if ([ident isEqualToString: @"Progress"])
{
NSDictionary * peer = [fPeers objectAtIndex: row];
[(PeerProgressIndicatorCell *)cell setSeed: [[peer objectForKey: @"Seed"] boolValue]];
}
}
}
- (void) tableView: (NSTableView *) tableView didClickTableColumn: (NSTableColumn *) tableColumn
{
if (tableView == fPeerTable)
@ -964,8 +980,17 @@ typedef enum
NSDictionary * peer = [fPeers objectAtIndex: row];
NSMutableArray * components = [NSMutableArray arrayWithCapacity: 5];
[components addObject: [NSString localizedStringWithFormat: NSLocalizedString(@"Progress: %.1f%%",
"Inspector -> Peers tab -> table row tooltip"), [[peer objectForKey: @"Progress"] floatValue] * 100.0]];
CGFloat progress = [[peer objectForKey: @"Progress"] floatValue];
NSString * seedStatus;
if (progress < 1.0 && [[peer objectForKey: @"Seed"] boolValue])
seedStatus = [NSString stringWithFormat: @" (%@)", NSLocalizedString(@"Partial Seed",
"Inspector -> Peers tab -> table row tooltip")];
else
seedStatus = @"";
[components addObject: [NSString localizedStringWithFormat: NSLocalizedString(@"Progress: %.1f%%%@",
"Inspector -> Peers tab -> table row tooltip"), progress * 100.0, seedStatus]];
if ([[peer objectForKey: @"Encryption"] boolValue])
[components addObject: NSLocalizedString(@"Encrypted Connection", "Inspector -> Peers tab -> table row tooltip")];

View file

@ -27,6 +27,9 @@
@interface PeerProgressIndicatorCell : NSLevelIndicatorCell
{
NSDictionary * fAttributes;
BOOL fSeed;
}
- (void) setSeed: (BOOL) seed;
@end

View file

@ -40,6 +40,11 @@
[super dealloc];
}
- (void) setSeed: (BOOL) seed
{
fSeed = seed;
}
- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView
{
if ([[NSUserDefaults standardUserDefaults] boolForKey: @"DisplayPeerProgressBarNumber"])
@ -58,7 +63,7 @@
}
[super drawWithFrame: cellFrame inView: controlView];
if ([self floatValue] >= 1.0f)
if (fSeed)
{
NSImage * checkImage = [NSImage imageNamed: @"CompleteCheck.png"];
[checkImage setFlipped: YES];

View file

@ -1038,12 +1038,13 @@ void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, vo
for (int i = 0; i < totalPeers; i++)
{
tr_peer_stat * peer = &peers[i];
NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithCapacity: 9];
NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithCapacity: 10];
[dict setObject: [NSNumber numberWithInt: peer->from] forKey: @"From"];
[dict setObject: [NSString stringWithUTF8String: peer->addr] forKey: @"IP"];
[dict setObject: [NSNumber numberWithInt: peer->port] forKey: @"Port"];
[dict setObject: [NSNumber numberWithFloat: peer->progress] forKey: @"Progress"];
[dict setObject: [NSNumber numberWithBool: peer->isSeed] forKey: @"Seed"];
[dict setObject: [NSNumber numberWithBool: peer->isEncrypted] forKey: @"Encryption"];
[dict setObject: [NSString stringWithUTF8String: peer->client] forKey: @"Client"];
[dict setObject: [NSString stringWithUTF8String: peer->flagStr] forKey: @"Flags"];