CurrentProjectFilter: Remove the old matchesFor() implementation

Change-Id: I2bd960c14056907e6735002120900b6252ea3989
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Jarek Kobus
2023-04-24 23:39:51 +02:00
parent 9c2fa5c975
commit 681627cac3
2 changed files with 12 additions and 42 deletions

View File

@@ -7,16 +7,12 @@
#include "projectexplorertr.h"
#include "projecttree.h"
#include <utils/algorithm.h>
#include <utils/tasktree.h>
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()
"\"+<number>\" or \":<number>\" 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();
}

View File

@@ -3,32 +3,24 @@
#pragma once
#include <coreplugin/locator/basefilefilter.h>
#include <coreplugin/locator/ilocatorfilter.h>
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