allow searching in current playlist
This commit is contained in:
@@ -381,11 +381,11 @@ Song MPDConnection::GetCurrentSong() const
|
|||||||
Song result = item->info.song;
|
Song result = item->info.song;
|
||||||
item->info.song = 0;
|
item->info.song = 0;
|
||||||
mpd_freeInfoEntity(item);
|
mpd_freeInfoEntity(item);
|
||||||
mpd_finishCommand(itsConnection);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Song();
|
return Song();
|
||||||
|
mpd_finishCommand(itsConnection);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Song();
|
return Song();
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ bool redraw_header = 1;
|
|||||||
bool reload_lyrics = 0;
|
bool reload_lyrics = 0;
|
||||||
|
|
||||||
extern bool header_update_status;
|
extern bool header_update_status;
|
||||||
|
extern bool search_place;
|
||||||
extern bool search_case_sensitive;
|
extern bool search_case_sensitive;
|
||||||
extern bool search_match_to_pattern;
|
extern bool search_match_to_pattern;
|
||||||
|
|
||||||
@@ -1256,18 +1257,24 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 10:
|
case 10:
|
||||||
|
{
|
||||||
|
search_place = !search_place;
|
||||||
|
mSearcher->Current().first = "[.b]Search in:[/b] " + string(search_place ? "Database" : "Current playlist");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 11:
|
||||||
{
|
{
|
||||||
search_match_to_pattern = !search_match_to_pattern;
|
search_match_to_pattern = !search_match_to_pattern;
|
||||||
mSearcher->Current().first = "[.b]Search mode:[/b] " + (search_match_to_pattern ? search_mode_normal : search_mode_strict);
|
mSearcher->Current().first = "[.b]Search mode:[/b] " + (search_match_to_pattern ? search_mode_normal : search_mode_strict);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 11:
|
case 12:
|
||||||
{
|
{
|
||||||
search_case_sensitive = !search_case_sensitive;
|
search_case_sensitive = !search_case_sensitive;
|
||||||
mSearcher->Current().first = "[.b]Case sensitive:[/b] " + string(search_case_sensitive ? "Yes" : "No");
|
mSearcher->Current().first = "[.b]Case sensitive:[/b] " + string(search_case_sensitive ? "Yes" : "No");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 13:
|
case 14:
|
||||||
{
|
{
|
||||||
ShowMessage("Searching...");
|
ShowMessage("Searching...");
|
||||||
Search(s);
|
Search(s);
|
||||||
@@ -1275,12 +1282,12 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int found = mSearcher->Size()-search_engine_static_options;
|
int found = mSearcher->Size()-search_engine_static_options;
|
||||||
found += 3; // don't count options inserted below
|
found += 3; // don't count options inserted below
|
||||||
mSearcher->InsertSeparator(14);
|
mSearcher->InsertSeparator(15);
|
||||||
mSearcher->Insert(15, make_pair("[." + Config.color1 + "]Search results:[/" + Config.color1 + "] [." + Config.color2 + "]Found " + IntoStr(found) + (found > 1 ? " songs" : " song") + "[/" + Config.color2 + "]", Song()), 1, 1);
|
mSearcher->Insert(16, make_pair("[." + Config.color1 + "]Search results:[/" + Config.color1 + "] [." + Config.color2 + "]Found " + IntoStr(found) + (found > 1 ? " songs" : " song") + "[/" + Config.color2 + "]", Song()), 1, 1);
|
||||||
mSearcher->InsertSeparator(16);
|
mSearcher->InsertSeparator(17);
|
||||||
UpdateFoundList();
|
UpdateFoundList();
|
||||||
ShowMessage("Searching finished!");
|
ShowMessage("Searching finished!");
|
||||||
for (int i = 0; i < 13; i++)
|
for (int i = 0; i < search_engine_static_options-4; i++)
|
||||||
mSearcher->MakeStatic(i, 1);
|
mSearcher->MakeStatic(i, 1);
|
||||||
mSearcher->Go(wDown);
|
mSearcher->Go(wDown);
|
||||||
mSearcher->Go(wDown);
|
mSearcher->Go(wDown);
|
||||||
@@ -1289,7 +1296,7 @@ int main(int argc, char *argv[])
|
|||||||
ShowMessage("No results found");
|
ShowMessage("No results found");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 14:
|
case 15:
|
||||||
{
|
{
|
||||||
found_pos = 0;
|
found_pos = 0;
|
||||||
vFoundPositions.clear();
|
vFoundPositions.clear();
|
||||||
@@ -2734,7 +2741,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (wCurrent == mSearcher)
|
if (wCurrent == mSearcher)
|
||||||
{
|
{
|
||||||
mSearcher->Highlight(12); // highlight 'search' button
|
mSearcher->Highlight(13); // highlight 'search' button
|
||||||
goto ENTER_SEARCH_ENGINE_SCREEN;
|
goto ENTER_SEARCH_ENGINE_SCREEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2765,7 +2772,7 @@ int main(int argc, char *argv[])
|
|||||||
if (wCurrent == mBrowser && browsed_dir != "/")
|
if (wCurrent == mBrowser && browsed_dir != "/")
|
||||||
wCurrent->Select(0, 0); // [..] cannot be selected, uhm.
|
wCurrent->Select(0, 0); // [..] cannot be selected, uhm.
|
||||||
if (wCurrent == mSearcher)
|
if (wCurrent == mSearcher)
|
||||||
wCurrent->Select(13, 0); // 'Reset' cannot be selected, omgplz.
|
wCurrent->Select(14, 0); // 'Reset' cannot be selected, omgplz.
|
||||||
// hacking shit ends. need better solution :/
|
// hacking shit ends. need better solution :/
|
||||||
ShowMessage("Selection reversed!");
|
ShowMessage("Selection reversed!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ extern Menu<Song> *mPlaylist;
|
|||||||
extern Menu< std::pair<string, Song> > *mSearcher;
|
extern Menu< std::pair<string, Song> > *mSearcher;
|
||||||
|
|
||||||
bool search_match_to_pattern = 1;
|
bool search_match_to_pattern = 1;
|
||||||
|
bool search_place = 1;
|
||||||
bool search_case_sensitive = 0;
|
bool search_case_sensitive = 0;
|
||||||
|
|
||||||
string SearchEngineDisplayer(const std::pair<string, Song> &pair, void *, const Menu< std::pair<string, Song> > *menu)
|
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]Genre:[/b] " + s.GetGenre(), Song()));
|
||||||
mSearcher->AddOption(make_pair("[.b]Comment:[/b] " + s.GetComment(), Song()));
|
mSearcher->AddOption(make_pair("[.b]Comment:[/b] " + s.GetComment(), Song()));
|
||||||
mSearcher->AddSeparator();
|
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]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->AddSeparator();
|
||||||
mSearcher->AddOption(make_pair("Search", Song()));
|
mSearcher->AddOption(make_pair("Search", Song()));
|
||||||
mSearcher->AddOption(make_pair("Reset", Song()));
|
mSearcher->AddOption(make_pair("Reset", Song()));
|
||||||
@@ -80,7 +82,14 @@ void Search(Song &s)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SongList list;
|
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;
|
bool found = 1;
|
||||||
|
|
||||||
@@ -191,7 +200,8 @@ void Search(Song &s)
|
|||||||
mSearcher->AddOption(make_pair(".", **it));
|
mSearcher->AddOption(make_pair(".", **it));
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
FreeSongList(list);
|
if (search_place) // free song list only if it's database
|
||||||
|
FreeSongList(list);
|
||||||
s.GetEmptyFields(0);
|
s.GetEmptyFields(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "mpdpp.h"
|
#include "mpdpp.h"
|
||||||
#include "ncmpcpp.h"
|
#include "ncmpcpp.h"
|
||||||
|
|
||||||
const int search_engine_static_options = 17;
|
const int search_engine_static_options = 18;
|
||||||
|
|
||||||
string SearchEngineDisplayer(const std::pair<string, Song> &, void *, const Menu< std::pair<string, Song> > *);
|
string SearchEngineDisplayer(const std::pair<string, Song> &, void *, const Menu< std::pair<string, Song> > *);
|
||||||
void UpdateFoundList();
|
void UpdateFoundList();
|
||||||
|
|||||||
Reference in New Issue
Block a user