mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-31 03:50:20 -07:00
Fix previous commit.
This commit is contained in:
parent
12b73747f5
commit
c8f955e302
2 changed files with 9 additions and 11 deletions
|
@ -86,7 +86,7 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
||||||
case TorrentModel::TR_ADD_DATE:
|
case TorrentModel::TR_ADD_DATE:
|
||||||
case TorrentModel::TR_SEED_DATE:
|
case TorrentModel::TR_SEED_DATE:
|
||||||
case TorrentModel::TR_SEEN_COMPLETE_DATE: {
|
case TorrentModel::TR_SEEN_COMPLETE_DATE: {
|
||||||
return dateLessThan(column, left, right);
|
return dateLessThan(sortColumn(), left, right, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
case TorrentModel::TR_PRIORITY: {
|
case TorrentModel::TR_PRIORITY: {
|
||||||
|
@ -138,12 +138,10 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invalidL && invalidR) {
|
if (invalidL && invalidR) {
|
||||||
if (seedingL) { //Both seeding
|
if (seedingL) //Both seeding
|
||||||
return dateLessThan(TorrentModelItem::TR_SEED_DATE, left, right);
|
return dateLessThan(TorrentModel::TR_SEED_DATE, left, right, true);
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return prioL < prioR;
|
return prioL < prioR;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!invalidL && !invalidR) {
|
else if (!invalidL && !invalidR) {
|
||||||
return etaL < etaR;
|
return etaL < etaR;
|
||||||
|
@ -196,13 +194,13 @@ bool TransferListSortModel::lowerPositionThan(const QModelIndex &left, const QMo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort according to TR_SEED_DATE
|
// Sort according to TR_SEED_DATE
|
||||||
return dateLessThan(TorrentModelItem::TR_SEED_DATE, left, right);
|
return dateLessThan(TorrentModel::TR_SEED_DATE, left, right, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Every time we compare QDateTimes we need a fallback comparison in case both
|
// Every time we compare QDateTimes we need a fallback comparison in case both
|
||||||
// values are empty. This is a workaround for unstable sort in QSortFilterProxyModel
|
// values are empty. This is a workaround for unstable sort in QSortFilterProxyModel
|
||||||
// (detailed discussion in #2526 and #2158).
|
// (detailed discussion in #2526 and #2158).
|
||||||
bool TransferListSortModel::dateLessThan(const int dateColumn, const QModelIndex &left, const QModelIndex &right) const
|
bool TransferListSortModel::dateLessThan(const int dateColumn, const QModelIndex &left, const QModelIndex &right, bool sortInvalidInBottom) const
|
||||||
{
|
{
|
||||||
const TorrentModel *model = dynamic_cast<TorrentModel*>(sourceModel());
|
const TorrentModel *model = dynamic_cast<TorrentModel*>(sourceModel());
|
||||||
const QDateTime dateL = model->data(model->index(left.row(), dateColumn)).toDateTime();
|
const QDateTime dateL = model->data(model->index(left.row(), dateColumn)).toDateTime();
|
||||||
|
@ -212,9 +210,9 @@ bool TransferListSortModel::dateLessThan(const int dateColumn, const QModelIndex
|
||||||
return dateL < dateR;
|
return dateL < dateR;
|
||||||
}
|
}
|
||||||
else if (dateL.isValid())
|
else if (dateL.isValid())
|
||||||
return false;
|
return sortInvalidInBottom;
|
||||||
else if (dateR.isValid())
|
else if (dateR.isValid())
|
||||||
return true;
|
return !sortInvalidInBottom;
|
||||||
|
|
||||||
// Finally, sort by hash
|
// Finally, sort by hash
|
||||||
const QString hashL(model->torrentHandle(model->index(left.row()))->hash());
|
const QString hashL(model->torrentHandle(model->index(left.row()))->hash());
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
private:
|
private:
|
||||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||||
bool lowerPositionThan(const QModelIndex &left, const QModelIndex &right) const;
|
bool lowerPositionThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||||
bool dateLessThan(const int dateColumn, const QModelIndex &left, const QModelIndex &right) const;
|
bool dateLessThan(const int dateColumn, const QModelIndex &left, const QModelIndex &right, bool sortInvalidInBottom) const;
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
bool matchFilter(int sourceRow, const QModelIndex &sourceParent) const;
|
bool matchFilter(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue