ProjectNodes: Add method to query FileType

Add methods to get the FileType based on filepath or mimetype.

Use that method in treescanner.

Change-Id: I3de50d7afd8262cc86ae722e7de4ca53921153d2
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Tobias Hunger
2017-03-10 17:03:51 +01:00
parent 7648504a30
commit a70370cc04
3 changed files with 35 additions and 23 deletions

View File

@@ -141,29 +141,7 @@ bool TreeScanner::isMimeBinary(const Utils::MimeType &mimeType, const Utils::Fil
FileType TreeScanner::genericFileType(const Utils::MimeType &mimeType, const Utils::FileName &/*fn*/)
{
FileType type = FileType::Unknown;
if (mimeType.isValid()) {
const QString mt = mimeType.name();
if (mt == CppTools::Constants::C_SOURCE_MIMETYPE
|| mt == CppTools::Constants::CPP_SOURCE_MIMETYPE
|| mt == CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE
|| mt == CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE
|| mt == CppTools::Constants::QDOC_MIMETYPE
|| mt == CppTools::Constants::MOC_MIMETYPE)
type = FileType::Source;
else if (mt == CppTools::Constants::C_HEADER_MIMETYPE
|| mt == CppTools::Constants::CPP_HEADER_MIMETYPE)
type = FileType::Header;
else if (mt == ProjectExplorer::Constants::FORM_MIMETYPE)
type = FileType::Form;
else if (mt == ProjectExplorer::Constants::RESOURCE_MIMETYPE)
type = FileType::Resource;
else if (mt == ProjectExplorer::Constants::SCXML_MIMETYPE)
type = FileType::StateChart;
else if (mt == ProjectExplorer::Constants::QML_MIMETYPE)
type = FileType::QML;
}
return type;
return Node::fileTypeForMimeType(mimeType);
}
void TreeScanner::scanForFiles(FutureInterface *fi, const Utils::FileName& directory, const FileFilter &filter, const FileTypeFactory &factory)