mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 08:52:36 +00:00
Fix game title sorting
This commit is contained in:
parent
19bbbf994c
commit
06ec10497d
@ -1,6 +1,8 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <algorithm> // std::transform
|
||||||
|
#include <cctype> // std::tolower
|
||||||
#include <QToolTip>
|
#include <QToolTip>
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
@ -108,10 +110,29 @@ void GameListFrame::PopulateGameList() {
|
|||||||
this->setColumnHidden(2, !Config::getCompatibilityEnabled());
|
this->setColumnHidden(2, !Config::getCompatibilityEnabled());
|
||||||
this->setColumnHidden(6, !Config::GetLoadGameSizeEnabled());
|
this->setColumnHidden(6, !Config::GetLoadGameSizeEnabled());
|
||||||
|
|
||||||
|
// Update the row count in the table based on the number of games
|
||||||
this->setRowCount(m_game_info->m_games.size());
|
this->setRowCount(m_game_info->m_games.size());
|
||||||
ResizeIcons(icon_size);
|
ResizeIcons(icon_size);
|
||||||
|
|
||||||
|
// Populate the columns with data for each game
|
||||||
for (int i = 0; i < m_game_info->m_games.size(); i++) {
|
for (int i = 0; i < m_game_info->m_games.size(); i++) {
|
||||||
|
FillRowData(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(
|
||||||
|
m_game_info->m_games.begin(), m_game_info->m_games.end(),
|
||||||
|
[this](const GameInfo& a, const GameInfo& b) { return CompareStringsAscending(a, b, 1); });
|
||||||
|
|
||||||
|
ResizeIcons(icon_size);
|
||||||
|
|
||||||
|
// Update the table with the sorted data , Refill the row after sorting
|
||||||
|
for (int i = 0; i < m_game_info->m_games.size(); i++) {
|
||||||
|
FillRowData(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameListFrame::FillRowData(int i) {
|
||||||
|
// Fill columns with game data
|
||||||
SetTableItem(i, 1, QString::fromStdString(m_game_info->m_games[i].name));
|
SetTableItem(i, 1, QString::fromStdString(m_game_info->m_games[i].name));
|
||||||
SetTableItem(i, 3, QString::fromStdString(m_game_info->m_games[i].serial));
|
SetTableItem(i, 3, QString::fromStdString(m_game_info->m_games[i].serial));
|
||||||
SetRegionFlag(i, 4, QString::fromStdString(m_game_info->m_games[i].region));
|
SetRegionFlag(i, 4, QString::fromStdString(m_game_info->m_games[i].region));
|
||||||
@ -119,10 +140,12 @@ void GameListFrame::PopulateGameList() {
|
|||||||
SetTableItem(i, 6, QString::fromStdString(m_game_info->m_games[i].size));
|
SetTableItem(i, 6, QString::fromStdString(m_game_info->m_games[i].size));
|
||||||
SetTableItem(i, 7, QString::fromStdString(m_game_info->m_games[i].version));
|
SetTableItem(i, 7, QString::fromStdString(m_game_info->m_games[i].version));
|
||||||
|
|
||||||
|
// Fill compatibility column
|
||||||
m_game_info->m_games[i].compatibility =
|
m_game_info->m_games[i].compatibility =
|
||||||
m_compat_info->GetCompatibilityInfo(m_game_info->m_games[i].serial);
|
m_compat_info->GetCompatibilityInfo(m_game_info->m_games[i].serial);
|
||||||
SetCompatibilityItem(i, 2, m_game_info->m_games[i].compatibility);
|
SetCompatibilityItem(i, 2, m_game_info->m_games[i].compatibility);
|
||||||
|
|
||||||
|
// Fill playtime column
|
||||||
QString playTime = GetPlayTime(m_game_info->m_games[i].serial);
|
QString playTime = GetPlayTime(m_game_info->m_games[i].serial);
|
||||||
if (playTime.isEmpty()) {
|
if (playTime.isEmpty()) {
|
||||||
m_game_info->m_games[i].play_time = "0:00:00";
|
m_game_info->m_games[i].play_time = "0:00:00";
|
||||||
@ -150,11 +173,11 @@ void GameListFrame::PopulateGameList() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fill path column
|
||||||
QString path;
|
QString path;
|
||||||
Common::FS::PathToQString(path, m_game_info->m_games[i].path);
|
Common::FS::PathToQString(path, m_game_info->m_games[i].path);
|
||||||
SetTableItem(i, 9, path);
|
SetTableItem(i, 9, path);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
|
void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
|
||||||
if (!item) {
|
if (!item) {
|
||||||
|
@ -47,6 +47,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void PopulateGameList();
|
void PopulateGameList();
|
||||||
|
void FillRowData(int i);
|
||||||
void ResizeIcons(int iconSize);
|
void ResizeIcons(int iconSize);
|
||||||
|
|
||||||
QImage backgroundImage;
|
QImage backgroundImage;
|
||||||
|
Loading…
Reference in New Issue
Block a user