playlist editor: make playlist deletion work
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -156,41 +156,45 @@ void PlaylistEditor::update()
|
||||
Playlists.refresh();
|
||||
}
|
||||
|
||||
if (!Playlists.empty()
|
||||
&& ((Content.reallyEmpty() && Global::Timer - m_timer > m_fetching_delay) || m_content_update_requested)
|
||||
)
|
||||
if ((Content.reallyEmpty() && Global::Timer - m_timer > m_fetching_delay)
|
||||
|| m_content_update_requested)
|
||||
{
|
||||
m_content_update_requested = false;
|
||||
Content.clearSearchResults();
|
||||
withUnfilteredMenuReapplyFilter(Content, [this]() {
|
||||
size_t idx = 0;
|
||||
Mpd.GetPlaylistContent(Playlists.current().value(), [this, &idx](MPD::Song s) {
|
||||
if (Playlists.empty())
|
||||
Content.clear();
|
||||
else
|
||||
{
|
||||
Content.clearSearchResults();
|
||||
withUnfilteredMenuReapplyFilter(Content, [this]() {
|
||||
size_t idx = 0;
|
||||
Mpd.GetPlaylistContent(Playlists.current().value(), [this, &idx](MPD::Song s) {
|
||||
if (idx < Content.size())
|
||||
{
|
||||
Content[idx].value() = s;
|
||||
Content[idx].setBold(myPlaylist->checkForSong(s));
|
||||
}
|
||||
else
|
||||
Content.addItem(s, myPlaylist->checkForSong(s));
|
||||
++idx;
|
||||
});
|
||||
if (idx < Content.size())
|
||||
Content.resizeList(idx);
|
||||
std::string title;
|
||||
if (Config.titles_visibility)
|
||||
{
|
||||
Content[idx].value() = s;
|
||||
Content[idx].setBold(myPlaylist->checkForSong(s));
|
||||
title = "Playlist content";
|
||||
title += " (";
|
||||
title += boost::lexical_cast<std::string>(Content.size());
|
||||
title += " item";
|
||||
if (Content.size() == 1)
|
||||
title += ")";
|
||||
else
|
||||
title += "s)";
|
||||
title.resize(Content.getWidth());
|
||||
}
|
||||
else
|
||||
Content.addItem(s, myPlaylist->checkForSong(s));
|
||||
++idx;
|
||||
Content.setTitle(title);
|
||||
});
|
||||
if (idx < Content.size())
|
||||
Content.resizeList(idx);
|
||||
std::string title;
|
||||
if (Config.titles_visibility)
|
||||
{
|
||||
title = "Playlist content";
|
||||
title += " (";
|
||||
title += boost::lexical_cast<std::string>(Content.size());
|
||||
title += " item";
|
||||
if (Content.size() == 1)
|
||||
title += ")";
|
||||
else
|
||||
title += "s)";
|
||||
title.resize(Content.getWidth());
|
||||
}
|
||||
Content.setTitle(title);
|
||||
});
|
||||
}
|
||||
Content.display();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user