forked from qt-creator/qt-creator
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:
@@ -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();
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user