forked from qt-creator/qt-creator
CppEditor: Simplify access to FileSettingForProject
Change-Id: I382a6cce314eafaeb21ae4c9fa42015b79a0cb0e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -601,24 +601,17 @@ void CppEditorPlugin::clearHeaderSourceCache()
|
|||||||
|
|
||||||
FilePath CppEditorPlugin::licenseTemplatePath(Project *project)
|
FilePath CppEditorPlugin::licenseTemplatePath(Project *project)
|
||||||
{
|
{
|
||||||
return FilePath::fromString(fileSettings(project).licenseTemplatePath);
|
return FilePath::fromString(cppFileSettingsForProject(project).licenseTemplatePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CppEditorPlugin::licenseTemplate(Project *project)
|
QString CppEditorPlugin::licenseTemplate(Project *project)
|
||||||
{
|
{
|
||||||
return fileSettings(project).licenseTemplate();
|
return cppFileSettingsForProject(project).licenseTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppEditorPlugin::usePragmaOnce(Project *project)
|
bool CppEditorPlugin::usePragmaOnce(Project *project)
|
||||||
{
|
{
|
||||||
return fileSettings(project).headerPragmaOnce;
|
return cppFileSettingsForProject(project).headerPragmaOnce;
|
||||||
}
|
|
||||||
|
|
||||||
CppFileSettings CppEditorPlugin::fileSettings(Project *project)
|
|
||||||
{
|
|
||||||
if (!project)
|
|
||||||
return globalCppFileSettings();
|
|
||||||
return CppFileSettingsForProject(project).settings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static FilePaths findFilesInProject(const QStringList &names, const Project *project,
|
static FilePaths findFilesInProject(const QStringList &names, const Project *project,
|
||||||
@@ -770,7 +763,7 @@ FilePath correspondingHeaderOrSource(const FilePath &filePath, bool *wasHeader,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Project * const projectForFile = ProjectManager::projectForFile(filePath);
|
Project * const projectForFile = ProjectManager::projectForFile(filePath);
|
||||||
const CppFileSettings settings = CppEditorPlugin::fileSettings(projectForFile);
|
const CppFileSettings settings = cppFileSettingsForProject(projectForFile);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << Q_FUNC_INFO << filePath.fileName() << kind;
|
qDebug() << Q_FUNC_INFO << filePath.fileName() << kind;
|
||||||
|
@@ -11,7 +11,6 @@ namespace Utils { class FilePath; }
|
|||||||
namespace CppEditor::Internal {
|
namespace CppEditor::Internal {
|
||||||
|
|
||||||
class CppEditorPluginPrivate;
|
class CppEditorPluginPrivate;
|
||||||
class CppFileSettings;
|
|
||||||
|
|
||||||
class CppEditorPlugin : public ExtensionSystem::IPlugin
|
class CppEditorPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
@@ -36,8 +35,6 @@ public:
|
|||||||
void renameSymbolUnderCursor();
|
void renameSymbolUnderCursor();
|
||||||
void switchDeclarationDefinition();
|
void switchDeclarationDefinition();
|
||||||
|
|
||||||
static CppFileSettings fileSettings(ProjectExplorer::Project *project);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void typeHierarchyRequested();
|
void typeHierarchyRequested();
|
||||||
void includeHierarchyRequested();
|
void includeHierarchyRequested();
|
||||||
|
@@ -464,11 +464,30 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CppFileSettingsForProject::CppFileSettingsForProject(ProjectExplorer::Project *project)
|
// CppFileSettingsForProject
|
||||||
: m_project(project)
|
|
||||||
|
class CppFileSettingsForProject final
|
||||||
{
|
{
|
||||||
loadSettings();
|
public:
|
||||||
}
|
CppFileSettingsForProject(Project *project)
|
||||||
|
: m_project(project)
|
||||||
|
{
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
CppFileSettings settings() const;
|
||||||
|
void setSettings(const CppFileSettings &settings);
|
||||||
|
bool useGlobalSettings() const { return m_useGlobalSettings; }
|
||||||
|
void setUseGlobalSettings(bool useGlobal);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void loadSettings();
|
||||||
|
void saveSettings();
|
||||||
|
|
||||||
|
Project * const m_project;
|
||||||
|
CppFileSettings m_customSettings;
|
||||||
|
bool m_useGlobalSettings = true;
|
||||||
|
};
|
||||||
|
|
||||||
CppFileSettings CppFileSettingsForProject::settings() const
|
CppFileSettings CppFileSettingsForProject::settings() const
|
||||||
{
|
{
|
||||||
@@ -623,6 +642,11 @@ CppFileSettings &globalCppFileSettings()
|
|||||||
return theGlobalCppFileSettings;
|
return theGlobalCppFileSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CppFileSettings cppFileSettingsForProject(ProjectExplorer::Project *project)
|
||||||
|
{
|
||||||
|
return CppFileSettingsForProject(project).settings();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace CppEditor::Internal
|
} // namespace CppEditor::Internal
|
||||||
|
|
||||||
#include <cppfilesettingspage.moc>
|
#include <cppfilesettingspage.moc>
|
||||||
|
@@ -48,27 +48,10 @@ public:
|
|||||||
bool operator!=(const CppFileSettings &s) const { return !equals(s); }
|
bool operator!=(const CppFileSettings &s) const { return !equals(s); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CppFileSettingsForProject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CppFileSettingsForProject(ProjectExplorer::Project *project);
|
|
||||||
|
|
||||||
CppFileSettings settings() const;
|
|
||||||
void setSettings(const CppFileSettings &settings);
|
|
||||||
bool useGlobalSettings() const { return m_useGlobalSettings; }
|
|
||||||
void setUseGlobalSettings(bool useGlobal);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void loadSettings();
|
|
||||||
void saveSettings();
|
|
||||||
|
|
||||||
ProjectExplorer::Project * const m_project;
|
|
||||||
CppFileSettings m_customSettings;
|
|
||||||
bool m_useGlobalSettings = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
CppFileSettings &globalCppFileSettings();
|
CppFileSettings &globalCppFileSettings();
|
||||||
|
|
||||||
|
CppFileSettings cppFileSettingsForProject(ProjectExplorer::Project *project);
|
||||||
|
|
||||||
void setupCppFileSettings();
|
void setupCppFileSettings();
|
||||||
|
|
||||||
} // namespace CppEditor::Internal
|
} // namespace CppEditor::Internal
|
||||||
|
@@ -33,7 +33,7 @@ static CppFileSettings fileSettings()
|
|||||||
{
|
{
|
||||||
// Note that the user can set a different project in the wizard *after* the file names
|
// Note that the user can set a different project in the wizard *after* the file names
|
||||||
// have been determined. There's nothing we can do about that here.
|
// have been determined. There's nothing we can do about that here.
|
||||||
return CppEditorPlugin::fileSettings(ProjectExplorer::ProjectTree::currentProject());
|
return cppFileSettingsForProject(ProjectExplorer::ProjectTree::currentProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString fileName(const QString &path, const QString &extension)
|
static QString fileName(const QString &path, const QString &extension)
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
#include "cppcodemodelsettings.h"
|
#include "cppcodemodelsettings.h"
|
||||||
#include "cppcompletionassist.h"
|
#include "cppcompletionassist.h"
|
||||||
#include "cppeditorconstants.h"
|
#include "cppeditorconstants.h"
|
||||||
#include "cppeditorplugin.h"
|
|
||||||
#include "cppeditorwidget.h"
|
#include "cppeditorwidget.h"
|
||||||
#include "cppeditortr.h"
|
#include "cppeditortr.h"
|
||||||
#include "cppfilesettingspage.h"
|
#include "cppfilesettingspage.h"
|
||||||
@@ -627,17 +626,17 @@ void openEditor(const Utils::FilePath &filePath, bool inNextSplit, Utils::Id edi
|
|||||||
|
|
||||||
bool preferLowerCaseFileNames(ProjectExplorer::Project *project)
|
bool preferLowerCaseFileNames(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
return Internal::CppEditorPlugin::fileSettings(project).lowerCaseFiles;
|
return Internal::cppFileSettingsForProject(project).lowerCaseFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString preferredCxxHeaderSuffix(ProjectExplorer::Project *project)
|
QString preferredCxxHeaderSuffix(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
return Internal::CppEditorPlugin::fileSettings(project).headerSuffix;
|
return Internal::cppFileSettingsForProject(project).headerSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString preferredCxxSourceSuffix(ProjectExplorer::Project *project)
|
QString preferredCxxSourceSuffix(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
return Internal::CppEditorPlugin::fileSettings(project).sourceSuffix;
|
return Internal::cppFileSettingsForProject(project).sourceSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchResultItems symbolOccurrencesInDeclarationComments(
|
SearchResultItems symbolOccurrencesInDeclarationComments(
|
||||||
|
Reference in New Issue
Block a user