From eca36a23d1b6ebebf155520b87fb6fd9e42ee5fc Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Fri, 3 Feb 2012 17:28:29 +0100 Subject: [PATCH] QmlProfiler: hiding extra statistics by default User can choose to see them through the context menu. Change-Id: Ibf1670098126658af497c7a87b46c26f6dd2d41e Reviewed-by: Kai Koehne --- .../qmlprofiler/qmlprofilereventview.cpp | 88 ++++++++++++++++--- .../qmlprofiler/qmlprofilereventview.h | 5 ++ src/plugins/qmlprofiler/qmlprofilertool.cpp | 10 +++ 3 files changed, 89 insertions(+), 14 deletions(-) diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.cpp b/src/plugins/qmlprofiler/qmlprofilereventview.cpp index 84bbdc93706..f89a966f9b8 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilereventview.cpp @@ -195,6 +195,16 @@ bool QmlProfilerEventsWidget::hasGlobalStats() const return m_globalStatsEnabled; } +void QmlProfilerEventsWidget::setShowExtendedStatistics(bool show) +{ + m_eventTree->setShowExtendedStatistics(show); +} + +bool QmlProfilerEventsWidget::showExtendedStatistics() const +{ + return m_eventTree->showExtendedStatistics(); +} + //////////////////////////////////////////////////////////////////////////////////// class QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate @@ -215,8 +225,9 @@ public: QmlProfilerEventList *m_eventStatistics; QStandardItemModel *m_model; QList m_fieldShown; + QHash m_columnIndex; // maps field enum to column index + bool m_showExtendedStatistics; int m_firstNumericColumn; - int m_detailsColumn; bool m_preventSelectBounce; }; @@ -241,8 +252,8 @@ QmlProfilerEventsMainView::QmlProfilerEventsMainView(QmlProfilerEventList *model setEventStatisticsModel(model); d->m_firstNumericColumn = 0; - d->m_detailsColumn = 0; d->m_preventSelectBounce = false; + d->m_showExtendedStatistics = false; // default view setViewType(EventsView); @@ -326,38 +337,85 @@ void QmlProfilerEventsMainView::setHeaderLabels() int fieldIndex = 0; d->m_firstNumericColumn = 0; + d->m_columnIndex.clear(); if (d->m_fieldShown[Name]) { + d->m_columnIndex[Name] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Location"))); d->m_firstNumericColumn++; } if (d->m_fieldShown[Type]) { + d->m_columnIndex[Type] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Type"))); d->m_firstNumericColumn++; } - if (d->m_fieldShown[Percent]) + if (d->m_fieldShown[Percent]) { + d->m_columnIndex[Percent] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Time in Percent"))); - if (d->m_fieldShown[TotalDuration]) + } + if (d->m_fieldShown[TotalDuration]) { + d->m_columnIndex[TotalDuration] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Total Time"))); - if (d->m_fieldShown[SelfPercent]) + } + if (d->m_fieldShown[SelfPercent]) { + d->m_columnIndex[Type] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Self Time in Percent"))); - if (d->m_fieldShown[SelfDuration]) + } + if (d->m_fieldShown[SelfDuration]) { + d->m_columnIndex[SelfDuration] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Self Time"))); - if (d->m_fieldShown[CallCount]) + } + if (d->m_fieldShown[CallCount]) { + d->m_columnIndex[CallCount] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Calls"))); - if (d->m_fieldShown[TimePerCall]) + } + if (d->m_fieldShown[TimePerCall]) { + d->m_columnIndex[TimePerCall] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Mean Time"))); - if (d->m_fieldShown[MedianTime]) + } + if (d->m_fieldShown[MedianTime]) { + d->m_columnIndex[MedianTime] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Median Time"))); - if (d->m_fieldShown[MaxTime]) + } + if (d->m_fieldShown[MaxTime]) { + d->m_columnIndex[MaxTime] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Longest Time"))); - if (d->m_fieldShown[MinTime]) + } + if (d->m_fieldShown[MinTime]) { + d->m_columnIndex[MinTime] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Shortest Time"))); + } if (d->m_fieldShown[Details]) { - d->m_detailsColumn = fieldIndex; + d->m_columnIndex[Details] = fieldIndex; d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Details"))); } } +void QmlProfilerEventsMainView::setShowExtendedStatistics(bool show) +{ + // Not checking if already set because we don't want the first call to skip + d->m_showExtendedStatistics = show; + if (show) { + if (d->m_fieldShown[MedianTime]) + showColumn(d->m_columnIndex[MedianTime]); + if (d->m_fieldShown[MaxTime]) + showColumn(d->m_columnIndex[MaxTime]); + if (d->m_fieldShown[MinTime]) + showColumn(d->m_columnIndex[MinTime]); + } else{ + if (d->m_fieldShown[MedianTime]) + hideColumn(d->m_columnIndex[MedianTime]); + if (d->m_fieldShown[MaxTime]) + hideColumn(d->m_columnIndex[MaxTime]); + if (d->m_fieldShown[MinTime]) + hideColumn(d->m_columnIndex[MinTime]); + } +} + +bool QmlProfilerEventsMainView::showExtendedStatistics() const +{ + return d->m_showExtendedStatistics; +} + void QmlProfilerEventsMainView::clear() { d->m_model->clear(); @@ -385,6 +443,8 @@ void QmlProfilerEventsMainView::buildModel() else d->buildModelFromList( d->m_eventStatistics->getEventDescriptions(), d->m_model->invisibleRootItem() ); + setShowExtendedStatistics(d->m_showExtendedStatistics); + setRootIsDecorated(false); setSortingEnabled(true); sortByColumn(d->m_firstNumericColumn,Qt::DescendingOrder); @@ -650,8 +710,8 @@ void QmlProfilerEventsMainView::changeDetailsForEvent(int eventId, const QString for (int i=0; im_model->rowCount(); i++) { QStandardItem *infoItem = d->m_model->item(i, 0); if (infoItem->data(EventIdRole).toInt() == eventId) { - d->m_model->item(i,d->m_detailsColumn)->setData(QVariant(newString),Qt::DisplayRole); - d->m_model->item(i,d->m_detailsColumn)->setData(QVariant(newString)); + d->m_model->item(i,d->m_columnIndex[Details])->setData(QVariant(newString),Qt::DisplayRole); + d->m_model->item(i,d->m_columnIndex[Details])->setData(QVariant(newString)); return; } } diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.h b/src/plugins/qmlprofiler/qmlprofilereventview.h index e0d8428e17c..73c700245f9 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.h +++ b/src/plugins/qmlprofiler/qmlprofilereventview.h @@ -72,6 +72,8 @@ public: void copyRowToClipboard() const; bool hasGlobalStats() const; + void setShowExtendedStatistics(bool show); + bool showExtendedStatistics() const; signals: void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber); @@ -142,6 +144,9 @@ public: bool isRangeGlobal(qint64 rangeStart, qint64 rangeEnd) const; int selectedEventId() const; + void setShowExtendedStatistics(bool); + bool showExtendedStatistics() const; + signals: void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber); void eventSelected(int eventId); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index b9919e3dcf3..db83c27851f 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -230,6 +230,7 @@ void QmlProfilerTool::showContextMenu(const QPoint &position) QAction *saveAction = menu.addAction(tr("Save QML Trace")); QAction *copyRowAction = 0; QAction *copyTableAction = 0; + QAction *showExtendedStatsAction = 0; QAction *viewAllAction = 0; QAction *getLocalStatsAction = 0; QAction *getGlobalStatsAction = 0; @@ -239,6 +240,13 @@ void QmlProfilerTool::showContextMenu(const QPoint &position) if (eventView->selectedItem().isValid()) copyRowAction = menu.addAction(tr("Copy Row")); copyTableAction = menu.addAction(tr("Copy Table")); + + if (eventView == d->m_eventsView) { + // only for qml events view, not for v8 + showExtendedStatsAction = menu.addAction(tr("Extended Event Statistics")); + showExtendedStatsAction->setCheckable(true); + showExtendedStatsAction->setChecked(eventView->showExtendedStatistics()); + } } if (sender() == d->m_traceWindow || sender() == d->m_eventsView) { @@ -281,6 +289,8 @@ void QmlProfilerTool::showContextMenu(const QPoint &position) d->m_traceWindow->getEventList()->traceStartTime(), d->m_traceWindow->getEventList()->traceEndTime()); } + if (selectedAction == showExtendedStatsAction) + eventView->setShowExtendedStatistics(!eventView->showExtendedStatistics()); } }