From 306ca6fce07fca984960c825178df3ae7eb46b6a Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 25 Aug 2014 21:10:24 +0200 Subject: [PATCH] TextEditor: Remove parts of old editor creation sequence Not used anymore. Change-Id: Iee0f6340097341bd584ae559e3f40f0c1364cba3 Reviewed-by: Christian Stenger --- src/plugins/texteditor/basetexteditor.cpp | 45 ++------------------ src/plugins/texteditor/basetexteditor.h | 23 ++++------ src/plugins/vcsbase/basevcseditorfactory.cpp | 4 +- src/plugins/vcsbase/basevcseditorfactory.h | 2 +- 4 files changed, 15 insertions(+), 59 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index c30b0eaaa7a..c7bcbe5371b 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -230,10 +230,6 @@ class BaseTextEditorPrivate public: BaseTextEditorPrivate() {} - BaseTextDocumentCreator m_documentCreator; - BaseTextEditorWidgetCreator m_editorWidgetCreator; - BaseTextEditorCreator m_editorCreator; - CommentDefinition m_commentDefinition; std::function m_completionAssistProvider; @@ -6594,21 +6590,6 @@ BaseTextEditor::~BaseTextEditor() delete d; } -void BaseTextEditor::setEditorCreator(const BaseTextEditorCreator &creator) -{ - d->m_editorCreator = creator; -} - -void BaseTextEditor::setDocumentCreator(const BaseTextDocumentCreator &creator) -{ - d->m_documentCreator = creator; -} - -void BaseTextEditor::setWidgetCreator(const BaseTextEditorWidgetCreator &creator) -{ - d->m_editorWidgetCreator = creator; -} - BaseTextDocument *BaseTextEditor::textDocument() { ensureDocument(); @@ -7190,15 +7171,6 @@ IEditor *BaseTextEditor::duplicate() if (d->m_origin) return d->m_origin->duplicateTextEditor(this); - // Use old setup if that's available. - if (d->m_editorCreator) { - BaseTextEditor *editor = d->m_editorCreator(); - BaseTextEditorWidget *widget = editor->ensureWidget(); - widget->setTextDocument(editorWidget()->textDocumentPtr()); - m_widget = widget; - return editor; - } - // If neither is sufficient, you need to implement 'YourEditor::duplicate'. QTC_CHECK(false); return 0; @@ -7211,15 +7183,6 @@ QWidget *BaseTextEditor::widget() const BaseTextEditorWidget *BaseTextEditor::ensureWidget() const { - if (m_widget.isNull()) { - QTC_ASSERT(!d->m_origin, return 0); // New style always sets it. - QTC_ASSERT(d->m_editorWidgetCreator, return 0); - BaseTextEditorWidget *widget = d->m_editorWidgetCreator(); - auto that = const_cast(this); - widget->d->m_editor = that; - that->m_widget = widget; - widget->d->m_codeAssistant.configure(that); - } return editorWidget(); } @@ -7228,8 +7191,6 @@ BaseTextDocumentPtr BaseTextEditor::ensureDocument() BaseTextEditorWidget *widget = ensureWidget(); if (widget->d->m_document.isNull()) { QTC_ASSERT(!d->m_origin, return BaseTextDocumentPtr()); // New style always sets it. - QTC_ASSERT(d->m_documentCreator, return BaseTextDocumentPtr()); - widget->setTextDocument(BaseTextDocumentPtr(d->m_documentCreator())); } return widget->textDocumentPtr(); } @@ -7246,17 +7207,17 @@ BaseTextEditorFactory::BaseTextEditorFactory(QObject *parent) m_widgetCreator = []() { return new BaseTextEditorWidget; }; } -void BaseTextEditorFactory::setDocumentCreator(const BaseTextDocumentCreator &creator) +void BaseTextEditorFactory::setDocumentCreator(const DocumentCreator &creator) { m_documentCreator = creator; } -void BaseTextEditorFactory::setEditorWidgetCreator(const BaseTextEditorWidgetCreator &creator) +void BaseTextEditorFactory::setEditorWidgetCreator(const EditorWidgetCreator &creator) { m_widgetCreator = creator; } -void BaseTextEditorFactory::setEditorCreator(const BaseTextEditorCreator &creator) +void BaseTextEditorFactory::setEditorCreator(const EditorCreator &creator) { m_editorCreator = creator; } diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index a52d3ce1af8..96bac2379bc 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -109,10 +109,6 @@ private: int _last; }; -typedef std::function BaseTextEditorCreator; -typedef std::function BaseTextDocumentCreator; -typedef std::function BaseTextEditorWidgetCreator; - class TEXTEDITOR_EXPORT BaseTextEditor : public Core::IEditor { Q_OBJECT @@ -131,10 +127,6 @@ public: virtual void finalizeInitialization() {} - void setEditorCreator(const BaseTextEditorCreator &creator); - void setDocumentCreator(const BaseTextDocumentCreator &creator); - void setWidgetCreator(const BaseTextEditorWidgetCreator &creator); - void setEditorWidget(BaseTextEditorWidget *editorWidget); enum MarkRequestKind { @@ -628,13 +620,16 @@ class TEXTEDITOR_EXPORT BaseTextEditorFactory : public Core::IEditorFactory public: BaseTextEditorFactory(QObject *parent = 0); + typedef std::function EditorCreator; + typedef std::function DocumentCreator; + typedef std::function EditorWidgetCreator; typedef std::function SyntaxHighLighterCreator; typedef std::function IndenterCreator; typedef std::function AutoCompleterCreator; - void setDocumentCreator(const BaseTextDocumentCreator &creator); - void setEditorWidgetCreator(const BaseTextEditorWidgetCreator &creator); - void setEditorCreator(const BaseTextEditorCreator &creator); + void setDocumentCreator(const DocumentCreator &creator); + void setEditorWidgetCreator(const EditorWidgetCreator &creator); + void setEditorCreator(const EditorCreator &creator); void setIndenterCreator(const IndenterCreator &creator); void setSyntaxHighlighterCreator(const SyntaxHighLighterCreator &creator); void setGenericSyntaxHighlighter(const QString &mimeType); @@ -650,9 +645,9 @@ private: BaseTextEditor *createEditorHelper(const BaseTextDocumentPtr &doc); BaseTextEditor *duplicateTextEditor(BaseTextEditor *); - BaseTextDocumentCreator m_documentCreator; - BaseTextEditorWidgetCreator m_widgetCreator; - BaseTextEditorCreator m_editorCreator; + DocumentCreator m_documentCreator; + EditorWidgetCreator m_widgetCreator; + EditorCreator m_editorCreator; AutoCompleterCreator m_autoCompleterCreator; IndenterCreator m_indenterCreator; SyntaxHighLighterCreator m_syntaxHighlighterCreator; diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp index e3afefd605d..eb21627fb14 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.cpp +++ b/src/plugins/vcsbase/basevcseditorfactory.cpp @@ -57,13 +57,13 @@ public: const VcsBaseEditorParameters *m_parameters; QObject *m_describeReceiver; const char *m_describeSlot; - BaseTextEditorWidgetCreator m_widgetCreator; + BaseTextEditorFactory::EditorWidgetCreator m_widgetCreator; }; } // namespace Internal VcsEditorFactory::VcsEditorFactory(const VcsBaseEditorParameters *parameters, - const BaseTextEditorWidgetCreator &creator, + const BaseTextEditorFactory::EditorWidgetCreator &creator, QObject *describeReceiver, const char *describeSlot) : d(new Internal::BaseVcsEditorFactoryPrivate) { diff --git a/src/plugins/vcsbase/basevcseditorfactory.h b/src/plugins/vcsbase/basevcseditorfactory.h index befafe30aa1..e88cf68be7e 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.h +++ b/src/plugins/vcsbase/basevcseditorfactory.h @@ -45,7 +45,7 @@ class VCSBASE_EXPORT VcsEditorFactory : public Core::IEditorFactory public: VcsEditorFactory(const VcsBaseEditorParameters *type, - const TextEditor::BaseTextEditorWidgetCreator &creator, + const TextEditor::BaseTextEditorFactory::EditorWidgetCreator &creator, QObject *describeReceiver, const char *describeSlot); ~VcsEditorFactory();