]> granicus.if.org Git - transmission/commitdiff
a couple more tweaks to displaying peers and webseeds
authorMitchell Livingston <livings124@transmissionbt.com>
Sun, 7 Feb 2010 17:37:01 +0000 (17:37 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sun, 7 Feb 2010 17:37:01 +0000 (17:37 +0000)
macosx/FileOutlineView.h
macosx/FileOutlineView.m
macosx/InfoWindowController.m
macosx/Torrent.m

index e10cd08d2535898f31e96a2d65549f633b2b46ca..30e42b680735de75f82b356b377ba20003f9efd0 100644 (file)
@@ -32,7 +32,7 @@
     
     NSGradient * fHighPriorityGradient, * fLowPriorityGradient, * fMixedPriorityGradient;
     
-    int fMouseRow;
+    NSInteger fMouseRow;
 }
 
 - (void) setTorrent: (Torrent *) torrent;
@@ -40,6 +40,6 @@
 
 - (NSRect) iconRectForRow: (int) row;
 
-- (int) hoveredRow;
+- (NSInteger) hoveredRow;
 
 @end
index a8f68518cb9e311afd86570665ca51a2b7369ec5..0a3e40535a475931ddcb785305a49892d4202d9f 100644 (file)
 
 - (NSMenu *) menuForEvent: (NSEvent *) event
 {
-    int row = [self rowAtPoint: [self convertPoint: [event locationInWindow] fromView: nil]];
+    const NSInteger row = [self rowAtPoint: [self convertPoint: [event locationInWindow] fromView: nil]];
     
     if (row >= 0)
     {
     FileNameCell * cell = (FileNameCell *)[self preparedCellAtColumn: [self columnWithIdentifier: @"Name"] row: row];
     NSRect iconRect = [cell imageRectForBounds: [self rectOfRow: row]];
     
-    iconRect.origin.x += [self indentationPerLevel] * (float)([self levelForRow: row] + 1);
+    iconRect.origin.x += [self indentationPerLevel] * (CGFloat)([self levelForRow: row] + 1);
     return iconRect;
 }
 
     }
 }
 
-- (int) hoveredRow
+- (NSInteger) hoveredRow
 {
     return fMouseRow;
 }
             NSGradient * gradient = nil;
             
             NSSet * priorities = [fTorrent filePrioritiesForIndexes: indexes];
-            int count = [priorities count];
+            const NSUInteger count = [priorities count];
             if (count == 1)
             {
                 switch ([[priorities anyObject] intValue])
index ec226076175e3327c50bb8363b69ab417ef29da6..f26d92b0fc1ebe9caf6ea33f8439ebcaf0c67367 100644 (file)
@@ -1565,14 +1565,16 @@ typedef enum
     BOOL anyActive = false;
     for (Torrent * torrent in fTorrents)
     {
-        [fPeers addObjectsFromArray: [torrent peers]];
-        [fWebSeeds addObjectsFromArray: [torrent webSeeds]];
+        if ([torrent webSeedCount] > 0)
+            [fWebSeeds addObjectsFromArray: [torrent webSeeds]];
         
         known += [torrent totalPeersKnown];
         
         if ([torrent isActive])
         {
             anyActive = YES;
+            [fPeers addObjectsFromArray: [torrent peers]];
+            
             const NSUInteger connectedThis = [torrent totalPeersConnected];
             if (connectedThis > 0)
             {
@@ -1649,7 +1651,7 @@ typedef enum
         else
             activeString = NSLocalizedString(@"Transfers Not Active", "Inspector -> Peers tab -> peers");
         
-        NSString * connectedText = [NSString stringWithFormat: @"%@\n%@", activeString, knownString];
+        NSString * connectedText = [activeString stringByAppendingFormat: @"\n%@", knownString];
         [fConnectedPeersField setStringValue: connectedText];
     }
 }
index dff20bc7c58164251342a4f48753a2f1577dba0c..ca286e21d8477106986d2675dd072a71cd089588 100644 (file)
@@ -892,26 +892,23 @@ int trashDataFile(const char * filename)
 {
     NSMutableArray * webSeeds = [NSMutableArray arrayWithCapacity: fInfo->webseedCount];
     
-    if (fInfo->webseedCount > 0)
+    float * dlSpeeds = tr_torrentWebSpeeds(fHandle);
+    
+    for (NSInteger i = 0; i < fInfo->webseedCount; i++)
     {
-        float * dlSpeeds = tr_torrentWebSpeeds(fHandle);
+        NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithCapacity: 3];
         
-        for (NSInteger i = 0; i < fInfo->webseedCount; i++)
-        {
-            NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithCapacity: 3];
-            
-            [dict setObject: [self name] forKey: @"Name"];
-            [dict setObject: [NSString stringWithUTF8String: fInfo->webseeds[i]] forKey: @"Address"];
-            
-            if (dlSpeeds[i] != -1.0)
-                [dict setObject: [NSNumber numberWithFloat: dlSpeeds[i]] forKey: @"DL From Rate"];
-            
-            [webSeeds addObject: dict];
-        }
+        [dict setObject: [self name] forKey: @"Name"];
+        [dict setObject: [NSString stringWithUTF8String: fInfo->webseeds[i]] forKey: @"Address"];
         
-        tr_free(dlSpeeds);
+        if (dlSpeeds[i] != -1.0)
+            [dict setObject: [NSNumber numberWithFloat: dlSpeeds[i]] forKey: @"DL From Rate"];
+        
+        [webSeeds addObject: dict];
     }
     
+    tr_free(dlSpeeds);
+    
     return webSeeds;
 }