ClangFormat: Synchronize with C++ code style settings

And remove UI for default code style settings because
it does not affect anything when ClangFormat plugin is
enabled.

Change-Id: Ie348b7d2691b09ea2b4868da987f2a27347ea0f3
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-11-08 10:35:23 +01:00
parent 3de607f4e0
commit 0e5c7f51fa
9 changed files with 253 additions and 69 deletions

View File

@@ -33,6 +33,8 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projecttree.h>
#include <texteditor/tabsettings.h>
#include <cplusplus/Overview.h>
#include <utils/qtcassert.h>
@@ -226,6 +228,31 @@ CppCodeStyleSettings CppCodeStyleSettings::currentGlobalCodeStyle()
return cppCodeStylePreferences->currentCodeStyleSettings();
}
TextEditor::TabSettings CppCodeStyleSettings::currentProjectTabSettings()
{
ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject();
if (!project)
return currentGlobalTabSettings();
ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration();
QTC_ASSERT(editorConfiguration, return currentGlobalTabSettings());
TextEditor::ICodeStylePreferences *codeStylePreferences
= editorConfiguration->codeStyle(CppTools::Constants::CPP_SETTINGS_ID);
QTC_ASSERT(codeStylePreferences, return currentGlobalTabSettings());
return codeStylePreferences->tabSettings();
}
TextEditor::TabSettings CppCodeStyleSettings::currentGlobalTabSettings()
{
CppTools::CppCodeStylePreferences *cppCodeStylePreferences
= CppTools::CppToolsSettings::instance()->cppCodeStyle();
QTC_ASSERT(cppCodeStylePreferences, return TextEditor::TabSettings());
return cppCodeStylePreferences->tabSettings();
}
static void configureOverviewWithCodeStyleSettings(CPlusPlus::Overview &overview,
const CppCodeStyleSettings &settings)
{

View File

@@ -34,6 +34,7 @@ class QSettings;
QT_END_NAMESPACE
namespace CPlusPlus { class Overview; }
namespace TextEditor { class TabSettings; }
namespace CppTools {
@@ -94,6 +95,8 @@ public:
static CppCodeStyleSettings currentProjectCodeStyle();
static CppCodeStyleSettings currentGlobalCodeStyle();
static TextEditor::TabSettings currentProjectTabSettings();
static TextEditor::TabSettings currentGlobalTabSettings();
/*! Returns an Overview configured by the current project's code style.