2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-06-29 15:05:45 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-06-29 15:05:45 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-06-29 15:05:45 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-06-29 15:05:45 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-06-29 15:05:45 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
#include "qmlprofilerstatisticsview.h"
|
2016-04-28 16:02:54 +02:00
|
|
|
#include "qmlprofilerviewmanager.h"
|
|
|
|
|
#include "qmlprofilertool.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/minisplitter.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
2016-09-16 16:10:19 +02:00
|
|
|
#include <timeline/timelineformattime.h>
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QUrl>
|
|
|
|
|
#include <QHash>
|
|
|
|
|
#include <QStandardItem>
|
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QClipboard>
|
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QHBoxLayout>
|
2012-02-24 10:47:17 +01:00
|
|
|
#include <QMenu>
|
|
|
|
|
|
2015-11-11 11:46:21 +01:00
|
|
|
#include <functional>
|
2011-06-29 15:05:45 +02:00
|
|
|
|
|
|
|
|
namespace QmlProfiler {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2018-01-31 12:37:21 +01:00
|
|
|
const int DEFAULT_SORT_COLUMN = 2;
|
|
|
|
|
|
|
|
|
|
struct SortPreserver {
|
|
|
|
|
SortPreserver(Utils::TreeView *view) : view(view)
|
|
|
|
|
{
|
|
|
|
|
const QHeaderView *header = view->header();
|
|
|
|
|
column = header->sortIndicatorSection();
|
|
|
|
|
order = header->sortIndicatorOrder();
|
|
|
|
|
view->setSortingEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~SortPreserver()
|
|
|
|
|
{
|
|
|
|
|
view->setSortingEnabled(true);
|
|
|
|
|
view->sortByColumn(column, order);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int column;
|
|
|
|
|
Qt::SortOrder order;
|
|
|
|
|
Utils::TreeView *view;
|
|
|
|
|
};
|
|
|
|
|
|
2012-02-06 16:08:56 +01:00
|
|
|
struct Colors {
|
2014-09-26 18:25:39 +02:00
|
|
|
Colors () : noteBackground(QColor("orange")), defaultBackground(QColor("white")) {}
|
|
|
|
|
QColor noteBackground;
|
|
|
|
|
QColor defaultBackground;
|
2012-02-06 16:08:56 +01:00
|
|
|
};
|
|
|
|
|
|
2016-04-26 11:50:59 +02:00
|
|
|
struct RootEventType : public QmlEventType {
|
2016-06-06 19:51:55 +02:00
|
|
|
RootEventType() : QmlEventType(MaximumMessage, MaximumRangeType, -1,
|
|
|
|
|
QmlEventLocation("<program>", 1, 1),
|
|
|
|
|
QmlProfilerStatisticsMainView::tr("Main Program"),
|
|
|
|
|
QmlProfilerStatisticsMainView::tr("<program>"))
|
2014-06-13 16:34:30 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2012-02-06 16:08:56 +01:00
|
|
|
Q_GLOBAL_STATIC(Colors, colors)
|
2014-06-13 16:34:30 +02:00
|
|
|
Q_GLOBAL_STATIC(RootEventType, rootEventType)
|
2012-02-06 16:08:56 +01:00
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
class StatisticsViewItem : public QStandardItem
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2016-12-09 16:17:07 +01:00
|
|
|
StatisticsViewItem(const QString &text, const QVariant &sort) : QStandardItem(text)
|
|
|
|
|
{
|
|
|
|
|
setData(sort, SortRole);
|
|
|
|
|
}
|
2011-06-29 15:05:45 +02:00
|
|
|
|
|
|
|
|
virtual bool operator<(const QStandardItem &other) const
|
|
|
|
|
{
|
2016-12-09 16:17:07 +01:00
|
|
|
if (data(SortRole).type() == QVariant::String) {
|
2014-07-04 14:10:37 +02:00
|
|
|
// Strings should be case-insensitive compared
|
|
|
|
|
return data(SortRole).toString().compare(other.data(SortRole).toString(),
|
|
|
|
|
Qt::CaseInsensitive) < 0;
|
|
|
|
|
} else {
|
|
|
|
|
// For everything else the standard comparison should be OK
|
|
|
|
|
return QStandardItem::operator<(other);
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
class QmlProfilerStatisticsView::QmlProfilerStatisticsViewPrivate
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
public:
|
2016-06-08 19:00:59 +02:00
|
|
|
QmlProfilerStatisticsMainView *m_statsTree;
|
|
|
|
|
QmlProfilerStatisticsRelativesView *m_statsChildren;
|
|
|
|
|
QmlProfilerStatisticsRelativesView *m_statsParents;
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
QmlProfilerStatisticsModel *model;
|
2012-02-24 10:47:17 +01:00
|
|
|
};
|
|
|
|
|
|
2015-07-01 18:04:26 +02:00
|
|
|
static void setViewDefaults(Utils::TreeView *view)
|
|
|
|
|
{
|
|
|
|
|
view->setFrameStyle(QFrame::NoFrame);
|
|
|
|
|
QHeaderView *header = view->header();
|
|
|
|
|
header->setSectionResizeMode(QHeaderView::Interactive);
|
|
|
|
|
header->setDefaultSectionSize(100);
|
|
|
|
|
header->setMinimumSectionSize(50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QString displayHeader(Fields header)
|
|
|
|
|
{
|
|
|
|
|
switch (header) {
|
|
|
|
|
case Callee:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Callee");
|
2015-07-01 18:04:26 +02:00
|
|
|
case CalleeDescription:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Callee Description");
|
2015-07-01 18:04:26 +02:00
|
|
|
case Caller:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Caller");
|
2015-07-01 18:04:26 +02:00
|
|
|
case CallerDescription:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Caller Description");
|
2015-07-01 18:04:26 +02:00
|
|
|
case CallCount:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Calls");
|
2015-07-01 18:04:26 +02:00
|
|
|
case Details:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Details");
|
2015-07-01 18:04:26 +02:00
|
|
|
case Location:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Location");
|
2015-07-01 18:04:26 +02:00
|
|
|
case MaxTime:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Longest Time");
|
2015-07-01 18:04:26 +02:00
|
|
|
case TimePerCall:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Mean Time");
|
2015-07-01 18:04:26 +02:00
|
|
|
case SelfTime:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Self Time");
|
2015-07-01 18:04:26 +02:00
|
|
|
case SelfTimeInPercent:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Self Time in Percent");
|
2015-07-01 18:04:26 +02:00
|
|
|
case MinTime:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Shortest Time");
|
2015-07-01 18:04:26 +02:00
|
|
|
case TimeInPercent:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Time in Percent");
|
2015-07-01 18:04:26 +02:00
|
|
|
case TotalTime:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Total Time");
|
2015-07-01 18:04:26 +02:00
|
|
|
case Type:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Type");
|
2015-07-01 18:04:26 +02:00
|
|
|
case MedianTime:
|
2018-01-25 17:49:15 +01:00
|
|
|
return QmlProfilerStatisticsMainView::tr("Median Time");
|
2015-07-01 18:04:26 +02:00
|
|
|
default:
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-11 11:46:21 +01:00
|
|
|
static void getSourceLocation(QStandardItem *infoItem,
|
|
|
|
|
std::function<void (const QString &, int, int)> receiver)
|
|
|
|
|
{
|
|
|
|
|
int line = infoItem->data(LineRole).toInt();
|
|
|
|
|
int column = infoItem->data(ColumnRole).toInt();
|
|
|
|
|
QString fileName = infoItem->data(FilenameRole).toString();
|
|
|
|
|
if (line != -1 && !fileName.isEmpty())
|
|
|
|
|
receiver(fileName, line, column);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-31 17:31:45 +02:00
|
|
|
QmlProfilerStatisticsView::QmlProfilerStatisticsView(QmlProfilerModelManager *profilerModelManager,
|
|
|
|
|
QWidget *parent)
|
2016-12-20 12:58:00 +01:00
|
|
|
: QmlProfilerEventsView(parent), d(new QmlProfilerStatisticsViewPrivate)
|
2012-02-24 10:47:17 +01:00
|
|
|
{
|
2016-12-14 13:50:20 +01:00
|
|
|
setObjectName(QLatin1String("QmlProfiler.Statistics.Dock"));
|
2015-12-04 16:54:58 +01:00
|
|
|
setWindowTitle(tr("Statistics"));
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
d->model = new QmlProfilerStatisticsModel(profilerModelManager, this);
|
2012-02-24 10:47:17 +01:00
|
|
|
|
2016-06-08 19:00:59 +02:00
|
|
|
d->m_statsTree = new QmlProfilerStatisticsMainView(this, d->model);
|
|
|
|
|
connect(d->m_statsTree, &QmlProfilerStatisticsMainView::gotoSourceLocation,
|
2015-12-04 13:30:54 +01:00
|
|
|
this, &QmlProfilerStatisticsView::gotoSourceLocation);
|
2016-06-08 19:00:59 +02:00
|
|
|
connect(d->m_statsTree, &QmlProfilerStatisticsMainView::typeSelected,
|
2015-12-04 13:30:54 +01:00
|
|
|
this, &QmlProfilerStatisticsView::typeSelected);
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2016-06-08 19:00:59 +02:00
|
|
|
d->m_statsChildren = new QmlProfilerStatisticsRelativesView(
|
2016-04-26 16:38:56 +02:00
|
|
|
new QmlProfilerStatisticsRelativesModel(profilerModelManager, d->model,
|
|
|
|
|
QmlProfilerStatisticsChilden, this),
|
2013-08-08 13:28:08 +02:00
|
|
|
this);
|
2016-06-08 19:00:59 +02:00
|
|
|
d->m_statsParents = new QmlProfilerStatisticsRelativesView(
|
2016-04-26 16:38:56 +02:00
|
|
|
new QmlProfilerStatisticsRelativesModel(profilerModelManager, d->model,
|
|
|
|
|
QmlProfilerStatisticsParents, this),
|
2013-08-08 13:28:08 +02:00
|
|
|
this);
|
2016-06-08 19:00:59 +02:00
|
|
|
connect(d->m_statsTree, &QmlProfilerStatisticsMainView::typeSelected,
|
|
|
|
|
d->m_statsChildren, &QmlProfilerStatisticsRelativesView::displayType);
|
|
|
|
|
connect(d->m_statsTree, &QmlProfilerStatisticsMainView::typeSelected,
|
|
|
|
|
d->m_statsParents, &QmlProfilerStatisticsRelativesView::displayType);
|
|
|
|
|
connect(d->m_statsChildren, &QmlProfilerStatisticsRelativesView::typeClicked,
|
|
|
|
|
d->m_statsTree, &QmlProfilerStatisticsMainView::selectType);
|
|
|
|
|
connect(d->m_statsParents, &QmlProfilerStatisticsRelativesView::typeClicked,
|
|
|
|
|
d->m_statsTree, &QmlProfilerStatisticsMainView::selectType);
|
|
|
|
|
connect(d->m_statsChildren, &QmlProfilerStatisticsRelativesView::gotoSourceLocation,
|
2015-12-04 13:30:54 +01:00
|
|
|
this, &QmlProfilerStatisticsView::gotoSourceLocation);
|
2016-06-08 19:00:59 +02:00
|
|
|
connect(d->m_statsParents, &QmlProfilerStatisticsRelativesView::gotoSourceLocation,
|
2015-12-04 13:30:54 +01:00
|
|
|
this, &QmlProfilerStatisticsView::gotoSourceLocation);
|
2011-11-04 17:33:09 +01:00
|
|
|
|
|
|
|
|
// widget arrangement
|
|
|
|
|
QVBoxLayout *groupLayout = new QVBoxLayout;
|
|
|
|
|
groupLayout->setContentsMargins(0,0,0,0);
|
|
|
|
|
groupLayout->setSpacing(0);
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
Core::MiniSplitter *splitterVertical = new Core::MiniSplitter;
|
2016-06-08 19:00:59 +02:00
|
|
|
splitterVertical->addWidget(d->m_statsTree);
|
2011-11-04 17:33:09 +01:00
|
|
|
Core::MiniSplitter *splitterHorizontal = new Core::MiniSplitter;
|
2016-06-08 19:00:59 +02:00
|
|
|
splitterHorizontal->addWidget(d->m_statsParents);
|
|
|
|
|
splitterHorizontal->addWidget(d->m_statsChildren);
|
2011-11-04 17:33:09 +01:00
|
|
|
splitterHorizontal->setOrientation(Qt::Horizontal);
|
|
|
|
|
splitterVertical->addWidget(splitterHorizontal);
|
|
|
|
|
splitterVertical->setOrientation(Qt::Vertical);
|
|
|
|
|
splitterVertical->setStretchFactor(0,5);
|
|
|
|
|
splitterVertical->setStretchFactor(1,2);
|
|
|
|
|
groupLayout->addWidget(splitterVertical);
|
|
|
|
|
setLayout(groupLayout);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QmlProfilerStatisticsView::~QmlProfilerStatisticsView()
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2015-12-04 15:41:20 +01:00
|
|
|
delete d->model;
|
2012-02-24 10:47:17 +01:00
|
|
|
delete d;
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsView::clear()
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2016-06-08 19:00:59 +02:00
|
|
|
d->m_statsTree->clear();
|
|
|
|
|
d->m_statsChildren->clear();
|
|
|
|
|
d->m_statsParents->clear();
|
2011-11-08 16:54:23 +01:00
|
|
|
}
|
|
|
|
|
|
2016-12-19 18:47:06 +01:00
|
|
|
QString QmlProfilerStatisticsView::summary(const QVector<int> &typeIds) const
|
|
|
|
|
{
|
|
|
|
|
const double cutoff = 0.1;
|
|
|
|
|
const double round = 0.05;
|
|
|
|
|
double maximum = 0;
|
|
|
|
|
double sum = 0;
|
|
|
|
|
|
|
|
|
|
for (int typeId : typeIds) {
|
2016-12-28 18:12:49 +01:00
|
|
|
const double percentage = d->model->durationPercent(typeId);
|
2016-12-19 18:47:06 +01:00
|
|
|
if (percentage > maximum)
|
|
|
|
|
maximum = percentage;
|
|
|
|
|
sum += percentage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QLatin1Char percent('%');
|
|
|
|
|
|
|
|
|
|
if (sum < cutoff)
|
|
|
|
|
return QLatin1Char('<') + QString::number(cutoff, 'f', 1) + percent;
|
|
|
|
|
|
|
|
|
|
if (typeIds.length() == 1)
|
|
|
|
|
return QLatin1Char('~') + QString::number(maximum, 'f', 1) + percent;
|
|
|
|
|
|
|
|
|
|
// add/subtract 0.05 to avoid problematic rounding
|
|
|
|
|
if (maximum < cutoff)
|
|
|
|
|
return QChar(0x2264) + QString::number(sum + round, 'f', 1) + percent;
|
|
|
|
|
|
|
|
|
|
return QChar(0x2265) + QString::number(qMax(maximum - round, cutoff), 'f', 1) + percent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList QmlProfilerStatisticsView::details(int typeId) const
|
|
|
|
|
{
|
|
|
|
|
const QmlEventType &type = d->model->getTypes()[typeId];
|
|
|
|
|
|
|
|
|
|
const QChar ellipsisChar(0x2026);
|
|
|
|
|
const int maxColumnWidth = 32;
|
|
|
|
|
|
|
|
|
|
QString data = type.data();
|
|
|
|
|
if (data.length() > maxColumnWidth)
|
|
|
|
|
data = data.left(maxColumnWidth - 1) + ellipsisChar;
|
|
|
|
|
|
|
|
|
|
return QStringList({
|
|
|
|
|
QmlProfilerStatisticsMainView::nameForType(type.rangeType()),
|
|
|
|
|
data,
|
2016-12-28 18:12:49 +01:00
|
|
|
QString::number(d->model->durationPercent(typeId), 'f', 2) + QLatin1Char('%')
|
2016-12-19 18:47:06 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QModelIndex QmlProfilerStatisticsView::selectedModelIndex() const
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2016-06-08 19:00:59 +02:00
|
|
|
return d->m_statsTree->selectedModelIndex();
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsView::contextMenuEvent(QContextMenuEvent *ev)
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2012-02-24 10:47:17 +01:00
|
|
|
QMenu menu;
|
|
|
|
|
QAction *copyRowAction = 0;
|
|
|
|
|
QAction *copyTableAction = 0;
|
|
|
|
|
QAction *showExtendedStatsAction = 0;
|
|
|
|
|
QAction *getGlobalStatsAction = 0;
|
|
|
|
|
|
|
|
|
|
QPoint position = ev->globalPos();
|
|
|
|
|
|
2016-01-04 17:20:13 +01:00
|
|
|
QList <QAction *> commonActions = QmlProfilerTool::profilerContextMenuActions();
|
|
|
|
|
foreach (QAction *act, commonActions)
|
|
|
|
|
menu.addAction(act);
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
if (mouseOnTable(position)) {
|
|
|
|
|
menu.addSeparator();
|
2014-08-29 16:32:42 +02:00
|
|
|
if (selectedModelIndex().isValid())
|
2012-02-24 10:47:17 +01:00
|
|
|
copyRowAction = menu.addAction(tr("Copy Row"));
|
|
|
|
|
copyTableAction = menu.addAction(tr("Copy Table"));
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
showExtendedStatsAction = menu.addAction(tr("Extended Event Statistics"));
|
|
|
|
|
showExtendedStatsAction->setCheckable(true);
|
|
|
|
|
showExtendedStatsAction->setChecked(showExtendedStatistics());
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
menu.addSeparator();
|
2014-03-06 16:12:02 +01:00
|
|
|
getGlobalStatsAction = menu.addAction(tr("Show Full Range"));
|
2016-04-28 16:13:16 +02:00
|
|
|
if (!d->model->modelManager()->isRestrictedToRange())
|
2013-08-08 13:28:08 +02:00
|
|
|
getGlobalStatsAction->setEnabled(false);
|
2012-02-24 10:47:17 +01:00
|
|
|
|
|
|
|
|
QAction *selectedAction = menu.exec(position);
|
|
|
|
|
|
|
|
|
|
if (selectedAction) {
|
|
|
|
|
if (selectedAction == copyRowAction)
|
|
|
|
|
copyRowToClipboard();
|
|
|
|
|
if (selectedAction == copyTableAction)
|
|
|
|
|
copyTableToClipboard();
|
2013-08-08 13:28:08 +02:00
|
|
|
if (selectedAction == getGlobalStatsAction)
|
2015-12-04 16:54:58 +01:00
|
|
|
emit showFullRange();
|
2012-02-24 10:47:17 +01:00
|
|
|
if (selectedAction == showExtendedStatsAction)
|
|
|
|
|
setShowExtendedStatistics(!showExtendedStatistics());
|
|
|
|
|
}
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
bool QmlProfilerStatisticsView::mouseOnTable(const QPoint &position) const
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2016-06-08 19:00:59 +02:00
|
|
|
QPoint tableTopLeft = d->m_statsTree->mapToGlobal(QPoint(0,0));
|
|
|
|
|
QPoint tableBottomRight = d->m_statsTree->mapToGlobal(QPoint(d->m_statsTree->width(), d->m_statsTree->height()));
|
2011-11-04 17:33:09 +01:00
|
|
|
return (position.x() >= tableTopLeft.x() && position.x() <= tableBottomRight.x() && position.y() >= tableTopLeft.y() && position.y() <= tableBottomRight.y());
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsView::copyTableToClipboard() const
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2016-06-08 19:00:59 +02:00
|
|
|
d->m_statsTree->copyTableToClipboard();
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsView::copyRowToClipboard() const
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2016-06-08 19:00:59 +02:00
|
|
|
d->m_statsTree->copyRowToClipboard();
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsView::selectByTypeId(int typeIndex)
|
2011-11-09 12:57:41 +01:00
|
|
|
{
|
2016-06-08 19:00:59 +02:00
|
|
|
if (d->m_statsTree->selectedTypeId() != typeIndex)
|
|
|
|
|
d->m_statsTree->selectType(typeIndex);
|
2011-11-09 12:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsView::onVisibleFeaturesChanged(quint64 features)
|
2015-06-30 16:23:13 +02:00
|
|
|
{
|
2016-04-28 16:13:16 +02:00
|
|
|
d->model->restrictToFeatures(features);
|
2011-11-10 11:19:22 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsView::setShowExtendedStatistics(bool show)
|
2012-02-03 17:28:29 +01:00
|
|
|
{
|
2016-06-08 19:00:59 +02:00
|
|
|
d->m_statsTree->setShowExtendedStatistics(show);
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
bool QmlProfilerStatisticsView::showExtendedStatistics() const
|
2012-02-03 17:28:29 +01:00
|
|
|
{
|
2016-06-08 19:00:59 +02:00
|
|
|
return d->m_statsTree->showExtendedStatistics();
|
2012-02-24 10:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
class QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2015-12-04 13:30:54 +01:00
|
|
|
QmlProfilerStatisticsMainViewPrivate(QmlProfilerStatisticsMainView *qq) : q(qq) {}
|
2011-06-29 15:05:45 +02:00
|
|
|
|
|
|
|
|
int getFieldCount();
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
QString textForItem(QStandardItem *item, bool recursive = false) const;
|
2011-08-24 11:18:48 +02:00
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QmlProfilerStatisticsMainView *q;
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
QmlProfilerStatisticsModel *model;
|
2011-06-29 15:05:45 +02:00
|
|
|
QStandardItemModel *m_model;
|
|
|
|
|
QList<bool> m_fieldShown;
|
2012-02-03 17:28:29 +01:00
|
|
|
QHash<int, int> m_columnIndex; // maps field enum to column index
|
|
|
|
|
bool m_showExtendedStatistics;
|
2011-06-29 15:05:45 +02:00
|
|
|
};
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainView(
|
2015-12-04 15:41:20 +01:00
|
|
|
QWidget *parent, QmlProfilerStatisticsModel *model) :
|
2015-12-04 13:30:54 +01:00
|
|
|
Utils::TreeView(parent), d(new QmlProfilerStatisticsMainViewPrivate(this))
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2015-07-01 18:04:26 +02:00
|
|
|
setViewDefaults(this);
|
2012-11-26 21:18:13 +02:00
|
|
|
setObjectName(QLatin1String("QmlProfilerEventsTable"));
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_model = new QStandardItemModel(this);
|
2014-07-04 14:10:37 +02:00
|
|
|
d->m_model->setSortRole(SortRole);
|
2011-06-29 15:05:45 +02:00
|
|
|
setModel(d->m_model);
|
2015-12-04 13:30:54 +01:00
|
|
|
connect(this, &QAbstractItemView::activated, this, &QmlProfilerStatisticsMainView::jumpToItem);
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
d->model = model;
|
|
|
|
|
connect(d->model, &QmlProfilerStatisticsModel::dataAvailable,
|
2015-12-04 13:30:54 +01:00
|
|
|
this, &QmlProfilerStatisticsMainView::buildModel);
|
2015-12-04 15:41:20 +01:00
|
|
|
connect(d->model, &QmlProfilerStatisticsModel::notesAvailable,
|
2015-12-04 13:30:54 +01:00
|
|
|
this, &QmlProfilerStatisticsMainView::updateNotes);
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_showExtendedStatistics = false;
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
setFieldViewable(Name, true);
|
|
|
|
|
setFieldViewable(Type, true);
|
|
|
|
|
setFieldViewable(TimeInPercent, true);
|
|
|
|
|
setFieldViewable(TotalTime, true);
|
2015-12-03 12:33:00 +01:00
|
|
|
setFieldViewable(SelfTimeInPercent, true);
|
|
|
|
|
setFieldViewable(SelfTime, true);
|
2013-08-08 13:28:08 +02:00
|
|
|
setFieldViewable(CallCount, true);
|
|
|
|
|
setFieldViewable(TimePerCall, true);
|
|
|
|
|
setFieldViewable(MaxTime, true);
|
|
|
|
|
setFieldViewable(MinTime, true);
|
|
|
|
|
setFieldViewable(MedianTime, true);
|
|
|
|
|
setFieldViewable(Details, true);
|
|
|
|
|
|
2018-01-31 12:37:21 +01:00
|
|
|
setSortingEnabled(true);
|
|
|
|
|
sortByColumn(DEFAULT_SORT_COLUMN, Qt::DescendingOrder);
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
buildModel();
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QmlProfilerStatisticsMainView::~QmlProfilerStatisticsMainView()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
delete d->m_model;
|
2012-03-14 12:30:22 +01:00
|
|
|
delete d;
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsMainView::setFieldViewable(Fields field, bool show)
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
if (field < MaxFields) {
|
|
|
|
|
int length = d->m_fieldShown.count();
|
|
|
|
|
if (field >= length) {
|
|
|
|
|
for (int i=length; i<MaxFields; i++)
|
|
|
|
|
d->m_fieldShown << false;
|
|
|
|
|
}
|
|
|
|
|
d->m_fieldShown[field] = show;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsMainView::setHeaderLabels()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
int fieldIndex = 0;
|
|
|
|
|
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_columnIndex.clear();
|
2011-06-29 15:05:45 +02:00
|
|
|
if (d->m_fieldShown[Name]) {
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_columnIndex[Name] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(Location)));
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[Type]) {
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_columnIndex[Type] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(Type)));
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[TimeInPercent]) {
|
|
|
|
|
d->m_columnIndex[TimeInPercent] = fieldIndex;
|
|
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(TimeInPercent)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[TotalTime]) {
|
|
|
|
|
d->m_columnIndex[TotalTime] = fieldIndex;
|
|
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(TotalTime)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[SelfTimeInPercent]) {
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_columnIndex[Type] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(SelfTimeInPercent)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[SelfTime]) {
|
|
|
|
|
d->m_columnIndex[SelfTime] = fieldIndex;
|
|
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(SelfTime)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[CallCount]) {
|
|
|
|
|
d->m_columnIndex[CallCount] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(CallCount)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[TimePerCall]) {
|
|
|
|
|
d->m_columnIndex[TimePerCall] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(TimePerCall)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[MedianTime]) {
|
|
|
|
|
d->m_columnIndex[MedianTime] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(MedianTime)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[MaxTime]) {
|
|
|
|
|
d->m_columnIndex[MaxTime] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(MaxTime)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
|
|
|
|
if (d->m_fieldShown[MinTime]) {
|
|
|
|
|
d->m_columnIndex[MinTime] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(MinTime)));
|
2012-02-03 17:28:29 +01:00
|
|
|
}
|
2012-01-17 13:26:57 +01:00
|
|
|
if (d->m_fieldShown[Details]) {
|
2012-02-03 17:28:29 +01:00
|
|
|
d->m_columnIndex[Details] = fieldIndex;
|
2013-08-08 13:28:08 +02:00
|
|
|
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(Details)));
|
2012-01-17 13:26:57 +01:00
|
|
|
}
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsMainView::setShowExtendedStatistics(bool show)
|
2012-02-03 17:28:29 +01:00
|
|
|
{
|
|
|
|
|
// Not checking if already set because we don't want the first call to skip
|
|
|
|
|
d->m_showExtendedStatistics = show;
|
|
|
|
|
if (show) {
|
|
|
|
|
if (d->m_fieldShown[MedianTime])
|
|
|
|
|
showColumn(d->m_columnIndex[MedianTime]);
|
|
|
|
|
if (d->m_fieldShown[MaxTime])
|
|
|
|
|
showColumn(d->m_columnIndex[MaxTime]);
|
|
|
|
|
if (d->m_fieldShown[MinTime])
|
|
|
|
|
showColumn(d->m_columnIndex[MinTime]);
|
|
|
|
|
} else{
|
|
|
|
|
if (d->m_fieldShown[MedianTime])
|
|
|
|
|
hideColumn(d->m_columnIndex[MedianTime]);
|
|
|
|
|
if (d->m_fieldShown[MaxTime])
|
|
|
|
|
hideColumn(d->m_columnIndex[MaxTime]);
|
|
|
|
|
if (d->m_fieldShown[MinTime])
|
|
|
|
|
hideColumn(d->m_columnIndex[MinTime]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
bool QmlProfilerStatisticsMainView::showExtendedStatistics() const
|
2012-02-03 17:28:29 +01:00
|
|
|
{
|
|
|
|
|
return d->m_showExtendedStatistics;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsMainView::clear()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2018-01-31 12:37:21 +01:00
|
|
|
SortPreserver sorter(this);
|
2011-06-29 15:05:45 +02:00
|
|
|
d->m_model->clear();
|
|
|
|
|
d->m_model->setColumnCount(d->getFieldCount());
|
|
|
|
|
setHeaderLabels();
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
int QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate::getFieldCount()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (int i=0; i < m_fieldShown.count(); ++i)
|
2011-12-05 16:32:05 +01:00
|
|
|
if (m_fieldShown[i])
|
2011-06-29 15:05:45 +02:00
|
|
|
count++;
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsMainView::buildModel()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
clear();
|
2012-02-03 17:28:29 +01:00
|
|
|
|
2018-01-31 12:37:21 +01:00
|
|
|
{
|
|
|
|
|
SortPreserver sorter(this);
|
|
|
|
|
parseModel();
|
|
|
|
|
setShowExtendedStatistics(d->m_showExtendedStatistics);
|
|
|
|
|
setRootIsDecorated(false);
|
|
|
|
|
}
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
expandAll();
|
|
|
|
|
if (d->m_fieldShown[Name])
|
|
|
|
|
resizeColumnToContents(0);
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[Type])
|
|
|
|
|
resizeColumnToContents(d->m_fieldShown[Name]?1:0);
|
|
|
|
|
collapseAll();
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsMainView::updateNotes(int typeIndex)
|
2014-09-26 18:25:39 +02:00
|
|
|
{
|
2016-04-26 11:50:59 +02:00
|
|
|
const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &eventList = d->model->getData();
|
2015-12-04 15:41:20 +01:00
|
|
|
const QHash<int, QString> ¬eList = d->model->getNotes();
|
2014-09-26 18:25:39 +02:00
|
|
|
QStandardItem *parentItem = d->m_model->invisibleRootItem();
|
|
|
|
|
|
|
|
|
|
for (int rowIndex = 0; rowIndex < parentItem->rowCount(); ++rowIndex) {
|
|
|
|
|
int rowType = parentItem->child(rowIndex, 0)->data(TypeIdRole).toInt();
|
|
|
|
|
if (rowType != typeIndex && typeIndex != -1)
|
|
|
|
|
continue;
|
2015-12-04 15:41:20 +01:00
|
|
|
const QmlProfilerStatisticsModel::QmlEventStats &stats = eventList[rowType];
|
2014-09-26 18:25:39 +02:00
|
|
|
|
|
|
|
|
for (int columnIndex = 0; columnIndex < parentItem->columnCount(); ++columnIndex) {
|
|
|
|
|
QStandardItem *item = parentItem->child(rowIndex, columnIndex);
|
|
|
|
|
QHash<int, QString>::ConstIterator it = noteList.find(rowType);
|
|
|
|
|
if (it != noteList.end()) {
|
|
|
|
|
item->setBackground(colors()->noteBackground);
|
|
|
|
|
item->setToolTip(it.value());
|
2016-12-28 18:12:49 +01:00
|
|
|
} else if (stats.durationRecursive > 0) {
|
2014-09-26 18:25:39 +02:00
|
|
|
item->setBackground(colors()->noteBackground);
|
2017-08-10 16:50:32 +02:00
|
|
|
item->setToolTip(tr("+%1 in recursive calls")
|
|
|
|
|
.arg(Timeline::formatTime(stats.durationRecursive)));
|
2014-09-26 18:25:39 +02:00
|
|
|
} else if (!item->toolTip().isEmpty()){
|
|
|
|
|
item->setBackground(colors()->defaultBackground);
|
|
|
|
|
item->setToolTip(QString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
void QmlProfilerStatisticsMainView::parseModel()
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2016-04-26 11:50:59 +02:00
|
|
|
const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &eventList = d->model->getData();
|
|
|
|
|
const QVector<QmlEventType> &typeList = d->model->getTypes();
|
2014-06-13 16:34:30 +02:00
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
QHash<int, QmlProfilerStatisticsModel::QmlEventStats>::ConstIterator it;
|
2014-06-13 16:34:30 +02:00
|
|
|
for (it = eventList.constBegin(); it != eventList.constEnd(); ++it) {
|
|
|
|
|
int typeIndex = it.key();
|
2015-12-04 15:41:20 +01:00
|
|
|
const QmlProfilerStatisticsModel::QmlEventStats &stats = it.value();
|
2016-06-08 19:00:59 +02:00
|
|
|
const QmlEventType &type = (typeIndex != -1 ? typeList[typeIndex] : *rootEventType());
|
2013-08-08 13:28:08 +02:00
|
|
|
QStandardItem *parentItem = d->m_model->invisibleRootItem();
|
2011-06-29 15:05:45 +02:00
|
|
|
QList<QStandardItem *> newRow;
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[Name])
|
2016-12-09 16:17:07 +01:00
|
|
|
newRow << new StatisticsViewItem(
|
|
|
|
|
type.displayName().isEmpty() ? tr("<bytecode>") : type.displayName(),
|
|
|
|
|
type.displayName());
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
if (d->m_fieldShown[Type]) {
|
2016-06-08 19:00:59 +02:00
|
|
|
QString typeString = QmlProfilerStatisticsMainView::nameForType(type.rangeType());
|
2016-12-09 16:17:07 +01:00
|
|
|
newRow << new StatisticsViewItem(typeString, typeString);
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[TimeInPercent]) {
|
2016-12-28 18:12:49 +01:00
|
|
|
const double percent = d->model->durationPercent(typeIndex);
|
|
|
|
|
newRow << new StatisticsViewItem(QString::number(percent, 'f', 2)
|
|
|
|
|
+ QLatin1String(" %"), percent);
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[TotalTime]) {
|
2017-08-10 16:50:32 +02:00
|
|
|
newRow << new StatisticsViewItem(
|
|
|
|
|
Timeline::formatTime(stats.duration - stats.durationRecursive),
|
|
|
|
|
stats.duration - stats.durationRecursive);
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2015-12-03 12:33:00 +01:00
|
|
|
if (d->m_fieldShown[SelfTimeInPercent]) {
|
2016-12-28 18:12:49 +01:00
|
|
|
const double percentSelf = d->model->durationSelfPercent(typeIndex);
|
|
|
|
|
newRow << new StatisticsViewItem(QString::number(percentSelf, 'f', 2)
|
|
|
|
|
+ QLatin1String(" %"), percentSelf);
|
2015-12-03 12:33:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (d->m_fieldShown[SelfTime]) {
|
2016-09-16 16:10:19 +02:00
|
|
|
newRow << new StatisticsViewItem(Timeline::formatTime(stats.durationSelf),
|
2016-12-09 16:17:07 +01:00
|
|
|
stats.durationSelf);
|
2015-12-03 12:33:00 +01:00
|
|
|
}
|
|
|
|
|
|
2016-12-09 16:17:07 +01:00
|
|
|
if (d->m_fieldShown[CallCount])
|
|
|
|
|
newRow << new StatisticsViewItem(QString::number(stats.calls), stats.calls);
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[TimePerCall]) {
|
2017-03-20 16:18:41 +01:00
|
|
|
const qint64 timePerCall = stats.calls > 0 ? stats.duration / stats.calls : 0;
|
2016-12-28 18:12:49 +01:00
|
|
|
newRow << new StatisticsViewItem(Timeline::formatTime(timePerCall),
|
|
|
|
|
timePerCall);
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[MedianTime]) {
|
2016-09-16 16:10:19 +02:00
|
|
|
newRow << new StatisticsViewItem(Timeline::formatTime(stats.medianTime),
|
2016-12-09 16:17:07 +01:00
|
|
|
stats.medianTime);
|
2011-08-24 16:30:31 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[MaxTime]) {
|
2016-09-16 16:10:19 +02:00
|
|
|
newRow << new StatisticsViewItem(Timeline::formatTime(stats.maxTime),
|
2016-12-09 16:17:07 +01:00
|
|
|
stats.maxTime);
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[MinTime]) {
|
2016-09-16 16:10:19 +02:00
|
|
|
newRow << new StatisticsViewItem(Timeline::formatTime(stats.minTime),
|
2016-12-09 16:17:07 +01:00
|
|
|
stats.minTime);
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (d->m_fieldShown[Details]) {
|
2016-12-09 16:17:07 +01:00
|
|
|
newRow << new StatisticsViewItem(type.data().isEmpty() ? tr("Source code not available")
|
|
|
|
|
: type.data(), type.data());
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2011-08-24 16:30:31 +02:00
|
|
|
|
|
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
if (!newRow.isEmpty()) {
|
|
|
|
|
// no edit
|
|
|
|
|
foreach (QStandardItem *item, newRow)
|
|
|
|
|
item->setEditable(false);
|
|
|
|
|
|
|
|
|
|
// metadata
|
2016-12-09 16:17:07 +01:00
|
|
|
QStandardItem *first = newRow.at(0);
|
|
|
|
|
first->setData(typeIndex, TypeIdRole);
|
2016-06-08 19:00:59 +02:00
|
|
|
const QmlEventLocation location(type.location());
|
2016-12-09 16:17:07 +01:00
|
|
|
first->setData(location.filename(), FilenameRole);
|
|
|
|
|
first->setData(location.line(), LineRole);
|
|
|
|
|
first->setData(location.column(), ColumnRole);
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
// append
|
|
|
|
|
parentItem->appendRow(newRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QStandardItem *QmlProfilerStatisticsMainView::itemFromIndex(const QModelIndex &index) const
|
2015-11-11 11:46:21 +01:00
|
|
|
{
|
|
|
|
|
QStandardItem *indexItem = d->m_model->itemFromIndex(index);
|
|
|
|
|
if (indexItem->parent())
|
|
|
|
|
return indexItem->parent()->child(indexItem->row(), 0);
|
|
|
|
|
else
|
|
|
|
|
return d->m_model->item(index.row(), 0);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QString QmlProfilerStatisticsMainView::nameForType(RangeType typeNumber)
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
|
|
|
|
switch (typeNumber) {
|
2016-12-20 16:47:34 +01:00
|
|
|
case Painting: return QmlProfilerStatisticsMainView::tr("Painting");
|
|
|
|
|
case Compiling: return QmlProfilerStatisticsMainView::tr("Compiling");
|
|
|
|
|
case Creating: return QmlProfilerStatisticsMainView::tr("Creating");
|
2015-12-04 13:30:54 +01:00
|
|
|
case Binding: return QmlProfilerStatisticsMainView::tr("Binding");
|
2016-12-20 16:47:34 +01:00
|
|
|
case HandlingSignal: return QmlProfilerStatisticsMainView::tr("Handling Signal");
|
2015-12-04 13:30:54 +01:00
|
|
|
case Javascript: return QmlProfilerStatisticsMainView::tr("JavaScript");
|
2014-06-03 16:57:32 +02:00
|
|
|
default: return QString();
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
int QmlProfilerStatisticsMainView::selectedTypeId() const
|
2011-11-09 12:57:41 +01:00
|
|
|
{
|
2014-08-29 16:32:42 +02:00
|
|
|
QModelIndex index = selectedModelIndex();
|
2011-11-09 12:57:41 +01:00
|
|
|
if (!index.isValid())
|
2014-06-13 16:34:30 +02:00
|
|
|
return -1;
|
2011-11-09 12:57:41 +01:00
|
|
|
QStandardItem *item = d->m_model->item(index.row(), 0);
|
2014-08-29 16:32:42 +02:00
|
|
|
return item->data(TypeIdRole).toInt();
|
2011-11-09 12:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsMainView::jumpToItem(const QModelIndex &index)
|
2011-06-29 15:05:45 +02:00
|
|
|
{
|
2015-11-11 11:46:21 +01:00
|
|
|
QStandardItem *infoItem = itemFromIndex(index);
|
2011-06-29 15:05:45 +02:00
|
|
|
|
2011-11-09 12:57:41 +01:00
|
|
|
// show in editor
|
2015-11-11 11:46:21 +01:00
|
|
|
getSourceLocation(infoItem, [this](const QString &fileName, int line, int column) {
|
2012-01-12 16:36:40 +01:00
|
|
|
emit gotoSourceLocation(fileName, line, column);
|
2015-11-11 11:46:21 +01:00
|
|
|
});
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2011-11-09 12:57:41 +01:00
|
|
|
// show in callers/callees subwindow
|
2014-08-29 16:32:42 +02:00
|
|
|
emit typeSelected(infoItem->data(TypeIdRole).toInt());
|
2011-06-29 15:05:45 +02:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsMainView::selectItem(const QStandardItem *item)
|
2014-04-03 11:15:56 +02:00
|
|
|
{
|
|
|
|
|
// If the same item is already selected, don't reselect it.
|
|
|
|
|
QModelIndex index = d->m_model->indexFromItem(item);
|
|
|
|
|
if (index != currentIndex()) {
|
|
|
|
|
setCurrentIndex(index);
|
2015-11-11 11:46:21 +01:00
|
|
|
|
|
|
|
|
// show in callers/callees subwindow
|
|
|
|
|
emit typeSelected(itemFromIndex(index)->data(TypeIdRole).toInt());
|
2014-04-03 11:15:56 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsMainView::selectType(int typeIndex)
|
2011-07-26 13:56:14 +02:00
|
|
|
{
|
2011-11-04 17:33:09 +01:00
|
|
|
for (int i=0; i<d->m_model->rowCount(); i++) {
|
|
|
|
|
QStandardItem *infoItem = d->m_model->item(i, 0);
|
2014-08-29 16:32:42 +02:00
|
|
|
if (infoItem->data(TypeIdRole).toInt() == typeIndex) {
|
2014-04-03 11:15:56 +02:00
|
|
|
selectItem(infoItem);
|
2011-11-04 17:33:09 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-26 13:56:14 +02:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QModelIndex QmlProfilerStatisticsMainView::selectedModelIndex() const
|
2011-08-24 11:18:48 +02:00
|
|
|
{
|
|
|
|
|
QModelIndexList sel = selectedIndexes();
|
|
|
|
|
if (sel.isEmpty())
|
|
|
|
|
return QModelIndex();
|
|
|
|
|
else
|
|
|
|
|
return sel.first();
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QString QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate::textForItem(
|
|
|
|
|
QStandardItem *item, bool recursive) const
|
2011-08-24 11:18:48 +02:00
|
|
|
{
|
|
|
|
|
QString str;
|
|
|
|
|
|
|
|
|
|
if (recursive) {
|
|
|
|
|
// indentation
|
|
|
|
|
QStandardItem *itemParent = item->parent();
|
|
|
|
|
while (itemParent) {
|
2012-11-26 21:18:13 +02:00
|
|
|
str += QLatin1String(" ");
|
2011-08-24 11:18:48 +02:00
|
|
|
itemParent = itemParent->parent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// item's data
|
|
|
|
|
int colCount = m_model->columnCount();
|
|
|
|
|
for (int j = 0; j < colCount; ++j) {
|
2015-12-04 13:30:54 +01:00
|
|
|
QStandardItem *colItem = item->parent() ? item->parent()->child(item->row(),j) :
|
|
|
|
|
m_model->item(item->row(),j);
|
2011-08-24 11:18:48 +02:00
|
|
|
str += colItem->data(Qt::DisplayRole).toString();
|
2012-11-26 21:18:13 +02:00
|
|
|
if (j < colCount-1) str += QLatin1Char('\t');
|
2011-08-24 11:18:48 +02:00
|
|
|
}
|
2012-11-26 21:18:13 +02:00
|
|
|
str += QLatin1Char('\n');
|
2011-08-24 11:18:48 +02:00
|
|
|
|
|
|
|
|
// recursively print children
|
|
|
|
|
if (recursive && item->child(0))
|
|
|
|
|
for (int j = 0; j != item->rowCount(); j++)
|
|
|
|
|
str += textForItem(item->child(j));
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsMainView::copyTableToClipboard() const
|
2011-08-24 11:18:48 +02:00
|
|
|
{
|
|
|
|
|
QString str;
|
2011-10-28 16:59:40 +02:00
|
|
|
// headers
|
|
|
|
|
int columnCount = d->m_model->columnCount();
|
|
|
|
|
for (int i = 0; i < columnCount; ++i) {
|
|
|
|
|
str += d->m_model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString();
|
|
|
|
|
if (i < columnCount - 1)
|
2012-11-26 21:18:13 +02:00
|
|
|
str += QLatin1Char('\t');
|
2011-10-28 16:59:40 +02:00
|
|
|
else
|
2012-11-26 21:18:13 +02:00
|
|
|
str += QLatin1Char('\n');
|
2011-10-28 16:59:40 +02:00
|
|
|
}
|
|
|
|
|
// data
|
|
|
|
|
int rowCount = d->m_model->rowCount();
|
|
|
|
|
for (int i = 0; i != rowCount; ++i) {
|
2011-08-24 11:18:48 +02:00
|
|
|
str += d->textForItem(d->m_model->item(i));
|
|
|
|
|
}
|
|
|
|
|
QClipboard *clipboard = QApplication::clipboard();
|
|
|
|
|
clipboard->setText(str, QClipboard::Selection);
|
|
|
|
|
clipboard->setText(str, QClipboard::Clipboard);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsMainView::copyRowToClipboard() const
|
2011-08-24 11:18:48 +02:00
|
|
|
{
|
|
|
|
|
QString str;
|
2014-08-29 16:32:42 +02:00
|
|
|
str = d->textForItem(d->m_model->itemFromIndex(selectedModelIndex()), false);
|
2011-08-24 11:18:48 +02:00
|
|
|
|
|
|
|
|
QClipboard *clipboard = QApplication::clipboard();
|
|
|
|
|
clipboard->setText(str, QClipboard::Selection);
|
|
|
|
|
clipboard->setText(str, QClipboard::Clipboard);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
class QmlProfilerStatisticsRelativesView::QmlProfilerStatisticsRelativesViewPrivate
|
2013-08-08 13:28:08 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2015-12-04 13:30:54 +01:00
|
|
|
QmlProfilerStatisticsRelativesViewPrivate(QmlProfilerStatisticsRelativesView *qq):q(qq) {}
|
|
|
|
|
~QmlProfilerStatisticsRelativesViewPrivate() {}
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
QmlProfilerStatisticsRelativesModel *model;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QmlProfilerStatisticsRelativesView *q;
|
2013-08-08 13:28:08 +02:00
|
|
|
};
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QmlProfilerStatisticsRelativesView::QmlProfilerStatisticsRelativesView(
|
2015-12-04 15:41:20 +01:00
|
|
|
QmlProfilerStatisticsRelativesModel *model, QWidget *parent) :
|
2015-12-04 13:30:54 +01:00
|
|
|
Utils::TreeView(parent), d(new QmlProfilerStatisticsRelativesViewPrivate(this))
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2015-07-01 18:04:26 +02:00
|
|
|
setViewDefaults(this);
|
2015-12-04 15:41:20 +01:00
|
|
|
d->model = model;
|
|
|
|
|
QStandardItemModel *itemModel = new QStandardItemModel(this);
|
|
|
|
|
itemModel->setSortRole(SortRole);
|
|
|
|
|
setModel(itemModel);
|
2011-11-04 17:33:09 +01:00
|
|
|
setRootIsDecorated(false);
|
|
|
|
|
updateHeader();
|
|
|
|
|
|
2018-01-31 12:37:21 +01:00
|
|
|
setSortingEnabled(true);
|
|
|
|
|
sortByColumn(DEFAULT_SORT_COLUMN, Qt::DescendingOrder);
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
connect(this, &QAbstractItemView::activated,
|
|
|
|
|
this, &QmlProfilerStatisticsRelativesView::jumpToItem);
|
2014-03-06 16:12:02 +01:00
|
|
|
|
|
|
|
|
// Clear when new data available as the selection may be invalid now.
|
2015-12-04 15:41:20 +01:00
|
|
|
connect(d->model, &QmlProfilerStatisticsRelativesModel::dataAvailable,
|
2015-12-04 13:30:54 +01:00
|
|
|
this, &QmlProfilerStatisticsRelativesView::clear);
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QmlProfilerStatisticsRelativesView::~QmlProfilerStatisticsRelativesView()
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2013-08-08 13:28:08 +02:00
|
|
|
delete d;
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsRelativesView::displayType(int typeIndex)
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2018-01-31 12:37:21 +01:00
|
|
|
SortPreserver sorter(this);
|
2015-12-04 15:41:20 +01:00
|
|
|
rebuildTree(d->model->getData(typeIndex));
|
2011-11-04 17:33:09 +01:00
|
|
|
|
|
|
|
|
updateHeader();
|
|
|
|
|
resizeColumnToContents(0);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsRelativesView::rebuildTree(
|
2015-12-04 15:41:20 +01:00
|
|
|
const QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesMap &map)
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(treeModel());
|
|
|
|
|
treeModel()->clear();
|
|
|
|
|
|
|
|
|
|
QStandardItem *topLevelItem = treeModel()->invisibleRootItem();
|
2016-04-26 11:50:59 +02:00
|
|
|
const QVector<QmlEventType> &typeList = d->model->getTypes();
|
2014-06-13 16:34:30 +02:00
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesMap::const_iterator it;
|
|
|
|
|
for (it = map.constBegin(); it != map.constEnd(); ++it) {
|
2016-06-08 19:00:59 +02:00
|
|
|
const QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesData &stats = it.value();
|
2014-06-13 16:34:30 +02:00
|
|
|
int typeIndex = it.key();
|
2016-04-26 11:50:59 +02:00
|
|
|
const QmlEventType &type = (typeIndex != -1 ? typeList[typeIndex] : *rootEventType());
|
2011-11-04 17:33:09 +01:00
|
|
|
QList<QStandardItem *> newRow;
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2015-12-04 15:41:20 +01:00
|
|
|
// ToDo: here we were going to search for the data in the other model
|
|
|
|
|
// maybe we should store the data in this model and get it here
|
2013-08-08 13:28:08 +02:00
|
|
|
// no indirections at this level of abstraction!
|
2016-12-09 16:17:07 +01:00
|
|
|
newRow << new StatisticsViewItem(
|
|
|
|
|
type.displayName().isEmpty() ? tr("<bytecode>") : type.displayName(),
|
|
|
|
|
type.displayName());
|
|
|
|
|
const QString typeName = QmlProfilerStatisticsMainView::nameForType(type.rangeType());
|
|
|
|
|
newRow << new StatisticsViewItem(typeName, typeName);
|
2016-09-16 16:10:19 +02:00
|
|
|
newRow << new StatisticsViewItem(Timeline::formatTime(stats.duration),
|
2016-12-09 16:17:07 +01:00
|
|
|
stats.duration);
|
|
|
|
|
newRow << new StatisticsViewItem(QString::number(stats.calls), stats.calls);
|
2016-06-06 19:51:55 +02:00
|
|
|
newRow << new StatisticsViewItem(type.data().isEmpty() ? tr("Source code not available") :
|
2016-12-09 16:17:07 +01:00
|
|
|
type.data(), type.data());
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2016-12-09 16:17:07 +01:00
|
|
|
QStandardItem *first = newRow.at(0);
|
|
|
|
|
first->setData(typeIndex, TypeIdRole);
|
2016-06-06 19:51:55 +02:00
|
|
|
const QmlEventLocation location(type.location());
|
2016-12-09 16:17:07 +01:00
|
|
|
first->setData(location.filename(), FilenameRole);
|
|
|
|
|
first->setData(location.line(), LineRole);
|
|
|
|
|
first->setData(location.column(), ColumnRole);
|
|
|
|
|
|
2016-06-06 19:51:55 +02:00
|
|
|
newRow.at(1)->setData(QmlProfilerStatisticsMainView::nameForType(type.rangeType()));
|
2016-06-08 19:00:59 +02:00
|
|
|
newRow.at(2)->setData(stats.duration);
|
|
|
|
|
newRow.at(3)->setData(stats.calls);
|
2016-06-06 19:51:55 +02:00
|
|
|
newRow.at(4)->setData(type.data());
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2016-12-28 18:12:49 +01:00
|
|
|
if (stats.isRecursive) {
|
2013-08-08 13:28:08 +02:00
|
|
|
foreach (QStandardItem *item, newRow) {
|
2014-09-26 18:25:39 +02:00
|
|
|
item->setBackground(colors()->noteBackground);
|
2016-12-28 18:12:49 +01:00
|
|
|
item->setToolTip(tr("called recursively"));
|
2013-08-08 13:28:08 +02:00
|
|
|
}
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2011-11-04 17:33:09 +01:00
|
|
|
foreach (QStandardItem *item, newRow)
|
|
|
|
|
item->setEditable(false);
|
|
|
|
|
|
|
|
|
|
topLevelItem->appendRow(newRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsRelativesView::clear()
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
|
|
|
|
if (treeModel()) {
|
2018-01-31 12:37:21 +01:00
|
|
|
SortPreserver sorter(this);
|
2011-11-04 17:33:09 +01:00
|
|
|
treeModel()->clear();
|
|
|
|
|
updateHeader();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsRelativesView::updateHeader()
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
2016-05-24 15:50:31 +02:00
|
|
|
bool calleesView = d->model->relation() == QmlProfilerStatisticsChilden;
|
2011-11-04 17:33:09 +01:00
|
|
|
|
|
|
|
|
if (treeModel()) {
|
2013-08-08 13:28:08 +02:00
|
|
|
treeModel()->setColumnCount(5);
|
2011-11-04 17:33:09 +01:00
|
|
|
|
|
|
|
|
int columnIndex = 0;
|
2013-08-08 13:28:08 +02:00
|
|
|
if (calleesView)
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(Callee)));
|
2011-11-04 17:33:09 +01:00
|
|
|
else
|
2013-08-08 13:28:08 +02:00
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(Caller)));
|
|
|
|
|
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(Type)));
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(TotalTime)));
|
2011-11-04 17:33:09 +01:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(CallCount)));
|
2011-12-05 16:32:05 +01:00
|
|
|
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
if (calleesView)
|
|
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(CalleeDescription)));
|
2011-11-04 17:33:09 +01:00
|
|
|
else
|
2013-08-08 13:28:08 +02:00
|
|
|
treeModel()->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(CallerDescription)));
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
QStandardItemModel *QmlProfilerStatisticsRelativesView::treeModel()
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
|
|
|
|
return qobject_cast<QStandardItemModel *>(model());
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 13:30:54 +01:00
|
|
|
void QmlProfilerStatisticsRelativesView::jumpToItem(const QModelIndex &index)
|
2011-11-04 17:33:09 +01:00
|
|
|
{
|
|
|
|
|
if (treeModel()) {
|
|
|
|
|
QStandardItem *infoItem = treeModel()->item(index.row(), 0);
|
2015-11-11 11:46:21 +01:00
|
|
|
// show in editor
|
|
|
|
|
getSourceLocation(infoItem, [this](const QString &fileName, int line, int column) {
|
|
|
|
|
emit gotoSourceLocation(fileName, line, column);
|
|
|
|
|
});
|
|
|
|
|
|
2014-08-29 16:32:42 +02:00
|
|
|
emit typeClicked(infoItem->data(TypeIdRole).toInt());
|
2011-11-04 17:33:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 15:05:45 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProfiler
|