From 32382464f803d8a7f7d36b3424e1fa8607bb65f6 Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Fri, 31 Mar 2017 09:15:42 +0200 Subject: [PATCH] Fixed bracket and parenthesis removal for games not found in the meta database. --- RetroFE/Source/Database/MetadataDatabase.cpp | 41 ----------------- RetroFE/Source/RetroFE.cpp | 47 ++++++++++++++++++++ 2 files changed, 47 insertions(+), 41 deletions(-) diff --git a/RetroFE/Source/Database/MetadataDatabase.cpp b/RetroFE/Source/Database/MetadataDatabase.cpp index 7e4228d..f6a6b81 100644 --- a/RetroFE/Source/Database/MetadataDatabase.cpp +++ b/RetroFE/Source/Database/MetadataDatabase.cpp @@ -228,13 +228,6 @@ void MetadataDatabase::injectMetadata(CollectionInfo *collection) int rc; sqlite3_stmt *stmt; - bool showParenthesis = true; - bool showSquareBrackets = true; - - (void)config_.getProperty("showParenthesis", showParenthesis); - (void)config_.getProperty("showSquareBrackets", showSquareBrackets); - - // items into a hash to make it easily searchable std::vector *items = &collection->items; std::map itemMap; @@ -272,40 +265,6 @@ void MetadataDatabase::injectMetadata(CollectionInfo *collection) std::string launcher; std::string title = fullTitle; - //todo: this should be a helper method, peformed both in CollectionInfoBuilder - if(!showParenthesis) - { - std::string::size_type firstPos = title.find_first_of("("); - std::string::size_type secondPos = title.find_first_of(")", firstPos); - - while(firstPos != std::string::npos && secondPos != std::string::npos) - { - firstPos = title.find_first_of("("); - secondPos = title.find_first_of(")", firstPos); - - if (firstPos != std::string::npos) - { - title.erase(firstPos, (secondPos - firstPos) + 1); - } - } - } - if(!showSquareBrackets) - { - std::string::size_type firstPos = title.find_first_of("["); - std::string::size_type secondPos = title.find_first_of("]", firstPos); - - while(firstPos != std::string::npos && secondPos != std::string::npos) - { - firstPos = title.find_first_of("["); - secondPos = title.find_first_of("]", firstPos); - - if (firstPos != std::string::npos && secondPos != std::string::npos) - { - title.erase(firstPos, (secondPos - firstPos) + 1); - } - } - } - std::map::iterator it = itemMap.find(name); if(it != itemMap.end()) diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 87b58fd..d71b01a 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -948,6 +948,53 @@ CollectionInfo *RetroFE::getCollection(std::string collectionName) cib.addPlaylists(collection); collection->sortFavoriteItems(); + // Remove parenthesis and brackets, if so configured + bool showParenthesis = true; + bool showSquareBrackets = true; + + (void)config_.getProperty("showParenthesis", showParenthesis); + (void)config_.getProperty("showSquareBrackets", showSquareBrackets); + + typedef std::map *> Playlists_T; + for(Playlists_T::iterator itP = collection->playlists.begin(); itP != collection->playlists.end(); itP++) + { + for(std::vector ::iterator itI = itP->second->begin(); itI != itP->second->end(); itI++) + { + if(!showParenthesis) + { + std::string::size_type firstPos = (*itI)->title.find_first_of("("); + std::string::size_type secondPos = (*itI)->title.find_first_of(")", firstPos); + + while(firstPos != std::string::npos && secondPos != std::string::npos) + { + firstPos = (*itI)->title.find_first_of("("); + secondPos = (*itI)->title.find_first_of(")", firstPos); + + if (firstPos != std::string::npos) + { + (*itI)->title.erase(firstPos, (secondPos - firstPos) + 1); + } + } + } + if(!showSquareBrackets) + { + std::string::size_type firstPos = (*itI)->title.find_first_of("["); + std::string::size_type secondPos = (*itI)->title.find_first_of("]", firstPos); + + while(firstPos != std::string::npos && secondPos != std::string::npos) + { + firstPos = (*itI)->title.find_first_of("["); + secondPos = (*itI)->title.find_first_of("]", firstPos); + + if (firstPos != std::string::npos && secondPos != std::string::npos) + { + (*itI)->title.erase(firstPos, (secondPos - firstPos) + 1); + } + } + } + } + } + return collection; }