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