diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2012-08-31 23:09:56 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2012-08-31 23:09:56 +0200 |
commit | 4c944085d62e566fd3c99b053907d8d8b08790b8 (patch) | |
tree | 1265dfb218794902ac085998127bb315b15c7976 /src/browser.cpp | |
parent | f1625c920ae900466b84bf1ca36cf3a5f5979aef (diff) |
menu: generalize filtering, introduce interfaces
Diffstat (limited to 'src/browser.cpp')
-rw-r--r-- | src/browser.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index 446556b9..fed5c0bd 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -319,9 +319,21 @@ void Browser::GetSelectedSongs(MPD::SongList &v) } } -void Browser::ApplyFilter(const std::string &s) +std::string Browser::currentFilter() { - w->ApplyFilter(s, itsBrowsedDir == "/" ? 0 : 1, REG_ICASE | Config.regex_type); + return RegexFilter<MPD::Item>::currentFilter(*w); +} + +void Browser::applyFilter(const std::string &filter) +{ + w->ShowAll(); + auto fun = [](const Regex &rx, Menu<MPD::Item> &menu, const Menu<MPD::Item>::Item &item) { + if (item.value().type == MPD::itDirectory && item.value().name == "..") + return true; + return rx.match(menu.Stringify(item)); + }; + auto rx = RegexFilter<MPD::Item>(filter, Config.regex_type, fun); + w->Filter(w->Begin(), w->End(), rx); } bool Browser::hasSupportedExtension(const std::string &file) @@ -485,7 +497,6 @@ void Browser::GetLocalDirectory(MPD::ItemList &v, const std::string &directory, MPD::MutableSong *s = new MPD::MutableSong(mpd_song_begin(&file_pair)); new_item.song = std::shared_ptr<MPD::Song>(s); # ifdef HAVE_TAGLIB_H - // FIXME if (!recursively) TagEditor::ReadTags(*s); # endif // HAVE_TAGLIB_H |