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 "projectexplorertr.h"
|
||||||
#include "projecttree.h"
|
#include "projecttree.h"
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
|
||||||
#include <utils/tasktree.h>
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
CurrentProjectFilter::CurrentProjectFilter()
|
CurrentProjectFilter::CurrentProjectFilter()
|
||||||
: BaseFileFilter()
|
|
||||||
{
|
{
|
||||||
setId("Files in current project");
|
setId("Files in current project");
|
||||||
setDisplayName(Tr::tr("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."));
|
"\"+<number>\" or \":<number>\" to jump to the column number as well."));
|
||||||
setDefaultShortcutString("p");
|
setDefaultShortcutString("p");
|
||||||
setDefaultIncludedByDefault(false);
|
setDefaultIncludedByDefault(false);
|
||||||
setRefreshRecipe(Tasking::Sync([this] { invalidateCache(); }));
|
setRefreshRecipe(Tasking::Sync([this] { invalidate(); }));
|
||||||
|
|
||||||
connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
|
connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
|
||||||
this, &CurrentProjectFilter::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()
|
void CurrentProjectFilter::currentProjectChanged()
|
||||||
{
|
{
|
||||||
Project *project = ProjectTree::currentProject();
|
Project *project = ProjectTree::currentProject();
|
||||||
if (project == m_project)
|
if (project == m_project)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_project)
|
if (m_project)
|
||||||
disconnect(m_project, &Project::fileListChanged,
|
disconnect(m_project, &Project::fileListChanged, this, &CurrentProjectFilter::invalidate);
|
||||||
this, &CurrentProjectFilter::invalidateCache);
|
|
||||||
|
|
||||||
if (project)
|
|
||||||
connect(project, &Project::fileListChanged,
|
|
||||||
this, &CurrentProjectFilter::invalidateCache);
|
|
||||||
|
|
||||||
m_project = project;
|
m_project = project;
|
||||||
invalidateCache();
|
if (m_project)
|
||||||
}
|
connect(m_project, &Project::fileListChanged, this, &CurrentProjectFilter::invalidate);
|
||||||
|
|
||||||
void CurrentProjectFilter::invalidateCache()
|
invalidate();
|
||||||
{
|
|
||||||
m_cache.invalidate();
|
|
||||||
setFileIterator(nullptr);
|
|
||||||
}
|
}
|
||||||
|
@@ -3,32 +3,24 @@
|
|||||||
|
|
||||||
#pragma once
|
#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 {
|
class CurrentProjectFilter : public Core::ILocatorFilter
|
||||||
|
|
||||||
// TODO: Don't derive from BaseFileFilter, flatten the hierarchy
|
|
||||||
class CurrentProjectFilter : public Core::BaseFileFilter
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CurrentProjectFilter();
|
CurrentProjectFilter();
|
||||||
void prepareSearch(const QString &entry) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::LocatorMatcherTasks matchers() final { return {m_cache.matcher()}; }
|
Core::LocatorMatcherTasks matchers() final { return {m_cache.matcher()}; }
|
||||||
void currentProjectChanged();
|
void currentProjectChanged();
|
||||||
// TODO: Remove me, replace with direct "m_cache.invalidate()" call
|
void invalidate() { m_cache.invalidate(); }
|
||||||
void invalidateCache();
|
|
||||||
|
|
||||||
Core::LocatorFileCache m_cache;
|
Core::LocatorFileCache m_cache;
|
||||||
Project *m_project = nullptr;
|
Project *m_project = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace ProjectExplorer::Internal
|
||||||
} // namespace ProjectExplorer
|
|
||||||
|
Reference in New Issue
Block a user