Fix game title sorting bug from Issue #2260 (#2284)

* Fix alphabetical sorting bug caused by case-sensitive string comparisons in GameListFrame.

* Fix bug with incorrect use of std::tolower.

* Fix clang-format error.

---------

Co-authored-by: Zaid Ismail <ZaidI@thoroughtec.com>
This commit is contained in:
Zaid Ismail 2025-01-30 14:09:50 +02:00 committed by GitHub
parent 3a163002d7
commit 19bbbf994c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,9 @@
#pragma once
#include <algorithm> // std::transform
#include <cctype> // std::tolower
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
@ -65,8 +68,12 @@ public:
static bool CompareStringsAscending(GameInfo a, GameInfo b, int columnIndex) {
switch (columnIndex) {
case 1:
return a.name < b.name;
case 1: {
std::string name_a = a.name, name_b = b.name;
std::transform(name_a.begin(), name_a.end(), name_a.begin(), ::tolower);
std::transform(name_b.begin(), name_b.end(), name_b.begin(), ::tolower);
return name_a < name_b;
}
case 2:
return a.compatibility.status < b.compatibility.status;
case 3:
@ -90,8 +97,12 @@ public:
static bool CompareStringsDescending(GameInfo a, GameInfo b, int columnIndex) {
switch (columnIndex) {
case 1:
return a.name > b.name;
case 1: {
std::string name_a = a.name, name_b = b.name;
std::transform(name_a.begin(), name_a.end(), name_a.begin(), ::tolower);
std::transform(name_b.begin(), name_b.end(), name_b.begin(), ::tolower);
return name_a > name_b;
}
case 2:
return a.compatibility.status > b.compatibility.status;
case 3: