2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-06-29 15:05:45 +02:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 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)
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
Analyzer::IAnalyzerTool *m_profilerTool;
|
|
|
|
|
QmlProfilerViewManager *m_viewContainer;
|
|
|
|
|
|
|
|
|
|
QmlProfilerEventsMainView *m_eventTree;
|
|
|
|
|
QmlProfilerEventsParentsAndChildrenView *m_eventChildren;
|
|
|
|
|
QmlProfilerEventsParentsAndChildrenView *m_eventParents;
|
|
|
|
|
QmlProfilerDataModel *m_profilerDataModel;
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
bool m_globalStatsEnabled;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent,
|
2012-05-02 17:53:50 +02:00
|
|
|
Analyzer::IAnalyzerTool *profilerTool,
|
|
|
|
|
QmlProfilerViewManager *container,
|
|
|
|
|
QmlProfilerDataModel *profilerDataModel )
|
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
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_profilerDataModel = profilerDataModel;
|
|
|
|
|
connect(d->m_profilerDataModel, SIGNAL(stateChanged()),
|
|
|
|
|
this, SLOT(profilerDataModelStateChanged()));
|
|
|
|
|
|
|
|
|
|
d->m_eventTree = new QmlProfilerEventsMainView(QmlProfilerEventsMainView::EventsView, this, d->m_profilerDataModel);
|
|
|
|
|
connect(d->m_eventTree, SIGNAL(gotoSourceLocation(QString,int,int)), this, SIGNAL(gotoSourceLocation(QString,int,int)));
|
|
|
|
|
connect(d->m_eventTree, SIGNAL(showEventInTimeline(int)), this, SIGNAL(showEventInTimeline(int)));
|
|
|
|
|
|
|
|
|
|
d->m_eventChildren = new QmlProfilerEventsParentsAndChildrenView(
|
|
|
|
|
QmlProfilerEventsParentsAndChildrenView::ChildrenView,
|
|
|
|
|
this,
|
|
|
|
|
d->m_profilerDataModel);
|
|
|
|
|
d->m_eventParents = new QmlProfilerEventsParentsAndChildrenView(
|
|
|
|
|
QmlProfilerEventsParentsAndChildrenView::ParentsView,
|
|
|
|
|
this,
|
|
|
|
|
d->m_profilerDataModel);
|
|
|
|
|
connect(d->m_eventTree, SIGNAL(eventSelected(int)), d->m_eventChildren, SLOT(displayEvent(int)));
|
|
|
|
|
connect(d->m_eventTree, SIGNAL(eventSelected(int)), d->m_eventParents, SLOT(displayEvent(int)));
|
|
|
|
|
connect(d->m_eventChildren, SIGNAL(eventClicked(int)), d->m_eventTree, SLOT(selectEvent(int)));
|
|
|
|
|
connect(d->m_eventParents, SIGNAL(eventClicked(int)), d->m_eventTree, SLOT(selectEvent(int)));
|
2011-11-04 17:33:09 +01:00
|
|
|
|
|
|
|
|
// widget arrangement
|
|
|
|
|
QVBoxLayout *groupLayout = new QVBoxLayout;
|
|
|
|
|
groupLayout->setContentsMargins(0,0,0,0);
|
|
|
|
|
groupLayout->setSpacing(0);
|
|
|
|
|
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;
|
|
|
|
|
d->m_globalStatsEnabled = true;
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProfilerEventsWidget::~QmlProfilerEventsWidget()
|
|
|
|
|
{
|
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
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
if (d->m_profilerDataModel) {
|
|
|
|
|
QmlProfilerDataModel::State newState = d->m_profilerDataModel->currentState();
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (newState == QmlProfilerDataModel::Empty)
|
2012-02-13 15:26:57 +01:00
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
void QmlProfilerEventsWidget::switchToV8View()
|
|
|
|
|
{
|
2012-11-26 21:18:13 +02:00
|
|
|
setObjectName(QLatin1String("QmlProfilerV8ProfileView"));
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_eventTree->setViewType(QmlProfilerEventsMainView::V8ProfileView);
|
|
|
|
|
d->m_eventParents->setViewType(QmlProfilerEventsParentsAndChildrenView::V8ParentsView);
|
|
|
|
|
d->m_eventChildren->setViewType(QmlProfilerEventsParentsAndChildrenView::V8ChildrenView);
|
2012-10-01 10:13:04 +02:00
|
|
|
setToolTip(tr("Trace information from the v8 JavaScript engine. Available only in Qt5 based applications."));
|
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)
|
|
|
|
|
{
|
|
|
|
|
clear();
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_eventTree->getStatisticsInRange(rangeStart, rangeEnd);
|
|
|
|
|
d->m_globalStatsEnabled = d->m_eventTree->isRangeGlobal(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;
|
|
|
|
|
QAction *getLocalStatsAction = 0;
|
|
|
|
|
QAction *getGlobalStatsAction = 0;
|
|
|
|
|
|
|
|
|
|
QmlProfilerTool *profilerTool = qobject_cast<QmlProfilerTool *>(d->m_profilerTool);
|
|
|
|
|
QPoint position = ev->globalPos();
|
|
|
|
|
|
|
|
|
|
if (profilerTool) {
|
|
|
|
|
QList <QAction *> commonActions = profilerTool->profilerContextMenuActions();
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
|
if (isQml()) {
|
|
|
|
|
// only for qml events view, not for v8
|
|
|
|
|
showExtendedStatsAction = menu.addAction(tr("Extended Event Statistics"));
|
|
|
|
|
showExtendedStatsAction->setCheckable(true);
|
|
|
|
|
showExtendedStatsAction->setChecked(showExtendedStatistics());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isQml()) {
|
|
|
|
|
menu.addSeparator();
|
|
|
|
|
getLocalStatsAction = menu.addAction(tr("Limit Events Pane to Current Range"));
|
|
|
|
|
if (!d->m_viewContainer->hasValidSelection())
|
|
|
|
|
getLocalStatsAction->setEnabled(false);
|
|
|
|
|
getGlobalStatsAction = menu.addAction(tr("Reset Events Pane"));
|
|
|
|
|
if (hasGlobalStats())
|
|
|
|
|
getGlobalStatsAction->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
if (selectedAction == getGlobalStatsAction) {
|
|
|
|
|
if (d->m_profilerDataModel) {
|
|
|
|
|
getStatisticsInRange(d->m_profilerDataModel->traceStartTime(),
|
|
|
|
|
d->m_profilerDataModel->traceEndTime());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (selectedAction == showExtendedStatsAction)
|
|
|
|
|
setShowExtendedStatistics(!showExtendedStatistics());
|
|
|
|
|
}
|
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
|
|
|
|
2011-11-09 12:57:41 +01:00
|
|
|
void QmlProfilerEventsWidget::updateSelectedEvent(int eventId) const
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
if (d->m_eventTree->selectedEventId() != eventId)
|
|
|
|
|
d->m_eventTree->selectEvent(eventId);
|
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
|
|
|
{
|
2012-01-12 16:36:40 +01:00
|
|
|
// This slot is used to connect the javascript pane with the qml events pane
|
|
|
|
|
// Our javascript trace data does not store column information
|
|
|
|
|
// thus we ignore it here
|
|
|
|
|
Q_UNUSED(column);
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_eventTree->selectEventByLocation(filename, line);
|
2011-12-14 14:30:37 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-10 11:19:22 +01:00
|
|
|
bool QmlProfilerEventsWidget::hasGlobalStats() const
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
return d->m_globalStatsEnabled;
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlProfilerEventsWidget::isQml() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_eventTree->viewType() == QmlProfilerEventsMainView::EventsView;
|
|
|
|
|
}
|
|
|
|
|
bool QmlProfilerEventsWidget::isV8() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_eventTree->viewType() == QmlProfilerEventsMainView::V8ProfileView;
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
void buildModelFromList(const QList<QmlRangeEventData *> &list, QStandardItem *parentItem );
|
|
|
|
|
void buildV8ModelFromList( const QList<QV8EventData *> &list );
|
2011-06-29 15:05:45 +02:00
|
|
|
int getFieldCount();
|
|
|
|
|
|
2011-08-24 11:18:48 +02:00
|
|
|
QString textForItem(QStandardItem *item, bool recursive) const;
|
|
|
|
|
|
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
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
QmlProfilerEventsMainView::ViewTypes m_viewType;
|
2012-02-24 10:47:17 +01:00
|
|
|
QmlProfilerDataModel *m_profilerDataModel;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
QmlProfilerEventsMainView::QmlProfilerEventsMainView(ViewTypes viewType,
|
|
|
|
|
QWidget *parent,
|
|
|
|
|
QmlProfilerDataModel *dataModel)
|
|
|
|
|
: QTreeView(parent), d(new QmlProfilerEventsMainViewPrivate(this))
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2012-11-26 21:18:13 +02:00
|
|
|
setObjectName(QLatin1String("QmlProfilerEventsTable"));
|
2011-06-29 15:05:45 +02:00
|
|
|
header()->setResizeMode(QHeaderView::Interactive);
|
|
|
|
|
header()->setDefaultSectionSize(100);
|
|
|
|
|
header()->setMinimumSectionSize(50);
|
|
|
|
|
setSortingEnabled(false);
|
|
|
|
|
setFrameStyle(QFrame::NoFrame);
|
|
|
|
|
|
|
|
|
|
d->m_model = new QStandardItemModel(this);
|
|
|
|
|
setModel(d->m_model);
|
|
|
|
|
connect(this,SIGNAL(clicked(QModelIndex)), this,SLOT(jumpToItem(QModelIndex)));
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_profilerDataModel = dataModel;
|
|
|
|
|
connect(d->m_profilerDataModel,SIGNAL(stateChanged()),
|
|
|
|
|
this,SLOT(profilerDataModelStateChanged()));
|
|
|
|
|
connect(d->m_profilerDataModel,SIGNAL(detailsChanged(int,QString)),
|
|
|
|
|
this,SLOT(changeDetailsForEvent(int,QString)));
|
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
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
setViewType(viewType);
|
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-24 10:47:17 +01:00
|
|
|
if (d->m_profilerDataModel) {
|
|
|
|
|
QmlProfilerDataModel::State newState = d->m_profilerDataModel->currentState();
|
|
|
|
|
if (newState == QmlProfilerDataModel::Done)
|
2012-02-13 15:26:57 +01:00
|
|
|
buildModel();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
QmlProfilerEventsMainView::ViewTypes QmlProfilerEventsMainView::viewType() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_viewType;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
void QmlProfilerEventsMainView::setViewType(ViewTypes type)
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2011-09-27 14:38:22 +02:00
|
|
|
d->m_viewType = type;
|
2011-06-29 15:05:45 +02:00
|
|
|
switch (type) {
|
|
|
|
|
case EventsView: {
|
2012-11-26 21:18:13 +02:00
|
|
|
setObjectName(QLatin1String("QmlProfilerEventsTable"));
|
2011-06-29 15:05:45 +02:00
|
|
|
setFieldViewable(Name, true);
|
|
|
|
|
setFieldViewable(Type, true);
|
|
|
|
|
setFieldViewable(Percent, true);
|
|
|
|
|
setFieldViewable(TotalDuration, true);
|
2011-09-27 14:38:22 +02:00
|
|
|
setFieldViewable(SelfPercent, false);
|
|
|
|
|
setFieldViewable(SelfDuration, false);
|
2011-06-29 15:05:45 +02:00
|
|
|
setFieldViewable(CallCount, true);
|
|
|
|
|
setFieldViewable(TimePerCall, true);
|
|
|
|
|
setFieldViewable(MaxTime, true);
|
|
|
|
|
setFieldViewable(MinTime, true);
|
2011-08-24 16:30:31 +02:00
|
|
|
setFieldViewable(MedianTime, true);
|
2011-09-27 14:38:22 +02:00
|
|
|
setFieldViewable(Details, true);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case V8ProfileView: {
|
2012-11-26 21:18:13 +02:00
|
|
|
setObjectName(QLatin1String("QmlProfilerV8ProfileTable"));
|
2011-09-27 14:38:22 +02:00
|
|
|
setFieldViewable(Name, true);
|
|
|
|
|
setFieldViewable(Type, false);
|
|
|
|
|
setFieldViewable(Percent, true);
|
|
|
|
|
setFieldViewable(TotalDuration, true);
|
|
|
|
|
setFieldViewable(SelfPercent, true);
|
|
|
|
|
setFieldViewable(SelfDuration, true);
|
|
|
|
|
setFieldViewable(CallCount, false);
|
|
|
|
|
setFieldViewable(TimePerCall, false);
|
|
|
|
|
setFieldViewable(MaxTime, false);
|
|
|
|
|
setFieldViewable(MinTime, false);
|
|
|
|
|
setFieldViewable(MedianTime, false);
|
|
|
|
|
setFieldViewable(Details, true);
|
2011-06-29 15:05:45 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buildModel();
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Location")));
|
|
|
|
|
d->m_firstNumericColumn++;
|
|
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[Type]) {
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_columnIndex[Type] = fieldIndex;
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Type")));
|
|
|
|
|
d->m_firstNumericColumn++;
|
|
|
|
|
}
|
2012-02-03 17:28:29 +01:00
|
|
|
if (d->m_fieldShown[Percent]) {
|
|
|
|
|
d->m_columnIndex[Percent] = fieldIndex;
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Time in Percent")));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[TotalDuration]) {
|
|
|
|
|
d->m_columnIndex[TotalDuration] = fieldIndex;
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Total Time")));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[SelfPercent]) {
|
|
|
|
|
d->m_columnIndex[Type] = fieldIndex;
|
2011-09-27 14:38:22 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Self Time in Percent")));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[SelfDuration]) {
|
|
|
|
|
d->m_columnIndex[SelfDuration] = fieldIndex;
|
2011-09-27 14:38:22 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Self Time")));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[CallCount]) {
|
|
|
|
|
d->m_columnIndex[CallCount] = fieldIndex;
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Calls")));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[TimePerCall]) {
|
|
|
|
|
d->m_columnIndex[TimePerCall] = fieldIndex;
|
2011-08-24 16:30:31 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Mean Time")));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[MedianTime]) {
|
|
|
|
|
d->m_columnIndex[MedianTime] = fieldIndex;
|
2011-08-24 16:30:31 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Median Time")));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[MaxTime]) {
|
|
|
|
|
d->m_columnIndex[MaxTime] = fieldIndex;
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Longest Time")));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[MinTime]) {
|
|
|
|
|
d->m_columnIndex[MinTime] = fieldIndex;
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("Shortest Time")));
|
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;
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(tr("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
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
if (d->m_profilerDataModel) {
|
2011-06-29 15:05:45 +02:00
|
|
|
clear();
|
2011-09-27 14:38:22 +02:00
|
|
|
if (d->m_viewType == V8ProfileView)
|
2012-02-24 10:47:17 +01:00
|
|
|
d->buildV8ModelFromList( d->m_profilerDataModel->getV8Events() );
|
2011-09-27 14:38:22 +02:00
|
|
|
else
|
2012-02-24 10:47:17 +01:00
|
|
|
d->buildModelFromList( d->m_profilerDataModel->getEventDescriptions(), d->m_model->invisibleRootItem() );
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2012-02-03 17:28:29 +01:00
|
|
|
setShowExtendedStatistics(d->m_showExtendedStatistics);
|
|
|
|
|
|
2011-12-05 16:32:05 +01:00
|
|
|
setRootIsDecorated(false);
|
2011-07-18 14:24:33 +02:00
|
|
|
setSortingEnabled(true);
|
2011-12-05 16:32:05 +01:00
|
|
|
sortByColumn(d->m_firstNumericColumn,Qt::DescendingOrder);
|
2011-06-29 15:05:45 +02:00
|
|
|
|
|
|
|
|
expandAll();
|
|
|
|
|
if (d->m_fieldShown[Name])
|
|
|
|
|
resizeColumnToContents(0);
|
|
|
|
|
|
|
|
|
|
if (d->m_fieldShown[Type])
|
|
|
|
|
resizeColumnToContents(d->m_fieldShown[Name]?1:0);
|
|
|
|
|
collapseAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
void QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::buildModelFromList( const QList<QmlRangeEventData *> &list, QStandardItem *parentItem)
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
foreach (QmlRangeEventData *binding, list) {
|
2011-11-08 16:54:23 +01:00
|
|
|
if (binding->calls == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
QList<QStandardItem *> newRow;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_fieldShown[Name])
|
2012-02-24 10:47:17 +01:00
|
|
|
newRow << new EventsViewItem(binding->displayName);
|
2011-06-29 15:05:45 +02:00
|
|
|
|
|
|
|
|
if (m_fieldShown[Type]) {
|
2012-05-02 17:53:50 +02:00
|
|
|
QString typeString = QmlProfilerEventsMainView::nameForType(binding->eventType);
|
|
|
|
|
QString toolTipText;
|
2012-05-31 12:00:49 +02:00
|
|
|
if (binding->eventType == Binding) {
|
|
|
|
|
if (binding->bindingType == (int)OptimizedBinding) {
|
|
|
|
|
typeString = typeString + tr(" (Opt)");
|
|
|
|
|
toolTipText = tr("Binding is evaluated by the optimized engine.");
|
|
|
|
|
} else if (binding->bindingType == (int)V8Binding) {
|
2012-10-01 10:13:04 +02:00
|
|
|
toolTipText = tr("Binding not optimized (e.g. has side effects or assignments,\n"
|
2012-05-31 12:00:49 +02:00
|
|
|
"references to elements in other files, loops, etc.)");
|
|
|
|
|
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_fieldShown[Percent]) {
|
|
|
|
|
newRow << new EventsViewItem(QString::number(binding->percentOfTime,'f',2)+QLatin1String(" %"));
|
2011-07-18 14:03:09 +02:00
|
|
|
newRow.last()->setData(QVariant(binding->percentOfTime));
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_fieldShown[TotalDuration]) {
|
2011-12-05 16:32:05 +01:00
|
|
|
newRow << new EventsViewItem(displayTime(binding->duration));
|
|
|
|
|
newRow.last()->setData(QVariant(binding->duration));
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_fieldShown[CallCount]) {
|
|
|
|
|
newRow << new EventsViewItem(QString::number(binding->calls));
|
|
|
|
|
newRow.last()->setData(QVariant(binding->calls));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_fieldShown[TimePerCall]) {
|
|
|
|
|
newRow << new EventsViewItem(displayTime(binding->timePerCall));
|
|
|
|
|
newRow.last()->setData(QVariant(binding->timePerCall));
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-24 16:30:31 +02:00
|
|
|
if (m_fieldShown[MedianTime]) {
|
|
|
|
|
newRow << new EventsViewItem(displayTime(binding->medianTime));
|
|
|
|
|
newRow.last()->setData(QVariant(binding->medianTime));
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
if (m_fieldShown[MaxTime]) {
|
|
|
|
|
newRow << new EventsViewItem(displayTime(binding->maxTime));
|
|
|
|
|
newRow.last()->setData(QVariant(binding->maxTime));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_fieldShown[MinTime]) {
|
|
|
|
|
newRow << new EventsViewItem(displayTime(binding->minTime));
|
|
|
|
|
newRow.last()->setData(QVariant(binding->minTime));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_fieldShown[Details]) {
|
2011-07-26 13:56:14 +02:00
|
|
|
newRow << new EventsViewItem(binding->details);
|
|
|
|
|
newRow.last()->setData(QVariant(binding->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
|
2011-12-05 16:32:05 +01:00
|
|
|
newRow.at(0)->setData(QVariant(binding->eventHashStr),EventHashStrRole);
|
2012-01-12 16:36:40 +01:00
|
|
|
newRow.at(0)->setData(QVariant(binding->location.filename),FilenameRole);
|
|
|
|
|
newRow.at(0)->setData(QVariant(binding->location.line),LineRole);
|
|
|
|
|
newRow.at(0)->setData(QVariant(binding->location.column),ColumnRole);
|
2011-11-04 17:33:09 +01:00
|
|
|
newRow.at(0)->setData(QVariant(binding->eventId),EventIdRole);
|
2012-02-06 16:08:56 +01:00
|
|
|
if (binding->isBindingLoop)
|
|
|
|
|
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
|
|
|
}
|
2011-06-29 15:05:45 +02:00
|
|
|
|
|
|
|
|
// append
|
|
|
|
|
parentItem->appendRow(newRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
void QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::buildV8ModelFromList(const QList<QV8EventData *> &list)
|
2011-09-27 14:38:22 +02:00
|
|
|
{
|
2011-11-04 17:33:09 +01:00
|
|
|
for (int index = 0; index < list.count(); index++) {
|
|
|
|
|
QV8EventData *v8event = list.at(index);
|
2011-09-27 14:38:22 +02:00
|
|
|
QList<QStandardItem *> newRow;
|
|
|
|
|
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_fieldShown[Name])
|
2011-09-27 14:38:22 +02:00
|
|
|
newRow << new EventsViewItem(v8event->displayName);
|
|
|
|
|
|
|
|
|
|
if (m_fieldShown[Percent]) {
|
|
|
|
|
newRow << new EventsViewItem(QString::number(v8event->totalPercent,'f',2)+QLatin1String(" %"));
|
|
|
|
|
newRow.last()->setData(QVariant(v8event->totalPercent));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_fieldShown[TotalDuration]) {
|
|
|
|
|
newRow << new EventsViewItem(displayTime(v8event->totalTime));
|
|
|
|
|
newRow.last()->setData(QVariant(v8event->totalTime));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_fieldShown[SelfPercent]) {
|
|
|
|
|
newRow << new EventsViewItem(QString::number(v8event->selfPercent,'f',2)+QLatin1String(" %"));
|
|
|
|
|
newRow.last()->setData(QVariant(v8event->selfPercent));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_fieldShown[SelfDuration]) {
|
|
|
|
|
newRow << new EventsViewItem(displayTime(v8event->selfTime));
|
|
|
|
|
newRow.last()->setData(QVariant(v8event->selfTime));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_fieldShown[Details]) {
|
|
|
|
|
newRow << new EventsViewItem(v8event->functionName);
|
|
|
|
|
newRow.last()->setData(QVariant(v8event->functionName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!newRow.isEmpty()) {
|
|
|
|
|
// no edit
|
|
|
|
|
foreach (QStandardItem *item, newRow)
|
|
|
|
|
item->setEditable(false);
|
|
|
|
|
|
|
|
|
|
// metadata
|
2012-11-26 21:18:13 +02:00
|
|
|
newRow.at(0)->setData(QString::fromLatin1("%1:%2").arg(v8event->filename, QString::number(v8event->line)), EventHashStrRole);
|
2011-12-05 16:32:05 +01:00
|
|
|
newRow.at(0)->setData(QVariant(v8event->filename), FilenameRole);
|
|
|
|
|
newRow.at(0)->setData(QVariant(v8event->line), LineRole);
|
2012-01-12 16:36:40 +01:00
|
|
|
newRow.at(0)->setData(QVariant(0),ColumnRole); // v8 events have no column info
|
2011-12-05 16:32:05 +01:00
|
|
|
newRow.at(0)->setData(QVariant(v8event->eventId), EventIdRole);
|
2011-09-27 14:38:22 +02:00
|
|
|
|
|
|
|
|
// append
|
|
|
|
|
m_model->invisibleRootItem()->appendRow(newRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-05 16:32:05 +01:00
|
|
|
QString QmlProfilerEventsMainView::displayTime(double time)
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
if (time < 1e6)
|
2012-01-13 14:44:03 +01:00
|
|
|
return QString::number(time/1e3,'f',3) + trUtf8(" \xc2\xb5s");
|
2011-06-29 15:05:45 +02:00
|
|
|
if (time < 1e9)
|
2011-12-05 16:32:05 +01:00
|
|
|
return QString::number(time/1e6,'f',3) + tr(" ms");
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2011-12-05 16:32:05 +01:00
|
|
|
return QString::number(time/1e9,'f',3) + tr(" s");
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
QString QmlProfilerEventsMainView::nameForType(int typeNumber)
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
switch (typeNumber) {
|
2011-11-04 17:33:09 +01:00
|
|
|
case 0: return QmlProfilerEventsMainView::tr("Paint");
|
|
|
|
|
case 1: return QmlProfilerEventsMainView::tr("Compile");
|
|
|
|
|
case 2: return QmlProfilerEventsMainView::tr("Create");
|
|
|
|
|
case 3: return QmlProfilerEventsMainView::tr("Binding");
|
|
|
|
|
case 4: return QmlProfilerEventsMainView::tr("Signal");
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-08 16:54:23 +01:00
|
|
|
void QmlProfilerEventsMainView::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd)
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
if (d->m_profilerDataModel)
|
|
|
|
|
d->m_profilerDataModel->compileStatistics(rangeStart, rangeEnd);
|
2011-11-08 16:54:23 +01:00
|
|
|
buildModel();
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-10 11:19:22 +01:00
|
|
|
bool QmlProfilerEventsMainView::isRangeGlobal(qint64 rangeStart, qint64 rangeEnd) const
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
if (d->m_profilerDataModel)
|
|
|
|
|
return d->m_profilerDataModel->traceStartTime() == rangeStart && d->m_profilerDataModel->traceEndTime() == rangeEnd;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
2011-11-10 11:19:22 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-09 12:57:41 +01:00
|
|
|
int QmlProfilerEventsMainView::selectedEventId() const
|
|
|
|
|
{
|
|
|
|
|
QModelIndex index = selectedItem();
|
|
|
|
|
if (!index.isValid())
|
|
|
|
|
return -1;
|
|
|
|
|
QStandardItem *item = d->m_model->item(index.row(), 0);
|
|
|
|
|
return item->data(EventIdRole).toInt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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
|
2011-11-04 17:33:09 +01:00
|
|
|
emit eventSelected(infoItem->data(EventIdRole).toInt());
|
2011-11-09 12:57:41 +01:00
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
// show in timelinerenderer
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (d->m_viewType == EventsView)
|
2011-11-09 12:57:41 +01:00
|
|
|
emit showEventInTimeline(infoItem->data(EventIdRole).toInt());
|
2012-01-23 17:40:32 +01:00
|
|
|
|
|
|
|
|
d->m_preventSelectBounce = false;
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
void QmlProfilerEventsMainView::selectEvent(int eventId)
|
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);
|
|
|
|
|
if (infoItem->data(EventIdRole).toInt() == eventId) {
|
|
|
|
|
setCurrentIndex(d->m_model->indexFromItem(infoItem));
|
|
|
|
|
jumpToItem(currentIndex());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-26 13:56:14 +02:00
|
|
|
}
|
|
|
|
|
|
2011-12-14 14:30:37 +01:00
|
|
|
void QmlProfilerEventsMainView::selectEventByLocation(const QString &filename, int line)
|
|
|
|
|
{
|
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);
|
|
|
|
|
if (currentIndex() != d->m_model->indexFromItem(infoItem) && infoItem->data(FilenameRole).toString() == filename && infoItem->data(LineRole).toInt() == line) {
|
|
|
|
|
setCurrentIndex(d->m_model->indexFromItem(infoItem));
|
|
|
|
|
jumpToItem(currentIndex());
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-17 13:26:57 +01:00
|
|
|
void QmlProfilerEventsMainView::changeDetailsForEvent(int eventId, const QString &newString)
|
|
|
|
|
{
|
|
|
|
|
// available only for QML
|
|
|
|
|
if (d->m_viewType != EventsView)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<d->m_model->rowCount(); i++) {
|
|
|
|
|
QStandardItem *infoItem = d->m_model->item(i, 0);
|
|
|
|
|
if (infoItem->data(EventIdRole).toInt() == eventId) {
|
2012-02-03 17:28:29 +01:00
|
|
|
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));
|
2012-01-17 13:26:57 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
QString QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::textForItem(QStandardItem *item, bool recursive = true) 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
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
QmlProfilerEventsParentsAndChildrenView::QmlProfilerEventsParentsAndChildrenView(
|
|
|
|
|
SubViewType subtableType, QWidget *parent, QmlProfilerDataModel *model)
|
|
|
|
|
: QTreeView(parent)
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
m_profilerDataModel = model;
|
2011-11-04 17:33:09 +01:00
|
|
|
setModel(new QStandardItemModel(this));
|
|
|
|
|
setRootIsDecorated(false);
|
|
|
|
|
setFrameStyle(QFrame::NoFrame);
|
|
|
|
|
m_subtableType = subtableType;
|
|
|
|
|
updateHeader();
|
|
|
|
|
|
|
|
|
|
connect(this,SIGNAL(clicked(QModelIndex)), this,SLOT(jumpToItem(QModelIndex)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProfilerEventsParentsAndChildrenView::~QmlProfilerEventsParentsAndChildrenView()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerEventsParentsAndChildrenView::setViewType(SubViewType type)
|
|
|
|
|
{
|
|
|
|
|
m_subtableType = type;
|
|
|
|
|
updateHeader();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerEventsParentsAndChildrenView::displayEvent(int eventId)
|
|
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
if (!m_profilerDataModel)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
bool isV8 = m_subtableType == V8ParentsView || m_subtableType == V8ChildrenView;
|
|
|
|
|
bool isChildren = m_subtableType == ChildrenView || m_subtableType == V8ChildrenView;
|
|
|
|
|
|
|
|
|
|
if (isV8) {
|
2012-02-24 10:47:17 +01:00
|
|
|
QV8EventData *v8event = m_profilerDataModel->v8EventDescription(eventId);
|
2011-11-04 17:33:09 +01:00
|
|
|
if (v8event) {
|
2011-12-05 16:32:05 +01:00
|
|
|
if (isChildren) {
|
2012-02-24 10:47:17 +01:00
|
|
|
QList <QV8EventSub *> childrenList = v8event->childrenHash.values();
|
2011-12-05 16:32:05 +01:00
|
|
|
rebuildTree((QObject *)&childrenList);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-02-24 10:47:17 +01:00
|
|
|
QList <QV8EventSub *> parentList = v8event->parentHash.values();
|
2011-12-05 16:32:05 +01:00
|
|
|
rebuildTree((QObject *)&parentList);
|
|
|
|
|
}
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
2012-02-24 10:47:17 +01:00
|
|
|
QmlRangeEventData *qmlEvent = m_profilerDataModel->eventDescription(eventId);
|
2011-11-04 17:33:09 +01:00
|
|
|
if (qmlEvent) {
|
2011-12-05 16:32:05 +01:00
|
|
|
if (isChildren) {
|
2012-02-24 10:47:17 +01:00
|
|
|
QList <QmlRangeEventRelative *> childrenList = qmlEvent->childrenHash.values();
|
2011-12-05 16:32:05 +01:00
|
|
|
rebuildTree((QObject *)&childrenList);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-02-24 10:47:17 +01:00
|
|
|
QList <QmlRangeEventRelative *> parentList = qmlEvent->parentHash.values();
|
2011-12-05 16:32:05 +01:00
|
|
|
rebuildTree((QObject *)&parentList);
|
|
|
|
|
}
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateHeader();
|
|
|
|
|
resizeColumnToContents(0);
|
2011-11-10 11:19:22 +01:00
|
|
|
setSortingEnabled(true);
|
2011-12-05 16:32:05 +01:00
|
|
|
if (isV8)
|
|
|
|
|
sortByColumn(1);
|
|
|
|
|
else
|
|
|
|
|
sortByColumn(2);
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
void QmlProfilerEventsParentsAndChildrenView::rebuildTree(void *profilerDataModel)
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(treeModel());
|
|
|
|
|
treeModel()->clear();
|
|
|
|
|
|
|
|
|
|
QStandardItem *topLevelItem = treeModel()->invisibleRootItem();
|
|
|
|
|
bool isV8 = m_subtableType == V8ParentsView || m_subtableType == V8ChildrenView;
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
QList <QmlRangeEventRelative *> *qmlList = static_cast< QList <QmlRangeEventRelative *> *>(profilerDataModel);
|
|
|
|
|
QList <QV8EventSub*> *v8List = static_cast< QList <QV8EventSub *> *>(profilerDataModel);
|
2011-11-04 17:33:09 +01:00
|
|
|
|
|
|
|
|
int listLength;
|
|
|
|
|
if (!isV8)
|
|
|
|
|
listLength = qmlList->length();
|
|
|
|
|
else
|
|
|
|
|
listLength = v8List->length();
|
|
|
|
|
|
|
|
|
|
for (int index=0; index < listLength; index++) {
|
|
|
|
|
QList<QStandardItem *> newRow;
|
|
|
|
|
if (!isV8) {
|
2012-02-24 10:47:17 +01:00
|
|
|
QmlRangeEventRelative *event = qmlList->at(index);
|
2011-12-05 16:32:05 +01:00
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
newRow << new EventsViewItem(event->reference->displayName);
|
2011-12-05 16:32:05 +01:00
|
|
|
newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event->reference->eventType));
|
|
|
|
|
newRow << new EventsViewItem(QmlProfilerEventsMainView::displayTime(event->duration));
|
|
|
|
|
newRow << new EventsViewItem(QString::number(event->calls));
|
|
|
|
|
newRow << new EventsViewItem(event->reference->details);
|
|
|
|
|
newRow.at(0)->setData(QVariant(event->reference->eventId), EventIdRole);
|
|
|
|
|
newRow.at(2)->setData(QVariant(event->duration));
|
|
|
|
|
newRow.at(3)->setData(QVariant(event->calls));
|
2012-02-06 16:08:56 +01:00
|
|
|
if (event->inLoopPath)
|
|
|
|
|
foreach (QStandardItem *item, newRow) {
|
|
|
|
|
item->setBackground(colors()->bindingLoopBackground);
|
2012-10-01 10:13:04 +02:00
|
|
|
item->setToolTip(tr("Part of binding loop."));
|
2012-02-06 16:08:56 +01:00
|
|
|
}
|
2011-11-04 17:33:09 +01:00
|
|
|
} else {
|
2011-12-05 16:32:05 +01:00
|
|
|
QV8EventSub *event = v8List->at(index);
|
|
|
|
|
newRow << new EventsViewItem(event->reference->displayName);
|
|
|
|
|
newRow << new EventsViewItem(QmlProfilerEventsMainView::displayTime(event->totalTime));
|
|
|
|
|
newRow << new EventsViewItem(event->reference->functionName);
|
|
|
|
|
newRow.at(0)->setData(QVariant(event->reference->eventId), EventIdRole);
|
|
|
|
|
newRow.at(1)->setData(QVariant(event->totalTime));
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
foreach (QStandardItem *item, newRow)
|
|
|
|
|
item->setEditable(false);
|
|
|
|
|
|
|
|
|
|
topLevelItem->appendRow(newRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerEventsParentsAndChildrenView::clear()
|
|
|
|
|
{
|
|
|
|
|
if (treeModel()) {
|
|
|
|
|
treeModel()->clear();
|
|
|
|
|
updateHeader();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerEventsParentsAndChildrenView::updateHeader()
|
|
|
|
|
{
|
|
|
|
|
bool isV8 = m_subtableType == V8ParentsView || m_subtableType == V8ChildrenView;
|
|
|
|
|
bool isChildren = m_subtableType == ChildrenView || m_subtableType == V8ChildrenView;
|
|
|
|
|
|
|
|
|
|
header()->setResizeMode(QHeaderView::Interactive);
|
|
|
|
|
header()->setDefaultSectionSize(100);
|
|
|
|
|
header()->setMinimumSectionSize(50);
|
|
|
|
|
|
|
|
|
|
if (treeModel()) {
|
|
|
|
|
if (isV8)
|
|
|
|
|
treeModel()->setColumnCount(3);
|
2011-12-05 16:32:05 +01:00
|
|
|
else
|
|
|
|
|
treeModel()->setColumnCount(5);
|
2011-11-04 17:33:09 +01:00
|
|
|
|
|
|
|
|
int columnIndex = 0;
|
|
|
|
|
if (isChildren)
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(tr("Callee")));
|
|
|
|
|
else
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(tr("Caller")));
|
|
|
|
|
|
|
|
|
|
if (!isV8)
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(tr("Type")));
|
|
|
|
|
|
2011-12-05 16:32:05 +01:00
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(tr("Total Time")));
|
|
|
|
|
|
|
|
|
|
if (!isV8)
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(tr("Calls")));
|
|
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
if (isChildren)
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(tr("Callee Description")));
|
|
|
|
|
else
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(tr("Caller Description")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStandardItemModel *QmlProfilerEventsParentsAndChildrenView::treeModel()
|
|
|
|
|
{
|
|
|
|
|
return qobject_cast<QStandardItemModel *>(model());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerEventsParentsAndChildrenView::jumpToItem(const QModelIndex &index)
|
|
|
|
|
{
|
|
|
|
|
if (treeModel()) {
|
|
|
|
|
QStandardItem *infoItem = treeModel()->item(index.row(), 0);
|
|
|
|
|
emit eventClicked(infoItem->data(EventIdRole).toInt());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProfiler
|