ProjectExplorer: Replace a non-FilePath based mimetype use

Change-Id: Icac2f3b2b79f725151a6947a0a6f544f51b31fd7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2022-06-14 17:06:19 +02:00
parent 56a3afef3c
commit 44764bc54e
3 changed files with 6 additions and 8 deletions

View File

@@ -86,7 +86,7 @@ bool JsonWizardGenerator::formatFile(const JsonWizard *wizard, GeneratedFile *fi
if (file->isBinary() || file->contents().isEmpty()) if (file->isBinary() || file->contents().isEmpty())
return true; // nothing to do return true; // nothing to do
Id languageId = TextEditorSettings::languageId(Utils::mimeTypeForFile(file->path()).name()); Id languageId = TextEditorSettings::languageId(Utils::mimeTypeForFile(file->filePath()).name());
if (!languageId.isValid()) if (!languageId.isValid())
return true; // don't modify files like *.ui, *.pro return true; // don't modify files like *.ui, *.pro
@@ -99,7 +99,7 @@ bool JsonWizardGenerator::formatFile(const JsonWizard *wizard, GeneratedFile *fi
Indenter *indenter = nullptr; Indenter *indenter = nullptr;
if (factory) { if (factory) {
indenter = factory->createIndenter(&doc); indenter = factory->createIndenter(&doc);
indenter->setFileName(Utils::FilePath::fromString(file->path())); indenter->setFileName(file->filePath());
} }
if (!indenter) if (!indenter)
indenter = new TextIndenter(&doc); indenter = new TextIndenter(&doc);

View File

@@ -25,15 +25,12 @@
#include "jsonwizardscannergenerator.h" #include "jsonwizardscannergenerator.h"
#include "../projectexplorer.h"
#include "../projectmanager.h" #include "../projectmanager.h"
#include "jsonwizard.h"
#include "jsonwizardfactory.h"
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/fileutils.h> #include <utils/filepath.h>
#include <utils/macroexpander.h> #include <utils/macroexpander.h>
#include <utils/mimeutils.h> #include <utils/mimeutils.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -104,7 +101,8 @@ Core::GeneratedFiles JsonWizardScannerGenerator::fileList(Utils::MacroExpander *
for (auto it = result.begin(); it != result.end(); ++it) { for (auto it = result.begin(); it != result.end(); ++it) {
const QString relPath = project.relativeFilePath(it->path()); const QString relPath = project.relativeFilePath(it->path());
it->setBinary(binaryPattern.match(relPath).hasMatch()); it->setBinary(binaryPattern.match(relPath).hasMatch());
bool found = ProjectManager::canOpenProjectForMimeType(Utils::mimeTypeForFile(relPath)); bool found = ProjectManager::canOpenProjectForMimeType(Utils::mimeTypeForFile(
Utils::FilePath::fromString(relPath)));
if (found) { if (found) {
it->setAttributes(it->attributes() | Core::GeneratedFile::OpenProjectAttribute); it->setAttributes(it->attributes() | Core::GeneratedFile::OpenProjectAttribute);
minDepth = std::min(minDepth, getDepth(it->path())); minDepth = std::min(minDepth, getDepth(it->path()));

View File

@@ -244,7 +244,7 @@ void ProjectFileWizardExtension::applyCodeStyle(GeneratedFile *file) const
if (file->isBinary() || file->contents().isEmpty()) if (file->isBinary() || file->contents().isEmpty())
return; // nothing to do return; // nothing to do
Id languageId = TextEditorSettings::languageId(Utils::mimeTypeForFile(file->path()).name()); Id languageId = TextEditorSettings::languageId(Utils::mimeTypeForFile(file->filePath()).name());
if (!languageId.isValid()) if (!languageId.isValid())
return; // don't modify files like *.ui *.pro return; // don't modify files like *.ui *.pro