QmlProfiler: Make the views accessible from the view manager

And then, drop some methods we don't need anymore.

Change-Id: I057bdc012072abddca2df83918ee9a0460f78611
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Ulf Hermann
2016-12-20 13:00:18 +01:00
parent beea69e486
commit 2ad8e27d53
5 changed files with 24 additions and 50 deletions

View File

@@ -27,7 +27,6 @@
#include "qmlprofilermodelmanager.h" #include "qmlprofilermodelmanager.h"
#include "qmlprofilerstatisticsmodel.h" #include "qmlprofilerstatisticsmodel.h"
#include "qmlprofilerviewmanager.h"
#include "qmlprofilereventsview.h" #include "qmlprofilereventsview.h"
#include "qmlprofilereventtypes.h" #include "qmlprofilereventtypes.h"

View File

@@ -70,6 +70,7 @@
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>
#include <QApplication> #include <QApplication>
#include <QDockWidget>
#include <QFileDialog> #include <QFileDialog>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel> #include <QLabel>
@@ -217,7 +218,7 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
d->m_searchButton->setToolTip(tr("Search timeline event notes.")); d->m_searchButton->setToolTip(tr("Search timeline event notes."));
connect(d->m_searchButton, &QToolButton::clicked, this, &QmlProfilerTool::showTimeLineSearch); connect(d->m_searchButton, &QToolButton::clicked, this, &QmlProfilerTool::showTimeLineSearch);
d->m_searchButton->setEnabled(d->m_viewContainer->isTimelineUsable()); d->m_searchButton->setEnabled(d->m_viewContainer->traceView()->isUsable());
d->m_displayFeaturesButton = new QToolButton; d->m_displayFeaturesButton = new QToolButton;
d->m_displayFeaturesButton->setIcon(Utils::Icons::FILTER.icon()); d->m_displayFeaturesButton->setIcon(Utils::Icons::FILTER.icon());
@@ -529,7 +530,10 @@ void QmlProfilerTool::updateTimeDisplay()
void QmlProfilerTool::showTimeLineSearch() void QmlProfilerTool::showTimeLineSearch()
{ {
d->m_viewContainer->raiseTimeline(); QmlProfilerTraceView *traceView = d->m_viewContainer->traceView();
QTC_ASSERT(qobject_cast<QDockWidget *>(traceView->parentWidget()), return);
traceView->parentWidget()->raise();
traceView->setFocus();
Core::Find::openFindToolBar(Core::Find::FindForwardDirection); Core::Find::openFindToolBar(Core::Find::FindForwardDirection);
} }
@@ -551,7 +555,7 @@ void QmlProfilerTool::setButtonsEnabled(bool enable)
{ {
d->m_clearButton->setEnabled(enable); d->m_clearButton->setEnabled(enable);
d->m_displayFeaturesButton->setEnabled(enable); d->m_displayFeaturesButton->setEnabled(enable);
d->m_searchButton->setEnabled(d->m_viewContainer->isTimelineUsable() && enable); d->m_searchButton->setEnabled(d->m_viewContainer->traceView()->isUsable() && enable);
d->m_recordFeaturesMenu->setEnabled(enable); d->m_recordFeaturesMenu->setEnabled(enable);
} }

View File

@@ -267,11 +267,11 @@ void QmlProfilerTraceView::showContextMenu(QPoint position)
menu.addSeparator(); menu.addSeparator();
QAction *getLocalStatsAction = menu.addAction(tr("Analyze Current Range")); QAction *getLocalStatsAction = menu.addAction(tr("Analyze Current Range"));
if (!d->m_viewContainer->hasValidSelection()) if (!hasValidSelection())
getLocalStatsAction->setEnabled(false); getLocalStatsAction->setEnabled(false);
QAction *getGlobalStatsAction = menu.addAction(tr("Analyze Full Range")); QAction *getGlobalStatsAction = menu.addAction(tr("Analyze Full Range"));
if (!d->m_viewContainer->isEventsRestrictedToRange()) if (!d->m_modelManager->isRestrictedToRange())
getGlobalStatsAction->setEnabled(false); getGlobalStatsAction->setEnabled(false);
if (d->m_zoomControl->traceDuration() > 0) { if (d->m_zoomControl->traceDuration() > 0) {
@@ -287,11 +287,10 @@ void QmlProfilerTraceView::showContextMenu(QPoint position)
d->m_zoomControl->traceEnd()); d->m_zoomControl->traceEnd());
} }
if (selectedAction == getLocalStatsAction) { if (selectedAction == getLocalStatsAction) {
d->m_viewContainer->restrictEventsToRange(d->m_viewContainer->selectionStart(), d->m_modelManager->restrictToRange(selectionStart(), selectionEnd());
d->m_viewContainer->selectionEnd());
} }
if (selectedAction == getGlobalStatsAction) if (selectedAction == getGlobalStatsAction)
d->m_viewContainer->restrictEventsToRange(-1, -1); d->m_modelManager->restrictToRange(-1, -1);
} }
} }

View File

@@ -25,13 +25,10 @@
#include "qmlprofilerviewmanager.h" #include "qmlprofilerviewmanager.h"
#include "qmlprofilertraceview.h"
#include "qmlprofilerstatisticsview.h"
#include "qmlprofilertool.h" #include "qmlprofilertool.h"
#include "qmlprofilerstatemanager.h" #include "qmlprofilerstatemanager.h"
#include "qmlprofilermodelmanager.h" #include "qmlprofilermodelmanager.h"
#include "qmlprofilerstatewidget.h" #include "qmlprofilerstatewidget.h"
#include "flamegraphview.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -102,7 +99,7 @@ void QmlProfilerViewManager::createViews()
connect(view, &QmlProfilerEventsView::gotoSourceLocation, connect(view, &QmlProfilerEventsView::gotoSourceLocation,
this, &QmlProfilerViewManager::gotoSourceLocation); this, &QmlProfilerViewManager::gotoSourceLocation);
connect(view, &QmlProfilerEventsView::showFullRange, connect(view, &QmlProfilerEventsView::showFullRange,
this, [this](){restrictEventsToRange(-1, -1);}); this, [this](){ d->profilerModelManager->restrictToRange(-1, -1);});
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, view); new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, view);
}; };
@@ -129,41 +126,19 @@ void QmlProfilerViewManager::createViews()
Debugger::registerPerspective(Constants::QmlProfilerPerspectiveId, perspective); Debugger::registerPerspective(Constants::QmlProfilerPerspectiveId, perspective);
} }
bool QmlProfilerViewManager::hasValidSelection() const QmlProfilerTraceView *QmlProfilerViewManager::traceView() const
{ {
return d->traceView->hasValidSelection(); return d->traceView;
} }
qint64 QmlProfilerViewManager::selectionStart() const QmlProfilerStatisticsView *QmlProfilerViewManager::statisticsView() const
{ {
return d->traceView->selectionStart(); return d->statisticsView;
} }
qint64 QmlProfilerViewManager::selectionEnd() const FlameGraphView *QmlProfilerViewManager::flameGraphView() const
{ {
return d->traceView->selectionEnd(); return d->flameGraphView;
}
bool QmlProfilerViewManager::isEventsRestrictedToRange() const
{
return d->profilerModelManager->isRestrictedToRange();
}
void QmlProfilerViewManager::restrictEventsToRange(qint64 rangeStart, qint64 rangeEnd)
{
d->profilerModelManager->restrictToRange(rangeStart, rangeEnd);
}
bool QmlProfilerViewManager::isTimelineUsable() const
{
return d->traceView->isUsable();
}
void QmlProfilerViewManager::raiseTimeline()
{
QTC_ASSERT(qobject_cast<QDockWidget *>(d->traceView->parentWidget()), return);
d->traceView->parentWidget()->raise();
d->traceView->setFocus();
} }
void QmlProfilerViewManager::clear() void QmlProfilerViewManager::clear()

View File

@@ -25,6 +25,9 @@
#pragma once #pragma once
#include "qmlprofilerstatisticsview.h"
#include "qmlprofilertraceview.h"
#include "flamegraphview.h"
#include <QObject> #include <QObject>
namespace QmlProfiler { namespace QmlProfiler {
@@ -46,15 +49,9 @@ public:
void createViews(); void createViews();
// used by the options "limit events to range" QmlProfilerTraceView *traceView() const;
bool hasValidSelection() const; QmlProfilerStatisticsView *statisticsView() const;
qint64 selectionStart() const; FlameGraphView *flameGraphView() const;
qint64 selectionEnd() const;
bool isEventsRestrictedToRange() const;
void restrictEventsToRange(qint64 rangeStart, qint64 rangeEnd);
bool isTimelineUsable() const;
void raiseTimeline();
public slots: public slots:
void clear(); void clear();