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