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 "qmlprofilertraceview.h"
|
2015-12-04 13:30:54 +01:00
|
|
|
#include "qmlprofilerstatisticsview.h"
|
2012-02-24 10:47:17 +01:00
|
|
|
#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"
|
2016-04-26 10:21:00 +02:00
|
|
|
#include "flamegraphview.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:
|
|
|
|
|
QmlProfilerViewManagerPrivate(QmlProfilerViewManager *qq) { Q_UNUSED(qq); }
|
|
|
|
|
|
|
|
|
|
QmlProfilerTraceView *traceView;
|
2015-12-04 16:54:58 +01:00
|
|
|
QList<QmlProfilerEventsView *> eventsViews;
|
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)
|
|
|
|
|
: QObject(parent), d(new QmlProfilerViewManagerPrivate(this))
|
|
|
|
|
{
|
2012-11-26 21:18:13 +02:00
|
|
|
setObjectName(QLatin1String("QML Profiler View Manager"));
|
2012-02-24 10:47:17 +01:00
|
|
|
d->traceView = 0;
|
|
|
|
|
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);
|
2014-07-23 16:07:39 +02:00
|
|
|
d->traceView->setWindowTitle(tr("Timeline"));
|
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"));
|
|
|
|
|
perspective->addOperation({Constants::QmlProfilerTimelineDockId, d->traceView, {},
|
|
|
|
|
Perspective::SplitVertical});
|
2016-02-26 14:14:49 +01:00
|
|
|
|
|
|
|
|
d->eventsViews << new QmlProfilerStatisticsView(0, d->profilerModelManager);
|
2016-04-26 10:21:00 +02:00
|
|
|
d->eventsViews << new FlameGraphView(0, d->profilerModelManager);
|
2015-12-04 16:54:58 +01:00
|
|
|
|
|
|
|
|
foreach (QmlProfilerEventsView *view, d->eventsViews) {
|
|
|
|
|
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,
|
|
|
|
|
this, [this](){restrictEventsToRange(-1, -1);});
|
2016-03-02 13:57:37 +01:00
|
|
|
QByteArray dockId = view->objectName().toLatin1();
|
2016-05-12 11:57:29 +02:00
|
|
|
perspective->addOperation({dockId, view, Constants::QmlProfilerTimelineDockId, Perspective::AddToTab});
|
2015-12-04 16:54:58 +01:00
|
|
|
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, view);
|
|
|
|
|
}
|
2016-05-12 11:57:29 +02:00
|
|
|
perspective->addOperation({Constants::QmlProfilerTimelineDockId, 0, {}, Perspective::Raise});
|
2016-03-02 13:57:37 +01:00
|
|
|
Debugger::registerPerspective(Constants::QmlProfilerPerspectiveId, perspective);
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlProfilerViewManager::hasValidSelection() const
|
|
|
|
|
{
|
|
|
|
|
return d->traceView->hasValidSelection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 QmlProfilerViewManager::selectionStart() const
|
|
|
|
|
{
|
|
|
|
|
return d->traceView->selectionStart();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 QmlProfilerViewManager::selectionEnd() const
|
|
|
|
|
{
|
|
|
|
|
return d->traceView->selectionEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:02:12 +01:00
|
|
|
bool QmlProfilerViewManager::isEventsRestrictedToRange() const
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2016-04-28 16:13:16 +02:00
|
|
|
return d->profilerModelManager->isRestrictedToRange();
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:02:12 +01:00
|
|
|
void QmlProfilerViewManager::restrictEventsToRange(qint64 rangeStart, qint64 rangeEnd)
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2016-04-28 16:13:16 +02:00
|
|
|
d->profilerModelManager->restrictToRange(rangeStart, rangeEnd);
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
2015-05-08 14:30:30 +02:00
|
|
|
void QmlProfilerViewManager::raiseTimeline()
|
|
|
|
|
{
|
2016-02-29 14:16:27 +01:00
|
|
|
QTC_ASSERT(qobject_cast<QDockWidget *>(d->traceView->parentWidget()), return);
|
|
|
|
|
d->traceView->parentWidget()->raise();
|
2015-05-08 14:30:30 +02:00
|
|
|
d->traceView->setFocus();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:47:17 +01:00
|
|
|
void QmlProfilerViewManager::clear()
|
|
|
|
|
{
|
2014-03-25 17:10:25 +01:00
|
|
|
d->traceView->clear();
|
2015-12-04 16:54:58 +01:00
|
|
|
foreach (QmlProfilerEventsView *view, d->eventsViews)
|
|
|
|
|
view->clear();
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProfiler
|