Commit 16bfbcee authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Allow filtering either JS or QML from the events view

As a lot of events show up as QML bindings and signals and as
JavaScript functions the events view can be hard to navigate. This
change allows the user to either filter out JavaScript events and make
it look like the old QML events view or filter out QML events and make
it look like the old V8 JavaScript view.

Change-Id: I9e0c1184da21263ae174f322b8fcd8ee5ca13f6d
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 64af5c12
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
int modelId; int modelId;
QVector<int> acceptedTypes; QList<QmlDebug::QmlEventType> acceptedTypes;
QSet<QString> eventsInBindingLoop; QSet<QString> eventsInBindingLoop;
}; };
...@@ -80,6 +80,19 @@ QmlProfilerEventsModelProxy::~QmlProfilerEventsModelProxy() ...@@ -80,6 +80,19 @@ QmlProfilerEventsModelProxy::~QmlProfilerEventsModelProxy()
delete d; delete d;
} }
void QmlProfilerEventsModelProxy::setEventTypeAccepted(QmlDebug::QmlEventType type, bool accepted)
{
if (accepted && !d->acceptedTypes.contains(type))
d->acceptedTypes << type;
else if (!accepted && d->acceptedTypes.contains(type))
d->acceptedTypes.removeOne(type);
}
bool QmlProfilerEventsModelProxy::eventTypeAccepted(QmlDebug::QmlEventType type) const
{
return d->acceptedTypes.contains(type);
}
const QList<QmlProfilerEventsModelProxy::QmlEventStats> QmlProfilerEventsModelProxy::getData() const const QList<QmlProfilerEventsModelProxy::QmlEventStats> QmlProfilerEventsModelProxy::getData() const
{ {
return d->data.values(); return d->data.values();
...@@ -131,7 +144,7 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd) ...@@ -131,7 +144,7 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
for (int i = 0; i < eventList.size(); ++i) { for (int i = 0; i < eventList.size(); ++i) {
const QmlProfilerDataModel::QmlEventData *event = &eventList[i]; const QmlProfilerDataModel::QmlEventData *event = &eventList[i];
if (!d->acceptedTypes.contains(event->eventType)) if (!d->acceptedTypes.contains((QmlDebug::QmlEventType)event->eventType))
continue; continue;
if (checkRanges) { if (checkRanges) {
...@@ -275,12 +288,13 @@ QmlProfilerEventRelativesModelProxy::QmlProfilerEventRelativesModelProxy(QmlProf ...@@ -275,12 +288,13 @@ QmlProfilerEventRelativesModelProxy::QmlProfilerEventRelativesModelProxy(QmlProf
{ {
QTC_CHECK(modelManager); QTC_CHECK(modelManager);
m_modelManager = modelManager; m_modelManager = modelManager;
connect(modelManager->qmlModel(), SIGNAL(changed()), this, SLOT(dataChanged()));
QTC_CHECK(eventsModel); QTC_CHECK(eventsModel);
m_eventsModel = eventsModel; m_eventsModel = eventsModel;
m_acceptedTypes << QmlDebug::Compiling << QmlDebug::Creating << QmlDebug::Binding << QmlDebug::HandlingSignal << QmlDebug::Javascript; // Load the child models whenever the parent model is done to get the filtering for JS/QML
// right.
connect(m_eventsModel, SIGNAL(dataAvailable()), this, SLOT(dataChanged()));
} }
QmlProfilerEventRelativesModelProxy::~QmlProfilerEventRelativesModelProxy() QmlProfilerEventRelativesModelProxy::~QmlProfilerEventRelativesModelProxy()
...@@ -356,7 +370,7 @@ void QmlProfilerEventParentsModelProxy::loadData() ...@@ -356,7 +370,7 @@ void QmlProfilerEventParentsModelProxy::loadData()
const QVector<QmlProfilerDataModel::QmlEventData> eventList = simpleModel->getEvents(); const QVector<QmlProfilerDataModel::QmlEventData> eventList = simpleModel->getEvents();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) { foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
// whitelist // whitelist
if (!m_acceptedTypes.contains(event.eventType)) if (!m_eventsModel->eventTypeAccepted((QmlDebug::QmlEventType)event.eventType))
continue; continue;
// level computation // level computation
...@@ -436,7 +450,7 @@ void QmlProfilerEventChildrenModelProxy::loadData() ...@@ -436,7 +450,7 @@ void QmlProfilerEventChildrenModelProxy::loadData()
const QVector<QmlProfilerDataModel::QmlEventData> eventList = simpleModel->getEvents(); const QVector<QmlProfilerDataModel::QmlEventData> eventList = simpleModel->getEvents();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) { foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
// whitelist // whitelist
if (!m_acceptedTypes.contains(event.eventType)) if (!m_eventsModel->eventTypeAccepted((QmlDebug::QmlEventType)event.eventType))
continue; continue;
// level computation // level computation
......
...@@ -70,6 +70,9 @@ public: ...@@ -70,6 +70,9 @@ public:
QmlProfilerEventsModelProxy(QmlProfilerModelManager *modelManager, QObject *parent = 0); QmlProfilerEventsModelProxy(QmlProfilerModelManager *modelManager, QObject *parent = 0);
~QmlProfilerEventsModelProxy(); ~QmlProfilerEventsModelProxy();
void setEventTypeAccepted(QmlDebug::QmlEventType type, bool accepted);
bool eventTypeAccepted(QmlDebug::QmlEventType) const;
const QList<QmlEventStats> getData() const; const QList<QmlEventStats> getData() const;
int count() const; int count() const;
void clear(); void clear();
...@@ -133,7 +136,6 @@ protected: ...@@ -133,7 +136,6 @@ protected:
QHash <QString, QmlEventRelativesMap> m_data; QHash <QString, QmlEventRelativesMap> m_data;
QmlProfilerModelManager *m_modelManager; QmlProfilerModelManager *m_modelManager;
QmlProfilerEventsModelProxy *m_eventsModel; QmlProfilerEventsModelProxy *m_eventsModel;
QVector <int> m_acceptedTypes;
}; };
class QmlProfilerEventParentsModelProxy : public QmlProfilerEventRelativesModelProxy class QmlProfilerEventParentsModelProxy : public QmlProfilerEventRelativesModelProxy
...@@ -147,8 +149,6 @@ public: ...@@ -147,8 +149,6 @@ public:
protected: protected:
virtual void loadData(); virtual void loadData();
signals:
void dataAvailable();
}; };
class QmlProfilerEventChildrenModelProxy : public QmlProfilerEventRelativesModelProxy class QmlProfilerEventChildrenModelProxy : public QmlProfilerEventRelativesModelProxy
...@@ -162,8 +162,6 @@ public: ...@@ -162,8 +162,6 @@ public:
protected: protected:
virtual void loadData(); virtual void loadData();
signals:
void dataAvailable();
}; };
} }
......
...@@ -111,7 +111,8 @@ public: ...@@ -111,7 +111,8 @@ public:
QmlProfilerEventRelativesView *m_eventParents; QmlProfilerEventRelativesView *m_eventParents;
QmlProfilerEventsModelProxy *modelProxy; QmlProfilerEventsModelProxy *modelProxy;
bool globalStats; qint64 rangeStart;
qint64 rangeEnd;
}; };
QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent, QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent,
...@@ -164,7 +165,7 @@ QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent, ...@@ -164,7 +165,7 @@ QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent,
d->m_profilerTool = profilerTool; d->m_profilerTool = profilerTool;
d->m_viewContainer = container; d->m_viewContainer = container;
d->globalStats = true; d->rangeStart = d->rangeEnd = -1;
} }
QmlProfilerEventsWidget::~QmlProfilerEventsWidget() QmlProfilerEventsWidget::~QmlProfilerEventsWidget()
...@@ -186,8 +187,9 @@ void QmlProfilerEventsWidget::clear() ...@@ -186,8 +187,9 @@ void QmlProfilerEventsWidget::clear()
void QmlProfilerEventsWidget::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd) void QmlProfilerEventsWidget::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd)
{ {
d->rangeStart = rangeStart;
d->rangeEnd = rangeEnd;
d->modelProxy->limitToRange(rangeStart, rangeEnd); d->modelProxy->limitToRange(rangeStart, rangeEnd);
d->globalStats = (rangeStart == -1) && (rangeEnd == -1);
} }
QModelIndex QmlProfilerEventsWidget::selectedItem() const QModelIndex QmlProfilerEventsWidget::selectedItem() const
...@@ -203,6 +205,8 @@ void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev) ...@@ -203,6 +205,8 @@ void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev)
QAction *copyRowAction = 0; QAction *copyRowAction = 0;
QAction *copyTableAction = 0; QAction *copyTableAction = 0;
QAction *showExtendedStatsAction = 0; QAction *showExtendedStatsAction = 0;
QAction *showJavaScriptAction = 0;
QAction *showQmlAction = 0;
QAction *getLocalStatsAction = 0; QAction *getLocalStatsAction = 0;
QAction *getGlobalStatsAction = 0; QAction *getGlobalStatsAction = 0;
...@@ -227,13 +231,21 @@ void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev) ...@@ -227,13 +231,21 @@ void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev)
} }
menu.addSeparator(); menu.addSeparator();
getLocalStatsAction = menu.addAction(tr("Limit Events Pane to Current Range")); getLocalStatsAction = menu.addAction(tr("Limit to Current Range"));
if (!d->m_viewContainer->hasValidSelection()) if (!d->m_viewContainer->hasValidSelection())
getLocalStatsAction->setEnabled(false); getLocalStatsAction->setEnabled(false);
getGlobalStatsAction = menu.addAction(tr("Reset Events Pane")); getGlobalStatsAction = menu.addAction(tr("Show Full Range"));
if (hasGlobalStats()) if (hasGlobalStats())
getGlobalStatsAction->setEnabled(false); getGlobalStatsAction->setEnabled(false);
showJavaScriptAction = menu.addAction(tr("Show JavaScript Events"));
showJavaScriptAction->setCheckable(true);
showJavaScriptAction->setChecked(showJavaScript());
showQmlAction = menu.addAction(tr("Show QML Events"));
showQmlAction->setCheckable(true);
showQmlAction->setChecked(showQml());
QAction *selectedAction = menu.exec(position); QAction *selectedAction = menu.exec(position);
if (selectedAction) { if (selectedAction) {
...@@ -249,6 +261,10 @@ void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev) ...@@ -249,6 +261,10 @@ void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev)
getStatisticsInRange(-1, -1); getStatisticsInRange(-1, -1);
if (selectedAction == showExtendedStatsAction) if (selectedAction == showExtendedStatsAction)
setShowExtendedStatistics(!showExtendedStatistics()); setShowExtendedStatistics(!showExtendedStatistics());
if (selectedAction == showJavaScriptAction)
setShowJavaScript(showJavaScriptAction->isChecked());
if (selectedAction == showQmlAction)
setShowQml(showQmlAction->isChecked());
} }
} }
...@@ -288,7 +304,7 @@ void QmlProfilerEventsWidget::selectBySourceLocation(const QString &filename, in ...@@ -288,7 +304,7 @@ void QmlProfilerEventsWidget::selectBySourceLocation(const QString &filename, in
bool QmlProfilerEventsWidget::hasGlobalStats() const bool QmlProfilerEventsWidget::hasGlobalStats() const
{ {
return d->globalStats; return d->rangeStart == -1 && d->rangeEnd == -1;
} }
void QmlProfilerEventsWidget::setShowExtendedStatistics(bool show) void QmlProfilerEventsWidget::setShowExtendedStatistics(bool show)
...@@ -301,6 +317,34 @@ bool QmlProfilerEventsWidget::showExtendedStatistics() const ...@@ -301,6 +317,34 @@ bool QmlProfilerEventsWidget::showExtendedStatistics() const
return d->m_eventTree->showExtendedStatistics(); return d->m_eventTree->showExtendedStatistics();
} }
void QmlProfilerEventsWidget::setShowJavaScript(bool show)
{
d->modelProxy->setEventTypeAccepted(QmlDebug::Javascript, show);
d->modelProxy->limitToRange(d->rangeStart, d->rangeEnd);
}
void QmlProfilerEventsWidget::setShowQml(bool show)
{
d->modelProxy->setEventTypeAccepted(QmlDebug::Binding, show);
d->modelProxy->setEventTypeAccepted(QmlDebug::HandlingSignal, show);
d->modelProxy->setEventTypeAccepted(QmlDebug::Compiling, show);
d->modelProxy->setEventTypeAccepted(QmlDebug::Creating, show);
d->modelProxy->limitToRange(d->rangeStart, d->rangeEnd);
}
bool QmlProfilerEventsWidget::showJavaScript() const
{
return d->modelProxy->eventTypeAccepted(QmlDebug::Javascript);
}
bool QmlProfilerEventsWidget::showQml() const
{
return d->modelProxy->eventTypeAccepted(QmlDebug::Binding) &&
d->modelProxy->eventTypeAccepted(QmlDebug::HandlingSignal) &&
d->modelProxy->eventTypeAccepted(QmlDebug::Compiling) &&
d->modelProxy->eventTypeAccepted(QmlDebug::Creating);
}
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
class QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate class QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate
...@@ -781,6 +825,9 @@ QmlProfilerEventRelativesView::QmlProfilerEventRelativesView(QmlProfilerModelMan ...@@ -781,6 +825,9 @@ QmlProfilerEventRelativesView::QmlProfilerEventRelativesView(QmlProfilerModelMan
updateHeader(); updateHeader();
connect(this,SIGNAL(clicked(QModelIndex)), this,SLOT(jumpToItem(QModelIndex))); connect(this,SIGNAL(clicked(QModelIndex)), this,SLOT(jumpToItem(QModelIndex)));
// Clear when new data available as the selection may be invalid now.
connect(d->modelProxy, SIGNAL(dataAvailable()), this, SLOT(clear()));
} }
QmlProfilerEventRelativesView::~QmlProfilerEventRelativesView() QmlProfilerEventRelativesView::~QmlProfilerEventRelativesView()
......
...@@ -78,6 +78,11 @@ public: ...@@ -78,6 +78,11 @@ public:
void setShowExtendedStatistics(bool show); void setShowExtendedStatistics(bool show);
bool showExtendedStatistics() const; bool showExtendedStatistics() const;
void setShowJavaScript(bool show);
bool showJavaScript() const;
void setShowQml(bool show);
bool showQml() const;
signals: signals:
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber); void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
......
...@@ -428,7 +428,7 @@ void QmlProfilerTraceView::showContextMenu(QPoint position) ...@@ -428,7 +428,7 @@ void QmlProfilerTraceView::showContextMenu(QPoint position)
if (!d->m_viewContainer->hasValidSelection()) if (!d->m_viewContainer->hasValidSelection())
getLocalStatsAction->setEnabled(false); getLocalStatsAction->setEnabled(false);
QAction *getGlobalStatsAction = menu.addAction(tr("Reset Events Pane")); QAction *getGlobalStatsAction = menu.addAction(tr("Show Full Range in Events Pane"));
if (d->m_viewContainer->hasGlobalStats()) if (d->m_viewContainer->hasGlobalStats())
getGlobalStatsAction->setEnabled(false); getGlobalStatsAction->setEnabled(false);
......
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