From 8f5df0b7da1844a20a60bc8a515d74b8e58cf4eb Mon Sep 17 00:00:00 2001 From: Ulf Hermann <ulf.hermann@digia.com> Date: Fri, 14 Feb 2014 17:01:24 +0100 Subject: [PATCH] QmlProfiler: Make time formatting available to all timeline models ... and remove some dead code. Change-Id: Ifdec932b87e8d33420d9713bfde9c4002f34844b Reviewed-by: Kai Koehne <kai.koehne@digia.com> --- .../qmlprofiler/qmlprofilereventview.cpp | 24 +++++----------- .../qmlprofiler/qmlprofilereventview.h | 1 - .../qmlprofilerpainteventsmodelproxy.cpp | 14 ++-------- .../qmlprofiler/qmlprofilersimplemodel.cpp | 10 +++++++ .../qmlprofiler/qmlprofilersimplemodel.h | 1 + .../qmlprofilertimelinemodelproxy.cpp | 15 ++-------- .../qmlprofiler/qv8profilereventview.cpp | 28 ++----------------- .../qmlprofiler/qv8profilereventview.h | 3 -- 8 files changed, 25 insertions(+), 71 deletions(-) diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.cpp b/src/plugins/qmlprofiler/qmlprofilereventview.cpp index da0137b9c3b..5e213955523 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilereventview.cpp @@ -544,7 +544,7 @@ void QmlProfilerEventsMainView::parseModelProxy() } if (d->m_fieldShown[TotalTime]) { - newRow << new EventsViewItem(displayTime(event.duration)); + newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.duration)); newRow.last()->setData(QVariant(event.duration)); } @@ -554,22 +554,22 @@ void QmlProfilerEventsMainView::parseModelProxy() } if (d->m_fieldShown[TimePerCall]) { - newRow << new EventsViewItem(displayTime(event.timePerCall)); + newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.timePerCall)); newRow.last()->setData(QVariant(event.timePerCall)); } if (d->m_fieldShown[MedianTime]) { - newRow << new EventsViewItem(displayTime(event.medianTime)); + newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.medianTime)); newRow.last()->setData(QVariant(event.medianTime)); } if (d->m_fieldShown[MaxTime]) { - newRow << new EventsViewItem(displayTime(event.maxTime)); + newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.maxTime)); newRow.last()->setData(QVariant(event.maxTime)); } if (d->m_fieldShown[MinTime]) { - newRow << new EventsViewItem(displayTime(event.minTime)); + newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.minTime)); newRow.last()->setData(QVariant(event.minTime)); } @@ -604,16 +604,6 @@ void QmlProfilerEventsMainView::parseModelProxy() } } -QString QmlProfilerEventsMainView::displayTime(double time) -{ - if (time < 1e6) - return QString::number(time/1e3,'f',3) + trUtf8(" \xc2\xb5s"); - if (time < 1e9) - return QString::number(time/1e6,'f',3) + tr(" ms"); - - return QString::number(time/1e9,'f',3) + tr(" s"); -} - QString QmlProfilerEventsMainView::nameForType(int typeNumber) { switch (typeNumber) { @@ -828,13 +818,13 @@ void QmlProfilerEventRelativesView::rebuildTree(QmlProfilerEventRelativesModelPr // no indirections at this level of abstraction! newRow << new EventsViewItem(event.displayName); newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event.eventType)); - newRow << new EventsViewItem(QmlProfilerEventsMainView::displayTime(event.duration)); + newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.duration)); newRow << new EventsViewItem(QString::number(event.calls)); newRow << new EventsViewItem(event.details); // newRow << new EventsViewItem(event->reference->displayName); // newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event->reference->eventType)); -// newRow << new EventsViewItem(QmlProfilerEventsMainView::displayTime(event->duration)); +// newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event->duration)); // newRow << new EventsViewItem(QString::number(event->calls)); // newRow << new EventsViewItem(event->reference->details); newRow.at(0)->setData(QVariant(key), EventHashStrRole); diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.h b/src/plugins/qmlprofiler/qmlprofilereventview.h index 3ef413cec63..0a3d2aea30b 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.h +++ b/src/plugins/qmlprofiler/qmlprofilereventview.h @@ -115,7 +115,6 @@ public: void copyTableToClipboard() const; void copyRowToClipboard() const; - static QString displayTime(double time); static QString nameForType(int typeNumber); void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd); diff --git a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp index cc92e9d5390..2c2a9c048b9 100644 --- a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp @@ -56,7 +56,6 @@ public: PaintEventsModelProxyPrivate(PaintEventsModelProxy *qq) : q(qq) {} ~PaintEventsModelProxyPrivate() {} - QString displayTime(double time); void computeAnimationCountLimit(); int minAnimationCount; @@ -281,16 +280,6 @@ const QVariantList PaintEventsModelProxy::getLabelsForCategory(int category) con return result; } -QString PaintEventsModelProxy::PaintEventsModelProxyPrivate::displayTime(double time) -{ - if (time < 1e6) - return QString::number(time/1e3,'f',3) + trUtf8(" \xc2\xb5s"); - if (time < 1e9) - return QString::number(time/1e6,'f',3) + tr(" ms"); - - return QString::number(time/1e9,'f',3) + tr(" s"); -} - void PaintEventsModelProxy::PaintEventsModelProxyPrivate::computeAnimationCountLimit() { minAnimationCount = 1; @@ -321,7 +310,8 @@ const QVariantList PaintEventsModelProxy::getEventDetails(int index) const // duration { QVariantMap valuePair; - valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), QVariant(d->displayTime(d->range(index).duration))); + valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), + QVariant(QmlProfilerSimpleModel::formatTime(d->range(index).duration))); result << valuePair; } diff --git a/src/plugins/qmlprofiler/qmlprofilersimplemodel.cpp b/src/plugins/qmlprofiler/qmlprofilersimplemodel.cpp index 231c062fc77..5d13ad9622c 100644 --- a/src/plugins/qmlprofiler/qmlprofilersimplemodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilersimplemodel.cpp @@ -105,4 +105,14 @@ QString QmlProfilerSimpleModel::getHashString(const QmlProfilerSimpleModel::QmlE QString::number(event.bindingType)); } +QString QmlProfilerSimpleModel::formatTime(qint64 timestamp) +{ + if (timestamp < 1e6) + return QString::number(timestamp/1e3f,'f',3) + trUtf8(" \xc2\xb5s"); + if (timestamp < 1e9) + return QString::number(timestamp/1e6f,'f',3) + tr(" ms"); + + return QString::number(timestamp/1e9f,'f',3) + tr(" s"); +} + } diff --git a/src/plugins/qmlprofiler/qmlprofilersimplemodel.h b/src/plugins/qmlprofiler/qmlprofilersimplemodel.h index afdc6bc5056..28c11ad0c41 100644 --- a/src/plugins/qmlprofiler/qmlprofilersimplemodel.h +++ b/src/plugins/qmlprofiler/qmlprofilersimplemodel.h @@ -75,6 +75,7 @@ public: qint64 lastTimeMark() const; static QString getHashString(const QmlProfilerSimpleModel::QmlEventData &event); + static QString formatTime(qint64 timestamp); protected: QVector<QmlEventData> eventList; diff --git a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp index 5096a58749e..f9c52cfdd91 100644 --- a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp @@ -64,8 +64,6 @@ public: void findBindingLoops(); void computeRowStarts(); - QString displayTime(double time); - QVector <BasicTimelineModel::QmlRangeEventData> eventDict; QVector <QString> eventHashes; QVector <CategorySpan> categorySpan; @@ -443,16 +441,6 @@ const QVariantList BasicTimelineModel::getLabelsForCategory(int category) const return result; } -QString BasicTimelineModel::BasicTimelineModelPrivate::displayTime(double time) -{ - if (time < 1e6) - return QString::number(time/1e3,'f',3) + trUtf8(" \xc2\xb5s"); - if (time < 1e9) - return QString::number(time/1e6,'f',3) + tr(" ms"); - - return QString::number(time/1e9,'f',3) + tr(" s"); -} - const QVariantList BasicTimelineModel::getEventDetails(int index) const { QVariantList result; @@ -468,7 +456,8 @@ const QVariantList BasicTimelineModel::getEventDetails(int index) const // duration { QVariantMap valuePair; - valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), QVariant(d->displayTime(d->range(index).duration))); + valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), + QVariant(QmlProfilerSimpleModel::formatTime(d->range(index).duration))); result << valuePair; } diff --git a/src/plugins/qmlprofiler/qv8profilereventview.cpp b/src/plugins/qmlprofiler/qv8profilereventview.cpp index 90616f37894..71166cb4b9a 100644 --- a/src/plugins/qmlprofiler/qv8profilereventview.cpp +++ b/src/plugins/qmlprofiler/qv8profilereventview.cpp @@ -443,7 +443,7 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr } if (m_fieldShown[TotalTime]) { - newRow << new EventsViewItem(displayTime(v8event->totalTime)); + newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(v8event->totalTime)); newRow.last()->setData(QVariant(v8event->totalTime)); } @@ -453,7 +453,7 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr } if (m_fieldShown[SelfTime]) { - newRow << new EventsViewItem(displayTime(v8event->selfTime)); + newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(v8event->selfTime)); newRow.last()->setData(QVariant(v8event->selfTime)); } @@ -480,28 +480,6 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr } } -QString QV8ProfilerEventsMainView::displayTime(double time) -{ - if (time < 1e6) - return QString::number(time/1e3,'f',3) + trUtf8(" \xc2\xb5s"); - if (time < 1e9) - return QString::number(time/1e6,'f',3) + tr(" ms"); - - return QString::number(time/1e9,'f',3) + tr(" s"); -} - -QString QV8ProfilerEventsMainView::nameForType(int typeNumber) -{ - switch (typeNumber) { - case 0: return QV8ProfilerEventsMainView::tr("Paint"); - case 1: return QV8ProfilerEventsMainView::tr("Compile"); - case 2: return QV8ProfilerEventsMainView::tr("Create"); - case 3: return QV8ProfilerEventsMainView::tr("Binding"); - case 4: return QV8ProfilerEventsMainView::tr("Signal"); - } - return QString(); -} - int QV8ProfilerEventsMainView::selectedEventId() const { QModelIndex index = selectedItem(); @@ -687,7 +665,7 @@ void QV8ProfilerEventRelativesView::rebuildTree(QList<QV8EventSub*> events) foreach (QV8EventSub *event, events) { QList<QStandardItem *> newRow; newRow << new EventsViewItem(event->reference->displayName); - newRow << new EventsViewItem(QV8ProfilerEventsMainView::displayTime(event->totalTime)); + newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event->totalTime)); newRow << new EventsViewItem(event->reference->functionName); newRow.at(0)->setData(QVariant(event->reference->eventId), EventIdRole); newRow.at(1)->setData(QVariant(event->totalTime)); diff --git a/src/plugins/qmlprofiler/qv8profilereventview.h b/src/plugins/qmlprofiler/qv8profilereventview.h index 5efa471c6c1..54dda682133 100644 --- a/src/plugins/qmlprofiler/qv8profilereventview.h +++ b/src/plugins/qmlprofiler/qv8profilereventview.h @@ -101,9 +101,6 @@ public: void copyTableToClipboard() const; void copyRowToClipboard() const; - static QString displayTime(double time); - static QString nameForType(int typeNumber); - int selectedEventId() const; void setShowExtendedStatistics(bool); -- GitLab