forked from qt-creator/qt-creator
TextEditor: Merge the two sets of *EditorWidget constructors
Change-Id: I45d87d0be722ac36d64af222f03f8cb76242c9df Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -58,7 +58,7 @@ PythonEditor::PythonEditor(PythonEditorWidget *editorWidget)
|
||||
|
||||
Core::IEditor *PythonEditor::duplicate()
|
||||
{
|
||||
PythonEditorWidget *widget = new PythonEditorWidget(qobject_cast<PythonEditorWidget *>(editorWidget()));
|
||||
PythonEditorWidget *widget = new PythonEditorWidget(editorWidget()->textDocumentPtr());
|
||||
TextEditor::TextEditorSettings::initializeEditor(widget);
|
||||
return widget->editor();
|
||||
}
|
||||
|
||||
@@ -60,10 +60,10 @@ EditorFactory::EditorFactory(QObject *parent)
|
||||
|
||||
Core::IEditor *EditorFactory::createEditor()
|
||||
{
|
||||
auto doc = new BaseTextDocument;
|
||||
BaseTextDocumentPtr doc(new BaseTextDocument);
|
||||
doc->setId(Constants::C_PYTHONEDITOR_ID);
|
||||
doc->setIndenter(new PythonIndenter);
|
||||
PythonEditorWidget *widget = new PythonEditorWidget(doc, 0);
|
||||
PythonEditorWidget *widget = new PythonEditorWidget(doc);
|
||||
TextEditor::TextEditorSettings::initializeEditor(widget);
|
||||
|
||||
return widget->editor();
|
||||
|
||||
@@ -47,25 +47,14 @@
|
||||
namespace PythonEditor {
|
||||
namespace Internal {
|
||||
|
||||
PythonEditorWidget::PythonEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent)
|
||||
: TextEditor::BaseTextEditorWidget(doc, parent)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
PythonEditorWidget::PythonEditorWidget(PythonEditorWidget *other)
|
||||
: TextEditor::BaseTextEditorWidget(other)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
void PythonEditorWidget::ctor()
|
||||
PythonEditorWidget::PythonEditorWidget(TextEditor::BaseTextDocumentPtr doc)
|
||||
{
|
||||
setTextDocument(doc);
|
||||
setParenthesesMatchingEnabled(true);
|
||||
setMarksVisible(true);
|
||||
setCodeFoldingSupported(true);
|
||||
|
||||
new PythonHighlighter(textDocument());
|
||||
new PythonHighlighter(doc.data());
|
||||
}
|
||||
|
||||
TextEditor::BaseTextEditor *PythonEditorWidget::createEditor()
|
||||
|
||||
@@ -40,15 +40,10 @@ class PythonEditorWidget : public TextEditor::BaseTextEditorWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PythonEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent);
|
||||
PythonEditorWidget(PythonEditorWidget *other);
|
||||
PythonEditorWidget(TextEditor::BaseTextDocumentPtr doc);
|
||||
|
||||
protected:
|
||||
TextEditor::BaseTextEditor *createEditor();
|
||||
|
||||
private:
|
||||
PythonEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
|
||||
void ctor();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user