2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-02-24 10:47:17 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-02-24 10:47:17 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2012-02-24 10:47:17 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
#include "qmlprofilerviewmanager.h"
|
|
|
|
|
|
|
|
|
|
#include "qmlprofilertool.h"
|
|
|
|
|
#include "qmlprofilerstatemanager.h"
|
2013-08-08 13:28:08 +02:00
|
|
|
#include "qmlprofilermodelmanager.h"
|
2012-05-16 12:16:45 +02:00
|
|
|
#include "qmlprofilerstatewidget.h"
|
2012-02-24 10:47:17 +01:00
|
|
|
|
2015-12-04 16:54:58 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2012-02-24 10:47:17 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2016-02-24 14:42:52 +01:00
|
|
|
#include <debugger/analyzer/analyzermanager.h>
|
2015-12-04 16:54:58 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
#include <QDockWidget>
|
|
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
using namespace Debugger;
|
|
|
|
|
using namespace Utils;
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
namespace QmlProfiler {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class QmlProfilerViewManager::QmlProfilerViewManagerPrivate {
|
|
|
|
|
public:
|
|
|
|
|
QmlProfilerTraceView *traceView;
|
2016-12-14 13:50:20 +01:00
|
|
|
QmlProfilerStatisticsView *statisticsView;
|
|
|
|
|
FlameGraphView *flameGraphView;
|
2012-02-24 10:47:17 +01:00
|
|
|
QmlProfilerStateManager *profilerState;
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerModelManager *profilerModelManager;
|
2012-02-24 10:47:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
2013-08-08 13:28:08 +02:00
|
|
|
QmlProfilerModelManager *modelManager,
|
2012-02-24 10:47:17 +01:00
|
|
|
QmlProfilerStateManager *profilerState)
|
2016-12-14 13:43:07 +01:00
|
|
|
: QObject(parent), d(new QmlProfilerViewManagerPrivate)
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2012-11-26 21:18:13 +02:00
|
|
|
setObjectName(QLatin1String("QML Profiler View Manager"));
|
2016-12-14 13:50:20 +01:00
|
|
|
d->traceView = nullptr;
|
|
|
|
|
d->statisticsView = nullptr;
|
|
|
|
|
d->flameGraphView = nullptr;
|
2012-02-24 10:47:17 +01:00
|
|
|
d->profilerState = profilerState;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->profilerModelManager = modelManager;
|
2012-02-24 10:47:17 +01:00
|
|
|
createViews();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProfilerViewManager::~QmlProfilerViewManager()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerViewManager::createViews()
|
|
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
QTC_ASSERT(d->profilerModelManager, return);
|
2012-02-24 10:47:17 +01:00
|
|
|
QTC_ASSERT(d->profilerState, return);
|
|
|
|
|
|
2016-02-26 14:14:49 +01:00
|
|
|
d->traceView = new QmlProfilerTraceView(0, this, d->profilerModelManager);
|
2015-10-30 12:35:17 +01:00
|
|
|
connect(d->traceView, &QmlProfilerTraceView::gotoSourceLocation,
|
|
|
|
|
this, &QmlProfilerViewManager::gotoSourceLocation);
|
|
|
|
|
connect(d->traceView, &QmlProfilerTraceView::typeSelected,
|
2015-12-04 16:54:58 +01:00
|
|
|
this, &QmlProfilerViewManager::typeSelected);
|
|
|
|
|
connect(this, &QmlProfilerViewManager::typeSelected,
|
|
|
|
|
d->traceView, &QmlProfilerTraceView::selectByTypeId);
|
2016-02-26 14:14:49 +01:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->traceView);
|
2015-12-04 16:54:58 +01:00
|
|
|
|
2016-05-12 11:57:29 +02:00
|
|
|
auto perspective = new Utils::Perspective;
|
|
|
|
|
perspective->setName(tr("QML Profiler"));
|
2016-02-26 14:14:49 +01:00
|
|
|
|
2016-12-14 13:50:20 +01:00
|
|
|
auto prepareEventsView = [this](QmlProfilerEventsView *view) {
|
2015-12-04 16:54:58 +01:00
|
|
|
connect(view, &QmlProfilerEventsView::typeSelected,
|
|
|
|
|
this, &QmlProfilerViewManager::typeSelected);
|
|
|
|
|
connect(this, &QmlProfilerViewManager::typeSelected,
|
|
|
|
|
view, &QmlProfilerEventsView::selectByTypeId);
|
|
|
|
|
connect(d->profilerModelManager, &QmlProfilerModelManager::visibleFeaturesChanged,
|
|
|
|
|
view, &QmlProfilerEventsView::onVisibleFeaturesChanged);
|
|
|
|
|
connect(view, &QmlProfilerEventsView::gotoSourceLocation,
|
|
|
|
|
this, &QmlProfilerViewManager::gotoSourceLocation);
|
|
|
|
|
connect(view, &QmlProfilerEventsView::showFullRange,
|
2016-12-20 13:00:18 +01:00
|
|
|
this, [this](){ d->profilerModelManager->restrictToRange(-1, -1);});
|
2015-12-04 16:54:58 +01:00
|
|
|
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, view);
|
2016-12-14 13:50:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
d->statisticsView = new QmlProfilerStatisticsView(d->profilerModelManager);
|
|
|
|
|
prepareEventsView(d->statisticsView);
|
|
|
|
|
d->flameGraphView = new FlameGraphView(d->profilerModelManager);
|
|
|
|
|
prepareEventsView(d->flameGraphView);
|
|
|
|
|
|
2016-12-14 13:54:25 +01:00
|
|
|
QByteArray anchorDockId;
|
|
|
|
|
if (d->traceView->isUsable()) {
|
|
|
|
|
anchorDockId = d->traceView->objectName().toLatin1();
|
|
|
|
|
perspective->addOperation({anchorDockId, d->traceView, {}, Perspective::SplitVertical});
|
|
|
|
|
perspective->addOperation({d->flameGraphView->objectName().toLatin1(), d->flameGraphView,
|
|
|
|
|
anchorDockId, Perspective::AddToTab});
|
|
|
|
|
} else {
|
|
|
|
|
anchorDockId = d->flameGraphView->objectName().toLatin1();
|
|
|
|
|
perspective->addOperation({anchorDockId, d->flameGraphView, {},
|
|
|
|
|
Perspective::SplitVertical});
|
|
|
|
|
}
|
2016-12-14 13:50:20 +01:00
|
|
|
perspective->addOperation({d->statisticsView->objectName().toLatin1(), d->statisticsView,
|
|
|
|
|
anchorDockId, Perspective::AddToTab});
|
|
|
|
|
perspective->addOperation({anchorDockId, 0, {}, Perspective::Raise});
|
|
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
Debugger::registerPerspective(Constants::QmlProfilerPerspectiveId, perspective);
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
2016-12-20 13:00:18 +01:00
|
|
|
QmlProfilerTraceView *QmlProfilerViewManager::traceView() const
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2016-12-20 13:00:18 +01:00
|
|
|
return d->traceView;
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
2016-12-20 13:00:18 +01:00
|
|
|
QmlProfilerStatisticsView *QmlProfilerViewManager::statisticsView() const
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2016-12-20 13:00:18 +01:00
|
|
|
return d->statisticsView;
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
2016-12-20 13:00:18 +01:00
|
|
|
FlameGraphView *QmlProfilerViewManager::flameGraphView() const
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2016-12-20 13:00:18 +01:00
|
|
|
return d->flameGraphView;
|
2015-05-08 14:30:30 +02:00
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
void QmlProfilerViewManager::clear()
|
|
|
|
|
{
|
2014-03-25 17:10:25 +01:00
|
|
|
d->traceView->clear();
|
2016-12-14 13:50:20 +01:00
|
|
|
d->flameGraphView->clear();
|
|
|
|
|
d->statisticsView->clear();
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProfiler
|