CppEditor: Make some settings accesses more direct

Change-Id: Ib7768462bcf50b5321323b27f0d2837444160162
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2024-01-23 08:44:54 +01:00
parent e1da48bf86
commit ff25fa6ca7
3 changed files with 7 additions and 26 deletions

View File

@@ -3,7 +3,6 @@
#include "abstracteditorsupport.h"
#include "cppeditorplugin.h"
#include "cppeditortr.h"
#include "cppfilesettingspage.h"
#include "cppmodelmanager.h"
@@ -42,7 +41,7 @@ void AbstractEditorSupport::notifyAboutUpdatedContents() const
QString AbstractEditorSupport::licenseTemplate(ProjectExplorer::Project *project,
const FilePath &filePath, const QString &className)
{
const QString license = Internal::CppEditorPlugin::licenseTemplate(project);
const QString license = Internal::cppFileSettingsForProject(project).licenseTemplate();
Utils::MacroExpander expander;
expander.registerVariable("Cpp:License:FileName", Tr::tr("The file name."),
[filePath] { return filePath.fileName(); });
@@ -54,7 +53,7 @@ QString AbstractEditorSupport::licenseTemplate(ProjectExplorer::Project *project
bool AbstractEditorSupport::usePragmaOnce(ProjectExplorer::Project *project)
{
return Internal::CppEditorPlugin::usePragmaOnce(project);
return Internal::cppFileSettingsForProject(project).headerPragmaOnce;
}
} // CppEditor

View File

@@ -478,14 +478,14 @@ void CppEditorPlugin::registerVariables()
// TODO: Per-project variants of these three?
expander->registerVariable("Cpp:LicenseTemplate",
Tr::tr("The license template."),
[]() { return CppEditorPlugin::licenseTemplate(nullptr); });
[] { return globalCppFileSettings().licenseTemplate(); });
expander->registerFileVariables("Cpp:LicenseTemplatePath",
Tr::tr("The configured path to the license template"),
[]() { return CppEditorPlugin::licenseTemplatePath(nullptr); });
[] { return FilePath::fromUserInput(globalCppFileSettings().licenseTemplatePath); });
expander->registerVariable(
"Cpp:PragmaOnce",
Tr::tr("Insert \"#pragma once\" instead of \"#ifndef\" include guards into header file"),
[] { return usePragmaOnce(nullptr) ? QString("true") : QString(); });
[] { return globalCppFileSettings().headerPragmaOnce ? QString("true") : QString(); });
}
void CppEditorPlugin::registerTests()
@@ -599,21 +599,6 @@ void CppEditorPlugin::clearHeaderSourceCache()
m_headerSourceMapping.clear();
}
FilePath CppEditorPlugin::licenseTemplatePath(Project *project)
{
return FilePath::fromString(cppFileSettingsForProject(project).licenseTemplatePath);
}
QString CppEditorPlugin::licenseTemplate(Project *project)
{
return cppFileSettingsForProject(project).licenseTemplate();
}
bool CppEditorPlugin::usePragmaOnce(Project *project)
{
return cppFileSettingsForProject(project).headerPragmaOnce;
}
static FilePaths findFilesInProject(const QStringList &names, const Project *project,
FileType fileType)
{

View File

@@ -24,9 +24,6 @@ public:
static CppEditorPlugin *instance();
static void clearHeaderSourceCache();
static Utils::FilePath licenseTemplatePath(ProjectExplorer::Project *project);
static QString licenseTemplate(ProjectExplorer::Project *project);
static bool usePragmaOnce(ProjectExplorer::Project *project);
void openDeclarationDefinitionInNextSplit();
void openTypeHierarchy();