CppTools: Modernize

Change-Id: I78af9cd4ccddfa4ed744dce96b772ae5644c89d2
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Nikolai Kosjar
2019-02-07 10:09:21 +01:00
parent 69281bcdcf
commit 12f4b1ee86
15 changed files with 61 additions and 96 deletions

View File

@@ -67,30 +67,7 @@ using namespace CppTools;
// ------------------ CppCodeStyleSettingsWidget
CppCodeStyleSettings::CppCodeStyleSettings() :
indentBlockBraces(false)
, indentBlockBody(true)
, indentClassBraces(false)
, indentEnumBraces(false)
, indentNamespaceBraces(false)
, indentNamespaceBody(false)
, indentAccessSpecifiers(false)
, indentDeclarationsRelativeToAccessSpecifiers(true)
, indentFunctionBody(true)
, indentFunctionBraces(false)
, indentSwitchLabels(false)
, indentStatementsRelativeToSwitchLabels(true)
, indentBlocksRelativeToSwitchLabels(false)
, indentControlFlowRelativeToSwitchLabels(true)
, bindStarToIdentifier(true)
, bindStarToTypeName(false)
, bindStarToLeftSpecifier(false)
, bindStarToRightSpecifier(false)
, extraPaddingForConditionsIfConfusingAlign(true)
, alignAssignments(false)
, preferGetterNameWithoutGetPrefix(true)
{
}
CppCodeStyleSettings::CppCodeStyleSettings() = default;
void CppCodeStyleSettings::toSettings(const QString &category, QSettings *s) const
{
@@ -203,21 +180,20 @@ bool CppCodeStyleSettings::equals(const CppCodeStyleSettings &rhs) const
Utils::optional<CppCodeStyleSettings> CppCodeStyleSettings::currentProjectCodeStyle()
{
ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject();
using OptSettings = Utils::optional<CppCodeStyleSettings>;
if (!project)
return OptSettings();
return {};
ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration();
QTC_ASSERT(editorConfiguration, return OptSettings());
QTC_ASSERT(editorConfiguration, return {});
TextEditor::ICodeStylePreferences *codeStylePreferences
= editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID);
QTC_ASSERT(codeStylePreferences, return OptSettings());
QTC_ASSERT(codeStylePreferences, return {});
auto cppCodeStylePreferences =
dynamic_cast<const CppCodeStylePreferences *>(codeStylePreferences);
if (!cppCodeStylePreferences)
return OptSettings();
return {};
return cppCodeStylePreferences->currentCodeStyleSettings();
}