From 2f8eb2edb964b255f1d141200f915e9763d3b824 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 28 May 2007 03:17:23 +0000 Subject: [PATCH] when sorting by progress, if seeding, sort by progress towards meeting set ratio --- macosx/Torrent.m | 13 ++++++++++++- macosx/TorrentCell.m | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/macosx/Torrent.m b/macosx/Torrent.m index ce107bcd1..0fa2c3511 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -1394,7 +1394,18 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 - (NSNumber *) progressSortKey { - return [NSNumber numberWithFloat: [self progress]]; + float progress; + if ((progress = [self progress]) >= 1.0) + { + float stopRatio, ratio; + if ((stopRatio = [self actualStopRatio]) == INVALID) + progress = 3.0; + else if (stopRatio > 0 && (ratio = [self ratio]) >= 0 && ratio <= stopRatio) + progress += ratio / stopRatio; + else; + } + + return [NSNumber numberWithFloat: progress]; } - (NSNumber *) ratioSortKey diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index 22b754d7b..673f41454 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -85,7 +85,8 @@ { float stopRatio, ratio; if ((stopRatio = [[info objectForKey: @"StopRatio"] floatValue]) != INVALID - && (ratio = [[info objectForKey: @"Ratio"] floatValue]) < stopRatio) + && (ratio = [[info objectForKey: @"Ratio"] floatValue]) < stopRatio + && stopRatio != 0) { if (ratio < 0) ratio = 0;