change namespace SearchEngine into class
This commit is contained in:
10
src/global.h
10
src/global.h
@@ -37,7 +37,7 @@ namespace Global
|
|||||||
|
|
||||||
// extern Menu<MPD::Song> *myPlaylist->Main();
|
// extern Menu<MPD::Song> *myPlaylist->Main();
|
||||||
// extern Menu<MPD::Item> *myBrowser->Main();
|
// extern Menu<MPD::Item> *myBrowser->Main();
|
||||||
extern Menu< std::pair<Buffer *, MPD::Song *> > *mSearcher;
|
// extern Menu< std::pair<Buffer *, MPD::Song *> > *mSearcher;
|
||||||
|
|
||||||
extern Window *wLibActiveCol;
|
extern Window *wLibActiveCol;
|
||||||
extern Menu<std::string> *mLibArtists;
|
extern Menu<std::string> *mLibArtists;
|
||||||
@@ -106,13 +106,13 @@ namespace Global
|
|||||||
extern bool header_update_status;
|
extern bool header_update_status;
|
||||||
|
|
||||||
extern bool header_update_status;
|
extern bool header_update_status;
|
||||||
extern bool search_case_sensitive;
|
// extern bool search_case_sensitive;
|
||||||
extern bool search_match_to_pattern;
|
// extern bool search_match_to_pattern;
|
||||||
|
|
||||||
extern std::string volume_state;
|
extern std::string volume_state;
|
||||||
|
|
||||||
extern const char *search_mode_normal;
|
// extern const char *search_mode_normal;
|
||||||
extern const char *search_mode_strict;
|
// extern const char *search_mode_strict;
|
||||||
|
|
||||||
extern std::vector<int> vFoundPositions;
|
extern std::vector<int> vFoundPositions;
|
||||||
extern int found_pos;
|
extern int found_pos;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "media_library.h"
|
#include "media_library.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "playlist_editor.h"
|
#include "playlist_editor.h"
|
||||||
|
#include "search_engine.h"
|
||||||
#include "status_checker.h"
|
#include "status_checker.h"
|
||||||
#include "tag_editor.h"
|
#include "tag_editor.h"
|
||||||
|
|
||||||
@@ -96,7 +97,7 @@ void Info::GetSong()
|
|||||||
else if (
|
else if (
|
||||||
(wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
(wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
||||||
|| (wCurrent == myBrowser->Main() && myBrowser->Main()->Current().type == MPD::itSong)
|
|| (wCurrent == myBrowser->Main() && myBrowser->Main()->Current().type == MPD::itSong)
|
||||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
|| (wCurrent == mySearcher->Main() && !mySearcher->Main()->Current().first)
|
||||||
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
||||||
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
@@ -115,7 +116,7 @@ void Info::GetSong()
|
|||||||
s = myBrowser->Main()->at(id).song;
|
s = myBrowser->Main()->at(id).song;
|
||||||
break;
|
break;
|
||||||
case csSearcher:
|
case csSearcher:
|
||||||
s = mSearcher->at(id).second;
|
s = mySearcher->Main()->at(id).second;
|
||||||
break;
|
break;
|
||||||
case csLibrary:
|
case csLibrary:
|
||||||
s = &mLibSongs->at(id);
|
s = &mLibSongs->at(id);
|
||||||
@@ -183,7 +184,7 @@ void Info::GetArtist()
|
|||||||
else if (
|
else if (
|
||||||
(wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
(wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
||||||
|| (wCurrent == myBrowser->Main() && myBrowser->Main()->Current().type == MPD::itSong)
|
|| (wCurrent == myBrowser->Main() && myBrowser->Main()->Current().type == MPD::itSong)
|
||||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
|| (wCurrent == mySearcher->Main() && !mySearcher->Main()->Current().first)
|
||||||
|| (wCurrent == mLibArtists && !mLibArtists->Empty())
|
|| (wCurrent == mLibArtists && !mLibArtists->Empty())
|
||||||
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
||||||
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
||||||
@@ -209,7 +210,7 @@ void Info::GetArtist()
|
|||||||
*artist = myBrowser->Main()->at(id).song->GetArtist();
|
*artist = myBrowser->Main()->at(id).song->GetArtist();
|
||||||
break;
|
break;
|
||||||
case csSearcher:
|
case csSearcher:
|
||||||
*artist = mSearcher->at(id).second->GetArtist();
|
*artist = mySearcher->Main()->at(id).second->GetArtist();
|
||||||
break;
|
break;
|
||||||
case csLibrary:
|
case csLibrary:
|
||||||
*artist = mLibArtists->at(id);
|
*artist = mLibArtists->at(id);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "media_library.h"
|
#include "media_library.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "playlist_editor.h"
|
#include "playlist_editor.h"
|
||||||
|
#include "search_engine.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "status_checker.h"
|
#include "status_checker.h"
|
||||||
@@ -109,7 +110,7 @@ void Lyrics::Get()
|
|||||||
reload_lyrics
|
reload_lyrics
|
||||||
|| (wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
|| (wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
||||||
|| (wCurrent == myBrowser->Main() && myBrowser->Main()->Current().type == MPD::itSong)
|
|| (wCurrent == myBrowser->Main() && myBrowser->Main()->Current().type == MPD::itSong)
|
||||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
|| (wCurrent == mySearcher->Main() && !mySearcher->Main()->Current().first)
|
||||||
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
||||||
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
@@ -147,7 +148,7 @@ void Lyrics::Get()
|
|||||||
s = myBrowser->Main()->at(id).song;
|
s = myBrowser->Main()->at(id).song;
|
||||||
break;
|
break;
|
||||||
case csSearcher:
|
case csSearcher:
|
||||||
s = mSearcher->at(id).second;
|
s = mySearcher->Main()->at(id).second;
|
||||||
break;
|
break;
|
||||||
case csLibrary:
|
case csLibrary:
|
||||||
s = &mLibSongs->at(id);
|
s = &mLibSongs->at(id);
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
myPlaylist->Init();
|
myPlaylist->Init();
|
||||||
myBrowser->Init();
|
myBrowser->Init();
|
||||||
SearchEngine::Init();
|
mySearcher->Init();
|
||||||
MediaLibrary::Init();
|
MediaLibrary::Init();
|
||||||
PlaylistEditor::Init();
|
PlaylistEditor::Init();
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ int main(int argc, char *argv[])
|
|||||||
screen_title = info_title;
|
screen_title = info_title;
|
||||||
break;
|
break;
|
||||||
case csSearcher:
|
case csSearcher:
|
||||||
screen_title = "Search engine";
|
screen_title = mySearcher->Title();
|
||||||
break;
|
break;
|
||||||
case csLibrary:
|
case csLibrary:
|
||||||
screen_title = "Media library";
|
screen_title = "Media library";
|
||||||
@@ -508,7 +508,7 @@ int main(int argc, char *argv[])
|
|||||||
Help::Resize();
|
Help::Resize();
|
||||||
myPlaylist->Resize();
|
myPlaylist->Resize();
|
||||||
myBrowser->Resize();
|
myBrowser->Resize();
|
||||||
SearchEngine::Resize();
|
mySearcher->Resize();
|
||||||
MediaLibrary::Resize();
|
MediaLibrary::Resize();
|
||||||
PlaylistEditor::Resize();
|
PlaylistEditor::Resize();
|
||||||
Info::Resize();
|
Info::Resize();
|
||||||
@@ -587,7 +587,7 @@ int main(int argc, char *argv[])
|
|||||||
# endif // HAVE_TAGLIB_H
|
# endif // HAVE_TAGLIB_H
|
||||||
case csSearcher:
|
case csSearcher:
|
||||||
{
|
{
|
||||||
SearchEngine::EnterPressed();
|
mySearcher->EnterPressed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case csLibrary:
|
case csLibrary:
|
||||||
@@ -624,7 +624,7 @@ int main(int argc, char *argv[])
|
|||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
|| wCurrent == mEditorTags
|
|| wCurrent == mEditorTags
|
||||||
# endif // HAVE_TAGLIB_H
|
# endif // HAVE_TAGLIB_H
|
||||||
|| (wCurrent == myBrowser->Main() && ((Menu<Song> *)wCurrent)->Choice() >= (myBrowser->CurrentDir() != "/" ? 1 : 0)) || (wCurrent == mSearcher && !mSearcher->Current().first)
|
|| (wCurrent == myBrowser->Main() && ((Menu<Song> *)wCurrent)->Choice() >= (myBrowser->CurrentDir() != "/" ? 1 : 0)) || (wCurrent == mySearcher->Main() && !mySearcher->Main()->Current().first)
|
||||||
|| wCurrent == mLibSongs
|
|| wCurrent == mLibSongs
|
||||||
|| wCurrent == mPlaylistEditor)
|
|| wCurrent == mPlaylistEditor)
|
||||||
{
|
{
|
||||||
@@ -644,7 +644,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (current_screen == csSearcher)
|
else if (current_screen == csSearcher)
|
||||||
{
|
{
|
||||||
SearchEngine::SpacePressed();
|
mySearcher->SpacePressed();
|
||||||
}
|
}
|
||||||
else if (current_screen == csLibrary)
|
else if (current_screen == csLibrary)
|
||||||
{
|
{
|
||||||
@@ -1259,12 +1259,12 @@ int main(int argc, char *argv[])
|
|||||||
ShowMessage("Browser display mode: %s", Config.columns_in_browser ? "Columns" : "Classic");
|
ShowMessage("Browser display mode: %s", Config.columns_in_browser ? "Columns" : "Classic");
|
||||||
myBrowser->Main()->SetTitle(Config.columns_in_browser ? Display::Columns(Config.song_columns_list_format) : "");
|
myBrowser->Main()->SetTitle(Config.columns_in_browser ? Display::Columns(Config.song_columns_list_format) : "");
|
||||||
}
|
}
|
||||||
else if (wCurrent == mSearcher)
|
else if (wCurrent == mySearcher->Main())
|
||||||
{
|
{
|
||||||
Config.columns_in_search_engine = !Config.columns_in_search_engine;
|
Config.columns_in_search_engine = !Config.columns_in_search_engine;
|
||||||
ShowMessage("Search engine display mode: %s", Config.columns_in_search_engine ? "Columns" : "Classic");
|
ShowMessage("Search engine display mode: %s", Config.columns_in_search_engine ? "Columns" : "Classic");
|
||||||
if (mSearcher->Size() > search_engine_static_options)
|
if (mySearcher->Main()->Size() > SearchEngine::StaticOptions)
|
||||||
mSearcher->SetTitle(Config.columns_in_search_engine ? Display::Columns(Config.song_columns_list_format) : "");
|
mySearcher->Main()->SetTitle(Config.columns_in_search_engine ? Display::Columns(Config.song_columns_list_format) : "");
|
||||||
}
|
}
|
||||||
// redraw_screen = 1;
|
// redraw_screen = 1;
|
||||||
}
|
}
|
||||||
@@ -1418,7 +1418,7 @@ int main(int argc, char *argv[])
|
|||||||
else if (
|
else if (
|
||||||
(wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
(wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
||||||
|| (wCurrent == myBrowser->Main() && myBrowser->Main()->Current().type == itSong)
|
|| (wCurrent == myBrowser->Main() && myBrowser->Main()->Current().type == itSong)
|
||||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
|| (wCurrent == mySearcher->Main() && !mySearcher->Main()->Current().first)
|
||||||
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
||||||
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
||||||
|| (wCurrent == mEditorTags && !mEditorTags->Empty()))
|
|| (wCurrent == mEditorTags && !mEditorTags->Empty()))
|
||||||
@@ -1434,7 +1434,7 @@ int main(int argc, char *argv[])
|
|||||||
edited_song = *myBrowser->Main()->at(id).song;
|
edited_song = *myBrowser->Main()->at(id).song;
|
||||||
break;
|
break;
|
||||||
case csSearcher:
|
case csSearcher:
|
||||||
edited_song = *mSearcher->at(id).second;
|
edited_song = *mySearcher->Main()->at(id).second;
|
||||||
break;
|
break;
|
||||||
case csLibrary:
|
case csLibrary:
|
||||||
edited_song = mLibSongs->at(id);
|
edited_song = mLibSongs->at(id);
|
||||||
@@ -1542,7 +1542,7 @@ int main(int argc, char *argv[])
|
|||||||
else if (Keypressed(input, Key.GoToContainingDir))
|
else if (Keypressed(input, Key.GoToContainingDir))
|
||||||
{
|
{
|
||||||
if ((wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
if ((wCurrent == myPlaylist->Main() && !myPlaylist->Main()->Empty())
|
||||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
|| (wCurrent == mySearcher->Main() && !mySearcher->Main()->Current().first)
|
||||||
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
|| (wCurrent == mLibSongs && !mLibSongs->Empty())
|
||||||
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
@@ -1558,7 +1558,7 @@ int main(int argc, char *argv[])
|
|||||||
s = &myPlaylist->Main()->at(id);
|
s = &myPlaylist->Main()->at(id);
|
||||||
break;
|
break;
|
||||||
case csSearcher:
|
case csSearcher:
|
||||||
s = mSearcher->at(id).second;
|
s = mySearcher->Main()->at(id).second;
|
||||||
break;
|
break;
|
||||||
case csLibrary:
|
case csLibrary:
|
||||||
s = &mLibSongs->at(id);
|
s = &mLibSongs->at(id);
|
||||||
@@ -1596,13 +1596,13 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.StartSearching))
|
else if (Keypressed(input, Key.StartSearching))
|
||||||
{
|
{
|
||||||
if (wCurrent == mSearcher)
|
if (wCurrent == mySearcher->Main())
|
||||||
{
|
{
|
||||||
mSearcher->Highlight(search_engine_search_button);
|
mySearcher->Main()->Highlight(SearchEngine::SearchButton);
|
||||||
mSearcher->Highlighting(0);
|
mySearcher->Main()->Highlighting(0);
|
||||||
mSearcher->Refresh();
|
mySearcher->Main()->Refresh();
|
||||||
mSearcher->Highlighting(1);
|
mySearcher->Main()->Highlighting(1);
|
||||||
SearchEngine::EnterPressed();
|
mySearcher->EnterPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.GoToPosition))
|
else if (Keypressed(input, Key.GoToPosition))
|
||||||
@@ -1626,7 +1626,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (wCurrent == myPlaylist->Main()
|
if (wCurrent == myPlaylist->Main()
|
||||||
|| wCurrent == myBrowser->Main()
|
|| wCurrent == myBrowser->Main()
|
||||||
|| (wCurrent == mSearcher && !mSearcher->Current().first)
|
|| (wCurrent == mySearcher->Main() && !mySearcher->Main()->Current().first)
|
||||||
|| wCurrent == mLibSongs
|
|| wCurrent == mLibSongs
|
||||||
|| wCurrent == mPlaylistEditor
|
|| wCurrent == mPlaylistEditor
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
@@ -1641,8 +1641,8 @@ int main(int argc, char *argv[])
|
|||||||
// hackish shit begins
|
// hackish shit begins
|
||||||
if (wCurrent == myBrowser->Main() && myBrowser->CurrentDir() != "/")
|
if (wCurrent == myBrowser->Main() && myBrowser->CurrentDir() != "/")
|
||||||
mList->Select(0, 0); // [..] cannot be selected, uhm.
|
mList->Select(0, 0); // [..] cannot be selected, uhm.
|
||||||
if (wCurrent == mSearcher)
|
if (wCurrent == mySearcher->Main())
|
||||||
mList->Select(search_engine_reset_button, 0); // 'Reset' cannot be selected, omgplz.
|
mList->Select(SearchEngine::ResetButton, 0); // 'Reset' cannot be selected, omgplz.
|
||||||
// hacking shit ends.
|
// hacking shit ends.
|
||||||
ShowMessage("Selection reversed!");
|
ShowMessage("Selection reversed!");
|
||||||
}
|
}
|
||||||
@@ -1651,7 +1651,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (wCurrent == myPlaylist->Main()
|
if (wCurrent == myPlaylist->Main()
|
||||||
|| wCurrent == myBrowser->Main()
|
|| wCurrent == myBrowser->Main()
|
||||||
|| wCurrent == mSearcher
|
|| wCurrent == mySearcher->Main()
|
||||||
|| wCurrent == mLibSongs
|
|| wCurrent == mLibSongs
|
||||||
|| wCurrent == mPlaylistEditor
|
|| wCurrent == mPlaylistEditor
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
@@ -1672,7 +1672,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (wCurrent != myPlaylist->Main()
|
if (wCurrent != myPlaylist->Main()
|
||||||
&& wCurrent != myBrowser->Main()
|
&& wCurrent != myBrowser->Main()
|
||||||
&& wCurrent != mSearcher
|
&& wCurrent != mySearcher->Main()
|
||||||
&& wCurrent != mLibSongs
|
&& wCurrent != mLibSongs
|
||||||
&& wCurrent != mPlaylistEditor)
|
&& wCurrent != mPlaylistEditor)
|
||||||
continue;
|
continue;
|
||||||
@@ -1723,7 +1723,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
case csSearcher:
|
case csSearcher:
|
||||||
{
|
{
|
||||||
Song *s = new Song(*mSearcher->at(*it).second);
|
Song *s = new Song(*mySearcher->Main()->at(*it).second);
|
||||||
result.push_back(s);
|
result.push_back(s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1908,7 +1908,7 @@ int main(int argc, char *argv[])
|
|||||||
# endif // HAVE_TAGLIB_H
|
# endif // HAVE_TAGLIB_H
|
||||||
)
|
)
|
||||||
&& (current_screen != csSearcher
|
&& (current_screen != csSearcher
|
||||||
|| mSearcher->Current().first)
|
|| mySearcher->Main()->Current().first)
|
||||||
)
|
)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1926,7 +1926,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
ShowMessage("Searching...");
|
ShowMessage("Searching...");
|
||||||
List *mList = reinterpret_cast<Menu<Song> *>(wCurrent);
|
List *mList = reinterpret_cast<Menu<Song> *>(wCurrent);
|
||||||
for (size_t i = (wCurrent == mSearcher ? search_engine_static_options : 0); i < mList->Size(); i++)
|
for (size_t i = (wCurrent == mySearcher->Main() ? SearchEngine::StaticOptions : 0); i < mList->Size(); i++)
|
||||||
{
|
{
|
||||||
string name;
|
string name;
|
||||||
switch (current_screen)
|
switch (current_screen)
|
||||||
@@ -1950,7 +1950,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case csSearcher:
|
case csSearcher:
|
||||||
name = mSearcher->at(i).second->toString(Config.song_list_format);
|
name = mySearcher->Main()->at(i).second->toString(Config.song_list_format);
|
||||||
break;
|
break;
|
||||||
case csLibrary:
|
case csLibrary:
|
||||||
if (wCurrent == mLibArtists)
|
if (wCurrent == mLibArtists)
|
||||||
@@ -2168,7 +2168,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.SearchEngine))
|
else if (Keypressed(input, Key.SearchEngine))
|
||||||
{
|
{
|
||||||
SearchEngine::SwitchTo();
|
mySearcher->SwitchTo();
|
||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.MediaLibrary))
|
else if (Keypressed(input, Key.MediaLibrary))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,32 +30,31 @@ using namespace MPD;
|
|||||||
using namespace Global;
|
using namespace Global;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
Menu< std::pair<Buffer *, Song *> > *Global::mSearcher;
|
SearchEngine *mySearcher = new SearchEngine;
|
||||||
|
|
||||||
bool Global::search_match_to_pattern = 1;
|
const char *SearchEngine::NormalMode = "Match if tag contains searched phrase";
|
||||||
bool Global::search_case_sensitive = 0;
|
const char *SearchEngine::StrictMode = "Match only if both values are the same";
|
||||||
|
|
||||||
const char *Global::search_mode_normal = "Match if tag contains searched phrase";
|
size_t SearchEngine::StaticOptions = 20;
|
||||||
const char *Global::search_mode_strict = "Match only if both values are the same";
|
size_t SearchEngine::SearchButton = 15;
|
||||||
|
size_t SearchEngine::ResetButton = 16;
|
||||||
|
|
||||||
namespace
|
bool SearchEngine::MatchToPattern = 1;
|
||||||
{
|
bool SearchEngine::CaseSensitive = 0;
|
||||||
SearchPattern sought;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchEngine::Init()
|
void SearchEngine::Init()
|
||||||
{
|
{
|
||||||
mSearcher = new Menu< std::pair<Buffer *, Song *> >(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
|
w = new Menu< std::pair<Buffer *, Song *> >(0, main_start_y, COLS, main_height, "", Config.main_color, brNone);
|
||||||
mSearcher->HighlightColor(Config.main_highlight_color);
|
w->HighlightColor(Config.main_highlight_color);
|
||||||
mSearcher->SetTimeout(ncmpcpp_window_timeout);
|
w->SetTimeout(ncmpcpp_window_timeout);
|
||||||
mSearcher->SetItemDisplayer(Display::SearchEngine);
|
w->SetItemDisplayer(Display::SearchEngine);
|
||||||
mSearcher->SetSelectPrefix(&Config.selected_item_prefix);
|
w->SetSelectPrefix(&Config.selected_item_prefix);
|
||||||
mSearcher->SetSelectSuffix(&Config.selected_item_suffix);
|
w->SetSelectSuffix(&Config.selected_item_suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchEngine::Resize()
|
void SearchEngine::Resize()
|
||||||
{
|
{
|
||||||
mSearcher->Resize(COLS, main_height);
|
w->Resize(COLS, main_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchEngine::SwitchTo()
|
void SearchEngine::SwitchTo()
|
||||||
@@ -67,14 +66,14 @@ void SearchEngine::SwitchTo()
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
CLEAR_FIND_HISTORY;
|
CLEAR_FIND_HISTORY;
|
||||||
if (mSearcher->Empty())
|
if (w->Empty())
|
||||||
PrepareSearchEngine();
|
Prepare();
|
||||||
wCurrent = mSearcher;
|
wCurrent = w;
|
||||||
wCurrent->Hide();
|
wCurrent->Hide();
|
||||||
current_screen = csSearcher;
|
current_screen = csSearcher;
|
||||||
// redraw_screen = 1;
|
// redraw_screen = 1;
|
||||||
redraw_header = 1;
|
redraw_header = 1;
|
||||||
if (!mSearcher->Back().first)
|
if (!w->Back().first)
|
||||||
{
|
{
|
||||||
wCurrent->WriteXY(0, 0, 0, "Updating list...");
|
wCurrent->WriteXY(0, 0, 0, "Updating list...");
|
||||||
UpdateFoundList();
|
UpdateFoundList();
|
||||||
@@ -82,126 +81,130 @@ void SearchEngine::SwitchTo()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SearchEngine::Title()
|
||||||
|
{
|
||||||
|
return "Search engine";
|
||||||
|
}
|
||||||
|
|
||||||
void SearchEngine::EnterPressed()
|
void SearchEngine::EnterPressed()
|
||||||
{
|
{
|
||||||
size_t option = mSearcher->Choice();
|
size_t option = w->Choice();
|
||||||
LockStatusbar();
|
LockStatusbar();
|
||||||
SearchPattern &s = sought;
|
|
||||||
|
|
||||||
if (option <= 12)
|
if (option < SearchButton)
|
||||||
mSearcher->Current().first->Clear();
|
w->Current().first->Clear();
|
||||||
|
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
Statusbar() << fmtBold << "Any: " << fmtBoldEnd;
|
Statusbar() << fmtBold << "Any: " << fmtBoldEnd;
|
||||||
s.Any(wFooter->GetString(s.Any()));
|
itsPattern.Any(wFooter->GetString(itsPattern.Any()));
|
||||||
*mSearcher->Current().first << fmtBold << "Any: " << fmtBoldEnd << ' ' << ShowTag(s.Any());
|
*w->Current().first << fmtBold << "Any: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.Any());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
Statusbar() << fmtBold << "Artist: " << fmtBoldEnd;
|
Statusbar() << fmtBold << "Artist: " << fmtBoldEnd;
|
||||||
s.SetArtist(wFooter->GetString(s.GetArtist()));
|
itsPattern.SetArtist(wFooter->GetString(itsPattern.GetArtist()));
|
||||||
*mSearcher->Current().first << fmtBold << "Artist: " << fmtBoldEnd << ' ' << ShowTag(s.GetArtist());
|
*w->Current().first << fmtBold << "Artist: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetArtist());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
Statusbar() << fmtBold << "Title: " << fmtBoldEnd;
|
Statusbar() << fmtBold << "Title: " << fmtBoldEnd;
|
||||||
s.SetTitle(wFooter->GetString(s.GetTitle()));
|
itsPattern.SetTitle(wFooter->GetString(itsPattern.GetTitle()));
|
||||||
*mSearcher->Current().first << fmtBold << "Title: " << fmtBoldEnd << ' ' << ShowTag(s.GetTitle());
|
*w->Current().first << fmtBold << "Title: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetTitle());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
Statusbar() << fmtBold << "Album: " << fmtBoldEnd;
|
Statusbar() << fmtBold << "Album: " << fmtBoldEnd;
|
||||||
s.SetAlbum(wFooter->GetString(s.GetAlbum()));
|
itsPattern.SetAlbum(wFooter->GetString(itsPattern.GetAlbum()));
|
||||||
*mSearcher->Current().first << fmtBold << "Album: " << fmtBoldEnd << ' ' << ShowTag(s.GetAlbum());
|
*w->Current().first << fmtBold << "Album: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetAlbum());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
Statusbar() << fmtBold << "Filename: " << fmtBoldEnd;
|
Statusbar() << fmtBold << "Filename: " << fmtBoldEnd;
|
||||||
s.SetFile(wFooter->GetString(s.GetFile()));
|
itsPattern.SetFile(wFooter->GetString(itsPattern.GetFile()));
|
||||||
*mSearcher->Current().first << fmtBold << "Filename: " << fmtBoldEnd << ' ' << ShowTag(s.GetFile());
|
*w->Current().first << fmtBold << "Filename: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetFile());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
{
|
{
|
||||||
Statusbar() << fmtBold << "Composer: " << fmtBoldEnd;
|
Statusbar() << fmtBold << "Composer: " << fmtBoldEnd;
|
||||||
s.SetComposer(wFooter->GetString(s.GetComposer()));
|
itsPattern.SetComposer(wFooter->GetString(itsPattern.GetComposer()));
|
||||||
*mSearcher->Current().first << fmtBold << "Composer: " << fmtBoldEnd << ' ' << ShowTag(s.GetComposer());
|
*w->Current().first << fmtBold << "Composer: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetComposer());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 6:
|
case 6:
|
||||||
{
|
{
|
||||||
Statusbar() << fmtBold << "Performer: " << fmtBoldEnd;
|
Statusbar() << fmtBold << "Performer: " << fmtBoldEnd;
|
||||||
s.SetPerformer(wFooter->GetString(s.GetPerformer()));
|
itsPattern.SetPerformer(wFooter->GetString(itsPattern.GetPerformer()));
|
||||||
*mSearcher->Current().first << fmtBold << "Performer:" << fmtBoldEnd << ' ' << ShowTag(s.GetPerformer());
|
*w->Current().first << fmtBold << "Performer:" << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetPerformer());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 7:
|
case 7:
|
||||||
{
|
{
|
||||||
Statusbar() << fmtBold << "Genre: " << fmtBoldEnd;
|
Statusbar() << fmtBold << "Genre: " << fmtBoldEnd;
|
||||||
s.SetGenre(wFooter->GetString(s.GetGenre()));
|
itsPattern.SetGenre(wFooter->GetString(itsPattern.GetGenre()));
|
||||||
*mSearcher->Current().first << fmtBold << "Genre: " << fmtBoldEnd << ' ' << ShowTag(s.GetGenre());
|
*w->Current().first << fmtBold << "Genre: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetGenre());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
Statusbar() << fmtBold << "Year: " << fmtBoldEnd;
|
Statusbar() << fmtBold << "Year: " << fmtBoldEnd;
|
||||||
s.SetYear(wFooter->GetString(s.GetYear(), 4));
|
itsPattern.SetYear(wFooter->GetString(itsPattern.GetYear(), 4));
|
||||||
*mSearcher->Current().first << fmtBold << "Year: " << fmtBoldEnd << ' ' << ShowTag(s.GetYear());
|
*w->Current().first << fmtBold << "Year: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetYear());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 9:
|
case 9:
|
||||||
{
|
{
|
||||||
Statusbar() << fmtBold << "Comment: " << fmtBoldEnd;
|
Statusbar() << fmtBold << "Comment: " << fmtBoldEnd;
|
||||||
s.SetComment(wFooter->GetString(s.GetComment()));
|
itsPattern.SetComment(wFooter->GetString(itsPattern.GetComment()));
|
||||||
*mSearcher->Current().first << fmtBold << "Comment: " << fmtBoldEnd << ' ' << ShowTag(s.GetComment());
|
*w->Current().first << fmtBold << "Comment: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetComment());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 11:
|
case 11:
|
||||||
{
|
{
|
||||||
Config.search_in_db = !Config.search_in_db;
|
Config.search_in_db = !Config.search_in_db;
|
||||||
*mSearcher->Current().first << fmtBold << "Search in:" << fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
|
*w->Current().first << fmtBold << "Search in:" << fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 12:
|
case 12:
|
||||||
{
|
{
|
||||||
search_match_to_pattern = !search_match_to_pattern;
|
MatchToPattern = !MatchToPattern;
|
||||||
*mSearcher->Current().first << fmtBold << "Search mode:" << fmtBoldEnd << ' ' << (search_match_to_pattern ? search_mode_normal : search_mode_strict);
|
*w->Current().first << fmtBold << "Search mode:" << fmtBoldEnd << ' ' << (MatchToPattern ? NormalMode : StrictMode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 13:
|
case 13:
|
||||||
{
|
{
|
||||||
search_case_sensitive = !search_case_sensitive;
|
CaseSensitive = !CaseSensitive;
|
||||||
*mSearcher->Current().first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (search_case_sensitive ? "Yes" : "No");
|
*w->Current().first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (CaseSensitive ? "Yes" : "No");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 15:
|
case 15:
|
||||||
{
|
{
|
||||||
ShowMessage("Searching...");
|
ShowMessage("Searching...");
|
||||||
Search();
|
Search();
|
||||||
if (!mSearcher->Back().first)
|
if (!w->Back().first)
|
||||||
{
|
{
|
||||||
if (Config.columns_in_search_engine)
|
if (Config.columns_in_search_engine)
|
||||||
mSearcher->SetTitle(Display::Columns(Config.song_columns_list_format));
|
w->SetTitle(Display::Columns(Config.song_columns_list_format));
|
||||||
size_t found = mSearcher->Size()-search_engine_static_options;
|
size_t found = w->Size()-SearchEngine::StaticOptions;
|
||||||
found += 3; // don't count options inserted below
|
found += 3; // don't count options inserted below
|
||||||
mSearcher->InsertSeparator(search_engine_reset_button+1);
|
w->InsertSeparator(ResetButton+1);
|
||||||
mSearcher->InsertOption(search_engine_reset_button+2, std::make_pair((Buffer *)0, (Song *)0), 1, 1);
|
w->InsertOption(ResetButton+2, std::make_pair((Buffer *)0, (Song *)0), 1, 1);
|
||||||
mSearcher->at(search_engine_reset_button+2).first = new Buffer();
|
w->at(ResetButton+2).first = new Buffer();
|
||||||
*mSearcher->at(search_engine_reset_button+2).first << Config.color1 << "Search results: " << Config.color2 << "Found " << found << (found > 1 ? " songs" : " song") << clDefault;
|
*w->at(ResetButton+2).first << Config.color1 << "Search results: " << Config.color2 << "Found " << found << (found > 1 ? " songs" : " song") << clDefault;
|
||||||
mSearcher->InsertSeparator(search_engine_reset_button+3);
|
w->InsertSeparator(ResetButton+3);
|
||||||
UpdateFoundList();
|
UpdateFoundList();
|
||||||
ShowMessage("Searching finished!");
|
ShowMessage("Searching finished!");
|
||||||
for (size_t i = 0; i < search_engine_static_options-4; i++)
|
for (size_t i = 0; i < StaticOptions-4; i++)
|
||||||
mSearcher->Static(i, 1);
|
w->Static(i, 1);
|
||||||
mSearcher->Scroll(wDown);
|
w->Scroll(wDown);
|
||||||
mSearcher->Scroll(wDown);
|
w->Scroll(wDown);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ShowMessage("No results found");
|
ShowMessage("No results found");
|
||||||
@@ -210,16 +213,16 @@ void SearchEngine::EnterPressed()
|
|||||||
case 16:
|
case 16:
|
||||||
{
|
{
|
||||||
CLEAR_FIND_HISTORY;
|
CLEAR_FIND_HISTORY;
|
||||||
PrepareSearchEngine();
|
Prepare();
|
||||||
ShowMessage("Search state reset");
|
ShowMessage("Search state reset");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
block_item_list_update = 1;
|
block_item_list_update = 1;
|
||||||
if (Config.ncmpc_like_songs_adding && mSearcher->isBold())
|
if (Config.ncmpc_like_songs_adding && w->isBold())
|
||||||
{
|
{
|
||||||
long long hash = mSearcher->Current().second->GetHash();
|
long long hash = w->Current().second->GetHash();
|
||||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||||
{
|
{
|
||||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
||||||
@@ -231,13 +234,13 @@ void SearchEngine::EnterPressed()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const Song &s = *mSearcher->Current().second;
|
const Song &s = *w->Current().second;
|
||||||
int id = Mpd->AddSong(s);
|
int id = Mpd->AddSong(s);
|
||||||
if (id >= 0)
|
if (id >= 0)
|
||||||
{
|
{
|
||||||
Mpd->PlayID(id);
|
Mpd->PlayID(id);
|
||||||
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str());
|
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str());
|
||||||
mSearcher->BoldOption(mSearcher->Choice(), 1);
|
w->BoldOption(w->Choice(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -248,14 +251,14 @@ void SearchEngine::EnterPressed()
|
|||||||
|
|
||||||
void SearchEngine::SpacePressed()
|
void SearchEngine::SpacePressed()
|
||||||
{
|
{
|
||||||
if (mSearcher->Current().first)
|
if (w->Current().first)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
block_item_list_update = 1;
|
block_item_list_update = 1;
|
||||||
if (Config.ncmpc_like_songs_adding && mSearcher->isBold())
|
if (Config.ncmpc_like_songs_adding && w->isBold())
|
||||||
{
|
{
|
||||||
block_playlist_update = 1;
|
block_playlist_update = 1;
|
||||||
long long hash = mSearcher->Current().second->GetHash();
|
long long hash = w->Current().second->GetHash();
|
||||||
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
for (size_t i = 0; i < myPlaylist->Main()->Size(); i++)
|
||||||
{
|
{
|
||||||
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
if (myPlaylist->Main()->at(i).GetHash() == hash)
|
||||||
@@ -266,95 +269,93 @@ void SearchEngine::SpacePressed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mpd->CommitQueue();
|
Mpd->CommitQueue();
|
||||||
mSearcher->BoldOption(mSearcher->Choice(), 0);
|
w->BoldOption(w->Choice(), 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const Song &s = *mSearcher->Current().second;
|
const Song &s = *w->Current().second;
|
||||||
if (Mpd->AddSong(s) != -1)
|
if (Mpd->AddSong(s) != -1)
|
||||||
{
|
{
|
||||||
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str());
|
ShowMessage("Added to playlist: %s", s.toString(Config.song_status_format).c_str());
|
||||||
mSearcher->BoldOption(mSearcher->Choice(), 1);
|
w->BoldOption(w->Choice(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mSearcher->Scroll(wDown);
|
w->Scroll(wDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateFoundList()
|
void SearchEngine::UpdateFoundList()
|
||||||
{
|
{
|
||||||
bool bold = 0;
|
bool bold = 0;
|
||||||
for (size_t i = search_engine_static_options; i < mSearcher->Size(); i++)
|
for (size_t i = StaticOptions; i < w->Size(); i++)
|
||||||
{
|
{
|
||||||
for (size_t j = 0; j < myPlaylist->Main()->Size(); j++)
|
for (size_t j = 0; j < myPlaylist->Main()->Size(); j++)
|
||||||
{
|
{
|
||||||
if (myPlaylist->Main()->at(j).GetHash() == mSearcher->at(i).second->GetHash())
|
if (myPlaylist->Main()->at(j).GetHash() == w->at(i).second->GetHash())
|
||||||
{
|
{
|
||||||
bold = 1;
|
bold = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mSearcher->BoldOption(i, bold);
|
w->BoldOption(i, bold);
|
||||||
bold = 0;
|
bold = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrepareSearchEngine()
|
void SearchEngine::Prepare()
|
||||||
{
|
{
|
||||||
SearchPattern &s = sought;
|
for (size_t i = 0; i < w->Size(); i++)
|
||||||
|
|
||||||
for (size_t i = 0; i < mSearcher->Size(); i++)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
delete (*mSearcher)[i].first;
|
delete (*w)[i].first;
|
||||||
delete (*mSearcher)[i].second;
|
delete (*w)[i].second;
|
||||||
}
|
}
|
||||||
catch (List::InvalidItem) { }
|
catch (List::InvalidItem) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Clear();
|
itsPattern.Clear();
|
||||||
mSearcher->SetTitle("");
|
w->SetTitle("");
|
||||||
mSearcher->Clear();
|
w->Clear();
|
||||||
mSearcher->Reset();
|
w->Reset();
|
||||||
mSearcher->ResizeBuffer(17);
|
w->ResizeBuffer(17);
|
||||||
|
|
||||||
mSearcher->IntoSeparator(10);
|
w->IntoSeparator(10);
|
||||||
mSearcher->IntoSeparator(14);
|
w->IntoSeparator(14);
|
||||||
|
|
||||||
for (size_t i = 0; i < 17; i++)
|
for (size_t i = 0; i < 17; i++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mSearcher->at(i).first = new Buffer();
|
w->at(i).first = new Buffer();
|
||||||
}
|
}
|
||||||
catch (List::InvalidItem) { }
|
catch (List::InvalidItem) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
*mSearcher->at(0).first << fmtBold << "Any: " << fmtBoldEnd << ' ' << ShowTag(s.Any());
|
*w->at(0).first << fmtBold << "Any: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.Any());
|
||||||
*mSearcher->at(1).first << fmtBold << "Artist: " << fmtBoldEnd << ' ' << ShowTag(s.GetArtist());
|
*w->at(1).first << fmtBold << "Artist: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetArtist());
|
||||||
*mSearcher->at(2).first << fmtBold << "Title: " << fmtBoldEnd << ' ' << ShowTag(s.GetTitle());
|
*w->at(2).first << fmtBold << "Title: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetTitle());
|
||||||
*mSearcher->at(3).first << fmtBold << "Album: " << fmtBoldEnd << ' ' << ShowTag(s.GetAlbum());
|
*w->at(3).first << fmtBold << "Album: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetAlbum());
|
||||||
*mSearcher->at(4).first << fmtBold << "Filename: " << fmtBoldEnd << ' ' << ShowTag(s.GetName());
|
*w->at(4).first << fmtBold << "Filename: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetName());
|
||||||
*mSearcher->at(5).first << fmtBold << "Composer: " << fmtBoldEnd << ' ' << ShowTag(s.GetComposer());
|
*w->at(5).first << fmtBold << "Composer: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetComposer());
|
||||||
*mSearcher->at(6).first << fmtBold << "Performer:" << fmtBoldEnd << ' ' << ShowTag(s.GetPerformer());
|
*w->at(6).first << fmtBold << "Performer:" << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetPerformer());
|
||||||
*mSearcher->at(7).first << fmtBold << "Genre: " << fmtBoldEnd << ' ' << ShowTag(s.GetGenre());
|
*w->at(7).first << fmtBold << "Genre: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetGenre());
|
||||||
*mSearcher->at(8).first << fmtBold << "Year: " << fmtBoldEnd << ' ' << ShowTag(s.GetYear());
|
*w->at(8).first << fmtBold << "Year: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetYear());
|
||||||
*mSearcher->at(9).first << fmtBold << "Comment: " << fmtBoldEnd << ' ' << ShowTag(s.GetComment());
|
*w->at(9).first << fmtBold << "Comment: " << fmtBoldEnd << ' ' << ShowTag(itsPattern.GetComment());
|
||||||
|
|
||||||
*mSearcher->at(11).first << fmtBold << "Search in:" << fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
|
*w->at(11).first << fmtBold << "Search in:" << fmtBoldEnd << ' ' << (Config.search_in_db ? "Database" : "Current playlist");
|
||||||
*mSearcher->at(12).first << fmtBold << "Search mode:" << fmtBoldEnd << ' ' << (search_match_to_pattern ? search_mode_normal : search_mode_strict);
|
*w->at(12).first << fmtBold << "Search mode:" << fmtBoldEnd << ' ' << (MatchToPattern ? NormalMode : StrictMode);
|
||||||
*mSearcher->at(13).first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (search_case_sensitive ? "Yes" : "No");
|
*w->at(13).first << fmtBold << "Case sensitive:" << fmtBoldEnd << ' ' << (CaseSensitive ? "Yes" : "No");
|
||||||
|
|
||||||
*mSearcher->at(15).first << "Search";
|
*w->at(15).first << "Search";
|
||||||
*mSearcher->at(16).first << "Reset";
|
*w->at(16).first << "Reset";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Search()
|
void SearchEngine::Search()
|
||||||
{
|
{
|
||||||
if (sought.Empty())
|
if (itsPattern.Empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SearchPattern s = sought;
|
SearchPattern s = itsPattern;
|
||||||
|
|
||||||
SongList list;
|
SongList list;
|
||||||
if (Config.search_in_db)
|
if (Config.search_in_db)
|
||||||
@@ -369,7 +370,7 @@ void Search()
|
|||||||
bool any_found = 1;
|
bool any_found = 1;
|
||||||
bool found = 1;
|
bool found = 1;
|
||||||
|
|
||||||
if (!search_case_sensitive)
|
if (!CaseSensitive)
|
||||||
{
|
{
|
||||||
string t;
|
string t;
|
||||||
t = s.Any();
|
t = s.Any();
|
||||||
@@ -413,7 +414,7 @@ void Search()
|
|||||||
{
|
{
|
||||||
Song copy = **it;
|
Song copy = **it;
|
||||||
|
|
||||||
if (!search_case_sensitive)
|
if (!CaseSensitive)
|
||||||
{
|
{
|
||||||
string t;
|
string t;
|
||||||
t = copy.GetArtist();
|
t = copy.GetArtist();
|
||||||
@@ -451,7 +452,7 @@ void Search()
|
|||||||
else
|
else
|
||||||
copy.SetFile(copy.GetName());
|
copy.SetFile(copy.GetName());
|
||||||
|
|
||||||
if (search_match_to_pattern)
|
if (MatchToPattern)
|
||||||
{
|
{
|
||||||
if (!s.Any().empty())
|
if (!s.Any().empty())
|
||||||
any_found =
|
any_found =
|
||||||
@@ -521,7 +522,7 @@ void Search()
|
|||||||
if (found && any_found)
|
if (found && any_found)
|
||||||
{
|
{
|
||||||
Song *ss = Config.search_in_db ? *it : new Song(**it);
|
Song *ss = Config.search_in_db ? *it : new Song(**it);
|
||||||
mSearcher->AddOption(std::make_pair((Buffer *)0, ss));
|
w->AddOption(std::make_pair((Buffer *)0, ss));
|
||||||
list[it-list.begin()] = 0;
|
list[it-list.begin()] = 0;
|
||||||
}
|
}
|
||||||
found = 1;
|
found = 1;
|
||||||
|
|||||||
@@ -24,18 +24,10 @@
|
|||||||
#include "mpdpp.h"
|
#include "mpdpp.h"
|
||||||
#include "ncmpcpp.h"
|
#include "ncmpcpp.h"
|
||||||
|
|
||||||
namespace SearchEngine
|
class SearchEngine : public Screen < Menu< std::pair<Buffer *, MPD::Song *> > >
|
||||||
{
|
|
||||||
void Init();
|
|
||||||
void Resize();
|
|
||||||
void SwitchTo();
|
|
||||||
|
|
||||||
void EnterPressed();
|
|
||||||
void SpacePressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
class SearchPattern : public MPD::Song
|
|
||||||
{
|
{
|
||||||
|
class SearchPattern : public MPD::Song
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
const std::string &Any() { return itsAnyField; }
|
const std::string &Any() { return itsAnyField; }
|
||||||
const std::string &Any(const std::string &s) { itsAnyField = s; return itsAnyField; }
|
const std::string &Any(const std::string &s) { itsAnyField = s; return itsAnyField; }
|
||||||
@@ -45,15 +37,38 @@ class SearchPattern : public MPD::Song
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string itsAnyField;
|
std::string itsAnyField;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void Init();
|
||||||
|
virtual void Resize();
|
||||||
|
virtual void SwitchTo();
|
||||||
|
|
||||||
|
virtual std::string Title();
|
||||||
|
|
||||||
|
virtual void EnterPressed();
|
||||||
|
virtual void SpacePressed();
|
||||||
|
|
||||||
|
void UpdateFoundList();
|
||||||
|
|
||||||
|
static size_t StaticOptions;
|
||||||
|
static size_t SearchButton;
|
||||||
|
static size_t ResetButton;
|
||||||
|
|
||||||
|
static const char *NormalMode;
|
||||||
|
static const char *StrictMode;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Prepare();
|
||||||
|
void Search();
|
||||||
|
|
||||||
|
SearchPattern itsPattern;
|
||||||
|
|
||||||
|
static bool MatchToPattern;
|
||||||
|
static bool CaseSensitive;
|
||||||
};
|
};
|
||||||
|
|
||||||
const size_t search_engine_static_options = 20;
|
extern SearchEngine *mySearcher;
|
||||||
const size_t search_engine_search_button = 15;
|
|
||||||
const size_t search_engine_reset_button = 16;
|
|
||||||
|
|
||||||
void UpdateFoundList();
|
|
||||||
void PrepareSearchEngine();
|
|
||||||
void Search();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *)
|
|||||||
}
|
}
|
||||||
else if (current_screen == csSearcher)
|
else if (current_screen == csSearcher)
|
||||||
{
|
{
|
||||||
UpdateFoundList();
|
mySearcher->UpdateFoundList();
|
||||||
}
|
}
|
||||||
else if (current_screen == csLibrary)
|
else if (current_screen == csLibrary)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include "media_library.h"
|
#include "media_library.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "playlist_editor.h"
|
#include "playlist_editor.h"
|
||||||
|
#include "search_engine.h"
|
||||||
#include "status_checker.h"
|
#include "status_checker.h"
|
||||||
|
|
||||||
using namespace Global;
|
using namespace Global;
|
||||||
@@ -161,7 +162,7 @@ void TinyTagEditor::EnterPressed(Song &s)
|
|||||||
{
|
{
|
||||||
Mpd->UpdateDirectory(locale_to_utf_cpy(s.GetDirectory()));
|
Mpd->UpdateDirectory(locale_to_utf_cpy(s.GetDirectory()));
|
||||||
if (prev_screen == csSearcher)
|
if (prev_screen == csSearcher)
|
||||||
*mSearcher->Current().second = s;
|
*mySearcher->Main()->Current().second = s;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user