Merge pull request #1286 from alderz/fix_peer_sorting

Fix peers and seeds sorting in transfer list.
This commit is contained in:
sledgehammer999 2014-01-18 09:57:56 -08:00
commit 3159012dbb

View file

@ -66,6 +66,16 @@ protected:
if (!vR.isValid()) return true; if (!vR.isValid()) return true;
return vL < vR; 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); return QSortFilterProxyModel::lessThan(left, right);
} }