forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -49,8 +49,7 @@ using namespace Android::Internal;
|
|||||||
// JavaEditor
|
// JavaEditor
|
||||||
//
|
//
|
||||||
|
|
||||||
JavaEditor::JavaEditor(JavaEditorWidget *editor)
|
JavaEditor::JavaEditor()
|
||||||
: BaseTextEditor(editor)
|
|
||||||
{
|
{
|
||||||
setContext(Core::Context(Constants::C_JAVA_EDITOR,
|
setContext(Core::Context(Constants::C_JAVA_EDITOR,
|
||||||
TextEditor::Constants::C_TEXTEDITOR));
|
TextEditor::Constants::C_TEXTEDITOR));
|
||||||
@@ -78,7 +77,7 @@ JavaEditorWidget::JavaEditorWidget()
|
|||||||
|
|
||||||
TextEditor::BaseTextEditor *JavaEditorWidget::createEditor()
|
TextEditor::BaseTextEditor *JavaEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
return new JavaEditor(this);
|
return new JavaEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -86,7 +85,6 @@ TextEditor::BaseTextEditor *JavaEditorWidget::createEditor()
|
|||||||
//
|
//
|
||||||
|
|
||||||
JavaDocument::JavaDocument()
|
JavaDocument::JavaDocument()
|
||||||
: TextEditor::BaseTextDocument()
|
|
||||||
{
|
{
|
||||||
setId(Constants::JAVA_EDITOR_ID);
|
setId(Constants::JAVA_EDITOR_ID);
|
||||||
setMimeType(QLatin1String(Constants::JAVA_MIMETYPE));
|
setMimeType(QLatin1String(Constants::JAVA_MIMETYPE));
|
||||||
|
|||||||
@@ -38,14 +38,13 @@ namespace Android {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class JavaEditorFactory;
|
class JavaEditorFactory;
|
||||||
class JavaEditorWidget;
|
|
||||||
|
|
||||||
class JavaEditor : public TextEditor::BaseTextEditor
|
class JavaEditor : public TextEditor::BaseTextEditor
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JavaEditor(JavaEditorWidget *);
|
JavaEditor();
|
||||||
|
|
||||||
Core::IEditor *duplicate();
|
Core::IEditor *duplicate();
|
||||||
TextEditor::CompletionAssistProvider *completionAssistProvider();
|
TextEditor::CompletionAssistProvider *completionAssistProvider();
|
||||||
|
|||||||
@@ -57,15 +57,13 @@ using namespace CMakeProjectManager::Internal;
|
|||||||
// ProFileEditorEditable
|
// ProFileEditorEditable
|
||||||
//
|
//
|
||||||
|
|
||||||
CMakeEditor::CMakeEditor(CMakeEditorWidget *editor)
|
CMakeEditor::CMakeEditor()
|
||||||
: BaseTextEditor(editor)
|
|
||||||
{
|
{
|
||||||
setContext(Core::Context(CMakeProjectManager::Constants::C_CMAKEEDITOR,
|
setContext(Core::Context(CMakeProjectManager::Constants::C_CMAKEEDITOR,
|
||||||
TextEditor::Constants::C_TEXTEDITOR));
|
TextEditor::Constants::C_TEXTEDITOR));
|
||||||
setDuplicateSupported(true);
|
setDuplicateSupported(true);
|
||||||
setCommentStyle(Utils::CommentDefinition::HashStyle);
|
setCommentStyle(Utils::CommentDefinition::HashStyle);
|
||||||
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<CMakeFileCompletionAssistProvider>());
|
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<CMakeFileCompletionAssistProvider>());
|
||||||
connect(document(), SIGNAL(changed()), this, SLOT(markAsChanged()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IEditor *CMakeEditor::duplicate()
|
Core::IEditor *CMakeEditor::duplicate()
|
||||||
@@ -157,7 +155,9 @@ CMakeEditorWidget::CMakeEditorWidget()
|
|||||||
|
|
||||||
TextEditor::BaseTextEditor *CMakeEditorWidget::createEditor()
|
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)
|
void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||||
|
|||||||
@@ -50,12 +50,13 @@ class CMakeEditor : public TextEditor::BaseTextEditor
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMakeEditor(CMakeEditorWidget *);
|
CMakeEditor();
|
||||||
|
|
||||||
Core::IEditor *duplicate();
|
Core::IEditor *duplicate();
|
||||||
|
|
||||||
QString contextHelpId() const;
|
QString contextHelpId() const;
|
||||||
|
|
||||||
|
friend class CMakeEditorWidget;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void markAsChanged();
|
void markAsChanged();
|
||||||
void build();
|
void build();
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ QTimer *newSingleShotTimer(QObject *parent, int msecInterval)
|
|||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
CPPEditor::CPPEditor(CppEditorWidget *editor)
|
CPPEditor::CPPEditor()
|
||||||
: BaseTextEditor(editor)
|
|
||||||
{
|
{
|
||||||
m_context.add(CppEditor::Constants::C_CPPEDITOR);
|
m_context.add(CppEditor::Constants::C_CPPEDITOR);
|
||||||
m_context.add(ProjectExplorer::Constants::LANG_CXX);
|
m_context.add(ProjectExplorer::Constants::LANG_CXX);
|
||||||
@@ -263,7 +262,7 @@ CppEditorOutline *CppEditorWidget::outline() const
|
|||||||
|
|
||||||
TextEditor::BaseTextEditor *CppEditorWidget::createEditor()
|
TextEditor::BaseTextEditor *CppEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
return new CPPEditor(this);
|
return new CPPEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorWidget::paste()
|
void CppEditorWidget::paste()
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ namespace CppEditor {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class CppEditorOutline;
|
class CppEditorOutline;
|
||||||
class CppEditorWidget;
|
|
||||||
class CppEditorWidgetPrivate;
|
class CppEditorWidgetPrivate;
|
||||||
class FollowSymbolUnderCursor;
|
class FollowSymbolUnderCursor;
|
||||||
|
|
||||||
@@ -59,7 +58,7 @@ class CPPEditor : public TextEditor::BaseTextEditor
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CPPEditor(CppEditorWidget *);
|
CPPEditor();
|
||||||
|
|
||||||
Core::IEditor *duplicate() QTC_OVERRIDE;
|
Core::IEditor *duplicate() QTC_OVERRIDE;
|
||||||
|
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ struct FormWindowEditorPrivate
|
|||||||
Internal::DesignerXmlEditorWidget *m_widget;
|
Internal::DesignerXmlEditorWidget *m_widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
FormWindowEditor::FormWindowEditor(Internal::DesignerXmlEditorWidget *editor) :
|
FormWindowEditor::FormWindowEditor(Internal::DesignerXmlEditorWidget *editor)
|
||||||
TextEditor::BaseTextEditor(editor),
|
: d(new FormWindowEditorPrivate)
|
||||||
d(new FormWindowEditorPrivate)
|
|
||||||
{
|
{
|
||||||
|
setEditorWidget(editor);
|
||||||
d->m_widget = editor;
|
d->m_widget = editor;
|
||||||
setDuplicateSupported(true);
|
setDuplicateSupported(true);
|
||||||
setContext(Core::Context(Designer::Constants::K_DESIGNER_XML_EDITOR_ID,
|
setContext(Core::Context(Designer::Constants::K_DESIGNER_XML_EDITOR_ID,
|
||||||
|
|||||||
@@ -83,12 +83,7 @@ public slots:
|
|||||||
void setDisplaySettings(const DisplaySettings &ds);
|
void setDisplaySettings(const DisplaySettings &ds);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseTextEditor *createEditor()
|
BaseTextEditor *createEditor() { return new BaseTextEditor; }
|
||||||
{
|
|
||||||
BaseTextEditor *editor = new BaseTextEditor(this);
|
|
||||||
editor->document()->setId("DiffEditor.DescriptionEditor");
|
|
||||||
return editor;
|
|
||||||
}
|
|
||||||
void mouseMoveEvent(QMouseEvent *e);
|
void mouseMoveEvent(QMouseEvent *e);
|
||||||
void mouseReleaseEvent(QMouseEvent *e);
|
void mouseReleaseEvent(QMouseEvent *e);
|
||||||
|
|
||||||
@@ -103,7 +98,7 @@ private:
|
|||||||
DescriptionEditorWidget::DescriptionEditorWidget(QWidget *parent)
|
DescriptionEditorWidget::DescriptionEditorWidget(QWidget *parent)
|
||||||
: BaseTextEditorWidget(parent)
|
: BaseTextEditorWidget(parent)
|
||||||
{
|
{
|
||||||
setTextDocument(BaseTextDocumentPtr(new BaseTextDocument));
|
setSimpleTextDocument("DiffEditor.DescriptionEditor");
|
||||||
DisplaySettings settings = displaySettings();
|
DisplaySettings settings = displaySettings();
|
||||||
settings.m_textWrapping = false;
|
settings.m_textWrapping = false;
|
||||||
settings.m_displayLineNumbers = false;
|
settings.m_displayLineNumbers = false;
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ public:
|
|||||||
public:
|
public:
|
||||||
DiffEditorController *controller() const;
|
DiffEditorController *controller() const;
|
||||||
|
|
||||||
// Core::IEditor
|
|
||||||
Core::IEditor *duplicate();
|
Core::IEditor *duplicate();
|
||||||
|
|
||||||
bool open(QString *errorString,
|
bool open(QString *errorString,
|
||||||
|
|||||||
@@ -38,13 +38,12 @@ namespace DiffEditor {
|
|||||||
SelectableTextEditorWidget::SelectableTextEditorWidget(QWidget *parent)
|
SelectableTextEditorWidget::SelectableTextEditorWidget(QWidget *parent)
|
||||||
: BaseTextEditorWidget(parent)
|
: BaseTextEditorWidget(parent)
|
||||||
{
|
{
|
||||||
setTextDocument(TextEditor::BaseTextDocumentPtr(new TextEditor::BaseTextDocument));
|
setSimpleTextDocument("DiffEditor.UnifiedDiffEditor");
|
||||||
setFrameStyle(QFrame::NoFrame);
|
setFrameStyle(QFrame::NoFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectableTextEditorWidget::~SelectableTextEditorWidget()
|
SelectableTextEditorWidget::~SelectableTextEditorWidget()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectableTextEditorWidget::paintEvent(QPaintEvent *e)
|
void SelectableTextEditorWidget::paintEvent(QPaintEvent *e)
|
||||||
|
|||||||
@@ -54,8 +54,7 @@ class DIFFEDITOR_EXPORT SelectableTextEditorWidget
|
|||||||
public:
|
public:
|
||||||
SelectableTextEditorWidget(QWidget *parent = 0);
|
SelectableTextEditorWidget(QWidget *parent = 0);
|
||||||
~SelectableTextEditorWidget();
|
~SelectableTextEditorWidget();
|
||||||
void setSelections(const QMap<int,
|
void setSelections(const QMap<int, QList<DiffSelection> > &selections) {
|
||||||
QList<DiffSelection> > &selections) {
|
|
||||||
m_selections = selections;
|
m_selections = selections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,10 +78,8 @@ class SideDiffEditor : public BaseTextEditor
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SideDiffEditor(BaseTextEditorWidget *editorWidget)
|
SideDiffEditor()
|
||||||
: BaseTextEditor(editorWidget)
|
|
||||||
{
|
{
|
||||||
document()->setId("DiffEditor.SideDiffEditor");
|
|
||||||
connect(this, SIGNAL(tooltipRequested(TextEditor::BaseTextEditor*,QPoint,int)),
|
connect(this, SIGNAL(tooltipRequested(TextEditor::BaseTextEditor*,QPoint,int)),
|
||||||
this, SLOT(slotTooltipRequested(TextEditor::BaseTextEditor*,QPoint,int)));
|
this, SLOT(slotTooltipRequested(TextEditor::BaseTextEditor*,QPoint,int)));
|
||||||
}
|
}
|
||||||
@@ -170,7 +168,7 @@ protected:
|
|||||||
return SelectableTextEditorWidget::extraAreaWidth(markWidthPtr);
|
return SelectableTextEditorWidget::extraAreaWidth(markWidthPtr);
|
||||||
}
|
}
|
||||||
void applyFontSettings();
|
void applyFontSettings();
|
||||||
BaseTextEditor *createEditor() { return new SideDiffEditor(this); }
|
BaseTextEditor *createEditor() { return new SideDiffEditor; }
|
||||||
virtual QString lineNumber(int blockNumber) const;
|
virtual QString lineNumber(int blockNumber) const;
|
||||||
virtual int lineNumberDigits() const;
|
virtual int lineNumberDigits() const;
|
||||||
virtual bool selectionVisible(int blockNumber) const;
|
virtual bool selectionVisible(int blockNumber) const;
|
||||||
@@ -326,6 +324,7 @@ SideDiffEditorWidget::SideDiffEditorWidget(QWidget *parent)
|
|||||||
m_lineNumberDigits(1),
|
m_lineNumberDigits(1),
|
||||||
m_inPaintEvent(false)
|
m_inPaintEvent(false)
|
||||||
{
|
{
|
||||||
|
textDocument()->setId("DiffEditor.SideDiffEditor");
|
||||||
DisplaySettings settings = displaySettings();
|
DisplaySettings settings = displaySettings();
|
||||||
settings.m_textWrapping = false;
|
settings.m_textWrapping = false;
|
||||||
settings.m_displayLineNumbers = true;
|
settings.m_displayLineNumbers = true;
|
||||||
|
|||||||
@@ -71,16 +71,6 @@ using namespace TextEditor;
|
|||||||
|
|
||||||
namespace DiffEditor {
|
namespace DiffEditor {
|
||||||
|
|
||||||
class UnifiedDiffEditor : public BaseTextEditor
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
UnifiedDiffEditor(BaseTextEditorWidget *editorWidget)
|
|
||||||
: BaseTextEditor(editorWidget) {
|
|
||||||
document()->setId("DiffEditor.UnifiedDiffEditor");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
UnifiedDiffEditorWidget::UnifiedDiffEditorWidget(QWidget *parent)
|
UnifiedDiffEditorWidget::UnifiedDiffEditorWidget(QWidget *parent)
|
||||||
: SelectableTextEditorWidget(parent)
|
: SelectableTextEditorWidget(parent)
|
||||||
, m_guiController(0)
|
, m_guiController(0)
|
||||||
@@ -389,7 +379,7 @@ void UnifiedDiffEditorWidget::patch(int diffFileIndex, int chunkIndex, bool reve
|
|||||||
|
|
||||||
TextEditor::BaseTextEditor *UnifiedDiffEditorWidget::createEditor()
|
TextEditor::BaseTextEditor *UnifiedDiffEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
return new UnifiedDiffEditor(this);
|
return new BaseTextEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnifiedDiffEditorWidget::clear(const QString &message)
|
void UnifiedDiffEditorWidget::clear(const QString &message)
|
||||||
@@ -844,5 +834,3 @@ void UnifiedDiffEditorWidget::setCurrentDiffFileIndex(int diffFileIndex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace DiffEditor
|
} // namespace DiffEditor
|
||||||
|
|
||||||
#include "unifieddiffeditorwidget.moc"
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ ProjectFilesFactory::ProjectFilesFactory(Manager *manager)
|
|||||||
Core::IEditor *ProjectFilesFactory::createEditor()
|
Core::IEditor *ProjectFilesFactory::createEditor()
|
||||||
{
|
{
|
||||||
auto widget = new ProjectFilesEditorWidget;
|
auto widget = new ProjectFilesEditorWidget;
|
||||||
widget->setTextDocument(BaseTextDocumentPtr(new BaseTextDocument));
|
widget->setSimpleTextDocument(Constants::FILES_EDITOR_ID);
|
||||||
TextEditorSettings::initializeEditor(widget);
|
TextEditorSettings::initializeEditor(widget);
|
||||||
return widget->editor();
|
return widget->editor();
|
||||||
}
|
}
|
||||||
@@ -76,10 +76,8 @@ Core::IEditor *ProjectFilesFactory::createEditor()
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ProjectFilesEditor::ProjectFilesEditor(ProjectFilesEditorWidget *editor)
|
ProjectFilesEditor::ProjectFilesEditor()
|
||||||
: BaseTextEditor(editor)
|
|
||||||
{
|
{
|
||||||
document()->setId(Constants::FILES_EDITOR_ID);
|
|
||||||
setContext(Core::Context(Constants::C_FILESEDITOR));
|
setContext(Core::Context(Constants::C_FILESEDITOR));
|
||||||
setDuplicateSupported(true);
|
setDuplicateSupported(true);
|
||||||
}
|
}
|
||||||
@@ -104,7 +102,7 @@ ProjectFilesEditorWidget::ProjectFilesEditorWidget()
|
|||||||
|
|
||||||
BaseTextEditor *ProjectFilesEditorWidget::createEditor()
|
BaseTextEditor *ProjectFilesEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
return new ProjectFilesEditor(this);
|
return new ProjectFilesEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class ProjectFilesEditor : public TextEditor::BaseTextEditor
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProjectFilesEditor(ProjectFilesEditorWidget *editorWidget);
|
ProjectFilesEditor();
|
||||||
|
|
||||||
Core::IEditor *duplicate();
|
Core::IEditor *duplicate();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ QString GlslEditorWidget::wordUnderCursor() const
|
|||||||
|
|
||||||
TextEditor::BaseTextEditor *GlslEditorWidget::createEditor()
|
TextEditor::BaseTextEditor *GlslEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
return new GlslEditor(this);
|
return new GlslEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlslEditorWidget::updateDocument()
|
void GlslEditorWidget::updateDocument()
|
||||||
|
|||||||
@@ -41,8 +41,7 @@
|
|||||||
namespace GLSLEditor {
|
namespace GLSLEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
GlslEditor::GlslEditor(GlslEditorWidget *editor)
|
GlslEditor::GlslEditor()
|
||||||
: BaseTextEditor(editor)
|
|
||||||
{
|
{
|
||||||
setContext(Core::Context(GLSLEditor::Constants::C_GLSLEDITOR_ID,
|
setContext(Core::Context(GLSLEditor::Constants::C_GLSLEDITOR_ID,
|
||||||
TextEditor::Constants::C_TEXTEDITOR));
|
TextEditor::Constants::C_TEXTEDITOR));
|
||||||
|
|||||||
@@ -35,14 +35,12 @@
|
|||||||
namespace GLSLEditor {
|
namespace GLSLEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class GlslEditorWidget;
|
|
||||||
|
|
||||||
class GlslEditor : public TextEditor::BaseTextEditor
|
class GlslEditor : public TextEditor::BaseTextEditor
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GlslEditor(GlslEditorWidget *);
|
GlslEditor();
|
||||||
|
|
||||||
Core::IEditor *duplicate();
|
Core::IEditor *duplicate();
|
||||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||||
|
|||||||
@@ -47,8 +47,7 @@
|
|||||||
namespace PythonEditor {
|
namespace PythonEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
PythonEditor::PythonEditor(PythonEditorWidget *editorWidget)
|
PythonEditor::PythonEditor()
|
||||||
:BaseTextEditor(editorWidget)
|
|
||||||
{
|
{
|
||||||
setContext(Core::Context(Constants::C_PYTHONEDITOR_ID,
|
setContext(Core::Context(Constants::C_PYTHONEDITOR_ID,
|
||||||
TextEditor::Constants::C_TEXTEDITOR));
|
TextEditor::Constants::C_TEXTEDITOR));
|
||||||
|
|||||||
@@ -35,14 +35,12 @@
|
|||||||
namespace PythonEditor {
|
namespace PythonEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class PythonEditorWidget;
|
|
||||||
|
|
||||||
class PythonEditor : public TextEditor::BaseTextEditor
|
class PythonEditor : public TextEditor::BaseTextEditor
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PythonEditor(PythonEditorWidget *editorWidget);
|
PythonEditor();
|
||||||
|
|
||||||
Core::IEditor *duplicate();
|
Core::IEditor *duplicate();
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ PythonEditorWidget::PythonEditorWidget(TextEditor::BaseTextDocumentPtr doc)
|
|||||||
|
|
||||||
TextEditor::BaseTextEditor *PythonEditorWidget::createEditor()
|
TextEditor::BaseTextEditor *PythonEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
return new PythonEditor(this);
|
return new PythonEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ namespace Internal {
|
|||||||
// ProFileEditor
|
// ProFileEditor
|
||||||
//
|
//
|
||||||
|
|
||||||
ProFileEditor::ProFileEditor(ProFileEditorWidget *editor)
|
ProFileEditor::ProFileEditor()
|
||||||
: BaseTextEditor(editor)
|
|
||||||
{
|
{
|
||||||
setContext(Core::Context(Constants::C_PROFILEEDITOR,
|
setContext(Core::Context(Constants::C_PROFILEEDITOR,
|
||||||
TextEditor::Constants::C_TEXTEDITOR));
|
TextEditor::Constants::C_TEXTEDITOR));
|
||||||
@@ -167,7 +166,7 @@ ProFileEditorWidget::Link ProFileEditorWidget::findLinkAt(const QTextCursor &cur
|
|||||||
|
|
||||||
TextEditor::BaseTextEditor *ProFileEditorWidget::createEditor()
|
TextEditor::BaseTextEditor *ProFileEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
return new ProFileEditor(this);
|
return new ProFileEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||||
@@ -180,7 +179,6 @@ void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
|||||||
//
|
//
|
||||||
|
|
||||||
ProFileDocument::ProFileDocument()
|
ProFileDocument::ProFileDocument()
|
||||||
: TextEditor::BaseTextDocument()
|
|
||||||
{
|
{
|
||||||
setId(Constants::PROFILE_EDITOR_ID);
|
setId(Constants::PROFILE_EDITOR_ID);
|
||||||
setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE));
|
setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE));
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class ProFileEditor : public TextEditor::BaseTextEditor
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProFileEditor(ProFileEditorWidget *);
|
ProFileEditor();
|
||||||
|
|
||||||
Core::IEditor *duplicate();
|
Core::IEditor *duplicate();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ namespace QmlJSEditor {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QmlJSTextEditorWidget::QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr doc)
|
QmlJSTextEditorWidget::QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr doc)
|
||||||
: TextEditor::BaseTextEditorWidget(0)
|
|
||||||
{
|
{
|
||||||
setTextDocument(doc);
|
setTextDocument(doc);
|
||||||
|
|
||||||
@@ -151,6 +150,7 @@ QmlJSTextEditorWidget::QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr doc
|
|||||||
SLOT(onRefactorMarkerClicked(TextEditor::RefactorMarker)));
|
SLOT(onRefactorMarkerClicked(TextEditor::RefactorMarker)));
|
||||||
|
|
||||||
setRequestMarkEnabled(true);
|
setRequestMarkEnabled(true);
|
||||||
|
createToolBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSTextEditorWidget::~QmlJSTextEditorWidget()
|
QmlJSTextEditorWidget::~QmlJSTextEditorWidget()
|
||||||
@@ -529,12 +529,10 @@ bool QmlJSTextEditorWidget::isClosingBrace(const QList<Token> &tokens) const
|
|||||||
|
|
||||||
TextEditor::BaseTextEditor *QmlJSTextEditorWidget::createEditor()
|
TextEditor::BaseTextEditor *QmlJSTextEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
QmlJSEditor *editable = new QmlJSEditor(this);
|
return new QmlJSEditor;
|
||||||
createToolBar(editable);
|
|
||||||
return editable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSTextEditorWidget::createToolBar(QmlJSEditor *editor)
|
void QmlJSTextEditorWidget::createToolBar()
|
||||||
{
|
{
|
||||||
m_outlineCombo = new QComboBox;
|
m_outlineCombo = new QComboBox;
|
||||||
m_outlineCombo->setMinimumContentsLength(22);
|
m_outlineCombo->setMinimumContentsLength(22);
|
||||||
@@ -568,7 +566,7 @@ void QmlJSTextEditorWidget::createToolBar(QmlJSEditor *editor)
|
|||||||
|
|
||||||
connect(this, SIGNAL(cursorPositionChanged()), m_updateOutlineIndexTimer, SLOT(start()));
|
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,
|
TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const QTextCursor &cursor,
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ protected:
|
|||||||
void scrollContentsBy(int dx, int dy);
|
void scrollContentsBy(int dx, int dy);
|
||||||
void applyFontSettings();
|
void applyFontSettings();
|
||||||
TextEditor::BaseTextEditor *createEditor();
|
TextEditor::BaseTextEditor *createEditor();
|
||||||
void createToolBar(QmlJSEditor *editable);
|
void createToolBar();
|
||||||
TextEditor::BaseTextEditorWidget::Link findLinkAt(const QTextCursor &cursor,
|
TextEditor::BaseTextEditorWidget::Link findLinkAt(const QTextCursor &cursor,
|
||||||
bool resolveTarget = true,
|
bool resolveTarget = true,
|
||||||
bool inNextSplit = false);
|
bool inNextSplit = false);
|
||||||
|
|||||||
@@ -48,8 +48,7 @@
|
|||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QmlJSEditor::QmlJSEditor(QmlJSTextEditorWidget *editor)
|
QmlJSEditor::QmlJSEditor()
|
||||||
: BaseTextEditor(editor)
|
|
||||||
{
|
{
|
||||||
m_context.add(Constants::C_QMLJSEDITOR_ID);
|
m_context.add(Constants::C_QMLJSEDITOR_ID);
|
||||||
m_context.add(TextEditor::Constants::C_TEXTEDITOR);
|
m_context.add(TextEditor::Constants::C_TEXTEDITOR);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class QmlJSEditor : public TextEditor::BaseTextEditor
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QmlJSEditor(QmlJSTextEditorWidget *);
|
QmlJSEditor();
|
||||||
|
|
||||||
Core::IEditor *duplicate();
|
Core::IEditor *duplicate();
|
||||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ void BaseTextDocumentPrivate::onModificationChanged(bool modified)
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
BaseTextDocument::BaseTextDocument()
|
BaseTextDocument::BaseTextDocument(Id id)
|
||||||
: d(new BaseTextDocumentPrivate(this))
|
: d(new BaseTextDocumentPrivate(this))
|
||||||
{
|
{
|
||||||
connect(d->m_document, SIGNAL(modificationChanged(bool)), d, SLOT(onModificationChanged(bool)));
|
connect(d->m_document, SIGNAL(modificationChanged(bool)), d, SLOT(onModificationChanged(bool)));
|
||||||
@@ -221,6 +221,9 @@ BaseTextDocument::BaseTextDocument()
|
|||||||
d->m_document->setDefaultTextOption(opt);
|
d->m_document->setDefaultTextOption(opt);
|
||||||
BaseTextDocumentLayout *documentLayout = new BaseTextDocumentLayout(d->m_document);
|
BaseTextDocumentLayout *documentLayout = new BaseTextDocumentLayout(d->m_document);
|
||||||
d->m_document->setDocumentLayout(documentLayout);
|
d->m_document->setDocumentLayout(documentLayout);
|
||||||
|
|
||||||
|
if (id.isValid())
|
||||||
|
setId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextDocument::~BaseTextDocument()
|
BaseTextDocument::~BaseTextDocument()
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "texteditor_global.h"
|
#include "texteditor_global.h"
|
||||||
|
|
||||||
|
#include <coreplugin/id.h>
|
||||||
#include <coreplugin/textdocument.h>
|
#include <coreplugin/textdocument.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
@@ -64,7 +65,7 @@ class TEXTEDITOR_EXPORT BaseTextDocument : public Core::TextDocument
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BaseTextDocument();
|
explicit BaseTextDocument(Core::Id id = Core::Id());
|
||||||
virtual ~BaseTextDocument();
|
virtual ~BaseTextDocument();
|
||||||
|
|
||||||
static QMap<QString, QString> openedTextDocumentContents();
|
static QMap<QString, QString> openedTextDocumentContents();
|
||||||
|
|||||||
@@ -662,6 +662,11 @@ BaseTextEditorWidget::~BaseTextEditorWidget()
|
|||||||
d = 0;
|
d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseTextEditorWidget::setSimpleTextDocument(Id id)
|
||||||
|
{
|
||||||
|
setTextDocument(BaseTextDocumentPtr(new BaseTextDocument(id)));
|
||||||
|
}
|
||||||
|
|
||||||
void BaseTextEditorWidget::print(QPrinter *printer)
|
void BaseTextEditorWidget::print(QPrinter *printer)
|
||||||
{
|
{
|
||||||
const bool oldFullPage = printer->fullPage();
|
const bool oldFullPage = printer->fullPage();
|
||||||
@@ -874,7 +879,10 @@ int BaseTextEditorWidgetPrivate::visualIndent(const QTextBlock &block) const
|
|||||||
BaseTextEditor *BaseTextEditorWidget::editor() const
|
BaseTextEditor *BaseTextEditorWidget::editor() const
|
||||||
{
|
{
|
||||||
if (!d->m_editor) {
|
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);
|
d->m_codeAssistant->configure(d->m_editor);
|
||||||
}
|
}
|
||||||
return d->m_editor;
|
return d->m_editor;
|
||||||
@@ -6473,7 +6481,8 @@ QColor BaseTextEditorWidget::replacementPenColor(int blockNumber) const
|
|||||||
|
|
||||||
BaseTextEditor *BaseTextEditorWidget::createEditor()
|
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,
|
editor->setContext(Core::Context(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
|
||||||
TextEditor::Constants::C_TEXTEDITOR));
|
TextEditor::Constants::C_TEXTEDITOR));
|
||||||
editor->setDuplicateSupported(true);
|
editor->setDuplicateSupported(true);
|
||||||
@@ -6510,13 +6519,16 @@ void BaseTextEditorWidget::appendStandardContextMenuActions(QMenu *menu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BaseTextEditor::BaseTextEditor(BaseTextEditorWidget *widget)
|
BaseTextEditor::BaseTextEditor()
|
||||||
: d(new BaseTextEditorPrivate)
|
: d(new BaseTextEditorPrivate)
|
||||||
|
{
|
||||||
|
d->m_completionAssistProvider = [] () -> CompletionAssistProvider * { return 0; };
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseTextEditor::setEditorWidget(BaseTextEditorWidget *widget)
|
||||||
{
|
{
|
||||||
setWidget(widget);
|
setWidget(widget);
|
||||||
d->m_editorWidget = widget;
|
d->m_editorWidget = widget;
|
||||||
|
|
||||||
d->m_completionAssistProvider = [] () -> CompletionAssistProvider * { return 0; };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextEditor::~BaseTextEditor()
|
BaseTextEditor::~BaseTextEditor()
|
||||||
|
|||||||
@@ -117,9 +117,11 @@ public:
|
|||||||
EndOfDoc = 5
|
EndOfDoc = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseTextEditor(BaseTextEditorWidget *editorWidget);
|
BaseTextEditor();
|
||||||
~BaseTextEditor();
|
~BaseTextEditor();
|
||||||
|
|
||||||
|
void setEditorWidget(BaseTextEditorWidget *editorWidget);
|
||||||
|
|
||||||
enum MarkRequestKind {
|
enum MarkRequestKind {
|
||||||
BreakpointRequest,
|
BreakpointRequest,
|
||||||
BookmarkRequest,
|
BookmarkRequest,
|
||||||
@@ -216,6 +218,7 @@ public:
|
|||||||
~BaseTextEditorWidget();
|
~BaseTextEditorWidget();
|
||||||
|
|
||||||
void setTextDocument(const BaseTextDocumentPtr &doc);
|
void setTextDocument(const BaseTextDocumentPtr &doc);
|
||||||
|
void setSimpleTextDocument(Core::Id id); // Convenience.
|
||||||
|
|
||||||
BaseTextDocument *textDocument() const;
|
BaseTextDocument *textDocument() const;
|
||||||
BaseTextDocumentPtr textDocumentPtr() const;
|
BaseTextDocumentPtr textDocumentPtr() const;
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ using namespace TextEditor;
|
|||||||
\ingroup Snippets
|
\ingroup Snippets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SnippetEditor::SnippetEditor(SnippetEditorWidget *editor)
|
SnippetEditor::SnippetEditor()
|
||||||
: BaseTextEditor(editor)
|
|
||||||
{
|
{
|
||||||
setContext(Core::Context(Constants::SNIPPET_EDITOR_ID, Constants::C_TEXTEDITOR));
|
setContext(Core::Context(Constants::SNIPPET_EDITOR_ID, Constants::C_TEXTEDITOR));
|
||||||
}
|
}
|
||||||
@@ -77,5 +76,5 @@ void SnippetEditorWidget::focusOutEvent(QFocusEvent *event)
|
|||||||
|
|
||||||
BaseTextEditor *SnippetEditorWidget::createEditor()
|
BaseTextEditor *SnippetEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
return new SnippetEditor(this);
|
return new SnippetEditor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class TEXTEDITOR_EXPORT SnippetEditor : public BaseTextEditor
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SnippetEditor(SnippetEditorWidget *editorWidget);
|
SnippetEditor();
|
||||||
|
|
||||||
Core::IEditor *duplicate() { return 0; }
|
Core::IEditor *duplicate() { return 0; }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class VcsBaseEditor : public TextEditor::BaseTextEditor
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VcsBaseEditor(VcsBaseEditorWidget *, const VcsBaseEditorParameters *type);
|
explicit VcsBaseEditor(const VcsBaseEditorParameters *type);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void describeRequested(const QString &source, const QString &change);
|
void describeRequested(const QString &source, const QString &change);
|
||||||
@@ -163,9 +163,7 @@ signals:
|
|||||||
const QString &change, int line);
|
const QString &change, int line);
|
||||||
};
|
};
|
||||||
|
|
||||||
VcsBaseEditor::VcsBaseEditor(VcsBaseEditorWidget *widget,
|
VcsBaseEditor::VcsBaseEditor(const VcsBaseEditorParameters *type)
|
||||||
const VcsBaseEditorParameters *type) :
|
|
||||||
BaseTextEditor(widget)
|
|
||||||
{
|
{
|
||||||
setContext(Core::Context(type->context, TextEditor::Constants::C_TEXTEDITOR));
|
setContext(Core::Context(type->context, TextEditor::Constants::C_TEXTEDITOR));
|
||||||
}
|
}
|
||||||
@@ -821,7 +819,7 @@ bool VcsBaseEditorWidget::isModified() const
|
|||||||
|
|
||||||
TextEditor::BaseTextEditor *VcsBaseEditorWidget::createEditor()
|
TextEditor::BaseTextEditor *VcsBaseEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
TextEditor::BaseTextEditor *editor = new VcsBaseEditor(this, d->m_parameters);
|
TextEditor::BaseTextEditor *editor = new VcsBaseEditor(d->m_parameters);
|
||||||
|
|
||||||
// Pass on signals.
|
// Pass on signals.
|
||||||
connect(this, SIGNAL(describeRequested(QString,QString)),
|
connect(this, SIGNAL(describeRequested(QString,QString)),
|
||||||
|
|||||||
Reference in New Issue
Block a user