From 3a6dff6743534760af3395864c84616d83db61bb Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 3 Feb 2022 15:14:24 +0100 Subject: [PATCH] ProjectExplorer: filepathify actualTabSettings Change-Id: I4b08b96d56bfeed0348d82bb96ff70d5f8ad583b Reviewed-by: Reviewed-by: Christian Kandeler --- src/plugins/cppeditor/cpprefactoringchanges.cpp | 6 ++---- src/plugins/projectexplorer/editorconfiguration.cpp | 4 ++-- src/plugins/projectexplorer/editorconfiguration.h | 6 ++++-- src/plugins/qmljstools/qmljsrefactoringchanges.cpp | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/plugins/cppeditor/cpprefactoringchanges.cpp b/src/plugins/cppeditor/cpprefactoringchanges.cpp index 10ff7fc62f0..8c16686824c 100644 --- a/src/plugins/cppeditor/cpprefactoringchanges.cpp +++ b/src/plugins/cppeditor/cpprefactoringchanges.cpp @@ -246,8 +246,7 @@ void CppRefactoringChangesData::indentSelection(const QTextCursor &selection, if (textDocument) { // use the indenter from the textDocument if there is one, can be ClangFormat textDocument->indenter()->indent(selection, QChar::Null, textDocument->tabSettings()); } else { - const auto &tabSettings = ProjectExplorer::actualTabSettings(filePath.toString(), - textDocument); + const auto &tabSettings = ProjectExplorer::actualTabSettings(filePath, textDocument); auto indenter = createIndenter(filePath, selection.document()); indenter->indent(selection, QChar::Null, tabSettings); } @@ -260,8 +259,7 @@ void CppRefactoringChangesData::reindentSelection(const QTextCursor &selection, if (textDocument) { // use the indenter from the textDocument if there is one, can be ClangFormat textDocument->indenter()->reindent(selection, textDocument->tabSettings()); } else { - const auto &tabSettings = ProjectExplorer::actualTabSettings(filePath.toString(), - textDocument); + const auto &tabSettings = ProjectExplorer::actualTabSettings(filePath, textDocument); auto indenter = createIndenter(filePath, selection.document()); indenter->reindent(selection, tabSettings); } diff --git a/src/plugins/projectexplorer/editorconfiguration.cpp b/src/plugins/projectexplorer/editorconfiguration.cpp index 286e8cf201d..760e08b6b91 100644 --- a/src/plugins/projectexplorer/editorconfiguration.cpp +++ b/src/plugins/projectexplorer/editorconfiguration.cpp @@ -407,12 +407,12 @@ void EditorConfiguration::slotAboutToRemoveProject(Project *project) deconfigureEditor(editor); } -TabSettings actualTabSettings(const QString &fileName, +TabSettings actualTabSettings(const Utils::FilePath &file, const TextDocument *baseTextdocument) { if (baseTextdocument) return baseTextdocument->tabSettings(); - if (Project *project = SessionManager::projectForFile(Utils::FilePath::fromString(fileName))) + if (Project *project = SessionManager::projectForFile(file)) return project->editorConfiguration()->codeStyle()->tabSettings(); return TextEditorSettings::codeStyle()->tabSettings(); } diff --git a/src/plugins/projectexplorer/editorconfiguration.h b/src/plugins/projectexplorer/editorconfiguration.h index fb9561d90a4..fef5e68466c 100644 --- a/src/plugins/projectexplorer/editorconfiguration.h +++ b/src/plugins/projectexplorer/editorconfiguration.h @@ -49,7 +49,9 @@ class StorageSettings; class BehaviorSettings; class ExtraEncodingSettings; class MarginSettings; -} +} // namespace TextEditor + +namespace Utils { class FilePath; } namespace ProjectExplorer { @@ -118,6 +120,6 @@ private: // the file belongs to and return the project settings. If the file doesn't belong to any // project return the global settings. PROJECTEXPLORER_EXPORT TextEditor::TabSettings actualTabSettings( - const QString &fileName, const TextEditor::TextDocument *baseTextDocument); + const Utils::FilePath &file, const TextEditor::TextDocument *baseTextDocument); } // namespace ProjectExplorer diff --git a/src/plugins/qmljstools/qmljsrefactoringchanges.cpp b/src/plugins/qmljstools/qmljsrefactoringchanges.cpp index e2e8bb2bda4..98d86199dd3 100644 --- a/src/plugins/qmljstools/qmljsrefactoringchanges.cpp +++ b/src/plugins/qmljstools/qmljsrefactoringchanges.cpp @@ -57,7 +57,7 @@ public: const QTextBlock end = doc->findBlock(selection.selectionEnd()).next(); const TextEditor::TabSettings &tabSettings = - ProjectExplorer::actualTabSettings(filePath.toString(), textDocument); + ProjectExplorer::actualTabSettings(filePath, textDocument); CreatorCodeFormatter codeFormatter(tabSettings); codeFormatter.updateStateUntil(block); do { @@ -82,7 +82,7 @@ public: const TextEditor::TextDocument *textDocument) const override { const TextEditor::TabSettings &tabSettings = - ProjectExplorer::actualTabSettings(filePath.toString(), textDocument); + ProjectExplorer::actualTabSettings(filePath, textDocument); QmlJSEditor::Internal::Indenter indenter(selection.document()); indenter.reindent(selection, tabSettings);