fix searching

This commit is contained in:
Andrzej Rybczak
2009-02-01 22:23:04 +01:00
parent 6e2a6dfd27
commit 1a6e0be0c1

View File

@@ -136,22 +136,30 @@ void Search(Song &s)
if (!search_case_sensitive) if (!search_case_sensitive)
{ {
string t; string t;
t = s.GetFile(); t = s.GetArtist();
ToLower(t); ToLower(t);
s.SetFile(t); s.SetArtist(t);
t = s.GetTitle(); t = s.GetTitle();
ToLower(t); ToLower(t);
s.SetTitle(t); s.SetTitle(t);
t = s.GetArtist();
ToLower(t);
s.SetArtist(t);
t = s.GetAlbum(); t = s.GetAlbum();
ToLower(t); ToLower(t);
s.SetAlbum(t); s.SetAlbum(t);
t = s.GetFile();
ToLower(t);
s.SetFile(t);
t = s.GetComposer();
ToLower(t);
s.SetComposer(t);
t = s.GetPerformer();
ToLower(t);
s.SetPerformer(t);
t = s.GetGenre(); t = s.GetGenre();
ToLower(t); ToLower(t);
s.SetGenre(t); s.SetGenre(t);
@@ -168,22 +176,30 @@ void Search(Song &s)
if (!search_case_sensitive) if (!search_case_sensitive)
{ {
string t; string t;
t = copy.GetName(); t = copy.GetArtist();
ToLower(t); ToLower(t);
copy.SetFile(t); copy.SetArtist(t);
t = copy.GetTitle(); t = copy.GetTitle();
ToLower(t); ToLower(t);
copy.SetTitle(t); copy.SetTitle(t);
t = copy.GetArtist();
ToLower(t);
copy.SetArtist(t);
t = copy.GetAlbum(); t = copy.GetAlbum();
ToLower(t); ToLower(t);
copy.SetAlbum(t); copy.SetAlbum(t);
t = copy.GetName();
ToLower(t);
copy.SetFile(t);
t = copy.GetComposer();
ToLower(t);
copy.SetComposer(t);
t = copy.GetPerformer();
ToLower(t);
copy.SetPerformer(t);
t = copy.GetGenre(); t = copy.GetGenre();
ToLower(t); ToLower(t);
copy.SetGenre(t); copy.SetGenre(t);
@@ -197,39 +213,43 @@ void Search(Song &s)
if (search_match_to_pattern) if (search_match_to_pattern)
{ {
if (found && !s.GetFile().empty())
found = copy.GetFile().find(s.GetFile()) != string::npos;
if (found && !s.GetTitle().empty())
found = copy.GetTitle().find(s.GetTitle()) != string::npos;
if (found && !s.GetArtist().empty()) if (found && !s.GetArtist().empty())
found = copy.GetArtist().find(s.GetArtist()) != string::npos; found = copy.GetArtist().find(s.GetArtist()) != string::npos;
if (found && !s.GetTitle().empty())
found = copy.GetTitle().find(s.GetTitle()) != string::npos;
if (found && !s.GetAlbum().empty()) if (found && !s.GetAlbum().empty())
found = copy.GetAlbum().find(s.GetAlbum()) != string::npos; found = copy.GetAlbum().find(s.GetAlbum()) != string::npos;
if (found && !s.GetYear().empty()) if (found && !s.GetFile().empty())
found = StrToInt(copy.GetYear()) == StrToInt(s.GetYear()) && StrToInt(s.GetYear()); found = copy.GetFile().find(s.GetFile()) != string::npos;
if (found && !s.GetTrack().empty()) if (found && !s.GetComposer().empty())
found = StrToInt(copy.GetTrack()) == StrToInt(s.GetTrack()) && StrToInt(s.GetTrack()); found = copy.GetComposer().find(s.GetComposer()) != string::npos;
if (found && !s.GetPerformer().empty())
found = copy.GetPerformer().find(s.GetPerformer()) != string::npos;
if (found && !s.GetGenre().empty()) if (found && !s.GetGenre().empty())
found = copy.GetGenre().find(s.GetGenre()) != string::npos; found = copy.GetGenre().find(s.GetGenre()) != string::npos;
if (found && !s.GetYear().empty())
found = StrToInt(copy.GetYear()) == StrToInt(s.GetYear()) && StrToInt(s.GetYear());
if (found && !s.GetComment().empty()) if (found && !s.GetComment().empty())
found = copy.GetComment().find(s.GetComment()) != string::npos; found = copy.GetComment().find(s.GetComment()) != string::npos;
} }
else else
{ {
if (found && !s.GetFile().empty())
found = copy.GetFile() == s.GetFile();
if (found && !s.GetTitle().empty())
found = copy.GetTitle() == s.GetTitle();
if (found && !s.GetArtist().empty()) if (found && !s.GetArtist().empty())
found = copy.GetArtist() == s.GetArtist(); found = copy.GetArtist() == s.GetArtist();
if (found && !s.GetTitle().empty())
found = copy.GetTitle() == s.GetTitle();
if (found && !s.GetAlbum().empty()) if (found && !s.GetAlbum().empty())
found = copy.GetAlbum() == s.GetAlbum(); found = copy.GetAlbum() == s.GetAlbum();
if (found && !s.GetYear().empty()) if (found && !s.GetFile().empty())
found = StrToInt(copy.GetYear()) == StrToInt(s.GetYear()) && StrToInt(s.GetYear()); found = copy.GetFile() == s.GetFile();
if (found && !s.GetTrack().empty()) if (found && !s.GetComposer().empty())
found = StrToInt(copy.GetTrack()) == StrToInt(s.GetTrack()) && StrToInt(s.GetTrack()); found = copy.GetComposer() == s.GetComposer();
if (found && !s.GetPerformer().empty())
found = copy.GetPerformer() == s.GetPerformer();
if (found && !s.GetGenre().empty()) if (found && !s.GetGenre().empty())
found = copy.GetGenre() == s.GetGenre(); found = copy.GetGenre() == s.GetGenre();
if (found && !s.GetYear().empty())
found = StrToInt(copy.GetYear()) == StrToInt(s.GetYear()) && StrToInt(s.GetYear());
if (found && !s.GetComment().empty()) if (found && !s.GetComment().empty())
found = copy.GetComment() == s.GetComment(); found = copy.GetComment() == s.GetComment();
} }