forked from qt-creator/qt-creator
QmlProfiler: Centralize timeline rowCount calculation
Change-Id: I0db3641c0d6e750459d815e25909babf8534a4f6 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -45,6 +45,8 @@ AbstractTimelineModel::AbstractTimelineModel(AbstractTimelineModelPrivate *dd,
|
|||||||
d->displayName = displayName;
|
d->displayName = displayName;
|
||||||
d->message = message;
|
d->message = message;
|
||||||
d->rangeType = rangeType;
|
d->rangeType = rangeType;
|
||||||
|
d->expandedRowCount = 1;
|
||||||
|
d->collapsedRowCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractTimelineModel::~AbstractTimelineModel()
|
AbstractTimelineModel::~AbstractTimelineModel()
|
||||||
@@ -229,9 +231,18 @@ QString AbstractTimelineModel::displayName() const
|
|||||||
return d->displayName;
|
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()
|
void AbstractTimelineModel::clear()
|
||||||
{
|
{
|
||||||
Q_D(AbstractTimelineModel);
|
Q_D(AbstractTimelineModel);
|
||||||
|
d->collapsedRowCount = d->expandedRowCount = 1;
|
||||||
bool wasExpanded = d->expanded;
|
bool wasExpanded = d->expanded;
|
||||||
bool hadRowHeights = !d->rowOffsets.empty();
|
bool hadRowHeights = !d->rowOffsets.empty();
|
||||||
d->rowOffsets.clear();
|
d->rowOffsets.clear();
|
||||||
|
|||||||
@@ -65,9 +65,9 @@ public:
|
|||||||
bool expanded() const;
|
bool expanded() const;
|
||||||
void setExpanded(bool expanded);
|
void setExpanded(bool expanded);
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
|
int rowCount() const;
|
||||||
|
|
||||||
// Methods that have to be implemented by child models
|
// Methods that have to be implemented by child models
|
||||||
virtual int rowCount() const = 0;
|
|
||||||
virtual int eventId(int index) const = 0;
|
virtual int eventId(int index) const = 0;
|
||||||
virtual QColor color(int index) const = 0;
|
virtual QColor color(int index) const = 0;
|
||||||
virtual QVariantList labels() const = 0;
|
virtual QVariantList labels() const = 0;
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public:
|
|||||||
QmlProfilerModelManager *modelManager;
|
QmlProfilerModelManager *modelManager;
|
||||||
int modelId;
|
int modelId;
|
||||||
bool expanded;
|
bool expanded;
|
||||||
|
int expandedRowCount;
|
||||||
|
int collapsedRowCount;
|
||||||
QString displayName;
|
QString displayName;
|
||||||
QmlDebug::Message message;
|
QmlDebug::Message message;
|
||||||
QmlDebug::RangeType rangeType;
|
QmlDebug::RangeType rangeType;
|
||||||
|
|||||||
@@ -140,21 +140,13 @@ void PaintEventsModelProxy::loadData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
computeNesting();
|
computeNesting();
|
||||||
|
d->expandedRowCount = d->collapsedRowCount =
|
||||||
|
(d->maxGuiThreadAnimations == 0 || d->maxRenderThreadAnimations == 0) ? 2 : 3;
|
||||||
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1);
|
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////// QML interface
|
/////////////////// 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(
|
int PaintEventsModelProxy::PaintEventsModelProxyPrivate::rowFromThreadId(
|
||||||
QmlDebug::AnimationThread threadId) const
|
QmlDebug::AnimationThread threadId) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ public:
|
|||||||
|
|
||||||
int rowMaxValue(int rowNumber) const;
|
int rowMaxValue(int rowNumber) const;
|
||||||
|
|
||||||
int rowCount() const;
|
|
||||||
int eventId(int index) const;
|
int eventId(int index) const;
|
||||||
int row(int index) const;
|
int row(int index) const;
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ public:
|
|||||||
|
|
||||||
QVector<QmlRangeEventStartInstance> data;
|
QVector<QmlRangeEventStartInstance> data;
|
||||||
QVector<int> expandedRowTypes;
|
QVector<int> expandedRowTypes;
|
||||||
int contractedRows;
|
|
||||||
bool seenPaintEvent;
|
|
||||||
private:
|
private:
|
||||||
Q_DECLARE_PUBLIC(RangeTimelineModel)
|
Q_DECLARE_PUBLIC(RangeTimelineModel)
|
||||||
};
|
};
|
||||||
@@ -65,9 +63,7 @@ RangeTimelineModel::RangeTimelineModel(QmlDebug::RangeType rangeType, QObject *p
|
|||||||
QmlDebug::MaximumMessage, rangeType, parent)
|
QmlDebug::MaximumMessage, rangeType, parent)
|
||||||
{
|
{
|
||||||
Q_D(RangeTimelineModel);
|
Q_D(RangeTimelineModel);
|
||||||
d->seenPaintEvent = false;
|
|
||||||
d->expandedRowTypes << -1;
|
d->expandedRowTypes << -1;
|
||||||
d->contractedRows = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 RangeTimelineModel::features() const
|
quint64 RangeTimelineModel::features() const
|
||||||
@@ -81,8 +77,6 @@ void RangeTimelineModel::clear()
|
|||||||
Q_D(RangeTimelineModel);
|
Q_D(RangeTimelineModel);
|
||||||
d->expandedRowTypes.clear();
|
d->expandedRowTypes.clear();
|
||||||
d->expandedRowTypes << -1;
|
d->expandedRowTypes << -1;
|
||||||
d->contractedRows = 1;
|
|
||||||
d->seenPaintEvent = false;
|
|
||||||
d->data.clear();
|
d->data.clear();
|
||||||
AbstractTimelineModel::clear();
|
AbstractTimelineModel::clear();
|
||||||
}
|
}
|
||||||
@@ -102,8 +96,6 @@ void RangeTimelineModel::loadData()
|
|||||||
const QmlProfilerDataModel::QmlEventTypeData &type = typesList[event.typeIndex];
|
const QmlProfilerDataModel::QmlEventTypeData &type = typesList[event.typeIndex];
|
||||||
if (!accepted(type))
|
if (!accepted(type))
|
||||||
continue;
|
continue;
|
||||||
if (type.rangeType == QmlDebug::Painting)
|
|
||||||
d->seenPaintEvent = true;
|
|
||||||
|
|
||||||
// store starttime-based instance
|
// store starttime-based instance
|
||||||
d->data.insert(insert(event.startTime, event.duration),
|
d->data.insert(insert(event.startTime, event.duration),
|
||||||
@@ -140,7 +132,7 @@ void RangeTimelineModel::RangeTimelineModelPrivate::computeNestingContracted()
|
|||||||
int eventCount = q->count();
|
int eventCount = q->count();
|
||||||
|
|
||||||
int nestingLevels = QmlDebug::Constants::QML_MIN_LEVEL;
|
int nestingLevels = QmlDebug::Constants::QML_MIN_LEVEL;
|
||||||
contractedRows = nestingLevels + 1;
|
collapsedRowCount = nestingLevels + 1;
|
||||||
QVector<qint64> nestingEndTimes;
|
QVector<qint64> nestingEndTimes;
|
||||||
nestingEndTimes.fill(0, nestingLevels + 1);
|
nestingEndTimes.fill(0, nestingLevels + 1);
|
||||||
|
|
||||||
@@ -151,8 +143,8 @@ void RangeTimelineModel::RangeTimelineModelPrivate::computeNestingContracted()
|
|||||||
if (nestingEndTimes[nestingLevels] > st) {
|
if (nestingEndTimes[nestingLevels] > st) {
|
||||||
if (++nestingLevels == nestingEndTimes.size())
|
if (++nestingLevels == nestingEndTimes.size())
|
||||||
nestingEndTimes << 0;
|
nestingEndTimes << 0;
|
||||||
if (nestingLevels == contractedRows)
|
if (nestingLevels == collapsedRowCount)
|
||||||
++contractedRows;
|
++collapsedRowCount;
|
||||||
} else {
|
} else {
|
||||||
while (nestingLevels > QmlDebug::Constants::QML_MIN_LEVEL &&
|
while (nestingLevels > QmlDebug::Constants::QML_MIN_LEVEL &&
|
||||||
nestingEndTimes[nestingLevels-1] <= st)
|
nestingEndTimes[nestingLevels-1] <= st)
|
||||||
@@ -177,6 +169,7 @@ void RangeTimelineModel::RangeTimelineModelPrivate::computeExpandedLevels()
|
|||||||
}
|
}
|
||||||
data[i].displayRowExpanded = eventRow[eventId];
|
data[i].displayRowExpanded = eventRow[eventId];
|
||||||
}
|
}
|
||||||
|
expandedRowCount = expandedRowTypes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RangeTimelineModel::RangeTimelineModelPrivate::findBindingLoops()
|
void RangeTimelineModel::RangeTimelineModelPrivate::findBindingLoops()
|
||||||
@@ -216,18 +209,6 @@ void RangeTimelineModel::RangeTimelineModelPrivate::findBindingLoops()
|
|||||||
|
|
||||||
/////////////////// QML interface
|
/////////////////// 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)
|
QString RangeTimelineModel::categoryLabel(QmlDebug::RangeType rangeType)
|
||||||
{
|
{
|
||||||
return QCoreApplication::translate("MainView",
|
return QCoreApplication::translate("MainView",
|
||||||
@@ -268,8 +249,7 @@ QVariantList RangeTimelineModel::labels() const
|
|||||||
if (d->expanded) {
|
if (d->expanded) {
|
||||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
|
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
|
||||||
d->modelManager->qmlModel()->getEventTypes();
|
d->modelManager->qmlModel()->getEventTypes();
|
||||||
int eventCount = d->expandedRowTypes.count();
|
for (int i = 1; i < d->expandedRowCount; i++) { // Ignore the -1 for the first row
|
||||||
for (int i = 1; i < eventCount; i++) { // Ignore the -1 for the first row
|
|
||||||
QVariantMap element;
|
QVariantMap element;
|
||||||
int typeId = d->expandedRowTypes[i];
|
int typeId = d->expandedRowTypes[i];
|
||||||
element.insert(QLatin1String("displayName"), QVariant(types[typeId].displayName));
|
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
|
// if this is called from v8 view, we don't have the column number, it will be -1
|
||||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
|
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
|
||||||
d->modelManager->qmlModel()->getEventTypes();
|
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];
|
int typeId = d->expandedRowTypes[i];
|
||||||
const QmlProfilerDataModel::QmlEventTypeData &eventData = types[typeId];
|
const QmlProfilerDataModel::QmlEventTypeData &eventData = types[typeId];
|
||||||
if (eventData.location.filename == filename &&
|
if (eventData.location.filename == filename &&
|
||||||
|
|||||||
@@ -68,10 +68,6 @@ public:
|
|||||||
void loadData();
|
void loadData();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
|
||||||
// QML interface
|
|
||||||
|
|
||||||
int rowCount() const;
|
|
||||||
static QString categoryLabel(QmlDebug::RangeType categoryIndex);
|
static QString categoryLabel(QmlDebug::RangeType categoryIndex);
|
||||||
quint64 features() const;
|
quint64 features() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user