From abcb7b0604e68833fc8041987ec6124ead481bc3 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 18 Feb 2014 17:40:58 +0100 Subject: [PATCH] QmlProfiler: Move the data structs of the V8 model into the model class QmlProfilerDataModel does it the same way and we don't pollute the namespace as much like this. Change-Id: Id1ed2c444cb2556fb8f1c886a754e51f3eae5772 Reviewed-by: Kai Koehne --- .../qmlprofiler/qv8profilerdatamodel.cpp | 18 +++--- .../qmlprofiler/qv8profilerdatamodel.h | 62 +++++++++---------- .../qmlprofiler/qv8profilereventview.cpp | 15 ++--- .../qmlprofiler/qv8profilereventview.h | 4 +- 4 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp b/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp index d4edb6dbac2..4e2423d3981 100644 --- a/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp @@ -35,24 +35,24 @@ #include QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(QmlProfiler::QV8EventData, Q_MOVABLE_TYPE); -Q_DECLARE_TYPEINFO(QmlProfiler::QV8EventSub, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QmlProfiler::QV8ProfilerDataModel::QV8EventData, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QmlProfiler::QV8ProfilerDataModel::QV8EventSub, Q_MOVABLE_TYPE); QT_END_NAMESPACE namespace QmlProfiler { -typedef QHash EventHash; +typedef QHash EventHash; static EventHash cloneEventHash(const EventHash &src) { EventHash result; const EventHash::ConstIterator cend = src.constEnd(); for (EventHash::ConstIterator it = src.constBegin(); it != cend; ++it) - result.insert(it.key(), new QV8EventSub(it.value())); + result.insert(it.key(), new QV8ProfilerDataModel::QV8EventSub(it.value())); return result; } -QV8EventData &QV8EventData::operator=(const QV8EventData &ref) +QV8ProfilerDataModel::QV8EventData &QV8ProfilerDataModel::QV8EventData::operator=(const QV8EventData &ref) { if (this == &ref) return *this; @@ -77,7 +77,7 @@ QV8EventData &QV8EventData::operator=(const QV8EventData &ref) return *this; } -QV8EventData::QV8EventData() +QV8ProfilerDataModel::QV8EventData::QV8EventData() { line = -1; eventId = -1; @@ -87,7 +87,7 @@ QV8EventData::QV8EventData() SelfTimeInPercent = 0; } -QV8EventData::~QV8EventData() +QV8ProfilerDataModel::QV8EventData::~QV8EventData() { qDeleteAll(parentHash.values()); parentHash.clear(); @@ -137,7 +137,7 @@ bool QV8ProfilerDataModel::isEmpty() const return d->v8EventHash.isEmpty(); } -QV8EventData *QV8ProfilerDataModel::v8EventDescription(int eventId) const +QV8ProfilerDataModel::QV8EventData *QV8ProfilerDataModel::v8EventDescription(int eventId) const { foreach (QV8EventData *event, d->v8EventHash) { if (event->eventId == eventId) @@ -151,7 +151,7 @@ qint64 QV8ProfilerDataModel::v8MeasuredTime() const return d->v8MeasuredTime; } -QList QV8ProfilerDataModel::getV8Events() const +QList QV8ProfilerDataModel::getV8Events() const { return d->v8EventHash.values(); } diff --git a/src/plugins/qmlprofiler/qv8profilerdatamodel.h b/src/plugins/qmlprofiler/qv8profilerdatamodel.h index 48492405bf5..a663a4373cb 100644 --- a/src/plugins/qmlprofiler/qv8profilerdatamodel.h +++ b/src/plugins/qmlprofiler/qv8profilerdatamodel.h @@ -41,41 +41,41 @@ namespace QmlProfiler { -struct QV8EventSub; - -struct QV8EventData -{ - QV8EventData(); - ~QV8EventData(); - - QString displayName; - QString eventHashStr; - QString filename; - QString functionName; - int line; - double totalTime; // given in milliseconds - double totalPercent; - double selfTime; - double SelfTimeInPercent; - QHash parentHash; - QHash childrenHash; - int eventId; - - QV8EventData &operator=(const QV8EventData &ref); -}; - -struct QV8EventSub { - QV8EventSub(QV8EventData *from) : reference(from), totalTime(0) {} - QV8EventSub(QV8EventSub *from) : reference(from->reference), totalTime(from->totalTime) {} - - QV8EventData *reference; - qint64 totalTime; -}; - class QV8ProfilerDataModel : public QmlProfilerBaseModel { Q_OBJECT public: + struct QV8EventSub; + + struct QV8EventData + { + QV8EventData(); + ~QV8EventData(); + + QString displayName; + QString eventHashStr; + QString filename; + QString functionName; + int line; + double totalTime; // given in milliseconds + double totalPercent; + double selfTime; + double SelfTimeInPercent; + QHash parentHash; + QHash childrenHash; + int eventId; + + QV8EventData &operator=(const QV8EventData &ref); + }; + + struct QV8EventSub { + QV8EventSub(QV8EventData *from) : reference(from), totalTime(0) {} + QV8EventSub(QV8EventSub *from) : reference(from->reference), totalTime(from->totalTime) {} + + QV8EventData *reference; + qint64 totalTime; + }; + QV8ProfilerDataModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent = 0); ~QV8ProfilerDataModel(); diff --git a/src/plugins/qmlprofiler/qv8profilereventview.cpp b/src/plugins/qmlprofiler/qv8profilereventview.cpp index dc87af30612..92d9f188b59 100644 --- a/src/plugins/qmlprofiler/qv8profilereventview.cpp +++ b/src/plugins/qmlprofiler/qv8profilereventview.cpp @@ -263,7 +263,7 @@ class QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate public: QV8ProfilerEventsMainViewPrivate(QV8ProfilerEventsMainView *qq) : q(qq) {} - void buildV8ModelFromList( const QList &list ); + void buildV8ModelFromList( const QList &list ); int getFieldCount(); QString textForItem(QStandardItem *item, bool recursive) const; @@ -428,10 +428,11 @@ void QV8ProfilerEventsMainView::buildModel() collapseAll(); } -void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFromList(const QList &list) +void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFromList( + const QList &list) { for (int index = 0; index < list.count(); index++) { - QV8EventData *v8event = list.at(index); + QV8ProfilerDataModel::QV8EventData *v8event = list.at(index); QList newRow; if (m_fieldShown[Name]) @@ -639,10 +640,10 @@ QV8ProfilerEventRelativesView::~QV8ProfilerEventRelativesView() void QV8ProfilerEventRelativesView::displayEvent(int index) { - QV8EventData *event = m_v8Model->v8EventDescription(index); + QV8ProfilerDataModel::QV8EventData *event = m_v8Model->v8EventDescription(index); QTC_CHECK(event); - QList events; + QList events; if (m_type == ParentsView) events = event->parentHash.values(); else @@ -656,13 +657,13 @@ void QV8ProfilerEventRelativesView::displayEvent(int index) sortByColumn(1); } -void QV8ProfilerEventRelativesView::rebuildTree(QList events) +void QV8ProfilerEventRelativesView::rebuildTree(QList events) { clear(); QStandardItem *topLevelItem = m_model->invisibleRootItem(); - foreach (QV8EventSub *event, events) { + foreach (QV8ProfilerDataModel::QV8EventSub *event, events) { QList newRow; newRow << new EventsViewItem(event->reference->displayName); newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event->totalTime)); diff --git a/src/plugins/qmlprofiler/qv8profilereventview.h b/src/plugins/qmlprofiler/qv8profilereventview.h index 6224d526263..cee7484e3e3 100644 --- a/src/plugins/qmlprofiler/qv8profilereventview.h +++ b/src/plugins/qmlprofiler/qv8profilereventview.h @@ -34,6 +34,7 @@ #include #include "qmlprofilermodelmanager.h" #include "qmlprofilereventsmodelproxy.h" +#include "qv8profilerdatamodel.h" #include "qmlprofilertreeview.h" #include @@ -41,7 +42,6 @@ #include "qmlprofilerviewmanager.h" namespace QmlProfiler { -struct QV8EventSub; namespace Internal { @@ -148,7 +148,7 @@ public slots: void clear(); private: - void rebuildTree(QList events); + void rebuildTree(QList events); void updateHeader(); QV8ProfilerEventRelativesView::SubViewType m_type;