playlist editor: make playlist deletion work

This commit is contained in:
Andrzej Rybczak
2014-10-04 17:17:23 +02:00
parent 9418451a31
commit af3a666915
2 changed files with 36 additions and 33 deletions

View File

@@ -724,12 +724,13 @@ void DeleteBrowserItems::run()
bool DeleteStoredPlaylist::canBeRun() const
{
return myScreen->isActiveWindow(myPlaylistEditor->Playlists)
&& myPlaylistEditor->Playlists.empty();
return myScreen->isActiveWindow(myPlaylistEditor->Playlists);
}
void DeleteStoredPlaylist::run()
{
if (myPlaylistEditor->Playlists.empty())
return;
boost::format question;
if (hasSelected(myPlaylistEditor->Playlists.begin(), myPlaylistEditor->Playlists.end()))
question = boost::format("Delete selected playlists?");
@@ -740,10 +741,8 @@ void DeleteStoredPlaylist::run()
if (yes)
{
auto list = getSelectedOrCurrent(myPlaylistEditor->Playlists.begin(), myPlaylistEditor->Playlists.end(), myPlaylistEditor->Playlists.currentI());
Mpd.StartCommandsList();
for (auto it = list.begin(); it != list.end(); ++it)
Mpd.DeletePlaylist((*it)->value());
Mpd.CommitCommandsList();
Statusbar::printf("%1% deleted", list.size() == 1 ? "Playlist" : "Playlists");
}
else