Skip to content
Snippets Groups Projects
Commit 878bb9f9 authored by Leandro Melo's avatar Leandro Melo
Browse files

Make type hierarchy widget reusable accross editors.

parent 2d683cd2
No related branches found
No related tags found
No related merge requests found
......@@ -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,12 +241,14 @@ CppTypeHierarchyStackedWidget::~CppTypeHierarchyStackedWidget()
void CppTypeHierarchyStackedWidget::editorChanged(Core::IEditor *editor)
{
if (!m_typeHiearchyWidgetInstance->handleReplacement(editor)) {
CppTypeHierarchyWidget *replacement = new CppTypeHierarchyWidget(editor);
removeWidget(m_typeHiearchyWidgetInstance);
m_typeHiearchyWidgetInstance->deleteLater();
m_typeHiearchyWidgetInstance = replacement;
addWidget(m_typeHiearchyWidgetInstance);
}
}
// CppTypeHierarchyFactory
CppTypeHierarchyFactory::CppTypeHierarchyFactory()
......
......@@ -92,6 +92,8 @@ public:
CppTypeHierarchyWidget(Core::IEditor *editor);
virtual ~CppTypeHierarchyWidget();
bool handleReplacement(Core::IEditor *editor);
public slots:
void perform();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment