From cb0ea6407fcac53f02be726476ad8fd43c32a208 Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Mon, 15 Jul 2013 16:54:50 +0200 Subject: [PATCH] QmlProfiler: resetting expanded when data changes Change-Id: Iaacbe03eecb0679da03006f439e10b1e2dfe9167 Reviewed-by: Christian Stenger Reviewed-by: Kai Koehne --- plugins/qmlprofiler/abstracttimelinemodel.h | 1 + plugins/qmlprofiler/qml/Label.qml | 2 ++ .../qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp | 10 +++++++++- plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h | 1 + plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp | 8 ++++++++ plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h | 1 + plugins/qmlprofiler/timelinemodelaggregator.cpp | 5 +++++ plugins/qmlprofiler/timelinemodelaggregator.h | 1 + plugins/qmlprofilerextension/pixmapcachemodel.cpp | 8 +++++++- plugins/qmlprofilerextension/pixmapcachemodel.h | 1 + .../qmlprofilerextension/scenegraphtimelinemodel.cpp | 8 +++++++- plugins/qmlprofilerextension/scenegraphtimelinemodel.h | 1 + 12 files changed, 44 insertions(+), 3 deletions(-) diff --git a/plugins/qmlprofiler/abstracttimelinemodel.h b/plugins/qmlprofiler/abstracttimelinemodel.h index 2eecdeef542..eb7d7e9a445 100644 --- a/plugins/qmlprofiler/abstracttimelinemodel.h +++ b/plugins/qmlprofiler/abstracttimelinemodel.h @@ -64,6 +64,7 @@ public: Q_INVOKABLE qint64 traceDuration() const; Q_INVOKABLE int getState() const; + Q_INVOKABLE virtual bool expanded(int category) const = 0; Q_INVOKABLE virtual void setExpanded(int category, bool expanded) = 0; Q_INVOKABLE virtual int categoryDepth(int categoryIndex) const = 0; Q_INVOKABLE virtual int categoryCount() const = 0; diff --git a/plugins/qmlprofiler/qml/Label.qml b/plugins/qmlprofiler/qml/Label.qml index 5c0ac3ca609..afc96b92f17 100644 --- a/plugins/qmlprofiler/qml/Label.qml +++ b/plugins/qmlprofiler/qml/Label.qml @@ -57,6 +57,8 @@ Item { } function updateHeight() { + if (expanded != qmlProfilerModelProxy.expanded(modelIndex, categoryIndex)) + expanded = qmlProfilerModelProxy.expanded(modelIndex, categoryIndex); height = root.singleRowHeight * qmlProfilerModelProxy.categoryDepth(modelIndex, categoryIndex); } diff --git a/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp b/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp index 7457e33dc84..9002d936082 100644 --- a/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp +++ b/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp @@ -61,6 +61,7 @@ public: QVector eventList; int minAnimationCount; int maxAnimationCount; + bool expanded; PaintEventsModelProxy *q; }; @@ -113,6 +114,7 @@ void PaintEventsModelProxy::clear() d->eventList.clear(); d->minAnimationCount = 1; d->maxAnimationCount = 1; + d->expanded = false; } void PaintEventsModelProxy::dataChanged() @@ -126,6 +128,7 @@ void PaintEventsModelProxy::dataChanged() emit stateChanged(); emit dataAvailable(); emit emptyChanged(); + emit expandedChanged(); } bool compareStartTimes(const PaintEventsModelProxy::QmlPaintEventData &t1, const PaintEventsModelProxy::QmlPaintEventData &t2) @@ -199,10 +202,15 @@ qint64 PaintEventsModelProxy::lastTimeMark() const return d->eventList.last().startTime + d->eventList.last().duration; } +bool PaintEventsModelProxy::expanded(int category) const +{ + return d->expanded; +} + void PaintEventsModelProxy::setExpanded(int category, bool expanded) { Q_UNUSED(category); - Q_UNUSED(expanded); + d->expanded = expanded; emit expandedChanged(); } diff --git a/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h b/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h index 677c5e5c173..eaf8e966642 100644 --- a/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h +++ b/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h @@ -80,6 +80,7 @@ public: Q_INVOKABLE qint64 lastTimeMark() const; + Q_INVOKABLE bool expanded(int category) const; Q_INVOKABLE void setExpanded(int category, bool expanded); Q_INVOKABLE int categoryDepth(int categoryIndex) const; Q_INVOKABLE int categoryCount() const; diff --git a/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp b/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp index 3984b25c441..9e8da0251bc 100644 --- a/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp +++ b/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp @@ -135,6 +135,7 @@ void BasicTimelineModel::dataChanged() emit stateChanged(); emit dataAvailable(); emit emptyChanged(); + emit expandedChanged(); } void BasicTimelineModel::BasicTimelineModelPrivate::prepare() @@ -393,6 +394,13 @@ qint64 BasicTimelineModel::lastTimeMark() const return d->startTimeData.last().startTime + d->startTimeData.last().duration; } +bool BasicTimelineModel::expanded(int category) const +{ + if (d->categorySpan.count() <= category) + return false; + return d->categorySpan[category].expanded; +} + void BasicTimelineModel::setExpanded(int category, bool expanded) { if (d->categorySpan.count() <= category) diff --git a/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h b/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h index a8e6f08aa2a..0a57541f8f4 100644 --- a/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h +++ b/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h @@ -101,6 +101,7 @@ public: Q_INVOKABLE qint64 lastTimeMark() const; + Q_INVOKABLE bool expanded(int category) const; Q_INVOKABLE void setExpanded(int category, bool expanded); Q_INVOKABLE int categoryDepth(int categoryIndex) const; Q_INVOKABLE int categoryCount() const; diff --git a/plugins/qmlprofiler/timelinemodelaggregator.cpp b/plugins/qmlprofiler/timelinemodelaggregator.cpp index 89f04d8daab..727b4ce23ba 100644 --- a/plugins/qmlprofiler/timelinemodelaggregator.cpp +++ b/plugins/qmlprofiler/timelinemodelaggregator.cpp @@ -176,6 +176,11 @@ qint64 TimelineModelAggregator::lastTimeMark() const return mark; } +bool TimelineModelAggregator::expanded(int modelIndex, int category) const +{ + return d->modelList[modelIndex]->expanded(category); +} + void TimelineModelAggregator::setExpanded(int modelIndex, int category, bool expanded) { // int modelIndex = modelIndexForCategory(category); diff --git a/plugins/qmlprofiler/timelinemodelaggregator.h b/plugins/qmlprofiler/timelinemodelaggregator.h index 9c15f362b3b..65dd3496c6a 100644 --- a/plugins/qmlprofiler/timelinemodelaggregator.h +++ b/plugins/qmlprofiler/timelinemodelaggregator.h @@ -68,6 +68,7 @@ public: Q_INVOKABLE qint64 lastTimeMark() const; + Q_INVOKABLE bool expanded(int modelIndex, int category) const; Q_INVOKABLE void setExpanded(int modelIndex, int category, bool expanded); Q_INVOKABLE int categoryDepth(int modelIndex, int categoryIndex) const; Q_INVOKABLE int categoryCount(int modelIndex) const; diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.cpp b/plugins/qmlprofilerextension/pixmapcachemodel.cpp index db8cd938bed..5f6c58784e1 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.cpp +++ b/plugins/qmlprofilerextension/pixmapcachemodel.cpp @@ -101,6 +101,11 @@ qint64 PixmapCacheModel::lastTimeMark() const return d->eventList.last().startTime; } +bool PixmapCacheModel::expanded(int category) const +{ + return d->isExpanded; +} + void PixmapCacheModel::setExpanded(int category, bool expanded) { Q_UNUSED(category); @@ -467,6 +472,7 @@ void PixmapCacheModel::clear() d->pixmapSizes.clear(); d->collapsedRowCount = 1; d->expandedRowCount = 1; + d->isExpanded = false; } void PixmapCacheModel::dataChanged() @@ -480,7 +486,7 @@ void PixmapCacheModel::dataChanged() emit stateChanged(); emit dataAvailable(); emit emptyChanged(); - return; + emit expandedChanged(); } void PixmapCacheModel::PixmapCacheModelPrivate::computeCacheSizes() diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.h b/plugins/qmlprofilerextension/pixmapcachemodel.h index 8fd38bb378d..9b006e49ce3 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.h +++ b/plugins/qmlprofilerextension/pixmapcachemodel.h @@ -73,6 +73,7 @@ public: Q_INVOKABLE qint64 lastTimeMark() const; + Q_INVOKABLE bool expanded(int category) const; Q_INVOKABLE void setExpanded(int category, bool expanded); Q_INVOKABLE int categoryDepth(int categoryIndex) const; Q_INVOKABLE int categoryCount() const; diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp index bcca3987e78..ccde5550936 100644 --- a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp +++ b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp @@ -109,6 +109,11 @@ qint64 SceneGraphTimelineModel::lastTimeMark() const return d->eventList.last().startTime; } +bool SceneGraphTimelineModel::expanded(int category) const +{ + return d->isExpanded; +} + void SceneGraphTimelineModel::setExpanded(int category, bool expanded) { Q_UNUSED(category); @@ -462,6 +467,7 @@ void SceneGraphTimelineModel::loadData() void SceneGraphTimelineModel::clear() { d->eventList.clear(); + d->isExpanded = false; } void SceneGraphTimelineModel::dataChanged() @@ -475,7 +481,7 @@ void SceneGraphTimelineModel::dataChanged() emit stateChanged(); emit dataAvailable(); emit emptyChanged(); - return; + emit expandedChanged(); } diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.h b/plugins/qmlprofilerextension/scenegraphtimelinemodel.h index 83812643a30..ae8d14eb112 100644 --- a/plugins/qmlprofilerextension/scenegraphtimelinemodel.h +++ b/plugins/qmlprofilerextension/scenegraphtimelinemodel.h @@ -61,6 +61,7 @@ public: Q_INVOKABLE qint64 lastTimeMark() const; + Q_INVOKABLE bool expanded(int category) const; Q_INVOKABLE void setExpanded(int category, bool expanded); Q_INVOKABLE int categoryDepth(int categoryIndex) const; Q_INVOKABLE int categoryCount() const;