Exemplo n.º 1
0
void Browser::LocateSong(const MPD::Song &s)
{
	if (s.getDirectory().empty())
		return;
	
	itsBrowseLocally = !s.isFromDatabase();
	
	if (myScreen != this)
		switchTo();
	
	if (itsBrowsedDir != s.getDirectory())
		GetDirectory(s.getDirectory());
	for (size_t i = 0; i < w.size(); ++i)
	{
		if (w[i].value().type == itSong && s.getHash() == w[i].value().song->getHash())
		{
			w.highlight(i);
			break;
		}
	}
	drawHeader();
}
Exemplo n.º 2
0
void MediaLibrary::LocateSong(const MPD::Song &s)
{
	std::string primary_tag = s.get(Config.media_lib_primary_tag);
	if (primary_tag.empty())
	{
		std::string item_type = boost::locale::to_lower(
			tagTypeToString(Config.media_lib_primary_tag));
		Statusbar::msg("Can't use this function because the song has no %s tag set", item_type.c_str());
		return;
	}
	
	if (myScreen != this)
		switchTo();
	Statusbar::put() << "Jumping to song...";
	Global::wFooter->refresh();
	
	if (!hasTwoColumns)
	{
		Tags.showAll();
		if (Tags.empty())
			update();
		if (primary_tag != Tags.current().value().tag())
		{
			for (size_t i = 0; i < Tags.size(); ++i)
			{
				if (primary_tag == Tags[i].value().tag())
				{
					Tags.highlight(i);
					Albums.clear();
					Songs.clear();
					break;
				}
			}
		}
	}
	
	Albums.showAll();
	if (Albums.empty())
		update();
	
	std::string album = s.getAlbum();
	std::string date = s.getDate();
	if ((hasTwoColumns && Albums.current().value().entry().tag() != primary_tag)
	||  album != Albums.current().value().entry().album()
	||  date != Albums.current().value().entry().date())
	{
		for (size_t i = 0; i < Albums.size(); ++i)
		{
			if ((!hasTwoColumns || Albums[i].value().entry().tag() == primary_tag)
			&&   album == Albums[i].value().entry().album()
			&&   date == Albums[i].value().entry().date())
			{
				Albums.highlight(i);
				Songs.clear();
				break;
			}
		}
	}
	
	Songs.showAll();
	if (Songs.empty())
		update();
	
	if (s.getHash() != Songs.current().value().getHash())
	{
		for (size_t i = 0; i < Songs.size(); ++i)
		{
			if (s.getHash()  == Songs[i].value().getHash())
			{
				Songs.highlight(i);
				break;
			}
		}
	}
	
	Tags.setHighlightColor(Config.main_highlight_color);
	Albums.setHighlightColor(Config.main_highlight_color);
	Songs.setHighlightColor(Config.active_column_color);
	w = &Songs;
	refresh();
}