forked from qt-creator/qt-creator
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:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user