summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-08-19 12:12:45 +0200
committerhjk <hjk121@nokiamail.com>2014-08-20 13:28:44 +0200
commitcb35594800a2f6d567ba78b8ed329f5eff8dfacd (patch)
tree31b2fe952017eff98a97931190054eff033162c5
parentb25c575b22f060f50f4d2382de6473dec83ad2ce (diff)
downloadqt-creator-cb35594800a2f6d567ba78b8ed329f5eff8dfacd.tar.gz
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: Christian Stenger <christian.stenger@digia.com>
-rw-r--r--src/plugins/android/androidmanifesteditorwidget.cpp2
-rw-r--r--src/plugins/android/javaeditor.cpp4
-rw-r--r--src/plugins/android/javaeditorfactory.cpp2
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditor.cpp2
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp2
-rw-r--r--src/plugins/cppeditor/cppdocumentationcommenthelper.cpp2
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp4
-rw-r--r--src/plugins/cppeditor/cppeditorplugin.cpp4
-rw-r--r--src/plugins/cppeditor/cppsnippetprovider.cpp2
-rw-r--r--src/plugins/designer/formeditorw.cpp2
-rw-r--r--src/plugins/genericprojectmanager/genericprojectfileseditor.cpp4
-rw-r--r--src/plugins/glsleditor/glsleditor.cpp15
-rw-r--r--src/plugins/glsleditor/glsleditoreditable.cpp1
-rw-r--r--src/plugins/glsleditor/glsleditorfactory.cpp4
-rw-r--r--src/plugins/pythoneditor/pythoneditor.cpp2
-rw-r--r--src/plugins/pythoneditor/pythoneditorfactory.cpp4
-rw-r--r--src/plugins/qmakeprojectmanager/profileeditor.cpp6
-rw-r--r--src/plugins/qmakeprojectmanager/profileeditorfactory.cpp2
-rw-r--r--src/plugins/qmljseditor/qmljseditor.cpp4
-rw-r--r--src/plugins/qmljseditor/qmljseditoreditable.cpp1
-rw-r--r--src/plugins/qmljseditor/qmljseditorfactory.cpp2
-rw-r--r--src/plugins/qmljseditor/qmljssnippetprovider.cpp2
-rw-r--r--src/plugins/qnx/bardescriptoreditorwidget.cpp2
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp74
-rw-r--r--src/plugins/texteditor/basetexteditor.h7
-rw-r--r--src/plugins/texteditor/plaintexteditorfactory.cpp10
-rw-r--r--src/plugins/texteditor/texteditorsettings.cpp42
-rw-r--r--src/plugins/texteditor/texteditorsettings.h5
-rw-r--r--src/plugins/vcsbase/basevcseditorfactory.cpp2
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.cpp2
30 files changed, 73 insertions, 144 deletions
diff --git a/src/plugins/android/androidmanifesteditorwidget.cpp b/src/plugins/android/androidmanifesteditorwidget.cpp
index e1da129b47..b023a8c978 100644
--- a/src/plugins/android/androidmanifesteditorwidget.cpp
+++ b/src/plugins/android/androidmanifesteditorwidget.cpp
@@ -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();
diff --git a/src/plugins/android/javaeditor.cpp b/src/plugins/android/javaeditor.cpp
index 532127749d..1520c9dd34 100644
--- a/src/plugins/android/javaeditor.cpp
+++ b/src/plugins/android/javaeditor.cpp
@@ -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()
diff --git a/src/plugins/android/javaeditorfactory.cpp b/src/plugins/android/javaeditorfactory.cpp
index 3a634467f2..14cb04c82e 100644
--- a/src/plugins/android/javaeditorfactory.cpp
+++ b/src/plugins/android/javaeditorfactory.cpp
@@ -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();
}
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
index 739808d943..ad5cb4350d 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
@@ -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();
}
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp
index d6a6f96570..3174dc1fd1 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp
@@ -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();
}
diff --git a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp
index 2dadacfe63..82b14fa25c 100644
--- a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp
+++ b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp
@@ -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:
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 37a8ab5e67..05cb2beaa1 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -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()
diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp
index e060fe402d..a12f542793 100644
--- a/src/plugins/cppeditor/cppeditorplugin.cpp
+++ b/src/plugins/cppeditor/cppeditorplugin.cpp
@@ -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)));
diff --git a/src/plugins/cppeditor/cppsnippetprovider.cpp b/src/plugins/cppeditor/cppsnippetprovider.cpp
index 0b28166002..2d560363ab 100644
--- a/src/plugins/cppeditor/cppsnippetprovider.cpp
+++ b/src/plugins/cppeditor/cppsnippetprovider.cpp
@@ -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);
}
diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp
index d4b680d5e0..4a39c8f33b 100644
--- a/src/plugins/designer/formeditorw.cpp
+++ b/src/plugins/designer/formeditorw.cpp
@@ -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()));
diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
index e286fcac18..8244e47ec9 100644
--- a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
+++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
@@ -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();
}
diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp
index c32b95832a..c9fcbe1ebd 100644
--- a/src/plugins/glsleditor/glsleditor.cpp
+++ b/src/plugins/glsleditor/glsleditor.cpp
@@ -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();
}
diff --git a/src/plugins/glsleditor/glsleditoreditable.cpp b/src/plugins/glsleditor/glsleditoreditable.cpp
index 3a86a54817..e1ec3172e4 100644
--- a/src/plugins/glsleditor/glsleditoreditable.cpp
+++ b/src/plugins/glsleditor/glsleditoreditable.cpp
@@ -48,7 +48,6 @@ GlslEditor::GlslEditor()
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::CppStyle);
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<GLSLCompletionAssistProvider>());
- setAutoCompleter(new GLSLCompleter);
}
} // namespace Internal
diff --git a/src/plugins/glsleditor/glsleditorfactory.cpp b/src/plugins/glsleditor/glsleditorfactory.cpp
index a492c6758b..edadb40181 100644
--- a/src/plugins/glsleditor/glsleditorfactory.cpp
+++ b/src/plugins/glsleditor/glsleditorfactory.cpp
@@ -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();
}
diff --git a/src/plugins/pythoneditor/pythoneditor.cpp b/src/plugins/pythoneditor/pythoneditor.cpp
index 0522fcbc3b..367ccb6f77 100644
--- a/src/plugins/pythoneditor/pythoneditor.cpp
+++ b/src/plugins/pythoneditor/pythoneditor.cpp
@@ -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();
}
diff --git a/src/plugins/pythoneditor/pythoneditorfactory.cpp b/src/plugins/pythoneditor/pythoneditorfactory.cpp
index 25089e6fb0..af4d0bd9fe 100644
--- a/src/plugins/pythoneditor/pythoneditorfactory.cpp
+++ b/src/plugins/pythoneditor/pythoneditorfactory.cpp
@@ -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();
}
diff --git a/src/plugins/qmakeprojectmanager/profileeditor.cpp b/src/plugins/qmakeprojectmanager/profileeditor.cpp
index 37c06aac16..14ccf433fb 100644
--- a/src/plugins/qmakeprojectmanager/profileeditor.cpp
+++ b/src/plugins/qmakeprojectmanager/profileeditor.cpp
@@ -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();
}
diff --git a/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp b/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp
index 8dee30c499..eec75c7857 100644
--- a/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp
+++ b/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp
@@ -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();
}
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index 24ec29c96e..411dcb2220 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -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();
}
diff --git a/src/plugins/qmljseditor/qmljseditoreditable.cpp b/src/plugins/qmljseditor/qmljseditoreditable.cpp
index 81f7f23caa..dfec522d26 100644
--- a/src/plugins/qmljseditor/qmljseditoreditable.cpp
+++ b/src/plugins/qmljseditor/qmljseditoreditable.cpp
@@ -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
diff --git a/src/plugins/qmljseditor/qmljseditorfactory.cpp b/src/plugins/qmljseditor/qmljseditorfactory.cpp
index 6b76c10c7f..d781686ae1 100644
--- a/src/plugins/qmljseditor/qmljseditorfactory.cpp
+++ b/src/plugins/qmljseditor/qmljseditorfactory.cpp
@@ -36,7 +36,6 @@
#include <qmljstools/qmljstoolsconstants.h>
#include <texteditor/texteditoractionhandler.h>
-#include <texteditor/texteditorsettings.h>
#include <QCoreApplication>
@@ -66,7 +65,6 @@ QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent)
Core::IEditor *QmlJSEditorFactory::createEditor()
{
QmlJSTextEditorWidget *rc = new QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr(new QmlJSEditorDocument));
- TextEditor::TextEditorSettings::initializeEditor(rc);
return rc->editor();
}
diff --git a/src/plugins/qmljseditor/qmljssnippetprovider.cpp b/src/plugins/qmljseditor/qmljssnippetprovider.cpp
index 83ec7eb6ec..0766ff13e9 100644
--- a/src/plugins/qmljseditor/qmljssnippetprovider.cpp
+++ b/src/plugins/qmljseditor/qmljssnippetprovider.cpp
@@ -66,5 +66,5 @@ void QmlJSSnippetProvider::decorateEditor(TextEditor::SnippetEditorWidget *edito
{
editor->setSyntaxHighlighter(new Highlighter);
editor->textDocument()->setIndenter(new Indenter);
- editor->editor()->setAutoCompleter(new AutoCompleter);
+ editor->setAutoCompleter(new AutoCompleter);
}
diff --git a/src/plugins/qnx/bardescriptoreditorwidget.cpp b/src/plugins/qnx/bardescriptoreditorwidget.cpp
index efda173dc4..fb9f547472 100644
--- a/src/plugins/qnx/bardescriptoreditorwidget.cpp
+++ b/src/plugins/qnx/bardescriptoreditorwidget.cpp
@@ -49,7 +49,6 @@
#include <projectexplorer/taskhub.h>
#include <texteditor/basetextdocument.h>
#include <texteditor/basetexteditor.h>
-#include <texteditor/texteditorsettings.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/normalindenter.h>
#include <utils/qtcassert.h>
@@ -178,7 +177,6 @@ void BarDescriptorEditorWidget::initSourcePage()
m_xmlSourceWidget->setupAsPlainEditor();
addWidget(m_xmlSourceWidget);
- TextEditor::TextEditorSettings::initializeEditor(m_xmlSourceWidget);
m_xmlSourceWidget->configureMimeType(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE));
}
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 74abd72c60..80258f3d2e 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -189,7 +189,6 @@ class BaseTextEditorPrivate
{
public:
BaseTextEditorPrivate()
- : m_autoCompleter(new AutoCompleter)
{}
// Note: This is always a copy of IContext::m_widget.
@@ -197,7 +196,6 @@ public:
CommentDefinition m_commentDefinition;
std::function<CompletionAssistProvider *()> m_completionAssistProvider;
- QScopedPointer<AutoCompleter> m_autoCompleter;
};
class BaseTextEditorWidgetPrivate : public QObject
@@ -206,9 +204,6 @@ public:
BaseTextEditorWidgetPrivate(BaseTextEditorWidget *parent);
~BaseTextEditorWidgetPrivate() { delete m_toolBar; }
- // FIXME: Remove after relevant members have been moved to BaseTextEditorPrivate
- BaseTextEditorPrivate *dd() { return q->editor()->d; }
-
void setupDocumentSignals();
void updateLineSelectionColor();
@@ -399,6 +394,8 @@ public:
QScopedPointer<Internal::ClipboardAssistProvider> m_clipboardAssistProvider;
bool m_isMissingSyntaxDefinition;
+
+ QScopedPointer<AutoCompleter> m_autoCompleter;
};
BaseTextEditorWidgetPrivate::BaseTextEditorWidgetPrivate(BaseTextEditorWidget *parent)
@@ -451,7 +448,8 @@ BaseTextEditorWidgetPrivate::BaseTextEditorWidgetPrivate(BaseTextEditorWidget *p
m_blockCount(0),
m_markDragging(false),
m_clipboardAssistProvider(new Internal::ClipboardAssistProvider),
- m_isMissingSyntaxDefinition(false)
+ m_isMissingSyntaxDefinition(false),
+ m_autoCompleter(new AutoCompleter)
{
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
BaseTextFind *baseTextFind = new BaseTextFind(q);
@@ -2026,7 +2024,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
cursor.beginEditBlock();
int extraBlocks =
- dd()->m_autoCompleter->paragraphSeparatorAboutToBeInserted(cursor,
+ d->m_autoCompleter->paragraphSeparatorAboutToBeInserted(cursor,
d->m_document->tabSettings());
QString previousIndentationString;
@@ -2226,7 +2224,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
case Qt::Key_Insert:
if (ro) break;
if (e->modifiers() == Qt::NoModifier) {
- AutoCompleter *ac = dd()->m_autoCompleter.data();
+ AutoCompleter *ac = d->m_autoCompleter.data();
if (inOverwriteMode) {
ac->setAutoParenthesesEnabled(d->autoParenthesisOverwriteBackup);
ac->setSurroundWithEnabled(d->surroundWithEnabledOverwriteBackup);
@@ -2285,7 +2283,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
// only go here if control is not pressed, except if also alt is pressed
// because AltGr maps to Alt + Ctrl
QTextCursor cursor = textCursor();
- const QString &autoText = dd()->m_autoCompleter->autoComplete(cursor, eventText);
+ const QString &autoText = d->m_autoCompleter->autoComplete(cursor, eventText);
QChar electricChar;
if (d->m_document->typingSettings().m_autoIndent) {
@@ -2325,7 +2323,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
//Select the inserted text, to be able to re-indent the inserted text
cursor.setPosition(pos, QTextCursor::KeepAnchor);
}
- if (!electricChar.isNull() && dd()->m_autoCompleter->contextAllowsElectricCharacters(cursor))
+ if (!electricChar.isNull() && d->m_autoCompleter->contextAllowsElectricCharacters(cursor))
d->m_document->autoIndent(cursor, electricChar);
if (!autoText.isEmpty())
cursor.setPosition(autoText.length() == 1 ? cursor.position() : cursor.anchor());
@@ -2800,12 +2798,12 @@ int BaseTextEditorWidget::visibleWrapColumn() const
return d->m_visibleWrapColumn;
}
-void BaseTextEditor::setAutoCompleter(AutoCompleter *autoCompleter)
+void BaseTextEditorWidget::setAutoCompleter(AutoCompleter *autoCompleter)
{
d->m_autoCompleter.reset(autoCompleter);
}
-AutoCompleter *BaseTextEditor::autoCompleter() const
+AutoCompleter *BaseTextEditorWidget::autoCompleter() const
{
return d->m_autoCompleter.data();
}
@@ -2847,8 +2845,44 @@ void BaseTextEditorWidgetPrivate::setupDocumentSignals()
this, &BaseTextEditorWidgetPrivate::applyFontSettingsDelayed);
slotUpdateExtraAreaWidth();
-}
+ TextEditorSettings *settings = TextEditorSettings::instance();
+
+ // Connect to settings change signals
+ connect(settings, &TextEditorSettings::fontSettingsChanged,
+ m_document.data(), &BaseTextDocument::setFontSettings);
+ connect(settings, &TextEditorSettings::typingSettingsChanged,
+ q, &BaseTextEditorWidget::setTypingSettings);
+ connect(settings, &TextEditorSettings::storageSettingsChanged,
+ q, &BaseTextEditorWidget::setStorageSettings);
+ connect(settings, &TextEditorSettings::behaviorSettingsChanged,
+ q, &BaseTextEditorWidget::setBehaviorSettings);
+ connect(settings, &TextEditorSettings::marginSettingsChanged,
+ q, &BaseTextEditorWidget::setMarginSettings);
+ connect(settings, &TextEditorSettings::displaySettingsChanged,
+ q, &BaseTextEditorWidget::setDisplaySettings);
+ connect(settings, &TextEditorSettings::completionSettingsChanged,
+ q, &BaseTextEditorWidget::setCompletionSettings);
+ connect(settings, &TextEditorSettings::extraEncodingSettingsChanged,
+ q, &BaseTextEditorWidget::setExtraEncodingSettings);
+
+ connect(q, &BaseTextEditorWidget::requestFontZoom,
+ settings, &TextEditorSettings::fontZoomRequested);
+ connect(q, &BaseTextEditorWidget::requestZoomReset,
+ settings, &TextEditorSettings::zoomResetRequested);
+
+ // Apply current settings
+ m_document->setFontSettings(settings->fontSettings());
+ m_document->setTabSettings(settings->codeStyle()->tabSettings()); // also set through code style ???
+ q->setTypingSettings(settings->typingSettings());
+ q->setStorageSettings(settings->storageSettings());
+ q->setBehaviorSettings(settings->behaviorSettings());
+ q->setMarginSettings(settings->marginSettings());
+ q->setDisplaySettings(settings->displaySettings());
+ q->setCompletionSettings(settings->completionSettings());
+ q->setExtraEncodingSettings(settings->extraEncodingSettings());
+ q->setCodeStyle(settings->codeStyle(q->languageSettingsId()));
+}
bool BaseTextEditorWidgetPrivate::snippetCheckCursor(const QTextCursor &cursor)
{
@@ -5159,7 +5193,7 @@ void BaseTextEditorWidgetPrivate::handleBackspaceKey()
const TextEditor::TabSettings &tabSettings = m_document->tabSettings();
const TextEditor::TypingSettings &typingSettings = m_document->typingSettings();
- if (typingSettings.m_autoIndent && dd()->m_autoCompleter->autoBackspace(cursor))
+ if (typingSettings.m_autoIndent && m_autoCompleter->autoBackspace(cursor))
return;
bool handled = false;
@@ -6102,8 +6136,8 @@ void BaseTextEditorWidget::setStorageSettings(const StorageSettings &storageSett
void BaseTextEditorWidget::setCompletionSettings(const TextEditor::CompletionSettings &completionSettings)
{
- dd()->m_autoCompleter->setAutoParenthesesEnabled(completionSettings.m_autoInsertBrackets);
- dd()->m_autoCompleter->setSurroundWithEnabled(completionSettings.m_autoInsertBrackets
+ d->m_autoCompleter->setAutoParenthesesEnabled(completionSettings.m_autoInsertBrackets);
+ d->m_autoCompleter->setSurroundWithEnabled(completionSettings.m_autoInsertBrackets
&& completionSettings.m_surroundingAutoBrackets);
}
@@ -6729,11 +6763,6 @@ void BaseTextEditorWidget::doFoo()
#endif
}
-BaseTextEditorPrivate *BaseTextEditorWidget::dd() const
-{
- return editor()->d;
-}
-
BaseTextBlockSelection::BaseTextBlockSelection(const BaseTextBlockSelection &other)
{
positionBlock = other.positionBlock;
@@ -7110,10 +7139,9 @@ void BaseTextEditorWidget::setupAsPlainEditor()
IEditor *BaseTextEditor::duplicate()
{
- auto newWidget = new BaseTextEditorWidget(0);
+ auto newWidget = new BaseTextEditorWidget;
newWidget->setTextDocument(editorWidget()->textDocumentPtr());
newWidget->setupAsPlainEditor();
- TextEditorSettings::initializeEditor(newWidget);
auto editor = newWidget->editor();
editor->setContext(Core::Context(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index e9e42f53da..2e0ee1367a 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -189,9 +189,6 @@ public:
// There should be something simpler.
void setCompletionAssistProvider(const std::function<CompletionAssistProvider *()> &provider);
- void setAutoCompleter(AutoCompleter *autoCompleter);
- AutoCompleter *autoCompleter() const;
-
signals:
void markRequested(TextEditor::BaseTextEditor *editor, int line, TextEditor::BaseTextEditor::MarkRequestKind kind);
void markContextMenuRequested(TextEditor::BaseTextEditor *editor, int line, QMenu *menu);
@@ -238,6 +235,9 @@ public:
void appendStandardContextMenuActions(QMenu *menu);
+ void setAutoCompleter(AutoCompleter *autoCompleter);
+ AutoCompleter *autoCompleter() const;
+
// Works only in conjunction with a syntax highlighter that puts
// parentheses into text block user data
void setParenthesesMatchingEnabled(bool b);
@@ -591,7 +591,6 @@ protected slots:
private:
Internal::BaseTextEditorWidgetPrivate *d;
- Internal::BaseTextEditorPrivate *dd() const;
friend class BaseTextEditor;
friend class Internal::BaseTextEditorWidgetPrivate;
friend class Internal::TextEditorOverlay;
diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp
index f14dce2685..40d6e5daa5 100644
--- a/src/plugins/texteditor/plaintexteditorfactory.cpp
+++ b/src/plugins/texteditor/plaintexteditorfactory.cpp
@@ -61,15 +61,13 @@ PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent)
Core::IEditor *PlainTextEditorFactory::createEditor()
{
- BaseTextDocumentPtr doc(new BaseTextDocument);
- doc->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
+ BaseTextDocumentPtr doc(new BaseTextDocument(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID));
doc->setIndenter(new NormalIndenter);
- auto widget = new BaseTextEditorWidget(0);
+ auto widget = new BaseTextEditorWidget;
widget->setTextDocument(doc);
widget->setupAsPlainEditor();
- TextEditorSettings::initializeEditor(widget);
- connect(widget, SIGNAL(configured(Core::IEditor*)),
- this, SLOT(updateEditorInfoBar(Core::IEditor*)));
+ connect(widget, &BaseTextEditorWidget::configured,
+ this, &PlainTextEditorFactory::updateEditorInfoBar);
updateEditorInfoBar(widget->editor());
return widget->editor();
}
diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp
index 274a63a11a..2a5e98eeb1 100644
--- a/src/plugins/texteditor/texteditorsettings.cpp
+++ b/src/plugins/texteditor/texteditorsettings.cpp
@@ -329,48 +329,6 @@ TextEditorSettings *TextEditorSettings::instance()
return m_instance;
}
-/**
- * Initializes editor settings. Also connects signals to keep them up to date
- * when they are changed.
- */
-void TextEditorSettings::initializeEditor(BaseTextEditorWidget *editor)
-{
- // Connect to settings change signals
- connect(m_instance, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
- editor->textDocument(), SLOT(setFontSettings(TextEditor::FontSettings)));
- connect(m_instance, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
- editor, SLOT(setTypingSettings(TextEditor::TypingSettings)));
- connect(m_instance, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
- editor, SLOT(setStorageSettings(TextEditor::StorageSettings)));
- connect(m_instance, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
- editor, SLOT(setBehaviorSettings(TextEditor::BehaviorSettings)));
- connect(m_instance, SIGNAL(marginSettingsChanged(TextEditor::MarginSettings)),
- editor, SLOT(setMarginSettings(TextEditor::MarginSettings)));
- connect(m_instance, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
- editor, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
- connect(m_instance, SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)),
- editor, SLOT(setCompletionSettings(TextEditor::CompletionSettings)));
- connect(m_instance, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)),
- editor, SLOT(setExtraEncodingSettings(TextEditor::ExtraEncodingSettings)));
-
- connect(editor, SIGNAL(requestFontZoom(int)),
- m_instance, SLOT(fontZoomRequested(int)));
- connect(editor, SIGNAL(requestZoomReset()),
- m_instance, SLOT(zoomResetRequested()));
-
- // Apply current settings
- editor->textDocument()->setFontSettings(fontSettings());
- editor->textDocument()->setTabSettings(codeStyle()->tabSettings()); // also set through code style ???
- editor->setTypingSettings(typingSettings());
- editor->setStorageSettings(storageSettings());
- editor->setBehaviorSettings(behaviorSettings());
- editor->setMarginSettings(marginSettings());
- editor->setDisplaySettings(displaySettings());
- editor->setCompletionSettings(completionSettings());
- editor->setExtraEncodingSettings(extraEncodingSettings());
- editor->setCodeStyle(codeStyle(editor->languageSettingsId()));
-}
-
const FontSettings &TextEditorSettings::fontSettings()
{
return d->m_fontSettingsPage->fontSettings();
diff --git a/src/plugins/texteditor/texteditorsettings.h b/src/plugins/texteditor/texteditorsettings.h
index 7a7a779a16..119eefce5e 100644
--- a/src/plugins/texteditor/texteditorsettings.h
+++ b/src/plugins/texteditor/texteditorsettings.h
@@ -43,7 +43,6 @@ QT_END_NAMESPACE
namespace TextEditor {
-class BaseTextEditorWidget;
class FontSettings;
class TabSettings;
class TypingSettings;
@@ -73,8 +72,6 @@ public:
static TextEditorSettings *instance();
- static void initializeEditor(BaseTextEditorWidget *editor);
-
static const FontSettings &fontSettings();
static const TypingSettings &typingSettings();
static const StorageSettings &storageSettings();
@@ -116,7 +113,7 @@ signals:
void completionSettingsChanged(const TextEditor::CompletionSettings &);
void extraEncodingSettingsChanged(const TextEditor::ExtraEncodingSettings &);
-private slots:
+public slots:
void fontZoomRequested(int zoom);
void zoomResetRequested();
};
diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp
index 39c1d0a43c..7328991329 100644
--- a/src/plugins/vcsbase/basevcseditorfactory.cpp
+++ b/src/plugins/vcsbase/basevcseditorfactory.cpp
@@ -31,7 +31,6 @@
#include "vcsbaseeditor.h"
#include <texteditor/texteditoractionhandler.h>
-#include <texteditor/texteditorsettings.h>
#include <diffeditor/diffeditorconstants.h>
@@ -90,7 +89,6 @@ Core::IEditor *BaseVcsEditorFactory::createEditor()
if (!mimeTypes().isEmpty())
vcsEditor->textDocument()->setMimeType(mimeTypes().front());
- TextEditor::TextEditorSettings::initializeEditor(vcsEditor);
return vcsEditor->editor();
}
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index 9205ccfbe6..ba9f689f00 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -44,7 +44,6 @@
#include <projectexplorer/session.h>
#include <texteditor/basetextdocument.h>
#include <texteditor/basetextdocumentlayout.h>
-#include <texteditor/texteditorsettings.h>
#include <utils/qtcassert.h>
#include <QDebug>
@@ -715,7 +714,6 @@ void VcsBaseEditorWidget::init()
setCodeFoldingSupported(true);
textDocument()->setSyntaxHighlighter(dh);
}
- TextEditor::TextEditorSettings::initializeEditor(this);
// override revisions display (green or red bar on the left, marking changes):
setRevisionsVisible(false);
}