diff --git a/src/libs/valgrind/callgrind/callgrindabstractmodel.cpp b/src/libs/valgrind/callgrind/callgrindabstractmodel.cpp index f55790d7779..58c15a3bf90 100644 --- a/src/libs/valgrind/callgrind/callgrindabstractmodel.cpp +++ b/src/libs/valgrind/callgrind/callgrindabstractmodel.cpp @@ -30,23 +30,3 @@ ** Nokia at qt-info@nokia.com. ** **************************************************************************/ - -#include "callgrindparsedata.h" -#include "callgrinddatamodel.h" - -namespace Valgrind { -namespace Callgrind { - -AbstractModel::AbstractModel() -{ - -} - -AbstractModel::~AbstractModel() -{ - -} - - -} // Callgrind -} // Valgrind diff --git a/src/libs/valgrind/callgrind/callgrindabstractmodel.h b/src/libs/valgrind/callgrind/callgrindabstractmodel.h index 2bd253c07b5..680eecad6e8 100644 --- a/src/libs/valgrind/callgrind/callgrindabstractmodel.h +++ b/src/libs/valgrind/callgrind/callgrindabstractmodel.h @@ -36,37 +36,19 @@ #include "../valgrind_global.h" +#include + namespace Valgrind { namespace Callgrind { class ParseData; -class VALGRINDSHARED_EXPORT AbstractModel { -public: - AbstractModel(); - virtual ~AbstractModel(); - - virtual void setParseData(const ParseData *data) = 0; - virtual const ParseData *parseData() const = 0; - - /// Only one cost event column will be shown, this decides which one it is. - /// By default it is the first event in the @c ParseData, i.e. 0. - virtual int costEvent() const = 0; - - //BEGIN SLOTS - virtual void setCostEvent(int event) = 0; - //END SLOTS - - //BEGIN SIGNALS - virtual void parseDataChanged(AbstractModel *model) = 0; - //END SIGNALS - - enum Roles { - ParentCostRole = Qt::UserRole, - RelativeTotalCostRole, - RelativeParentCostRole, - NextCustomRole - }; +enum AbstractModelRoles +{ + ParentCostRole = Qt::UserRole, + RelativeTotalCostRole, + RelativeParentCostRole, + NextCustomRole }; } // Callgrind diff --git a/src/libs/valgrind/callgrind/callgrindcallmodel.cpp b/src/libs/valgrind/callgrind/callgrindcallmodel.cpp index 40664f6df39..29963b596f9 100644 --- a/src/libs/valgrind/callgrind/callgrindcallmodel.cpp +++ b/src/libs/valgrind/callgrind/callgrindcallmodel.cpp @@ -69,10 +69,8 @@ CallModel::Private::Private() //BEGIN CallModel CallModel::CallModel(QObject *parent) -: QAbstractItemModel(parent) -, d(new Private) + : QAbstractItemModel(parent), d(new Private) { - } CallModel::~CallModel() @@ -125,7 +123,6 @@ void CallModel::setParseData(const ParseData *data) clear(); d->m_data = data; - emit parseDataChanged(this); } const ParseData *CallModel::parseData() const diff --git a/src/libs/valgrind/callgrind/callgrindcallmodel.h b/src/libs/valgrind/callgrind/callgrindcallmodel.h index d64e67c7ab6..383c6bb5c1c 100644 --- a/src/libs/valgrind/callgrind/callgrindcallmodel.h +++ b/src/libs/valgrind/callgrind/callgrindcallmodel.h @@ -50,12 +50,11 @@ class Function; /** * Model to display list of function calls. */ -class VALGRINDSHARED_EXPORT CallModel : public QAbstractItemModel, public AbstractModel +class VALGRINDSHARED_EXPORT CallModel : public QAbstractItemModel { Q_OBJECT - public: - explicit CallModel(QObject *parent = 0); + explicit CallModel(QObject *parent); virtual ~CallModel(); void clear(); @@ -63,6 +62,7 @@ public: /// Only one cost event column will be shown, this decides which one it is. /// By default it is the first event in the @c ParseData, i.e. 0. virtual int costEvent() const; + virtual void setCostEvent(int event); virtual void setParseData(const ParseData *data); virtual const ParseData *parseData() const; @@ -87,17 +87,9 @@ public: }; enum Roles { - FunctionCallRole = AbstractModel::NextCustomRole + FunctionCallRole = NextCustomRole }; -public slots: - /// Only one cost event column will be shown, this decides which one it is. - /// By default it is the first event in the @c ParseData, i.e. 0. - void setCostEvent(int event); - -signals: - void parseDataChanged(AbstractModel *model); - private: class Private; Private *d; diff --git a/src/libs/valgrind/callgrind/callgrinddatamodel.cpp b/src/libs/valgrind/callgrind/callgrinddatamodel.cpp index 5449ef085dd..ff3c595ac9f 100644 --- a/src/libs/valgrind/callgrind/callgrinddatamodel.cpp +++ b/src/libs/valgrind/callgrind/callgrinddatamodel.cpp @@ -108,8 +108,7 @@ void DataModel::Private::updateFunctions() //BEGIN DataModel DataModel::DataModel(QObject *parent) -: QAbstractItemModel(parent) -, d(new Private) + : QAbstractItemModel(parent), d(new Private) { } @@ -129,7 +128,6 @@ void DataModel::setParseData(const ParseData *data) d->m_event = 0; d->updateFunctions(); endResetModel(); - emit parseDataChanged(this); } const ParseData *DataModel::parseData() const diff --git a/src/libs/valgrind/callgrind/callgrinddatamodel.h b/src/libs/valgrind/callgrind/callgrinddatamodel.h index 61a655cb601..47e641ce2ef 100644 --- a/src/libs/valgrind/callgrind/callgrinddatamodel.h +++ b/src/libs/valgrind/callgrind/callgrinddatamodel.h @@ -47,12 +47,12 @@ namespace Callgrind { class Function; class ParseData; -class VALGRINDSHARED_EXPORT DataModel : public QAbstractItemModel, public AbstractModel +class VALGRINDSHARED_EXPORT DataModel : public QAbstractItemModel { Q_OBJECT public: - explicit DataModel(QObject *parent = 0); + explicit DataModel(QObject *parent); virtual ~DataModel(); virtual void setParseData(const ParseData *data); @@ -82,7 +82,7 @@ public: }; enum Roles { - FunctionRole = AbstractModel::NextCustomRole, + FunctionRole = NextCustomRole, LineNumberRole, FileNameRole }; @@ -95,9 +95,6 @@ public slots: /// By default it is the first event in the @c ParseData, i.e. 0. virtual void setCostEvent(int event); -signals: - void parseDataChanged(AbstractModel *model); - private: class Private; Private *d; diff --git a/src/plugins/callgrind/callgrindcostdelegate.cpp b/src/plugins/callgrind/callgrindcostdelegate.cpp index d3336da251a..bd1a53700f5 100644 --- a/src/plugins/callgrind/callgrindcostdelegate.cpp +++ b/src/plugins/callgrind/callgrindcostdelegate.cpp @@ -51,13 +51,12 @@ using namespace Valgrind::Callgrind; namespace Callgrind { namespace Internal { -//BEGIN CostDelegate::Private -class CostDelegate::Private { +class CostDelegate::Private +{ public: Private(); - ~Private(); - Valgrind::Callgrind::AbstractModel *m_model; + QAbstractItemModel *m_model; CostDelegate::CostFormat m_format; static int toNativeRole(CostFormat format); @@ -69,12 +68,6 @@ CostDelegate::Private::Private() : m_model(0) , m_format(CostDelegate::FormatAbsolute) { - -} - -CostDelegate::Private::~Private() -{ - } int CostDelegate::Private::toNativeRole(CostDelegate::CostFormat format) @@ -83,9 +76,9 @@ int CostDelegate::Private::toNativeRole(CostDelegate::CostFormat format) { case FormatAbsolute: case FormatRelative: - return Valgrind::Callgrind::AbstractModel::RelativeTotalCostRole; + return Valgrind::Callgrind::RelativeTotalCostRole; case FormatRelativeToParent: - return Valgrind::Callgrind::AbstractModel::RelativeParentCostRole; + return Valgrind::Callgrind::RelativeParentCostRole; default: return -1; } @@ -129,7 +122,7 @@ CostDelegate::~CostDelegate() delete d; } -void CostDelegate::setModel(Valgrind::Callgrind::AbstractModel *model) +void CostDelegate::setModel(QAbstractItemModel *model) { d->m_model = model; } diff --git a/src/plugins/callgrind/callgrindcostdelegate.h b/src/plugins/callgrind/callgrindcostdelegate.h index f93349c0370..091cfb01e6b 100644 --- a/src/plugins/callgrind/callgrindcostdelegate.h +++ b/src/plugins/callgrind/callgrindcostdelegate.h @@ -36,16 +36,9 @@ #include -namespace Valgrind { -namespace Callgrind { -class AbstractModel; -} -} - namespace Callgrind { namespace Internal { - class CostDelegate : public QStyledItemDelegate { Q_OBJECT @@ -58,7 +51,7 @@ public: const QModelIndex &index) const; virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; - void setModel(Valgrind::Callgrind::AbstractModel *model); + void setModel(QAbstractItemModel *model); enum CostFormat { /// show absolute numbers @@ -77,7 +70,6 @@ private: Private *d; }; - } // Internal } // Callgrind diff --git a/src/plugins/callgrind/callgrindcostview.cpp b/src/plugins/callgrind/callgrindcostview.cpp index 468d607914a..d756346c532 100644 --- a/src/plugins/callgrind/callgrindcostview.cpp +++ b/src/plugins/callgrind/callgrindcostview.cpp @@ -96,12 +96,7 @@ void CostView::setModel(QAbstractItemModel *model) { QTreeView::setModel(model); - AbstractModel *abstractModel = 0; forever { - abstractModel = dynamic_cast(model); - if (abstractModel) - break; - QAbstractProxyModel *proxy = qobject_cast(model); if (proxy) model = proxy->sourceModel(); @@ -114,7 +109,7 @@ void CostView::setModel(QAbstractItemModel *model) headerView->setResizeMode(QHeaderView::Interactive); headerView->setStretchLastSection(false); - if (dynamic_cast(abstractModel)) { + if (qobject_cast(model)) { setItemDelegateForColumn(CallModel::CostColumn, d->m_costDelegate); headerView->setResizeMode(CallModel::CostColumn, QHeaderView::ResizeToContents); headerView->setResizeMode(CallModel::CallsColumn, QHeaderView::ResizeToContents); @@ -122,7 +117,7 @@ void CostView::setModel(QAbstractItemModel *model) setItemDelegateForColumn(CallModel::CalleeColumn, d->m_nameDelegate); headerView->setResizeMode(CallModel::CallerColumn, QHeaderView::Stretch); setItemDelegateForColumn(CallModel::CallerColumn, d->m_nameDelegate); - } else if(dynamic_cast(abstractModel)) { + } else if (qobject_cast(model)) { setItemDelegateForColumn(DataModel::SelfCostColumn, d->m_costDelegate); headerView->setResizeMode(DataModel::SelfCostColumn, QHeaderView::ResizeToContents); setItemDelegateForColumn(DataModel::InclusiveCostColumn, d->m_costDelegate); @@ -132,7 +127,7 @@ void CostView::setModel(QAbstractItemModel *model) headerView->setResizeMode(DataModel::LocationColumn, QHeaderView::Stretch); } - d->m_costDelegate->setModel(abstractModel); + d->m_costDelegate->setModel(model); } void CostView::setCostFormat(CostDelegate::CostFormat format) diff --git a/src/plugins/callgrind/callgrindtextmark.cpp b/src/plugins/callgrind/callgrindtextmark.cpp index b365f3cc029..f78612e5f91 100644 --- a/src/plugins/callgrind/callgrindtextmark.cpp +++ b/src/plugins/callgrind/callgrindtextmark.cpp @@ -60,7 +60,7 @@ void CallgrindTextMark::paint(QPainter *painter, const QRect &paintRect) const return; bool ok; - qreal costs = m_modelIndex.data(DataModel::RelativeTotalCostRole).toReal(&ok); + qreal costs = m_modelIndex.data(RelativeTotalCostRole).toReal(&ok); QTC_ASSERT(ok, return) QTC_ASSERT(costs >= 0.0 && costs <= 100.0, return)