diff --git a/src/plugins/projectexplorer/currentprojectfilter.cpp b/src/plugins/projectexplorer/currentprojectfilter.cpp index 5b5c34fe44f..d42ab82e968 100644 --- a/src/plugins/projectexplorer/currentprojectfilter.cpp +++ b/src/plugins/projectexplorer/currentprojectfilter.cpp @@ -7,16 +7,12 @@ #include "projectexplorertr.h" #include "projecttree.h" -#include -#include - using namespace Core; using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; using namespace Utils; CurrentProjectFilter::CurrentProjectFilter() - : BaseFileFilter() { setId("Files in current project"); setDisplayName(Tr::tr("Files in Current Project")); @@ -25,7 +21,7 @@ CurrentProjectFilter::CurrentProjectFilter() "\"+\" or \":\" to jump to the column number as well.")); setDefaultShortcutString("p"); setDefaultIncludedByDefault(false); - setRefreshRecipe(Tasking::Sync([this] { invalidateCache(); })); + setRefreshRecipe(Tasking::Sync([this] { invalidate(); })); connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged, this, &CurrentProjectFilter::currentProjectChanged); @@ -36,35 +32,17 @@ CurrentProjectFilter::CurrentProjectFilter() }); } -void CurrentProjectFilter::prepareSearch(const QString &entry) -{ - Q_UNUSED(entry) - if (!fileIterator()) { - const FilePaths paths = m_project ? m_project->files(Project::SourceFiles) : FilePaths(); - setFileIterator(new BaseFileFilter::ListIterator(paths)); - } - BaseFileFilter::prepareSearch(entry); -} - void CurrentProjectFilter::currentProjectChanged() { Project *project = ProjectTree::currentProject(); if (project == m_project) return; + if (m_project) - disconnect(m_project, &Project::fileListChanged, - this, &CurrentProjectFilter::invalidateCache); - - if (project) - connect(project, &Project::fileListChanged, - this, &CurrentProjectFilter::invalidateCache); - + disconnect(m_project, &Project::fileListChanged, this, &CurrentProjectFilter::invalidate); m_project = project; - invalidateCache(); -} + if (m_project) + connect(m_project, &Project::fileListChanged, this, &CurrentProjectFilter::invalidate); -void CurrentProjectFilter::invalidateCache() -{ - m_cache.invalidate(); - setFileIterator(nullptr); + invalidate(); } diff --git a/src/plugins/projectexplorer/currentprojectfilter.h b/src/plugins/projectexplorer/currentprojectfilter.h index 6aef3050584..6c500707907 100644 --- a/src/plugins/projectexplorer/currentprojectfilter.h +++ b/src/plugins/projectexplorer/currentprojectfilter.h @@ -3,32 +3,24 @@ #pragma once -#include +#include -namespace ProjectExplorer { +namespace ProjectExplorer { class Project; } -class Project; +namespace ProjectExplorer::Internal { -namespace Internal { - -// TODO: Don't derive from BaseFileFilter, flatten the hierarchy -class CurrentProjectFilter : public Core::BaseFileFilter +class CurrentProjectFilter : public Core::ILocatorFilter { - Q_OBJECT - public: CurrentProjectFilter(); - void prepareSearch(const QString &entry) override; private: Core::LocatorMatcherTasks matchers() final { return {m_cache.matcher()}; } void currentProjectChanged(); - // TODO: Remove me, replace with direct "m_cache.invalidate()" call - void invalidateCache(); + void invalidate() { m_cache.invalidate(); } Core::LocatorFileCache m_cache; Project *m_project = nullptr; }; -} // namespace Internal -} // namespace ProjectExplorer +} // namespace ProjectExplorer::Internal