diff --git a/src/plugins/valgrind/callgrindcostview.cpp b/src/plugins/valgrind/callgrindcostview.cpp index 33ace83d6b1..412d96c900d 100644 --- a/src/plugins/valgrind/callgrindcostview.cpp +++ b/src/plugins/valgrind/callgrindcostview.cpp @@ -37,7 +37,8 @@ #include #include -#include +#include +#include #include using namespace Valgrind::Callgrind; @@ -61,7 +62,7 @@ CostView::Private::Private(CostView *qq) CostView::CostView(QWidget *parent) - : QTreeView(parent) + : Utils::BaseTreeView(parent) , d(new Private(this)) { setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -91,20 +92,13 @@ void CostView::setModel(QAbstractItemModel *model) break; } - QHeaderView *headerView = header(); setItemDelegate(new QStyledItemDelegate(this)); - headerView->setResizeMode(QHeaderView::Interactive); - headerView->setStretchLastSection(false); if (qobject_cast(model)) { - headerView->setResizeMode(CallModel::CallsColumn, QHeaderView::ResizeToContents); - headerView->setResizeMode(CallModel::CostColumn, QHeaderView::ResizeToContents); setItemDelegateForColumn(CallModel::CalleeColumn, d->m_nameDelegate); setItemDelegateForColumn(CallModel::CallerColumn, d->m_nameDelegate); setItemDelegateForColumn(CallModel::CostColumn, d->m_costDelegate); } else if (qobject_cast(model)) { - headerView->setResizeMode(DataModel::InclusiveCostColumn, QHeaderView::ResizeToContents); - headerView->setResizeMode(DataModel::SelfCostColumn, QHeaderView::ResizeToContents); setItemDelegateForColumn(DataModel::InclusiveCostColumn, d->m_costDelegate); setItemDelegateForColumn(DataModel::NameColumn, d->m_nameDelegate); setItemDelegateForColumn(DataModel::SelfCostColumn, d->m_costDelegate); @@ -124,5 +118,13 @@ CostDelegate::CostFormat CostView::costFormat() const return d->m_costDelegate->format(); } +void CostView::contextMenuEvent(QContextMenuEvent *ev) +{ + QMenu menu; + addBaseContextActions(&menu); + QAction *act = menu.exec(ev->globalPos()); + handleBaseContextAction(act); +} + } // namespace Internal } // namespace Valgrind diff --git a/src/plugins/valgrind/callgrindcostview.h b/src/plugins/valgrind/callgrindcostview.h index 3c9345a406f..5a49b276861 100644 --- a/src/plugins/valgrind/callgrindcostview.h +++ b/src/plugins/valgrind/callgrindcostview.h @@ -32,12 +32,12 @@ #include "callgrindcostdelegate.h" -#include +#include namespace Valgrind { namespace Internal { -class CostView : public QTreeView +class CostView : public Utils::BaseTreeView { Q_OBJECT @@ -57,6 +57,8 @@ public: void setCostFormat(CostDelegate::CostFormat format); CostDelegate::CostFormat costFormat() const; + void contextMenuEvent(QContextMenuEvent *ev); + private: class Private; Private *d;