From ee8a0b30d933e875697bc969a0d4adf729aa21ff Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 20 Jun 2013 09:23:35 +0200 Subject: [PATCH] Valgrind: Use BaseTreeView instead of QTreeView Change-Id: Ica796ba3d45b97fb5ed0856acb0860f15d45be56 Reviewed-by: hjk --- src/plugins/valgrind/callgrindcostview.cpp | 20 +++++++++++--------- src/plugins/valgrind/callgrindcostview.h | 6 ++++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/plugins/valgrind/callgrindcostview.cpp b/src/plugins/valgrind/callgrindcostview.cpp index 33ace83d6b..412d96c900 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 3c9345a406..5a49b27686 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; -- GitLab