]> granicus.if.org Git - transmission/commitdiff
show a checkmark in the peer inspector for partial seeds and reflect that status...
authorMitchell Livingston <livings124@transmissionbt.com>
Wed, 3 Dec 2008 00:18:18 +0000 (00:18 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Wed, 3 Dec 2008 00:18:18 +0000 (00:18 +0000)
macosx/InfoWindowController.m
macosx/PeerProgressIndicatorCell.h
macosx/PeerProgressIndicatorCell.m
macosx/Torrent.m

index a04163b25d883d34e8f3b2e0d95df57547740f6a..dd370cc9680dc4d9a1098518ebae2ac63768704b 100644 (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")];
index 3790f1773f5ea6ed9c65c0354edbe947648da26e..bffeac4417823ab9e14c39282bff9a2ca83d1916 100644 (file)
@@ -27,6 +27,9 @@
 @interface PeerProgressIndicatorCell : NSLevelIndicatorCell
 {
     NSDictionary * fAttributes;
+    BOOL fSeed;
 }
 
+- (void) setSeed: (BOOL) seed;
+
 @end
index c864235264e88af59090e3ef44cd0c5eb2a01ded..d093f876c62827f53317267d1e6e4032b5d10b3e 100644 (file)
     [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];
index 200c681317b9721be2d1db987749ed2743824799..691d7eae7d27072ab36f3e1318cfaea6b92355be 100644 (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"];