QT: Fix search in Grid mode (#2490)
Some checks are pending
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions

* QT: Fix search in Grid mode

* Fix performance?

* Fix performance List

* +fix
This commit is contained in:
DanielSvoboda 2025-02-21 03:29:30 -03:00 committed by GitHub
parent 6f5dfc576f
commit 745cdd89fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View file

@ -49,6 +49,9 @@ void GameInfoClass::GetGameInfo(QWidget* parent) {
return readGameInfo(Common::FS::PathFromQString(path));
}).results();
// used to retrieve values after performing a search
m_games_backup = m_games;
// Progress bar, please be patient :)
QProgressDialog dialog(tr("Loading game list, please wait :3"), tr("Cancel"), 0, 0, parent);
dialog.setWindowTitle(tr("Loading..."));

View file

@ -17,6 +17,7 @@ public:
~GameInfoClass();
void GetGameInfo(QWidget* parent = nullptr);
QVector<GameInfo> m_games;
QVector<GameInfo> m_games_backup;
static bool CompareStrings(GameInfo& a, GameInfo& b) {
std::string name_a = a.name, name_b = b.name;

View file

@ -413,6 +413,7 @@ void MainWindow::CreateConnects() {
int slider_pos = Config::getSliderPosition();
ui->sizeSlider->setEnabled(true);
ui->sizeSlider->setSliderPosition(slider_pos);
ui->mw_searchbar->setText("");
});
// Grid
connect(ui->setlistModeGridAct, &QAction::triggered, m_dock_widget.data(), [this]() {
@ -430,6 +431,7 @@ void MainWindow::CreateConnects() {
int slider_pos_grid = Config::getSliderPositionGrid();
ui->sizeSlider->setEnabled(true);
ui->sizeSlider->setSliderPosition(slider_pos_grid);
ui->mw_searchbar->setText("");
});
// Elf Viewer
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) {
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++) {
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
m_game_list_frame->setRowHidden(row, !match);
}
} 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;
for (const auto& gameInfo : m_game_info->m_games) {
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);
m_game_info->m_games = filteredGames;
m_game_grid_frame->PopulateGameGrid(filteredGames, true);
}
}