From a1b08c5776dbc929809519e087e592c02505d3d4 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Mon, 16 Mar 2009 17:10:43 +0100 Subject: [PATCH] add ('a') items to currently selected playlist in playlist editor --- src/ncmpcpp.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 70830271..c13b345c 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -875,8 +875,10 @@ int main(int argc, char *argv[]) } else if (Keypressed(input, Key.Add)) { + if (myScreen == myPlaylistEditor && myPlaylistEditor->Playlists->Empty()) + continue; LockStatusbar(); - Statusbar() << "Add: "; + Statusbar() << (myScreen == myPlaylistEditor ? "Add to playlist: " : "Add: "); string path = wFooter->GetString(); UnlockStatusbar(); if (!path.empty()) @@ -887,12 +889,20 @@ int main(int argc, char *argv[]) { Mpd->StartCommandsList(); SongList::const_iterator it = list.begin(); - for (; it != list.end(); it++) - if (Mpd->AddSong(**it) < 0) - break; + if (myScreen == myPlaylistEditor) + { + 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(); - if (it != list.begin()) + if (it != list.begin() && myScreen != myPlaylistEditor) { Song &s = myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size()); if (s.GetHash() != list[0]->GetHash()) @@ -900,7 +910,18 @@ int main(int argc, char *argv[]) } } 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); } }