Commit 01822144 authored by hjk's avatar hjk
Browse files

TextEditor: Remove indenter construction from PlainTextEditorWidget



Do it in the users "that know" and remove the special constructor case.

Change-Id: I9298c8d13118068adc7958c0894dccb7af4d7855
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent fde176e5
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
// Open file // Open file
QScopedPointer<TextEditor::BaseTextEditorWidget> editorWidget( QScopedPointer<TextEditor::BaseTextEditorWidget> editorWidget(
new TextEditor::PlainTextEditorWidget); new TextEditor::PlainTextEditorWidget(new TextEditor::PlainTextDocument));
QString error; QString error;
editorWidget->open(&error, document->fileName(), document->fileName()); editorWidget->open(&error, document->fileName(), document->fileName());
QVERIFY(error.isEmpty()); QVERIFY(error.isEmpty());
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include <texteditor/plaintexteditor.h> #include <texteditor/plaintexteditor.h>
#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorsettings.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <texteditor/normalindenter.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
using namespace Qnx; using namespace Qnx;
...@@ -165,7 +166,9 @@ void BarDescriptorEditorWidget::initAssetsPage() ...@@ -165,7 +166,9 @@ void BarDescriptorEditorWidget::initAssetsPage()
void BarDescriptorEditorWidget::initSourcePage() 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); addWidget(m_xmlSourceWidget);
TextEditor::TextEditorSettings::initializeEditor(m_xmlSourceWidget); TextEditor::TextEditorSettings::initializeEditor(m_xmlSourceWidget);
......
...@@ -66,14 +66,6 @@ PlainTextEditor::PlainTextEditor(PlainTextEditorWidget *editor) ...@@ -66,14 +66,6 @@ PlainTextEditor::PlainTextEditor(PlainTextEditorWidget *editor)
setDuplicateSupported(true); 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) PlainTextEditorWidget::PlainTextEditorWidget(PlainTextDocument *doc, QWidget *parent)
: BaseTextEditorWidget(doc, parent) : BaseTextEditorWidget(doc, parent)
{ {
......
...@@ -59,7 +59,6 @@ class TEXTEDITOR_EXPORT PlainTextEditorWidget : public BaseTextEditorWidget ...@@ -59,7 +59,6 @@ class TEXTEDITOR_EXPORT PlainTextEditorWidget : public BaseTextEditorWidget
Q_OBJECT Q_OBJECT
public: public:
PlainTextEditorWidget(QWidget *parent = 0);
PlainTextEditorWidget(PlainTextDocument *doc, QWidget *parent = 0); PlainTextEditorWidget(PlainTextDocument *doc, QWidget *parent = 0);
PlainTextEditorWidget(PlainTextEditorWidget *other); PlainTextEditorWidget(PlainTextEditorWidget *other);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "plaintexteditorfactory.h" #include "plaintexteditorfactory.h"
#include "plaintexteditor.h" #include "plaintexteditor.h"
#include "basetextdocument.h" #include "basetextdocument.h"
#include "normalindenter.h"
#include "texteditoractionhandler.h" #include "texteditoractionhandler.h"
#include "texteditorconstants.h" #include "texteditorconstants.h"
#include "texteditorplugin.h" #include "texteditorplugin.h"
...@@ -60,12 +61,14 @@ PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent) ...@@ -60,12 +61,14 @@ PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent)
Core::IEditor *PlainTextEditorFactory::createEditor() Core::IEditor *PlainTextEditorFactory::createEditor()
{ {
PlainTextEditorWidget *rc = new PlainTextEditorWidget(); auto doc = new PlainTextDocument;
TextEditorSettings::initializeEditor(rc); doc->setIndenter(new NormalIndenter);
connect(rc, SIGNAL(configured(Core::IEditor*)), auto widget = new PlainTextEditorWidget(doc);
TextEditorSettings::initializeEditor(widget);
connect(widget, SIGNAL(configured(Core::IEditor*)),
this, SLOT(updateEditorInfoBar(Core::IEditor*))); this, SLOT(updateEditorInfoBar(Core::IEditor*)));
updateEditorInfoBar(rc->editor()); updateEditorInfoBar(widget->editor());
return rc->editor(); return widget->editor();
} }
/*! /*!
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment