CppEditor: Convert to new construction scheme

Change-Id: I947f76b4dbc3a197cd49993855c3b0f5e3dc7b49
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
hjk
2014-08-27 14:18:35 +02:00
parent 61276ab636
commit c655d7e598
4 changed files with 48 additions and 84 deletions

View File

@@ -148,21 +148,26 @@ CppEditorWidgetPrivate::CppEditorWidgetPrivate(CppEditorWidget *q)
{
}
CppEditorWidget::CppEditorWidget(TextEditor::BaseTextDocumentPtr doc, CppEditor *editor)
CppEditorWidget::CppEditorWidget()
: d(new CppEditorWidgetPrivate(this))
{
qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo");
}
editor->setEditorWidget(this);
void CppEditorWidget::finalizeInitialization()
{
d->m_cppEditorDocument = qobject_cast<CppEditorDocument *>(textDocument());
setTextDocument(doc);
d.reset(new CppEditorWidgetPrivate(this));
setAutoCompleter(new CppAutoCompleter);
setLanguageSettingsId(CppTools::Constants::CPP_SETTINGS_ID);
setCodeFoldingSupported(true);
setMarksVisible(true);
setParenthesesMatchingEnabled(true);
setRevisionsVisible(true);
// function combo box sorting
connect(CppEditorPlugin::instance(), &CppEditorPlugin::outlineSortingChanged,
outline(), &CppEditorOutline::setSorted);
connect(d->m_cppEditorDocument, &CppEditorDocument::codeWarningsUpdated,
this, &CppEditorWidget::onCodeWarningsUpdated);
connect(d->m_cppEditorDocument, &CppEditorDocument::ifdefedOutBlocksUpdated,
@@ -222,6 +227,12 @@ CppEditorWidget::CppEditorWidget(TextEditor::BaseTextDocumentPtr doc, CppEditor
connect(d->m_preprocessorButton, SIGNAL(clicked()), this, SLOT(showPreProcessorWidget()));
insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, d->m_preprocessorButton);
insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, d->m_cppEditorOutline->widget());
// updateSemanticInfo(semanticInfo());
// updateFunctionDeclDefLink();
// d->m_cppEditorOutline->update();
// const ExtraSelectionKind selectionKind = CodeWarningsSelection;
// setExtraSelections(selectionKind, extraSelections(selectionKind));
}
CppEditorWidget::~CppEditorWidget()
@@ -229,20 +240,6 @@ CppEditorWidget::~CppEditorWidget()
// non-inline destructor, see section "Forward Declared Pointers" of QScopedPointer.
}
CppEditorWidget *CppEditorWidget::duplicate(CppEditor *editor) const
{
QTC_ASSERT(editor, return 0);
CppEditorWidget *widget = new CppEditorWidget(textDocumentPtr(), editor);
widget->updateSemanticInfo(semanticInfo());
widget->updateFunctionDeclDefLink();
widget->d->m_cppEditorOutline->update();
const ExtraSelectionKind selectionKind = CodeWarningsSelection;
widget->setExtraSelections(selectionKind, extraSelections(selectionKind));
return widget;
}
CppEditorDocument *CppEditorWidget::cppEditorDocument() const
{
return d->m_cppEditorDocument;
@@ -564,15 +561,6 @@ void CppEditorWidget::keyPressEvent(QKeyEvent *e)
TextEditor::BaseTextEditorWidget::keyPressEvent(e);
}
Core::IEditor *CppEditor::duplicate()
{
CppEditor *editor = new CppEditor;
CppEditorWidget *widget = qobject_cast<CppEditorWidget *>(editorWidget())->duplicate(editor);
CppEditorPlugin::instance()->initializeEditor(widget);
editor->configureCodeAssistant();
return editor;
}
bool CppEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
if (!TextEditor::BaseTextEditor::open(errorString, fileName, realFileName))