2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-06-29 15:05:45 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-06-29 15:05:45 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-06-29 15:05:45 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-06-29 15:05:45 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-06-29 15:05:45 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-06-29 15:05:45 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-06-29 15:05:45 +02:00
|
|
|
|
|
|
|
|
#include "qmlprofilereventview.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QUrl>
|
|
|
|
|
#include <QHash>
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QStandardItem>
|
|
|
|
|
#include <QHeaderView>
|
2011-07-26 13:56:14 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QClipboard>
|
2011-08-24 11:18:48 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QContextMenuEvent>
|
2011-07-26 13:56:14 +02:00
|
|
|
#include <QDebug>
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
#include <coreplugin/minisplitter.h>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QHBoxLayout>
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
#include "qmlprofilerviewmanager.h"
|
|
|
|
|
#include "qmlprofilertool.h"
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
using namespace QmlDebug;
|
2011-08-05 11:12:27 +02:00
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
namespace QmlProfiler {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2012-02-06 16:08:56 +01:00
|
|
|
struct Colors {
|
|
|
|
|
Colors () {
|
|
|
|
|
this->bindingLoopBackground = QColor("orange").lighter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QColor bindingLoopBackground;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Q_GLOBAL_STATIC(Colors, colors)
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
2011-07-26 13:56:14 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
class EventsViewItem : public QStandardItem
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
EventsViewItem(const QString &text) : QStandardItem(text) {}
|
|
|
|
|
|
|
|
|
|
virtual bool operator<(const QStandardItem &other) const
|
|
|
|
|
{
|
|
|
|
|
if (data().type() == QVariant::String) {
|
|
|
|
|
// first column
|
2011-07-18 14:24:33 +02:00
|
|
|
if (column() == 0) {
|
|
|
|
|
return data(FilenameRole).toString() == other.data(FilenameRole).toString() ?
|
2012-05-02 17:53:50 +02:00
|
|
|
data(LineRole).toInt() < other.data(LineRole).toInt() :
|
|
|
|
|
data(FilenameRole).toString() < other.data(FilenameRole).toString();
|
2011-07-18 14:24:33 +02:00
|
|
|
} else {
|
2011-12-05 16:32:05 +01:00
|
|
|
return data().toString().toLower() < other.data().toString().toLower();
|
2011-07-18 14:24:33 +02:00
|
|
|
}
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return data().toDouble() < other.data().toDouble();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
class QmlProfilerEventsWidget::QmlProfilerEventsWidgetPrivate
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
public:
|
|
|
|
|
QmlProfilerEventsWidgetPrivate(QmlProfilerEventsWidget *qq):q(qq) {}
|
|
|
|
|
~QmlProfilerEventsWidgetPrivate() {}
|
|
|
|
|
|
|
|
|
|
QmlProfilerEventsWidget *q;
|
|
|
|
|
|
2013-08-08 11:37:15 +02:00
|
|
|
QmlProfilerTool *m_profilerTool;
|
2012-02-24 10:47:17 +01:00
|
|
|
QmlProfilerViewManager *m_viewContainer;
|
|
|
|
|
|
|
|
|
|
QmlProfilerEventsMainView *m_eventTree;
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerEventRelativesView *m_eventChildren;
|
|
|
|
|
QmlProfilerEventRelativesView *m_eventParents;
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerEventsModelProxy *modelProxy;
|
2014-03-06 16:12:02 +01:00
|
|
|
qint64 rangeStart;
|
|
|
|
|
qint64 rangeEnd;
|
2012-02-24 10:47:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent,
|
2013-08-08 11:37:15 +02:00
|
|
|
QmlProfilerTool *profilerTool,
|
2012-05-02 17:53:50 +02:00
|
|
|
QmlProfilerViewManager *container,
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerModelManager *profilerModelManager )
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
: QWidget(parent), d(new QmlProfilerEventsWidgetPrivate(this))
|
|
|
|
|
{
|
2012-11-26 21:18:13 +02:00
|
|
|
setObjectName(QLatin1String("QmlProfilerEventsView"));
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
d->modelProxy = new QmlProfilerEventsModelProxy(profilerModelManager, this);
|
|
|
|
|
connect(profilerModelManager, SIGNAL(stateChanged()),
|
2012-02-24 10:47:17 +01:00
|
|
|
this, SLOT(profilerDataModelStateChanged()));
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_eventTree = new QmlProfilerEventsMainView(this, d->modelProxy);
|
2012-02-24 10:47:17 +01:00
|
|
|
connect(d->m_eventTree, SIGNAL(gotoSourceLocation(QString,int,int)), this, SIGNAL(gotoSourceLocation(QString,int,int)));
|
2013-08-08 13:28:08 +02:00
|
|
|
connect(d->m_eventTree, SIGNAL(eventSelected(QString)), this, SIGNAL(eventSelectedByHash(QString)));
|
|
|
|
|
|
|
|
|
|
d->m_eventChildren = new QmlProfilerEventRelativesView(
|
|
|
|
|
profilerModelManager,
|
|
|
|
|
new QmlProfilerEventChildrenModelProxy(profilerModelManager, d->modelProxy, this),
|
|
|
|
|
this);
|
|
|
|
|
d->m_eventParents = new QmlProfilerEventRelativesView(
|
|
|
|
|
profilerModelManager,
|
|
|
|
|
new QmlProfilerEventParentsModelProxy(profilerModelManager, d->modelProxy, this),
|
|
|
|
|
this);
|
|
|
|
|
connect(d->m_eventTree, SIGNAL(eventSelected(QString)), d->m_eventChildren, SLOT(displayEvent(QString)));
|
|
|
|
|
connect(d->m_eventTree, SIGNAL(eventSelected(QString)), d->m_eventParents, SLOT(displayEvent(QString)));
|
|
|
|
|
connect(d->m_eventChildren, SIGNAL(eventClicked(QString)), d->m_eventTree, SLOT(selectEvent(QString)));
|
|
|
|
|
connect(d->m_eventParents, SIGNAL(eventClicked(QString)), d->m_eventTree, SLOT(selectEvent(QString)));
|
2011-11-04 17:33:09 +01:00
|
|
|
|
|
|
|
|
// widget arrangement
|
|
|
|
|
QVBoxLayout *groupLayout = new QVBoxLayout;
|
|
|
|
|
groupLayout->setContentsMargins(0,0,0,0);
|
|
|
|
|
groupLayout->setSpacing(0);
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
Core::MiniSplitter *splitterVertical = new Core::MiniSplitter;
|
2012-02-24 10:47:17 +01:00
|
|
|
splitterVertical->addWidget(d->m_eventTree);
|
2011-11-04 17:33:09 +01:00
|
|
|
Core::MiniSplitter *splitterHorizontal = new Core::MiniSplitter;
|
2012-02-24 10:47:17 +01:00
|
|
|
splitterHorizontal->addWidget(d->m_eventParents);
|
|
|
|
|
splitterHorizontal->addWidget(d->m_eventChildren);
|
2011-11-04 17:33:09 +01:00
|
|
|
splitterHorizontal->setOrientation(Qt::Horizontal);
|
|
|
|
|
splitterVertical->addWidget(splitterHorizontal);
|
|
|
|
|
splitterVertical->setOrientation(Qt::Vertical);
|
|
|
|
|
splitterVertical->setStretchFactor(0,5);
|
|
|
|
|
splitterVertical->setStretchFactor(1,2);
|
|
|
|
|
groupLayout->addWidget(splitterVertical);
|
|
|
|
|
setLayout(groupLayout);
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_profilerTool = profilerTool;
|
|
|
|
|
d->m_viewContainer = container;
|
2014-03-06 16:12:02 +01:00
|
|
|
d->rangeStart = d->rangeEnd = -1;
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProfilerEventsWidget::~QmlProfilerEventsWidget()
|
|
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
delete d->modelProxy;
|
2012-02-24 10:47:17 +01:00
|
|
|
delete d;
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
void QmlProfilerEventsWidget::profilerDataModelStateChanged()
|
2012-02-13 15:26:57 +01:00
|
|
|
{
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerEventsWidget::clear()
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_eventTree->clear();
|
|
|
|
|
d->m_eventChildren->clear();
|
|
|
|
|
d->m_eventParents->clear();
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-08 16:54:23 +01:00
|
|
|
void QmlProfilerEventsWidget::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd)
|
|
|
|
|
{
|
2014-03-06 16:12:02 +01:00
|
|
|
d->rangeStart = rangeStart;
|
|
|
|
|
d->rangeEnd = rangeEnd;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->modelProxy->limitToRange(rangeStart, rangeEnd);
|
2011-11-08 16:54:23 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
QModelIndex QmlProfilerEventsWidget::selectedItem() const
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
return d->m_eventTree->selectedItem();
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev)
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
QTC_ASSERT(d->m_viewContainer, return;);
|
|
|
|
|
|
|
|
|
|
QMenu menu;
|
|
|
|
|
QAction *copyRowAction = 0;
|
|
|
|
|
QAction *copyTableAction = 0;
|
|
|
|
|
QAction *showExtendedStatsAction = 0;
|
2014-03-06 16:12:02 +01:00
|
|
|
QAction *showJavaScriptAction = 0;
|
|
|
|
|
QAction *showQmlAction = 0;
|
2012-02-24 10:47:17 +01:00
|
|
|
QAction *getLocalStatsAction = 0;
|
|
|
|
|
QAction *getGlobalStatsAction = 0;
|
|
|
|
|
|
|
|
|
|
QPoint position = ev->globalPos();
|
|
|
|
|
|
2013-08-08 11:37:15 +02:00
|
|
|
if (d->m_profilerTool) {
|
|
|
|
|
QList <QAction *> commonActions = d->m_profilerTool->profilerContextMenuActions();
|
2012-02-24 10:47:17 +01:00
|
|
|
foreach (QAction *act, commonActions) {
|
|
|
|
|
menu.addAction(act);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mouseOnTable(position)) {
|
|
|
|
|
menu.addSeparator();
|
|
|
|
|
if (selectedItem().isValid())
|
|
|
|
|
copyRowAction = menu.addAction(tr("Copy Row"));
|
|
|
|
|
copyTableAction = menu.addAction(tr("Copy Table"));
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
showExtendedStatsAction = menu.addAction(tr("Extended Event Statistics"));
|
|
|
|
|
showExtendedStatsAction->setCheckable(true);
|
|
|
|
|
showExtendedStatsAction->setChecked(showExtendedStatistics());
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
menu.addSeparator();
|
2014-03-06 16:12:02 +01:00
|
|
|
getLocalStatsAction = menu.addAction(tr("Limit to Current Range"));
|
2013-08-08 13:28:08 +02:00
|
|
|
if (!d->m_viewContainer->hasValidSelection())
|
|
|
|
|
getLocalStatsAction->setEnabled(false);
|
2014-03-06 16:12:02 +01:00
|
|
|
getGlobalStatsAction = menu.addAction(tr("Show Full Range"));
|
2013-08-08 13:28:08 +02:00
|
|
|
if (hasGlobalStats())
|
|
|
|
|
getGlobalStatsAction->setEnabled(false);
|
2012-02-24 10:47:17 +01:00
|
|
|
|
2014-03-06 16:12:02 +01:00
|
|
|
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());
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
QAction *selectedAction = menu.exec(position);
|
|
|
|
|
|
|
|
|
|
if (selectedAction) {
|
|
|
|
|
if (selectedAction == copyRowAction)
|
|
|
|
|
copyRowToClipboard();
|
|
|
|
|
if (selectedAction == copyTableAction)
|
|
|
|
|
copyTableToClipboard();
|
|
|
|
|
if (selectedAction == getLocalStatsAction) {
|
|
|
|
|
getStatisticsInRange(d->m_viewContainer->selectionStart(),
|
|
|
|
|
d->m_viewContainer->selectionEnd());
|
|
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
if (selectedAction == getGlobalStatsAction)
|
|
|
|
|
getStatisticsInRange(-1, -1);
|
2012-02-24 10:47:17 +01:00
|
|
|
if (selectedAction == showExtendedStatsAction)
|
|
|
|
|
setShowExtendedStatistics(!showExtendedStatistics());
|
2014-03-06 16:12:02 +01:00
|
|
|
if (selectedAction == showJavaScriptAction)
|
|
|
|
|
setShowJavaScript(showJavaScriptAction->isChecked());
|
|
|
|
|
if (selectedAction == showQmlAction)
|
|
|
|
|
setShowQml(showQmlAction->isChecked());
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2012-05-16 12:16:45 +02:00
|
|
|
void QmlProfilerEventsWidget::resizeEvent(QResizeEvent *event)
|
|
|
|
|
{
|
|
|
|
|
QWidget::resizeEvent(event);
|
|
|
|
|
emit resized();
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
bool QmlProfilerEventsWidget::mouseOnTable(const QPoint &position) const
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
QPoint tableTopLeft = d->m_eventTree->mapToGlobal(QPoint(0,0));
|
|
|
|
|
QPoint tableBottomRight = d->m_eventTree->mapToGlobal(QPoint(d->m_eventTree->width(), d->m_eventTree->height()));
|
2011-11-04 17:33:09 +01:00
|
|
|
return (position.x() >= tableTopLeft.x() && position.x() <= tableBottomRight.x() && position.y() >= tableTopLeft.y() && position.y() <= tableBottomRight.y());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerEventsWidget::copyTableToClipboard() const
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_eventTree->copyTableToClipboard();
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerEventsWidget::copyRowToClipboard() const
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_eventTree->copyRowToClipboard();
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
void QmlProfilerEventsWidget::updateSelectedEvent(const QString &eventHash) const
|
2011-11-09 12:57:41 +01:00
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_eventTree->selectedEventHash() != eventHash)
|
|
|
|
|
d->m_eventTree->selectEvent(eventHash);
|
2011-11-09 12:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-12 16:36:40 +01:00
|
|
|
void QmlProfilerEventsWidget::selectBySourceLocation(const QString &filename, int line, int column)
|
2011-12-14 14:30:37 +01:00
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_eventTree->selectEventByLocation(filename, line, column);
|
2011-12-14 14:30:37 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-10 11:19:22 +01:00
|
|
|
bool QmlProfilerEventsWidget::hasGlobalStats() const
|
|
|
|
|
{
|
2014-03-06 16:12:02 +01:00
|
|
|
return d->rangeStart == -1 && d->rangeEnd == -1;
|
2011-11-10 11:19:22 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-03 17:28:29 +01:00
|
|
|
void QmlProfilerEventsWidget::setShowExtendedStatistics(bool show)
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_eventTree->setShowExtendedStatistics(show);
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlProfilerEventsWidget::showExtendedStatistics() const
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
return d->m_eventTree->showExtendedStatistics();
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-06 16:12:02 +01:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
class QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2011-11-04 17:33:09 +01:00
|
|
|
QmlProfilerEventsMainViewPrivate(QmlProfilerEventsMainView *qq) : q(qq) {}
|
2011-06-29 15:05:45 +02:00
|
|
|
|
|
|
|
|
int getFieldCount();
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
QString textForItem(QStandardItem *item, bool recursive = false) const;
|
2011-08-24 11:18:48 +02:00
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
QmlProfilerEventsMainView *q;
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerEventsModelProxy *modelProxy;
|
2011-06-29 15:05:45 +02:00
|
|
|
QStandardItemModel *m_model;
|
|
|
|
|
QList<bool> m_fieldShown;
|
2012-02-03 17:28:29 +01:00
|
|
|
QHash<int, int> m_columnIndex; // maps field enum to column index
|
|
|
|
|
bool m_showExtendedStatistics;
|
2011-06-29 15:05:45 +02:00
|
|
|
int m_firstNumericColumn;
|
2012-01-23 17:40:32 +01:00
|
|
|
bool m_preventSelectBounce;
|
2011-06-29 15:05:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerEventsMainView::QmlProfilerEventsMainView(QWidget *parent,
|
|
|
|
|
QmlProfilerEventsModelProxy *modelProxy)
|
|
|
|
|
: QmlProfilerTreeView(parent), d(new QmlProfilerEventsMainViewPrivate(this))
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2012-11-26 21:18:13 +02:00
|
|
|
setObjectName(QLatin1String("QmlProfilerEventsTable"));
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
setSortingEnabled(false);
|
|
|
|
|
|
|
|
|
|
d->m_model = new QStandardItemModel(this);
|
|
|
|
|
setModel(d->m_model);
|
2014-04-09 17:25:34 +02:00
|
|
|
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(jumpToItem(QModelIndex)));
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
d->modelProxy = modelProxy;
|
|
|
|
|
connect(d->modelProxy,SIGNAL(dataAvailable()), this, SLOT(buildModel()));
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_firstNumericColumn = 0;
|
2012-01-23 17:40:32 +01:00
|
|
|
d->m_preventSelectBounce = false;
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_showExtendedStatistics = false;
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
setFieldViewable(Name, true);
|
|
|
|
|
setFieldViewable(Type, true);
|
|
|
|
|
setFieldViewable(TimeInPercent, true);
|
|
|
|
|
setFieldViewable(TotalTime, true);
|
|
|
|
|
setFieldViewable(SelfTimeInPercent, false);
|
|
|
|
|
setFieldViewable(SelfTime, false);
|
|
|
|
|
setFieldViewable(CallCount, true);
|
|
|
|
|
setFieldViewable(TimePerCall, true);
|
|
|
|
|
setFieldViewable(MaxTime, true);
|
|
|
|
|
setFieldViewable(MinTime, true);
|
|
|
|
|
setFieldViewable(MedianTime, true);
|
|
|
|
|
setFieldViewable(Details, true);
|
|
|
|
|
|
|
|
|
|
buildModel();
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
QmlProfilerEventsMainView::~QmlProfilerEventsMainView()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
delete d->m_model;
|
2012-03-14 12:30:22 +01:00
|
|
|
delete d;
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
void QmlProfilerEventsMainView::profilerDataModelStateChanged()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2012-02-13 15:26:57 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
void QmlProfilerEventsMainView::setFieldViewable(Fields field, bool show)
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
if (field < MaxFields) {
|
|
|
|
|
int length = d->m_fieldShown.count();
|
|
|
|
|
if (field >= length) {
|
|
|
|
|
for (int i=length; i<MaxFields; i++)
|
|
|
|
|
d->m_fieldShown << false;
|
|
|
|
|
}
|
|
|
|
|
d->m_fieldShown[field] = show;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
void QmlProfilerEventsMainView::setHeaderLabels()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
int fieldIndex = 0;
|
|
|
|
|
d->m_firstNumericColumn = 0;
|
|
|
|
|
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_columnIndex.clear();
|
2011-06-29 15:05:45 +02:00
|
|
|
if (d->m_fieldShown[Name]) {
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_columnIndex[Name] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(Location)));
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_firstNumericColumn++;
|
|
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[Type]) {
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_columnIndex[Type] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(Type)));
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_firstNumericColumn++;
|
|
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[TimeInPercent]) {
|
|
|
|
|
d->m_columnIndex[TimeInPercent] = fieldIndex;
|
|
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(TimeInPercent)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[TotalTime]) {
|
|
|
|
|
d->m_columnIndex[TotalTime] = fieldIndex;
|
|
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(TotalTime)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[SelfTimeInPercent]) {
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_columnIndex[Type] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(SelfTimeInPercent)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[SelfTime]) {
|
|
|
|
|
d->m_columnIndex[SelfTime] = fieldIndex;
|
|
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(SelfTime)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[CallCount]) {
|
|
|
|
|
d->m_columnIndex[CallCount] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(CallCount)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[TimePerCall]) {
|
|
|
|
|
d->m_columnIndex[TimePerCall] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(TimePerCall)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[MedianTime]) {
|
|
|
|
|
d->m_columnIndex[MedianTime] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(MedianTime)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[MaxTime]) {
|
|
|
|
|
d->m_columnIndex[MaxTime] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(MaxTime)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[MinTime]) {
|
|
|
|
|
d->m_columnIndex[MinTime] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(MinTime)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
2012-01-17 13:26:57 +01:00
|
|
|
if (d->m_fieldShown[Details]) {
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_columnIndex[Details] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(Details)));
|
2012-01-17 13:26:57 +01:00
|
|
|
}
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2012-02-03 17:28:29 +01:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
void QmlProfilerEventsMainView::clear()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
d->m_model->clear();
|
|
|
|
|
d->m_model->setColumnCount(d->getFieldCount());
|
|
|
|
|
|
|
|
|
|
setHeaderLabels();
|
|
|
|
|
setSortingEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
int QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::getFieldCount()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (int i=0; i < m_fieldShown.count(); ++i)
|
2011-12-05 16:32:05 +01:00
|
|
|
if (m_fieldShown[i])
|
2011-06-29 15:05:45 +02:00
|
|
|
count++;
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
void QmlProfilerEventsMainView::buildModel()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
clear();
|
|
|
|
|
parseModelProxy();
|
|
|
|
|
setShowExtendedStatistics(d->m_showExtendedStatistics);
|
2012-02-03 17:28:29 +01:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
setRootIsDecorated(false);
|
|
|
|
|
setSortingEnabled(true);
|
|
|
|
|
sortByColumn(d->m_firstNumericColumn,Qt::DescendingOrder);
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
expandAll();
|
|
|
|
|
if (d->m_fieldShown[Name])
|
|
|
|
|
resizeColumnToContents(0);
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[Type])
|
|
|
|
|
resizeColumnToContents(d->m_fieldShown[Name]?1:0);
|
|
|
|
|
collapseAll();
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
void QmlProfilerEventsMainView::parseModelProxy()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
const QList <QmlProfilerEventsModelProxy::QmlEventStats> eventList = d->modelProxy->getData();
|
|
|
|
|
foreach (const QmlProfilerEventsModelProxy::QmlEventStats &event, eventList) {
|
|
|
|
|
QStandardItem *parentItem = d->m_model->invisibleRootItem();
|
2011-06-29 15:05:45 +02:00
|
|
|
QList<QStandardItem *> newRow;
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[Name])
|
|
|
|
|
newRow << new EventsViewItem(event.displayName);
|
|
|
|
|
|
|
|
|
|
if (d->m_fieldShown[Type]) {
|
2014-06-03 16:57:32 +02:00
|
|
|
QString typeString = QmlProfilerEventsMainView::nameForType(event.rangeType);
|
2012-05-02 17:53:50 +02:00
|
|
|
QString toolTipText;
|
2014-06-03 16:57:32 +02:00
|
|
|
if (event.rangeType == Binding) {
|
2013-08-08 13:28:08 +02:00
|
|
|
if (event.bindingType == (int)OptimizedBinding) {
|
2013-10-17 14:52:10 +02:00
|
|
|
typeString = typeString + QLatin1Char(' ') + tr("(Opt)");
|
2012-05-31 12:00:49 +02:00
|
|
|
toolTipText = tr("Binding is evaluated by the optimized engine.");
|
2013-08-08 13:28:08 +02:00
|
|
|
} else if (event.bindingType == (int)V8Binding) {
|
2014-03-06 14:49:03 +01:00
|
|
|
toolTipText = tr("Binding not optimized (might have side effects or assignments,\n"
|
|
|
|
|
"references to elements in other files, loops, and so on.)");
|
2012-05-31 12:00:49 +02:00
|
|
|
|
|
|
|
|
}
|
2012-05-02 17:53:50 +02:00
|
|
|
}
|
|
|
|
|
newRow << new EventsViewItem(typeString);
|
|
|
|
|
newRow.last()->setData(QVariant(typeString));
|
|
|
|
|
if (!toolTipText.isEmpty())
|
|
|
|
|
newRow.last()->setToolTip(toolTipText);
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[TimeInPercent]) {
|
|
|
|
|
newRow << new EventsViewItem(QString::number(event.percentOfTime,'f',2)+QLatin1String(" %"));
|
|
|
|
|
newRow.last()->setData(QVariant(event.percentOfTime));
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[TotalTime]) {
|
2014-02-18 17:32:20 +01:00
|
|
|
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.duration));
|
2013-08-08 13:28:08 +02:00
|
|
|
newRow.last()->setData(QVariant(event.duration));
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[CallCount]) {
|
|
|
|
|
newRow << new EventsViewItem(QString::number(event.calls));
|
|
|
|
|
newRow.last()->setData(QVariant(event.calls));
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[TimePerCall]) {
|
2014-02-18 17:32:20 +01:00
|
|
|
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.timePerCall));
|
2013-08-08 13:28:08 +02:00
|
|
|
newRow.last()->setData(QVariant(event.timePerCall));
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[MedianTime]) {
|
2014-02-18 17:32:20 +01:00
|
|
|
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.medianTime));
|
2013-08-08 13:28:08 +02:00
|
|
|
newRow.last()->setData(QVariant(event.medianTime));
|
2011-08-24 16:30:31 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[MaxTime]) {
|
2014-02-18 17:32:20 +01:00
|
|
|
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.maxTime));
|
2013-08-08 13:28:08 +02:00
|
|
|
newRow.last()->setData(QVariant(event.maxTime));
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[MinTime]) {
|
2014-02-18 17:32:20 +01:00
|
|
|
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.minTime));
|
2013-08-08 13:28:08 +02:00
|
|
|
newRow.last()->setData(QVariant(event.minTime));
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[Details]) {
|
|
|
|
|
newRow << new EventsViewItem(event.details);
|
|
|
|
|
newRow.last()->setData(QVariant(event.details));
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2011-08-24 16:30:31 +02:00
|
|
|
|
|
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
if (!newRow.isEmpty()) {
|
|
|
|
|
// no edit
|
|
|
|
|
foreach (QStandardItem *item, newRow)
|
|
|
|
|
item->setEditable(false);
|
|
|
|
|
|
|
|
|
|
// metadata
|
2013-08-08 13:28:08 +02:00
|
|
|
newRow.at(0)->setData(QVariant(event.eventHashStr),EventHashStrRole);
|
|
|
|
|
newRow.at(0)->setData(QVariant(event.location.filename),FilenameRole);
|
|
|
|
|
newRow.at(0)->setData(QVariant(event.location.line),LineRole);
|
|
|
|
|
newRow.at(0)->setData(QVariant(event.location.column),ColumnRole);
|
|
|
|
|
|
|
|
|
|
if (event.isBindingLoop) {
|
2012-02-06 16:08:56 +01:00
|
|
|
foreach (QStandardItem *item, newRow) {
|
|
|
|
|
item->setBackground(colors()->bindingLoopBackground);
|
2012-10-01 10:13:04 +02:00
|
|
|
item->setToolTip(tr("Binding loop detected."));
|
2012-02-06 16:08:56 +01:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
}
|
2011-06-29 15:05:45 +02:00
|
|
|
|
|
|
|
|
// append
|
|
|
|
|
parentItem->appendRow(newRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-03 16:57:32 +02:00
|
|
|
QString QmlProfilerEventsMainView::nameForType(QmlDebug::RangeType typeNumber)
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
switch (typeNumber) {
|
2014-06-03 16:57:32 +02:00
|
|
|
case QmlDebug::Painting: return QmlProfilerEventsMainView::tr("Paint");
|
|
|
|
|
case QmlDebug::Compiling: return QmlProfilerEventsMainView::tr("Compile");
|
|
|
|
|
case QmlDebug::Creating: return QmlProfilerEventsMainView::tr("Create");
|
|
|
|
|
case QmlDebug::Binding: return QmlProfilerEventsMainView::tr("Binding");
|
|
|
|
|
case QmlDebug::HandlingSignal: return QmlProfilerEventsMainView::tr("Signal");
|
|
|
|
|
case QmlDebug::Javascript: return QmlProfilerEventsMainView::tr("JavaScript");
|
|
|
|
|
default: return QString();
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-08 16:54:23 +01:00
|
|
|
void QmlProfilerEventsMainView::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd)
|
|
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
d->modelProxy->limitToRange(rangeStart, rangeEnd);
|
2011-11-10 11:19:22 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
QString QmlProfilerEventsMainView::selectedEventHash() const
|
2011-11-09 12:57:41 +01:00
|
|
|
{
|
|
|
|
|
QModelIndex index = selectedItem();
|
|
|
|
|
if (!index.isValid())
|
2013-08-08 13:28:08 +02:00
|
|
|
return QString();
|
2011-11-09 12:57:41 +01:00
|
|
|
QStandardItem *item = d->m_model->item(index.row(), 0);
|
2013-08-08 13:28:08 +02:00
|
|
|
return item->data(EventHashStrRole).toString();
|
2011-11-09 12:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
void QmlProfilerEventsMainView::jumpToItem(const QModelIndex &index)
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2012-01-23 17:40:32 +01:00
|
|
|
if (d->m_preventSelectBounce)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
d->m_preventSelectBounce = true;
|
2011-06-29 15:05:45 +02:00
|
|
|
QStandardItem *clickedItem = d->m_model->itemFromIndex(index);
|
|
|
|
|
QStandardItem *infoItem;
|
|
|
|
|
if (clickedItem->parent())
|
|
|
|
|
infoItem = clickedItem->parent()->child(clickedItem->row(), 0);
|
|
|
|
|
else
|
|
|
|
|
infoItem = d->m_model->item(index.row(), 0);
|
|
|
|
|
|
2011-11-09 12:57:41 +01:00
|
|
|
// show in editor
|
2011-06-29 15:05:45 +02:00
|
|
|
int line = infoItem->data(LineRole).toInt();
|
2012-01-12 16:36:40 +01:00
|
|
|
int column = infoItem->data(ColumnRole).toInt();
|
2011-06-29 15:05:45 +02:00
|
|
|
QString fileName = infoItem->data(FilenameRole).toString();
|
2011-11-04 17:33:09 +01:00
|
|
|
if (line!=-1 && !fileName.isEmpty())
|
2012-01-12 16:36:40 +01:00
|
|
|
emit gotoSourceLocation(fileName, line, column);
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2011-11-09 12:57:41 +01:00
|
|
|
// show in callers/callees subwindow
|
2013-08-08 13:28:08 +02:00
|
|
|
emit eventSelected(infoItem->data(EventHashStrRole).toString());
|
2012-01-23 17:40:32 +01:00
|
|
|
|
|
|
|
|
d->m_preventSelectBounce = false;
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2014-04-03 11:15:56 +02:00
|
|
|
void QmlProfilerEventsMainView::selectItem(const QStandardItem *item)
|
|
|
|
|
{
|
|
|
|
|
// If the same item is already selected, don't reselect it.
|
|
|
|
|
QModelIndex index = d->m_model->indexFromItem(item);
|
|
|
|
|
if (index != currentIndex()) {
|
|
|
|
|
setCurrentIndex(index);
|
|
|
|
|
jumpToItem(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
void QmlProfilerEventsMainView::selectEvent(const QString &eventHash)
|
2011-07-26 13:56:14 +02:00
|
|
|
{
|
2011-11-04 17:33:09 +01:00
|
|
|
for (int i=0; i<d->m_model->rowCount(); i++) {
|
|
|
|
|
QStandardItem *infoItem = d->m_model->item(i, 0);
|
2013-08-08 13:28:08 +02:00
|
|
|
if (infoItem->data(EventHashStrRole).toString() == eventHash) {
|
2014-04-03 11:15:56 +02:00
|
|
|
selectItem(infoItem);
|
2011-11-04 17:33:09 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-26 13:56:14 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
void QmlProfilerEventsMainView::selectEventByLocation(const QString &filename, int line, int column)
|
2011-12-14 14:30:37 +01:00
|
|
|
{
|
2012-01-23 17:40:32 +01:00
|
|
|
if (d->m_preventSelectBounce)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-12-14 14:30:37 +01:00
|
|
|
for (int i=0; i<d->m_model->rowCount(); i++) {
|
|
|
|
|
QStandardItem *infoItem = d->m_model->item(i, 0);
|
2014-04-03 11:15:56 +02:00
|
|
|
if (infoItem->data(FilenameRole).toString() == filename &&
|
2013-08-08 13:28:08 +02:00
|
|
|
infoItem->data(LineRole).toInt() == line &&
|
|
|
|
|
(column == -1 ||
|
|
|
|
|
infoItem->data(ColumnRole).toInt() == column)) {
|
2014-04-03 11:15:56 +02:00
|
|
|
selectItem(infoItem);
|
2011-12-14 14:30:37 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
QModelIndex QmlProfilerEventsMainView::selectedItem() const
|
2011-08-24 11:18:48 +02:00
|
|
|
{
|
|
|
|
|
QModelIndexList sel = selectedIndexes();
|
|
|
|
|
if (sel.isEmpty())
|
|
|
|
|
return QModelIndex();
|
|
|
|
|
else
|
|
|
|
|
return sel.first();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
QString QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::textForItem(QStandardItem *item, bool recursive) const
|
2011-08-24 11:18:48 +02:00
|
|
|
{
|
|
|
|
|
QString str;
|
|
|
|
|
|
|
|
|
|
if (recursive) {
|
|
|
|
|
// indentation
|
|
|
|
|
QStandardItem *itemParent = item->parent();
|
|
|
|
|
while (itemParent) {
|
2012-11-26 21:18:13 +02:00
|
|
|
str += QLatin1String(" ");
|
2011-08-24 11:18:48 +02:00
|
|
|
itemParent = itemParent->parent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// item's data
|
|
|
|
|
int colCount = m_model->columnCount();
|
|
|
|
|
for (int j = 0; j < colCount; ++j) {
|
|
|
|
|
QStandardItem *colItem = item->parent() ? item->parent()->child(item->row(),j) : m_model->item(item->row(),j);
|
|
|
|
|
str += colItem->data(Qt::DisplayRole).toString();
|
2012-11-26 21:18:13 +02:00
|
|
|
if (j < colCount-1) str += QLatin1Char('\t');
|
2011-08-24 11:18:48 +02:00
|
|
|
}
|
2012-11-26 21:18:13 +02:00
|
|
|
str += QLatin1Char('\n');
|
2011-08-24 11:18:48 +02:00
|
|
|
|
|
|
|
|
// recursively print children
|
|
|
|
|
if (recursive && item->child(0))
|
|
|
|
|
for (int j = 0; j != item->rowCount(); j++)
|
|
|
|
|
str += textForItem(item->child(j));
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
void QmlProfilerEventsMainView::copyTableToClipboard() const
|
2011-08-24 11:18:48 +02:00
|
|
|
{
|
|
|
|
|
QString str;
|
2011-10-28 16:59:40 +02:00
|
|
|
// headers
|
|
|
|
|
int columnCount = d->m_model->columnCount();
|
|
|
|
|
for (int i = 0; i < columnCount; ++i) {
|
|
|
|
|
str += d->m_model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString();
|
|
|
|
|
if (i < columnCount - 1)
|
2012-11-26 21:18:13 +02:00
|
|
|
str += QLatin1Char('\t');
|
2011-10-28 16:59:40 +02:00
|
|
|
else
|
2012-11-26 21:18:13 +02:00
|
|
|
str += QLatin1Char('\n');
|
2011-10-28 16:59:40 +02:00
|
|
|
}
|
|
|
|
|
// data
|
|
|
|
|
int rowCount = d->m_model->rowCount();
|
|
|
|
|
for (int i = 0; i != rowCount; ++i) {
|
2011-08-24 11:18:48 +02:00
|
|
|
str += d->textForItem(d->m_model->item(i));
|
|
|
|
|
}
|
|
|
|
|
QClipboard *clipboard = QApplication::clipboard();
|
|
|
|
|
clipboard->setText(str, QClipboard::Selection);
|
|
|
|
|
clipboard->setText(str, QClipboard::Clipboard);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
void QmlProfilerEventsMainView::copyRowToClipboard() const
|
2011-08-24 11:18:48 +02:00
|
|
|
{
|
|
|
|
|
QString str;
|
|
|
|
|
str = d->textForItem(d->m_model->itemFromIndex(selectedItem()), false);
|
|
|
|
|
|
|
|
|
|
QClipboard *clipboard = QApplication::clipboard();
|
|
|
|
|
clipboard->setText(str, QClipboard::Selection);
|
|
|
|
|
clipboard->setText(str, QClipboard::Clipboard);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
class QmlProfilerEventRelativesView::QmlProfilerEventParentsViewPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QmlProfilerEventParentsViewPrivate(QmlProfilerEventRelativesView *qq):q(qq) {}
|
|
|
|
|
~QmlProfilerEventParentsViewPrivate() {}
|
|
|
|
|
|
|
|
|
|
QmlProfilerEventRelativesModelProxy *modelProxy;
|
|
|
|
|
|
|
|
|
|
QmlProfilerEventRelativesView *q;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QmlProfilerEventRelativesView::QmlProfilerEventRelativesView(QmlProfilerModelManager *modelManager, QmlProfilerEventRelativesModelProxy *modelProxy, QWidget *parent)
|
|
|
|
|
: QmlProfilerTreeView(parent), d(new QmlProfilerEventParentsViewPrivate(this))
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
Q_UNUSED(modelManager);
|
|
|
|
|
setSortingEnabled(false);
|
|
|
|
|
d->modelProxy = modelProxy;
|
2011-11-04 17:33:09 +01:00
|
|
|
setModel(new QStandardItemModel(this));
|
|
|
|
|
setRootIsDecorated(false);
|
|
|
|
|
updateHeader();
|
|
|
|
|
|
2014-04-09 17:25:34 +02:00
|
|
|
connect(this,SIGNAL(activated(QModelIndex)), this,SLOT(jumpToItem(QModelIndex)));
|
2014-03-06 16:12:02 +01:00
|
|
|
|
|
|
|
|
// Clear when new data available as the selection may be invalid now.
|
|
|
|
|
connect(d->modelProxy, SIGNAL(dataAvailable()), this, SLOT(clear()));
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerEventRelativesView::~QmlProfilerEventRelativesView()
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
delete d;
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
void QmlProfilerEventRelativesView::displayEvent(const QString &eventHash)
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
rebuildTree(d->modelProxy->getData(eventHash));
|
2011-11-04 17:33:09 +01:00
|
|
|
|
|
|
|
|
updateHeader();
|
|
|
|
|
resizeColumnToContents(0);
|
2011-11-10 11:19:22 +01:00
|
|
|
setSortingEnabled(true);
|
2013-08-08 13:28:08 +02:00
|
|
|
sortByColumn(2);
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
void QmlProfilerEventRelativesView::rebuildTree(QmlProfilerEventRelativesModelProxy::QmlEventRelativesMap eventMap)
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(treeModel());
|
|
|
|
|
treeModel()->clear();
|
|
|
|
|
|
|
|
|
|
QStandardItem *topLevelItem = treeModel()->invisibleRootItem();
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
foreach (const QString &key, eventMap.keys()) {
|
|
|
|
|
const QmlProfilerEventRelativesModelProxy::QmlEventRelativesData &event = eventMap[key];
|
2011-11-04 17:33:09 +01:00
|
|
|
QList<QStandardItem *> newRow;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
// ToDo: here we were going to search for the data in the other modelproxy
|
|
|
|
|
// maybe we should store the data in this proxy and get it here
|
|
|
|
|
// no indirections at this level of abstraction!
|
|
|
|
|
newRow << new EventsViewItem(event.displayName);
|
2014-06-03 16:57:32 +02:00
|
|
|
newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event.rangeType));
|
2014-02-18 17:32:20 +01:00
|
|
|
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.duration));
|
2013-08-08 13:28:08 +02:00
|
|
|
newRow << new EventsViewItem(QString::number(event.calls));
|
|
|
|
|
newRow << new EventsViewItem(event.details);
|
|
|
|
|
|
|
|
|
|
newRow.at(0)->setData(QVariant(key), EventHashStrRole);
|
|
|
|
|
newRow.at(2)->setData(QVariant(event.duration));
|
|
|
|
|
newRow.at(3)->setData(QVariant(event.calls));
|
|
|
|
|
|
|
|
|
|
if (event.isBindingLoop) {
|
|
|
|
|
foreach (QStandardItem *item, newRow) {
|
|
|
|
|
item->setBackground(colors()->bindingLoopBackground);
|
|
|
|
|
item->setToolTip(tr("Part of binding loop."));
|
|
|
|
|
}
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
foreach (QStandardItem *item, newRow)
|
|
|
|
|
item->setEditable(false);
|
|
|
|
|
|
|
|
|
|
topLevelItem->appendRow(newRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
void QmlProfilerEventRelativesView::clear()
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
|
|
|
|
if (treeModel()) {
|
|
|
|
|
treeModel()->clear();
|
|
|
|
|
updateHeader();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
void QmlProfilerEventRelativesView::updateHeader()
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
bool calleesView = qobject_cast<QmlProfilerEventChildrenModelProxy *>(d->modelProxy) != 0;
|
2011-11-04 17:33:09 +01:00
|
|
|
|
|
|
|
|
if (treeModel()) {
|
2013-08-08 13:28:08 +02:00
|
|
|
treeModel()->setColumnCount(5);
|
2011-11-04 17:33:09 +01:00
|
|
|
|
|
|
|
|
int columnIndex = 0;
|
2013-08-08 13:28:08 +02:00
|
|
|
if (calleesView)
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(Callee)));
|
2011-11-04 17:33:09 +01:00
|
|
|
else
|
2013-08-08 13:28:08 +02:00
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(Caller)));
|
|
|
|
|
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(Type)));
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(TotalTime)));
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(CallCount)));
|
2011-12-05 16:32:05 +01:00
|
|
|
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (calleesView)
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(CalleeDescription)));
|
2011-11-04 17:33:09 +01:00
|
|
|
else
|
2013-08-08 13:28:08 +02:00
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(CallerDescription)));
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
QStandardItemModel *QmlProfilerEventRelativesView::treeModel()
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
|
|
|
|
return qobject_cast<QStandardItemModel *>(model());
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
void QmlProfilerEventRelativesView::jumpToItem(const QModelIndex &index)
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
|
|
|
|
if (treeModel()) {
|
|
|
|
|
QStandardItem *infoItem = treeModel()->item(index.row(), 0);
|
2013-08-08 13:28:08 +02:00
|
|
|
emit eventClicked(infoItem->data(EventHashStrRole).toString());
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProfiler
|