Added a system sorting function to SystemData.

This commit is contained in:
Leon Styhre 2020-09-26 13:03:14 +02:00
parent 8db04c5fcb
commit 707850b339
3 changed files with 26 additions and 16 deletions

View file

@ -15,6 +15,7 @@
#include "utils/FileSystemUtil.h"
#include "utils/StringUtil.h"
#include "views/UIModeController.h"
#include "views/ViewController.h"
#include "CollectionSystemManager.h"
#include "FileFilterIndex.h"
#include "FileSorts.h"
@ -613,6 +614,28 @@ FileData* SystemData::getRandomGame(const FileData* currentGame)
return gameList.at(target);
}
void SystemData::sortSystem(bool reloadGamelist)
{
if (getName() == "recent")
return;
bool favoritesSorting;
if (CollectionSystemManager::get()->getIsCustomCollection(this))
favoritesSorting = Settings::getInstance()->getBool("FavFirstCustom");
else
favoritesSorting = Settings::getInstance()->getBool("FavoritesFirst");
FileData* rootFolder = getRootFolder();
setupSystemSortType(rootFolder);
rootFolder->sort(rootFolder->getSortTypeFromString(
rootFolder->getSortTypeString()), favoritesSorting);
if (reloadGamelist)
ViewController::get()->reloadGameListView(this, false);
}
std::pair<unsigned int, unsigned int> SystemData::getDisplayedGameCount() const
{
// Return all games for the system which are marked as 'countasgame'. As this flag is set

View file

@ -93,6 +93,8 @@ public:
static FileData* getRandomCollectionFolder(const FileData* currentFolder);
FileData* getRandomGame(const FileData* currentGame = nullptr);
void sortSystem(bool reloadGamelist = true);
// Load or re-load theme.
void loadTheme();

View file

@ -372,22 +372,7 @@ void GuiMenu::openUISettings()
for (auto it = SystemData::sSystemVector.cbegin(); it !=
SystemData::sSystemVector.cend(); it++) {
bool favoritesSorting;
if ((*it)->getName() == "recent")
continue;
if (CollectionSystemManager::get()->getIsCustomCollection(*it))
favoritesSorting = Settings::getInstance()->getBool("FavFirstCustom");
else
favoritesSorting = Settings::getInstance()->getBool("FavoritesFirst");
FileData* rootFolder = (*it)->getRootFolder();
rootFolder->getSystem()->setupSystemSortType(rootFolder);
rootFolder->sort(rootFolder->getSortTypeFromString(
rootFolder->getSortTypeString()), favoritesSorting);
ViewController::get()->reloadGameListView(*it);
(*it)->sortSystem();
// Jump to the first row of the gamelist.
IGameListView* gameList = ViewController::get()->getGameListView((*it)).get();