Commit c5fae0e8 authored by hjk's avatar hjk
Browse files

TextEditor: Further *Editor/*EditorWidget disentangling



In most cases, the *Editor constructor does not need to
access the *EditorWidget.

Change-Id: I1f5c076a0f723d5d82b398e8c250c7bd1d47eb17
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent d2ec7d80
......@@ -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));
......
......@@ -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();
......
......@@ -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)
......
......@@ -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();
......
......@@ -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()
......
......@@ -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;
......
......@@ -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,
......
......@@ -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;
......
......@@ -63,7 +63,6 @@ public:
public:
DiffEditorController *controller() const;
// Core::IEditor
Core::IEditor *duplicate();
bool open(QString *errorString,
......
......@@ -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)
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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"
......@@ -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
......
......@@ -65,7 +65,7 @@ class ProjectFilesEditor : public TextEditor::BaseTextEditor
Q_OBJECT
public:
ProjectFilesEditor(ProjectFilesEditorWidget *editorWidget);
ProjectFilesEditor();
Core::IEditor *duplicate();
};
......
......@@ -232,7 +232,7 @@ QString GlslEditorWidget::wordUnderCursor() const
TextEditor::BaseTextEditor *GlslEditorWidget::createEditor()
{
return new GlslEditor(this);
return new GlslEditor;
}
void GlslEditorWidget::updateDocument()
......
......@@ -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));
......
......@@ -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);
......
......@@ -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));
......
......@@ -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();
......
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