Small refactoring of CollectionSystemManager.

This commit is contained in:
Leon Styhre 2020-10-25 19:42:25 +01:00
parent 546f6304ef
commit d01be2ecba
3 changed files with 8 additions and 18 deletions

View file

@ -449,7 +449,7 @@ void CollectionSystemManager::updateCollectionSystem(FileData* file, CollectionS
void CollectionSystemManager::trimCollectionCount(FileData* rootFolder, int limit) void CollectionSystemManager::trimCollectionCount(FileData* rootFolder, int limit)
{ {
SystemData* curSys = rootFolder->getSystem(); SystemData* curSys = rootFolder->getSystem();
while ((int)rootFolder->getChildrenListToDisplay().size() > limit) { while (static_cast<int>(rootFolder->getChildrenListToDisplay().size()) > limit) {
CollectionFileData* gameToRemove = CollectionFileData* gameToRemove =
(CollectionFileData*)rootFolder->getChildrenListToDisplay().back(); (CollectionFileData*)rootFolder->getChildrenListToDisplay().back();
ViewController::get()->getGameListView(curSys).get()->remove(gameToRemove, false); ViewController::get()->getGameListView(curSys).get()->remove(gameToRemove, false);
@ -1191,24 +1191,17 @@ bool CollectionSystemManager::includeFileInAutoCollections(FileData* file)
return file->getName() != "kodi" && file->getSystem()->isGameSystem(); return file->getName() != "kodi" && file->getSystem()->isGameSystem();
} }
std::string getCustomCollectionConfigPath(std::string collectionName) std::string CollectionSystemManager::getCustomCollectionConfigPath(std::string collectionName)
{ {
return getCollectionsFolder() + "/custom-" + collectionName + ".cfg"; return getCollectionsFolder() + "/custom-" + collectionName + ".cfg";
} }
std::string getCollectionsFolder() std::string CollectionSystemManager::getCollectionsFolder()
{ {
return Utils::FileSystem::getGenericPath(Utils::FileSystem::getHomePath() + return Utils::FileSystem::getGenericPath(Utils::FileSystem::getHomePath() +
"/.emulationstation/collections"); "/.emulationstation/collections");
} }
bool systemSort(SystemData* sys1, SystemData* sys2)
{
std::string name1 = Utils::String::toUpper(sys1->getName());
std::string name2 = Utils::String::toUpper(sys2->getName());
return name1.compare(name2) < 0;
}
// Return whether the system is a custom collection. // Return whether the system is a custom collection.
bool CollectionSystemManager::getIsCustomCollection(SystemData* system) bool CollectionSystemManager::getIsCustomCollection(SystemData* system)
{ {

View file

@ -115,6 +115,7 @@ private:
bool mHasEnabledCustomCollection; bool mHasEnabledCustomCollection;
std::string mEditingCollection; std::string mEditingCollection;
CollectionSystemData* mEditingCollectionSystemData; CollectionSystemData* mEditingCollectionSystemData;
SystemData* mCustomCollectionsBundle;
void initAutoCollectionSystems(); void initAutoCollectionSystems();
void initCustomCollectionSystems(); void initCustomCollectionSystems();
@ -138,11 +139,8 @@ private:
bool themeFolderExists(std::string folder); bool themeFolderExists(std::string folder);
bool includeFileInAutoCollections(FileData* file); bool includeFileInAutoCollections(FileData* file);
SystemData* mCustomCollectionsBundle; std::string getCustomCollectionConfigPath(std::string collectionName);
std::string getCollectionsFolder();
}; };
std::string getCustomCollectionConfigPath(std::string collectionName);
std::string getCollectionsFolder();
bool systemSort(SystemData* sys1, SystemData* sys2);
#endif // ES_APP_COLLECTION_SYSTEM_MANAGER_H #endif // ES_APP_COLLECTION_SYSTEM_MANAGER_H

View file

@ -299,8 +299,8 @@ const std::string FileData::getVideoPath() const
if (Settings::getInstance()->getBool("LocalArt")) if (Settings::getInstance()->getBool("LocalArt"))
{ {
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
std::string localMediaPath = mEnvData->mStartPath + "/videos/" + getDisplayName() + std::string localMediaPath = mEnvData->mStartPath + "/videos/" +
"-video" + extList[i]; getDisplayName() + "-video" + extList[i];
if (Utils::FileSystem::exists(localMediaPath)) if (Utils::FileSystem::exists(localMediaPath))
return localMediaPath; return localMediaPath;
} }
@ -311,7 +311,6 @@ const std::string FileData::getVideoPath() const
const std::vector<FileData*>& FileData::getChildrenListToDisplay() const std::vector<FileData*>& FileData::getChildrenListToDisplay()
{ {
FileFilterIndex* idx = mSystem->getIndex(); FileFilterIndex* idx = mSystem->getIndex();
if (idx->isFiltered()) { if (idx->isFiltered()) {
mFilteredChildren.clear(); mFilteredChildren.clear();