forked from qt-creator/qt-creator
QmlProfiler: Allow multiple events views loaded from plugins
Change-Id: Ifaf4e63f4a843a42a1a22f005e87d8c1a4604686 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
@@ -546,7 +546,7 @@
|
||||
|
||||
When you select an event in the \uicontrol Timeline view, information about it is
|
||||
displayed in the \uicontrol Statistics view. To view an event range in the
|
||||
\uicontrol Statistics view, select \uicontrol {Limit Statistics Pane to Current Range}
|
||||
\uicontrol Statistics view, select \uicontrol {Analyze Current Range}
|
||||
in the context menu in the \uicontrol Timeline view.
|
||||
|
||||
To copy the contents of one view or row to the clipboard, select
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#define QMLPROFILEREVENTSVIEW_H
|
||||
|
||||
#include "qmlprofiler_global.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QWidget>
|
||||
@@ -51,12 +52,21 @@ public:
|
||||
signals:
|
||||
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
|
||||
void typeSelected(int typeIndex);
|
||||
void showFullRange();
|
||||
|
||||
public slots:
|
||||
virtual void selectByTypeId(int typeIndex) = 0;
|
||||
virtual void onVisibleFeaturesChanged(quint64 features) = 0;
|
||||
};
|
||||
|
||||
class QMLPROFILER_EXPORT QmlProfilerEventsViewFactory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual QList<QmlProfilerEventsView *> create(QWidget *parent,
|
||||
QmlProfilerModelManager *manager) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // QMLPROFILEREVENTSVIEW_H
|
||||
|
@@ -192,6 +192,7 @@ QmlProfilerStatisticsView::QmlProfilerStatisticsView(QWidget *parent,
|
||||
: QmlProfilerEventsView(parent), d(new QmlProfilerStatisticsViewPrivate(this))
|
||||
{
|
||||
setObjectName(QLatin1String("QmlProfilerStatisticsView"));
|
||||
setWindowTitle(tr("Statistics"));
|
||||
|
||||
d->model = new QmlProfilerStatisticsModel(profilerModelManager, this);
|
||||
|
||||
@@ -304,7 +305,7 @@ void QmlProfilerStatisticsView::contextMenuEvent(QContextMenuEvent *ev)
|
||||
if (selectedAction == copyTableAction)
|
||||
copyTableToClipboard();
|
||||
if (selectedAction == getGlobalStatsAction)
|
||||
restrictToRange(-1, -1);
|
||||
emit showFullRange();
|
||||
if (selectedAction == showExtendedStatsAction)
|
||||
setShowExtendedStatistics(!showExtendedStatistics());
|
||||
}
|
||||
|
@@ -242,11 +242,11 @@ void QmlProfilerTraceView::showContextMenu(QPoint position)
|
||||
menu.addActions(QmlProfilerTool::profilerContextMenuActions());
|
||||
menu.addSeparator();
|
||||
|
||||
QAction *getLocalStatsAction = menu.addAction(tr("Limit Statistics Pane to Current Range"));
|
||||
QAction *getLocalStatsAction = menu.addAction(tr("Analyze Current Range"));
|
||||
if (!d->m_viewContainer->hasValidSelection())
|
||||
getLocalStatsAction->setEnabled(false);
|
||||
|
||||
QAction *getGlobalStatsAction = menu.addAction(tr("Show Full Range in Statistics Pane"));
|
||||
QAction *getGlobalStatsAction = menu.addAction(tr("Analyze Full Range"));
|
||||
if (!d->m_viewContainer->isEventsRestrictedToRange())
|
||||
getGlobalStatsAction->setEnabled(false);
|
||||
|
||||
|
@@ -37,9 +37,11 @@
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilerstatewidget.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fancymainwindow.h>
|
||||
#include <analyzerbase/analyzermanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
@@ -54,9 +56,10 @@ public:
|
||||
|
||||
QDockWidget *timelineDock;
|
||||
QmlProfilerTraceView *traceView;
|
||||
QmlProfilerStatisticsView *eventsView;
|
||||
QList<QmlProfilerEventsView *> eventsViews;
|
||||
QmlProfilerStateManager *profilerState;
|
||||
QmlProfilerModelManager *profilerModelManager;
|
||||
QmlProfilerEventsViewFactory *eventsViewFactory;
|
||||
};
|
||||
|
||||
QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
||||
@@ -66,9 +69,10 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
||||
{
|
||||
setObjectName(QLatin1String("QML Profiler View Manager"));
|
||||
d->traceView = 0;
|
||||
d->eventsView = 0;
|
||||
d->profilerState = profilerState;
|
||||
d->profilerModelManager = modelManager;
|
||||
d->eventsViewFactory =
|
||||
ExtensionSystem::PluginManager::getObject<QmlProfilerEventsViewFactory>();
|
||||
createViews();
|
||||
}
|
||||
|
||||
@@ -79,7 +83,6 @@ QmlProfilerViewManager::~QmlProfilerViewManager()
|
||||
|
||||
void QmlProfilerViewManager::createViews()
|
||||
{
|
||||
|
||||
QTC_ASSERT(d->profilerModelManager, return);
|
||||
QTC_ASSERT(d->profilerState, return);
|
||||
|
||||
@@ -89,32 +92,48 @@ void QmlProfilerViewManager::createViews()
|
||||
d->traceView->setWindowTitle(tr("Timeline"));
|
||||
connect(d->traceView, &QmlProfilerTraceView::gotoSourceLocation,
|
||||
this, &QmlProfilerViewManager::gotoSourceLocation);
|
||||
|
||||
d->eventsView = new QmlProfilerStatisticsView(mw, d->profilerModelManager);
|
||||
d->eventsView->setWindowTitle(tr("Statistics"));
|
||||
connect(d->eventsView, &QmlProfilerStatisticsView::gotoSourceLocation,
|
||||
this, &QmlProfilerViewManager::gotoSourceLocation);
|
||||
connect(d->eventsView, &QmlProfilerStatisticsView::typeSelected,
|
||||
d->traceView, &QmlProfilerTraceView::selectByTypeId);
|
||||
connect(d->traceView, &QmlProfilerTraceView::typeSelected,
|
||||
d->eventsView, &QmlProfilerStatisticsView::selectByTypeId);
|
||||
connect(d->profilerModelManager, &QmlProfilerModelManager::visibleFeaturesChanged,
|
||||
d->eventsView, &QmlProfilerStatisticsView::onVisibleFeaturesChanged);
|
||||
|
||||
QDockWidget *eventsDock = AnalyzerManager::createDockWidget
|
||||
(Constants::QmlProfilerToolId, d->eventsView);
|
||||
d->timelineDock = AnalyzerManager::createDockWidget
|
||||
(Constants::QmlProfilerToolId, d->traceView);
|
||||
|
||||
eventsDock->show();
|
||||
this, &QmlProfilerViewManager::typeSelected);
|
||||
connect(this, &QmlProfilerViewManager::typeSelected,
|
||||
d->traceView, &QmlProfilerTraceView::selectByTypeId);
|
||||
d->timelineDock = AnalyzerManager::createDockWidget(Constants::QmlProfilerToolId, d->traceView);
|
||||
d->timelineDock->show();
|
||||
|
||||
mw->splitDockWidget(mw->toolBarDockWidget(), d->timelineDock, Qt::Vertical);
|
||||
mw->tabifyDockWidget(d->timelineDock, eventsDock);
|
||||
d->timelineDock->raise();
|
||||
|
||||
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->eventsView);
|
||||
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->traceView);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
bool QmlProfilerViewManager::hasValidSelection() const
|
||||
@@ -134,12 +153,17 @@ qint64 QmlProfilerViewManager::selectionEnd() const
|
||||
|
||||
bool QmlProfilerViewManager::isEventsRestrictedToRange() const
|
||||
{
|
||||
return d->eventsView->isRestrictedToRange();
|
||||
foreach (QmlProfilerEventsView *view, d->eventsViews) {
|
||||
if (view->isRestrictedToRange())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QmlProfilerViewManager::restrictEventsToRange(qint64 rangeStart, qint64 rangeEnd)
|
||||
{
|
||||
d->eventsView->restrictToRange(rangeStart, rangeEnd);
|
||||
foreach (QmlProfilerEventsView *view, d->eventsViews)
|
||||
view->restrictToRange(rangeStart, rangeEnd);
|
||||
}
|
||||
|
||||
void QmlProfilerViewManager::raiseTimeline()
|
||||
@@ -151,7 +175,8 @@ void QmlProfilerViewManager::raiseTimeline()
|
||||
void QmlProfilerViewManager::clear()
|
||||
{
|
||||
d->traceView->clear();
|
||||
d->eventsView->clear();
|
||||
foreach (QmlProfilerEventsView *view, d->eventsViews)
|
||||
view->clear();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -65,6 +65,7 @@ public slots:
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
void typeSelected(int typeId);
|
||||
void gotoSourceLocation(QString,int,int);
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user