menu: generalize filtering, introduce interfaces

This commit is contained in:
Andrzej Rybczak
2012-08-31 23:09:56 +02:00
parent f1625c920a
commit 4c944085d6
25 changed files with 516 additions and 142 deletions

View File

@@ -1991,7 +1991,7 @@ void ReversePlaylist::Run()
bool ApplyFilter::canBeRun() const
{
return myScreen->GetList();
return dynamic_cast<Filterable *>(myScreen);
}
void ApplyFilter::Run()
@@ -1999,20 +1999,21 @@ void ApplyFilter::Run()
using Global::RedrawHeader;
using Global::wFooter;
List *mList = myScreen->GetList();
assert(mList);
Filterable *f = dynamic_cast<Filterable *>(myScreen);
assert(f);
LockStatusbar();
Statusbar() << fmtBold << "Apply filter: " << fmtBoldEnd;
wFooter->SetGetStringHelper(StatusbarApplyFilterImmediately);
wFooter->GetString(mList->GetFilter());
wFooter->SetGetStringHelper(std::bind(StatusbarApplyFilterImmediately, f, _1));
wFooter->GetString(f->currentFilter());
wFooter->SetGetStringHelper(StatusbarGetStringHelper);
UnlockStatusbar();
if (mList->isFiltered())
ShowMessage("Using filter \"%s\"", mList->GetFilter().c_str());
else
std::string filter = f->currentFilter();
if (filter.empty())
ShowMessage("Filtering disabled");
else
ShowMessage("Using filter \"%s\"", filter.c_str());
if (myScreen == myPlaylist)
{