Commit 878bb9f9 authored by Leandro Melo's avatar Leandro Melo
Browse files

Make type hierarchy widget reusable accross editors.

parent 2d683cd2
......@@ -168,6 +168,19 @@ CppTypeHierarchyWidget::~CppTypeHierarchyWidget()
delete m_delegate;
}
bool CppTypeHierarchyWidget::handleReplacement(Core::IEditor *editor)
{
if (CPPEditorEditable *cppEditable = qobject_cast<CPPEditorEditable *>(editor)) {
if (m_cppEditor) {
m_cppEditor = static_cast<CPPEditor *>(cppEditable->widget());
return true;
}
} else if (!m_cppEditor) {
return true;
}
return false;
}
void CppTypeHierarchyWidget::perform()
{
if (!m_cppEditor)
......@@ -228,11 +241,13 @@ CppTypeHierarchyStackedWidget::~CppTypeHierarchyStackedWidget()
void CppTypeHierarchyStackedWidget::editorChanged(Core::IEditor *editor)
{
CppTypeHierarchyWidget *replacement = new CppTypeHierarchyWidget(editor);
removeWidget(m_typeHiearchyWidgetInstance);
m_typeHiearchyWidgetInstance->deleteLater();
m_typeHiearchyWidgetInstance = replacement;
addWidget(m_typeHiearchyWidgetInstance);
if (!m_typeHiearchyWidgetInstance->handleReplacement(editor)) {
CppTypeHierarchyWidget *replacement = new CppTypeHierarchyWidget(editor);
removeWidget(m_typeHiearchyWidgetInstance);
m_typeHiearchyWidgetInstance->deleteLater();
m_typeHiearchyWidgetInstance = replacement;
addWidget(m_typeHiearchyWidgetInstance);
}
}
// CppTypeHierarchyFactory
......
......@@ -92,6 +92,8 @@ public:
CppTypeHierarchyWidget(Core::IEditor *editor);
virtual ~CppTypeHierarchyWidget();
bool handleReplacement(Core::IEditor *editor);
public slots:
void perform();
......
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