Commit 092627f6 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Simplify range details



There is no use in creating multiple nested maps and lists and
selecting special translation contexts for that.

Change-Id: Ib83ab651adca8258a0e5b9ac99a657623a24145b
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent b0a3b295
......@@ -78,7 +78,7 @@ public:
virtual int eventId(int index) const = 0;
virtual QColor color(int index) const = 0;
virtual QVariantList labels() const = 0;
virtual QVariantList details(int index) const = 0;
virtual QVariantMap details(int index) const = 0;
virtual int row(int index) const = 0;
virtual void loadData() = 0;
virtual void clear() = 0;
......
......@@ -57,21 +57,18 @@ Item {
onHeightChanged: fitInView();
}
//property int eventInfo
ListModel {
id: eventInfo
}
function showInfo(eventData) {
eventInfo.clear();
rangeDetails.dialogTitle = eventData[0].displayName;
for (var i = 1; i < eventData.length; i++) {
for (var k in eventData[i]) {
if (eventData[i][k].length > 0) {
eventInfo.append({"content" : k});
eventInfo.append({"content" : eventData[i][k]});
}
for (var k in eventData) {
if (k === "displayName") {
dialogTitle = eventData[k];
} else if (eventData[k].length > 0) {
eventInfo.append({content : k});
eventInfo.append({content : eventData[k]});
}
}
rangeDetails.visible = true;
......
......@@ -236,49 +236,17 @@ QVariantList PaintEventsModelProxy::labels() const
return result;
}
QVariantList PaintEventsModelProxy::details(int index) const
QVariantMap PaintEventsModelProxy::details(int index) const
{
Q_D(const PaintEventsModelProxy);
QVariantList result;
static const char trContext[] = "RangeDetails";
{
QVariantMap valuePair;
valuePair.insert(QLatin1String("displayName"), QVariant(displayName()));
result << valuePair;
}
// duration
{
QVariantMap valuePair;
valuePair.insert(QCoreApplication::translate(trContext, "Duration:"),
QVariant(QmlProfilerBaseModel::formatTime(d->range(index).duration)));
result << valuePair;
}
// duration
{
QVariantMap valuePair;
valuePair.insert(QCoreApplication::translate(trContext, "Framerate:"), QVariant(QString::fromLatin1("%1 FPS").arg(d->range(index).framerate)));
result << valuePair;
}
// duration
{
QVariantMap valuePair;
valuePair.insert(QCoreApplication::translate(trContext, "Animations:"), QVariant(QString::fromLatin1("%1").arg(d->range(index).animationcount)));
result << valuePair;
}
{
QVariantMap valuePair;
valuePair.insert(QCoreApplication::translate(trContext, "Context:"),
QCoreApplication::translate(trContext,
d->range(index).threadId == QmlDebug::GuiThread ?
"GUI Thread" : "Render Thread"));
result << valuePair;
}
QVariantMap result;
result.insert(QStringLiteral("displayName"), displayName());
result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(d->range(index).duration));
result.insert(tr("Framerate"), QString::fromLatin1("%1 FPS").arg(d->range(index).framerate));
result.insert(tr("Animations"), QString::fromLatin1("%1").arg(d->range(index).animationcount));
result.insert(tr("Context"), tr(d->range(index).threadId == QmlDebug::GuiThread ?
"GUI Thread" : "Render Thread"));
return result;
}
......
......@@ -74,7 +74,7 @@ public:
float height(int index) const;
QVariantList labels() const;
QVariantList details(int index) const;
QVariantMap details(int index) const;
private slots:
bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const;
......
......@@ -287,51 +287,22 @@ QVariantList RangeTimelineModel::labels() const
return result;
}
QVariantList RangeTimelineModel::details(int index) const
QVariantMap RangeTimelineModel::details(int index) const
{
Q_D(const RangeTimelineModel);
QVariantList result;
QVariantMap result;
int id = eventId(index);
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
d->modelManager->qmlModel()->getEventTypes();
static const char trContext[] = "RangeDetails";
{
QVariantMap valuePair;
valuePair.insert(QLatin1String("displayName"), QVariant(categoryLabel(d->rangeType)));
result << valuePair;
}
// duration
{
QVariantMap valuePair;
valuePair.insert(QCoreApplication::translate(trContext, "Duration:"),
QVariant(QmlProfilerBaseModel::formatTime(d->range(index).duration)));
result << valuePair;
}
// details
{
QVariantMap valuePair;
QString detailsString = types[id].data;
if (detailsString.length() > 40)
detailsString = detailsString.left(40) + QLatin1String("...");
valuePair.insert(QCoreApplication::translate(trContext, "Details:"),
QVariant(detailsString));
result << valuePair;
}
// location
{
QVariantMap valuePair;
valuePair.insert(QCoreApplication::translate(trContext, "Location:"),
QVariant(types[id].displayName));
result << valuePair;
}
// isbindingloop
{}
result.insert(QStringLiteral("displayName"), categoryLabel(d->rangeType));
result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(d->range(index).duration));
QString detailsString = types[id].data;
if (detailsString.length() > 40)
detailsString = detailsString.left(40) + QLatin1String("...");
result.insert(tr("Details"), detailsString);
result.insert(tr("Location"), types[id].displayName);
return result;
}
......
......@@ -80,7 +80,7 @@ public:
QColor color(int index) const;
QVariantList labels() const;
QVariantList details(int index) const;
QVariantMap details(int index) const;
QVariantMap location(int index) const;
int eventIdForTypeIndex(int typeIndex) const;
......
......@@ -225,7 +225,7 @@ QVariantList TimelineModelAggregator::labels(int modelIndex) const
return d->modelList[modelIndex]->labels();
}
QVariantList TimelineModelAggregator::details(int modelIndex, int index) const
QVariantMap TimelineModelAggregator::details(int modelIndex, int index) const
{
return d->modelList[modelIndex]->details(index);
}
......
......@@ -82,7 +82,7 @@ public:
Q_INVOKABLE QVariantList labels(int modelIndex) const;
Q_INVOKABLE QVariantList details(int modelIndex, int index) const;
Q_INVOKABLE QVariantMap details(int modelIndex, int index) const;
Q_INVOKABLE QVariantMap location(int modelIndex, int index) const;
Q_INVOKABLE int eventIdForTypeIndex(int modelIndex, int typeIndex) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment