diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel.cpp b/src/plugins/qmlprofiler/abstracttimelinemodel.cpp index e13cb2272f2..1124d5958a6 100644 --- a/src/plugins/qmlprofiler/abstracttimelinemodel.cpp +++ b/src/plugins/qmlprofiler/abstracttimelinemodel.cpp @@ -45,6 +45,8 @@ AbstractTimelineModel::AbstractTimelineModel(AbstractTimelineModelPrivate *dd, d->displayName = displayName; d->message = message; d->rangeType = rangeType; + d->expandedRowCount = 1; + d->collapsedRowCount = 1; } AbstractTimelineModel::~AbstractTimelineModel() @@ -229,9 +231,18 @@ QString AbstractTimelineModel::displayName() const return d->displayName; } +int AbstractTimelineModel::rowCount() const +{ + Q_D(const AbstractTimelineModel); + if (isEmpty()) + return d->modelManager->isEmpty() ? 1 : 0; + return d->expanded ? d->expandedRowCount : d->collapsedRowCount; +} + void AbstractTimelineModel::clear() { Q_D(AbstractTimelineModel); + d->collapsedRowCount = d->expandedRowCount = 1; bool wasExpanded = d->expanded; bool hadRowHeights = !d->rowOffsets.empty(); d->rowOffsets.clear(); diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel.h b/src/plugins/qmlprofiler/abstracttimelinemodel.h index 552d2de909e..24be2fc614a 100644 --- a/src/plugins/qmlprofiler/abstracttimelinemodel.h +++ b/src/plugins/qmlprofiler/abstracttimelinemodel.h @@ -65,9 +65,9 @@ public: bool expanded() const; void setExpanded(bool expanded); QString displayName() const; + int rowCount() const; // Methods that have to be implemented by child models - virtual int rowCount() const = 0; virtual int eventId(int index) const = 0; virtual QColor color(int index) const = 0; virtual QVariantList labels() const = 0; diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel_p.h b/src/plugins/qmlprofiler/abstracttimelinemodel_p.h index 421adb3b99d..9696b17b286 100644 --- a/src/plugins/qmlprofiler/abstracttimelinemodel_p.h +++ b/src/plugins/qmlprofiler/abstracttimelinemodel_p.h @@ -40,6 +40,8 @@ public: QmlProfilerModelManager *modelManager; int modelId; bool expanded; + int expandedRowCount; + int collapsedRowCount; QString displayName; QmlDebug::Message message; QmlDebug::RangeType rangeType; diff --git a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp index 4a5453d998b..910b4760d05 100644 --- a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp @@ -140,21 +140,13 @@ void PaintEventsModelProxy::loadData() } computeNesting(); - + d->expandedRowCount = d->collapsedRowCount = + (d->maxGuiThreadAnimations == 0 || d->maxRenderThreadAnimations == 0) ? 2 : 3; d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1); } /////////////////// QML interface -int PaintEventsModelProxy::rowCount() const -{ - Q_D(const PaintEventsModelProxy); - if (isEmpty()) - return 1; - else - return (d->maxGuiThreadAnimations == 0 || d->maxRenderThreadAnimations == 0) ? 2 : 3; -} - int PaintEventsModelProxy::PaintEventsModelProxyPrivate::rowFromThreadId( QmlDebug::AnimationThread threadId) const { diff --git a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h index bcdbfbbe81d..2493efd81b2 100644 --- a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h +++ b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h @@ -66,7 +66,6 @@ public: int rowMaxValue(int rowNumber) const; - int rowCount() const; int eventId(int index) const; int row(int index) const; diff --git a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp index a594002d563..32a15c9dc5a 100644 --- a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp @@ -54,8 +54,6 @@ public: QVector data; QVector expandedRowTypes; - int contractedRows; - bool seenPaintEvent; private: Q_DECLARE_PUBLIC(RangeTimelineModel) }; @@ -65,9 +63,7 @@ RangeTimelineModel::RangeTimelineModel(QmlDebug::RangeType rangeType, QObject *p QmlDebug::MaximumMessage, rangeType, parent) { Q_D(RangeTimelineModel); - d->seenPaintEvent = false; d->expandedRowTypes << -1; - d->contractedRows = 1; } quint64 RangeTimelineModel::features() const @@ -81,8 +77,6 @@ void RangeTimelineModel::clear() Q_D(RangeTimelineModel); d->expandedRowTypes.clear(); d->expandedRowTypes << -1; - d->contractedRows = 1; - d->seenPaintEvent = false; d->data.clear(); AbstractTimelineModel::clear(); } @@ -102,8 +96,6 @@ void RangeTimelineModel::loadData() const QmlProfilerDataModel::QmlEventTypeData &type = typesList[event.typeIndex]; if (!accepted(type)) continue; - if (type.rangeType == QmlDebug::Painting) - d->seenPaintEvent = true; // store starttime-based instance d->data.insert(insert(event.startTime, event.duration), @@ -140,7 +132,7 @@ void RangeTimelineModel::RangeTimelineModelPrivate::computeNestingContracted() int eventCount = q->count(); int nestingLevels = QmlDebug::Constants::QML_MIN_LEVEL; - contractedRows = nestingLevels + 1; + collapsedRowCount = nestingLevels + 1; QVector nestingEndTimes; nestingEndTimes.fill(0, nestingLevels + 1); @@ -151,8 +143,8 @@ void RangeTimelineModel::RangeTimelineModelPrivate::computeNestingContracted() if (nestingEndTimes[nestingLevels] > st) { if (++nestingLevels == nestingEndTimes.size()) nestingEndTimes << 0; - if (nestingLevels == contractedRows) - ++contractedRows; + if (nestingLevels == collapsedRowCount) + ++collapsedRowCount; } else { while (nestingLevels > QmlDebug::Constants::QML_MIN_LEVEL && nestingEndTimes[nestingLevels-1] <= st) @@ -177,6 +169,7 @@ void RangeTimelineModel::RangeTimelineModelPrivate::computeExpandedLevels() } data[i].displayRowExpanded = eventRow[eventId]; } + expandedRowCount = expandedRowTypes.size(); } void RangeTimelineModel::RangeTimelineModelPrivate::findBindingLoops() @@ -216,18 +209,6 @@ void RangeTimelineModel::RangeTimelineModelPrivate::findBindingLoops() /////////////////// QML interface -int RangeTimelineModel::rowCount() const -{ - Q_D(const RangeTimelineModel); - // special for paint events: show only when empty model or there's actual events - if (d->rangeType == QmlDebug::Painting && !d->seenPaintEvent) - return 0; - if (d->expanded) - return d->expandedRowTypes.size(); - else - return d->contractedRows; -} - QString RangeTimelineModel::categoryLabel(QmlDebug::RangeType rangeType) { return QCoreApplication::translate("MainView", @@ -268,8 +249,7 @@ QVariantList RangeTimelineModel::labels() const if (d->expanded) { const QVector &types = d->modelManager->qmlModel()->getEventTypes(); - int eventCount = d->expandedRowTypes.count(); - for (int i = 1; i < eventCount; i++) { // Ignore the -1 for the first row + for (int i = 1; i < d->expandedRowCount; i++) { // Ignore the -1 for the first row QVariantMap element; int typeId = d->expandedRowTypes[i]; element.insert(QLatin1String("displayName"), QVariant(types[typeId].displayName)); @@ -332,7 +312,7 @@ int RangeTimelineModel::eventIdForLocation(const QString &filename, int line, in // if this is called from v8 view, we don't have the column number, it will be -1 const QVector &types = d->modelManager->qmlModel()->getEventTypes(); - for (int i = 1; i < d->expandedRowTypes.size(); ++i) { + for (int i = 1; i < d->expandedRowCount; ++i) { int typeId = d->expandedRowTypes[i]; const QmlProfilerDataModel::QmlEventTypeData &eventData = types[typeId]; if (eventData.location.filename == filename && diff --git a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h index 9c6f71a5889..22ad43c9451 100644 --- a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h +++ b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h @@ -68,10 +68,6 @@ public: void loadData(); void clear(); - -// QML interface - - int rowCount() const; static QString categoryLabel(QmlDebug::RangeType categoryIndex); quint64 features() const;