add allowsFiltering / allowsSearching checks
This commit is contained in:
@@ -346,6 +346,7 @@ void Action::FindItem(const FindDirection fd)
|
||||
|
||||
Searchable *w = dynamic_cast<Searchable *>(myScreen);
|
||||
assert(w);
|
||||
assert(w->allowsSearching());
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << "Find " << (fd == fdForward ? "forward" : "backward") << ": ";
|
||||
@@ -1997,7 +1998,8 @@ void ReversePlaylist::Run()
|
||||
|
||||
bool ApplyFilter::canBeRun() const
|
||||
{
|
||||
return dynamic_cast<Filterable *>(myScreen);
|
||||
auto w = dynamic_cast<Filterable *>(myScreen);
|
||||
return w && w->allowsFiltering();
|
||||
}
|
||||
|
||||
void ApplyFilter::Run()
|
||||
@@ -2007,6 +2009,7 @@ void ApplyFilter::Run()
|
||||
|
||||
Filterable *f = dynamic_cast<Filterable *>(myScreen);
|
||||
assert(f);
|
||||
assert(f->allowsFiltering());
|
||||
|
||||
LockStatusbar();
|
||||
Statusbar() << NC::fmtBold << "Apply filter: " << NC::fmtBoldEnd;
|
||||
@@ -2072,7 +2075,8 @@ void Find::Run()
|
||||
|
||||
bool FindItemBackward::canBeRun() const
|
||||
{
|
||||
return dynamic_cast<Searchable *>(myScreen);
|
||||
auto w = dynamic_cast<Searchable *>(myScreen);
|
||||
return w && w->allowsSearching();
|
||||
}
|
||||
|
||||
void FindItemForward::Run()
|
||||
@@ -2083,7 +2087,8 @@ void FindItemForward::Run()
|
||||
|
||||
bool FindItemForward::canBeRun() const
|
||||
{
|
||||
return dynamic_cast<Searchable *>(myScreen);
|
||||
auto w = dynamic_cast<Searchable *>(myScreen);
|
||||
return w && w->allowsSearching();
|
||||
}
|
||||
|
||||
void FindItemBackward::Run()
|
||||
|
||||
@@ -267,6 +267,11 @@ void Browser::MouseButtonPressed(MEVENT me)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool Browser::allowsFiltering()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Browser::currentFilter()
|
||||
{
|
||||
return RegexFilter<MPD::Item>::currentFilter(*w);
|
||||
@@ -282,6 +287,11 @@ void Browser::applyFilter(const std::string &filter)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool Browser::allowsSearching()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Browser::search(const std::string &constraint)
|
||||
{
|
||||
auto fun = std::bind(BrowserEntryMatcher, _1, _2, false);
|
||||
|
||||
@@ -41,10 +41,12 @@ class Browser : public Screen< NC::Menu<MPD::Item> >, public Filterable, public
|
||||
virtual bool isTabbable() { return true; }
|
||||
|
||||
/// Filterable implementation
|
||||
virtual bool allowsFiltering();
|
||||
virtual std::string currentFilter();
|
||||
virtual void applyFilter(const std::string &filter);
|
||||
|
||||
/// Searchable implementation
|
||||
virtual bool allowsSearching();
|
||||
virtual bool search(const std::string &constraint);
|
||||
virtual void nextFound(bool wrap);
|
||||
virtual void prevFound(bool wrap);
|
||||
|
||||
@@ -28,12 +28,14 @@
|
||||
|
||||
struct Filterable
|
||||
{
|
||||
virtual bool allowsFiltering() = 0;
|
||||
virtual std::string currentFilter() = 0;
|
||||
virtual void applyFilter(const std::string &filter) = 0;
|
||||
};
|
||||
|
||||
struct Searchable
|
||||
{
|
||||
virtual bool allowsSearching() = 0;
|
||||
virtual bool search(const std::string &constraint) = 0;
|
||||
virtual void nextFound(bool wrap) = 0;
|
||||
virtual void prevFound(bool wrap) = 0;
|
||||
|
||||
@@ -438,6 +438,11 @@ void MediaLibrary::MouseButtonPressed(MEVENT me)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool MediaLibrary::allowsFiltering()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string MediaLibrary::currentFilter()
|
||||
{
|
||||
std::string filter;
|
||||
@@ -475,6 +480,11 @@ void MediaLibrary::applyFilter(const std::string &filter)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool MediaLibrary::allowsSearching()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MediaLibrary::search(const std::string &constraint)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -41,10 +41,12 @@ class MediaLibrary : public Screen<NC::Window>, public Filterable, public HasSon
|
||||
virtual bool isTabbable() { return true; }
|
||||
|
||||
/// Filterable implementation
|
||||
virtual bool allowsFiltering();
|
||||
virtual std::string currentFilter();
|
||||
virtual void applyFilter(const std::string &filter);
|
||||
|
||||
/// Searchable implementation
|
||||
virtual bool allowsSearching();
|
||||
virtual bool search(const std::string &constraint);
|
||||
virtual void nextFound(bool wrap);
|
||||
virtual void prevFound(bool wrap);
|
||||
|
||||
@@ -272,6 +272,11 @@ void Playlist::MouseButtonPressed(MEVENT me)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool Playlist::allowsFiltering()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Playlist::currentFilter()
|
||||
{
|
||||
std::string filter;
|
||||
@@ -292,6 +297,11 @@ void Playlist::applyFilter(const std::string &filter)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool Playlist::allowsSearching()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Playlist::search(const std::string &constraint)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -44,10 +44,12 @@ class Playlist : public Screen<NC::Window>, public Filterable, public HasSongs,
|
||||
virtual bool isTabbable() { return true; }
|
||||
|
||||
/// Filterable implementation
|
||||
virtual bool allowsFiltering();
|
||||
virtual std::string currentFilter();
|
||||
virtual void applyFilter(const std::string &filter);
|
||||
|
||||
/// Searchable implementation
|
||||
virtual bool allowsSearching();
|
||||
virtual bool search(const std::string &constraint);
|
||||
virtual void nextFound(bool wrap);
|
||||
virtual void prevFound(bool wrap);
|
||||
|
||||
@@ -424,6 +424,11 @@ void PlaylistEditor::MouseButtonPressed(MEVENT me)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool PlaylistEditor::allowsFiltering()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string PlaylistEditor::currentFilter()
|
||||
{
|
||||
std::string filter;
|
||||
@@ -452,6 +457,11 @@ void PlaylistEditor::applyFilter(const std::string &filter)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool PlaylistEditor::allowsSearching()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PlaylistEditor::search(const std::string &constraint)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -40,10 +40,12 @@ class PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasS
|
||||
virtual bool isTabbable() { return true; }
|
||||
|
||||
/// Filterable implementation
|
||||
virtual bool allowsFiltering();
|
||||
virtual std::string currentFilter();
|
||||
virtual void applyFilter(const std::string &filter);
|
||||
|
||||
/// Searchable implementation
|
||||
virtual bool allowsSearching();
|
||||
virtual bool search(const std::string &constraint);
|
||||
virtual void nextFound(bool wrap);
|
||||
virtual void prevFound(bool wrap);
|
||||
|
||||
@@ -280,6 +280,11 @@ void SearchEngine::MouseButtonPressed(MEVENT me)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool SearchEngine::allowsFiltering()
|
||||
{
|
||||
return w->back().value().isSong();
|
||||
}
|
||||
|
||||
std::string SearchEngine::currentFilter()
|
||||
{
|
||||
return RegexItemFilter<SEItem>::currentFilter(*w);
|
||||
@@ -295,6 +300,11 @@ void SearchEngine::applyFilter(const std::string &filter)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool SearchEngine::allowsSearching()
|
||||
{
|
||||
return w->back().value().isSong();
|
||||
}
|
||||
|
||||
bool SearchEngine::search(const std::string &constraint)
|
||||
{
|
||||
auto fun = std::bind(SEItemEntryMatcher, _1, _2, false);
|
||||
|
||||
@@ -87,10 +87,12 @@ class SearchEngine : public Screen< NC::Menu<SEItem> >, public Filterable, publi
|
||||
virtual bool isTabbable() { return true; }
|
||||
|
||||
/// Filterable implementation
|
||||
virtual bool allowsFiltering();
|
||||
virtual std::string currentFilter();
|
||||
virtual void applyFilter(const std::string &filter);
|
||||
|
||||
/// Searchable implementation
|
||||
virtual bool allowsSearching();
|
||||
virtual bool search(const std::string &constraint);
|
||||
virtual void nextFound(bool wrap);
|
||||
virtual void prevFound(bool wrap);
|
||||
|
||||
@@ -773,6 +773,11 @@ void TagEditor::MouseButtonPressed(MEVENT me)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool TagEditor::allowsFiltering()
|
||||
{
|
||||
return w == LeftColumn || w == Tags;
|
||||
}
|
||||
|
||||
std::string TagEditor::currentFilter()
|
||||
{
|
||||
std::string filter;
|
||||
@@ -810,6 +815,11 @@ void TagEditor::applyFilter(const std::string &filter)
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
bool TagEditor::allowsSearching()
|
||||
{
|
||||
return w == LeftColumn || w == Tags;
|
||||
}
|
||||
|
||||
bool TagEditor::search(const std::string &constraint)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -52,10 +52,12 @@ class TagEditor : public Screen<NC::Window>, public Filterable, public HasSongs,
|
||||
virtual bool isTabbable() { return true; }
|
||||
|
||||
/// Filterable implementation
|
||||
virtual bool allowsFiltering();
|
||||
virtual std::string currentFilter();
|
||||
virtual void applyFilter(const std::string &filter);
|
||||
|
||||
/// Searchable implementation
|
||||
virtual bool allowsSearching();
|
||||
virtual bool search(const std::string &constraint);
|
||||
virtual void nextFound(bool wrap);
|
||||
virtual void prevFound(bool wrap);
|
||||
|
||||
Reference in New Issue
Block a user