Merge pull request #234 from muesli/master

Fix sorting by progress (Qt client)
This commit is contained in:
Mike Gelfand 2017-05-01 12:58:02 +03:00 committed by GitHub
commit c19e49d851
2 changed files with 6 additions and 1 deletions

View File

@ -314,7 +314,7 @@ public:
double percentComplete() const
{
return haveTotal() / static_cast<double>(totalSize());
return totalSize() != 0 ? haveTotal() / static_cast<double>(totalSize()) : 0;
}
double percentDone() const

View File

@ -155,6 +155,11 @@ bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right)
// fall through
case SortMode::SORT_BY_PROGRESS:
if (val == 0)
{
val = -compare(a->isMagnet(), b->isMagnet());
}
if (val == 0)
{
val = compare(a->percentComplete(), b->percentComplete());