make feature 'select songs of album around cursor' work in all screens

This commit is contained in:
Andrzej Rybczak
2010-07-12 09:15:50 +02:00
parent d962653c76
commit 883d1a6cdd

View File

@@ -1706,34 +1706,30 @@ int main(int argc, char *argv[])
{ {
if (myScreen->allowsSelection()) if (myScreen->allowsSelection())
{ {
Menu<MPD::Song> *songs = NULL; if (List *mList = myScreen->GetList())
if (myScreen == myPlaylist && !myPlaylist->Items->Empty())
songs = myPlaylist->Items;
else if (myScreen->ActiveWindow() == myPlaylistEditor->Content)
songs = myPlaylistEditor->Content;
else if (myScreen == mySearcher)
mySearcher->SelectAlbum();
if (songs && !songs->Empty())
{ {
size_t pos = songs->Choice(); size_t pos = mList->Choice();
std::string album = songs->at(pos).GetAlbum(); if (MPD::Song *s = myScreen->GetSong(pos))
List *mList = myScreen->GetList(); {
std::string album = s->GetAlbum();
// select song under cursor // select song under cursor
mList->Select(pos, 1); mList->Select(pos, 1);
// go up // go up
while (pos > 0) while (pos > 0)
{ {
if (songs->at(--pos).GetAlbum() != album) s = myScreen->GetSong(--pos);
if (!s || s->GetAlbum() != album)
break; break;
else else
mList->Select(pos, 1); mList->Select(pos, 1);
} }
// go down // go down
pos = songs->Choice(); pos = mList->Choice();
while (pos < songs->Size() - 1) while (pos < mList->Size() - 1)
{ {
if (songs->at(++pos).GetAlbum() != album) s = myScreen->GetSong(++pos);
if (!s || s->GetAlbum() != album)
break; break;
else else
mList->Select(pos, 1); mList->Select(pos, 1);
@@ -1742,6 +1738,7 @@ int main(int argc, char *argv[])
} }
} }
} }
}
else if (Keypressed(input, Key.AddSelected)) else if (Keypressed(input, Key.AddSelected))
{ {
mySelectedItemsAdder->SwitchTo(); mySelectedItemsAdder->SwitchTo();