Add support for ignoring diacritics while searching and filtering lists
This commit is contained in:
@@ -734,7 +734,7 @@ bool browserEntryMatcher(const Regex::Regex &rx, const MPD::Item &item, bool fil
|
||||
{
|
||||
if (isItemParentDirectory(item))
|
||||
return filter;
|
||||
return Regex::search(itemToString(item), rx);
|
||||
return Regex::search(itemToString(item), rx, Config.ignore_diacritics);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1086,19 +1086,19 @@ std::string SongToString(const MPD::Song &s)
|
||||
|
||||
bool TagEntryMatcher(const Regex::Regex &rx, const PrimaryTag &pt)
|
||||
{
|
||||
return Regex::search(pt.tag(), rx);
|
||||
return Regex::search(pt.tag(), rx, Config.ignore_diacritics);
|
||||
}
|
||||
|
||||
bool AlbumEntryMatcher(const Regex::Regex &rx, const NC::Menu<AlbumEntry>::Item &item, bool filter)
|
||||
{
|
||||
if (item.isSeparator() || item.value().isAllTracksEntry())
|
||||
return filter;
|
||||
return Regex::search(AlbumToString(item.value()), rx);
|
||||
return Regex::search(AlbumToString(item.value()), rx, Config.ignore_diacritics);
|
||||
}
|
||||
|
||||
bool SongEntryMatcher(const Regex::Regex &rx, const MPD::Song &s)
|
||||
{
|
||||
return Regex::search(SongToString(s), rx);
|
||||
return Regex::search(SongToString(s), rx, Config.ignore_diacritics);
|
||||
}
|
||||
|
||||
bool MoveToTag(NC::Menu<PrimaryTag> &tags, const std::string &primary_tag)
|
||||
|
||||
@@ -353,7 +353,7 @@ std::string songToString(const MPD::Song &s)
|
||||
|
||||
bool playlistEntryMatcher(const Regex::Regex &rx, const MPD::Song &s)
|
||||
{
|
||||
return Regex::search(songToString(s), rx);
|
||||
return Regex::search(songToString(s), rx, Config.ignore_diacritics);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -558,12 +558,12 @@ std::string SongToString(const MPD::Song &s)
|
||||
|
||||
bool PlaylistEntryMatcher(const Regex::Regex &rx, const MPD::Playlist &playlist)
|
||||
{
|
||||
return Regex::search(playlist.path(), rx);
|
||||
return Regex::search(playlist.path(), rx, Config.ignore_diacritics);
|
||||
}
|
||||
|
||||
bool SongEntryMatcher(const Regex::Regex &rx, const MPD::Song &s)
|
||||
{
|
||||
return Regex::search(SongToString(s), rx);
|
||||
return Regex::search(SongToString(s), rx, Config.ignore_diacritics);
|
||||
}
|
||||
|
||||
boost::optional<size_t> GetSongIndexInPlaylist(MPD::Playlist playlist, const MPD::Song &song)
|
||||
|
||||
@@ -517,36 +517,36 @@ void SearchEngine::Search()
|
||||
{
|
||||
if (!rx[0].empty())
|
||||
any_found =
|
||||
Regex::search(s->getArtist(), rx[0])
|
||||
|| Regex::search(s->getAlbumArtist(), rx[0])
|
||||
|| Regex::search(s->getTitle(), rx[0])
|
||||
|| Regex::search(s->getAlbum(), rx[0])
|
||||
|| Regex::search(s->getName(), rx[0])
|
||||
|| Regex::search(s->getComposer(), rx[0])
|
||||
|| Regex::search(s->getPerformer(), rx[0])
|
||||
|| Regex::search(s->getGenre(), rx[0])
|
||||
|| Regex::search(s->getDate(), rx[0])
|
||||
|| Regex::search(s->getComment(), rx[0]);
|
||||
Regex::search(s->getArtist(), rx[0], Config.ignore_diacritics)
|
||||
|| Regex::search(s->getAlbumArtist(), rx[0], Config.ignore_diacritics)
|
||||
|| Regex::search(s->getTitle(), rx[0], Config.ignore_diacritics)
|
||||
|| Regex::search(s->getAlbum(), rx[0], Config.ignore_diacritics)
|
||||
|| Regex::search(s->getName(), rx[0], Config.ignore_diacritics)
|
||||
|| Regex::search(s->getComposer(), rx[0], Config.ignore_diacritics)
|
||||
|| Regex::search(s->getPerformer(), rx[0], Config.ignore_diacritics)
|
||||
|| Regex::search(s->getGenre(), rx[0], Config.ignore_diacritics)
|
||||
|| Regex::search(s->getDate(), rx[0], Config.ignore_diacritics)
|
||||
|| Regex::search(s->getComment(), rx[0], Config.ignore_diacritics);
|
||||
if (found && !rx[1].empty())
|
||||
found = Regex::search(s->getArtist(), rx[1]);
|
||||
found = Regex::search(s->getArtist(), rx[1], Config.ignore_diacritics);
|
||||
if (found && !rx[2].empty())
|
||||
found = Regex::search(s->getAlbumArtist(), rx[2]);
|
||||
found = Regex::search(s->getAlbumArtist(), rx[2], Config.ignore_diacritics);
|
||||
if (found && !rx[3].empty())
|
||||
found = Regex::search(s->getTitle(), rx[3]);
|
||||
found = Regex::search(s->getTitle(), rx[3], Config.ignore_diacritics);
|
||||
if (found && !rx[4].empty())
|
||||
found = Regex::search(s->getAlbum(), rx[4]);
|
||||
found = Regex::search(s->getAlbum(), rx[4], Config.ignore_diacritics);
|
||||
if (found && !rx[5].empty())
|
||||
found = Regex::search(s->getName(), rx[5]);
|
||||
found = Regex::search(s->getName(), rx[5], Config.ignore_diacritics);
|
||||
if (found && !rx[6].empty())
|
||||
found = Regex::search(s->getComposer(), rx[6]);
|
||||
found = Regex::search(s->getComposer(), rx[6], Config.ignore_diacritics);
|
||||
if (found && !rx[7].empty())
|
||||
found = Regex::search(s->getPerformer(), rx[7]);
|
||||
found = Regex::search(s->getPerformer(), rx[7], Config.ignore_diacritics);
|
||||
if (found && !rx[8].empty())
|
||||
found = Regex::search(s->getGenre(), rx[8]);
|
||||
found = Regex::search(s->getGenre(), rx[8], Config.ignore_diacritics);
|
||||
if (found && !rx[9].empty())
|
||||
found = Regex::search(s->getDate(), rx[9]);
|
||||
found = Regex::search(s->getDate(), rx[9], Config.ignore_diacritics);
|
||||
if (found && !rx[10].empty())
|
||||
found = Regex::search(s->getComment(), rx[10]);
|
||||
found = Regex::search(s->getComment(), rx[10], Config.ignore_diacritics);
|
||||
}
|
||||
else // match only if values are equal
|
||||
{
|
||||
@@ -616,7 +616,7 @@ bool SEItemEntryMatcher(const Regex::Regex &rx, const NC::Menu<SEItem>::Item &it
|
||||
{
|
||||
if (item.isSeparator() || !item.value().isSong())
|
||||
return filter;
|
||||
return Regex::search(SEItemToString(item.value()), rx);
|
||||
return Regex::search(SEItemToString(item.value()), rx, Config.ignore_diacritics);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ void DisplayComponent(SelectedItemsAdder::Component &menu)
|
||||
bool EntryMatcher(const Regex::Regex &rx, const NC::Menu<SelectedItemsAdder::Entry>::Item &item)
|
||||
{
|
||||
if (!item.isSeparator())
|
||||
return Regex::search(item.value().item(), rx);
|
||||
return Regex::search(item.value().item(), rx, Config.ignore_diacritics);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1191,12 +1191,12 @@ bool DirEntryMatcher(const Regex::Regex &rx, const std::pair<std::string, std::s
|
||||
{
|
||||
if (dir.first == "." || dir.first == "..")
|
||||
return filter;
|
||||
return Regex::search(dir.first, rx);
|
||||
return Regex::search(dir.first, rx, Config.ignore_diacritics);
|
||||
}
|
||||
|
||||
bool SongEntryMatcher(const Regex::Regex &rx, const MPD::MutableSong &s)
|
||||
{
|
||||
return Regex::search(SongToString(s), rx);
|
||||
return Regex::search(SongToString(s), rx, Config.ignore_diacritics);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user