TextEditor: Remove one stack of EditorWidget constructors

There are conceptually only two: one that operates a new document,
and one that shares one. Being explicit makes moving data over to
the Editor hierarchy easier. Convenience can be re-added there,
later.

Change-Id: I9b34ff26628c99ffff01201dcf99332d5e7253e9
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
hjk
2014-07-31 14:44:42 +02:00
parent 73d41589ab
commit f5b0bd32b2
16 changed files with 38 additions and 48 deletions

View File

@@ -31,6 +31,7 @@
#include "pythoneditorconstants.h"
#include "pythoneditorwidget.h"
#include "pythoneditorplugin.h"
#include "tools/pythonindenter.h"
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
@@ -39,6 +40,8 @@
#include <QDebug>
using namespace TextEditor;
namespace PythonEditor {
namespace Internal {
@@ -57,7 +60,10 @@ EditorFactory::EditorFactory(QObject *parent)
Core::IEditor *EditorFactory::createEditor()
{
PythonEditorWidget *widget = new PythonEditorWidget();
auto doc = new BaseTextDocument;
doc->setId(Constants::C_PYTHONEDITOR_ID);
doc->setIndenter(new PythonIndenter);
PythonEditorWidget *widget = new PythonEditorWidget(doc, 0);
TextEditor::TextEditorSettings::initializeEditor(widget);
return widget->editor();

View File

@@ -35,7 +35,6 @@
#include "pythoneditorwidget.h"
#include "tools/pythonhighlighter.h"
#include "tools/pythonindenter.h"
#include "pythoneditor.h"
#include "pythoneditorconstants.h"
@@ -48,11 +47,9 @@
namespace PythonEditor {
namespace Internal {
PythonEditorWidget::PythonEditorWidget(QWidget *parent)
: TextEditor::BaseTextEditorWidget(parent)
PythonEditorWidget::PythonEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent)
: TextEditor::BaseTextEditorWidget(doc, parent)
{
baseTextDocument()->setId(Constants::C_PYTHONEDITOR_ID);
baseTextDocument()->setIndenter(new PythonIndenter());
ctor();
}

View File

@@ -40,7 +40,7 @@ class PythonEditorWidget : public TextEditor::BaseTextEditorWidget
Q_OBJECT
public:
PythonEditorWidget(QWidget *parent = 0);
PythonEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent);
PythonEditorWidget(PythonEditorWidget *other);
protected: