From 85cfe464f911b38710f6a7a127cde887e52ba62d Mon Sep 17 00:00:00 2001 From: alfrix Date: Sun, 9 Feb 2014 21:27:42 -0300 Subject: [PATCH] Fix queue sorting order fixes #1120 --- src/transferlistsortmodel.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/transferlistsortmodel.h b/src/transferlistsortmodel.h index c0168bc3a..f3be98353 100644 --- a/src/transferlistsortmodel.h +++ b/src/transferlistsortmodel.h @@ -66,16 +66,26 @@ 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(); + } + else if (sortColumn() == TorrentModelItem::TR_PRIORITY) { + int vL = sourceModel()->data(left).toInt(); + int vR = sourceModel()->data(right).toInt(); + + //finished torrents should be last + if (vL == -1) return false; + if (vR == -1) 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); + // 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); }