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"
|
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>
|
|
|
|
|
#include <utils/fancymainwindow.h>
|
|
|
|
|
#include <analyzerbase/analyzermanager.h>
|
2015-12-04 16:54:58 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
#include <QDockWidget>
|
|
|
|
|
|
|
|
|
|
using namespace Analyzer;
|
|
|
|
|
|
|
|
|
|
namespace QmlProfiler {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class QmlProfilerViewManager::QmlProfilerViewManagerPrivate {
|
|
|
|
|
public:
|
|
|
|
|
QmlProfilerViewManagerPrivate(QmlProfilerViewManager *qq) { Q_UNUSED(qq); }
|
|
|
|
|
|
2015-05-08 14:30:30 +02:00
|
|
|
QDockWidget *timelineDock;
|
2012-02-24 10:47:17 +01:00
|
|
|
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;
|
2015-12-04 16:54:58 +01:00
|
|
|
QmlProfilerEventsViewFactory *eventsViewFactory;
|
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;
|
2015-12-04 16:54:58 +01:00
|
|
|
d->eventsViewFactory =
|
|
|
|
|
ExtensionSystem::PluginManager::getObject<QmlProfilerEventsViewFactory>();
|
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);
|
|
|
|
|
|
|
|
|
|
Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow();
|
|
|
|
|
|
2016-01-04 17:20:13 +01:00
|
|
|
d->traceView = new QmlProfilerTraceView(mw, 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);
|
|
|
|
|
d->timelineDock = AnalyzerManager::createDockWidget(Constants::QmlProfilerToolId, d->traceView);
|
2015-05-08 14:30:30 +02:00
|
|
|
d->timelineDock->show();
|
|
|
|
|
mw->splitDockWidget(mw->toolBarDockWidget(), d->timelineDock, Qt::Vertical);
|
2013-08-08 13:28:08 +02:00
|
|
|
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->traceView);
|
2015-12-04 16:54:58 +01:00
|
|
|
|
|
|
|
|
d->eventsViews << new QmlProfilerStatisticsView(mw, d->profilerModelManager);
|
|
|
|
|
if (d->eventsViewFactory)
|
|
|
|
|
d->eventsViews.append(d->eventsViewFactory->create(mw, d->profilerModelManager));
|
|
|
|
|
|
|
|
|
|
// Clear settings if the new views aren't there yet. Otherwise we get glitches
|
|
|
|
|
QSettings *settings = Core::ICore::settings();
|
|
|
|
|
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") +
|
|
|
|
|
QLatin1String(QmlProfiler::Constants::QmlProfilerToolId));
|
|
|
|
|
|
|
|
|
|
foreach (QmlProfilerEventsView *view, d->eventsViews) {
|
|
|
|
|
view->setParent(mw);
|
|
|
|
|
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);});
|
|
|
|
|
QDockWidget *eventsDock = AnalyzerManager::createDockWidget(Constants::QmlProfilerToolId,
|
|
|
|
|
view);
|
|
|
|
|
eventsDock->show();
|
|
|
|
|
mw->tabifyDockWidget(d->timelineDock, eventsDock);
|
|
|
|
|
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, view);
|
|
|
|
|
|
|
|
|
|
if (!settings->contains(eventsDock->objectName()))
|
|
|
|
|
settings->remove(QString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
d->timelineDock->raise();
|
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
|
|
|
{
|
2015-12-04 16:54:58 +01:00
|
|
|
foreach (QmlProfilerEventsView *view, d->eventsViews) {
|
|
|
|
|
if (view->isRestrictedToRange())
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
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
|
|
|
{
|
2015-12-04 16:54:58 +01:00
|
|
|
foreach (QmlProfilerEventsView *view, d->eventsViews)
|
|
|
|
|
view->restrictToRange(rangeStart, rangeEnd);
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
2015-05-08 14:30:30 +02:00
|
|
|
void QmlProfilerViewManager::raiseTimeline()
|
|
|
|
|
{
|
|
|
|
|
d->timelineDock->raise();
|
|
|
|
|
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
|