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 @@ ...@@ -37,7 +37,8 @@
#include <valgrind/callgrind/callgrindcallmodel.h> #include <valgrind/callgrind/callgrindcallmodel.h>
#include <QAbstractProxyModel> #include <QAbstractProxyModel>
#include <QHeaderView> #include <QContextMenuEvent>
#include <QMenu>
#include <QDebug> #include <QDebug>
using namespace Valgrind::Callgrind; using namespace Valgrind::Callgrind;
...@@ -61,7 +62,7 @@ CostView::Private::Private(CostView *qq) ...@@ -61,7 +62,7 @@ CostView::Private::Private(CostView *qq)
CostView::CostView(QWidget *parent) CostView::CostView(QWidget *parent)
: QTreeView(parent) : Utils::BaseTreeView(parent)
, d(new Private(this)) , d(new Private(this))
{ {
setSelectionMode(QAbstractItemView::ExtendedSelection); setSelectionMode(QAbstractItemView::ExtendedSelection);
...@@ -91,20 +92,13 @@ void CostView::setModel(QAbstractItemModel *model) ...@@ -91,20 +92,13 @@ void CostView::setModel(QAbstractItemModel *model)
break; break;
} }
QHeaderView *headerView = header();
setItemDelegate(new QStyledItemDelegate(this)); setItemDelegate(new QStyledItemDelegate(this));
headerView->setResizeMode(QHeaderView::Interactive);
headerView->setStretchLastSection(false);
if (qobject_cast<CallModel *>(model)) { 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::CalleeColumn, d->m_nameDelegate);
setItemDelegateForColumn(CallModel::CallerColumn, d->m_nameDelegate); setItemDelegateForColumn(CallModel::CallerColumn, d->m_nameDelegate);
setItemDelegateForColumn(CallModel::CostColumn, d->m_costDelegate); setItemDelegateForColumn(CallModel::CostColumn, d->m_costDelegate);
} else if (qobject_cast<DataModel *>(model)) { } 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::InclusiveCostColumn, d->m_costDelegate);
setItemDelegateForColumn(DataModel::NameColumn, d->m_nameDelegate); setItemDelegateForColumn(DataModel::NameColumn, d->m_nameDelegate);
setItemDelegateForColumn(DataModel::SelfCostColumn, d->m_costDelegate); setItemDelegateForColumn(DataModel::SelfCostColumn, d->m_costDelegate);
...@@ -124,5 +118,13 @@ CostDelegate::CostFormat CostView::costFormat() const ...@@ -124,5 +118,13 @@ CostDelegate::CostFormat CostView::costFormat() const
return d->m_costDelegate->format(); 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 Internal
} // namespace Valgrind } // namespace Valgrind
...@@ -32,12 +32,12 @@ ...@@ -32,12 +32,12 @@
#include "callgrindcostdelegate.h" #include "callgrindcostdelegate.h"
#include <QTreeView> #include <utils/basetreeview.h>
namespace Valgrind { namespace Valgrind {
namespace Internal { namespace Internal {
class CostView : public QTreeView class CostView : public Utils::BaseTreeView
{ {
Q_OBJECT Q_OBJECT
...@@ -57,6 +57,8 @@ public: ...@@ -57,6 +57,8 @@ public:
void setCostFormat(CostDelegate::CostFormat format); void setCostFormat(CostDelegate::CostFormat format);
CostDelegate::CostFormat costFormat() const; CostDelegate::CostFormat costFormat() const;
void contextMenuEvent(QContextMenuEvent *ev);
private: private:
class Private; class Private;
Private *d; 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