fixes for locating song in media library in two columns mode

This commit is contained in:
Andrzej Rybczak
2009-12-17 19:25:15 +01:00
parent a5882ee27f
commit a0c5298372

View File

@@ -566,7 +566,7 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
ShowMessage("Invalid tag type in left column of the media library");
return;
}
if (primary_tag == "")
if (primary_tag.empty())
{
std::string item_type = IntoStr(Config.media_lib_primary_tag);
ToLower(item_type);
@@ -579,12 +579,15 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
Statusbar() << "Jumping to song...";
wFooter->Refresh();
if (Artists->Empty() || primary_tag != Artists->Current())
if (!hasTwoColumns)
{
if (Artists->Empty())
Update();
if (primary_tag != Artists->Current())
{
for (size_t i = 0; i < Artists->Size(); ++i)
{
if (primary_tag == Artists->at(i))
if (primary_tag == (*Artists)[i])
{
Artists->Highlight(i);
Albums->Clear();
@@ -592,16 +595,22 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
}
}
}
}
if (Albums->Empty())
Update();
std::string album = s.GetAlbum();
std::string date = s.GetDate();
if (Albums->Empty() || (album != Albums->Current().second.Album
&& date != Albums->Current().second.Year))
if ((hasTwoColumns && Albums->Current().second.Artist != primary_tag)
|| album != Albums->Current().second.Album
|| date != Albums->Current().second.Year)
{
Update();
for (size_t i = 0; i < Albums->Size(); ++i)
{
if (album == Albums->at(i).second.Album && date == Albums->at(i).second.Year)
if ((!hasTwoColumns || (*Albums)[i].second.Artist == primary_tag)
&& album == (*Albums)[i].second.Album
&& date == (*Albums)[i].second.Year)
{
Albums->Highlight(i);
Songs->Clear();
@@ -610,13 +619,15 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
}
}
std::string song = s.GetTitle();
if (Songs->Empty() || song != Songs->Current().GetTitle())
{
if (Songs->Empty())
Update();
std::string song = s.GetTitle();
if (song != Songs->Current().GetTitle())
{
for (size_t i = 0; i < Songs->Size(); ++i)
{
if (song == Songs->at(i).GetTitle())
if (song == (*Songs)[i].GetTitle())
{
Songs->Highlight(i);
break;