Qt: fix gamegrid regression: mismatch between entry count and grid size

This commit is contained in:
Megamouse 2017-10-05 17:39:54 +02:00 committed by Ani
parent 33182650ca
commit b2605206b1

View file

@ -1043,20 +1043,19 @@ void game_list_frame::PopulateGameGrid(uint maxCols, const QSize& image_size, co
m_xgrid = new game_list_grid(image_size, image_color, m_Margin_Factor, m_Text_Factor, showText); m_xgrid = new game_list_grid(image_size, image_color, m_Margin_Factor, m_Text_Factor, showText);
} }
// Get number of things that'll be in grid and precompute grid size. // Get list of matching apps and their index
uint entries = 0; QList<QPair<GUI_GameInfo*, int>> matching_apps;
for (const GUI_GameInfo& game : m_game_data)
for (uint i = 0; i < m_game_data.size(); i++)
{ {
if (qstr(game.info.category) == category::disc_Game || qstr(game.info.category) == category::hdd_Game) if (category::CategoryInMap(m_game_data[i].info.category, category::cat_boot) && SearchMatchesApp(m_game_data[i].info.name, m_game_data[i].info.serial))
{ {
if (SearchMatchesApp(game.info.name, game.info.serial) == false) matching_apps.append(QPair<GUI_GameInfo*, int>(&m_game_data[i], i));
{
continue;
}
++entries;
} }
} }
int entries = matching_apps.count();
// Edge cases! // Edge cases!
if (entries == 0) if (entries == 0)
{ // For whatever reason, 0%x is division by zero. Absolute nonsense by definition of modulus. But, I'll acquiesce. { // For whatever reason, 0%x is division by zero. Absolute nonsense by definition of modulus. But, I'll acquiesce.
@ -1076,19 +1075,13 @@ void game_list_frame::PopulateGameGrid(uint maxCols, const QSize& image_size, co
m_xgrid->setRowCount(maxRows); m_xgrid->setRowCount(maxRows);
m_xgrid->setColumnCount(maxCols); m_xgrid->setColumnCount(maxCols);
for (uint i = 0; i < m_game_data.size(); i++) for (const auto& app : matching_apps)
{ {
if (SearchMatchesApp(m_game_data[i].info.name, m_game_data[i].info.serial) == false) QString title = GUI::get_Single_Line(qstr(app.first->info.name));
{
continue;
}
if (category::CategoryInMap(m_game_data[i].info.category, category::cat_boot))
{
QString title = GUI::get_Single_Line(qstr(m_game_data[i].info.name));
m_xgrid->addItem(m_game_data[i].pxmap, title, i, r, c); m_xgrid->addItem(app.first->pxmap, title, app.second, r, c);
if (selected_item == m_game_data[i].info.icon_path) if (selected_item == app.first->info.icon_path)
{ {
m_xgrid->setCurrentItem(m_xgrid->item(r, c)); m_xgrid->setCurrentItem(m_xgrid->item(r, c));
} }
@ -1099,7 +1092,6 @@ void game_list_frame::PopulateGameGrid(uint maxCols, const QSize& image_size, co
r++; r++;
} }
} }
}
if (c != 0) if (c != 0)
{ // if left over games exist -- if empty entries exist { // if left over games exist -- if empty entries exist