key_select_album also works in search results now

This commit is contained in:
Frank Blendinger
2010-07-03 23:21:21 +02:00
committed by Andrzej Rybczak
parent 7600429383
commit 13dbf65350
3 changed files with 33 additions and 0 deletions

View File

@@ -1703,6 +1703,8 @@ int main(int argc, char *argv[])
songs = myPlaylist->Items;
else if (myScreen->ActiveWindow() == myPlaylistEditor->Content)
songs = myPlaylistEditor->Content;
else if (myScreen == mySearcher)
mySearcher->SelectAlbum();
if (songs && !songs->Empty())
{

View File

@@ -337,6 +337,36 @@ void SearchEngine::Scroll(int input)
}
}
void SearchEngine::SelectAlbum()
{
size_t pos = w->Choice();
if (pos < StaticOptions)
return; // not on a song
std::string album = w->at(pos).second->GetAlbum();
// select song under cursor
w->Select(pos, 1);
// go up
while (pos > StaticOptions)
{
if (w->at(--pos).second->GetAlbum() != album)
break;
else
w->Select(pos, 1);
}
// go down
while (pos < w->Size() - 1)
{
if (w->at(++pos).second->GetAlbum() != album)
break;
else
w->Select(pos, 1);
}
}
void SearchEngine::Prepare()
{
for (size_t i = 0; i < w->Size(); ++i)

View File

@@ -49,6 +49,7 @@ class SearchEngine : public Screen< Menu< std::pair<Buffer *, MPD::Song *> > >
void UpdateFoundList();
void Scroll(int);
void SelectAlbum();
static size_t StaticOptions;
static size_t SearchButton;