2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-02-24 10:47:17 +01: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
|
2012-02-24 10:47:17 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-02-24 10:47:17 +01: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.
|
2012-02-24 10:47:17 +01: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.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2012-02-24 10:47:17 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
#include "qmlprofilertraceview.h"
|
|
|
|
|
#include "qmlprofilertool.h"
|
|
|
|
|
#include "qmlprofilerstatemanager.h"
|
2013-08-08 13:28:08 +02:00
|
|
|
#include "qmlprofilermodelmanager.h"
|
|
|
|
|
#include "qmlprofilertimelinemodelproxy.h"
|
|
|
|
|
#include "timelinemodelaggregator.h"
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
// Needed for the load&save actions in the context menu
|
|
|
|
|
#include <analyzerbase/ianalyzertool.h>
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
// Communication with the other views (limit events to range)
|
2012-02-24 10:47:17 +01:00
|
|
|
#include "qmlprofilerviewmanager.h"
|
|
|
|
|
|
|
|
|
|
#include <utils/styledbar.h>
|
|
|
|
|
|
2013-09-16 14:33:07 +02:00
|
|
|
#include <QQmlContext>
|
2012-02-24 10:47:17 +01:00
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QEvent>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QGraphicsObject>
|
|
|
|
|
#include <QScrollBar>
|
|
|
|
|
#include <QSlider>
|
|
|
|
|
#include <QMenu>
|
2013-09-16 14:33:07 +02:00
|
|
|
#include <QQuickItem>
|
2014-02-21 18:34:05 +01:00
|
|
|
#include <QApplication>
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
2012-04-18 12:06:10 +02:00
|
|
|
using namespace QmlDebug;
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
namespace QmlProfiler {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
|
void ZoomControl::setRange(qint64 startTime, qint64 endTime)
|
|
|
|
|
{
|
|
|
|
|
if (m_startTime != startTime || m_endTime != endTime) {
|
|
|
|
|
m_startTime = startTime;
|
|
|
|
|
m_endTime = endTime;
|
|
|
|
|
emit rangeChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
|
class QmlProfilerTraceView::QmlProfilerTraceViewPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QmlProfilerTraceViewPrivate(QmlProfilerTraceView *qq) : q(qq) {}
|
2013-09-16 14:33:07 +02:00
|
|
|
~QmlProfilerTraceViewPrivate()
|
|
|
|
|
{
|
|
|
|
|
delete m_mainView;
|
|
|
|
|
delete m_timebar;
|
|
|
|
|
delete m_overview;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
QmlProfilerTraceView *q;
|
|
|
|
|
|
|
|
|
|
QmlProfilerStateManager *m_profilerState;
|
|
|
|
|
Analyzer::IAnalyzerTool *m_profilerTool;
|
|
|
|
|
QmlProfilerViewManager *m_viewContainer;
|
|
|
|
|
|
|
|
|
|
QSize m_sizeHint;
|
|
|
|
|
|
2013-09-03 14:06:31 +02:00
|
|
|
QQuickView *m_mainView;
|
2013-09-16 14:33:07 +02:00
|
|
|
QQuickView *m_timebar;
|
|
|
|
|
QQuickView *m_overview;
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerModelManager *m_modelManager;
|
|
|
|
|
TimelineModelAggregator *m_modelProxy;
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
ZoomControl *m_zoomControl;
|
|
|
|
|
|
|
|
|
|
QToolButton *m_buttonRange;
|
|
|
|
|
QToolButton *m_buttonLock;
|
|
|
|
|
};
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerTool *profilerTool, QmlProfilerViewManager *container, QmlProfilerModelManager *modelManager, QmlProfilerStateManager *profilerState)
|
2012-02-24 10:47:17 +01:00
|
|
|
: QWidget(parent), d(new QmlProfilerTraceViewPrivate(this))
|
|
|
|
|
{
|
2012-11-26 21:18:13 +02:00
|
|
|
setObjectName(QLatin1String("QML Profiler"));
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
d->m_zoomControl = new ZoomControl(this);
|
|
|
|
|
connect(d->m_zoomControl, SIGNAL(rangeChanged()), this, SLOT(updateRange()));
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *groupLayout = new QVBoxLayout;
|
|
|
|
|
groupLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
groupLayout->setSpacing(0);
|
|
|
|
|
|
2014-02-21 18:34:05 +01:00
|
|
|
d->m_mainView = new QmlProfilerQuickView(this);
|
2013-10-30 13:49:01 +01:00
|
|
|
d->m_mainView->setResizeMode(QQuickView::SizeRootObjectToView);
|
2013-09-16 14:33:07 +02:00
|
|
|
QWidget *mainViewContainer = QWidget::createWindowContainer(d->m_mainView);
|
2014-01-10 11:54:29 +01:00
|
|
|
mainViewContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
QHBoxLayout *toolsLayout = new QHBoxLayout;
|
|
|
|
|
|
2014-02-21 18:34:05 +01:00
|
|
|
d->m_timebar = new QmlProfilerQuickView(this);
|
2013-09-16 14:33:07 +02:00
|
|
|
d->m_timebar->setResizeMode(QQuickView::SizeRootObjectToView);
|
|
|
|
|
QWidget *timeBarContainer = QWidget::createWindowContainer(d->m_timebar);
|
|
|
|
|
timeBarContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
timeBarContainer->setFixedHeight(24);
|
2012-02-24 10:47:17 +01:00
|
|
|
|
2014-02-21 18:34:05 +01:00
|
|
|
d->m_overview = new QmlProfilerQuickView(this);
|
2013-09-16 14:33:07 +02:00
|
|
|
d->m_overview->setResizeMode(QQuickView::SizeRootObjectToView);
|
|
|
|
|
QWidget *overviewContainer = QWidget::createWindowContainer(d->m_overview);
|
|
|
|
|
overviewContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
2014-01-10 11:54:29 +01:00
|
|
|
overviewContainer->setFixedHeight(50);
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
toolsLayout->addWidget(createToolbar());
|
2013-09-16 14:33:07 +02:00
|
|
|
toolsLayout->addWidget(timeBarContainer);
|
2012-02-24 10:47:17 +01:00
|
|
|
emit enableToolbar(false);
|
|
|
|
|
|
|
|
|
|
groupLayout->addLayout(toolsLayout);
|
2013-09-16 14:33:07 +02:00
|
|
|
groupLayout->addWidget(mainViewContainer);
|
|
|
|
|
groupLayout->addWidget(overviewContainer);
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
setLayout(groupLayout);
|
|
|
|
|
|
|
|
|
|
d->m_profilerTool = profilerTool;
|
|
|
|
|
d->m_viewContainer = container;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_modelManager = modelManager;
|
|
|
|
|
d->m_modelProxy = new TimelineModelAggregator(this);
|
|
|
|
|
d->m_modelProxy->setModelManager(modelManager);
|
|
|
|
|
connect(d->m_modelManager, SIGNAL(stateChanged()),
|
2012-02-24 10:47:17 +01:00
|
|
|
this, SLOT(profilerDataModelStateChanged()));
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_mainView->rootContext()->setContextProperty(QLatin1String("qmlProfilerModelProxy"),
|
|
|
|
|
d->m_modelProxy);
|
|
|
|
|
d->m_overview->rootContext()->setContextProperty(QLatin1String("qmlProfilerModelProxy"),
|
|
|
|
|
d->m_modelProxy);
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
d->m_profilerState = profilerState;
|
|
|
|
|
|
|
|
|
|
// Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin
|
|
|
|
|
setMinimumHeight(170);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProfilerTraceView::~QmlProfilerTraceView()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
|
// Initialize widgets
|
|
|
|
|
void QmlProfilerTraceView::reset()
|
|
|
|
|
{
|
2012-11-26 21:18:13 +02:00
|
|
|
d->m_mainView->rootContext()->setContextProperty(QLatin1String("zoomControl"), d->m_zoomControl);
|
|
|
|
|
d->m_timebar->rootContext()->setContextProperty(QLatin1String("zoomControl"), d->m_zoomControl);
|
|
|
|
|
d->m_overview->rootContext()->setContextProperty(QLatin1String("zoomControl"), d->m_zoomControl);
|
2012-02-24 10:47:17 +01:00
|
|
|
|
2012-11-26 21:18:13 +02:00
|
|
|
d->m_timebar->setSource(QUrl(QLatin1String("qrc:/qmlprofiler/TimeDisplay.qml")));
|
|
|
|
|
d->m_overview->setSource(QUrl(QLatin1String("qrc:/qmlprofiler/Overview.qml")));
|
2012-02-24 10:47:17 +01:00
|
|
|
|
2012-11-26 21:18:13 +02:00
|
|
|
d->m_mainView->setSource(QUrl(QLatin1String("qrc:/qmlprofiler/MainView.qml")));
|
2012-12-30 12:01:41 +01:00
|
|
|
|
2013-10-30 13:49:01 +01:00
|
|
|
QQuickItem *rootObject = d->m_mainView->rootObject();
|
2012-12-30 12:01:41 +01:00
|
|
|
connect(rootObject, SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition()));
|
|
|
|
|
connect(rootObject, SIGNAL(updateRangeButton()), this, SLOT(updateRangeButton()));
|
|
|
|
|
connect(rootObject, SIGNAL(updateLockButton()), this, SLOT(updateLockButton()));
|
|
|
|
|
connect(this, SIGNAL(jumpToPrev()), rootObject, SLOT(prevEvent()));
|
|
|
|
|
connect(this, SIGNAL(jumpToNext()), rootObject, SLOT(nextEvent()));
|
|
|
|
|
connect(rootObject, SIGNAL(changeToolTip(QString)), this, SLOT(updateToolTip(QString)));
|
2013-11-28 14:42:03 +01:00
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), this, SLOT(setZoomSliderEnabled(bool)));
|
|
|
|
|
connect(this, SIGNAL(showZoomSlider(bool)), this, SLOT(setZoomSliderVisible(bool)));
|
|
|
|
|
}
|
2013-11-12 12:44:54 +01:00
|
|
|
|
2013-11-28 14:42:03 +01:00
|
|
|
void QmlProfilerTraceView::setZoomSliderEnabled(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
QQuickItem *zoomSlider = d->m_mainView->rootObject()->findChild<QQuickItem*>(QLatin1String("zoomSliderToolBar"));
|
|
|
|
|
if (zoomSlider->isEnabled() != enabled)
|
|
|
|
|
zoomSlider->setEnabled(enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerTraceView::setZoomSliderVisible(bool visible)
|
|
|
|
|
{
|
|
|
|
|
QQuickItem *zoomSlider = d->m_mainView->rootObject()->findChild<QQuickItem*>(QLatin1String("zoomSliderToolBar"));
|
|
|
|
|
if (zoomSlider->isVisible() != visible)
|
|
|
|
|
zoomSlider->setVisible(visible);
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *QmlProfilerTraceView::createToolbar()
|
|
|
|
|
{
|
|
|
|
|
Utils::StyledBar *bar = new Utils::StyledBar(this);
|
2012-04-12 15:40:47 +02:00
|
|
|
bar->setStyleSheet(QLatin1String("background: #9B9B9B"));
|
2012-02-24 10:47:17 +01:00
|
|
|
bar->setSingleRow(true);
|
|
|
|
|
bar->setFixedWidth(150);
|
|
|
|
|
bar->setFixedHeight(24);
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *toolBarLayout = new QHBoxLayout(bar);
|
|
|
|
|
toolBarLayout->setMargin(0);
|
|
|
|
|
toolBarLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
QToolButton *buttonPrev= new QToolButton;
|
2012-11-26 21:18:13 +02:00
|
|
|
buttonPrev->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_prev.png")));
|
2014-03-13 09:55:53 +01:00
|
|
|
buttonPrev->setToolTip(tr("Jump to previous event."));
|
2012-02-24 10:47:17 +01:00
|
|
|
connect(buttonPrev, SIGNAL(clicked()), this, SIGNAL(jumpToPrev()));
|
|
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), buttonPrev, SLOT(setEnabled(bool)));
|
|
|
|
|
|
|
|
|
|
QToolButton *buttonNext= new QToolButton;
|
2012-11-26 21:18:13 +02:00
|
|
|
buttonNext->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_next.png")));
|
2014-03-13 09:55:53 +01:00
|
|
|
buttonNext->setToolTip(tr("Jump to next event."));
|
2012-02-24 10:47:17 +01:00
|
|
|
connect(buttonNext, SIGNAL(clicked()), this, SIGNAL(jumpToNext()));
|
|
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), buttonNext, SLOT(setEnabled(bool)));
|
|
|
|
|
|
|
|
|
|
QToolButton *buttonZoomControls = new QToolButton;
|
2012-11-26 21:18:13 +02:00
|
|
|
buttonZoomControls->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_zoom.png")));
|
2014-03-13 09:55:53 +01:00
|
|
|
buttonZoomControls->setToolTip(tr("Show zoom slider."));
|
2012-02-24 10:47:17 +01:00
|
|
|
buttonZoomControls->setCheckable(true);
|
|
|
|
|
buttonZoomControls->setChecked(false);
|
2013-11-12 12:44:54 +01:00
|
|
|
connect(buttonZoomControls, SIGNAL(toggled(bool)), this, SIGNAL(showZoomSlider(bool)));
|
2012-02-24 10:47:17 +01:00
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), buttonZoomControls, SLOT(setEnabled(bool)));
|
|
|
|
|
|
|
|
|
|
d->m_buttonRange = new QToolButton;
|
2012-11-26 21:18:13 +02:00
|
|
|
d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselection.png")));
|
2014-03-13 09:55:53 +01:00
|
|
|
d->m_buttonRange->setToolTip(tr("Select range."));
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_buttonRange->setCheckable(true);
|
|
|
|
|
d->m_buttonRange->setChecked(false);
|
|
|
|
|
connect(d->m_buttonRange, SIGNAL(clicked(bool)), this, SLOT(toggleRangeMode(bool)));
|
|
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), d->m_buttonRange, SLOT(setEnabled(bool)));
|
|
|
|
|
connect(this, SIGNAL(rangeModeChanged(bool)), d->m_buttonRange, SLOT(setChecked(bool)));
|
|
|
|
|
|
|
|
|
|
d->m_buttonLock = new QToolButton;
|
2012-11-26 21:18:13 +02:00
|
|
|
d->m_buttonLock->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_selectionmode.png")));
|
2014-03-13 09:55:53 +01:00
|
|
|
d->m_buttonLock->setToolTip(tr("View event information on mouseover."));
|
2012-02-24 10:47:17 +01:00
|
|
|
d->m_buttonLock->setCheckable(true);
|
|
|
|
|
d->m_buttonLock->setChecked(false);
|
|
|
|
|
connect(d->m_buttonLock, SIGNAL(clicked(bool)), this, SLOT(toggleLockMode(bool)));
|
|
|
|
|
connect(this, SIGNAL(enableToolbar(bool)), d->m_buttonLock, SLOT(setEnabled(bool)));
|
|
|
|
|
connect(this, SIGNAL(lockModeChanged(bool)), d->m_buttonLock, SLOT(setChecked(bool)));
|
|
|
|
|
|
|
|
|
|
toolBarLayout->addWidget(buttonPrev);
|
|
|
|
|
toolBarLayout->addWidget(buttonNext);
|
|
|
|
|
toolBarLayout->addWidget(new Utils::StyledSeparator());
|
|
|
|
|
toolBarLayout->addWidget(buttonZoomControls);
|
|
|
|
|
toolBarLayout->addWidget(new Utils::StyledSeparator());
|
|
|
|
|
toolBarLayout->addWidget(d->m_buttonRange);
|
|
|
|
|
toolBarLayout->addWidget(d->m_buttonLock);
|
|
|
|
|
|
|
|
|
|
return bar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
|
bool QmlProfilerTraceView::hasValidSelection() const
|
|
|
|
|
{
|
2013-09-16 14:33:07 +02:00
|
|
|
QQuickItem *rootObject = d->m_mainView->rootObject();
|
2012-12-30 12:01:41 +01:00
|
|
|
if (rootObject)
|
|
|
|
|
return rootObject->property("selectionRangeReady").toBool();
|
2012-02-24 10:47:17 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 QmlProfilerTraceView::selectionStart() const
|
|
|
|
|
{
|
2013-09-16 14:33:07 +02:00
|
|
|
QQuickItem *rootObject = d->m_mainView->rootObject();
|
2012-12-30 12:01:41 +01:00
|
|
|
if (rootObject)
|
|
|
|
|
return rootObject->property("selectionRangeStart").toLongLong();
|
2012-02-24 10:47:17 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 QmlProfilerTraceView::selectionEnd() const
|
|
|
|
|
{
|
2013-09-16 14:33:07 +02:00
|
|
|
QQuickItem *rootObject = d->m_mainView->rootObject();
|
2012-12-30 12:01:41 +01:00
|
|
|
if (rootObject)
|
|
|
|
|
return rootObject->property("selectionRangeEnd").toLongLong();
|
2012-02-24 10:47:17 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-25 17:10:25 +01:00
|
|
|
void QmlProfilerTraceView::clear()
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2014-03-25 17:10:25 +01:00
|
|
|
QMetaObject::invokeMethod(d->m_mainView->rootObject(), "clear");
|
|
|
|
|
QMetaObject::invokeMethod(d->m_overview->rootObject(), "clear");
|
|
|
|
|
QMetaObject::invokeMethod(d->m_timebar->rootObject(), "clear");
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
void QmlProfilerTraceView::selectNextEventByHash(const QString &hash)
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2013-09-16 14:33:07 +02:00
|
|
|
QQuickItem *rootObject = d->m_mainView->rootObject();
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2012-12-30 12:01:41 +01:00
|
|
|
if (rootObject)
|
2013-08-08 13:28:08 +02:00
|
|
|
QMetaObject::invokeMethod(rootObject, "selectNextByHash",
|
|
|
|
|
Q_ARG(QVariant,QVariant(hash)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerTraceView::selectNextEventByLocation(const QString &filename, const int line, const int column)
|
|
|
|
|
{
|
|
|
|
|
int eventId = d->m_modelProxy->getEventIdForLocation(filename, line, column);
|
|
|
|
|
|
|
|
|
|
if (eventId != -1) {
|
2013-09-16 14:33:07 +02:00
|
|
|
QQuickItem *rootObject = d->m_mainView->rootObject();
|
2013-08-08 13:28:08 +02:00
|
|
|
if (rootObject)
|
|
|
|
|
QMetaObject::invokeMethod(rootObject, "selectNextById",
|
|
|
|
|
Q_ARG(QVariant,QVariant(eventId)));
|
|
|
|
|
}
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
|
// Goto source location
|
|
|
|
|
void QmlProfilerTraceView::updateCursorPosition()
|
|
|
|
|
{
|
2013-09-16 14:33:07 +02:00
|
|
|
QQuickItem *rootObject = d->m_mainView->rootObject();
|
2012-12-30 12:01:41 +01:00
|
|
|
emit gotoSourceLocation(rootObject->property("fileName").toString(),
|
|
|
|
|
rootObject->property("lineNumber").toInt(),
|
|
|
|
|
rootObject->property("columnNumber").toInt());
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
|
// Toolbar buttons
|
|
|
|
|
void QmlProfilerTraceView::toggleRangeMode(bool active)
|
|
|
|
|
{
|
2013-09-16 14:33:07 +02:00
|
|
|
QQuickItem *rootObject = d->m_mainView->rootObject();
|
2012-12-30 12:01:41 +01:00
|
|
|
bool rangeMode = rootObject->property("selectionRangeMode").toBool();
|
2012-02-24 10:47:17 +01:00
|
|
|
if (active != rangeMode) {
|
|
|
|
|
if (active)
|
2012-11-26 21:18:13 +02:00
|
|
|
d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselected.png")));
|
2012-02-24 10:47:17 +01:00
|
|
|
else
|
2012-11-26 21:18:13 +02:00
|
|
|
d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselection.png")));
|
2012-12-30 12:01:41 +01:00
|
|
|
rootObject->setProperty("selectionRangeMode", QVariant(active));
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerTraceView::updateRangeButton()
|
|
|
|
|
{
|
|
|
|
|
bool rangeMode = d->m_mainView->rootObject()->property("selectionRangeMode").toBool();
|
|
|
|
|
if (rangeMode)
|
2012-11-26 21:18:13 +02:00
|
|
|
d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselected.png")));
|
2012-02-24 10:47:17 +01:00
|
|
|
else
|
2012-11-26 21:18:13 +02:00
|
|
|
d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselection.png")));
|
2012-02-24 10:47:17 +01:00
|
|
|
emit rangeModeChanged(rangeMode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerTraceView::toggleLockMode(bool active)
|
|
|
|
|
{
|
2013-09-16 14:33:07 +02:00
|
|
|
QQuickItem *rootObject = d->m_mainView->rootObject();
|
2012-12-30 12:01:41 +01:00
|
|
|
bool lockMode = !rootObject->property("selectionLocked").toBool();
|
2012-02-24 10:47:17 +01:00
|
|
|
if (active != lockMode) {
|
2012-12-30 12:01:41 +01:00
|
|
|
rootObject->setProperty("selectionLocked", QVariant(!active));
|
|
|
|
|
rootObject->setProperty("selectedItem", QVariant(-1));
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerTraceView::updateLockButton()
|
|
|
|
|
{
|
|
|
|
|
bool lockMode = !d->m_mainView->rootObject()->property("selectionLocked").toBool();
|
|
|
|
|
emit lockModeChanged(lockMode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
// Zoom control
|
|
|
|
|
void QmlProfilerTraceView::updateRange()
|
|
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
if (!d->m_modelManager)
|
2012-02-24 10:47:17 +01:00
|
|
|
return;
|
|
|
|
|
qreal duration = d->m_zoomControl->endTime() - d->m_zoomControl->startTime();
|
|
|
|
|
if (duration <= 0)
|
|
|
|
|
return;
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_modelManager->traceTime()->duration() <= 0)
|
2012-02-24 10:47:17 +01:00
|
|
|
return;
|
2013-11-12 16:12:43 +01:00
|
|
|
QMetaObject::invokeMethod(d->m_mainView->rootObject()->findChild<QObject*>(QLatin1String("zoomSliderToolBar")), "updateZoomLevel");
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
void QmlProfilerTraceView::updateToolTip(const QString &text)
|
|
|
|
|
{
|
|
|
|
|
setToolTip(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerTraceView::resizeEvent(QResizeEvent *event)
|
|
|
|
|
{
|
2012-05-16 12:16:45 +02:00
|
|
|
QWidget::resizeEvent(event);
|
|
|
|
|
emit resized();
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
// Context menu
|
|
|
|
|
void QmlProfilerTraceView::contextMenuEvent(QContextMenuEvent *ev)
|
2014-02-21 18:34:05 +01:00
|
|
|
{
|
|
|
|
|
showContextMenu(ev->globalPos());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerTraceView::showContextMenu(QPoint position)
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
|
|
|
|
QMenu menu;
|
|
|
|
|
QAction *viewAllAction = 0;
|
|
|
|
|
|
|
|
|
|
QmlProfilerTool *profilerTool = qobject_cast<QmlProfilerTool *>(d->m_profilerTool);
|
|
|
|
|
|
2012-12-30 12:01:41 +01:00
|
|
|
if (profilerTool)
|
|
|
|
|
menu.addActions(profilerTool->profilerContextMenuActions());
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
menu.addSeparator();
|
2012-12-30 12:01:41 +01:00
|
|
|
|
|
|
|
|
QAction *getLocalStatsAction = menu.addAction(tr("Limit Events Pane to Current Range"));
|
2012-02-24 10:47:17 +01:00
|
|
|
if (!d->m_viewContainer->hasValidSelection())
|
|
|
|
|
getLocalStatsAction->setEnabled(false);
|
2012-12-30 12:01:41 +01:00
|
|
|
|
2014-03-06 16:12:02 +01:00
|
|
|
QAction *getGlobalStatsAction = menu.addAction(tr("Show Full Range in Events Pane"));
|
2012-02-24 10:47:17 +01:00
|
|
|
if (d->m_viewContainer->hasGlobalStats())
|
|
|
|
|
getGlobalStatsAction->setEnabled(false);
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (!d->m_modelProxy->isEmpty()) {
|
2012-02-24 10:47:17 +01:00
|
|
|
menu.addSeparator();
|
|
|
|
|
viewAllAction = menu.addAction(tr("Reset Zoom"));
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-21 18:34:05 +01:00
|
|
|
QAction *selectedAction = menu.exec(position);
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
if (selectedAction) {
|
|
|
|
|
if (selectedAction == viewAllAction) {
|
|
|
|
|
d->m_zoomControl->setRange(
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_modelManager->traceTime()->startTime(),
|
|
|
|
|
d->m_modelManager->traceTime()->endTime());
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
if (selectedAction == getLocalStatsAction) {
|
|
|
|
|
d->m_viewContainer->getStatisticsInRange(
|
|
|
|
|
d->m_viewContainer->selectionStart(),
|
|
|
|
|
d->m_viewContainer->selectionEnd());
|
|
|
|
|
}
|
2013-11-11 22:20:47 +02:00
|
|
|
if (selectedAction == getGlobalStatsAction)
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_viewContainer->getStatisticsInRange(-1, -1);
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
// Profiler State
|
|
|
|
|
void QmlProfilerTraceView::profilerDataModelStateChanged()
|
|
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
switch (d->m_modelManager->state()) {
|
2013-12-09 12:11:48 +01:00
|
|
|
case QmlProfilerDataState::Empty: break;
|
|
|
|
|
case QmlProfilerDataState::ClearingData:
|
2014-01-09 17:23:41 +01:00
|
|
|
d->m_mainView->hide();
|
2013-08-08 13:28:08 +02:00
|
|
|
emit enableToolbar(false);
|
2012-02-24 10:47:17 +01:00
|
|
|
break;
|
2013-08-08 13:28:08 +02:00
|
|
|
case QmlProfilerDataState::AcquiringData: break;
|
|
|
|
|
case QmlProfilerDataState::ProcessingData: break;
|
|
|
|
|
case QmlProfilerDataState::Done:
|
|
|
|
|
emit enableToolbar(true);
|
2014-01-09 17:23:41 +01:00
|
|
|
d->m_mainView->show();
|
2012-02-24 10:47:17 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-21 18:34:05 +01:00
|
|
|
bool QmlProfilerQuickView::event(QEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
// We assume context menus can only be triggered by mouse press, mouse release, or
|
|
|
|
|
// pre-synthesized events from the window system.
|
|
|
|
|
|
|
|
|
|
bool relayed = false;
|
|
|
|
|
switch (ev->type()) {
|
|
|
|
|
case QEvent::ContextMenu:
|
|
|
|
|
// In the case of mouse clicks the active popup gets automatically closed before they show
|
|
|
|
|
// up here. That's not necessarily the case with keyboard triggered context menu events, so
|
|
|
|
|
// we just ignore them if there is a popup already. Also, the event's pos() and globalPos()
|
|
|
|
|
// don't make much sense in this case, so we just put the menu in the upper left corner.
|
|
|
|
|
if (QApplication::activePopupWidget() == 0) {
|
|
|
|
|
ev->accept();
|
|
|
|
|
parent->showContextMenu(parent->mapToGlobal(QPoint(0,0)));
|
|
|
|
|
relayed = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case QEvent::MouseButtonPress:
|
|
|
|
|
case QEvent::MouseButtonRelease: {
|
|
|
|
|
QMouseEvent *orig = static_cast<QMouseEvent *>(ev);
|
|
|
|
|
QCoreApplication::instance()->postEvent(parent->window()->windowHandle(),
|
|
|
|
|
new QMouseEvent(orig->type(), parent->window()->mapFromGlobal(orig->globalPos()),
|
|
|
|
|
orig->button(), orig->buttons(), orig->modifiers()));
|
|
|
|
|
relayed = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// QQuickView will eat mouse events even if they're not accepted by any QML construct. So we
|
|
|
|
|
// ignore the return value of event() above.
|
|
|
|
|
return QQuickView::event(ev) || relayed;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProfiler
|