CppEditor: Remove one use of mimetype via QFileInfo

Plus some cosmetical changes I could not resist.

Change-Id: Id2634d3876437a5dfe7ddb4aaa53db396f37e02a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2022-06-14 15:48:57 +02:00
parent bf8bf1adc0
commit 79e467a8b8

View File

@@ -26,16 +26,13 @@
#include "cppeditordocument.h"
#include "baseeditordocumentparser.h"
#include "builtineditordocumentprocessor.h"
#include "cppcodeformatter.h"
#include "cppcodemodelsettings.h"
#include "cppeditorconstants.h"
#include "cppeditorplugin.h"
#include "cppmodelmanager.h"
#include "cppeditorconstants.h"
#include "cppeditorplugin.h"
#include "cpphighlighter.h"
#include "cppqtstyleindenter.h"
#include "cppquickfixassistant.h"
#include <coreplugin/editormanager/editormanager.h>
@@ -58,20 +55,17 @@
const char NO_PROJECT_CONFIGURATION[] = "NoProject";
namespace {
CppEditor::CppModelManager *mm()
{
return CppEditor::CppModelManager::instance();
}
} // anonymous namespace
using namespace TextEditor;
using namespace Utils;
namespace CppEditor {
namespace Internal {
static CppEditor::CppModelManager *mm()
{
return CppEditor::CppModelManager::instance();
}
enum { processDocumentIntervalInMs = 150 };
class CppEditorDocumentHandleImpl : public CppEditorDocumentHandle
@@ -245,14 +239,13 @@ void CppEditorDocument::reparseWithPreferredParseContext(const QString &parseCon
scheduleProcessDocument();
}
void CppEditorDocument::onFilePathChanged(const Utils::FilePath &oldPath,
const Utils::FilePath &newPath)
void CppEditorDocument::onFilePathChanged(const FilePath &oldPath, const FilePath &newPath)
{
Q_UNUSED(oldPath)
if (!newPath.isEmpty()) {
indenter()->setFileName(newPath);
setMimeType(Utils::mimeTypeForFile(newPath.toFileInfo()).name());
setMimeType(mimeTypeForFile(newPath).name());
connect(this, &Core::IDocument::contentsChanged,
this, &CppEditorDocument::scheduleProcessDocument,
@@ -363,13 +356,13 @@ void CppEditorDocument::releaseResources()
void CppEditorDocument::showHideInfoBarAboutMultipleParseContexts(bool show)
{
const Utils::Id id = Constants::MULTIPLE_PARSE_CONTEXTS_AVAILABLE;
const Id id = Constants::MULTIPLE_PARSE_CONTEXTS_AVAILABLE;
if (show) {
Utils::InfoBarEntry info(id,
InfoBarEntry info(id,
tr("Note: Multiple parse contexts are available for this file. "
"Choose the preferred one from the editor toolbar."),
Utils::InfoBarEntry::GlobalSuppression::Enabled);
InfoBarEntry::GlobalSuppression::Enabled);
info.removeCancelButton();
if (infoBar()->canInfoBeAdded(id))
infoBar()->addInfo(info);
@@ -444,9 +437,9 @@ TextEditor::TabSettings CppEditorDocument::tabSettings() const
return indenter()->tabSettings().value_or(TextEditor::TextDocument::tabSettings());
}
bool CppEditorDocument::save(QString *errorString, const Utils::FilePath &filePath, bool autoSave)
bool CppEditorDocument::save(QString *errorString, const FilePath &filePath, bool autoSave)
{
Utils::ExecuteOnDestruction resetSettingsOnScopeExit;
ExecuteOnDestruction resetSettingsOnScopeExit;
if (indenter()->formatOnSave() && !autoSave) {
auto *layout = qobject_cast<TextEditor::TextDocumentLayout *>(document()->documentLayout());