diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-07-07 14:41:44 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@digia.com> | 2014-08-26 15:53:21 +0300 |
commit | ae07d0624c7cfe718526047985dc35f22361494f (patch) | |
tree | 38b83539915fd2596b502e04f2878cd1944aaab7 | |
parent | b7cd23a466c30ab62d2101233585c5ff89b3e160 (diff) | |
download | qt-creator-ae07d0624c7cfe718526047985dc35f22361494f.tar.gz |
Simplify range details
Adapt to the new signature of the details method and don't create
unnecessary nested maps.
Change-Id: Iab8d31e48d35923fee3e258c0390459a81ece746
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
6 files changed, 42 insertions, 78 deletions
diff --git a/plugins/qmlprofilerextension/memoryusagemodel.cpp b/plugins/qmlprofilerextension/memoryusagemodel.cpp index d2928ef26f..d465035279 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.cpp +++ b/plugins/qmlprofilerextension/memoryusagemodel.cpp @@ -134,39 +134,33 @@ QVariantList MemoryUsageModel::labels() const return result; } -QVariantList MemoryUsageModel::details(int index) const +QVariantMap MemoryUsageModel::details(int index) const { Q_D(const MemoryUsageModel); - QVariantList result; + QVariantMap result; const MemoryUsageModelPrivate::Range *ev = &d->range(index); - QVariantMap res; if (ev->allocated >= -ev->deallocated) - res.insert(QLatin1String("displayName"), tr("Memory Allocated")); + result.insert(QLatin1String("displayName"), tr("Memory Allocated")); else - res.insert(QLatin1String("displayName"), tr("Memory Freed")); - result << res; - res.clear(); - - res.insert(tr("Total"), QVariant(QString::fromLatin1("%1 bytes").arg(ev->size))); - result << res; - res.clear(); + result.insert(QLatin1String("displayName"), tr("Memory Freed")); + result.insert(tr("Total"), QString::fromLatin1("%1 bytes").arg(ev->size)); if (ev->allocations > 0) { - res.insert(tr("Allocated"), QString::fromLatin1("%1 bytes").arg(ev->allocated)); - res.insert(tr("Allocations"), QString::number(ev->allocations)); + result.insert(tr("Allocated"), QString::fromLatin1("%1 bytes").arg(ev->allocated)); + result.insert(tr("Allocations"), QString::number(ev->allocations)); } if (ev->deallocations > 0) { - res.insert(tr("Deallocated"), QString::fromLatin1("%1 bytes").arg(-ev->deallocated)); - res.insert(tr("Deallocations"), QString::number(ev->deallocations)); + result.insert(tr("Deallocated"), QString::fromLatin1("%1 bytes").arg(-ev->deallocated)); + result.insert(tr("Deallocations"), QString::number(ev->deallocations)); } - res.insert(tr("Type"), QVariant(MemoryUsageModelPrivate::memoryTypeName(ev->type))); + result.insert(tr("Type"), QVariant(MemoryUsageModelPrivate::memoryTypeName(ev->type))); + if (ev->originTypeIndex != -1) { - res.insert(tr("Location"), + result.insert(tr("Location"), d->modelManager->qmlModel()->getEventTypes().at(ev->originTypeIndex).displayName); } - result << res; return result; } diff --git a/plugins/qmlprofilerextension/memoryusagemodel.h b/plugins/qmlprofilerextension/memoryusagemodel.h index 32969e5172..caff902f61 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.h +++ b/plugins/qmlprofilerextension/memoryusagemodel.h @@ -61,7 +61,7 @@ public: QVariantMap location(int index) const; QVariantList labels() const; - QVariantList details(int index) const; + QVariantMap details(int index) const; void loadData(); void clear(); diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.cpp b/plugins/qmlprofilerextension/pixmapcachemodel.cpp index 98d6e9667b..fa3a44c9fe 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.cpp +++ b/plugins/qmlprofilerextension/pixmapcachemodel.cpp @@ -190,54 +190,29 @@ void PixmapCacheModel::PixmapCacheModelPrivate::addVP(QVariantList &l, QString l } } -QVariantList PixmapCacheModel::details(int index) const +QVariantMap PixmapCacheModel::details(int index) const { Q_D(const PixmapCacheModel); - QVariantList result; + QVariantMap result; const PixmapCacheModelPrivate::Range *ev = &d->range(index); - { - QVariantMap res; - if (ev->pixmapEventType == PixmapCacheCountChanged) - res.insert(QLatin1String("displayName"), QVariant(QLatin1String("Image Cached"))); - else if (ev->pixmapEventType == PixmapLoadingStarted) - res.insert(QLatin1String("displayName"), QVariant(QLatin1String("Image Loaded"))); - result << res; - } - - if (ev->pixmapEventType != PixmapCacheCountChanged) { - d->addVP(result, tr("Duration"), ev->duration ); + if (ev->pixmapEventType == PixmapCacheCountChanged) { + result.insert(QLatin1String("displayName"), tr("Image Cached")); } else { - QVariantMap res; - res.insert(tr("Cache Size"), QVariant(QString::fromLatin1("%1 px") - .arg(ev->cacheSize))); - result << res; - } - - { - QVariantMap res; - res.insert(tr("File"), QVariant(getFilenameOnly(d->pixmaps[ev->urlIndex].url))); - result << res; - } - - { - QVariantMap res; - res.insert(tr("Width"), QVariant(QString::fromLatin1("%1 px") - .arg(d->pixmaps[ev->urlIndex].sizes[ev->sizeIndex].size.width()))); - result << res; - res.clear(); - res.insert(tr("Height"), QVariant(QString::fromLatin1("%1 px") - .arg(d->pixmaps[ev->urlIndex].sizes[ev->sizeIndex].size.height()))); - result << res; - } - - if (ev->pixmapEventType == PixmapLoadingStarted && - d->pixmaps[ev->urlIndex].sizes[ev->sizeIndex].loadState != Finished) { - QVariantMap res; - res.insert(tr("Result"), QVariant(QLatin1String("Load Error"))); - result << res; + if (ev->pixmapEventType == PixmapLoadingStarted) { + result.insert(QLatin1String("displayName"), tr("Image Loaded")); + if (d->pixmaps[ev->urlIndex].sizes[ev->sizeIndex].loadState != Finished) + result.insert(tr("Result"), tr("Load Error")); + } + result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(ev->duration)); } + result.insert(tr("Cache Size"), QString::fromLatin1("%1 px").arg(ev->cacheSize)); + result.insert(tr("File"), getFilenameOnly(d->pixmaps[ev->urlIndex].url)); + result.insert(tr("Width"), QString::fromLatin1("%1 px") + .arg(d->pixmaps[ev->urlIndex].sizes[ev->sizeIndex].size.width())); + result.insert(tr("Height"), QString::fromLatin1("%1 px") + .arg(d->pixmaps[ev->urlIndex].sizes[ev->sizeIndex].size.height())); return result; } diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.h b/plugins/qmlprofilerextension/pixmapcachemodel.h index 44609db316..87c49f1804 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.h +++ b/plugins/qmlprofilerextension/pixmapcachemodel.h @@ -65,7 +65,7 @@ public: QVariantList labels() const; - QVariantList details(int index) const; + QVariantMap details(int index) const; void loadData(); void clear(); diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp index b60cfc987d..ccb27cb7b4 100644 --- a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp +++ b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp @@ -57,7 +57,7 @@ class SceneGraphTimelineModel::SceneGraphTimelineModelPrivate : AbstractTimelineModel::AbstractTimelineModelPrivate> { public: - void addVP(QVariantList &l, QString label, qint64 time) const; + void addVP(QVariantMap &result, QString label, qint64 time) const; private: bool seenPolishAndSync; Q_DECLARE_PUBLIC(SceneGraphTimelineModel) @@ -145,30 +145,25 @@ QVariantList SceneGraphTimelineModel::labels() const return result; } -void SceneGraphTimelineModel::SceneGraphTimelineModelPrivate::addVP(QVariantList &l, QString label, qint64 time) const +void SceneGraphTimelineModel::SceneGraphTimelineModelPrivate::addVP(QVariantMap &result, + QString label, + qint64 time) const { - if (time > 0) { - QVariantMap res; - res.insert(label, QVariant(QmlProfilerBaseModel::formatTime(time))); - l << res; - } + if (time > 0) + result.insert(label, QmlProfilerBaseModel::formatTime(time)); } -QVariantList SceneGraphTimelineModel::details(int index) const + +QVariantMap SceneGraphTimelineModel::details(int index) const { Q_D(const SceneGraphTimelineModel); - QVariantList result; + QVariantMap result; const SortedTimelineModel<SceneGraphEvent, AbstractTimelineModel::AbstractTimelineModelPrivate>::Range *ev = &d->range(index); - { - QVariantMap res; - res.insert(QLatin1String("displayName"), QVariant(labelForSGType( - d->seenPolishAndSync ? ev->sgEventType : SceneGraphGUIThread))); - result << res; - } - + result.insert(QLatin1String("displayName"), labelForSGType( + d->seenPolishAndSync ? ev->sgEventType : SceneGraphGUIThread)); d->addVP(result, tr("Duration"), ev->duration ); if (ev->sgEventType == SceneGraphRenderThread) { diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.h b/plugins/qmlprofilerextension/scenegraphtimelinemodel.h index 479f7dae39..6a9ebfd76c 100644 --- a/plugins/qmlprofilerextension/scenegraphtimelinemodel.h +++ b/plugins/qmlprofilerextension/scenegraphtimelinemodel.h @@ -51,7 +51,7 @@ public: QVariantList labels() const; - QVariantList details(int index) const; + QVariantMap details(int index) const; void loadData(); void clear(); |