From aa9001522cf339acdb38f86299e9678da73cbc4c Mon Sep 17 00:00:00 2001 From: Angel Alonso Date: Sat, 18 Jan 2014 11:53:44 +0100 Subject: [PATCH] Fix peers and seeds sorting in transfer list. When active peers (or seeds) of two torrents are the same we sort by total peers (or seeds). --- src/transferlistsortmodel.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/transferlistsortmodel.h b/src/transferlistsortmodel.h index ee73e1c3a..c0168bc3a 100644 --- a/src/transferlistsortmodel.h +++ b/src/transferlistsortmodel.h @@ -66,6 +66,16 @@ protected: if (!vR.isValid()) return true; return vL < vR; + } else if (sortColumn() == TorrentModelItem::TR_PEERS || sortColumn() == TorrentModelItem::TR_SEEDS) { + int left_active = sourceModel()->data(left).toInt(); + int left_total = sourceModel()->data(left, Qt::UserRole).toInt(); + int right_active = sourceModel()->data(right).toInt(); + int right_total = sourceModel()->data(right, Qt::UserRole).toInt(); + + // Active peers/seeds take precedence over total peers/seeds. + if (left_active == right_active) + return (left_total < right_total); + else return (left_active < right_active); } return QSortFilterProxyModel::lessThan(left, right); }