Project: Make Project::file take a std::function to match files

Make Project::files take a standard function to match files with instead
of an enum (and a std::function).

Change-Id: I6a24e40dba0e972ff96c0a57e775d2377e2545e0
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2017-12-06 10:58:59 +01:00
parent 18f38ff18e
commit f542e24eca
5 changed files with 40 additions and 28 deletions

View File

@@ -86,14 +86,13 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
Constants::QMLPROJECT_MIMETYPE,
Constants::QMLTYPES_MIMETYPE,
Constants::QMLUI_MIMETYPE };
projectInfo.sourceFiles = Utils::transform(project->files(Project::SourceFiles,
[&qmlTypeNames](const Node *n) {
if (const FileNode *fn = n->asFileNode()) {
return fn->fileType() == FileType::QML
&& qmlTypeNames.contains(Utils::mimeTypeForFile(fn->filePath().toString(),
MimeMatchMode::MatchExtension).name());
}
return false;
projectInfo.sourceFiles = Utils::transform(project->files([&qmlTypeNames](const Node *n) {
if (!Project::SourceFiles(n))
return false;
const FileNode *fn = n->asFileNode();
return fn && fn->fileType() == FileType::QML
&& qmlTypeNames.contains(Utils::mimeTypeForFile(fn->filePath().toString(),
MimeMatchMode::MatchExtension).name());
}), &FileName::toString);
activeTarget = project->activeTarget();
}