Minor fixes to some std::sort calls (#3967)

This commit is contained in:
Olxinos 2020-04-23 16:23:59 +01:00 committed by GitHub
parent 1976c4caed
commit db85ec48c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -364,7 +364,7 @@ void WndSets::actDown()
{ {
QModelIndexList rows = view->selectionModel()->selectedRows(); QModelIndexList rows = view->selectionModel()->selectedRows();
// QModelIndex only implements operator<, so we can't use std::greater // QModelIndex only implements operator<, so we can't use std::greater
std::sort(rows.begin(), rows.end(), [](const QModelIndex &a, const QModelIndex &b) { return !(b < a); }); std::sort(rows.begin(), rows.end(), [](const QModelIndex &a, const QModelIndex &b) { return b < a; });
QSet<int> newRows; QSet<int> newRows;
if (rows.empty()) if (rows.empty())
@ -412,7 +412,7 @@ void WndSets::actBottom()
{ {
QModelIndexList rows = view->selectionModel()->selectedRows(); QModelIndexList rows = view->selectionModel()->selectedRows();
// QModelIndex only implements operator<, so we can't use std::greater // QModelIndex only implements operator<, so we can't use std::greater
std::sort(rows.begin(), rows.end(), [](const QModelIndex &a, const QModelIndex &b) { return !(b < a); }); std::sort(rows.begin(), rows.end(), [](const QModelIndex &a, const QModelIndex &b) { return b < a; });
QSet<int> newRows; QSet<int> newRows;
int newRow = model->rowCount() - 1; int newRow = model->rowCount() - 1;

View file

@ -254,7 +254,7 @@ public:
} }
inline bool operator()(QPair<int, AbstractDecklistNode *> a, QPair<int, AbstractDecklistNode *> b) const inline bool operator()(QPair<int, AbstractDecklistNode *> a, QPair<int, AbstractDecklistNode *> b) const
{ {
return (order == Qt::AscendingOrder) ^ (a.second->compare(b.second)); return (order == Qt::AscendingOrder) ? (b.second->compare(a.second)) : (a.second->compare(b.second));
} }
}; };