forked from qt-creator/qt-creator
QmlProfiler: Clean up view initialization
As there are only two events views we can handle them separately rather than keeping them in a list. Also, the object names and dock IDs should match. This breaks the settings, but that shouldn't be a big problem. Change-Id: Iac46fd7976d1e747fef4b40cead9a54e830d188f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -43,10 +43,8 @@ FlameGraphView::FlameGraphView(QmlProfilerModelManager *manager, QWidget *parent
|
||||
QmlProfilerEventsView(parent), m_content(new QQuickWidget(this)),
|
||||
m_model(new FlameGraphModel(manager, this))
|
||||
{
|
||||
setWindowTitle(QStringLiteral("Flame Graph"));
|
||||
|
||||
// We cannot change this without breaking the settings.
|
||||
setObjectName(QStringLiteral("QmlProfilerFlamegraph"));
|
||||
setObjectName("QmlProfiler.FlameGraph.Dock");
|
||||
setWindowTitle(tr("Flame Graph"));
|
||||
|
||||
qmlRegisterType<FlameGraph::FlameGraph>("FlameGraph", 1, 0, "FlameGraph");
|
||||
qmlRegisterUncreatableType<FlameGraphModel>("QmlProfilerFlameGraphModel", 1, 0,
|
||||
|
@@ -43,7 +43,6 @@ const char QtdFileExtension[] = ".qtd";
|
||||
const char QztFileExtension[] = ".qzt";
|
||||
|
||||
const char QmlProfilerPerspectiveId[] = "QmlProfiler.Perspective";
|
||||
const char QmlProfilerTimelineDockId[] = "QmlProfiler.Timeline.Dock";
|
||||
const char QmlProfilerLocalActionId[] = "QmlProfiler.Local";
|
||||
const char QmlProfilerRemoteActionId[] = "QmlProfiler.Remote";
|
||||
|
||||
|
@@ -165,7 +165,7 @@ QmlProfilerStatisticsView::QmlProfilerStatisticsView(QmlProfilerModelManager *pr
|
||||
QWidget *parent)
|
||||
: QmlProfilerEventsView(parent), d(new QmlProfilerStatisticsViewPrivate(this))
|
||||
{
|
||||
setObjectName(QLatin1String("QmlProfilerStatisticsView"));
|
||||
setObjectName(QLatin1String("QmlProfiler.Statistics.Dock"));
|
||||
setWindowTitle(tr("Statistics"));
|
||||
|
||||
d->model = new QmlProfilerStatisticsModel(profilerModelManager, this);
|
||||
|
@@ -90,7 +90,8 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
|
||||
QmlProfilerModelManager *modelManager)
|
||||
: QWidget(parent), d(new QmlProfilerTraceViewPrivate(this))
|
||||
{
|
||||
setObjectName(QLatin1String("QML Profiler"));
|
||||
setWindowTitle(tr("Timeline"));
|
||||
setObjectName("QmlProfiler.Timeline.Dock");
|
||||
|
||||
d->m_zoomControl = new Timeline::TimelineZoomControl(this);
|
||||
connect(modelManager, &QmlProfilerModelManager::stateChanged, this, [modelManager, this]() {
|
||||
|
@@ -49,7 +49,8 @@ namespace Internal {
|
||||
class QmlProfilerViewManager::QmlProfilerViewManagerPrivate {
|
||||
public:
|
||||
QmlProfilerTraceView *traceView;
|
||||
QList<QmlProfilerEventsView *> eventsViews;
|
||||
QmlProfilerStatisticsView *statisticsView;
|
||||
FlameGraphView *flameGraphView;
|
||||
QmlProfilerStateManager *profilerState;
|
||||
QmlProfilerModelManager *profilerModelManager;
|
||||
};
|
||||
@@ -60,7 +61,9 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
||||
: QObject(parent), d(new QmlProfilerViewManagerPrivate)
|
||||
{
|
||||
setObjectName(QLatin1String("QML Profiler View Manager"));
|
||||
d->traceView = 0;
|
||||
d->traceView = nullptr;
|
||||
d->statisticsView = nullptr;
|
||||
d->flameGraphView = nullptr;
|
||||
d->profilerState = profilerState;
|
||||
d->profilerModelManager = modelManager;
|
||||
createViews();
|
||||
@@ -77,7 +80,6 @@ void QmlProfilerViewManager::createViews()
|
||||
QTC_ASSERT(d->profilerState, return);
|
||||
|
||||
d->traceView = new QmlProfilerTraceView(0, this, d->profilerModelManager);
|
||||
d->traceView->setWindowTitle(tr("Timeline"));
|
||||
connect(d->traceView, &QmlProfilerTraceView::gotoSourceLocation,
|
||||
this, &QmlProfilerViewManager::gotoSourceLocation);
|
||||
connect(d->traceView, &QmlProfilerTraceView::typeSelected,
|
||||
@@ -89,13 +91,8 @@ void QmlProfilerViewManager::createViews()
|
||||
|
||||
auto perspective = new Utils::Perspective;
|
||||
perspective->setName(tr("QML Profiler"));
|
||||
perspective->addOperation({Constants::QmlProfilerTimelineDockId, d->traceView, {},
|
||||
Perspective::SplitVertical});
|
||||
|
||||
d->eventsViews << new QmlProfilerStatisticsView(d->profilerModelManager);
|
||||
d->eventsViews << new FlameGraphView(d->profilerModelManager);
|
||||
|
||||
foreach (QmlProfilerEventsView *view, d->eventsViews) {
|
||||
auto prepareEventsView = [this](QmlProfilerEventsView *view) {
|
||||
connect(view, &QmlProfilerEventsView::typeSelected,
|
||||
this, &QmlProfilerViewManager::typeSelected);
|
||||
connect(this, &QmlProfilerViewManager::typeSelected,
|
||||
@@ -106,11 +103,22 @@ void QmlProfilerViewManager::createViews()
|
||||
this, &QmlProfilerViewManager::gotoSourceLocation);
|
||||
connect(view, &QmlProfilerEventsView::showFullRange,
|
||||
this, [this](){restrictEventsToRange(-1, -1);});
|
||||
QByteArray dockId = view->objectName().toLatin1();
|
||||
perspective->addOperation({dockId, view, Constants::QmlProfilerTimelineDockId, Perspective::AddToTab});
|
||||
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, view);
|
||||
}
|
||||
perspective->addOperation({Constants::QmlProfilerTimelineDockId, 0, {}, Perspective::Raise});
|
||||
};
|
||||
|
||||
d->statisticsView = new QmlProfilerStatisticsView(d->profilerModelManager);
|
||||
prepareEventsView(d->statisticsView);
|
||||
d->flameGraphView = new FlameGraphView(d->profilerModelManager);
|
||||
prepareEventsView(d->flameGraphView);
|
||||
|
||||
const QByteArray anchorDockId = d->traceView->objectName().toLatin1();
|
||||
perspective->addOperation({anchorDockId, d->traceView, {}, Perspective::SplitVertical});
|
||||
perspective->addOperation({d->flameGraphView->objectName().toLatin1(), d->flameGraphView,
|
||||
anchorDockId, Perspective::AddToTab});
|
||||
perspective->addOperation({d->statisticsView->objectName().toLatin1(), d->statisticsView,
|
||||
anchorDockId, Perspective::AddToTab});
|
||||
perspective->addOperation({anchorDockId, 0, {}, Perspective::Raise});
|
||||
|
||||
Debugger::registerPerspective(Constants::QmlProfilerPerspectiveId, perspective);
|
||||
}
|
||||
|
||||
@@ -149,8 +157,8 @@ void QmlProfilerViewManager::raiseTimeline()
|
||||
void QmlProfilerViewManager::clear()
|
||||
{
|
||||
d->traceView->clear();
|
||||
foreach (QmlProfilerEventsView *view, d->eventsViews)
|
||||
view->clear();
|
||||
d->flameGraphView->clear();
|
||||
d->statisticsView->clear();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user