2011-03-11 12:22:57 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-03-25 09:25:17 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2011-03-11 12:22:57 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2011-03-11 12:22:57 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-07-06 15:48:52 +00:00
|
|
|
** 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-03-11 12:22:57 +01:00
|
|
|
**
|
2011-03-25 09:25:17 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-07-06 15:48:52 +00:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2011-03-25 09:25:17 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-07-06 15:48:52 +00:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2011-03-25 09:25:17 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2011-03-11 12:22:57 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
2011-03-25 09:25:17 +01:00
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
#include "tracewindow.h"
|
|
|
|
|
|
2011-05-20 13:36:16 +02:00
|
|
|
#include "qmlprofilerplugin.h"
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-08-18 16:10:33 +02:00
|
|
|
#include <qmljsdebugclient/qmlprofilereventlist.h>
|
2011-08-05 11:12:27 +02:00
|
|
|
#include <qmljsdebugclient/qmlprofilertraceclient.h>
|
2011-06-28 15:51:20 +02:00
|
|
|
#include <utils/styledbar.h>
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-06-28 15:51:20 +02:00
|
|
|
#include <QtDeclarative/QDeclarativeView>
|
|
|
|
|
#include <QtDeclarative/QDeclarativeContext>
|
|
|
|
|
#include <QtGui/QVBoxLayout>
|
|
|
|
|
#include <QtGui/QGraphicsObject>
|
2011-07-26 13:56:14 +02:00
|
|
|
#include <QtGui/QContextMenuEvent>
|
2011-10-11 17:52:39 +02:00
|
|
|
#include <QtGui/QScrollBar>
|
2011-10-20 17:38:24 +02:00
|
|
|
#include <QtGui/QSlider>
|
2011-10-11 17:52:39 +02:00
|
|
|
#include <QtGui/QWidget>
|
2011-04-14 15:49:12 +02:00
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
#include <math.h>
|
|
|
|
|
|
2011-08-05 11:12:27 +02:00
|
|
|
using namespace QmlJsDebugClient;
|
|
|
|
|
|
2011-03-25 09:21:00 +01:00
|
|
|
namespace QmlProfiler {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
const int sliderTicks = 10000;
|
|
|
|
|
const qreal sliderExp = 3;
|
|
|
|
|
|
|
|
|
|
void ZoomControl::setRange(qint64 startTime, qint64 endTime)
|
|
|
|
|
{
|
|
|
|
|
if (m_startTime != startTime || m_endTime != endTime) {
|
|
|
|
|
m_startTime = startTime;
|
|
|
|
|
m_endTime = endTime;
|
|
|
|
|
emit rangeChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-16 16:08:05 +01:00
|
|
|
ScrollableDeclarativeView::ScrollableDeclarativeView(QWidget *parent)
|
|
|
|
|
: QDeclarativeView(parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScrollableDeclarativeView::~ScrollableDeclarativeView()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScrollableDeclarativeView::scrollContentsBy(int dx, int dy)
|
|
|
|
|
{
|
|
|
|
|
// special workaround to track the scrollbar
|
|
|
|
|
if (rootObject()) {
|
|
|
|
|
int scrollY = rootObject()->property("scrollY").toInt();
|
|
|
|
|
rootObject()->setProperty("scrollY", QVariant(scrollY - dy));
|
|
|
|
|
}
|
|
|
|
|
QDeclarativeView::scrollContentsBy(dx,dy);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
TraceWindow::TraceWindow(QWidget *parent)
|
2011-05-20 13:36:16 +02:00
|
|
|
: QWidget(parent)
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
2011-06-28 15:51:20 +02:00
|
|
|
setObjectName("QML Profiler");
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
m_zoomControl = new ZoomControl(this);
|
|
|
|
|
connect(m_zoomControl.data(), SIGNAL(rangeChanged()), this, SLOT(updateRange()));
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
QVBoxLayout *groupLayout = new QVBoxLayout;
|
|
|
|
|
groupLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
groupLayout->setSpacing(0);
|
|
|
|
|
|
2011-11-16 16:08:05 +01:00
|
|
|
m_mainView = new ScrollableDeclarativeView(this);
|
2011-10-11 17:52:39 +02:00
|
|
|
m_mainView->setResizeMode(QDeclarativeView::SizeViewToRootObject);
|
|
|
|
|
m_mainView->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
|
|
|
|
m_mainView->setBackgroundBrush(QBrush(Qt::white));
|
|
|
|
|
m_mainView->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
|
|
|
|
m_mainView->setFocus();
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
MouseWheelResizer *resizer = new MouseWheelResizer(this);
|
|
|
|
|
connect(resizer,SIGNAL(mouseWheelMoved(int,int,int)), this, SLOT(mouseWheelMoved(int,int,int)));
|
|
|
|
|
m_mainView->viewport()->installEventFilter(resizer);
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
QHBoxLayout *toolsLayout = new QHBoxLayout;
|
|
|
|
|
|
|
|
|
|
m_timebar = new QDeclarativeView(this);
|
|
|
|
|
m_timebar->setResizeMode(QDeclarativeView::SizeRootObjectToView);
|
|
|
|
|
m_timebar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
2011-10-19 14:28:21 +02:00
|
|
|
m_timebar->setFixedHeight(24);
|
2011-10-11 17:52:39 +02:00
|
|
|
|
|
|
|
|
m_overview = new QDeclarativeView(this);
|
|
|
|
|
m_overview->setResizeMode(QDeclarativeView::SizeRootObjectToView);
|
|
|
|
|
m_overview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
m_overview->setMaximumHeight(50);
|
|
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
m_zoomToolbar = createZoomToolbar();
|
|
|
|
|
m_zoomToolbar->move(0, m_timebar->height());
|
|
|
|
|
m_zoomToolbar->setVisible(false);
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
toolsLayout->addWidget(createToolbar());
|
|
|
|
|
toolsLayout->addWidget(m_timebar);
|
|
|
|
|
|
|
|
|
|
groupLayout->addLayout(toolsLayout);
|
|
|
|
|
groupLayout->addWidget(m_mainView);
|
|
|
|
|
groupLayout->addWidget(m_overview);
|
|
|
|
|
|
|
|
|
|
setLayout(groupLayout);
|
|
|
|
|
|
|
|
|
|
m_eventList = new QmlProfilerEventList(this);
|
2012-01-12 16:36:40 +01:00
|
|
|
connect(this,SIGNAL(range(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)), m_eventList, SLOT(addRangedEvent(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)));
|
2011-10-11 17:52:39 +02:00
|
|
|
connect(this, SIGNAL(traceFinished(qint64)), m_eventList, SLOT(setTraceEndTime(qint64)));
|
2011-11-02 16:57:31 +01:00
|
|
|
connect(this, SIGNAL(traceStarted(qint64)), m_eventList, SLOT(setTraceStartTime(qint64)));
|
2011-12-14 16:44:33 +01:00
|
|
|
connect(this, SIGNAL(frameEvent(qint64,int,int)), m_eventList, SLOT(addFrameEvent(qint64,int,int)));
|
2011-10-11 17:52:39 +02:00
|
|
|
connect(this,SIGNAL(viewUpdated()), m_eventList, SLOT(complete()));
|
|
|
|
|
m_mainView->rootContext()->setContextProperty("qmlEventList", m_eventList);
|
|
|
|
|
m_overview->rootContext()->setContextProperty("qmlEventList", m_eventList);
|
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(v8range(int,QString,QString,int,double,double)), m_eventList, SLOT(addV8Event(int,QString,QString,int,double,double)));
|
|
|
|
|
|
|
|
|
|
// Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin
|
|
|
|
|
setMinimumHeight(170);
|
2011-10-20 17:38:24 +02:00
|
|
|
m_currentZoomLevel = 0;
|
2011-11-28 16:30:30 +01:00
|
|
|
m_profiledTime = 0;
|
2011-10-11 17:52:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TraceWindow::~TraceWindow()
|
|
|
|
|
{
|
2011-11-28 16:30:30 +01:00
|
|
|
disconnectClientSignals();
|
2011-10-11 17:52:39 +02:00
|
|
|
delete m_plugin.data();
|
|
|
|
|
delete m_v8plugin.data();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *TraceWindow::createToolbar()
|
|
|
|
|
{
|
2011-06-24 18:19:08 +02:00
|
|
|
Utils::StyledBar *bar = new Utils::StyledBar(this);
|
|
|
|
|
bar->setSingleRow(true);
|
2011-10-19 14:28:21 +02:00
|
|
|
bar->setFixedWidth(150);
|
|
|
|
|
bar->setFixedHeight(24);
|
|
|
|
|
|
2011-06-24 18:19:08 +02:00
|
|
|
QHBoxLayout *toolBarLayout = new QHBoxLayout(bar);
|
|
|
|
|
toolBarLayout->setMargin(0);
|
|
|
|
|
toolBarLayout->setSpacing(0);
|
2011-10-20 17:38:24 +02:00
|
|
|
|
2011-06-24 18:19:08 +02:00
|
|
|
QToolButton *buttonPrev= new QToolButton;
|
2011-11-16 16:08:05 +01:00
|
|
|
buttonPrev->setIcon(QIcon(":/qmlprofiler/ico_prev.png"));
|
2011-07-05 16:40:26 +02:00
|
|
|
buttonPrev->setToolTip(tr("Jump to previous event"));
|
2011-06-24 18:19:08 +02:00
|
|
|
connect(buttonPrev, SIGNAL(clicked()), this, SIGNAL(jumpToPrev()));
|
2011-07-05 15:50:32 +02:00
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), buttonPrev, SLOT(setEnabled(bool)));
|
2011-10-20 17:38:24 +02:00
|
|
|
|
2011-06-24 18:19:08 +02:00
|
|
|
QToolButton *buttonNext= new QToolButton;
|
2011-11-16 16:08:05 +01:00
|
|
|
buttonNext->setIcon(QIcon(":/qmlprofiler/ico_next.png"));
|
2011-07-05 16:40:26 +02:00
|
|
|
buttonNext->setToolTip(tr("Jump to next event"));
|
2011-06-24 18:19:08 +02:00
|
|
|
connect(buttonNext, SIGNAL(clicked()), this, SIGNAL(jumpToNext()));
|
2011-07-05 15:50:32 +02:00
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), buttonNext, SLOT(setEnabled(bool)));
|
2011-10-20 17:38:24 +02:00
|
|
|
|
|
|
|
|
QToolButton *buttonZoomControls = new QToolButton;
|
2011-11-16 16:08:05 +01:00
|
|
|
buttonZoomControls->setIcon(QIcon(":/qmlprofiler/ico_zoom.png"));
|
2011-10-20 17:38:24 +02:00
|
|
|
buttonZoomControls->setToolTip(tr("Show zoom slider"));
|
|
|
|
|
buttonZoomControls->setCheckable(true);
|
|
|
|
|
buttonZoomControls->setChecked(false);
|
|
|
|
|
connect(buttonZoomControls, SIGNAL(toggled(bool)), m_zoomToolbar, SLOT(setVisible(bool)));
|
|
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), buttonZoomControls, SLOT(setEnabled(bool)));
|
|
|
|
|
|
2011-10-19 14:28:21 +02:00
|
|
|
m_buttonRange = new QToolButton;
|
2011-11-16 16:08:05 +01:00
|
|
|
m_buttonRange->setIcon(QIcon(":/qmlprofiler/ico_rangeselection.png"));
|
2011-10-19 14:28:21 +02:00
|
|
|
m_buttonRange->setToolTip(tr("Select range"));
|
|
|
|
|
m_buttonRange->setCheckable(true);
|
|
|
|
|
m_buttonRange->setChecked(false);
|
|
|
|
|
connect(m_buttonRange, SIGNAL(clicked(bool)), this, SLOT(toggleRangeMode(bool)));
|
|
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), m_buttonRange, SLOT(setEnabled(bool)));
|
|
|
|
|
connect(this, SIGNAL(rangeModeChanged(bool)), m_buttonRange, SLOT(setChecked(bool)));
|
2011-07-05 15:50:32 +02:00
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
m_buttonLock = new QToolButton;
|
2011-11-16 16:08:05 +01:00
|
|
|
m_buttonLock->setIcon(QIcon(":/qmlprofiler/ico_selectionmode.png"));
|
2011-10-26 11:32:01 +02:00
|
|
|
m_buttonLock->setToolTip(tr("View event information on mouseover"));
|
|
|
|
|
m_buttonLock->setCheckable(true);
|
|
|
|
|
m_buttonLock->setChecked(false);
|
|
|
|
|
connect(m_buttonLock, SIGNAL(clicked(bool)), this, SLOT(toggleLockMode(bool)));
|
|
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), m_buttonLock, SLOT(setEnabled(bool)));
|
|
|
|
|
connect(this, SIGNAL(lockModeChanged(bool)), m_buttonLock, SLOT(setChecked(bool)));
|
|
|
|
|
|
2011-06-24 18:19:08 +02:00
|
|
|
toolBarLayout->addWidget(buttonPrev);
|
|
|
|
|
toolBarLayout->addWidget(buttonNext);
|
2011-11-16 16:08:05 +01:00
|
|
|
toolBarLayout->addWidget(new Utils::StyledSeparator());
|
2011-10-20 17:38:24 +02:00
|
|
|
toolBarLayout->addWidget(buttonZoomControls);
|
2011-11-16 16:08:05 +01:00
|
|
|
toolBarLayout->addWidget(new Utils::StyledSeparator());
|
2011-10-19 14:28:21 +02:00
|
|
|
toolBarLayout->addWidget(m_buttonRange);
|
2011-11-16 16:08:05 +01:00
|
|
|
toolBarLayout->addWidget(m_buttonLock);
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
return bar;
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
|
|
|
|
|
QWidget *TraceWindow::createZoomToolbar()
|
|
|
|
|
{
|
|
|
|
|
Utils::StyledBar *bar = new Utils::StyledBar(this);
|
|
|
|
|
bar->setSingleRow(true);
|
|
|
|
|
bar->setFixedWidth(150);
|
|
|
|
|
bar->setFixedHeight(24);
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *toolBarLayout = new QHBoxLayout(bar);
|
|
|
|
|
toolBarLayout->setMargin(0);
|
|
|
|
|
toolBarLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
QSlider *zoomSlider = new QSlider(Qt::Horizontal);
|
|
|
|
|
zoomSlider->setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
zoomSlider->setRange(1, sliderTicks);
|
|
|
|
|
zoomSlider->setInvertedAppearance(true);
|
|
|
|
|
zoomSlider->setPageStep(sliderTicks/100);
|
|
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), zoomSlider, SLOT(setEnabled(bool)));
|
|
|
|
|
connect(zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setZoomLevel(int)));
|
|
|
|
|
connect(this, SIGNAL(zoomLevelChanged(int)), zoomSlider, SLOT(setValue(int)));
|
|
|
|
|
zoomSlider->setStyleSheet("\
|
|
|
|
|
QSlider:horizontal {\
|
|
|
|
|
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #444444, stop: 1 #5a5a5a);\
|
|
|
|
|
border: 1px #313131;\
|
|
|
|
|
height: 20px;\
|
|
|
|
|
margin: 0px 0px 0px 0px;\
|
|
|
|
|
}\
|
|
|
|
|
QSlider::add-page:horizontal {\
|
|
|
|
|
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5a5a5a, stop: 1 #444444);\
|
|
|
|
|
border: 1px #313131;\
|
|
|
|
|
}\
|
|
|
|
|
QSlider::sub-page:horizontal {\
|
|
|
|
|
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5a5a5a, stop: 1 #444444);\
|
|
|
|
|
border: 1px #313131;\
|
|
|
|
|
}\
|
|
|
|
|
");
|
|
|
|
|
|
|
|
|
|
toolBarLayout->addWidget(zoomSlider);
|
|
|
|
|
|
|
|
|
|
return bar;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-05 11:12:27 +02:00
|
|
|
void TraceWindow::reset(QDeclarativeDebugConnection *conn)
|
2011-03-11 12:22:57 +01:00
|
|
|
{
|
2011-11-28 16:30:30 +01:00
|
|
|
disconnectClientSignals();
|
|
|
|
|
|
2011-04-14 17:18:32 +02:00
|
|
|
delete m_plugin.data();
|
2011-06-28 15:51:20 +02:00
|
|
|
m_plugin = new QmlProfilerTraceClient(conn);
|
2011-09-27 14:38:22 +02:00
|
|
|
delete m_v8plugin.data();
|
|
|
|
|
m_v8plugin = new QV8ProfilerClient(conn);
|
2011-11-28 16:30:30 +01:00
|
|
|
|
|
|
|
|
connectClientSignals();
|
2011-09-27 14:38:22 +02:00
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
m_mainView->rootContext()->setContextProperty("connection", m_plugin.data());
|
|
|
|
|
m_mainView->rootContext()->setContextProperty("zoomControl", m_zoomControl.data());
|
|
|
|
|
m_timebar->rootContext()->setContextProperty("zoomControl", m_zoomControl.data());
|
|
|
|
|
m_overview->rootContext()->setContextProperty("zoomControl", m_zoomControl.data());
|
|
|
|
|
|
|
|
|
|
m_timebar->setSource(QUrl("qrc:/qmlprofiler/TimeDisplay.qml"));
|
|
|
|
|
m_overview->setSource(QUrl("qrc:/qmlprofiler/Overview.qml"));
|
|
|
|
|
|
|
|
|
|
m_mainView->setSource(QUrl("qrc:/qmlprofiler/MainView.qml"));
|
|
|
|
|
m_mainView->rootObject()->setProperty("width", QVariant(width()));
|
|
|
|
|
m_mainView->rootObject()->setProperty("candidateHeight", QVariant(height() - m_timebar->height() - m_overview->height()));
|
2011-03-11 12:22:57 +01:00
|
|
|
|
2011-07-05 15:50:32 +02:00
|
|
|
updateToolbar();
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
connect(m_mainView->rootObject(), SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition()));
|
|
|
|
|
connect(m_mainView->rootObject(), SIGNAL(updateTimer()), this, SLOT(updateTimer()));
|
2011-10-19 14:28:21 +02:00
|
|
|
connect(m_mainView->rootObject(), SIGNAL(updateRangeButton()), this, SLOT(updateRangeButton()));
|
2011-10-26 11:32:01 +02:00
|
|
|
connect(m_mainView->rootObject(), SIGNAL(updateLockButton()), this, SLOT(updateLockButton()));
|
2011-07-26 13:56:14 +02:00
|
|
|
connect(m_eventList, SIGNAL(countChanged()), this, SLOT(updateToolbar()));
|
2011-10-11 17:52:39 +02:00
|
|
|
connect(this, SIGNAL(jumpToPrev()), m_mainView->rootObject(), SLOT(prevEvent()));
|
|
|
|
|
connect(this, SIGNAL(jumpToNext()), m_mainView->rootObject(), SLOT(nextEvent()));
|
2011-10-20 17:38:24 +02:00
|
|
|
connect(this, SIGNAL(updateViewZoom(QVariant)), m_mainView->rootObject(), SLOT(updateWindowLength(QVariant)));
|
|
|
|
|
connect(this, SIGNAL(wheelZoom(QVariant,QVariant)), m_mainView->rootObject(), SLOT(wheelZoom(QVariant,QVariant)));
|
|
|
|
|
connect(this, SIGNAL(globalZoom()), m_mainView->rootObject(), SLOT(globalZoom()));
|
2011-11-09 12:57:41 +01:00
|
|
|
connect(this, SIGNAL(selectNextEventInDisplay(QVariant)), m_mainView->rootObject(), SLOT(selectNextWithId(QVariant)));
|
|
|
|
|
connect(m_mainView->rootObject(), SIGNAL(selectedEventIdChanged(int)), this, SIGNAL(selectedEventIdChanged(int)));
|
2012-01-11 14:46:05 +01:00
|
|
|
connect(m_mainView->rootObject(), SIGNAL(changeToolTip(QString)), this, SLOT(updateToolTip(QString)));
|
2011-06-24 18:19:08 +02:00
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
connect(this, SIGNAL(internalClearDisplay()), m_mainView->rootObject(), SLOT(clearAll()));
|
|
|
|
|
connect(this,SIGNAL(internalClearDisplay()), m_overview->rootObject(), SLOT(clearDisplay()));
|
2011-09-27 14:38:22 +02:00
|
|
|
|
|
|
|
|
m_v8DataReady = false;
|
|
|
|
|
m_qmlDataReady = false;
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-28 16:30:30 +01:00
|
|
|
void TraceWindow::connectClientSignals()
|
|
|
|
|
{
|
|
|
|
|
if (m_plugin) {
|
|
|
|
|
connect(m_plugin.data(), SIGNAL(complete()), this, SLOT(qmlComplete()));
|
2012-01-12 16:36:40 +01:00
|
|
|
connect(m_plugin.data(), SIGNAL(range(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)),
|
|
|
|
|
this, SIGNAL(range(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)));
|
2011-11-28 16:30:30 +01:00
|
|
|
connect(m_plugin.data(), SIGNAL(traceFinished(qint64)), this, SIGNAL(traceFinished(qint64)));
|
|
|
|
|
connect(m_plugin.data(), SIGNAL(traceStarted(qint64)), this, SIGNAL(traceStarted(qint64)));
|
2011-12-14 16:44:33 +01:00
|
|
|
connect(m_plugin.data(), SIGNAL(frame(qint64,int,int)), this, SIGNAL(frameEvent(qint64,int,int)));
|
2011-11-28 16:30:30 +01:00
|
|
|
connect(m_plugin.data(), SIGNAL(enabledChanged()), this, SLOT(updateProfilerState()));
|
2011-11-15 15:04:25 +01:00
|
|
|
connect(m_plugin.data(), SIGNAL(enabledChanged()), m_plugin.data(), SLOT(sendRecordingStatus()));
|
2011-11-28 16:30:30 +01:00
|
|
|
}
|
|
|
|
|
if (m_v8plugin) {
|
|
|
|
|
connect(m_v8plugin.data(), SIGNAL(complete()), this, SLOT(v8Complete()));
|
|
|
|
|
connect(m_v8plugin.data(), SIGNAL(v8range(int,QString,QString,int,double,double)), this, SIGNAL(v8range(int,QString,QString,int,double,double)));
|
|
|
|
|
connect(m_v8plugin.data(), SIGNAL(enabledChanged()), this, SLOT(updateProfilerState()));
|
2011-11-15 15:04:25 +01:00
|
|
|
connect(m_v8plugin.data(), SIGNAL(enabledChanged()), m_v8plugin.data(), SLOT(sendRecordingStatus()));
|
2011-11-28 16:30:30 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWindow::disconnectClientSignals()
|
|
|
|
|
{
|
|
|
|
|
if (m_plugin) {
|
|
|
|
|
disconnect(m_plugin.data(), SIGNAL(complete()), this, SLOT(qmlComplete()));
|
2012-01-12 16:36:40 +01:00
|
|
|
disconnect(m_plugin.data(), SIGNAL(range(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)),
|
|
|
|
|
this, SIGNAL(range(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)));
|
2011-11-28 16:30:30 +01:00
|
|
|
disconnect(m_plugin.data(), SIGNAL(traceFinished(qint64)), this, SIGNAL(traceFinished(qint64)));
|
|
|
|
|
disconnect(m_plugin.data(), SIGNAL(traceStarted(qint64)), this, SIGNAL(traceStarted(qint64)));
|
|
|
|
|
disconnect(m_plugin.data(), SIGNAL(enabledChanged()), this, SLOT(updateProfilerState()));
|
2011-11-15 15:04:25 +01:00
|
|
|
disconnect(m_plugin.data(), SIGNAL(enabledChanged()), m_plugin.data(), SLOT(sendRecordingStatus()));
|
2011-11-28 16:30:30 +01:00
|
|
|
}
|
|
|
|
|
if (m_v8plugin) {
|
|
|
|
|
disconnect(m_v8plugin.data(), SIGNAL(complete()), this, SLOT(v8Complete()));
|
|
|
|
|
disconnect(m_v8plugin.data(), SIGNAL(v8range(int,QString,QString,int,double,double)), this, SIGNAL(v8range(int,QString,QString,int,double,double)));
|
|
|
|
|
disconnect(m_v8plugin.data(), SIGNAL(enabledChanged()), this, SLOT(updateProfilerState()));
|
2011-11-15 15:04:25 +01:00
|
|
|
disconnect(m_v8plugin.data(), SIGNAL(enabledChanged()), m_v8plugin.data(), SLOT(sendRecordingStatus()));
|
2011-11-28 16:30:30 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-26 13:56:14 +02:00
|
|
|
QmlProfilerEventList *TraceWindow::getEventList() const
|
|
|
|
|
{
|
|
|
|
|
return m_eventList;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-08 16:54:23 +01:00
|
|
|
ZoomControl *TraceWindow::rangeTimes() const
|
|
|
|
|
{
|
|
|
|
|
return m_zoomControl.data();
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-26 13:56:14 +02:00
|
|
|
void TraceWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
emit contextMenuRequested(ev->globalPos());
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
void TraceWindow::updateCursorPosition()
|
|
|
|
|
{
|
2011-10-11 17:52:39 +02:00
|
|
|
emit gotoSourceLocation(m_mainView->rootObject()->property("fileName").toString(),
|
2012-01-12 16:36:40 +01:00
|
|
|
m_mainView->rootObject()->property("lineNumber").toInt(),
|
|
|
|
|
m_mainView->rootObject()->property("columnNumber").toInt());
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-24 12:42:15 +01:00
|
|
|
void TraceWindow::updateTimer()
|
|
|
|
|
{
|
2011-11-28 16:30:30 +01:00
|
|
|
m_profiledTime = m_mainView->rootObject()->property("elapsedTime").toDouble();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double TraceWindow::profiledTime() const
|
|
|
|
|
{
|
|
|
|
|
return m_profiledTime;
|
2011-03-24 12:42:15 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-06 16:04:18 +02:00
|
|
|
void TraceWindow::clearDisplay()
|
|
|
|
|
{
|
2011-07-26 13:56:14 +02:00
|
|
|
m_eventList->clear();
|
|
|
|
|
|
2011-04-06 16:04:18 +02:00
|
|
|
if (m_plugin)
|
2011-08-05 12:58:43 +02:00
|
|
|
m_plugin.data()->clearData();
|
2011-09-27 14:38:22 +02:00
|
|
|
if (m_v8plugin)
|
|
|
|
|
m_v8plugin.data()->clearData();
|
2011-07-26 13:56:14 +02:00
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
m_zoomControl.data()->setRange(0,0);
|
2011-11-28 16:30:30 +01:00
|
|
|
m_profiledTime = 0;
|
2011-10-11 17:52:39 +02:00
|
|
|
|
2011-07-26 13:56:14 +02:00
|
|
|
emit internalClearDisplay();
|
2011-04-06 16:04:18 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-05 15:50:32 +02:00
|
|
|
void TraceWindow::updateToolbar()
|
|
|
|
|
{
|
2011-07-26 13:56:14 +02:00
|
|
|
emit enableToolbar(m_eventList && m_eventList->count()>0);
|
2011-07-05 15:50:32 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-19 14:28:21 +02:00
|
|
|
void TraceWindow::toggleRangeMode(bool active)
|
|
|
|
|
{
|
|
|
|
|
bool rangeMode = m_mainView->rootObject()->property("selectionRangeMode").toBool();
|
|
|
|
|
if (active != rangeMode) {
|
|
|
|
|
if (active)
|
2011-11-16 16:08:05 +01:00
|
|
|
m_buttonRange->setIcon(QIcon(":/qmlprofiler/ico_rangeselected.png"));
|
2011-10-19 14:28:21 +02:00
|
|
|
else
|
2011-11-16 16:08:05 +01:00
|
|
|
m_buttonRange->setIcon(QIcon(":/qmlprofiler/ico_rangeselection.png"));
|
2011-10-19 14:28:21 +02:00
|
|
|
m_mainView->rootObject()->setProperty("selectionRangeMode", QVariant(active));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWindow::updateRangeButton()
|
|
|
|
|
{
|
|
|
|
|
bool rangeMode = m_mainView->rootObject()->property("selectionRangeMode").toBool();
|
|
|
|
|
if (rangeMode)
|
2011-11-16 16:08:05 +01:00
|
|
|
m_buttonRange->setIcon(QIcon(":/qmlprofiler/ico_rangeselected.png"));
|
2011-10-19 14:28:21 +02:00
|
|
|
else
|
2011-11-16 16:08:05 +01:00
|
|
|
m_buttonRange->setIcon(QIcon(":/qmlprofiler/ico_rangeselection.png"));
|
2011-10-19 14:28:21 +02:00
|
|
|
emit rangeModeChanged(rangeMode);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-26 11:32:01 +02:00
|
|
|
void TraceWindow::toggleLockMode(bool active)
|
|
|
|
|
{
|
|
|
|
|
bool lockMode = !m_mainView->rootObject()->property("selectionLocked").toBool();
|
|
|
|
|
if (active != lockMode) {
|
|
|
|
|
m_mainView->rootObject()->setProperty("selectionLocked", QVariant(!active));
|
|
|
|
|
m_mainView->rootObject()->setProperty("selectedItem", QVariant(-1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWindow::updateLockButton()
|
|
|
|
|
{
|
|
|
|
|
bool lockMode = !m_mainView->rootObject()->property("selectionLocked").toBool();
|
|
|
|
|
emit lockModeChanged(lockMode);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 12:22:57 +01:00
|
|
|
void TraceWindow::setRecording(bool recording)
|
|
|
|
|
{
|
2011-09-27 14:38:22 +02:00
|
|
|
if (recording) {
|
|
|
|
|
m_v8DataReady = false;
|
|
|
|
|
m_qmlDataReady = false;
|
|
|
|
|
}
|
2011-04-15 14:51:49 +02:00
|
|
|
if (m_plugin)
|
|
|
|
|
m_plugin.data()->setRecording(recording);
|
2011-09-27 14:38:22 +02:00
|
|
|
if (m_v8plugin)
|
|
|
|
|
m_v8plugin.data()->setRecording(recording);
|
2011-03-11 12:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-06 12:26:19 +02:00
|
|
|
bool TraceWindow::isRecording() const
|
|
|
|
|
{
|
2011-05-20 13:36:16 +02:00
|
|
|
return m_plugin.data()->isRecording();
|
2011-04-06 12:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-27 14:38:22 +02:00
|
|
|
void TraceWindow::qmlComplete()
|
|
|
|
|
{
|
|
|
|
|
m_qmlDataReady = true;
|
|
|
|
|
|
|
|
|
|
if (!m_v8plugin || m_v8plugin.data()->status() != QDeclarativeDebugClient::Enabled || m_v8DataReady)
|
|
|
|
|
emit viewUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWindow::v8Complete()
|
|
|
|
|
{
|
|
|
|
|
m_v8DataReady = true;
|
|
|
|
|
if (!m_plugin || m_plugin.data()->status() != QDeclarativeDebugClient::Enabled || m_qmlDataReady)
|
|
|
|
|
emit viewUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-11 17:52:39 +02:00
|
|
|
void TraceWindow::resizeEvent(QResizeEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (m_mainView->rootObject()) {
|
|
|
|
|
m_mainView->rootObject()->setProperty("width", QVariant(event->size().width()));
|
|
|
|
|
int newHeight = event->size().height() - m_timebar->height() - m_overview->height();
|
|
|
|
|
m_mainView->rootObject()->setProperty("candidateHeight", QVariant(newHeight));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
bool MouseWheelResizer::eventFilter(QObject *obj, QEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (event->type() == QEvent::Wheel) {
|
|
|
|
|
QWheelEvent *ev = static_cast<QWheelEvent *>(event);
|
|
|
|
|
if (ev->modifiers() & Qt::ControlModifier) {
|
|
|
|
|
emit mouseWheelMoved(ev->pos().x(), ev->pos().y(), ev->delta());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QObject::eventFilter(obj, event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWindow::mouseWheelMoved(int x, int y, int delta)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(y);
|
|
|
|
|
if (m_mainView->rootObject()) {
|
|
|
|
|
emit wheelZoom(QVariant(x), QVariant(delta));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWindow::viewAll()
|
|
|
|
|
{
|
|
|
|
|
emit globalZoom();
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-08 16:54:23 +01:00
|
|
|
bool TraceWindow::hasValidSelection() const
|
|
|
|
|
{
|
|
|
|
|
if (m_mainView->rootObject()) {
|
|
|
|
|
return m_mainView->rootObject()->property("selectionRangeReady").toBool();
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 TraceWindow::selectionStart() const
|
|
|
|
|
{
|
|
|
|
|
if (m_mainView->rootObject()) {
|
|
|
|
|
return m_mainView->rootObject()->property("selectionRangeStart").toLongLong();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 TraceWindow::selectionEnd() const
|
|
|
|
|
{
|
|
|
|
|
if (m_mainView->rootObject()) {
|
|
|
|
|
return m_mainView->rootObject()->property("selectionRangeEnd").toLongLong();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-20 17:38:24 +02:00
|
|
|
void TraceWindow::setZoomLevel(int zoomLevel)
|
|
|
|
|
{
|
|
|
|
|
if (m_currentZoomLevel != zoomLevel && m_mainView->rootObject()) {
|
|
|
|
|
qreal newFactor = pow(qreal(zoomLevel) / qreal(sliderTicks), sliderExp);
|
|
|
|
|
m_currentZoomLevel = zoomLevel;
|
|
|
|
|
emit updateViewZoom(QVariant(newFactor));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TraceWindow::updateRange()
|
|
|
|
|
{
|
|
|
|
|
if (!m_eventList)
|
|
|
|
|
return;
|
|
|
|
|
qreal duration = m_zoomControl.data()->endTime() - m_zoomControl.data()->startTime();
|
|
|
|
|
if (duration <= 0)
|
|
|
|
|
return;
|
2011-11-02 16:57:31 +01:00
|
|
|
if (m_eventList->traceDuration() <= 0)
|
2011-10-20 17:38:24 +02:00
|
|
|
return;
|
2011-11-02 16:57:31 +01:00
|
|
|
int newLevel = pow(duration / m_eventList->traceDuration(), 1/sliderExp) * sliderTicks;
|
2011-10-20 17:38:24 +02:00
|
|
|
if (m_currentZoomLevel != newLevel) {
|
|
|
|
|
m_currentZoomLevel = newLevel;
|
|
|
|
|
emit zoomLevelChanged(newLevel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-09 12:57:41 +01:00
|
|
|
void TraceWindow::selectNextEvent(int eventId)
|
|
|
|
|
{
|
|
|
|
|
emit selectNextEventInDisplay(QVariant(eventId));
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-28 16:30:30 +01:00
|
|
|
void TraceWindow::updateProfilerState()
|
|
|
|
|
{
|
|
|
|
|
bool qmlActive = false;
|
|
|
|
|
bool v8Active = false;
|
|
|
|
|
if (m_plugin)
|
|
|
|
|
qmlActive = m_plugin.data()->isEnabled();
|
|
|
|
|
if (m_v8plugin)
|
|
|
|
|
v8Active = m_v8plugin.data()->isEnabled();
|
|
|
|
|
|
|
|
|
|
emit profilerStateChanged(qmlActive, v8Active);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 12:25:53 +01:00
|
|
|
void TraceWindow::updateToolTip(const QString &text)
|
2012-01-11 14:46:05 +01:00
|
|
|
{
|
|
|
|
|
setToolTip(text);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-20 13:36:16 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProfiler
|