Fix list sorting for some categories (#1242)

* fix list sorting for serial, firmware version, and game size

* bad apple!!

* qol
This commit is contained in:
ElBread3 2024-10-05 13:34:38 -05:00 committed by GitHub
parent a5968b630d
commit 2b8c2ce423
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 7 deletions

View file

@ -102,7 +102,9 @@ void GameGridFrame::PopulateGameGrid(QVector<GameInfo> m_games_search, bool from
name_label->setGraphicsEffect(shadowEffect);
widget->setLayout(layout);
QString tooltipText = QString::fromStdString(m_games_[gameCounter].name);
QString tooltipText = QString::fromStdString(m_games_[gameCounter].name + " (" +
m_games_[gameCounter].version + ", " +
m_games_[gameCounter].region + ")");
widget->setToolTip(tooltipText);
QString tooltipStyle = QString("QToolTip {"
"background-color: #ffffff;"

View file

@ -44,18 +44,27 @@ public:
int icon_size;
static float parseAsFloat(const std::string& str, const int& offset) {
return std::stof(str.substr(0, str.size() - offset));
}
static float parseSizeMB(const std::string& size) {
float num = parseAsFloat(size, 3);
return (size[size.size() - 2] == 'G') ? num * 1024 : num;
}
static bool CompareStringsAscending(GameInfo a, GameInfo b, int columnIndex) {
switch (columnIndex) {
case 1:
return a.name < b.name;
case 2:
return a.serial < b.serial;
return a.serial.substr(4) < b.serial.substr(4);
case 3:
return a.region < b.region;
case 4:
return a.fw < b.fw;
return parseAsFloat(a.fw, 0) < parseAsFloat(b.fw, 0);
case 5:
return a.size < b.size;
return parseSizeMB(b.size) < parseSizeMB(a.size);
case 6:
return a.version < b.version;
case 7:
@ -70,13 +79,13 @@ public:
case 1:
return a.name > b.name;
case 2:
return a.serial > b.serial;
return a.serial.substr(4) > b.serial.substr(4);
case 3:
return a.region > b.region;
case 4:
return a.fw > b.fw;
return parseAsFloat(a.fw, 0) > parseAsFloat(b.fw, 0);
case 5:
return a.size > b.size;
return parseSizeMB(b.size) > parseSizeMB(a.size);
case 6:
return a.version > b.version;
case 7: