game_list: fix sort and scroll

This commit is contained in:
Megamouse 2017-07-25 11:30:50 +02:00 committed by Ivan
parent 60e2928ec1
commit ff772dd28b
2 changed files with 13 additions and 10 deletions

View File

@ -321,7 +321,7 @@ void game_list_frame::OnColClicked(int col)
xgui_settings->SetValue(GUI::gl_sortAsc, m_colSortOrder == Qt::AscendingOrder);
xgui_settings->SetValue(GUI::gl_sortCol, col);
gameList->sortByColumn(m_sortColumn, m_colSortOrder);
SortGameList();
}
// Filter for Categories
@ -343,6 +343,15 @@ void game_list_frame::FilterData()
}
}
void game_list_frame::SortGameList()
{
gameList->sortByColumn(m_sortColumn, m_colSortOrder);
gameList->verticalHeader()->setMinimumSectionSize(m_Icon_Size.height());
gameList->verticalHeader()->setMaximumSectionSize(m_Icon_Size.height());
gameList->resizeRowsToContents();
gameList->resizeColumnToContents(0);
}
void game_list_frame::Refresh(bool fromDrive)
{
if (fromDrive)
@ -471,13 +480,7 @@ void game_list_frame::Refresh(bool fromDrive)
int row = PopulateGameList();
FilterData();
gameList->selectRow(row);
gameList->sortByColumn(m_sortColumn, m_colSortOrder);
gameList->verticalHeader()->setMinimumSectionSize(m_Icon_Size.height());
gameList->verticalHeader()->setMaximumSectionSize(m_Icon_Size.height());
gameList->resizeRowsToContents();
gameList->resizeColumnToContents(0);
gameList->scrollToTop(); // fix drunk scroll behaviour (may still not be perfect)
gameList->scrollToBottom(); // fix drunk scroll behaviour (may still not be perfect)
SortGameList();
gameList->scrollTo(gameList->currentIndex(), QAbstractItemView::PositionAtCenter);
}
else
@ -842,8 +845,7 @@ int game_list_frame::PopulateGameList()
std::string selected_item = CurrentSelectionIconPath();
// Hack to delete everything without removing the headers.
gameList->setRowCount(0);
gameList->clearContents();
gameList->setRowCount(m_game_data.size());

View File

@ -218,6 +218,7 @@ protected:
private:
void PopulateGameGrid(uint maxCols, const QSize& image_size, const QColor& image_color);
void FilterData();
void SortGameList();
int PopulateGameList();
bool SearchMatchesApp(const std::string& name, const std::string& serial);