summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-07-31 14:44:42 +0200
committerhjk <hjk121@nokiamail.com>2014-08-01 14:10:23 +0200
commitf5b0bd32b20fc1e37f95b412252b597b9936dda7 (patch)
treecfc1caf4b8adb4a1b3cbc6380ef6d009039d6ade /src
parent73d41589ab1aeb3be2593045618fc15e4592c17b (diff)
downloadqt-creator-f5b0bd32b20fc1e37f95b412252b597b9936dda7.tar.gz
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>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp2
-rw-r--r--src/plugins/diffeditor/diffeditor.cpp2
-rw-r--r--src/plugins/diffeditor/selectabletexteditorwidget.cpp3
-rw-r--r--src/plugins/genericprojectmanager/genericprojectfileseditor.cpp19
-rw-r--r--src/plugins/genericprojectmanager/genericprojectfileseditor.h7
-rw-r--r--src/plugins/glsleditor/glsleditor.cpp10
-rw-r--r--src/plugins/glsleditor/glsleditor.h3
-rw-r--r--src/plugins/glsleditor/glsleditorfactory.cpp6
-rw-r--r--src/plugins/pythoneditor/pythoneditorfactory.cpp8
-rw-r--r--src/plugins/pythoneditor/pythoneditorwidget.cpp7
-rw-r--r--src/plugins/pythoneditor/pythoneditorwidget.h2
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp7
-rw-r--r--src/plugins/texteditor/basetexteditor.h3
-rw-r--r--src/plugins/texteditor/plaintexteditorfactory.cpp2
-rw-r--r--src/plugins/texteditor/snippets/snippeteditor.cpp3
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.cpp2
16 files changed, 38 insertions, 48 deletions
diff --git a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
index 03619884bc..b0781dac35 100644
--- a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
+++ b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
@@ -104,7 +104,7 @@ public:
// Open file
auto textDocument = new TextEditor::BaseTextDocument;
textDocument->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
- TextEditor::BaseTextEditorWidget editorWidget(textDocument);
+ TextEditor::BaseTextEditorWidget editorWidget(textDocument, 0);
editorWidget.setupAsPlainEditor();
QString error;
editorWidget.open(&error, document->fileName(), document->fileName());
diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp
index 34d75a2bbc..3b1bb16a8a 100644
--- a/src/plugins/diffeditor/diffeditor.cpp
+++ b/src/plugins/diffeditor/diffeditor.cpp
@@ -101,7 +101,7 @@ private:
};
DescriptionEditorWidget::DescriptionEditorWidget(QWidget *parent)
- : BaseTextEditorWidget(parent)
+ : BaseTextEditorWidget(new BaseTextDocument, parent)
{
DisplaySettings settings = displaySettings();
settings.m_textWrapping = false;
diff --git a/src/plugins/diffeditor/selectabletexteditorwidget.cpp b/src/plugins/diffeditor/selectabletexteditorwidget.cpp
index 91e31b0e8c..cc906cd154 100644
--- a/src/plugins/diffeditor/selectabletexteditorwidget.cpp
+++ b/src/plugins/diffeditor/selectabletexteditorwidget.cpp
@@ -28,6 +28,7 @@
****************************************************************************/
#include "selectabletexteditorwidget.h"
+#include <texteditor/basetextdocument.h>
#include <QPainter>
#include <QTextBlock>
@@ -35,7 +36,7 @@
namespace DiffEditor {
SelectableTextEditorWidget::SelectableTextEditorWidget(QWidget *parent)
- : BaseTextEditorWidget(parent)
+ : BaseTextEditorWidget(new TextEditor::BaseTextDocument, parent)
{
setFrameStyle(QFrame::NoFrame);
}
diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
index 05f285e67c..143e2fa927 100644
--- a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
+++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
@@ -64,9 +64,9 @@ ProjectFilesFactory::ProjectFilesFactory(Manager *manager)
Core::IEditor *ProjectFilesFactory::createEditor()
{
- ProjectFilesEditorWidget *ed = new ProjectFilesEditorWidget();
- TextEditorSettings::initializeEditor(ed);
- return ed->editor();
+ auto widget = new ProjectFilesEditorWidget(new BaseTextDocument, 0);
+ TextEditorSettings::initializeEditor(widget);
+ return widget->editor();
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -85,10 +85,9 @@ ProjectFilesEditor::ProjectFilesEditor(ProjectFilesEditorWidget *editor)
Core::IEditor *ProjectFilesEditor::duplicate()
{
- ProjectFilesEditorWidget *editor = new ProjectFilesEditorWidget(
- qobject_cast<ProjectFilesEditorWidget *>(editorWidget()));
- TextEditorSettings::initializeEditor(editor);
- return editor->editor();
+ auto widget = new ProjectFilesEditorWidget(editorWidget());
+ TextEditorSettings::initializeEditor(widget);
+ return widget->editor();
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -97,12 +96,12 @@ Core::IEditor *ProjectFilesEditor::duplicate()
//
////////////////////////////////////////////////////////////////////////////////////////
-ProjectFilesEditorWidget::ProjectFilesEditorWidget(QWidget *parent)
- : BaseTextEditorWidget(parent)
+ProjectFilesEditorWidget::ProjectFilesEditorWidget(BaseTextDocument *doc, QWidget *parent)
+ : BaseTextEditorWidget(doc, parent)
{
}
-ProjectFilesEditorWidget::ProjectFilesEditorWidget(ProjectFilesEditorWidget *other)
+ProjectFilesEditorWidget::ProjectFilesEditorWidget(BaseTextEditorWidget *other)
: BaseTextEditorWidget(other)
{
}
diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.h b/src/plugins/genericprojectmanager/genericprojectfileseditor.h
index 8c74f26dbc..755161abe0 100644
--- a/src/plugins/genericprojectmanager/genericprojectfileseditor.h
+++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.h
@@ -67,13 +67,10 @@ class ProjectFilesEditorWidget : public TextEditor::BaseTextEditorWidget
Q_OBJECT
public:
- ProjectFilesEditorWidget(QWidget *parent = 0);
- ProjectFilesEditorWidget(ProjectFilesEditorWidget *other);
+ ProjectFilesEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent);
+ ProjectFilesEditorWidget(BaseTextEditorWidget *other);
TextEditor::BaseTextEditor *createEditor();
-
-private:
- ProjectFilesEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
};
} // namespace Internal
diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp
index 4509c00512..9bc953cc05 100644
--- a/src/plugins/glsleditor/glsleditor.cpp
+++ b/src/plugins/glsleditor/glsleditor.cpp
@@ -140,11 +140,9 @@ void Document::addRange(const QTextCursor &cursor, GLSL::Scope *scope)
_cursors.append(c);
}
-GlslEditorWidget::GlslEditorWidget(QWidget *parent)
- : TextEditor::BaseTextEditorWidget(parent)
+GlslEditorWidget::GlslEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent)
+ : TextEditor::BaseTextEditorWidget(doc, parent)
{
- baseTextDocument()->setId(GLSLEditor::Constants::C_GLSLEDITOR_ID);
- baseTextDocument()->setIndenter(new GLSLIndenter());
ctor();
}
@@ -180,10 +178,6 @@ void GlslEditorWidget::ctor()
// }
}
-GlslEditorWidget::~GlslEditorWidget()
-{
-}
-
int GlslEditorWidget::editorRevision() const
{
//return document()->revision();
diff --git a/src/plugins/glsleditor/glsleditor.h b/src/plugins/glsleditor/glsleditor.h
index 64f67d5c78..39f185a754 100644
--- a/src/plugins/glsleditor/glsleditor.h
+++ b/src/plugins/glsleditor/glsleditor.h
@@ -86,9 +86,8 @@ class GlslEditorWidget : public TextEditor::BaseTextEditorWidget
Q_OBJECT
public:
- GlslEditorWidget(QWidget *parent = 0);
+ GlslEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent);
GlslEditorWidget(GlslEditorWidget *other);
- ~GlslEditorWidget();
int editorRevision() const;
bool isOutdated() const;
diff --git a/src/plugins/glsleditor/glsleditorfactory.cpp b/src/plugins/glsleditor/glsleditorfactory.cpp
index b66d83052c..5393d1834e 100644
--- a/src/plugins/glsleditor/glsleditorfactory.cpp
+++ b/src/plugins/glsleditor/glsleditorfactory.cpp
@@ -32,6 +32,7 @@
#include "glsleditor.h"
#include "glsleditorconstants.h"
#include "glsleditorplugin.h"
+#include "glslindenter.h"
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
@@ -65,7 +66,10 @@ GLSLEditorFactory::GLSLEditorFactory(QObject *parent)
Core::IEditor *GLSLEditorFactory::createEditor()
{
- GlslEditorWidget *rc = new GlslEditorWidget();
+ auto doc = new TextEditor::BaseTextDocument;
+ doc->setId(C_GLSLEDITOR_ID);
+ doc->setIndenter(new GLSLIndenter);
+ GlslEditorWidget *rc = new GlslEditorWidget(doc, 0);
TextEditor::TextEditorSettings::initializeEditor(rc);
return rc->editor();
}
diff --git a/src/plugins/pythoneditor/pythoneditorfactory.cpp b/src/plugins/pythoneditor/pythoneditorfactory.cpp
index 483309899c..8a3c19e232 100644
--- a/src/plugins/pythoneditor/pythoneditorfactory.cpp
+++ b/src/plugins/pythoneditor/pythoneditorfactory.cpp
@@ -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();
diff --git a/src/plugins/pythoneditor/pythoneditorwidget.cpp b/src/plugins/pythoneditor/pythoneditorwidget.cpp
index 495ba2158d..2fcf5a2c6e 100644
--- a/src/plugins/pythoneditor/pythoneditorwidget.cpp
+++ b/src/plugins/pythoneditor/pythoneditorwidget.cpp
@@ -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();
}
diff --git a/src/plugins/pythoneditor/pythoneditorwidget.h b/src/plugins/pythoneditor/pythoneditorwidget.h
index 37b1d46405..c182e195ad 100644
--- a/src/plugins/pythoneditor/pythoneditorwidget.h
+++ b/src/plugins/pythoneditor/pythoneditorwidget.h
@@ -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:
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index cdad9c2392..a4276f1a4c 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -455,13 +455,6 @@ QString BaseTextEditorWidget::convertToPlainText(const QString &txt)
static const char kTextBlockMimeType[] = "application/vnd.qtcreator.blocktext";
-BaseTextEditorWidget::BaseTextEditorWidget(QWidget *parent)
- : QPlainTextEdit(parent)
-{
- d = new BaseTextEditorWidgetPrivate(this);
- d->ctor(QSharedPointer<BaseTextDocument>(new BaseTextDocument));
-}
-
BaseTextEditorWidget::BaseTextEditorWidget(BaseTextDocument *doc, QWidget *parent)
: QPlainTextEdit(parent)
{
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index 21b1457a03..acd15505f4 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -225,8 +225,7 @@ class TEXTEDITOR_EXPORT BaseTextEditorWidget : public QPlainTextEdit
Q_PROPERTY(int verticalBlockSelectionLastColumn READ verticalBlockSelectionLastColumn)
public:
- BaseTextEditorWidget(QWidget *parent = 0);
- BaseTextEditorWidget(BaseTextDocument *doc, QWidget *parent = 0);
+ BaseTextEditorWidget(BaseTextDocument *doc, QWidget *parent);
BaseTextEditorWidget(BaseTextEditorWidget *other);
~BaseTextEditorWidget();
diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp
index 2bcbc2a0fc..6266e75db8 100644
--- a/src/plugins/texteditor/plaintexteditorfactory.cpp
+++ b/src/plugins/texteditor/plaintexteditorfactory.cpp
@@ -64,7 +64,7 @@ Core::IEditor *PlainTextEditorFactory::createEditor()
auto doc = new BaseTextDocument;
doc->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
doc->setIndenter(new NormalIndenter);
- auto widget = new BaseTextEditorWidget(doc);
+ auto widget = new BaseTextEditorWidget(doc, 0);
widget->setupAsPlainEditor();
TextEditorSettings::initializeEditor(widget);
connect(widget, SIGNAL(configured(Core::IEditor*)),
diff --git a/src/plugins/texteditor/snippets/snippeteditor.cpp b/src/plugins/texteditor/snippets/snippeteditor.cpp
index 72e7665f30..140468be44 100644
--- a/src/plugins/texteditor/snippets/snippeteditor.cpp
+++ b/src/plugins/texteditor/snippets/snippeteditor.cpp
@@ -49,7 +49,8 @@ SnippetEditor::SnippetEditor(SnippetEditorWidget *editor)
setContext(Core::Context(Constants::SNIPPET_EDITOR_ID, Constants::C_TEXTEDITOR));
}
-SnippetEditorWidget::SnippetEditorWidget(QWidget *parent) : BaseTextEditorWidget(parent)
+SnippetEditorWidget::SnippetEditorWidget(QWidget *parent)
+ : BaseTextEditorWidget(new BaseTextDocument, parent)
{
baseTextDocument()->setId(Constants::SNIPPET_EDITOR_ID);
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index 1aca147ab1..f2407f3d19 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -648,7 +648,7 @@ QComboBox *VcsBaseEditorWidgetPrivate::entriesComboBox()
*/
VcsBaseEditorWidget::VcsBaseEditorWidget(const VcsBaseEditorParameters *type, QWidget *parent)
- : BaseTextEditorWidget(parent),
+ : BaseTextEditorWidget(new TextEditor::BaseTextDocument, parent),
d(new Internal::VcsBaseEditorWidgetPrivate(this, type))
{
viewport()->setMouseTracking(true);