actions: implement filtering playlist on priorities
This commit is contained in:
@@ -2204,9 +2204,9 @@ void SetSelectedItemsPriority::Run()
|
|||||||
Statusbar() << "Set priority [0-255]: ";
|
Statusbar() << "Set priority [0-255]: ";
|
||||||
std::string strprio = wFooter->getString();
|
std::string strprio = wFooter->getString();
|
||||||
UnlockStatusbar();
|
UnlockStatusbar();
|
||||||
if (!isInteger(strprio.c_str()))
|
if (!isInteger(strprio.c_str(), true))
|
||||||
return;
|
return;
|
||||||
int prio = atoi(strprio.c_str());
|
int prio = stringToInt(strprio);
|
||||||
if (prio < 0 || prio > 255)
|
if (prio < 0 || prio > 255)
|
||||||
{
|
{
|
||||||
ShowMessage("Number is out of range");
|
ShowMessage("Number is out of range");
|
||||||
@@ -2215,6 +2215,29 @@ void SetSelectedItemsPriority::Run()
|
|||||||
myPlaylist->SetSelectedItemsPriority(prio);
|
myPlaylist->SetSelectedItemsPriority(prio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FilterPlaylistOnPriorities::canBeRun() const
|
||||||
|
{
|
||||||
|
return myScreen->ActiveWindow() == myPlaylist->Items;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FilterPlaylistOnPriorities::Run()
|
||||||
|
{
|
||||||
|
using Global::wFooter;
|
||||||
|
|
||||||
|
LockStatusbar();
|
||||||
|
Statusbar() << "Show songs with priority higher than: ";
|
||||||
|
std::string strprio = wFooter->getString();
|
||||||
|
UnlockStatusbar();
|
||||||
|
if (!isInteger(strprio.c_str(), false))
|
||||||
|
return;
|
||||||
|
unsigned prio = stringToInt(strprio);
|
||||||
|
myPlaylist->Items->filter(myPlaylist->Items->begin(), myPlaylist->Items->end(),
|
||||||
|
[prio](const NC::Menu<MPD::Song>::Item &s) {
|
||||||
|
return s.value().getPrio() > prio;
|
||||||
|
});
|
||||||
|
ShowMessage("Playlist filtered (songs with priority higher than %u)", prio);
|
||||||
|
}
|
||||||
|
|
||||||
void ShowSongInfo::Run()
|
void ShowSongInfo::Run()
|
||||||
{
|
{
|
||||||
mySongInfo->SwitchTo();
|
mySongInfo->SwitchTo();
|
||||||
@@ -2578,6 +2601,7 @@ void populateActions()
|
|||||||
insertAction(new RefetchLyrics());
|
insertAction(new RefetchLyrics());
|
||||||
insertAction(new RefetchArtistInfo());
|
insertAction(new RefetchArtistInfo());
|
||||||
insertAction(new SetSelectedItemsPriority());
|
insertAction(new SetSelectedItemsPriority());
|
||||||
|
insertAction(new FilterPlaylistOnPriorities());
|
||||||
insertAction(new ShowSongInfo());
|
insertAction(new ShowSongInfo());
|
||||||
insertAction(new ShowArtistInfo());
|
insertAction(new ShowArtistInfo());
|
||||||
insertAction(new ShowLyrics());
|
insertAction(new ShowLyrics());
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ enum ActionType
|
|||||||
aApplyFilter, aFind, aFindItemForward, aFindItemBackward, aNextFoundItem,
|
aApplyFilter, aFind, aFindItemForward, aFindItemBackward, aNextFoundItem,
|
||||||
aPreviousFoundItem, aToggleFindMode, aToggleReplayGainMode, aToggleSpaceMode, aToggleAddMode,
|
aPreviousFoundItem, aToggleFindMode, aToggleReplayGainMode, aToggleSpaceMode, aToggleAddMode,
|
||||||
aToggleMouse, aToggleBitrateVisibility, aAddRandomItems, aToggleBrowserSortMode, aToggleLibraryTagType,
|
aToggleMouse, aToggleBitrateVisibility, aAddRandomItems, aToggleBrowserSortMode, aToggleLibraryTagType,
|
||||||
aRefetchLyrics, aRefetchArtistInfo, aSetSelectedItemsPriority, aShowSongInfo, aShowArtistInfo,
|
aRefetchLyrics, aRefetchArtistInfo, aSetSelectedItemsPriority, aFilterPlaylistOnPriorities,
|
||||||
|
aShowSongInfo, aShowArtistInfo,
|
||||||
aShowLyrics, aQuit, aNextScreen, aPreviousScreen, aShowHelp, aShowPlaylist, aShowBrowser,
|
aShowLyrics, aQuit, aNextScreen, aPreviousScreen, aShowHelp, aShowPlaylist, aShowBrowser,
|
||||||
aShowSearchEngine, aShowMediaLibrary, aShowPlaylistEditor, aShowTagEditor, aShowOutputs,
|
aShowSearchEngine, aShowMediaLibrary, aShowPlaylistEditor, aShowTagEditor, aShowOutputs,
|
||||||
aShowVisualizer, aShowClock, aShowServerInfo
|
aShowVisualizer, aShowClock, aShowServerInfo
|
||||||
@@ -915,6 +916,16 @@ protected:
|
|||||||
virtual void Run();
|
virtual void Run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FilterPlaylistOnPriorities : public Action
|
||||||
|
{
|
||||||
|
FilterPlaylistOnPriorities()
|
||||||
|
: Action(aFilterPlaylistOnPriorities, "filter_playlist_on_priorities") { }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool canBeRun() const;
|
||||||
|
virtual void Run();
|
||||||
|
};
|
||||||
|
|
||||||
struct ShowSongInfo : public Action
|
struct ShowSongInfo : public Action
|
||||||
{
|
{
|
||||||
ShowSongInfo() : Action(aShowSongInfo, "show_song_info") { }
|
ShowSongInfo() : Action(aShowSongInfo, "show_song_info") { }
|
||||||
|
|||||||
@@ -493,7 +493,6 @@ void BindingsConfiguration::generateDefaults()
|
|||||||
if (notBound(k = stringToKey("q")))
|
if (notBound(k = stringToKey("q")))
|
||||||
bind(k, aQuit);
|
bind(k, aQuit);
|
||||||
|
|
||||||
|
|
||||||
if (notBound(k = stringToKey("-")))
|
if (notBound(k = stringToKey("-")))
|
||||||
bind(k, aVolumeDown);
|
bind(k, aVolumeDown);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ void Help::GetKeybindings()
|
|||||||
KeyDesc(aSavePlaylist, "Save playlist");
|
KeyDesc(aSavePlaylist, "Save playlist");
|
||||||
KeyDesc(aSortPlaylist, "Sort playlist");
|
KeyDesc(aSortPlaylist, "Sort playlist");
|
||||||
KeyDesc(aReversePlaylist, "Reverse playlist");
|
KeyDesc(aReversePlaylist, "Reverse playlist");
|
||||||
|
KeyDesc(aFilterPlaylistOnPriorities, "Filter playlist on priorities");
|
||||||
KeyDesc(aJumpToPlayingSong, "Jump to playing song");
|
KeyDesc(aJumpToPlayingSong, "Jump to playing song");
|
||||||
KeyDesc(aTogglePlayingSongCentering, "Toggle playing song centering");
|
KeyDesc(aTogglePlayingSongCentering, "Toggle playing song centering");
|
||||||
|
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ long stringToLongInt(const std::string &s)
|
|||||||
return atol(s.c_str());
|
return atol(s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInteger(const char *s)
|
bool isInteger(const char *s, bool accept_signed)
|
||||||
{
|
{
|
||||||
assert(s);
|
assert(s);
|
||||||
if (*s == '\0')
|
if (*s == '\0')
|
||||||
return false;
|
return false;
|
||||||
for (const char *it = s; *it != '\0'; ++it)
|
for (const char *it = s; *it != '\0'; ++it)
|
||||||
if (!isdigit(*it) && (it != s || *it != '-'))
|
if (!(isdigit(*it) || (accept_signed && it == s && *it == '-')))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ template <size_t N> struct print<N, std::wstring> {
|
|||||||
|
|
||||||
int stringToInt(const std::string &s);
|
int stringToInt(const std::string &s);
|
||||||
long stringToLongInt(const std::string &s);
|
long stringToLongInt(const std::string &s);
|
||||||
bool isInteger(const char *s);
|
bool isInteger(const char *s, bool accept_signed);
|
||||||
|
|
||||||
std::string ToString(const std::wstring &ws);
|
std::string ToString(const std::wstring &ws);
|
||||||
std::wstring ToWString(const std::string &s);
|
std::wstring ToWString(const std::string &s);
|
||||||
|
|||||||
Reference in New Issue
Block a user