diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.cpp b/src/plugins/qmlprofiler/qmlprofilereventview.cpp index b5b1ee1eae9..7de11d5c89d 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilereventview.cpp @@ -117,6 +117,8 @@ QmlProfilerEventsWidget::QmlProfilerEventsWidget(QmlJsDebugClient::QmlProfilerEv connect(model,SIGNAL(dataReady()),m_eventChildren,SLOT(clear())); connect(model,SIGNAL(dataReady()),m_eventParents,SLOT(clear())); } + + m_globalStatsEnabled = true; } QmlProfilerEventsWidget::~QmlProfilerEventsWidget() @@ -143,6 +145,7 @@ void QmlProfilerEventsWidget::getStatisticsInRange(qint64 rangeStart, qint64 ran { clear(); m_eventTree->getStatisticsInRange(rangeStart, rangeEnd); + m_globalStatsEnabled = m_eventTree->isRangeGlobal(rangeStart, rangeEnd); } QModelIndex QmlProfilerEventsWidget::selectedItem() const @@ -178,6 +181,11 @@ void QmlProfilerEventsWidget::updateSelectedEvent(int eventId) const m_eventTree->selectEvent(eventId); } +bool QmlProfilerEventsWidget::hasGlobalStats() const +{ + return m_globalStatsEnabled; +} + //////////////////////////////////////////////////////////////////////////////////// class QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate @@ -553,6 +561,11 @@ void QmlProfilerEventsMainView::getStatisticsInRange(qint64 rangeStart, qint64 r buildModel(); } +bool QmlProfilerEventsMainView::isRangeGlobal(qint64 rangeStart, qint64 rangeEnd) const +{ + return d->m_eventStatistics->traceStartTime() == rangeStart && d->m_eventStatistics->traceEndTime() == rangeEnd; +} + int QmlProfilerEventsMainView::selectedEventId() const { QModelIndex index = selectedItem(); @@ -723,6 +736,7 @@ void QmlProfilerEventsParentsAndChildrenView::displayEvent(int eventId) updateHeader(); resizeColumnToContents(0); + setSortingEnabled(true); } void QmlProfilerEventsParentsAndChildrenView::rebuildTree(void *eventList) diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.h b/src/plugins/qmlprofiler/qmlprofilereventview.h index f77940cd39d..9ceeb9ed86a 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.h +++ b/src/plugins/qmlprofiler/qmlprofilereventview.h @@ -70,6 +70,8 @@ public: void copyTableToClipboard() const; void copyRowToClipboard() const; + bool hasGlobalStats() const; + signals: void gotoSourceLocation(const QString &fileName, int lineNumber); void contextMenuRequested(const QPoint &position); @@ -85,6 +87,8 @@ private: QmlProfilerEventsMainView *m_eventTree; QmlProfilerEventsParentsAndChildrenView *m_eventChildren; QmlProfilerEventsParentsAndChildrenView *m_eventParents; + + bool m_globalStatsEnabled; }; class QmlProfilerEventsMainView : public QTreeView @@ -134,6 +138,7 @@ public: static QString nameForType(int typeNumber); void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd); + bool isRangeGlobal(qint64 rangeStart, qint64 rangeEnd) const; int selectedEventId() const; signals: diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 5ce880af1bb..9fc5962d25a 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -192,6 +192,16 @@ void QmlProfilerTool::showContextMenu(const QPoint &position) copyTableAction = menu.addAction(tr("Copy Table")); } + if (sender() == d->m_traceWindow || sender() == d->m_eventsView) { + menu.addSeparator(); + getLocalStatsAction = menu.addAction(tr("Limit Events Pane to Current Range")); + if (!d->m_traceWindow->hasValidSelection()) + getLocalStatsAction->setEnabled(false); + getGlobalStatsAction = menu.addAction(tr("Reset Events Pane")); + if (d->m_eventsView->hasGlobalStats()) + getGlobalStatsAction->setEnabled(false); + } + if (traceView) { if (traceView->getEventList()->count() > 0) { menu.addSeparator(); @@ -199,13 +209,6 @@ void QmlProfilerTool::showContextMenu(const QPoint &position) } } - if (sender() == d->m_traceWindow || sender() == d->m_eventsView) { - menu.addSeparator(); - if (d->m_traceWindow->hasValidSelection()) - getLocalStatsAction = menu.addAction(tr("Get Stats For Current Range")); - getGlobalStatsAction = menu.addAction(tr("Get Global Statistics")); - } - QAction *selectedAction = menu.exec(position); if (selectedAction) {