Commit ee8a0b30 authored by hjk's avatar hjk

Valgrind: Use BaseTreeView instead of QTreeView

Change-Id: Ica796ba3d45b97fb5ed0856acb0860f15d45be56
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent fbda4769
......@@ -37,7 +37,8 @@
#include <valgrind/callgrind/callgrindcallmodel.h>
#include <QAbstractProxyModel>
#include <QHeaderView>
#include <QContextMenuEvent>
#include <QMenu>
#include <QDebug>
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<CallModel *>(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<DataModel *>(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
......@@ -32,12 +32,12 @@
#include "callgrindcostdelegate.h"
#include <QTreeView>
#include <utils/basetreeview.h>
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;
......
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