From: Mitchell Livingston Date: Sun, 7 Feb 2010 17:37:01 +0000 (+0000) Subject: a couple more tweaks to displaying peers and webseeds X-Git-Tag: 1.90~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=55956663107c53c23ed110be0f4f1b95fd3988d4;p=transmission a couple more tweaks to displaying peers and webseeds --- diff --git a/macosx/FileOutlineView.h b/macosx/FileOutlineView.h index e10cd08d2..30e42b680 100644 --- a/macosx/FileOutlineView.h +++ b/macosx/FileOutlineView.h @@ -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 diff --git a/macosx/FileOutlineView.m b/macosx/FileOutlineView.m index a8f68518c..0a3e40535 100644 --- a/macosx/FileOutlineView.m +++ b/macosx/FileOutlineView.m @@ -105,7 +105,7 @@ - (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) { @@ -123,7 +123,7 @@ 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; } @@ -153,7 +153,7 @@ } } -- (int) hoveredRow +- (NSInteger) hoveredRow { return fMouseRow; } @@ -191,7 +191,7 @@ NSGradient * gradient = nil; NSSet * priorities = [fTorrent filePrioritiesForIndexes: indexes]; - int count = [priorities count]; + const NSUInteger count = [priorities count]; if (count == 1) { switch ([[priorities anyObject] intValue]) diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index ec2260761..f26d92b0f 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -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]; } } diff --git a/macosx/Torrent.m b/macosx/Torrent.m index dff20bc7c..ca286e21d 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -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; }