playlist editor: disallow cropping/clearing filtered playlists
This commit is contained in:
@@ -1814,6 +1814,8 @@ void AddSelectedItems::Run()
|
||||
|
||||
void CropMainPlaylist::Run()
|
||||
{
|
||||
if (myPlaylist->isFiltered())
|
||||
return;
|
||||
bool yes = true;
|
||||
if (Config.ask_before_clearing_main_playlist)
|
||||
yes = AskYesNoQuestion("Do you really want to crop main playlist?", TraceMpdStatus);
|
||||
@@ -1848,9 +1850,8 @@ bool CropPlaylist::canBeRun() const
|
||||
|
||||
void CropPlaylist::Run()
|
||||
{
|
||||
if (myPlaylistEditor->Playlists->Empty())
|
||||
if (myPlaylistEditor->Playlists->Empty() || myPlaylistEditor->isContentFiltered())
|
||||
return;
|
||||
|
||||
bool yes = true;
|
||||
if (Config.ask_before_clearing_main_playlist)
|
||||
yes = AskYesNoQuestion("Do you really want to crop playlist \"" + myPlaylistEditor->Playlists->Current() + "\"?", TraceMpdStatus);
|
||||
@@ -1909,29 +1910,17 @@ bool ClearPlaylist::canBeRun() const
|
||||
|
||||
void ClearPlaylist::Run()
|
||||
{
|
||||
if (myPlaylistEditor->Playlists->Empty())
|
||||
if (myPlaylistEditor->Playlists->Empty() || myPlaylistEditor->isContentFiltered())
|
||||
return;
|
||||
// OMGPLZ
|
||||
bool yes = true;
|
||||
if (Config.ask_before_clearing_main_playlist)
|
||||
yes = AskYesNoQuestion("Do you really want to clear playlist \"" + myPlaylistEditor->Playlists->Current() + "\"?", TraceMpdStatus);
|
||||
if (yes)
|
||||
{
|
||||
if (myPlaylistEditor->Content->isFiltered())
|
||||
{
|
||||
std::string playlist = locale_to_utf_cpy(myPlaylistEditor->Playlists->Current());
|
||||
ShowMessage("Deleting filtered items from playlist \"%s\"...", myPlaylistEditor->Playlists->Current().c_str());
|
||||
Mpd.StartCommandsList();
|
||||
for (int i = myPlaylistEditor->Content->Size()-1; i >= 0; --i)
|
||||
Mpd.Delete(playlist, (*myPlaylistEditor->Content)[i].GetPosition());
|
||||
if (Mpd.CommitCommandsList())
|
||||
ShowMessage("Filtered items deleted from playlist \"%s\"", myPlaylistEditor->Playlists->Current().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Clearing playlist...");
|
||||
Mpd.ClearPlaylist(locale_to_utf_cpy(myPlaylistEditor->Playlists->Current()));
|
||||
}
|
||||
|
||||
ShowMessage("Clearing playlist \"%s\"...", myPlaylistEditor->Playlists->Current().c_str());
|
||||
if (Mpd.ClearPlaylist(locale_to_utf_cpy(myPlaylistEditor->Playlists->Current())))
|
||||
ShowMessage("Playlist \"%s\" cleared", myPlaylistEditor->Playlists->Current().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ void Help::GetKeybindings()
|
||||
KeyDesc(aPressEnter, "Play selected item");
|
||||
KeyDesc(aDelete, "Delete selected item(s) from playlist");
|
||||
KeyDesc(aClearMainPlaylist, "Clear playlist");
|
||||
KeyDesc(aCropMainPlaylist, "Clear playlist except playing/selected items");
|
||||
KeyDesc(aCropMainPlaylist, "Clear playlist except selected item(s)");
|
||||
KeyDesc(aSetSelectedItemsPriority, "Set priority of selected items");
|
||||
KeyDesc(aMoveSelectedItemsUp, "Move selected item(s) up");
|
||||
KeyDesc(aMoveSelectedItemsDown, "Move selected item(s) down");
|
||||
|
||||
@@ -551,18 +551,18 @@ bool MPD::Connection::ClearPlaylist()
|
||||
}
|
||||
}
|
||||
|
||||
void MPD::Connection::ClearPlaylist(const std::string &playlist)
|
||||
bool MPD::Connection::ClearPlaylist(const std::string &playlist)
|
||||
{
|
||||
if (!itsConnection)
|
||||
return;
|
||||
return false;
|
||||
if (!isCommandsListEnabled)
|
||||
{
|
||||
GoBusy();
|
||||
mpd_run_playlist_clear(itsConnection, playlist.c_str());
|
||||
return mpd_run_playlist_clear(itsConnection, playlist.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
mpd_send_playlist_clear(itsConnection, playlist.c_str());
|
||||
return mpd_send_playlist_clear(itsConnection, playlist.c_str());
|
||||
assert(!isIdle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace MPD
|
||||
bool DeletePlaylist(const std::string &);
|
||||
bool LoadPlaylist(const std::string &name);
|
||||
int SavePlaylist(const std::string &);
|
||||
void ClearPlaylist(const std::string &);
|
||||
bool ClearPlaylist(const std::string &);
|
||||
void AddToPlaylist(const std::string &, const Song &);
|
||||
void AddToPlaylist(const std::string &, const std::string &);
|
||||
bool Move(const std::string &, int, int);
|
||||
|
||||
@@ -273,6 +273,17 @@ void PlaylistEditor::MoveSelectedItems(Playlist::Movement where)
|
||||
}
|
||||
}
|
||||
|
||||
bool PlaylistEditor::isContentFiltered()
|
||||
{
|
||||
if (Content->isFiltered())
|
||||
{
|
||||
ShowMessage("Function currently unavailable due to filtered playlist content");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool PlaylistEditor::isNextColumnAvailable()
|
||||
{
|
||||
if (w == Playlists)
|
||||
|
||||
@@ -57,6 +57,7 @@ class PlaylistEditor : public Screen<Window>
|
||||
|
||||
void MoveSelectedItems(Playlist::Movement where);
|
||||
|
||||
bool isContentFiltered();
|
||||
bool isNextColumnAvailable();
|
||||
bool NextColumn();
|
||||
bool isPrevColumnAvailable();
|
||||
|
||||
Reference in New Issue
Block a user