Apply static pattern to TextEditorSetting

Change-Id: I4e6f573d893c0aa2bb4ca9812fc8db2961dac172
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
hjk
2013-09-19 17:59:27 +02:00
parent bd10688a62
commit ca15d0aa95
49 changed files with 262 additions and 299 deletions

View File

@@ -50,7 +50,7 @@ static const char idKey[] = "CppGlobal";
using namespace CppTools;
using namespace CppTools::Internal;
using TextEditor::TabSettings;
using namespace TextEditor;
namespace CppTools {
namespace Internal {
@@ -89,15 +89,13 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
this,
SIGNAL(commentsSettingsChanged(CppTools::CommentsSettings)));
TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance();
// code style factory
TextEditor::ICodeStylePreferencesFactory *factory = new CppTools::CppCodeStylePreferencesFactory();
textEditorSettings->registerCodeStyleFactory(factory);
ICodeStylePreferencesFactory *factory = new CppTools::CppCodeStylePreferencesFactory();
TextEditorSettings::registerCodeStyleFactory(factory);
// code style pool
TextEditor::CodeStylePool *pool = new TextEditor::CodeStylePool(factory, this);
textEditorSettings->registerCodeStylePool(Constants::CPP_SETTINGS_ID, pool);
CodeStylePool *pool = new CodeStylePool(factory, this);
TextEditorSettings::registerCodeStylePool(Constants::CPP_SETTINGS_ID, pool);
// global code style settings
d->m_globalCodeStyle = new CppCodeStylePreferences(this);
@@ -105,7 +103,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
d->m_globalCodeStyle->setDisplayName(tr("Global", "Settings"));
d->m_globalCodeStyle->setId(QLatin1String(idKey));
pool->addCodeStyle(d->m_globalCodeStyle);
textEditorSettings->registerCodeStyle(CppTools::Constants::CPP_SETTINGS_ID, d->m_globalCodeStyle);
TextEditorSettings::registerCodeStyle(CppTools::Constants::CPP_SETTINGS_ID, d->m_globalCodeStyle);
/*
For every language we have exactly 1 pool. The pool contains:
@@ -203,7 +201,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
QString(), s, &legacyTabSettings);
} else {
// delegating to global
legacyTabSettings = textEditorSettings->codeStyle()->currentTabSettings();
legacyTabSettings = TextEditorSettings::codeStyle()->currentTabSettings();
}
// create custom code style out of old settings
@@ -224,16 +222,16 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
// mimetypes to be handled
textEditorSettings->registerMimeTypeForLanguageId(
TextEditorSettings::registerMimeTypeForLanguageId(
QLatin1String(Constants::C_SOURCE_MIMETYPE),
Constants::CPP_SETTINGS_ID);
textEditorSettings->registerMimeTypeForLanguageId(
TextEditorSettings::registerMimeTypeForLanguageId(
QLatin1String(Constants::C_HEADER_MIMETYPE),
Constants::CPP_SETTINGS_ID);
textEditorSettings->registerMimeTypeForLanguageId(
TextEditorSettings::registerMimeTypeForLanguageId(
QLatin1String(Constants::CPP_SOURCE_MIMETYPE),
Constants::CPP_SETTINGS_ID);
textEditorSettings->registerMimeTypeForLanguageId(
TextEditorSettings::registerMimeTypeForLanguageId(
QLatin1String(Constants::CPP_HEADER_MIMETYPE),
Constants::CPP_SETTINGS_ID);
}
@@ -242,10 +240,9 @@ CppToolsSettings::~CppToolsSettings()
{
ExtensionSystem::PluginManager::removeObject(d->m_completionSettingsPage);
TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance();
textEditorSettings->unregisterCodeStyle(Constants::CPP_SETTINGS_ID);
textEditorSettings->unregisterCodeStylePool(Constants::CPP_SETTINGS_ID);
textEditorSettings->unregisterCodeStyleFactory(Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStyle(Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStylePool(Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStyleFactory(Constants::CPP_SETTINGS_ID);
delete d;