Commit cb355948 authored by hjk's avatar hjk
Browse files

TextEditor: Centralize settings connections setup



All editors did that manually, with varying approaches. Connect once
when the document is made known to the EditorWidget instead.

Change-Id: Ib0828b08158539859f6f89c8080435a027aa06ed
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent b25c575b
......@@ -47,7 +47,6 @@
#include <projectexplorer/kitinformation.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/basetexteditor.h>
#include <utils/algorithm.h>
......@@ -112,7 +111,6 @@ AndroidManifestEditorWidget::AndroidManifestEditorWidget()
{
m_textEditorWidget = new AndroidManifestTextEditorWidget(this);
m_textEditorWidget->setupAsPlainEditor();
TextEditor::TextEditorSettings::initializeEditor(m_textEditorWidget);
initializePage();
......
......@@ -33,7 +33,6 @@
#include "androidconstants.h"
#include "javacompletionassistprovider.h"
#include <texteditor/texteditorsettings.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/normalindenter.h>
#include <texteditor/highlighterutils.h>
......@@ -56,14 +55,12 @@ JavaEditor::JavaEditor()
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::CppStyle);
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<JavaCompletionAssistProvider>());
setAutoCompleter(new JavaAutoCompleter);
}
Core::IEditor *JavaEditor::duplicate()
{
JavaEditorWidget *ret = new JavaEditorWidget;
ret->setTextDocument(editorWidget()->textDocumentPtr());
TextEditor::TextEditorSettings::initializeEditor(ret);
return ret->editor();
}
......@@ -73,6 +70,7 @@ Core::IEditor *JavaEditor::duplicate()
JavaEditorWidget::JavaEditorWidget()
{
setAutoCompleter(new JavaAutoCompleter);
}
TextEditor::BaseTextEditor *JavaEditorWidget::createEditor()
......
......@@ -32,7 +32,6 @@
#include "androidconstants.h"
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorsettings.h>
using namespace Android;
using namespace Android::Internal;
......@@ -50,6 +49,5 @@ Core::IEditor *JavaEditorFactory::createEditor()
{
JavaEditorWidget *editor = new JavaEditorWidget;
editor->setTextDocument(TextEditor::BaseTextDocumentPtr(new JavaDocument));
TextEditor::TextEditorSettings::initializeEditor(editor);
return editor->editor();
}
......@@ -43,7 +43,6 @@
#include <projectexplorer/session.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/highlighterutils.h>
#include <QFileInfo>
......@@ -70,7 +69,6 @@ Core::IEditor *CMakeEditor::duplicate()
{
CMakeEditorWidget *ret = new CMakeEditorWidget;
ret->setTextDocument(editorWidget()->textDocumentPtr());
TextEditor::TextEditorSettings::initializeEditor(ret);
return ret->editor();
}
......
......@@ -37,7 +37,6 @@
#include <coreplugin/editormanager/editormanager.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
......@@ -74,6 +73,5 @@ Core::IEditor *CMakeEditorFactory::createEditor()
{
CMakeEditorWidget *widget = new CMakeEditorWidget;
widget->setTextDocument(TextEditor::BaseTextDocumentPtr(new CMakeDocument));
TextEditor::TextEditorSettings::initializeEditor(widget);
return widget->editor();
}
......@@ -253,7 +253,7 @@ bool CppDocumentationCommentHelper::handleKeyPressEvent(QKeyEvent *e) const
if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
QTextCursor cursor = m_editorWidget->textCursor();
if (!m_editorWidget->editor()->autoCompleter()->isInComment(cursor))
if (!m_editorWidget->autoCompleter()->isInComment(cursor))
return false;
// We are interested on two particular cases:
......
......@@ -50,6 +50,7 @@
#include <cpptools/cpphighlightingsupport.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <cpptools/cppsemanticinfo.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cpptoolseditorsupport.h>
#include <cpptools/cpptoolsplugin.h>
#include <cpptools/cpptoolsreuse.h>
......@@ -116,7 +117,6 @@ CPPEditor::CPPEditor()
setCompletionAssistProvider([this] () -> TextEditor::CompletionAssistProvider * {
return CppModelManagerInterface::instance()->cppEditorSupport(this)->completionAssistProvider();
});
setAutoCompleter(new CppAutoCompleter);
}
Q_GLOBAL_STATIC(CppTools::SymbolFinder, symbolFinder)
......@@ -180,6 +180,7 @@ CppEditorWidget::CppEditorWidget(TextEditor::BaseTextDocumentPtr doc)
{
setTextDocument(doc);
d.reset(new CppEditorWidgetPrivate(this));
setAutoCompleter(new CppAutoCompleter);
qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo");
......@@ -243,6 +244,7 @@ CppEditorWidget::CppEditorWidget(TextEditor::BaseTextDocumentPtr doc)
connect(d->m_preprocessorButton, SIGNAL(clicked()), this, SLOT(showPreProcessorWidget()));
insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, d->m_preprocessorButton);
insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, d->m_cppEditorOutline->widget());
setLanguageSettingsId(CppTools::Constants::CPP_SETTINGS_ID);
}
CppEditorWidget::~CppEditorWidget()
......
......@@ -54,7 +54,6 @@
#include <cpptools/cpptoolsconstants.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/highlighterfactory.h>
#include <utils/hostosinfo.h>
......@@ -130,9 +129,6 @@ CppEditorPlugin *CppEditorPlugin::instance()
void CppEditorPlugin::initializeEditor(CppEditorWidget *editor)
{
editor->setLanguageSettingsId(CppTools::Constants::CPP_SETTINGS_ID);
TextEditor::TextEditorSettings::initializeEditor(editor);
// function combo box sorting
connect(this, SIGNAL(outlineSortingChanged(bool)),
editor->outline(), SLOT(setSorted(bool)));
......
......@@ -64,5 +64,5 @@ void CppSnippetProvider::decorateEditor(TextEditor::SnippetEditorWidget *editor)
{
editor->setSyntaxHighlighter(new CppHighlighter);
editor->textDocument()->setIndenter(new CppTools::CppQtStyleIndenter);
editor->editor()->setAutoCompleter(new CppAutoCompleter);
editor->setAutoCompleter(new CppAutoCompleter);
}
......@@ -49,7 +49,6 @@
#include <coreplugin/minisplitter.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/outputpane.h>
#include <texteditor/texteditorsettings.h>
#include <utils/qtcassert.h>
#include <QDesignerFormEditorPluginInterface>
......@@ -684,7 +683,6 @@ EditorData FormEditorW::createEditor()
#endif
data.widgetHost = new SharedTools::WidgetHost( /* parent */ 0, form);
DesignerXmlEditorWidget *xmlEditor = new DesignerXmlEditorWidget(form);
TextEditor::TextEditorSettings::initializeEditor(xmlEditor);
data.formWindowEditor = xmlEditor->designerEditor();
connect(data.formWindowEditor->document(), SIGNAL(filePathChanged(QString,QString)),
resourceHandler, SLOT(updateResources()));
......
......@@ -32,9 +32,7 @@
#include "genericprojectconstants.h"
#include <coreplugin/editormanager/editormanager.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorsettings.h>
#include <QCoreApplication>
#include <QSharedPointer>
......@@ -66,7 +64,6 @@ Core::IEditor *ProjectFilesFactory::createEditor()
{
auto widget = new ProjectFilesEditorWidget;
widget->setSimpleTextDocument(Constants::FILES_EDITOR_ID);
TextEditorSettings::initializeEditor(widget);
return widget->editor();
}
......@@ -86,7 +83,6 @@ Core::IEditor *ProjectFilesEditor::duplicate()
{
auto widget = new ProjectFilesEditorWidget;
widget->setTextDocument(editorWidget()->textDocumentPtr());
TextEditorSettings::initializeEditor(widget);
return widget->editor();
}
......
......@@ -52,25 +52,18 @@
#include <extensionsystem/pluginmanager.h>
#include <texteditor/basetextdocument.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/syntaxhighlighter.h>
#include <texteditor/refactoroverlay.h>
#include <qmldesigner/qmldesignerconstants.h>
#include <utils/changeset.h>
#include <utils/uncommentselection.h>
#include <QFileInfo>
#include <QSignalMapper>
#include <QTimer>
#include <QTextBlock>
#include <QMenu>
#include <QComboBox>
#include <QFileInfo>
#include <QHeaderView>
#include <QInputDialog>
#include <QToolBar>
#include <QTextBlock>
#include <QTimer>
#include <QTreeView>
#include <QSharedPointer>
using namespace GLSL;
using namespace GLSLEditor;
......@@ -143,6 +136,7 @@ void Document::addRange(const QTextCursor &cursor, GLSL::Scope *scope)
GlslEditorWidget::GlslEditorWidget(const TextEditor::BaseTextDocumentPtr &doc)
{
setTextDocument(doc);
setAutoCompleter(new GLSLCompleter);
m_outlineCombo = 0;
setParenthesesMatchingEnabled(true);
......@@ -206,7 +200,6 @@ bool GlslEditorWidget::isOutdated() const
Core::IEditor *GlslEditor::duplicate()
{
GlslEditorWidget *newEditor = new GlslEditorWidget(editorWidget()->textDocumentPtr());
TextEditor::TextEditorSettings::initializeEditor(newEditor);
return newEditor->editor();
}
......
......@@ -48,7 +48,6 @@ GlslEditor::GlslEditor()
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::CppStyle);
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<GLSLCompletionAssistProvider>());
setAutoCompleter(new GLSLCompleter);
}
} // namespace Internal
......
......@@ -66,10 +66,8 @@ GLSLEditorFactory::GLSLEditorFactory(QObject *parent)
Core::IEditor *GLSLEditorFactory::createEditor()
{
TextEditor::BaseTextDocumentPtr doc(new TextEditor::BaseTextDocument);
doc->setId(C_GLSLEDITOR_ID);
TextEditor::BaseTextDocumentPtr doc(new TextEditor::BaseTextDocument(C_GLSLEDITOR_ID));
doc->setIndenter(new GLSLIndenter);
GlslEditorWidget *rc = new GlslEditorWidget(doc);
TextEditor::TextEditorSettings::initializeEditor(rc);
return rc->editor();
}
......@@ -40,7 +40,6 @@
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <QFileInfo>
......@@ -58,7 +57,6 @@ PythonEditor::PythonEditor()
Core::IEditor *PythonEditor::duplicate()
{
PythonEditorWidget *widget = new PythonEditorWidget(editorWidget()->textDocumentPtr());
TextEditor::TextEditorSettings::initializeEditor(widget);
return widget->editor();
}
......
......@@ -36,9 +36,6 @@
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorsettings.h>
#include <QDebug>
using namespace TextEditor;
......@@ -64,7 +61,6 @@ Core::IEditor *EditorFactory::createEditor()
doc->setId(Constants::C_PYTHONEDITOR_ID);
doc->setIndenter(new PythonIndenter);
PythonEditorWidget *widget = new PythonEditorWidget(doc);
TextEditor::TextEditorSettings::initializeEditor(widget);
return widget->editor();
}
......
......@@ -36,13 +36,8 @@
#include <extensionsystem/pluginmanager.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorsettings.h>
#include <QFileInfo>
#include <QDir>
#include <QSharedPointer>
#include <QTextBlock>
namespace QmakeProjectManager {
......@@ -65,7 +60,6 @@ Core::IEditor *ProFileEditor::duplicate()
{
ProFileEditorWidget *ret = new ProFileEditorWidget;
ret->setTextDocument(editorWidget()->textDocumentPtr());
TextEditor::TextEditorSettings::initializeEditor(ret);
return ret->editor();
}
......
......@@ -36,7 +36,6 @@
#include <qtsupport/qtsupportconstants.h>
#include <coreplugin/fileiconprovider.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorsettings.h>
#include <QCoreApplication>
......@@ -67,6 +66,5 @@ Core::IEditor *ProFileEditorFactory::createEditor()
{
ProFileEditorWidget *editor = new ProFileEditorWidget;
editor->setTextDocument(TextEditor::BaseTextDocumentPtr(new ProFileDocument));
TextEditor::TextEditorSettings::initializeEditor(editor);
return editor->editor();
}
......@@ -29,6 +29,7 @@
#include "qmljseditor.h"
#include "qmljsautocompleter.h"
#include "qmljseditoreditable.h"
#include "qmljseditorconstants.h"
#include "qmljseditordocument.h"
......@@ -58,7 +59,6 @@
#include <texteditor/fontsettings.h>
#include <texteditor/tabsettings.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/syntaxhighlighter.h>
#include <texteditor/refactoroverlay.h>
#include <texteditor/codeassist/genericproposal.h>
......@@ -100,6 +100,7 @@ namespace Internal {
QmlJSTextEditorWidget::QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr doc)
{
setTextDocument(doc);
setAutoCompleter(new AutoCompleter);
m_qmlJsEditorDocument = static_cast<QmlJSEditorDocument *>(doc.data());
m_outlineCombo = 0;
......@@ -169,7 +170,6 @@ QModelIndex QmlJSTextEditorWidget::outlineModelIndex()
IEditor *QmlJSEditor::duplicate()
{
QmlJSTextEditorWidget *newEditor = new QmlJSTextEditorWidget(editorWidget()->textDocumentPtr());
TextEditor::TextEditorSettings::initializeEditor(newEditor);
return newEditor->editor();
}
......
......@@ -56,7 +56,6 @@ QmlJSEditor::QmlJSEditor()
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::CppStyle);
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<Internal::QmlJSCompletionAssistProvider>());
setAutoCompleter(new AutoCompleter);
}
bool QmlJSEditor::isDesignModePreferred() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment