Fixed an issue where system names were included in game name searches done in collection systems.

This commit is contained in:
Leon Styhre 2021-09-23 17:42:04 +02:00
parent afe8128cc7
commit 61dbe3cba9
3 changed files with 25 additions and 6 deletions

View file

@ -21,6 +21,7 @@
FileFilterIndex::FileFilterIndex() FileFilterIndex::FileFilterIndex()
: mFilterByText(false) : mFilterByText(false)
, mTextRemoveSystem(false)
, mFilterByFavorites(false) , mFilterByFavorites(false)
, mFilterByGenre(false) , mFilterByGenre(false)
, mFilterByPlayers(false) , mFilterByPlayers(false)
@ -35,7 +36,7 @@ FileFilterIndex::FileFilterIndex()
// clang-format off // clang-format off
FilterDataDecl filterDecls[] = { FilterDataDecl filterDecls[] = {
//type //allKeys //filteredBy //filteredKeys //primaryKey //hasSecondaryKey //secondaryKey //menuLabel //type //allKeys //filteredBy //filteredKeys //primaryKey //hasSecondaryKey //secondaryKey //menuLabel
{FAVORITES_FILTER, &mFavoritesIndexAllKeys, &mFilterByFavorites, &mFavoritesIndexFilteredKeys, "favorite", false, "", "FAVORITES"}, {FAVORITES_FILTER, &mFavoritesIndexAllKeys, &mFilterByFavorites, &mFavoritesIndexFilteredKeys, "favorite", false, "", "FAVORITES"},
{GENRE_FILTER, &mGenreIndexAllKeys, &mFilterByGenre, &mGenreIndexFilteredKeys, "genre", true, "genre", "GENRE"}, {GENRE_FILTER, &mGenreIndexAllKeys, &mFilterByGenre, &mGenreIndexFilteredKeys, "genre", true, "genre", "GENRE"},
{PLAYER_FILTER, &mPlayersIndexAllKeys, &mFilterByPlayers, &mPlayersIndexFilteredKeys, "players", false, "", "PLAYERS"}, {PLAYER_FILTER, &mPlayersIndexAllKeys, &mFilterByPlayers, &mPlayersIndexFilteredKeys, "players", false, "", "PLAYERS"},
@ -359,15 +360,22 @@ bool FileFilterIndex::showFile(FileData* game)
bool keepGoing = false; bool keepGoing = false;
// Name filters take precedence over all other filters, so if there is no match for // Name filters take precedence over all other filters, so if there is no match for
// the game name, then always return false. // the game name, then always return false. If we're in a collection system and the option
if (mTextFilter != "" && // to show the system name has been enabled, then exclude the system name that is encapsulated
!(Utils::String::toUpper(game->getName()).find(mTextFilter) != std::string::npos)) { // in [] from the search string.
if (mTextFilter != "" && mTextRemoveSystem &&
!(Utils::String::toUpper(game->getName().substr(0, game->getName().find_last_of("[")))
.find(mTextFilter) != std::string::npos)) {
return false; return false;
} }
else if (mTextFilter != "") { else if (mTextFilter != "" &&
nameMatch = true; !(Utils::String::toUpper(game->getName()).find(mTextFilter) != std::string::npos)) {
return false;
} }
if (mTextFilter != "")
nameMatch = true;
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin(); for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin();
it != filterDataDecl.cend(); it++) { it != filterDataDecl.cend(); it++) {
FilterDataDecl filterData = (*it); FilterDataDecl filterData = (*it);

View file

@ -59,6 +59,7 @@ public:
bool isFiltered(); bool isFiltered();
bool isKeyBeingFilteredBy(std::string key, FilterIndexType type); bool isKeyBeingFilteredBy(std::string key, FilterIndexType type);
std::vector<FilterDataDecl>& getFilterDataDecls() { return filterDataDecl; } std::vector<FilterDataDecl>& getFilterDataDecls() { return filterDataDecl; }
void setTextRemoveSystem(bool status) { mTextRemoveSystem = status; }
void importIndex(FileFilterIndex* indexToImport); void importIndex(FileFilterIndex* indexToImport);
void resetIndex(); void resetIndex();
@ -85,6 +86,7 @@ private:
std::string mTextFilter; std::string mTextFilter;
bool mFilterByText; bool mFilterByText;
bool mTextRemoveSystem;
bool mFilterByFavorites; bool mFilterByFavorites;
bool mFilterByGenre; bool mFilterByGenre;

View file

@ -36,6 +36,15 @@ void GuiGamelistFilter::initializeMenu()
// Get filters from system. // Get filters from system.
mFilterIndex = mSystem->getIndex(); mFilterIndex = mSystem->getIndex();
// If this is a collection and system names are shown per game, then let FileFilterIndex
// know about this so the system names will not be included in game name text searches.
if (ViewController::get()->getState().getSystem()->isCollection()) {
if (Settings::getInstance()->getBool("CollectionShowSystemInfo"))
mFilterIndex->setTextRemoveSystem(true);
else
mFilterIndex->setTextRemoveSystem(false);
}
ComponentListRow row; ComponentListRow row;
// Show filtered menu. // Show filtered menu.