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(); }
void Browser::locateSong(const MPD::Song &s) { if (s.getDirectory().empty()) throw std::runtime_error("Song's directory is empty"); m_local_browser = !s.isFromDatabase(); if (myScreen != this) switchTo(); // change to relevant directory if (m_current_directory != s.getDirectory()) { getDirectory(s.getDirectory()); drawHeader(); } // highlight the item auto begin = w.beginV(), end = w.endV(); auto it = std::find(begin, end, MPD::Item(s)); if (it != end) w.highlight(it-begin); }