mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 04:38:04 -06:00
[GUI] Implement stable sort (#7703)
* NaturalCompare now returns compare result instead of "less than" result * Change to stable sort in GUI components * Add Utils::String::naturalLessThan() helper function * Use Qt::CaseSensitivity type
This commit is contained in:
@@ -110,13 +110,20 @@ bool SearchSortModel::lessThan(const QModelIndex &left, const QModelIndex &right
|
||||
switch (sortColumn()) {
|
||||
case NAME:
|
||||
case ENGINE_URL: {
|
||||
QString vL = left.data().toString();
|
||||
QString vR = right.data().toString();
|
||||
return Utils::String::naturalCompareCaseInsensitive(vL, vR);
|
||||
}
|
||||
const QString strL = left.data().toString();
|
||||
const QString strR = right.data().toString();
|
||||
const int result = Utils::String::naturalCompare(strL, strR, Qt::CaseInsensitive);
|
||||
if (result != 0)
|
||||
return (result < 0);
|
||||
|
||||
return (mapFromSource(left) < mapFromSource(right));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return base::lessThan(left, right);
|
||||
if (left.data() != right.data())
|
||||
return base::lessThan(left, right);
|
||||
|
||||
return (mapFromSource(left) < mapFromSource(right));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user