Commit cb355948 authored by hjk's avatar hjk

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
......
......@@ -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();
}
......
......@@ -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);
}
......@@ -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));
}
......
......@@ -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));
......
......@@ -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;
......
......@@ -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);