mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-28 22:33:17 +00:00
QT: Fix search in Grid mode (#2490)
* QT: Fix search in Grid mode * Fix performance? * Fix performance List * +fix
This commit is contained in:
parent
6f5dfc576f
commit
745cdd89fd
3 changed files with 17 additions and 0 deletions
|
@ -49,6 +49,9 @@ void GameInfoClass::GetGameInfo(QWidget* parent) {
|
||||||
return readGameInfo(Common::FS::PathFromQString(path));
|
return readGameInfo(Common::FS::PathFromQString(path));
|
||||||
}).results();
|
}).results();
|
||||||
|
|
||||||
|
// used to retrieve values after performing a search
|
||||||
|
m_games_backup = m_games;
|
||||||
|
|
||||||
// Progress bar, please be patient :)
|
// Progress bar, please be patient :)
|
||||||
QProgressDialog dialog(tr("Loading game list, please wait :3"), tr("Cancel"), 0, 0, parent);
|
QProgressDialog dialog(tr("Loading game list, please wait :3"), tr("Cancel"), 0, 0, parent);
|
||||||
dialog.setWindowTitle(tr("Loading..."));
|
dialog.setWindowTitle(tr("Loading..."));
|
||||||
|
|
|
@ -17,6 +17,7 @@ public:
|
||||||
~GameInfoClass();
|
~GameInfoClass();
|
||||||
void GetGameInfo(QWidget* parent = nullptr);
|
void GetGameInfo(QWidget* parent = nullptr);
|
||||||
QVector<GameInfo> m_games;
|
QVector<GameInfo> m_games;
|
||||||
|
QVector<GameInfo> m_games_backup;
|
||||||
|
|
||||||
static bool CompareStrings(GameInfo& a, GameInfo& b) {
|
static bool CompareStrings(GameInfo& a, GameInfo& b) {
|
||||||
std::string name_a = a.name, name_b = b.name;
|
std::string name_a = a.name, name_b = b.name;
|
||||||
|
|
|
@ -413,6 +413,7 @@ void MainWindow::CreateConnects() {
|
||||||
int slider_pos = Config::getSliderPosition();
|
int slider_pos = Config::getSliderPosition();
|
||||||
ui->sizeSlider->setEnabled(true);
|
ui->sizeSlider->setEnabled(true);
|
||||||
ui->sizeSlider->setSliderPosition(slider_pos);
|
ui->sizeSlider->setSliderPosition(slider_pos);
|
||||||
|
ui->mw_searchbar->setText("");
|
||||||
});
|
});
|
||||||
// Grid
|
// Grid
|
||||||
connect(ui->setlistModeGridAct, &QAction::triggered, m_dock_widget.data(), [this]() {
|
connect(ui->setlistModeGridAct, &QAction::triggered, m_dock_widget.data(), [this]() {
|
||||||
|
@ -430,6 +431,7 @@ void MainWindow::CreateConnects() {
|
||||||
int slider_pos_grid = Config::getSliderPositionGrid();
|
int slider_pos_grid = Config::getSliderPositionGrid();
|
||||||
ui->sizeSlider->setEnabled(true);
|
ui->sizeSlider->setEnabled(true);
|
||||||
ui->sizeSlider->setSliderPosition(slider_pos_grid);
|
ui->sizeSlider->setSliderPosition(slider_pos_grid);
|
||||||
|
ui->mw_searchbar->setText("");
|
||||||
});
|
});
|
||||||
// Elf Viewer
|
// Elf Viewer
|
||||||
connect(ui->setlistElfAct, &QAction::triggered, m_dock_widget.data(), [this]() {
|
connect(ui->setlistElfAct, &QAction::triggered, m_dock_widget.data(), [this]() {
|
||||||
|
@ -658,14 +660,24 @@ void MainWindow::StartGame() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isTable;
|
||||||
void MainWindow::SearchGameTable(const QString& text) {
|
void MainWindow::SearchGameTable(const QString& text) {
|
||||||
if (isTableList) {
|
if (isTableList) {
|
||||||
|
if (isTable != true) {
|
||||||
|
m_game_info->m_games = m_game_info->m_games_backup;
|
||||||
|
m_game_list_frame->PopulateGameList();
|
||||||
|
isTable = true;
|
||||||
|
}
|
||||||
for (int row = 0; row < m_game_list_frame->rowCount(); row++) {
|
for (int row = 0; row < m_game_list_frame->rowCount(); row++) {
|
||||||
QString game_name = QString::fromStdString(m_game_info->m_games[row].name);
|
QString game_name = QString::fromStdString(m_game_info->m_games[row].name);
|
||||||
bool match = (game_name.contains(text, Qt::CaseInsensitive)); // Check only in column 1
|
bool match = (game_name.contains(text, Qt::CaseInsensitive)); // Check only in column 1
|
||||||
m_game_list_frame->setRowHidden(row, !match);
|
m_game_list_frame->setRowHidden(row, !match);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
isTable = false;
|
||||||
|
m_game_info->m_games = m_game_info->m_games_backup;
|
||||||
|
m_game_grid_frame->PopulateGameGrid(m_game_info->m_games, false);
|
||||||
|
|
||||||
QVector<GameInfo> filteredGames;
|
QVector<GameInfo> filteredGames;
|
||||||
for (const auto& gameInfo : m_game_info->m_games) {
|
for (const auto& gameInfo : m_game_info->m_games) {
|
||||||
QString game_name = QString::fromStdString(gameInfo.name);
|
QString game_name = QString::fromStdString(gameInfo.name);
|
||||||
|
@ -674,6 +686,7 @@ void MainWindow::SearchGameTable(const QString& text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::sort(filteredGames.begin(), filteredGames.end(), m_game_info->CompareStrings);
|
std::sort(filteredGames.begin(), filteredGames.end(), m_game_info->CompareStrings);
|
||||||
|
m_game_info->m_games = filteredGames;
|
||||||
m_game_grid_frame->PopulateGameGrid(filteredGames, true);
|
m_game_grid_frame->PopulateGameGrid(filteredGames, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue