forked from qt-creator/qt-creator
TextEditor: Remove indenter construction from PlainTextEditorWidget
Do it in the users "that know" and remove the special constructor case. Change-Id: I9298c8d13118068adc7958c0894dccb7af4d7855 Reviewed-by: Christian Stenger <christian.stenger@digia.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -101,7 +101,7 @@ public:
|
||||
|
||||
// Open file
|
||||
QScopedPointer<TextEditor::BaseTextEditorWidget> editorWidget(
|
||||
new TextEditor::PlainTextEditorWidget);
|
||||
new TextEditor::PlainTextEditorWidget(new TextEditor::PlainTextDocument));
|
||||
QString error;
|
||||
editorWidget->open(&error, document->fileName(), document->fileName());
|
||||
QVERIFY(error.isEmpty());
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <texteditor/plaintexteditor.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
#include <texteditor/normalindenter.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace Qnx;
|
||||
@@ -165,7 +166,9 @@ void BarDescriptorEditorWidget::initAssetsPage()
|
||||
|
||||
void BarDescriptorEditorWidget::initSourcePage()
|
||||
{
|
||||
m_xmlSourceWidget = new TextEditor::PlainTextEditorWidget(this);
|
||||
auto doc = new TextEditor::PlainTextDocument;
|
||||
doc->setIndenter(new TextEditor::NormalIndenter);
|
||||
m_xmlSourceWidget = new TextEditor::PlainTextEditorWidget(doc, this);
|
||||
addWidget(m_xmlSourceWidget);
|
||||
|
||||
TextEditor::TextEditorSettings::initializeEditor(m_xmlSourceWidget);
|
||||
|
||||
@@ -66,14 +66,6 @@ PlainTextEditor::PlainTextEditor(PlainTextEditorWidget *editor)
|
||||
setDuplicateSupported(true);
|
||||
}
|
||||
|
||||
PlainTextEditorWidget::PlainTextEditorWidget(QWidget *parent)
|
||||
: BaseTextEditorWidget(new PlainTextDocument(), parent)
|
||||
{
|
||||
// Currently only "normal" indentation is supported.
|
||||
baseTextDocument()->setIndenter(new NormalIndenter);
|
||||
ctor();
|
||||
}
|
||||
|
||||
PlainTextEditorWidget::PlainTextEditorWidget(PlainTextDocument *doc, QWidget *parent)
|
||||
: BaseTextEditorWidget(doc, parent)
|
||||
{
|
||||
|
||||
@@ -59,7 +59,6 @@ class TEXTEDITOR_EXPORT PlainTextEditorWidget : public BaseTextEditorWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlainTextEditorWidget(QWidget *parent = 0);
|
||||
PlainTextEditorWidget(PlainTextDocument *doc, QWidget *parent = 0);
|
||||
PlainTextEditorWidget(PlainTextEditorWidget *other);
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "plaintexteditorfactory.h"
|
||||
#include "plaintexteditor.h"
|
||||
#include "basetextdocument.h"
|
||||
#include "normalindenter.h"
|
||||
#include "texteditoractionhandler.h"
|
||||
#include "texteditorconstants.h"
|
||||
#include "texteditorplugin.h"
|
||||
@@ -60,12 +61,14 @@ PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent)
|
||||
|
||||
Core::IEditor *PlainTextEditorFactory::createEditor()
|
||||
{
|
||||
PlainTextEditorWidget *rc = new PlainTextEditorWidget();
|
||||
TextEditorSettings::initializeEditor(rc);
|
||||
connect(rc, SIGNAL(configured(Core::IEditor*)),
|
||||
auto doc = new PlainTextDocument;
|
||||
doc->setIndenter(new NormalIndenter);
|
||||
auto widget = new PlainTextEditorWidget(doc);
|
||||
TextEditorSettings::initializeEditor(widget);
|
||||
connect(widget, SIGNAL(configured(Core::IEditor*)),
|
||||
this, SLOT(updateEditorInfoBar(Core::IEditor*)));
|
||||
updateEditorInfoBar(rc->editor());
|
||||
return rc->editor();
|
||||
updateEditorInfoBar(widget->editor());
|
||||
return widget->editor();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user