add ('a') items to currently selected playlist in playlist editor

This commit is contained in:
Andrzej Rybczak
2009-03-16 17:10:43 +01:00
parent 8a1223aa18
commit a1b08c5776

View File

@@ -875,8 +875,10 @@ int main(int argc, char *argv[])
} }
else if (Keypressed(input, Key.Add)) else if (Keypressed(input, Key.Add))
{ {
if (myScreen == myPlaylistEditor && myPlaylistEditor->Playlists->Empty())
continue;
LockStatusbar(); LockStatusbar();
Statusbar() << "Add: "; Statusbar() << (myScreen == myPlaylistEditor ? "Add to playlist: " : "Add: ");
string path = wFooter->GetString(); string path = wFooter->GetString();
UnlockStatusbar(); UnlockStatusbar();
if (!path.empty()) if (!path.empty())
@@ -887,12 +889,20 @@ int main(int argc, char *argv[])
{ {
Mpd->StartCommandsList(); Mpd->StartCommandsList();
SongList::const_iterator it = list.begin(); SongList::const_iterator it = list.begin();
for (; it != list.end(); it++) if (myScreen == myPlaylistEditor)
if (Mpd->AddSong(**it) < 0) {
break; for (; it != list.end(); it++)
Mpd->AddToPlaylist(myPlaylistEditor->Playlists->Current(), **it);
}
else
{
for (; it != list.end(); it++)
if (Mpd->AddSong(**it) < 0)
break;
}
Mpd->CommitCommandsList(); Mpd->CommitCommandsList();
if (it != list.begin()) if (it != list.begin() && myScreen != myPlaylistEditor)
{ {
Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size()); Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());
if (s.GetHash() != list[0]->GetHash()) if (s.GetHash() != list[0]->GetHash())
@@ -900,7 +910,18 @@ int main(int argc, char *argv[])
} }
} }
else else
Mpd->AddSong(path); {
if (myScreen == myPlaylistEditor)
{
Mpd->AddToPlaylist(myPlaylistEditor->Playlists->Current(), path);
}
else
{
Mpd->AddSong(path);
}
}
if (myScreen == myPlaylistEditor)
myPlaylistEditor->Content->Clear(0); // make it refetch content of playlist
FreeSongList(list); FreeSongList(list);
} }
} }