From 323de569df10282db1d81c4d3d83bbb993feb557 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sun, 14 Jul 2013 14:54:29 +0300 Subject: [PATCH] Sort invalid dates always at the bottom. Closes #106 and #735. --- src/transferlistsortmodel.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/transferlistsortmodel.h b/src/transferlistsortmodel.h index e4c820fb6..bc50fc6de 100644 --- a/src/transferlistsortmodel.h +++ b/src/transferlistsortmodel.h @@ -57,6 +57,16 @@ protected: return QSortFilterProxyModel::lessThan(left, right); } + else if (sortColumn() == TorrentModelItem::TR_ADD_DATE || sortColumn() == TorrentModelItem::TR_SEED_DATE) { + QDateTime vL = sourceModel()->data(left).toDateTime(); + QDateTime vR = sourceModel()->data(right).toDateTime(); + + //not valid dates should be sorted at the bottom. + if (!vL.isValid()) return !(sortOrder() == Qt::AscendingOrder); + if (!vR.isValid()) return (sortOrder() == Qt::AscendingOrder); + + return vL < vR; + } return QSortFilterProxyModel::lessThan(left, right); } };