actions: define DisableFilter in terms of ApplyFilter

This commit is contained in:
Andrzej Rybczak
2012-08-25 20:41:17 +02:00
parent 08adcbfdc8
commit b299806a90
2 changed files with 13 additions and 16 deletions

View File

@@ -1972,14 +1972,18 @@ void ReversePlaylist::Run()
myPlaylist->Reverse();
}
bool ApplyFilter::canBeRun() const
{
return myScreen->GetList();
}
void ApplyFilter::Run()
{
using Global::RedrawHeader;
using Global::wFooter;
List *mList = myScreen->GetList();
if (!mList)
return;
assert(mList);
LockStatusbar();
Statusbar() << fmtBold << "Apply filter: " << fmtBoldEnd;
@@ -2004,24 +2008,16 @@ void ApplyFilter::Run()
void DisableFilter::Run()
{
using Global::RedrawHeader;
using Global::wFooter;
List *mList = myScreen->GetList();
if (!mList)
return;
mList->ApplyFilter("");
ShowMessage("Filtering disabled");
if (myScreen == myPlaylist)
ApplyFilter *applyFilter = dynamic_cast<ApplyFilter *>(Get(aApplyFilter));
if (applyFilter && applyFilter->canBeRun())
{
myPlaylist->EnableHighlighting();
Playlist::ReloadTotalLength = true;
RedrawHeader = true;
// delete current filter
wFooter->PushChar(KEY_CTRL_U);
wFooter->PushChar(KEY_ENTER);
applyFilter->Execute();
}
ListsChangeFinisher();
}
bool Find::canBeRun() const

View File

@@ -634,6 +634,7 @@ struct ReversePlaylist : public Action
struct ApplyFilter : public Action
{
ApplyFilter() : Action(aApplyFilter, "apply_filter") { }
virtual bool canBeRun() const;
virtual void Run();
};