Sort finished torrents by completed date when sorting by queue number.

This commit is contained in:
sledgehammer999 2014-08-14 22:29:33 +03:00
parent 15a948675b
commit ddbe5b18d5

View file

@ -70,10 +70,23 @@ protected:
return vL < vR;
}
else if (column == TorrentModelItem::TR_PRIORITY) {
int vL = left.data().toInt();
int vR = right.data().toInt();
const int vL = left.data().toInt();
const int vR = right.data().toInt();
//finished torrents should be last
// Seeding torrents should be sorted by their completed date instead.
if (vL == -1 && vR == -1) {
QAbstractItemModel *model = sourceModel();
const QDateTime dateL = model->data(model->index(left.row(), TorrentModelItem::TR_SEED_DATE)).toDateTime();
const QDateTime dateR = model->data(model->index(right.row(), TorrentModelItem::TR_SEED_DATE)).toDateTime();
//not valid dates should be sorted at the bottom.
if (!dateL.isValid()) return false;
if (!dateR.isValid()) return true;
return dateL < dateR;
}
// Seeding torrents should be at the bottom
if (vL == -1) return false;
if (vR == -1) return true;
return vL < vR;