Commit 1dc7e0d3 authored by Leandro Melo's avatar Leandro Melo
Browse files

C++: Don't show inspected type in type hierarcy bases/derived



Instead, show it on a label above.

Task-number: QTCREATORBUG-6775
Change-Id: I7bf8e72c8a0ba1c07444230915d72b0cd9b66672
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent ccb0a1bf
......@@ -89,6 +89,35 @@ QList<CppClass> sortClasses(const QList<CppClass> &cppClasses)
} // Anonymous
namespace CppEditor {
namespace Internal {
class CppClassLabel : public QLabel
{
public:
CppClassLabel(CPPEditorWidget *editor, QWidget *parent)
: QLabel(parent), m_editor(editor)
{}
void setup(CppClass *cppClass)
{
setText(cppClass->name());
m_link = cppClass->link();
}
private:
void mousePressEvent(QMouseEvent *)
{
m_editor->openLink(m_link);
}
CPPEditorWidget *m_editor;
CPPEditorWidget::Link m_link;
};
} // namespace Internal
} // namespace CppEditor
// CppTypeHierarchyWidget
CppTypeHierarchyWidget::CppTypeHierarchyWidget(Core::IEditor *editor) :
QWidget(0),
......@@ -104,6 +133,9 @@ CppTypeHierarchyWidget::CppTypeHierarchyWidget(Core::IEditor *editor) :
if (CPPEditor *cppEditor = qobject_cast<CPPEditor *>(editor)) {
m_cppEditor = static_cast<CPPEditorWidget *>(cppEditor->widget());
m_inspectedClass = new CppClassLabel(m_cppEditor, this);
m_inspectedClass->setMargin(5);
layout->addWidget(m_inspectedClass);
m_model = new QStandardItemModel(this);
m_treeView = new NavigationTreeView(this);
m_delegate = new AnnotatedItemDelegate(this);
......@@ -158,6 +190,7 @@ void CppTypeHierarchyWidget::perform()
const QSharedPointer<CppElement> &cppElement = evaluator.cppElement();
CppElement *element = cppElement.data();
if (CppClass *cppClass = dynamic_cast<CppClass *>(element)) {
m_inspectedClass->setup(cppClass);
QStandardItem *bases = new QStandardItem(tr("Bases"));
m_model->invisibleRootItem()->appendRow(bases);
QVector<CppClass> v;
......@@ -166,7 +199,8 @@ void CppTypeHierarchyWidget::perform()
m_treeView->expand(m_model->indexFromItem(bases));
QStandardItem *derived = new QStandardItem(tr("Derived"));
m_model->invisibleRootItem()->appendRow(derived);
buildDerivedHierarchy(*cppClass, derived);
foreach (const CppClass &derivedClass, sortClasses(cppClass->derived()))
buildDerivedHierarchy(derivedClass, derived);
}
}
}
......@@ -183,7 +217,7 @@ void CppTypeHierarchyWidget::buildBaseHierarchy(QVector<CppClass> *s)
}
} else {
QStandardItem *parent = m_model->item(0, 0);
for (int i = s->size() - 1; i >= 0; --i) {
for (int i = s->size() - 1; i > 0; --i) {
QStandardItem *item = itemForClass(s->at(i));
parent->appendRow(item);
m_treeView->expand(m_model->indexFromItem(parent));
......
......@@ -43,6 +43,7 @@ QT_BEGIN_NAMESPACE
class QStandardItemModel;
class QStandardItem;
class QModelIndex;
class QLabel;
template <class> class QVector;
QT_END_NAMESPACE
......@@ -60,6 +61,7 @@ namespace Internal {
class CPPEditorWidget;
class CppClass;
class CppClassLabel;
class CppTypeHierarchyWidget : public QWidget
{
......@@ -84,6 +86,7 @@ private:
Utils::NavigationTreeView *m_treeView;
QStandardItemModel *m_model;
Utils::AnnotatedItemDelegate *m_delegate;
CppClassLabel *m_inspectedClass;
};
// @todo: Pretty much the same design as the OutlineWidgetStack. Maybe we can generalize the
......
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