summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-08-19 00:54:45 +0200
committerhjk <hjk121@nokiamail.com>2014-08-19 10:32:12 +0200
commitc5fae0e8dac0a5a5466d8cc3bb0bc81ce2d625b8 (patch)
treeb75d2581adb69730cbd5dd4ddf3ce004d2b500e4 /src
parentd2ec7d80d92952262b164068b52f63e39e259f7c (diff)
downloadqt-creator-c5fae0e8dac0a5a5466d8cc3bb0bc81ce2d625b8.tar.gz
TextEditor: Further *Editor/*EditorWidget disentangling
In most cases, the *Editor constructor does not need to access the *EditorWidget. Change-Id: I1f5c076a0f723d5d82b398e8c250c7bd1d47eb17 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/android/javaeditor.cpp6
-rw-r--r--src/plugins/android/javaeditor.h3
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditor.cpp8
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditor.h5
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp5
-rw-r--r--src/plugins/cppeditor/cppeditor.h3
-rw-r--r--src/plugins/designer/formwindoweditor.cpp6
-rw-r--r--src/plugins/diffeditor/diffeditor.cpp9
-rw-r--r--src/plugins/diffeditor/diffeditor.h1
-rw-r--r--src/plugins/diffeditor/selectabletexteditorwidget.cpp3
-rw-r--r--src/plugins/diffeditor/selectabletexteditorwidget.h3
-rw-r--r--src/plugins/diffeditor/sidebysidediffeditorwidget.cpp7
-rw-r--r--src/plugins/diffeditor/unifieddiffeditorwidget.cpp14
-rw-r--r--src/plugins/genericprojectmanager/genericprojectfileseditor.cpp8
-rw-r--r--src/plugins/genericprojectmanager/genericprojectfileseditor.h2
-rw-r--r--src/plugins/glsleditor/glsleditor.cpp2
-rw-r--r--src/plugins/glsleditor/glsleditoreditable.cpp3
-rw-r--r--src/plugins/glsleditor/glsleditoreditable.h4
-rw-r--r--src/plugins/pythoneditor/pythoneditor.cpp3
-rw-r--r--src/plugins/pythoneditor/pythoneditor.h4
-rw-r--r--src/plugins/pythoneditor/pythoneditorwidget.cpp2
-rw-r--r--src/plugins/qmakeprojectmanager/profileeditor.cpp6
-rw-r--r--src/plugins/qmakeprojectmanager/profileeditor.h2
-rw-r--r--src/plugins/qmljseditor/qmljseditor.cpp10
-rw-r--r--src/plugins/qmljseditor/qmljseditor.h2
-rw-r--r--src/plugins/qmljseditor/qmljseditoreditable.cpp3
-rw-r--r--src/plugins/qmljseditor/qmljseditoreditable.h2
-rw-r--r--src/plugins/texteditor/basetextdocument.cpp5
-rw-r--r--src/plugins/texteditor/basetextdocument.h3
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp22
-rw-r--r--src/plugins/texteditor/basetexteditor.h5
-rw-r--r--src/plugins/texteditor/snippets/snippeteditor.cpp5
-rw-r--r--src/plugins/texteditor/snippets/snippeteditor.h2
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.cpp8
34 files changed, 77 insertions, 99 deletions
diff --git a/src/plugins/android/javaeditor.cpp b/src/plugins/android/javaeditor.cpp
index 2e4a72eb39..532127749d 100644
--- a/src/plugins/android/javaeditor.cpp
+++ b/src/plugins/android/javaeditor.cpp
@@ -49,8 +49,7 @@ using namespace Android::Internal;
// JavaEditor
//
-JavaEditor::JavaEditor(JavaEditorWidget *editor)
- : BaseTextEditor(editor)
+JavaEditor::JavaEditor()
{
setContext(Core::Context(Constants::C_JAVA_EDITOR,
TextEditor::Constants::C_TEXTEDITOR));
@@ -78,7 +77,7 @@ JavaEditorWidget::JavaEditorWidget()
TextEditor::BaseTextEditor *JavaEditorWidget::createEditor()
{
- return new JavaEditor(this);
+ return new JavaEditor;
}
//
@@ -86,7 +85,6 @@ TextEditor::BaseTextEditor *JavaEditorWidget::createEditor()
//
JavaDocument::JavaDocument()
- : TextEditor::BaseTextDocument()
{
setId(Constants::JAVA_EDITOR_ID);
setMimeType(QLatin1String(Constants::JAVA_MIMETYPE));
diff --git a/src/plugins/android/javaeditor.h b/src/plugins/android/javaeditor.h
index fd5e216e9d..058cde57ee 100644
--- a/src/plugins/android/javaeditor.h
+++ b/src/plugins/android/javaeditor.h
@@ -38,14 +38,13 @@ namespace Android {
namespace Internal {
class JavaEditorFactory;
-class JavaEditorWidget;
class JavaEditor : public TextEditor::BaseTextEditor
{
Q_OBJECT
public:
- JavaEditor(JavaEditorWidget *);
+ JavaEditor();
Core::IEditor *duplicate();
TextEditor::CompletionAssistProvider *completionAssistProvider();
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
index 52e5de75ec..739808d943 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
@@ -57,15 +57,13 @@ using namespace CMakeProjectManager::Internal;
// ProFileEditorEditable
//
-CMakeEditor::CMakeEditor(CMakeEditorWidget *editor)
- : BaseTextEditor(editor)
+CMakeEditor::CMakeEditor()
{
setContext(Core::Context(CMakeProjectManager::Constants::C_CMAKEEDITOR,
TextEditor::Constants::C_TEXTEDITOR));
setDuplicateSupported(true);
setCommentStyle(Utils::CommentDefinition::HashStyle);
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<CMakeFileCompletionAssistProvider>());
- connect(document(), SIGNAL(changed()), this, SLOT(markAsChanged()));
}
Core::IEditor *CMakeEditor::duplicate()
@@ -157,7 +155,9 @@ CMakeEditorWidget::CMakeEditorWidget()
TextEditor::BaseTextEditor *CMakeEditorWidget::createEditor()
{
- return new CMakeEditor(this);
+ auto editor = new CMakeEditor;
+ connect(textDocument(), &Core::IDocument::changed, editor, &CMakeEditor::markAsChanged);
+ return editor;
}
void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e)
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.h b/src/plugins/cmakeprojectmanager/cmakeeditor.h
index fee92e1971..ffe82b418d 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.h
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.h
@@ -50,12 +50,13 @@ class CMakeEditor : public TextEditor::BaseTextEditor
Q_OBJECT
public:
- CMakeEditor(CMakeEditorWidget *);
+ CMakeEditor();
Core::IEditor *duplicate();
-
QString contextHelpId() const;
+ friend class CMakeEditorWidget;
+
private slots:
void markAsChanged();
void build();
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 1d42d9bae3..c20c7ef5be 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -105,8 +105,7 @@ QTimer *newSingleShotTimer(QObject *parent, int msecInterval)
namespace CppEditor {
namespace Internal {
-CPPEditor::CPPEditor(CppEditorWidget *editor)
- : BaseTextEditor(editor)
+CPPEditor::CPPEditor()
{
m_context.add(CppEditor::Constants::C_CPPEDITOR);
m_context.add(ProjectExplorer::Constants::LANG_CXX);
@@ -263,7 +262,7 @@ CppEditorOutline *CppEditorWidget::outline() const
TextEditor::BaseTextEditor *CppEditorWidget::createEditor()
{
- return new CPPEditor(this);
+ return new CPPEditor;
}
void CppEditorWidget::paste()
diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h
index 91de8e456f..9bf513e7e8 100644
--- a/src/plugins/cppeditor/cppeditor.h
+++ b/src/plugins/cppeditor/cppeditor.h
@@ -50,7 +50,6 @@ namespace CppEditor {
namespace Internal {
class CppEditorOutline;
-class CppEditorWidget;
class CppEditorWidgetPrivate;
class FollowSymbolUnderCursor;
@@ -59,7 +58,7 @@ class CPPEditor : public TextEditor::BaseTextEditor
Q_OBJECT
public:
- CPPEditor(CppEditorWidget *);
+ CPPEditor();
Core::IEditor *duplicate() QTC_OVERRIDE;
diff --git a/src/plugins/designer/formwindoweditor.cpp b/src/plugins/designer/formwindoweditor.cpp
index cd2d547d65..6038368064 100644
--- a/src/plugins/designer/formwindoweditor.cpp
+++ b/src/plugins/designer/formwindoweditor.cpp
@@ -50,10 +50,10 @@ struct FormWindowEditorPrivate
Internal::DesignerXmlEditorWidget *m_widget;
};
-FormWindowEditor::FormWindowEditor(Internal::DesignerXmlEditorWidget *editor) :
- TextEditor::BaseTextEditor(editor),
- d(new FormWindowEditorPrivate)
+FormWindowEditor::FormWindowEditor(Internal::DesignerXmlEditorWidget *editor)
+ : d(new FormWindowEditorPrivate)
{
+ setEditorWidget(editor);
d->m_widget = editor;
setDuplicateSupported(true);
setContext(Core::Context(Designer::Constants::K_DESIGNER_XML_EDITOR_ID,
diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp
index 3b98173c94..357fbdc2d8 100644
--- a/src/plugins/diffeditor/diffeditor.cpp
+++ b/src/plugins/diffeditor/diffeditor.cpp
@@ -83,12 +83,7 @@ public slots:
void setDisplaySettings(const DisplaySettings &ds);
protected:
- BaseTextEditor *createEditor()
- {
- BaseTextEditor *editor = new BaseTextEditor(this);
- editor->document()->setId("DiffEditor.DescriptionEditor");
- return editor;
- }
+ BaseTextEditor *createEditor() { return new BaseTextEditor; }
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
@@ -103,7 +98,7 @@ private:
DescriptionEditorWidget::DescriptionEditorWidget(QWidget *parent)
: BaseTextEditorWidget(parent)
{
- setTextDocument(BaseTextDocumentPtr(new BaseTextDocument));
+ setSimpleTextDocument("DiffEditor.DescriptionEditor");
DisplaySettings settings = displaySettings();
settings.m_textWrapping = false;
settings.m_displayLineNumbers = false;
diff --git a/src/plugins/diffeditor/diffeditor.h b/src/plugins/diffeditor/diffeditor.h
index 1082b6e654..8be9cb1a81 100644
--- a/src/plugins/diffeditor/diffeditor.h
+++ b/src/plugins/diffeditor/diffeditor.h
@@ -63,7 +63,6 @@ public:
public:
DiffEditorController *controller() const;
- // Core::IEditor
Core::IEditor *duplicate();
bool open(QString *errorString,
diff --git a/src/plugins/diffeditor/selectabletexteditorwidget.cpp b/src/plugins/diffeditor/selectabletexteditorwidget.cpp
index 53e03b3c1f..2c7cdfd103 100644
--- a/src/plugins/diffeditor/selectabletexteditorwidget.cpp
+++ b/src/plugins/diffeditor/selectabletexteditorwidget.cpp
@@ -38,13 +38,12 @@ namespace DiffEditor {
SelectableTextEditorWidget::SelectableTextEditorWidget(QWidget *parent)
: BaseTextEditorWidget(parent)
{
- setTextDocument(TextEditor::BaseTextDocumentPtr(new TextEditor::BaseTextDocument));
+ setSimpleTextDocument("DiffEditor.UnifiedDiffEditor");
setFrameStyle(QFrame::NoFrame);
}
SelectableTextEditorWidget::~SelectableTextEditorWidget()
{
-
}
void SelectableTextEditorWidget::paintEvent(QPaintEvent *e)
diff --git a/src/plugins/diffeditor/selectabletexteditorwidget.h b/src/plugins/diffeditor/selectabletexteditorwidget.h
index 0c0f2d9af9..a58b1eaf74 100644
--- a/src/plugins/diffeditor/selectabletexteditorwidget.h
+++ b/src/plugins/diffeditor/selectabletexteditorwidget.h
@@ -54,8 +54,7 @@ class DIFFEDITOR_EXPORT SelectableTextEditorWidget
public:
SelectableTextEditorWidget(QWidget *parent = 0);
~SelectableTextEditorWidget();
- void setSelections(const QMap<int,
- QList<DiffSelection> > &selections) {
+ void setSelections(const QMap<int, QList<DiffSelection> > &selections) {
m_selections = selections;
}
diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp
index 7a895e9ac8..65bdae387b 100644
--- a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp
+++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp
@@ -78,10 +78,8 @@ class SideDiffEditor : public BaseTextEditor
{
Q_OBJECT
public:
- SideDiffEditor(BaseTextEditorWidget *editorWidget)
- : BaseTextEditor(editorWidget)
+ SideDiffEditor()
{
- document()->setId("DiffEditor.SideDiffEditor");
connect(this, SIGNAL(tooltipRequested(TextEditor::BaseTextEditor*,QPoint,int)),
this, SLOT(slotTooltipRequested(TextEditor::BaseTextEditor*,QPoint,int)));
}
@@ -170,7 +168,7 @@ protected:
return SelectableTextEditorWidget::extraAreaWidth(markWidthPtr);
}
void applyFontSettings();
- BaseTextEditor *createEditor() { return new SideDiffEditor(this); }
+ BaseTextEditor *createEditor() { return new SideDiffEditor; }
virtual QString lineNumber(int blockNumber) const;
virtual int lineNumberDigits() const;
virtual bool selectionVisible(int blockNumber) const;
@@ -326,6 +324,7 @@ SideDiffEditorWidget::SideDiffEditorWidget(QWidget *parent)
m_lineNumberDigits(1),
m_inPaintEvent(false)
{
+ textDocument()->setId("DiffEditor.SideDiffEditor");
DisplaySettings settings = displaySettings();
settings.m_textWrapping = false;
settings.m_displayLineNumbers = true;
diff --git a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp
index be7a4f7782..ffa8351d54 100644
--- a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp
+++ b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp
@@ -71,16 +71,6 @@ using namespace TextEditor;
namespace DiffEditor {
-class UnifiedDiffEditor : public BaseTextEditor
-{
- Q_OBJECT
-public:
- UnifiedDiffEditor(BaseTextEditorWidget *editorWidget)
- : BaseTextEditor(editorWidget) {
- document()->setId("DiffEditor.UnifiedDiffEditor");
- }
-};
-
UnifiedDiffEditorWidget::UnifiedDiffEditorWidget(QWidget *parent)
: SelectableTextEditorWidget(parent)
, m_guiController(0)
@@ -389,7 +379,7 @@ void UnifiedDiffEditorWidget::patch(int diffFileIndex, int chunkIndex, bool reve
TextEditor::BaseTextEditor *UnifiedDiffEditorWidget::createEditor()
{
- return new UnifiedDiffEditor(this);
+ return new BaseTextEditor;
}
void UnifiedDiffEditorWidget::clear(const QString &message)
@@ -844,5 +834,3 @@ void UnifiedDiffEditorWidget::setCurrentDiffFileIndex(int diffFileIndex)
}
} // namespace DiffEditor
-
-#include "unifieddiffeditorwidget.moc"
diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
index 1f2b4ba6cb..e286fcac18 100644
--- a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
+++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
@@ -65,7 +65,7 @@ ProjectFilesFactory::ProjectFilesFactory(Manager *manager)
Core::IEditor *ProjectFilesFactory::createEditor()
{
auto widget = new ProjectFilesEditorWidget;
- widget->setTextDocument(BaseTextDocumentPtr(new BaseTextDocument));
+ widget->setSimpleTextDocument(Constants::FILES_EDITOR_ID);
TextEditorSettings::initializeEditor(widget);
return widget->editor();
}
@@ -76,10 +76,8 @@ Core::IEditor *ProjectFilesFactory::createEditor()
//
////////////////////////////////////////////////////////////////////////////////////////
-ProjectFilesEditor::ProjectFilesEditor(ProjectFilesEditorWidget *editor)
- : BaseTextEditor(editor)
+ProjectFilesEditor::ProjectFilesEditor()
{
- document()->setId(Constants::FILES_EDITOR_ID);
setContext(Core::Context(Constants::C_FILESEDITOR));
setDuplicateSupported(true);
}
@@ -104,7 +102,7 @@ ProjectFilesEditorWidget::ProjectFilesEditorWidget()
BaseTextEditor *ProjectFilesEditorWidget::createEditor()
{
- return new ProjectFilesEditor(this);
+ return new ProjectFilesEditor;
}
} // namespace Internal
diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.h b/src/plugins/genericprojectmanager/genericprojectfileseditor.h
index 803e3bf9a7..5d337230b8 100644
--- a/src/plugins/genericprojectmanager/genericprojectfileseditor.h
+++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.h
@@ -65,7 +65,7 @@ class ProjectFilesEditor : public TextEditor::BaseTextEditor
Q_OBJECT
public:
- ProjectFilesEditor(ProjectFilesEditorWidget *editorWidget);
+ ProjectFilesEditor();
Core::IEditor *duplicate();
};
diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp
index 15398b928b..c32b95832a 100644
--- a/src/plugins/glsleditor/glsleditor.cpp
+++ b/src/plugins/glsleditor/glsleditor.cpp
@@ -232,7 +232,7 @@ QString GlslEditorWidget::wordUnderCursor() const
TextEditor::BaseTextEditor *GlslEditorWidget::createEditor()
{
- return new GlslEditor(this);
+ return new GlslEditor;
}
void GlslEditorWidget::updateDocument()
diff --git a/src/plugins/glsleditor/glsleditoreditable.cpp b/src/plugins/glsleditor/glsleditoreditable.cpp
index 857af69cc8..3a86a54817 100644
--- a/src/plugins/glsleditor/glsleditoreditable.cpp
+++ b/src/plugins/glsleditor/glsleditoreditable.cpp
@@ -41,8 +41,7 @@
namespace GLSLEditor {
namespace Internal {
-GlslEditor::GlslEditor(GlslEditorWidget *editor)
- : BaseTextEditor(editor)
+GlslEditor::GlslEditor()
{
setContext(Core::Context(GLSLEditor::Constants::C_GLSLEDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
diff --git a/src/plugins/glsleditor/glsleditoreditable.h b/src/plugins/glsleditor/glsleditoreditable.h
index 9fdb0e87c3..9c40192bba 100644
--- a/src/plugins/glsleditor/glsleditoreditable.h
+++ b/src/plugins/glsleditor/glsleditoreditable.h
@@ -35,14 +35,12 @@
namespace GLSLEditor {
namespace Internal {
-class GlslEditorWidget;
-
class GlslEditor : public TextEditor::BaseTextEditor
{
Q_OBJECT
public:
- explicit GlslEditor(GlslEditorWidget *);
+ GlslEditor();
Core::IEditor *duplicate();
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
diff --git a/src/plugins/pythoneditor/pythoneditor.cpp b/src/plugins/pythoneditor/pythoneditor.cpp
index f7a85c828b..0522fcbc3b 100644
--- a/src/plugins/pythoneditor/pythoneditor.cpp
+++ b/src/plugins/pythoneditor/pythoneditor.cpp
@@ -47,8 +47,7 @@
namespace PythonEditor {
namespace Internal {
-PythonEditor::PythonEditor(PythonEditorWidget *editorWidget)
- :BaseTextEditor(editorWidget)
+PythonEditor::PythonEditor()
{
setContext(Core::Context(Constants::C_PYTHONEDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
diff --git a/src/plugins/pythoneditor/pythoneditor.h b/src/plugins/pythoneditor/pythoneditor.h
index 6c77597b73..6597d4c5ce 100644
--- a/src/plugins/pythoneditor/pythoneditor.h
+++ b/src/plugins/pythoneditor/pythoneditor.h
@@ -35,14 +35,12 @@
namespace PythonEditor {
namespace Internal {
-class PythonEditorWidget;
-
class PythonEditor : public TextEditor::BaseTextEditor
{
Q_OBJECT
public:
- explicit PythonEditor(PythonEditorWidget *editorWidget);
+ PythonEditor();
Core::IEditor *duplicate();
diff --git a/src/plugins/pythoneditor/pythoneditorwidget.cpp b/src/plugins/pythoneditor/pythoneditorwidget.cpp
index 4a8d1edf59..6d69762d3c 100644
--- a/src/plugins/pythoneditor/pythoneditorwidget.cpp
+++ b/src/plugins/pythoneditor/pythoneditorwidget.cpp
@@ -59,7 +59,7 @@ PythonEditorWidget::PythonEditorWidget(TextEditor::BaseTextDocumentPtr doc)
TextEditor::BaseTextEditor *PythonEditorWidget::createEditor()
{
- return new PythonEditor(this);
+ return new PythonEditor;
}
} // namespace Internal
diff --git a/src/plugins/qmakeprojectmanager/profileeditor.cpp b/src/plugins/qmakeprojectmanager/profileeditor.cpp
index 68822ac301..37c06aac16 100644
--- a/src/plugins/qmakeprojectmanager/profileeditor.cpp
+++ b/src/plugins/qmakeprojectmanager/profileeditor.cpp
@@ -52,8 +52,7 @@ namespace Internal {
// ProFileEditor
//
-ProFileEditor::ProFileEditor(ProFileEditorWidget *editor)
- : BaseTextEditor(editor)
+ProFileEditor::ProFileEditor()
{
setContext(Core::Context(Constants::C_PROFILEEDITOR,
TextEditor::Constants::C_TEXTEDITOR));
@@ -167,7 +166,7 @@ ProFileEditorWidget::Link ProFileEditorWidget::findLinkAt(const QTextCursor &cur
TextEditor::BaseTextEditor *ProFileEditorWidget::createEditor()
{
- return new ProFileEditor(this);
+ return new ProFileEditor;
}
void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e)
@@ -180,7 +179,6 @@ void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e)
//
ProFileDocument::ProFileDocument()
- : TextEditor::BaseTextDocument()
{
setId(Constants::PROFILE_EDITOR_ID);
setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE));
diff --git a/src/plugins/qmakeprojectmanager/profileeditor.h b/src/plugins/qmakeprojectmanager/profileeditor.h
index caa92e2f26..ce27b4bd9c 100644
--- a/src/plugins/qmakeprojectmanager/profileeditor.h
+++ b/src/plugins/qmakeprojectmanager/profileeditor.h
@@ -45,7 +45,7 @@ class ProFileEditor : public TextEditor::BaseTextEditor
Q_OBJECT
public:
- ProFileEditor(ProFileEditorWidget *);
+ ProFileEditor();
Core::IEditor *duplicate();
};
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index 6ce3e637ce..24ec29c96e 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -98,7 +98,6 @@ namespace QmlJSEditor {
namespace Internal {
QmlJSTextEditorWidget::QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr doc)
- : TextEditor::BaseTextEditorWidget(0)
{
setTextDocument(doc);
@@ -151,6 +150,7 @@ QmlJSTextEditorWidget::QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr doc
SLOT(onRefactorMarkerClicked(TextEditor::RefactorMarker)));
setRequestMarkEnabled(true);
+ createToolBar();
}
QmlJSTextEditorWidget::~QmlJSTextEditorWidget()
@@ -529,12 +529,10 @@ bool QmlJSTextEditorWidget::isClosingBrace(const QList<Token> &tokens) const
TextEditor::BaseTextEditor *QmlJSTextEditorWidget::createEditor()
{
- QmlJSEditor *editable = new QmlJSEditor(this);
- createToolBar(editable);
- return editable;
+ return new QmlJSEditor;
}
-void QmlJSTextEditorWidget::createToolBar(QmlJSEditor *editor)
+void QmlJSTextEditorWidget::createToolBar()
{
m_outlineCombo = new QComboBox;
m_outlineCombo->setMinimumContentsLength(22);
@@ -568,7 +566,7 @@ void QmlJSTextEditorWidget::createToolBar(QmlJSEditor *editor)
connect(this, SIGNAL(cursorPositionChanged()), m_updateOutlineIndexTimer, SLOT(start()));
- editor->editorWidget()->insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, m_outlineCombo);
+ insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, m_outlineCombo);
}
TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const QTextCursor &cursor,
diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h
index f67c5e4f5f..9226b067e3 100644
--- a/src/plugins/qmljseditor/qmljseditor.h
+++ b/src/plugins/qmljseditor/qmljseditor.h
@@ -116,7 +116,7 @@ protected:
void scrollContentsBy(int dx, int dy);
void applyFontSettings();
TextEditor::BaseTextEditor *createEditor();
- void createToolBar(QmlJSEditor *editable);
+ void createToolBar();
TextEditor::BaseTextEditorWidget::Link findLinkAt(const QTextCursor &cursor,
bool resolveTarget = true,
bool inNextSplit = false);
diff --git a/src/plugins/qmljseditor/qmljseditoreditable.cpp b/src/plugins/qmljseditor/qmljseditoreditable.cpp
index e2d77d3cf5..81f7f23caa 100644
--- a/src/plugins/qmljseditor/qmljseditoreditable.cpp
+++ b/src/plugins/qmljseditor/qmljseditoreditable.cpp
@@ -48,8 +48,7 @@
namespace QmlJSEditor {
namespace Internal {
-QmlJSEditor::QmlJSEditor(QmlJSTextEditorWidget *editor)
- : BaseTextEditor(editor)
+QmlJSEditor::QmlJSEditor()
{
m_context.add(Constants::C_QMLJSEDITOR_ID);
m_context.add(TextEditor::Constants::C_TEXTEDITOR);
diff --git a/src/plugins/qmljseditor/qmljseditoreditable.h b/src/plugins/qmljseditor/qmljseditoreditable.h
index 32dc6e12b0..f8e108db78 100644
--- a/src/plugins/qmljseditor/qmljseditoreditable.h
+++ b/src/plugins/qmljseditor/qmljseditoreditable.h
@@ -44,7 +44,7 @@ class QmlJSEditor : public TextEditor::BaseTextEditor
Q_OBJECT
public:
- explicit QmlJSEditor(QmlJSTextEditorWidget *);
+ QmlJSEditor();
Core::IEditor *duplicate();
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp
index 48d70f0fd5..7dff24a47c 100644
--- a/src/plugins/texteditor/basetextdocument.cpp
+++ b/src/plugins/texteditor/basetextdocument.cpp
@@ -205,7 +205,7 @@ void BaseTextDocumentPrivate::onModificationChanged(bool modified)
//
///////////////////////////////////////////////////////////////////////
-BaseTextDocument::BaseTextDocument()
+BaseTextDocument::BaseTextDocument(Id id)
: d(new BaseTextDocumentPrivate(this))
{
connect(d->m_document, SIGNAL(modificationChanged(bool)), d, SLOT(onModificationChanged(bool)));
@@ -221,6 +221,9 @@ BaseTextDocument::BaseTextDocument()
d->m_document->setDefaultTextOption(opt);
BaseTextDocumentLayout *documentLayout = new BaseTextDocumentLayout(d->m_document);
d->m_document->setDocumentLayout(documentLayout);
+
+ if (id.isValid())
+ setId(id);
}
BaseTextDocument::~BaseTextDocument()
diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h
index 71c1d428b0..553a7fb24f 100644
--- a/src/plugins/texteditor/basetextdocument.h
+++ b/src/plugins/texteditor/basetextdocument.h
@@ -32,6 +32,7 @@
#include "texteditor_global.h"
+#include <coreplugin/id.h>
#include <coreplugin/textdocument.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
@@ -64,7 +65,7 @@ class TEXTEDITOR_EXPORT BaseTextDocument : public Core::TextDocument
Q_OBJECT
public:
- BaseTextDocument();
+ explicit BaseTextDocument(Core::Id id = Core::Id());
virtual ~BaseTextDocument();
static QMap<QString, QString> openedTextDocumentContents();
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 60ff90a47e..49cae974d1 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -662,6 +662,11 @@ BaseTextEditorWidget::~BaseTextEditorWidget()
d = 0;
}
+void BaseTextEditorWidget::setSimpleTextDocument(Id id)
+{
+ setTextDocument(BaseTextDocumentPtr(new BaseTextDocument(id)));
+}
+
void BaseTextEditorWidget::print(QPrinter *printer)
{
const bool oldFullPage = printer->fullPage();
@@ -874,7 +879,10 @@ int BaseTextEditorWidgetPrivate::visualIndent(const QTextBlock &block) const
BaseTextEditor *BaseTextEditorWidget::editor() const
{
if (!d->m_editor) {
- d->m_editor = const_cast<BaseTextEditorWidget *>(this)->createEditor();
+ auto that = const_cast<BaseTextEditorWidget *>(this);
+ d->m_editor = that->createEditor();
+ if (!d->m_editor->widget())
+ d->m_editor->setEditorWidget(that);
d->m_codeAssistant->configure(d->m_editor);
}
return d->m_editor;
@@ -6473,7 +6481,8 @@ QColor BaseTextEditorWidget::replacementPenColor(int blockNumber) const
BaseTextEditor *BaseTextEditorWidget::createEditor()
{
- auto editor = new BaseTextEditor(this);
+ auto editor = new BaseTextEditor;
+ editor->setEditorWidget(this);
editor->setContext(Core::Context(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
editor->setDuplicateSupported(true);
@@ -6510,13 +6519,16 @@ void BaseTextEditorWidget::appendStandardContextMenuActions(QMenu *menu)
}
-BaseTextEditor::BaseTextEditor(BaseTextEditorWidget *widget)
+BaseTextEditor::BaseTextEditor()
: d(new BaseTextEditorPrivate)
{
+ d->m_completionAssistProvider = [] () -> CompletionAssistProvider * { return 0; };
+}
+
+void BaseTextEditor::setEditorWidget(BaseTextEditorWidget *widget)
+{
setWidget(widget);
d->m_editorWidget = widget;
-
- d->m_completionAssistProvider = [] () -> CompletionAssistProvider * { return 0; };
}
BaseTextEditor::~BaseTextEditor()
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index bfb118fc6f..e9e42f53da 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -117,9 +117,11 @@ public:
EndOfDoc = 5
};
- BaseTextEditor(BaseTextEditorWidget *editorWidget);
+ BaseTextEditor();
~BaseTextEditor();
+ void setEditorWidget(BaseTextEditorWidget *editorWidget);
+
enum MarkRequestKind {
BreakpointRequest,
BookmarkRequest,
@@ -216,6 +218,7 @@ public:
~BaseTextEditorWidget();
void setTextDocument(const BaseTextDocumentPtr &doc);
+ void setSimpleTextDocument(Core::Id id); // Convenience.
BaseTextDocument *textDocument() const;
BaseTextDocumentPtr textDocumentPtr() const;
diff --git a/src/plugins/texteditor/snippets/snippeteditor.cpp b/src/plugins/texteditor/snippets/snippeteditor.cpp
index d59be8a5b4..3c6d23dc8d 100644
--- a/src/plugins/texteditor/snippets/snippeteditor.cpp
+++ b/src/plugins/texteditor/snippets/snippeteditor.cpp
@@ -43,8 +43,7 @@ using namespace TextEditor;
\ingroup Snippets
*/
-SnippetEditor::SnippetEditor(SnippetEditorWidget *editor)
- : BaseTextEditor(editor)
+SnippetEditor::SnippetEditor()
{
setContext(Core::Context(Constants::SNIPPET_EDITOR_ID, Constants::C_TEXTEDITOR));
}
@@ -77,5 +76,5 @@ void SnippetEditorWidget::focusOutEvent(QFocusEvent *event)
BaseTextEditor *SnippetEditorWidget::createEditor()
{
- return new SnippetEditor(this);
+ return new SnippetEditor;
}
diff --git a/src/plugins/texteditor/snippets/snippeteditor.h b/src/plugins/texteditor/snippets/snippeteditor.h
index 7f1072552b..0fd99d50ad 100644
--- a/src/plugins/texteditor/snippets/snippeteditor.h
+++ b/src/plugins/texteditor/snippets/snippeteditor.h
@@ -46,7 +46,7 @@ class TEXTEDITOR_EXPORT SnippetEditor : public BaseTextEditor
Q_OBJECT
public:
- SnippetEditor(SnippetEditorWidget *editorWidget);
+ SnippetEditor();
Core::IEditor *duplicate() { return 0; }
};
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index 4cce8c946c..9205ccfbe6 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -155,7 +155,7 @@ class VcsBaseEditor : public TextEditor::BaseTextEditor
{
Q_OBJECT
public:
- VcsBaseEditor(VcsBaseEditorWidget *, const VcsBaseEditorParameters *type);
+ explicit VcsBaseEditor(const VcsBaseEditorParameters *type);
signals:
void describeRequested(const QString &source, const QString &change);
@@ -163,9 +163,7 @@ signals:
const QString &change, int line);
};
-VcsBaseEditor::VcsBaseEditor(VcsBaseEditorWidget *widget,
- const VcsBaseEditorParameters *type) :
- BaseTextEditor(widget)
+VcsBaseEditor::VcsBaseEditor(const VcsBaseEditorParameters *type)
{
setContext(Core::Context(type->context, TextEditor::Constants::C_TEXTEDITOR));
}
@@ -821,7 +819,7 @@ bool VcsBaseEditorWidget::isModified() const
TextEditor::BaseTextEditor *VcsBaseEditorWidget::createEditor()
{
- TextEditor::BaseTextEditor *editor = new VcsBaseEditor(this, d->m_parameters);
+ TextEditor::BaseTextEditor *editor = new VcsBaseEditor(d->m_parameters);
// Pass on signals.
connect(this, SIGNAL(describeRequested(QString,QString)),