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

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

View File

@@ -30,7 +30,7 @@ QtcPlugin {
"qmlprofilerdatamodel.cpp", "qmlprofilerdatamodel.h",
"qmlprofilerdetailsrewriter.cpp", "qmlprofilerdetailsrewriter.h",
"qmlprofilereventsmodelproxy.cpp", "qmlprofilereventsmodelproxy.h",
"qmlprofilereventview.cpp", "qmlprofilereventview.h",
"qmlprofilereventsview.h",
"qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h",
"qmlprofilernotesmodel.cpp", "qmlprofilernotesmodel.h",
"qmlprofileroptionspage.cpp", "qmlprofileroptionspage.h",
@@ -42,6 +42,7 @@ QtcPlugin {
"qmlprofilersettings.cpp", "qmlprofilersettings.h",
"qmlprofilerstatemanager.cpp", "qmlprofilerstatemanager.h",
"qmlprofilerstatewidget.cpp", "qmlprofilerstatewidget.h",
"qmlprofilerstatisticsview.cpp", "qmlprofilerstatisticsview.h",
"qmlprofilertimelinemodel.cpp", "qmlprofilertimelinemodel.h",
"qmlprofilertimelinemodelfactory.cpp", "qmlprofilertimelinemodelfactory.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 <QHash>
@@ -67,23 +67,23 @@ struct Colors {
struct RootEventType : public QmlProfilerDataModel::QmlEventTypeData {
RootEventType()
{
QString rootEventName = QmlProfilerEventsMainView::tr("<program>");
QString rootEventName = QmlProfilerStatisticsMainView::tr("<program>");
displayName = rootEventName;
location = QmlEventLocation(rootEventName, 1, 1);
message = MaximumMessage;
rangeType = MaximumRangeType;
detailType = -1;
data = QmlProfilerEventsMainView::tr("Main Program");
data = QmlProfilerStatisticsMainView::tr("Main Program");
}
};
Q_GLOBAL_STATIC(Colors, colors)
Q_GLOBAL_STATIC(RootEventType, rootEventType)
class EventsViewItem : public QStandardItem
class StatisticsViewItem : public QStandardItem
{
public:
EventsViewItem(const QString &text) : QStandardItem(text) {}
StatisticsViewItem(const QString &text) : QStandardItem(text) {}
virtual bool operator<(const QStandardItem &other) const
{
@@ -109,20 +109,20 @@ public:
}
};
class QmlProfilerEventsWidget::QmlProfilerEventsWidgetPrivate
class QmlProfilerStatisticsView::QmlProfilerStatisticsViewPrivate
{
public:
QmlProfilerEventsWidgetPrivate(QmlProfilerEventsWidget *qq):q(qq) {}
~QmlProfilerEventsWidgetPrivate() {}
QmlProfilerStatisticsViewPrivate(QmlProfilerStatisticsView *qq) : q(qq) {}
~QmlProfilerStatisticsViewPrivate() {}
QmlProfilerEventsWidget *q;
QmlProfilerStatisticsView *q;
QmlProfilerTool *m_profilerTool;
QmlProfilerViewManager *m_viewContainer;
QmlProfilerEventsMainView *m_eventTree;
QmlProfilerEventRelativesView *m_eventChildren;
QmlProfilerEventRelativesView *m_eventParents;
QmlProfilerStatisticsMainView *m_eventTree;
QmlProfilerStatisticsRelativesView *m_eventChildren;
QmlProfilerStatisticsRelativesView *m_eventParents;
QmlProfilerEventsModelProxy *modelProxy;
qint64 rangeStart;
@@ -190,41 +190,39 @@ static void getSourceLocation(QStandardItem *infoItem,
receiver(fileName, line, column);
}
QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent,
QmlProfilerTool *profilerTool,
QmlProfilerViewManager *container,
QmlProfilerModelManager *profilerModelManager )
: QWidget(parent), d(new QmlProfilerEventsWidgetPrivate(this))
QmlProfilerStatisticsView::QmlProfilerStatisticsView(QWidget *parent, QmlProfilerTool *profilerTool,
QmlProfilerViewManager *container,
QmlProfilerModelManager *profilerModelManager )
: QmlProfilerEventsView(parent), d(new QmlProfilerStatisticsViewPrivate(this))
{
setObjectName(QLatin1String("QmlProfilerEventsView"));
setObjectName(QLatin1String("QmlProfilerStatisticsView"));
d->modelProxy = new QmlProfilerEventsModelProxy(profilerModelManager, this);
d->m_eventTree = new QmlProfilerEventsMainView(this, d->modelProxy);
connect(d->m_eventTree, &QmlProfilerEventsMainView::gotoSourceLocation,
this, &QmlProfilerEventsWidget::gotoSourceLocation);
connect(d->m_eventTree, &QmlProfilerEventsMainView::typeSelected,
this, &QmlProfilerEventsWidget::typeSelected);
d->m_eventTree = new QmlProfilerStatisticsMainView(this, d->modelProxy);
connect(d->m_eventTree, &QmlProfilerStatisticsMainView::gotoSourceLocation,
this, &QmlProfilerStatisticsView::gotoSourceLocation);
connect(d->m_eventTree, &QmlProfilerStatisticsMainView::typeSelected,
this, &QmlProfilerStatisticsView::typeSelected);
d->m_eventChildren = new QmlProfilerEventRelativesView(
d->m_eventChildren = new QmlProfilerStatisticsRelativesView(
new QmlProfilerEventChildrenModelProxy(profilerModelManager, d->modelProxy, this),
this);
d->m_eventParents = new QmlProfilerEventRelativesView(
d->m_eventParents = new QmlProfilerStatisticsRelativesView(
new QmlProfilerEventParentsModelProxy(profilerModelManager, d->modelProxy, this),
this);
connect(d->m_eventTree, &QmlProfilerEventsMainView::typeSelected,
d->m_eventChildren, &QmlProfilerEventRelativesView::displayType);
connect(d->m_eventTree, &QmlProfilerEventsMainView::typeSelected,
d->m_eventParents, &QmlProfilerEventRelativesView::displayType);
connect(d->m_eventChildren, &QmlProfilerEventRelativesView::typeClicked,
d->m_eventTree, &QmlProfilerEventsMainView::selectType);
connect(d->m_eventParents, &QmlProfilerEventRelativesView::typeClicked,
d->m_eventTree, &QmlProfilerEventsMainView::selectType);
connect(d->m_eventChildren, &QmlProfilerEventRelativesView::gotoSourceLocation,
this, &QmlProfilerEventsWidget::gotoSourceLocation);
connect(d->m_eventParents, &QmlProfilerEventRelativesView::gotoSourceLocation,
this, &QmlProfilerEventsWidget::gotoSourceLocation);
connect(d->m_eventTree, &QmlProfilerStatisticsMainView::typeSelected,
d->m_eventChildren, &QmlProfilerStatisticsRelativesView::displayType);
connect(d->m_eventTree, &QmlProfilerStatisticsMainView::typeSelected,
d->m_eventParents, &QmlProfilerStatisticsRelativesView::displayType);
connect(d->m_eventChildren, &QmlProfilerStatisticsRelativesView::typeClicked,
d->m_eventTree, &QmlProfilerStatisticsMainView::selectType);
connect(d->m_eventParents, &QmlProfilerStatisticsRelativesView::typeClicked,
d->m_eventTree, &QmlProfilerStatisticsMainView::selectType);
connect(d->m_eventChildren, &QmlProfilerStatisticsRelativesView::gotoSourceLocation,
this, &QmlProfilerStatisticsView::gotoSourceLocation);
connect(d->m_eventParents, &QmlProfilerStatisticsRelativesView::gotoSourceLocation,
this, &QmlProfilerStatisticsView::gotoSourceLocation);
// widget arrangement
QVBoxLayout *groupLayout = new QVBoxLayout;
@@ -249,32 +247,32 @@ QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent,
d->rangeStart = d->rangeEnd = -1;
}
QmlProfilerEventsWidget::~QmlProfilerEventsWidget()
QmlProfilerStatisticsView::~QmlProfilerStatisticsView()
{
delete d->modelProxy;
delete d;
}
void QmlProfilerEventsWidget::clear()
void QmlProfilerStatisticsView::clear()
{
d->m_eventTree->clear();
d->m_eventChildren->clear();
d->m_eventParents->clear();
}
void QmlProfilerEventsWidget::restrictToRange(qint64 rangeStart, qint64 rangeEnd)
void QmlProfilerStatisticsView::restrictToRange(qint64 rangeStart, qint64 rangeEnd)
{
d->rangeStart = rangeStart;
d->rangeEnd = rangeEnd;
d->modelProxy->limitToRange(rangeStart, rangeEnd);
}
QModelIndex QmlProfilerEventsWidget::selectedModelIndex() const
QModelIndex QmlProfilerStatisticsView::selectedModelIndex() const
{
return d->m_eventTree->selectedModelIndex();
}
void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev)
void QmlProfilerStatisticsView::contextMenuEvent(QContextMenuEvent *ev)
{
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 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());
}
void QmlProfilerEventsWidget::copyTableToClipboard() const
void QmlProfilerStatisticsView::copyTableToClipboard() const
{
d->m_eventTree->copyTableToClipboard();
}
void QmlProfilerEventsWidget::copyRowToClipboard() const
void QmlProfilerStatisticsView::copyRowToClipboard() const
{
d->m_eventTree->copyRowToClipboard();
}
void QmlProfilerEventsWidget::selectByTypeId(int typeIndex)
void QmlProfilerStatisticsView::selectByTypeId(int typeIndex)
{
if (d->m_eventTree->selectedTypeId() != typeIndex)
d->m_eventTree->selectType(typeIndex);
}
void QmlProfilerEventsWidget::onVisibleFeaturesChanged(quint64 features)
void QmlProfilerStatisticsView::onVisibleFeaturesChanged(quint64 features)
{
for (int i = 0; i < MaximumRangeType; ++i) {
RangeType range = static_cast<RangeType>(i);
@@ -365,32 +363,32 @@ void QmlProfilerEventsWidget::onVisibleFeaturesChanged(quint64 features)
d->modelProxy->limitToRange(d->rangeStart, d->rangeEnd);
}
bool QmlProfilerEventsWidget::isRestrictedToRange() const
bool QmlProfilerStatisticsView::isRestrictedToRange() const
{
return d->rangeStart != -1 || d->rangeEnd != -1;
}
void QmlProfilerEventsWidget::setShowExtendedStatistics(bool show)
void QmlProfilerStatisticsView::setShowExtendedStatistics(bool show)
{
d->m_eventTree->setShowExtendedStatistics(show);
}
bool QmlProfilerEventsWidget::showExtendedStatistics() const
bool QmlProfilerStatisticsView::showExtendedStatistics() const
{
return d->m_eventTree->showExtendedStatistics();
}
class QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate
class QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate
{
public:
QmlProfilerEventsMainViewPrivate(QmlProfilerEventsMainView *qq) : q(qq) {}
QmlProfilerStatisticsMainViewPrivate(QmlProfilerStatisticsMainView *qq) : q(qq) {}
int getFieldCount();
QString textForItem(QStandardItem *item, bool recursive = false) const;
QmlProfilerEventsMainView *q;
QmlProfilerStatisticsMainView *q;
QmlProfilerEventsModelProxy *modelProxy;
QStandardItemModel *m_model;
@@ -400,9 +398,9 @@ public:
int m_firstNumericColumn;
};
QmlProfilerEventsMainView::QmlProfilerEventsMainView(QWidget *parent,
QmlProfilerEventsModelProxy *modelProxy) :
Utils::TreeView(parent), d(new QmlProfilerEventsMainViewPrivate(this))
QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainView(
QWidget *parent, QmlProfilerEventsModelProxy *modelProxy) :
Utils::TreeView(parent), d(new QmlProfilerStatisticsMainViewPrivate(this))
{
setViewDefaults(this);
setObjectName(QLatin1String("QmlProfilerEventsTable"));
@@ -412,13 +410,13 @@ QmlProfilerEventsMainView::QmlProfilerEventsMainView(QWidget *parent,
d->m_model = new QStandardItemModel(this);
d->m_model->setSortRole(SortRole);
setModel(d->m_model);
connect(this, &QAbstractItemView::activated, this, &QmlProfilerEventsMainView::jumpToItem);
connect(this, &QAbstractItemView::activated, this, &QmlProfilerStatisticsMainView::jumpToItem);
d->modelProxy = modelProxy;
connect(d->modelProxy, &QmlProfilerEventsModelProxy::dataAvailable,
this, &QmlProfilerEventsMainView::buildModel);
this, &QmlProfilerStatisticsMainView::buildModel);
connect(d->modelProxy, &QmlProfilerEventsModelProxy::notesAvailable,
this, &QmlProfilerEventsMainView::updateNotes);
this, &QmlProfilerStatisticsMainView::updateNotes);
d->m_firstNumericColumn = 0;
d->m_showExtendedStatistics = false;
@@ -438,14 +436,14 @@ QmlProfilerEventsMainView::QmlProfilerEventsMainView(QWidget *parent,
buildModel();
}
QmlProfilerEventsMainView::~QmlProfilerEventsMainView()
QmlProfilerStatisticsMainView::~QmlProfilerStatisticsMainView()
{
clear();
delete d->m_model;
delete d;
}
void QmlProfilerEventsMainView::setFieldViewable(Fields field, bool show)
void QmlProfilerStatisticsMainView::setFieldViewable(Fields field, bool show)
{
if (field < MaxFields) {
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;
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
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;
}
void QmlProfilerEventsMainView::clear()
void QmlProfilerStatisticsMainView::clear()
{
d->m_model->clear();
d->m_model->setColumnCount(d->getFieldCount());
@@ -551,7 +549,7 @@ void QmlProfilerEventsMainView::clear()
setSortingEnabled(false);
}
int QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::getFieldCount()
int QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate::getFieldCount()
{
int count = 0;
for (int i=0; i < m_fieldShown.count(); ++i)
@@ -560,7 +558,7 @@ int QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::getFieldCount()
return count;
}
void QmlProfilerEventsMainView::buildModel()
void QmlProfilerStatisticsMainView::buildModel()
{
clear();
parseModelProxy();
@@ -579,7 +577,7 @@ void QmlProfilerEventsMainView::buildModel()
collapseAll();
}
void QmlProfilerEventsMainView::updateNotes(int typeIndex)
void QmlProfilerStatisticsMainView::updateNotes(int typeIndex)
{
const QHash<int, QmlProfilerEventsModelProxy::QmlEventStats> &eventList =
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();
@@ -625,11 +624,11 @@ void QmlProfilerEventsMainView::parseModelProxy()
QList<QStandardItem *> newRow;
if (d->m_fieldShown[Name])
newRow << new EventsViewItem(event.displayName.isEmpty() ? tr("<bytecode>") :
newRow << new StatisticsViewItem(event.displayName.isEmpty() ? tr("<bytecode>") :
event.displayName);
if (d->m_fieldShown[Type]) {
QString typeString = QmlProfilerEventsMainView::nameForType(event.rangeType);
QString typeString = QmlProfilerStatisticsMainView::nameForType(event.rangeType);
QString toolTipText;
if (event.rangeType == Binding) {
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));
if (!toolTipText.isEmpty())
newRow.last()->setToolTip(toolTipText);
}
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));
}
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));
}
if (d->m_fieldShown[SelfTimeInPercent]) {
newRow << new EventsViewItem(QString::number(stats.percentSelf, 'f', 2)
+ QLatin1String(" %"));
newRow << new StatisticsViewItem(QString::number(stats.percentSelf, 'f', 2)
+ QLatin1String(" %"));
newRow.last()->setData(QVariant(stats.percentSelf));
}
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));
}
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));
}
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));
}
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));
}
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));
}
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));
}
if (d->m_fieldShown[Details]) {
newRow << new EventsViewItem(event.data.isEmpty() ? tr("Source code not available") :
event.data);
newRow << new StatisticsViewItem(event.data.isEmpty() ?
tr("Source code not available") : 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);
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) {
case Painting: return QmlProfilerEventsMainView::tr("Paint");
case Compiling: return QmlProfilerEventsMainView::tr("Compile");
case Creating: return QmlProfilerEventsMainView::tr("Create");
case Binding: return QmlProfilerEventsMainView::tr("Binding");
case HandlingSignal: return QmlProfilerEventsMainView::tr("Signal");
case Javascript: return QmlProfilerEventsMainView::tr("JavaScript");
case Painting: return QmlProfilerStatisticsMainView::tr("Paint");
case Compiling: return QmlProfilerStatisticsMainView::tr("Compile");
case Creating: return QmlProfilerStatisticsMainView::tr("Create");
case Binding: return QmlProfilerStatisticsMainView::tr("Binding");
case HandlingSignal: return QmlProfilerStatisticsMainView::tr("Signal");
case Javascript: return QmlProfilerStatisticsMainView::tr("JavaScript");
default: return QString();
}
}
void QmlProfilerEventsMainView::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd)
void QmlProfilerStatisticsMainView::getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd)
{
d->modelProxy->limitToRange(rangeStart, rangeEnd);
}
int QmlProfilerEventsMainView::selectedTypeId() const
int QmlProfilerStatisticsMainView::selectedTypeId() const
{
QModelIndex index = selectedModelIndex();
if (!index.isValid())
@@ -755,7 +755,7 @@ int QmlProfilerEventsMainView::selectedTypeId() const
return item->data(TypeIdRole).toInt();
}
void QmlProfilerEventsMainView::jumpToItem(const QModelIndex &index)
void QmlProfilerStatisticsMainView::jumpToItem(const QModelIndex &index)
{
QStandardItem *infoItem = itemFromIndex(index);
@@ -768,7 +768,7 @@ void QmlProfilerEventsMainView::jumpToItem(const QModelIndex &index)
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.
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++) {
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();
if (sel.isEmpty())
@@ -800,7 +800,8 @@ QModelIndex QmlProfilerEventsMainView::selectedModelIndex() const
return sel.first();
}
QString QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::textForItem(QStandardItem *item, bool recursive) const
QString QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate::textForItem(
QStandardItem *item, bool recursive) const
{
QString str;
@@ -816,7 +817,8 @@ QString QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::textForItem
// item's data
int colCount = m_model->columnCount();
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();
if (j < colCount-1) str += QLatin1Char('\t');
}
@@ -830,7 +832,7 @@ QString QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::textForItem
return str;
}
void QmlProfilerEventsMainView::copyTableToClipboard() const
void QmlProfilerStatisticsMainView::copyTableToClipboard() const
{
QString str;
// headers
@@ -852,7 +854,7 @@ void QmlProfilerEventsMainView::copyTableToClipboard() const
clipboard->setText(str, QClipboard::Clipboard);
}
void QmlProfilerEventsMainView::copyRowToClipboard() const
void QmlProfilerStatisticsMainView::copyRowToClipboard() const
{
QString str;
str = d->textForItem(d->m_model->itemFromIndex(selectedModelIndex()), false);
@@ -862,20 +864,20 @@ void QmlProfilerEventsMainView::copyRowToClipboard() const
clipboard->setText(str, QClipboard::Clipboard);
}
class QmlProfilerEventRelativesView::QmlProfilerEventParentsViewPrivate
class QmlProfilerStatisticsRelativesView::QmlProfilerStatisticsRelativesViewPrivate
{
public:
QmlProfilerEventParentsViewPrivate(QmlProfilerEventRelativesView *qq):q(qq) {}
~QmlProfilerEventParentsViewPrivate() {}
QmlProfilerStatisticsRelativesViewPrivate(QmlProfilerStatisticsRelativesView *qq):q(qq) {}
~QmlProfilerStatisticsRelativesViewPrivate() {}
QmlProfilerEventRelativesModelProxy *modelProxy;
QmlProfilerEventRelativesView *q;
QmlProfilerStatisticsRelativesView *q;
};
QmlProfilerEventRelativesView::QmlProfilerEventRelativesView(
QmlProfilerStatisticsRelativesView::QmlProfilerStatisticsRelativesView(
QmlProfilerEventRelativesModelProxy *modelProxy, QWidget *parent) :
Utils::TreeView(parent), d(new QmlProfilerEventParentsViewPrivate(this))
Utils::TreeView(parent), d(new QmlProfilerStatisticsRelativesViewPrivate(this))
{
setViewDefaults(this);
setSortingEnabled(false);
@@ -886,19 +888,20 @@ QmlProfilerEventRelativesView::QmlProfilerEventRelativesView(
setRootIsDecorated(false);
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.
connect(d->modelProxy, &QmlProfilerEventRelativesModelProxy::dataAvailable,
this, &QmlProfilerEventRelativesView::clear);
this, &QmlProfilerStatisticsRelativesView::clear);
}
QmlProfilerEventRelativesView::~QmlProfilerEventRelativesView()
QmlProfilerStatisticsRelativesView::~QmlProfilerStatisticsRelativesView()
{
delete d;
}
void QmlProfilerEventRelativesView::displayType(int typeIndex)
void QmlProfilerStatisticsRelativesView::displayType(int typeIndex)
{
rebuildTree(d->modelProxy->getData(typeIndex));
@@ -908,7 +911,7 @@ void QmlProfilerEventRelativesView::displayType(int typeIndex)
sortByColumn(2);
}
void QmlProfilerEventRelativesView::rebuildTree(
void QmlProfilerStatisticsRelativesView::rebuildTree(
const QmlProfilerEventRelativesModelProxy::QmlEventRelativesMap &eventMap)
{
Q_ASSERT(treeModel());
@@ -928,19 +931,20 @@ void QmlProfilerEventRelativesView::rebuildTree(
// 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
// 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);
newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(type.rangeType));
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(event.duration));
newRow << new EventsViewItem(QString::number(event.calls));
newRow << new EventsViewItem(type.data.isEmpty() ? tr("Source code not available") :
newRow << new StatisticsViewItem(QmlProfilerStatisticsMainView::nameForType(
type.rangeType));
newRow << new StatisticsViewItem(QmlProfilerDataModel::formatTime(event.duration));
newRow << new StatisticsViewItem(QString::number(event.calls));
newRow << new StatisticsViewItem(type.data.isEmpty() ? tr("Source code not available") :
type.data);
newRow.at(0)->setData(QVariant(typeIndex), TypeIdRole);
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.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(3)->setData(QVariant(event.calls));
newRow.at(4)->setData(QVariant(type.data));
@@ -959,7 +963,7 @@ void QmlProfilerEventRelativesView::rebuildTree(
}
}
void QmlProfilerEventRelativesView::clear()
void QmlProfilerStatisticsRelativesView::clear()
{
if (treeModel()) {
treeModel()->clear();
@@ -967,7 +971,7 @@ void QmlProfilerEventRelativesView::clear()
}
}
void QmlProfilerEventRelativesView::updateHeader()
void QmlProfilerStatisticsRelativesView::updateHeader()
{
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());
}
void QmlProfilerEventRelativesView::jumpToItem(const QModelIndex &index)
void QmlProfilerStatisticsRelativesView::jumpToItem(const QModelIndex &index)
{
if (treeModel()) {
QStandardItem *infoItem = treeModel()->item(index.row(), 0);

View File

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

View File

@@ -248,11 +248,11 @@ void QmlProfilerTraceView::showContextMenu(QPoint position)
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())
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())
getGlobalStatsAction->setEnabled(false);

View File

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