allow searching in current playlist

This commit is contained in:
unK
2008-10-19 23:00:46 +02:00
parent f7e56300cf
commit 5775eaf039
4 changed files with 31 additions and 14 deletions

View File

@@ -26,6 +26,7 @@ extern Menu<Song> *mPlaylist;
extern Menu< std::pair<string, Song> > *mSearcher;
bool search_match_to_pattern = 1;
bool search_place = 1;
bool search_case_sensitive = 0;
string SearchEngineDisplayer(const std::pair<string, Song> &pair, void *, const Menu< std::pair<string, Song> > *menu)
@@ -67,8 +68,9 @@ void PrepareSearchEngine(Song &s)
mSearcher->AddOption(make_pair("[.b]Genre:[/b] " + s.GetGenre(), Song()));
mSearcher->AddOption(make_pair("[.b]Comment:[/b] " + s.GetComment(), Song()));
mSearcher->AddSeparator();
mSearcher->AddOption(make_pair("[.b]Search in:[/b] " + string(search_place ? "Database" : "Current playlist"), Song()));
mSearcher->AddOption(make_pair("[.b]Search mode:[/b] " + (search_match_to_pattern ? search_mode_normal : search_mode_strict), Song()));
mSearcher->AddOption(make_pair("[.b]Case sensitive:[/b] " + (string)(search_case_sensitive ? "Yes" : "No"), Song()));
mSearcher->AddOption(make_pair("[.b]Case sensitive:[/b] " + string(search_case_sensitive ? "Yes" : "No"), Song()));
mSearcher->AddSeparator();
mSearcher->AddOption(make_pair("Search", Song()));
mSearcher->AddOption(make_pair("Reset", Song()));
@@ -80,7 +82,14 @@ void Search(Song &s)
return;
SongList list;
Mpd->GetDirectoryRecursive("/", list);
if (search_place)
Mpd->GetDirectoryRecursive("/", list);
else
{
list.reserve(mPlaylist->Size());
for (int i = 0; i < mPlaylist->Size(); i++)
list.push_back(&(*mPlaylist)[i]);
}
bool found = 1;
@@ -191,7 +200,8 @@ void Search(Song &s)
mSearcher->AddOption(make_pair(".", **it));
found = 1;
}
FreeSongList(list);
if (search_place) // free song list only if it's database
FreeSongList(list);
s.GetEmptyFields(0);
}