QmlProfiler: Rename "events" to "statistics" view

Change-Id: Id552e0ead056214a7d72dd618c54897b55cd5e38
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2015-12-04 13:30:54 +01:00
parent df4e46ff02
commit 4223d76c48
8 changed files with 243 additions and 176 deletions

View File

@@ -521,9 +521,9 @@
\li None \li None
\endtable \endtable
\section1 Viewing Events \section1 Viewing Statistics
The \uicontrol Events view displays the number of times each binding, create, The \uicontrol Statistics view displays the number of times each binding, create,
compile, JavaScript, or signal event is triggered and the average time it compile, JavaScript, or signal event is triggered and the average time it
takes. This allows you to examine which events you need to optimize. A high takes. This allows you to examine which events you need to optimize. A high
number of occurrences might indicate that an event is triggered number of occurrences might indicate that an event is triggered
@@ -533,7 +533,7 @@
Click on an event to move to it in the source code Click on an event to move to it in the source code
in the code editor. in the code editor.
\image qtcreator-analyzer-bindings.png "Events view" \image qtcreator-analyzer-bindings.png "Statistics view"
The \uicontrol Callers and \uicontrol Callees panes show dependencies between events. The \uicontrol Callers and \uicontrol Callees panes show dependencies between events.
They allow you to examine the internal functions of the application. They allow you to examine the internal functions of the application.
@@ -545,13 +545,13 @@
Click on an event to move to it in the source code in the code editor. Click on an event to move to it in the source code in the code editor.
When you select an event in the \uicontrol Timeline view, information about it is When you select an event in the \uicontrol Timeline view, information about it is
displayed in the \uicontrol Events view. To view an event range in the \uicontrol Events displayed in the \uicontrol Statistics view. To view an event range in the
view, select \uicontrol {Limit Events Pane to Current Range} in the context menu \uicontrol Statistics view, select \uicontrol {Limit Statistics Pane to Current Range}
in the \uicontrol Timeline view. in the context menu in the \uicontrol Timeline view.
To copy the contents of one view or row to the clipboard, select To copy the contents of one view or row to the clipboard, select
\uicontrol {Copy Table} or \uicontrol {Copy Row} in the context menu. \uicontrol {Copy Table} or \uicontrol {Copy Row} in the context menu.
JavaScript events are shown in the \uicontrol Events view only for applications JavaScript events are shown in the \uicontrol Statistics view only for applications
that use Qt Quick 2 and are compiled with Qt 5.3 or later. that use Qt Quick 2 and are compiled with Qt 5.3 or later.
*/ */

View File

@@ -14,7 +14,6 @@ SOURCES += \
qmlprofilerdatamodel.cpp \ qmlprofilerdatamodel.cpp \
qmlprofilerdetailsrewriter.cpp \ qmlprofilerdetailsrewriter.cpp \
qmlprofilereventsmodelproxy.cpp \ qmlprofilereventsmodelproxy.cpp \
qmlprofilereventview.cpp \
qmlprofilermodelmanager.cpp \ qmlprofilermodelmanager.cpp \
qmlprofilernotesmodel.cpp \ qmlprofilernotesmodel.cpp \
qmlprofileroptionspage.cpp \ qmlprofileroptionspage.cpp \
@@ -26,6 +25,7 @@ SOURCES += \
qmlprofilersettings.cpp \ qmlprofilersettings.cpp \
qmlprofilerstatemanager.cpp \ qmlprofilerstatemanager.cpp \
qmlprofilerstatewidget.cpp \ qmlprofilerstatewidget.cpp \
qmlprofilerstatisticsview.cpp \
qmlprofilertimelinemodel.cpp \ qmlprofilertimelinemodel.cpp \
qmlprofilertimelinemodelfactory.cpp \ qmlprofilertimelinemodelfactory.cpp \
qmlprofilertool.cpp \ qmlprofilertool.cpp \
@@ -45,7 +45,7 @@ HEADERS += \
qmlprofilerdatamodel.h \ qmlprofilerdatamodel.h \
qmlprofilerdetailsrewriter.h \ qmlprofilerdetailsrewriter.h \
qmlprofilereventsmodelproxy.h \ qmlprofilereventsmodelproxy.h \
qmlprofilereventview.h \ qmlprofilereventsview.h \
qmlprofilermodelmanager.h \ qmlprofilermodelmanager.h \
qmlprofilernotesmodel.h \ qmlprofilernotesmodel.h \
qmlprofileroptionspage.h \ qmlprofileroptionspage.h \
@@ -57,6 +57,7 @@ HEADERS += \
qmlprofilersettings.h \ qmlprofilersettings.h \
qmlprofilerstatemanager.h \ qmlprofilerstatemanager.h \
qmlprofilerstatewidget.h \ qmlprofilerstatewidget.h \
qmlprofilerstatisticsview.h \
qmlprofilertimelinemodel.h \ qmlprofilertimelinemodel.h \
qmlprofilertimelinemodelfactory.h \ qmlprofilertimelinemodelfactory.h \
qmlprofilertool.h \ qmlprofilertool.h \

View File

@@ -30,7 +30,7 @@ QtcPlugin {
"qmlprofilerdatamodel.cpp", "qmlprofilerdatamodel.h", "qmlprofilerdatamodel.cpp", "qmlprofilerdatamodel.h",
"qmlprofilerdetailsrewriter.cpp", "qmlprofilerdetailsrewriter.h", "qmlprofilerdetailsrewriter.cpp", "qmlprofilerdetailsrewriter.h",
"qmlprofilereventsmodelproxy.cpp", "qmlprofilereventsmodelproxy.h", "qmlprofilereventsmodelproxy.cpp", "qmlprofilereventsmodelproxy.h",
"qmlprofilereventview.cpp", "qmlprofilereventview.h", "qmlprofilereventsview.h",
"qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h", "qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h",
"qmlprofilernotesmodel.cpp", "qmlprofilernotesmodel.h", "qmlprofilernotesmodel.cpp", "qmlprofilernotesmodel.h",
"qmlprofileroptionspage.cpp", "qmlprofileroptionspage.h", "qmlprofileroptionspage.cpp", "qmlprofileroptionspage.h",
@@ -42,6 +42,7 @@ QtcPlugin {
"qmlprofilersettings.cpp", "qmlprofilersettings.h", "qmlprofilersettings.cpp", "qmlprofilersettings.h",
"qmlprofilerstatemanager.cpp", "qmlprofilerstatemanager.h", "qmlprofilerstatemanager.cpp", "qmlprofilerstatemanager.h",
"qmlprofilerstatewidget.cpp", "qmlprofilerstatewidget.h", "qmlprofilerstatewidget.cpp", "qmlprofilerstatewidget.h",
"qmlprofilerstatisticsview.cpp", "qmlprofilerstatisticsview.h",
"qmlprofilertimelinemodel.cpp", "qmlprofilertimelinemodel.h", "qmlprofilertimelinemodel.cpp", "qmlprofilertimelinemodel.h",
"qmlprofilertimelinemodelfactory.cpp", "qmlprofilertimelinemodelfactory.h", "qmlprofilertimelinemodelfactory.cpp", "qmlprofilertimelinemodelfactory.h",
"qmlprofilertool.cpp", "qmlprofilertool.h", "qmlprofilertool.cpp", "qmlprofilertool.h",

View File

@@ -0,0 +1,62 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLPROFILEREVENTSVIEW_H
#define QMLPROFILEREVENTSVIEW_H
#include "qmlprofiler_global.h"
#include <QAbstractItemModel>
#include <QWidget>
namespace QmlProfiler {
class QMLPROFILER_EXPORT QmlProfilerEventsView : public QWidget
{
Q_OBJECT
public:
QmlProfilerEventsView(QWidget *parent = 0) : QWidget(parent) {}
virtual void clear() = 0;
virtual void restrictToRange(qint64 rangeStart, qint64 rangeEnd) = 0;
virtual bool isRestrictedToRange() const = 0;
signals:
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
void typeSelected(int typeIndex);
public slots:
virtual void selectByTypeId(int typeIndex) = 0;
virtual void onVisibleFeaturesChanged(quint64 features) = 0;
};
}
#endif // QMLPROFILEREVENTSVIEW_H

View File

@@ -28,7 +28,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include "qmlprofilereventview.h" #include "qmlprofilerstatisticsview.h"
#include <QUrl> #include <QUrl>
#include <QHash> #include <QHash>
@@ -67,23 +67,23 @@ struct Colors {
struct RootEventType : public QmlProfilerDataModel::QmlEventTypeData { struct RootEventType : public QmlProfilerDataModel::QmlEventTypeData {
RootEventType() RootEventType()
{ {
QString rootEventName = QmlProfilerEventsMainView::tr("<program>"); QString rootEventName = QmlProfilerStatisticsMainView::tr("<program>");
displayName = rootEventName; displayName = rootEventName;
location = QmlEventLocation(rootEventName, 1, 1); location = QmlEventLocation(rootEventName, 1, 1);
message = MaximumMessage; message = MaximumMessage;
rangeType = MaximumRangeType; rangeType = MaximumRangeType;
detailType = -1; detailType = -1;
data = QmlProfilerEventsMainView::tr("Main Program"); data = QmlProfilerStatisticsMainView::tr("Main Program");
} }
}; };
Q_GLOBAL_STATIC(Colors, colors) Q_GLOBAL_STATIC(Colors, colors)
Q_GLOBAL_STATIC(RootEventType, rootEventType) Q_GLOBAL_STATIC(RootEventType, rootEventType)
class EventsViewItem : public QStandardItem class StatisticsViewItem : public QStandardItem
{ {
public: public:
EventsViewItem(const QString &text) : QStandardItem(text) {} StatisticsViewItem(const QString &text) : QStandardItem(text) {}
virtual bool operator<(const QStandardItem &other) const virtual bool operator<(const QStandardItem &other) const
{ {
@@ -109,20 +109,20 @@ public:
} }
}; };
class QmlProfilerEventsWidget::QmlProfilerEventsWidgetPrivate class QmlProfilerStatisticsView::QmlProfilerStatisticsViewPrivate
{ {
public: public:
QmlProfilerEventsWidgetPrivate(QmlProfilerEventsWidget *qq):q(qq) {} QmlProfilerStatisticsViewPrivate(QmlProfilerStatisticsView *qq) : q(qq) {}
~QmlProfilerEventsWidgetPrivate() {} ~QmlProfilerStatisticsViewPrivate() {}
QmlProfilerEventsWidget *q; QmlProfilerStatisticsView *q;
QmlProfilerTool *m_profilerTool; QmlProfilerTool *m_profilerTool;
QmlProfilerViewManager *m_viewContainer; QmlProfilerViewManager *m_viewContainer;
QmlProfilerEventsMainView *m_eventTree; QmlProfilerStatisticsMainView *m_eventTree;
QmlProfilerEventRelativesView *m_eventChildren; QmlProfilerStatisticsRelativesView *m_eventChildren;
QmlProfilerEventRelativesView *m_eventParents; QmlProfilerStatisticsRelativesView *m_eventParents;
QmlProfilerEventsModelProxy *modelProxy; QmlProfilerEventsModelProxy *modelProxy;
qint64 rangeStart; qint64 rangeStart;
@@ -190,41 +190,39 @@ static void getSourceLocation(QStandardItem *infoItem,
receiver(fileName, line, column); receiver(fileName, line, column);
} }
QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent, QmlProfilerStatisticsView::QmlProfilerStatisticsView(QWidget *parent, QmlProfilerTool *profilerTool,
QmlProfilerTool *profilerTool,
QmlProfilerViewManager *container, QmlProfilerViewManager *container,
QmlProfilerModelManager *profilerModelManager ) QmlProfilerModelManager *profilerModelManager )
: QmlProfilerEventsView(parent), d(new QmlProfilerStatisticsViewPrivate(this))
: QWidget(parent), d(new QmlProfilerEventsWidgetPrivate(this))
{ {
setObjectName(QLatin1String("QmlProfilerEventsView")); setObjectName(QLatin1String("QmlProfilerStatisticsView"));
d->modelProxy = new QmlProfilerEventsModelProxy(profilerModelManager, this); d->modelProxy = new QmlProfilerEventsModelProxy(profilerModelManager, this);
d->m_eventTree = new QmlProfilerEventsMainView(this, d->modelProxy); d->m_eventTree = new QmlProfilerStatisticsMainView(this, d->modelProxy);
connect(d->m_eventTree, &QmlProfilerEventsMainView::gotoSourceLocation, connect(d->m_eventTree, &QmlProfilerStatisticsMainView::gotoSourceLocation,
this, &QmlProfilerEventsWidget::gotoSourceLocation); this, &QmlProfilerStatisticsView::gotoSourceLocation);
connect(d->m_eventTree, &QmlProfilerEventsMainView::typeSelected, connect(d->m_eventTree, &QmlProfilerStatisticsMainView::typeSelected,
this, &QmlProfilerEventsWidget::typeSelected); this, &QmlProfilerStatisticsView::typeSelected);
d->m_eventChildren = new QmlProfilerEventRelativesView( d->m_eventChildren = new QmlProfilerStatisticsRelativesView(
new QmlProfilerEventChildrenModelProxy(profilerModelManager, d->modelProxy, this), new QmlProfilerEventChildrenModelProxy(profilerModelManager, d->modelProxy, this),
this); this);
d->m_eventParents = new QmlProfilerEventRelativesView( d->m_eventParents = new QmlProfilerStatisticsRelativesView(
new QmlProfilerEventParentsModelProxy(profilerModelManager, d->modelProxy, this), new QmlProfilerEventParentsModelProxy(profilerModelManager, d->modelProxy, this),
this); this);
connect(d->m_eventTree, &QmlProfilerEventsMainView::typeSelected, connect(d->m_eventTree, &QmlProfilerStatisticsMainView::typeSelected,
d->m_eventChildren, &QmlProfilerEventRelativesView::displayType); d->m_eventChildren, &QmlProfilerStatisticsRelativesView::displayType);
connect(d->m_eventTree, &QmlProfilerEventsMainView::typeSelected, connect(d->m_eventTree, &QmlProfilerStatisticsMainView::typeSelected,
d->m_eventParents, &QmlProfilerEventRelativesView::displayType); d->m_eventParents, &QmlProfilerStatisticsRelativesView::displayType);
connect(d->m_eventChildren, &QmlProfilerEventRelativesView::typeClicked, connect(d->m_eventChildren, &QmlProfilerStatisticsRelativesView::typeClicked,
d->m_eventTree, &QmlProfilerEventsMainView::selectType); d->m_eventTree, &QmlProfilerStatisticsMainView::selectType);
connect(d->m_eventParents, &QmlProfilerEventRelativesView::typeClicked, connect(d->m_eventParents, &QmlProfilerStatisticsRelativesView::typeClicked,
d->m_eventTree, &QmlProfilerEventsMainView::selectType); d->m_eventTree, &QmlProfilerStatisticsMainView::selectType);
connect(d->m_eventChildren, &QmlProfilerEventRelativesView::gotoSourceLocation, connect(d->m_eventChildren, &QmlProfilerStatisticsRelativesView::gotoSourceLocation,
this, &QmlProfilerEventsWidget::gotoSourceLocation); this, &QmlProfilerStatisticsView::gotoSourceLocation);
connect(d->m_eventParents, &QmlProfilerEventRelativesView::gotoSourceLocation, connect(d->m_eventParents, &QmlProfilerStatisticsRelativesView::gotoSourceLocation,
this, &QmlProfilerEventsWidget::gotoSourceLocation); this, &QmlProfilerStatisticsView::gotoSourceLocation);
// widget arrangement // widget arrangement
QVBoxLayout *groupLayout = new QVBoxLayout; QVBoxLayout *groupLayout = new QVBoxLayout;
@@ -249,32 +247,32 @@ QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent,
d->rangeStart = d->rangeEnd = -1; d->rangeStart = d->rangeEnd = -1;
} }
QmlProfilerEventsWidget::~QmlProfilerEventsWidget() QmlProfilerStatisticsView::~QmlProfilerStatisticsView()
{ {
delete d->modelProxy; delete d->modelProxy;
delete d; delete d;
} }
void QmlProfilerEventsWidget::clear() void QmlProfilerStatisticsView::clear()
{ {
d->m_eventTree->clear(); d->m_eventTree->clear();
d->m_eventChildren->clear(); d->m_eventChildren->clear();
d->m_eventParents->clear(); d->m_eventParents->clear();
} }
void QmlProfilerEventsWidget::restrictToRange(qint64 rangeStart, qint64 rangeEnd) void QmlProfilerStatisticsView::restrictToRange(qint64 rangeStart, qint64 rangeEnd)
{ {
d->rangeStart = rangeStart; d->rangeStart = rangeStart;
d->rangeEnd = rangeEnd; d->rangeEnd = rangeEnd;
d->modelProxy->limitToRange(rangeStart, rangeEnd); d->modelProxy->limitToRange(rangeStart, rangeEnd);
} }
QModelIndex QmlProfilerEventsWidget::selectedModelIndex() const QModelIndex QmlProfilerStatisticsView::selectedModelIndex() const
{ {
return d->m_eventTree->selectedModelIndex(); return d->m_eventTree->selectedModelIndex();
} }
void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev) void QmlProfilerStatisticsView::contextMenuEvent(QContextMenuEvent *ev)
{ {
QTC_ASSERT(d->m_viewContainer, return;); QTC_ASSERT(d->m_viewContainer, return;);
@@ -331,30 +329,30 @@ void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev)
} }
} }
bool QmlProfilerEventsWidget::mouseOnTable(const QPoint &position) const bool QmlProfilerStatisticsView::mouseOnTable(const QPoint &position) const
{ {
QPoint tableTopLeft = d->m_eventTree->mapToGlobal(QPoint(0,0)); QPoint tableTopLeft = d->m_eventTree->mapToGlobal(QPoint(0,0));
QPoint tableBottomRight = d->m_eventTree->mapToGlobal(QPoint(d->m_eventTree->width(), d->m_eventTree->height())); QPoint tableBottomRight = d->m_eventTree->mapToGlobal(QPoint(d->m_eventTree->width(), d->m_eventTree->height()));
return (position.x() >= tableTopLeft.x() && position.x() <= tableBottomRight.x() && position.y() >= tableTopLeft.y() && position.y() <= tableBottomRight.y()); return (position.x() >= tableTopLeft.x() && position.x() <= tableBottomRight.x() && position.y() >= tableTopLeft.y() && position.y() <= tableBottomRight.y());
} }
void QmlProfilerEventsWidget::copyTableToClipboard() const void QmlProfilerStatisticsView::copyTableToClipboard() const
{ {
d->m_eventTree->copyTableToClipboard(); d->m_eventTree->copyTableToClipboard();
} }
void QmlProfilerEventsWidget::copyRowToClipboard() const void QmlProfilerStatisticsView::copyRowToClipboard() const
{ {
d->m_eventTree->copyRowToClipboard(); d->m_eventTree->copyRowToClipboard();
} }
void QmlProfilerEventsWidget::selectByTypeId(int typeIndex) void QmlProfilerStatisticsView::selectByTypeId(int typeIndex)
{ {
if (d->m_eventTree->selectedTypeId() != typeIndex) if (d->m_eventTree->selectedTypeId() != typeIndex)
d->m_eventTree->selectType(typeIndex); d->m_eventTree->selectType(typeIndex);
} }
void QmlProfilerEventsWidget::onVisibleFeaturesChanged(quint64 features) void QmlProfilerStatisticsView::onVisibleFeaturesChanged(quint64 features)
{ {
for (int i = 0; i < MaximumRangeType; ++i) { for (int i = 0; i < MaximumRangeType; ++i) {
RangeType range = static_cast<RangeType>(i); RangeType range = static_cast<RangeType>(i);
@@ -365,32 +363,32 @@ void QmlProfilerEventsWidget::onVisibleFeaturesChanged(quint64 features)
d->modelProxy->limitToRange(d->rangeStart, d->rangeEnd); d->modelProxy->limitToRange(d->rangeStart, d->rangeEnd);
} }
bool QmlProfilerEventsWidget::isRestrictedToRange() const bool QmlProfilerStatisticsView::isRestrictedToRange() const
{ {
return d->rangeStart != -1 || d->rangeEnd != -1; return d->rangeStart != -1 || d->rangeEnd != -1;
} }
void QmlProfilerEventsWidget::setShowExtendedStatistics(bool show) void QmlProfilerStatisticsView::setShowExtendedStatistics(bool show)
{ {
d->m_eventTree->setShowExtendedStatistics(show); d->m_eventTree->setShowExtendedStatistics(show);
} }
bool QmlProfilerEventsWidget::showExtendedStatistics() const bool QmlProfilerStatisticsView::showExtendedStatistics() const
{ {
return d->m_eventTree->showExtendedStatistics(); return d->m_eventTree->showExtendedStatistics();
} }
class QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate class QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate
{ {
public: public:
QmlProfilerEventsMainViewPrivate(QmlProfilerEventsMainView *qq) : q(qq) {} QmlProfilerStatisticsMainViewPrivate(QmlProfilerStatisticsMainView *qq) : q(qq) {}
int getFieldCount(); int getFieldCount();
QString textForItem(QStandardItem *item, bool recursive = false) const; QString textForItem(QStandardItem *item, bool recursive = false) const;
QmlProfilerEventsMainView *q; QmlProfilerStatisticsMainView *q;
QmlProfilerEventsModelProxy *modelProxy; QmlProfilerEventsModelProxy *modelProxy;
QStandardItemModel *m_model; QStandardItemModel *m_model;
@@ -400,9 +398,9 @@ public:
int m_firstNumericColumn; int m_firstNumericColumn;
}; };
QmlProfilerEventsMainView::QmlProfilerEventsMainView(QWidget *parent, QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainView(
QmlProfilerEventsModelProxy *modelProxy) : QWidget *parent, QmlProfilerEventsModelProxy *modelProxy) :
Utils::TreeView(parent), d(new QmlProfilerEventsMainViewPrivate(this)) Utils::TreeView(parent), d(new QmlProfilerStatisticsMainViewPrivate(this))
{ {
setViewDefaults(this); setViewDefaults(this);
setObjectName(QLatin1String("QmlProfilerEventsTable")); setObjectName(QLatin1String("QmlProfilerEventsTable"));
@@ -412,13 +410,13 @@ QmlProfilerEventsMainView::QmlProfilerEventsMainView(QWidget *parent,
d->m_model = new QStandardItemModel(this); d->m_model = new QStandardItemModel(this);
d->m_model->setSortRole(SortRole); d->m_model->setSortRole(SortRole);
setModel(d->m_model); setModel(d->m_model);
connect(this, &QAbstractItemView::activated, this, &QmlProfilerEventsMainView::jumpToItem); connect(this, &QAbstractItemView::activated, this, &QmlProfilerStatisticsMainView::jumpToItem);
d->modelProxy = modelProxy; d->modelProxy = modelProxy;
connect(d->modelProxy, &QmlProfilerEventsModelProxy::dataAvailable, connect(d->modelProxy, &QmlProfilerEventsModelProxy::dataAvailable,
this, &QmlProfilerEventsMainView::buildModel); this, &QmlProfilerStatisticsMainView::buildModel);
connect(d->modelProxy, &QmlProfilerEventsModelProxy::notesAvailable, connect(d->modelProxy, &QmlProfilerEventsModelProxy::notesAvailable,
this, &QmlProfilerEventsMainView::updateNotes); this, &QmlProfilerStatisticsMainView::updateNotes);
d->m_firstNumericColumn = 0; d->m_firstNumericColumn = 0;
d->m_showExtendedStatistics = false; d->m_showExtendedStatistics = false;
@@ -438,14 +436,14 @@ QmlProfilerEventsMainView::QmlProfilerEventsMainView(QWidget *parent,
buildModel(); buildModel();
} }
QmlProfilerEventsMainView::~QmlProfilerEventsMainView() QmlProfilerStatisticsMainView::~QmlProfilerStatisticsMainView()
{ {
clear(); clear();
delete d->m_model; delete d->m_model;
delete d; delete d;
} }
void QmlProfilerEventsMainView::setFieldViewable(Fields field, bool show) void QmlProfilerStatisticsMainView::setFieldViewable(Fields field, bool show)
{ {
if (field < MaxFields) { if (field < MaxFields) {
int length = d->m_fieldShown.count(); int length = d->m_fieldShown.count();
@@ -458,7 +456,7 @@ void QmlProfilerEventsMainView::setFieldViewable(Fields field, bool show)
} }
void QmlProfilerEventsMainView::setHeaderLabels() void QmlProfilerStatisticsMainView::setHeaderLabels()
{ {
int fieldIndex = 0; int fieldIndex = 0;
d->m_firstNumericColumn = 0; d->m_firstNumericColumn = 0;
@@ -516,7 +514,7 @@ void QmlProfilerEventsMainView::setHeaderLabels()
} }
} }
void QmlProfilerEventsMainView::setShowExtendedStatistics(bool show) void QmlProfilerStatisticsMainView::setShowExtendedStatistics(bool show)
{ {
// Not checking if already set because we don't want the first call to skip // Not checking if already set because we don't want the first call to skip
d->m_showExtendedStatistics = show; d->m_showExtendedStatistics = show;
@@ -537,12 +535,12 @@ void QmlProfilerEventsMainView::setShowExtendedStatistics(bool show)
} }
} }
bool QmlProfilerEventsMainView::showExtendedStatistics() const bool QmlProfilerStatisticsMainView::showExtendedStatistics() const
{ {
return d->m_showExtendedStatistics; return d->m_showExtendedStatistics;
} }
void QmlProfilerEventsMainView::clear() void QmlProfilerStatisticsMainView::clear()
{ {
d->m_model->clear(); d->m_model->clear();
d->m_model->setColumnCount(d->getFieldCount()); d->m_model->setColumnCount(d->getFieldCount());
@@ -551,7 +549,7 @@ void QmlProfilerEventsMainView::clear()
setSortingEnabled(false); setSortingEnabled(false);
} }
int QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::getFieldCount() int QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate::getFieldCount()
{ {
int count = 0; int count = 0;
for (int i=0; i < m_fieldShown.count(); ++i) for (int i=0; i < m_fieldShown.count(); ++i)
@@ -560,7 +558,7 @@ int QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::getFieldCount()
return count; return count;
} }
void QmlProfilerEventsMainView::buildModel() void QmlProfilerStatisticsMainView::buildModel()
{ {
clear(); clear();
parseModelProxy(); parseModelProxy();
@@ -579,7 +577,7 @@ void QmlProfilerEventsMainView::buildModel()
collapseAll(); collapseAll();
} }
void QmlProfilerEventsMainView::updateNotes(int typeIndex) void QmlProfilerStatisticsMainView::updateNotes(int typeIndex)
{ {
const QHash<int, QmlProfilerEventsModelProxy::QmlEventStats> &eventList = const QHash<int, QmlProfilerEventsModelProxy::QmlEventStats> &eventList =
d->modelProxy->getData(); d->modelProxy->getData();
@@ -609,9 +607,10 @@ void QmlProfilerEventsMainView::updateNotes(int typeIndex)
} }
} }
void QmlProfilerEventsMainView::parseModelProxy() void QmlProfilerStatisticsMainView::parseModelProxy()
{ {
const QHash<int, QmlProfilerEventsModelProxy::QmlEventStats> &eventList = d->modelProxy->getData(); const QHash<int, QmlProfilerEventsModelProxy::QmlEventStats> &eventList =
d->modelProxy->getData();
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = d->modelProxy->getTypes(); const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = d->modelProxy->getTypes();
@@ -625,11 +624,11 @@ void QmlProfilerEventsMainView::parseModelProxy()
QList<QStandardItem *> newRow; QList<QStandardItem *> newRow;
if (d->m_fieldShown[Name]) if (d->m_fieldShown[Name])
newRow << new EventsViewItem(event.displayName.isEmpty() ? tr("<bytecode>") : newRow << new StatisticsViewItem(event.displayName.isEmpty() ? tr("<bytecode>") :
event.displayName); event.displayName);
if (d->m_fieldShown[Type]) { if (d->m_fieldShown[Type]) {
QString typeString = QmlProfilerEventsMainView::nameForType(event.rangeType); QString typeString = QmlProfilerStatisticsMainView::nameForType(event.rangeType);
QString toolTipText; QString toolTipText;
if (event.rangeType == Binding) { if (event.rangeType == Binding) {
if (event.detailType == (int)OptimizedBinding) { if (event.detailType == (int)OptimizedBinding) {
@@ -641,61 +640,62 @@ void QmlProfilerEventsMainView::parseModelProxy()
} }
} }
newRow << new EventsViewItem(typeString); newRow << new StatisticsViewItem(typeString);
newRow.last()->setData(QVariant(typeString)); newRow.last()->setData(QVariant(typeString));
if (!toolTipText.isEmpty()) if (!toolTipText.isEmpty())
newRow.last()->setToolTip(toolTipText); newRow.last()->setToolTip(toolTipText);
} }
if (d->m_fieldShown[TimeInPercent]) { if (d->m_fieldShown[TimeInPercent]) {
newRow << new EventsViewItem(QString::number(stats.percentOfTime,'f',2)+QLatin1String(" %")); newRow << new StatisticsViewItem(QString::number(stats.percentOfTime,'f',2)
+ QLatin1String(" %"));
newRow.last()->setData(QVariant(stats.percentOfTime)); newRow.last()->setData(QVariant(stats.percentOfTime));
} }
if (d->m_fieldShown[TotalTime]) { if (d->m_fieldShown[TotalTime]) {
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.duration)); newRow << new StatisticsViewItem(QmlProfilerDataModel::formatTime(stats.duration));
newRow.last()->setData(QVariant(stats.duration)); newRow.last()->setData(QVariant(stats.duration));
} }
if (d->m_fieldShown[SelfTimeInPercent]) { if (d->m_fieldShown[SelfTimeInPercent]) {
newRow << new EventsViewItem(QString::number(stats.percentSelf, 'f', 2) newRow << new StatisticsViewItem(QString::number(stats.percentSelf, 'f', 2)
+ QLatin1String(" %")); + QLatin1String(" %"));
newRow.last()->setData(QVariant(stats.percentSelf)); newRow.last()->setData(QVariant(stats.percentSelf));
} }
if (d->m_fieldShown[SelfTime]) { if (d->m_fieldShown[SelfTime]) {
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.durationSelf)); newRow << new StatisticsViewItem(QmlProfilerDataModel::formatTime(stats.durationSelf));
newRow.last()->setData(QVariant(stats.durationSelf)); newRow.last()->setData(QVariant(stats.durationSelf));
} }
if (d->m_fieldShown[CallCount]) { if (d->m_fieldShown[CallCount]) {
newRow << new EventsViewItem(QString::number(stats.calls)); newRow << new StatisticsViewItem(QString::number(stats.calls));
newRow.last()->setData(QVariant(stats.calls)); newRow.last()->setData(QVariant(stats.calls));
} }
if (d->m_fieldShown[TimePerCall]) { if (d->m_fieldShown[TimePerCall]) {
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.timePerCall)); newRow << new StatisticsViewItem(QmlProfilerDataModel::formatTime(stats.timePerCall));
newRow.last()->setData(QVariant(stats.timePerCall)); newRow.last()->setData(QVariant(stats.timePerCall));
} }
if (d->m_fieldShown[MedianTime]) { if (d->m_fieldShown[MedianTime]) {
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.medianTime)); newRow << new StatisticsViewItem(QmlProfilerDataModel::formatTime(stats.medianTime));
newRow.last()->setData(QVariant(stats.medianTime)); newRow.last()->setData(QVariant(stats.medianTime));
} }
if (d->m_fieldShown[MaxTime]) { if (d->m_fieldShown[MaxTime]) {
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.maxTime)); newRow << new StatisticsViewItem(QmlProfilerDataModel::formatTime(stats.maxTime));
newRow.last()->setData(QVariant(stats.maxTime)); newRow.last()->setData(QVariant(stats.maxTime));
} }
if (d->m_fieldShown[MinTime]) { if (d->m_fieldShown[MinTime]) {
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.minTime)); newRow << new StatisticsViewItem(QmlProfilerDataModel::formatTime(stats.minTime));
newRow.last()->setData(QVariant(stats.minTime)); newRow.last()->setData(QVariant(stats.minTime));
} }
if (d->m_fieldShown[Details]) { if (d->m_fieldShown[Details]) {
newRow << new EventsViewItem(event.data.isEmpty() ? tr("Source code not available") : newRow << new StatisticsViewItem(event.data.isEmpty() ?
event.data); tr("Source code not available") : event.data);
newRow.last()->setData(QVariant(event.data)); newRow.last()->setData(QVariant(event.data));
} }
@@ -718,7 +718,7 @@ void QmlProfilerEventsMainView::parseModelProxy()
} }
} }
QStandardItem *QmlProfilerEventsMainView::itemFromIndex(const QModelIndex &index) const QStandardItem *QmlProfilerStatisticsMainView::itemFromIndex(const QModelIndex &index) const
{ {
QStandardItem *indexItem = d->m_model->itemFromIndex(index); QStandardItem *indexItem = d->m_model->itemFromIndex(index);
if (indexItem->parent()) if (indexItem->parent())
@@ -728,25 +728,25 @@ QStandardItem *QmlProfilerEventsMainView::itemFromIndex(const QModelIndex &index
} }
QString QmlProfilerEventsMainView::nameForType(RangeType typeNumber) QString QmlProfilerStatisticsMainView::nameForType(RangeType typeNumber)
{ {
switch (typeNumber) { switch (typeNumber) {
case Painting: return QmlProfilerEventsMainView::tr("Paint"); case Painting: return QmlProfilerStatisticsMainView::tr("Paint");
case Compiling: return QmlProfilerEventsMainView::tr("Compile"); case Compiling: return QmlProfilerStatisticsMainView::tr("Compile");
case Creating: return QmlProfilerEventsMainView::tr("Create"); case Creating: return QmlProfilerStatisticsMainView::tr("Create");
case Binding: return QmlProfilerEventsMainView::tr("Binding"); case Binding: return QmlProfilerStatisticsMainView::tr("Binding");
case HandlingSignal: return QmlProfilerEventsMainView::tr("Signal"); case HandlingSignal: return QmlProfilerStatisticsMainView::tr("Signal");
case Javascript: return QmlProfilerEventsMainView::tr("JavaScript"); case Javascript: return QmlProfilerStatisticsMainView::tr("JavaScript");
default: return QString(); default: return QString();
} }
} }
void QmlProfilerEventsMainView::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd) void QmlProfilerStatisticsMainView::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd)
{ {
d->modelProxy->limitToRange(rangeStart, rangeEnd); d->modelProxy->limitToRange(rangeStart, rangeEnd);
} }
int QmlProfilerEventsMainView::selectedTypeId() const int QmlProfilerStatisticsMainView::selectedTypeId() const
{ {
QModelIndex index = selectedModelIndex(); QModelIndex index = selectedModelIndex();
if (!index.isValid()) if (!index.isValid())
@@ -755,7 +755,7 @@ int QmlProfilerEventsMainView::selectedTypeId() const
return item->data(TypeIdRole).toInt(); return item->data(TypeIdRole).toInt();
} }
void QmlProfilerEventsMainView::jumpToItem(const QModelIndex &index) void QmlProfilerStatisticsMainView::jumpToItem(const QModelIndex &index)
{ {
QStandardItem *infoItem = itemFromIndex(index); QStandardItem *infoItem = itemFromIndex(index);
@@ -768,7 +768,7 @@ void QmlProfilerEventsMainView::jumpToItem(const QModelIndex &index)
emit typeSelected(infoItem->data(TypeIdRole).toInt()); emit typeSelected(infoItem->data(TypeIdRole).toInt());
} }
void QmlProfilerEventsMainView::selectItem(const QStandardItem *item) void QmlProfilerStatisticsMainView::selectItem(const QStandardItem *item)
{ {
// If the same item is already selected, don't reselect it. // If the same item is already selected, don't reselect it.
QModelIndex index = d->m_model->indexFromItem(item); QModelIndex index = d->m_model->indexFromItem(item);
@@ -780,7 +780,7 @@ void QmlProfilerEventsMainView::selectItem(const QStandardItem *item)
} }
} }
void QmlProfilerEventsMainView::selectType(int typeIndex) void QmlProfilerStatisticsMainView::selectType(int typeIndex)
{ {
for (int i=0; i<d->m_model->rowCount(); i++) { for (int i=0; i<d->m_model->rowCount(); i++) {
QStandardItem *infoItem = d->m_model->item(i, 0); QStandardItem *infoItem = d->m_model->item(i, 0);
@@ -791,7 +791,7 @@ void QmlProfilerEventsMainView::selectType(int typeIndex)
} }
} }
QModelIndex QmlProfilerEventsMainView::selectedModelIndex() const QModelIndex QmlProfilerStatisticsMainView::selectedModelIndex() const
{ {
QModelIndexList sel = selectedIndexes(); QModelIndexList sel = selectedIndexes();
if (sel.isEmpty()) if (sel.isEmpty())
@@ -800,7 +800,8 @@ QModelIndex QmlProfilerEventsMainView::selectedModelIndex() const
return sel.first(); return sel.first();
} }
QString QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::textForItem(QStandardItem *item, bool recursive) const QString QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate::textForItem(
QStandardItem *item, bool recursive) const
{ {
QString str; QString str;
@@ -816,7 +817,8 @@ QString QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::textForItem
// item's data // item's data
int colCount = m_model->columnCount(); int colCount = m_model->columnCount();
for (int j = 0; j < colCount; ++j) { for (int j = 0; j < colCount; ++j) {
QStandardItem *colItem = item->parent() ? item->parent()->child(item->row(),j) : m_model->item(item->row(),j); QStandardItem *colItem = item->parent() ? item->parent()->child(item->row(),j) :
m_model->item(item->row(),j);
str += colItem->data(Qt::DisplayRole).toString(); str += colItem->data(Qt::DisplayRole).toString();
if (j < colCount-1) str += QLatin1Char('\t'); if (j < colCount-1) str += QLatin1Char('\t');
} }
@@ -830,7 +832,7 @@ QString QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::textForItem
return str; return str;
} }
void QmlProfilerEventsMainView::copyTableToClipboard() const void QmlProfilerStatisticsMainView::copyTableToClipboard() const
{ {
QString str; QString str;
// headers // headers
@@ -852,7 +854,7 @@ void QmlProfilerEventsMainView::copyTableToClipboard() const
clipboard->setText(str, QClipboard::Clipboard); clipboard->setText(str, QClipboard::Clipboard);
} }
void QmlProfilerEventsMainView::copyRowToClipboard() const void QmlProfilerStatisticsMainView::copyRowToClipboard() const
{ {
QString str; QString str;
str = d->textForItem(d->m_model->itemFromIndex(selectedModelIndex()), false); str = d->textForItem(d->m_model->itemFromIndex(selectedModelIndex()), false);
@@ -862,20 +864,20 @@ void QmlProfilerEventsMainView::copyRowToClipboard() const
clipboard->setText(str, QClipboard::Clipboard); clipboard->setText(str, QClipboard::Clipboard);
} }
class QmlProfilerEventRelativesView::QmlProfilerEventParentsViewPrivate class QmlProfilerStatisticsRelativesView::QmlProfilerStatisticsRelativesViewPrivate
{ {
public: public:
QmlProfilerEventParentsViewPrivate(QmlProfilerEventRelativesView *qq):q(qq) {} QmlProfilerStatisticsRelativesViewPrivate(QmlProfilerStatisticsRelativesView *qq):q(qq) {}
~QmlProfilerEventParentsViewPrivate() {} ~QmlProfilerStatisticsRelativesViewPrivate() {}
QmlProfilerEventRelativesModelProxy *modelProxy; QmlProfilerEventRelativesModelProxy *modelProxy;
QmlProfilerEventRelativesView *q; QmlProfilerStatisticsRelativesView *q;
}; };
QmlProfilerEventRelativesView::QmlProfilerEventRelativesView( QmlProfilerStatisticsRelativesView::QmlProfilerStatisticsRelativesView(
QmlProfilerEventRelativesModelProxy *modelProxy, QWidget *parent) : QmlProfilerEventRelativesModelProxy *modelProxy, QWidget *parent) :
Utils::TreeView(parent), d(new QmlProfilerEventParentsViewPrivate(this)) Utils::TreeView(parent), d(new QmlProfilerStatisticsRelativesViewPrivate(this))
{ {
setViewDefaults(this); setViewDefaults(this);
setSortingEnabled(false); setSortingEnabled(false);
@@ -886,19 +888,20 @@ QmlProfilerEventRelativesView::QmlProfilerEventRelativesView(
setRootIsDecorated(false); setRootIsDecorated(false);
updateHeader(); updateHeader();
connect(this, &QAbstractItemView::activated, this, &QmlProfilerEventRelativesView::jumpToItem); connect(this, &QAbstractItemView::activated,
this, &QmlProfilerStatisticsRelativesView::jumpToItem);
// Clear when new data available as the selection may be invalid now. // Clear when new data available as the selection may be invalid now.
connect(d->modelProxy, &QmlProfilerEventRelativesModelProxy::dataAvailable, connect(d->modelProxy, &QmlProfilerEventRelativesModelProxy::dataAvailable,
this, &QmlProfilerEventRelativesView::clear); this, &QmlProfilerStatisticsRelativesView::clear);
} }
QmlProfilerEventRelativesView::~QmlProfilerEventRelativesView() QmlProfilerStatisticsRelativesView::~QmlProfilerStatisticsRelativesView()
{ {
delete d; delete d;
} }
void QmlProfilerEventRelativesView::displayType(int typeIndex) void QmlProfilerStatisticsRelativesView::displayType(int typeIndex)
{ {
rebuildTree(d->modelProxy->getData(typeIndex)); rebuildTree(d->modelProxy->getData(typeIndex));
@@ -908,7 +911,7 @@ void QmlProfilerEventRelativesView::displayType(int typeIndex)
sortByColumn(2); sortByColumn(2);
} }
void QmlProfilerEventRelativesView::rebuildTree( void QmlProfilerStatisticsRelativesView::rebuildTree(
const QmlProfilerEventRelativesModelProxy::QmlEventRelativesMap &eventMap) const QmlProfilerEventRelativesModelProxy::QmlEventRelativesMap &eventMap)
{ {
Q_ASSERT(treeModel()); Q_ASSERT(treeModel());
@@ -928,19 +931,20 @@ void QmlProfilerEventRelativesView::rebuildTree(
// ToDo: here we were going to search for the data in the other modelproxy // ToDo: here we were going to search for the data in the other modelproxy
// maybe we should store the data in this proxy and get it here // maybe we should store the data in this proxy and get it here
// no indirections at this level of abstraction! // no indirections at this level of abstraction!
newRow << new EventsViewItem(type.displayName.isEmpty() ? tr("<bytecode>") : newRow << new StatisticsViewItem(type.displayName.isEmpty() ? tr("<bytecode>") :
type.displayName); type.displayName);
newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(type.rangeType)); newRow << new StatisticsViewItem(QmlProfilerStatisticsMainView::nameForType(
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(event.duration)); type.rangeType));
newRow << new EventsViewItem(QString::number(event.calls)); newRow << new StatisticsViewItem(QmlProfilerDataModel::formatTime(event.duration));
newRow << new EventsViewItem(type.data.isEmpty() ? tr("Source code not available") : newRow << new StatisticsViewItem(QString::number(event.calls));
newRow << new StatisticsViewItem(type.data.isEmpty() ? tr("Source code not available") :
type.data); type.data);
newRow.at(0)->setData(QVariant(typeIndex), TypeIdRole); newRow.at(0)->setData(QVariant(typeIndex), TypeIdRole);
newRow.at(0)->setData(QVariant(type.location.filename),FilenameRole); newRow.at(0)->setData(QVariant(type.location.filename),FilenameRole);
newRow.at(0)->setData(QVariant(type.location.line),LineRole); newRow.at(0)->setData(QVariant(type.location.line),LineRole);
newRow.at(0)->setData(QVariant(type.location.column),ColumnRole); newRow.at(0)->setData(QVariant(type.location.column),ColumnRole);
newRow.at(1)->setData(QVariant(QmlProfilerEventsMainView::nameForType(type.rangeType))); newRow.at(1)->setData(QVariant(QmlProfilerStatisticsMainView::nameForType(type.rangeType)));
newRow.at(2)->setData(QVariant(event.duration)); newRow.at(2)->setData(QVariant(event.duration));
newRow.at(3)->setData(QVariant(event.calls)); newRow.at(3)->setData(QVariant(event.calls));
newRow.at(4)->setData(QVariant(type.data)); newRow.at(4)->setData(QVariant(type.data));
@@ -959,7 +963,7 @@ void QmlProfilerEventRelativesView::rebuildTree(
} }
} }
void QmlProfilerEventRelativesView::clear() void QmlProfilerStatisticsRelativesView::clear()
{ {
if (treeModel()) { if (treeModel()) {
treeModel()->clear(); treeModel()->clear();
@@ -967,7 +971,7 @@ void QmlProfilerEventRelativesView::clear()
} }
} }
void QmlProfilerEventRelativesView::updateHeader() void QmlProfilerStatisticsRelativesView::updateHeader()
{ {
bool calleesView = qobject_cast<QmlProfilerEventChildrenModelProxy *>(d->modelProxy) != 0; bool calleesView = qobject_cast<QmlProfilerEventChildrenModelProxy *>(d->modelProxy) != 0;
@@ -994,12 +998,12 @@ void QmlProfilerEventRelativesView::updateHeader()
} }
} }
QStandardItemModel *QmlProfilerEventRelativesView::treeModel() QStandardItemModel *QmlProfilerStatisticsRelativesView::treeModel()
{ {
return qobject_cast<QStandardItemModel *>(model()); return qobject_cast<QStandardItemModel *>(model());
} }
void QmlProfilerEventRelativesView::jumpToItem(const QModelIndex &index) void QmlProfilerStatisticsRelativesView::jumpToItem(const QModelIndex &index)
{ {
if (treeModel()) { if (treeModel()) {
QStandardItem *infoItem = treeModel()->item(index.row(), 0); QStandardItem *infoItem = treeModel()->item(index.row(), 0);

View File

@@ -28,12 +28,13 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef QMLPROFILEREVENTVIEW_H #ifndef QMLPROFILERSTATISTICSVIEW_H
#define QMLPROFILEREVENTVIEW_H #define QMLPROFILERSTATISTICSVIEW_H
#include "qmlprofilermodelmanager.h" #include "qmlprofilermodelmanager.h"
#include "qmlprofilereventsmodelproxy.h" #include "qmlprofilereventsmodelproxy.h"
#include "qmlprofilerviewmanager.h" #include "qmlprofilerviewmanager.h"
#include "qmlprofilereventsview.h"
#include <qmldebug/qmlprofilereventtypes.h> #include <qmldebug/qmlprofilereventtypes.h>
#include <analyzerbase/ianalyzertool.h> #include <analyzerbase/ianalyzertool.h>
@@ -44,9 +45,8 @@
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
class QmlProfilerEventsMainView; class QmlProfilerStatisticsMainView;
class QmlProfilerEventChildrenView; class QmlProfilerStatisticsRelativesView;
class QmlProfilerEventRelativesView;
enum ItemRole { enum ItemRole {
SortRole = Qt::UserRole + 1, // Sort by data, not by displayed string SortRole = Qt::UserRole + 1, // Sort by data, not by displayed string
@@ -77,27 +77,26 @@ enum Fields {
MaxFields MaxFields
}; };
class QmlProfilerEventsWidget : public QWidget class QmlProfilerStatisticsView : public QmlProfilerEventsView
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QmlProfilerEventsWidget(QWidget *parent, explicit QmlProfilerStatisticsView(QWidget *parent, QmlProfilerTool *profilerTool,
QmlProfilerTool *profilerTool,
QmlProfilerViewManager *container, QmlProfilerViewManager *container,
QmlProfilerModelManager *profilerModelManager ); QmlProfilerModelManager *profilerModelManager);
~QmlProfilerEventsWidget(); ~QmlProfilerStatisticsView();
void clear(); void clear() override;
void restrictToRange(qint64 rangeStart, qint64 rangeEnd); void restrictToRange(qint64 rangeStart, qint64 rangeEnd) override;
bool isRestrictedToRange() const; bool isRestrictedToRange() const override;
signals: signals:
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber); void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
void typeSelected(int typeIndex); void typeSelected(int typeIndex);
public slots: public slots:
void selectByTypeId(int typeIndex); void selectByTypeId(int typeIndex) override;
void onVisibleFeaturesChanged(quint64 features); void onVisibleFeaturesChanged(quint64 features) override;
protected: protected:
void contextMenuEvent(QContextMenuEvent *ev); void contextMenuEvent(QContextMenuEvent *ev);
@@ -110,17 +109,17 @@ private:
void setShowExtendedStatistics(bool show); void setShowExtendedStatistics(bool show);
bool showExtendedStatistics() const; bool showExtendedStatistics() const;
class QmlProfilerEventsWidgetPrivate; class QmlProfilerStatisticsViewPrivate;
QmlProfilerEventsWidgetPrivate *d; QmlProfilerStatisticsViewPrivate *d;
}; };
class QmlProfilerEventsMainView : public Utils::TreeView class QmlProfilerStatisticsMainView : public Utils::TreeView
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QmlProfilerEventsMainView(QWidget *parent, explicit QmlProfilerStatisticsMainView(QWidget *parent,
QmlProfilerEventsModelProxy *modelProxy); QmlProfilerEventsModelProxy *modelProxy);
~QmlProfilerEventsMainView(); ~QmlProfilerStatisticsMainView();
void setFieldViewable(Fields field, bool show); void setFieldViewable(Fields field, bool show);
void setShowAnonymousEvents( bool showThem ); void setShowAnonymousEvents( bool showThem );
@@ -156,18 +155,18 @@ private:
QStandardItem *itemFromIndex(const QModelIndex &index) const; QStandardItem *itemFromIndex(const QModelIndex &index) const;
private: private:
class QmlProfilerEventsMainViewPrivate; class QmlProfilerStatisticsMainViewPrivate;
QmlProfilerEventsMainViewPrivate *d; QmlProfilerStatisticsMainViewPrivate *d;
}; };
class QmlProfilerEventRelativesView : public Utils::TreeView class QmlProfilerStatisticsRelativesView : public Utils::TreeView
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QmlProfilerEventRelativesView(QmlProfilerEventRelativesModelProxy *modelProxy, explicit QmlProfilerStatisticsRelativesView(QmlProfilerEventRelativesModelProxy *modelProxy,
QWidget *parent ); QWidget *parent );
~QmlProfilerEventRelativesView(); ~QmlProfilerStatisticsRelativesView();
signals: signals:
void typeClicked(int typeIndex); void typeClicked(int typeIndex);
@@ -183,11 +182,11 @@ private:
void updateHeader(); void updateHeader();
QStandardItemModel *treeModel(); QStandardItemModel *treeModel();
class QmlProfilerEventParentsViewPrivate; class QmlProfilerStatisticsRelativesViewPrivate;
QmlProfilerEventParentsViewPrivate *d; QmlProfilerStatisticsRelativesViewPrivate *d;
}; };
} // namespace Internal } // namespace Internal
} // namespace QmlProfiler } // namespace QmlProfiler
#endif // QMLPROFILEREVENTVIEW_H #endif // QMLPROFILERSTATISTICSVIEW_H

View File

@@ -248,11 +248,11 @@ void QmlProfilerTraceView::showContextMenu(QPoint position)
menu.addSeparator(); menu.addSeparator();
QAction *getLocalStatsAction = menu.addAction(tr("Limit Events Pane to Current Range")); QAction *getLocalStatsAction = menu.addAction(tr("Limit Statistics Pane to Current Range"));
if (!d->m_viewContainer->hasValidSelection()) if (!d->m_viewContainer->hasValidSelection())
getLocalStatsAction->setEnabled(false); getLocalStatsAction->setEnabled(false);
QAction *getGlobalStatsAction = menu.addAction(tr("Show Full Range in Events Pane")); QAction *getGlobalStatsAction = menu.addAction(tr("Show Full Range in Statistics Pane"));
if (!d->m_viewContainer->isEventsRestrictedToRange()) if (!d->m_viewContainer->isEventsRestrictedToRange())
getGlobalStatsAction->setEnabled(false); getGlobalStatsAction->setEnabled(false);

View File

@@ -31,7 +31,7 @@
#include "qmlprofilerviewmanager.h" #include "qmlprofilerviewmanager.h"
#include "qmlprofilertraceview.h" #include "qmlprofilertraceview.h"
#include "qmlprofilereventview.h" #include "qmlprofilerstatisticsview.h"
#include "qmlprofilertool.h" #include "qmlprofilertool.h"
#include "qmlprofilerstatemanager.h" #include "qmlprofilerstatemanager.h"
#include "qmlprofilermodelmanager.h" #include "qmlprofilermodelmanager.h"
@@ -54,7 +54,7 @@ public:
QDockWidget *timelineDock; QDockWidget *timelineDock;
QmlProfilerTraceView *traceView; QmlProfilerTraceView *traceView;
QmlProfilerEventsWidget *eventsView; QmlProfilerStatisticsView *eventsView;
QmlProfilerStateManager *profilerState; QmlProfilerStateManager *profilerState;
QmlProfilerModelManager *profilerModelManager; QmlProfilerModelManager *profilerModelManager;
QmlProfilerTool *profilerTool; QmlProfilerTool *profilerTool;
@@ -96,17 +96,17 @@ void QmlProfilerViewManager::createViews()
connect(d->traceView, &QmlProfilerTraceView::gotoSourceLocation, connect(d->traceView, &QmlProfilerTraceView::gotoSourceLocation,
this, &QmlProfilerViewManager::gotoSourceLocation); this, &QmlProfilerViewManager::gotoSourceLocation);
d->eventsView = new QmlProfilerEventsWidget(mw, d->profilerTool, this, d->eventsView = new QmlProfilerStatisticsView(mw, d->profilerTool, this,
d->profilerModelManager); d->profilerModelManager);
d->eventsView->setWindowTitle(tr("Events")); d->eventsView->setWindowTitle(tr("Statistics"));
connect(d->eventsView, &QmlProfilerEventsWidget::gotoSourceLocation, connect(d->eventsView, &QmlProfilerStatisticsView::gotoSourceLocation,
this, &QmlProfilerViewManager::gotoSourceLocation); this, &QmlProfilerViewManager::gotoSourceLocation);
connect(d->eventsView, &QmlProfilerEventsWidget::typeSelected, connect(d->eventsView, &QmlProfilerStatisticsView::typeSelected,
d->traceView, &QmlProfilerTraceView::selectByTypeId); d->traceView, &QmlProfilerTraceView::selectByTypeId);
connect(d->traceView, &QmlProfilerTraceView::typeSelected, connect(d->traceView, &QmlProfilerTraceView::typeSelected,
d->eventsView, &QmlProfilerEventsWidget::selectByTypeId); d->eventsView, &QmlProfilerStatisticsView::selectByTypeId);
connect(d->profilerModelManager, &QmlProfilerModelManager::visibleFeaturesChanged, connect(d->profilerModelManager, &QmlProfilerModelManager::visibleFeaturesChanged,
d->eventsView, &QmlProfilerEventsWidget::onVisibleFeaturesChanged); d->eventsView, &QmlProfilerStatisticsView::onVisibleFeaturesChanged);
QDockWidget *eventsDock = AnalyzerManager::createDockWidget QDockWidget *eventsDock = AnalyzerManager::createDockWidget
(Constants::QmlProfilerToolId, d->eventsView); (Constants::QmlProfilerToolId, d->eventsView);