QmlProfiler: Clean up statistics view

Fix some misnomers and remove an unused declaration.

Change-Id: Ia5e30ccc7c465a10c5214b7fe025aa0f578cdab4
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2016-06-08 19:00:59 +02:00
parent b326060da8
commit 5101a504b3
2 changed files with 47 additions and 49 deletions

View File

@@ -101,9 +101,9 @@ public:
QmlProfilerStatisticsView *q; QmlProfilerStatisticsView *q;
QmlProfilerStatisticsMainView *m_eventTree; QmlProfilerStatisticsMainView *m_statsTree;
QmlProfilerStatisticsRelativesView *m_eventChildren; QmlProfilerStatisticsRelativesView *m_statsChildren;
QmlProfilerStatisticsRelativesView *m_eventParents; QmlProfilerStatisticsRelativesView *m_statsParents;
QmlProfilerStatisticsModel *model; QmlProfilerStatisticsModel *model;
}; };
@@ -178,31 +178,31 @@ QmlProfilerStatisticsView::QmlProfilerStatisticsView(QmlProfilerModelManager *pr
d->model = new QmlProfilerStatisticsModel(profilerModelManager, this); d->model = new QmlProfilerStatisticsModel(profilerModelManager, this);
d->m_eventTree = new QmlProfilerStatisticsMainView(this, d->model); d->m_statsTree = new QmlProfilerStatisticsMainView(this, d->model);
connect(d->m_eventTree, &QmlProfilerStatisticsMainView::gotoSourceLocation, connect(d->m_statsTree, &QmlProfilerStatisticsMainView::gotoSourceLocation,
this, &QmlProfilerStatisticsView::gotoSourceLocation); this, &QmlProfilerStatisticsView::gotoSourceLocation);
connect(d->m_eventTree, &QmlProfilerStatisticsMainView::typeSelected, connect(d->m_statsTree, &QmlProfilerStatisticsMainView::typeSelected,
this, &QmlProfilerStatisticsView::typeSelected); this, &QmlProfilerStatisticsView::typeSelected);
d->m_eventChildren = new QmlProfilerStatisticsRelativesView( d->m_statsChildren = new QmlProfilerStatisticsRelativesView(
new QmlProfilerStatisticsRelativesModel(profilerModelManager, d->model, new QmlProfilerStatisticsRelativesModel(profilerModelManager, d->model,
QmlProfilerStatisticsChilden, this), QmlProfilerStatisticsChilden, this),
this); this);
d->m_eventParents = new QmlProfilerStatisticsRelativesView( d->m_statsParents = new QmlProfilerStatisticsRelativesView(
new QmlProfilerStatisticsRelativesModel(profilerModelManager, d->model, new QmlProfilerStatisticsRelativesModel(profilerModelManager, d->model,
QmlProfilerStatisticsParents, this), QmlProfilerStatisticsParents, this),
this); this);
connect(d->m_eventTree, &QmlProfilerStatisticsMainView::typeSelected, connect(d->m_statsTree, &QmlProfilerStatisticsMainView::typeSelected,
d->m_eventChildren, &QmlProfilerStatisticsRelativesView::displayType); d->m_statsChildren, &QmlProfilerStatisticsRelativesView::displayType);
connect(d->m_eventTree, &QmlProfilerStatisticsMainView::typeSelected, connect(d->m_statsTree, &QmlProfilerStatisticsMainView::typeSelected,
d->m_eventParents, &QmlProfilerStatisticsRelativesView::displayType); d->m_statsParents, &QmlProfilerStatisticsRelativesView::displayType);
connect(d->m_eventChildren, &QmlProfilerStatisticsRelativesView::typeClicked, connect(d->m_statsChildren, &QmlProfilerStatisticsRelativesView::typeClicked,
d->m_eventTree, &QmlProfilerStatisticsMainView::selectType); d->m_statsTree, &QmlProfilerStatisticsMainView::selectType);
connect(d->m_eventParents, &QmlProfilerStatisticsRelativesView::typeClicked, connect(d->m_statsParents, &QmlProfilerStatisticsRelativesView::typeClicked,
d->m_eventTree, &QmlProfilerStatisticsMainView::selectType); d->m_statsTree, &QmlProfilerStatisticsMainView::selectType);
connect(d->m_eventChildren, &QmlProfilerStatisticsRelativesView::gotoSourceLocation, connect(d->m_statsChildren, &QmlProfilerStatisticsRelativesView::gotoSourceLocation,
this, &QmlProfilerStatisticsView::gotoSourceLocation); this, &QmlProfilerStatisticsView::gotoSourceLocation);
connect(d->m_eventParents, &QmlProfilerStatisticsRelativesView::gotoSourceLocation, connect(d->m_statsParents, &QmlProfilerStatisticsRelativesView::gotoSourceLocation,
this, &QmlProfilerStatisticsView::gotoSourceLocation); this, &QmlProfilerStatisticsView::gotoSourceLocation);
// widget arrangement // widget arrangement
@@ -211,10 +211,10 @@ QmlProfilerStatisticsView::QmlProfilerStatisticsView(QmlProfilerModelManager *pr
groupLayout->setSpacing(0); groupLayout->setSpacing(0);
Core::MiniSplitter *splitterVertical = new Core::MiniSplitter; Core::MiniSplitter *splitterVertical = new Core::MiniSplitter;
splitterVertical->addWidget(d->m_eventTree); splitterVertical->addWidget(d->m_statsTree);
Core::MiniSplitter *splitterHorizontal = new Core::MiniSplitter; Core::MiniSplitter *splitterHorizontal = new Core::MiniSplitter;
splitterHorizontal->addWidget(d->m_eventParents); splitterHorizontal->addWidget(d->m_statsParents);
splitterHorizontal->addWidget(d->m_eventChildren); splitterHorizontal->addWidget(d->m_statsChildren);
splitterHorizontal->setOrientation(Qt::Horizontal); splitterHorizontal->setOrientation(Qt::Horizontal);
splitterVertical->addWidget(splitterHorizontal); splitterVertical->addWidget(splitterHorizontal);
splitterVertical->setOrientation(Qt::Vertical); splitterVertical->setOrientation(Qt::Vertical);
@@ -232,14 +232,14 @@ QmlProfilerStatisticsView::~QmlProfilerStatisticsView()
void QmlProfilerStatisticsView::clear() void QmlProfilerStatisticsView::clear()
{ {
d->m_eventTree->clear(); d->m_statsTree->clear();
d->m_eventChildren->clear(); d->m_statsChildren->clear();
d->m_eventParents->clear(); d->m_statsParents->clear();
} }
QModelIndex QmlProfilerStatisticsView::selectedModelIndex() const QModelIndex QmlProfilerStatisticsView::selectedModelIndex() const
{ {
return d->m_eventTree->selectedModelIndex(); return d->m_statsTree->selectedModelIndex();
} }
void QmlProfilerStatisticsView::contextMenuEvent(QContextMenuEvent *ev) void QmlProfilerStatisticsView::contextMenuEvent(QContextMenuEvent *ev)
@@ -288,25 +288,25 @@ void QmlProfilerStatisticsView::contextMenuEvent(QContextMenuEvent *ev)
bool QmlProfilerStatisticsView::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_statsTree->mapToGlobal(QPoint(0,0));
QPoint tableBottomRight = d->m_eventTree->mapToGlobal(QPoint(d->m_eventTree->width(), d->m_eventTree->height())); QPoint tableBottomRight = d->m_statsTree->mapToGlobal(QPoint(d->m_statsTree->width(), d->m_statsTree->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 QmlProfilerStatisticsView::copyTableToClipboard() const void QmlProfilerStatisticsView::copyTableToClipboard() const
{ {
d->m_eventTree->copyTableToClipboard(); d->m_statsTree->copyTableToClipboard();
} }
void QmlProfilerStatisticsView::copyRowToClipboard() const void QmlProfilerStatisticsView::copyRowToClipboard() const
{ {
d->m_eventTree->copyRowToClipboard(); d->m_statsTree->copyRowToClipboard();
} }
void QmlProfilerStatisticsView::selectByTypeId(int typeIndex) void QmlProfilerStatisticsView::selectByTypeId(int typeIndex)
{ {
if (d->m_eventTree->selectedTypeId() != typeIndex) if (d->m_statsTree->selectedTypeId() != typeIndex)
d->m_eventTree->selectType(typeIndex); d->m_statsTree->selectType(typeIndex);
} }
void QmlProfilerStatisticsView::onVisibleFeaturesChanged(quint64 features) void QmlProfilerStatisticsView::onVisibleFeaturesChanged(quint64 features)
@@ -316,12 +316,12 @@ void QmlProfilerStatisticsView::onVisibleFeaturesChanged(quint64 features)
void QmlProfilerStatisticsView::setShowExtendedStatistics(bool show) void QmlProfilerStatisticsView::setShowExtendedStatistics(bool show)
{ {
d->m_eventTree->setShowExtendedStatistics(show); d->m_statsTree->setShowExtendedStatistics(show);
} }
bool QmlProfilerStatisticsView::showExtendedStatistics() const bool QmlProfilerStatisticsView::showExtendedStatistics() const
{ {
return d->m_eventTree->showExtendedStatistics(); return d->m_statsTree->showExtendedStatistics();
} }
class QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate class QmlProfilerStatisticsMainView::QmlProfilerStatisticsMainViewPrivate
@@ -557,21 +557,20 @@ void QmlProfilerStatisticsMainView::parseModel()
const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &eventList = d->model->getData(); const QHash<int, QmlProfilerStatisticsModel::QmlEventStats> &eventList = d->model->getData();
const QVector<QmlEventType> &typeList = d->model->getTypes(); const QVector<QmlEventType> &typeList = d->model->getTypes();
QHash<int, QmlProfilerStatisticsModel::QmlEventStats>::ConstIterator it; QHash<int, QmlProfilerStatisticsModel::QmlEventStats>::ConstIterator it;
for (it = eventList.constBegin(); it != eventList.constEnd(); ++it) { for (it = eventList.constBegin(); it != eventList.constEnd(); ++it) {
int typeIndex = it.key(); int typeIndex = it.key();
const QmlProfilerStatisticsModel::QmlEventStats &stats = it.value(); const QmlProfilerStatisticsModel::QmlEventStats &stats = it.value();
const QmlEventType &event = (typeIndex != -1 ? typeList[typeIndex] : *rootEventType()); const QmlEventType &type = (typeIndex != -1 ? typeList[typeIndex] : *rootEventType());
QStandardItem *parentItem = d->m_model->invisibleRootItem(); QStandardItem *parentItem = d->m_model->invisibleRootItem();
QList<QStandardItem *> newRow; QList<QStandardItem *> newRow;
if (d->m_fieldShown[Name]) if (d->m_fieldShown[Name])
newRow << new StatisticsViewItem(event.displayName().isEmpty() ? tr("<bytecode>") : newRow << new StatisticsViewItem(type.displayName().isEmpty() ? tr("<bytecode>") :
event.displayName()); type.displayName());
if (d->m_fieldShown[Type]) { if (d->m_fieldShown[Type]) {
QString typeString = QmlProfilerStatisticsMainView::nameForType(event.rangeType()); QString typeString = QmlProfilerStatisticsMainView::nameForType(type.rangeType());
newRow << new StatisticsViewItem(typeString); newRow << new StatisticsViewItem(typeString);
newRow.last()->setData(QVariant(typeString)); newRow.last()->setData(QVariant(typeString));
} }
@@ -624,9 +623,9 @@ void QmlProfilerStatisticsMainView::parseModel()
} }
if (d->m_fieldShown[Details]) { if (d->m_fieldShown[Details]) {
newRow << new StatisticsViewItem(event.data().isEmpty() ? newRow << new StatisticsViewItem(type.data().isEmpty() ?
tr("Source code not available") : event.data()); tr("Source code not available") : type.data());
newRow.last()->setData(event.data()); newRow.last()->setData(type.data());
} }
@@ -638,7 +637,7 @@ void QmlProfilerStatisticsMainView::parseModel()
// metadata // metadata
newRow.at(0)->setData(typeIndex, TypeIdRole); newRow.at(0)->setData(typeIndex, TypeIdRole);
const QmlEventLocation location(event.location()); const QmlEventLocation location(type.location());
newRow.at(0)->setData(location.filename(), FilenameRole); newRow.at(0)->setData(location.filename(), FilenameRole);
newRow.at(0)->setData(location.line(), LineRole); newRow.at(0)->setData(location.line(), LineRole);
newRow.at(0)->setData(location.column(), ColumnRole); newRow.at(0)->setData(location.column(), ColumnRole);
@@ -848,7 +847,7 @@ void QmlProfilerStatisticsRelativesView::rebuildTree(
QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesMap::const_iterator it; QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesMap::const_iterator it;
for (it = map.constBegin(); it != map.constEnd(); ++it) { for (it = map.constBegin(); it != map.constEnd(); ++it) {
const QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesData &event = it.value(); const QmlProfilerStatisticsRelativesModel::QmlStatisticsRelativesData &stats = it.value();
int typeIndex = it.key(); int typeIndex = it.key();
const QmlEventType &type = (typeIndex != -1 ? typeList[typeIndex] : *rootEventType()); const QmlEventType &type = (typeIndex != -1 ? typeList[typeIndex] : *rootEventType());
QList<QStandardItem *> newRow; QList<QStandardItem *> newRow;
@@ -860,8 +859,8 @@ void QmlProfilerStatisticsRelativesView::rebuildTree(
type.displayName()); type.displayName());
newRow << new StatisticsViewItem(QmlProfilerStatisticsMainView::nameForType( newRow << new StatisticsViewItem(QmlProfilerStatisticsMainView::nameForType(
type.rangeType())); type.rangeType()));
newRow << new StatisticsViewItem(QmlProfilerDataModel::formatTime(event.duration)); newRow << new StatisticsViewItem(QmlProfilerDataModel::formatTime(stats.duration));
newRow << new StatisticsViewItem(QString::number(event.calls)); newRow << new StatisticsViewItem(QString::number(stats.calls));
newRow << new StatisticsViewItem(type.data().isEmpty() ? tr("Source code not available") : newRow << new StatisticsViewItem(type.data().isEmpty() ? tr("Source code not available") :
type.data()); type.data());
@@ -871,11 +870,11 @@ void QmlProfilerStatisticsRelativesView::rebuildTree(
newRow.at(0)->setData(location.line(), LineRole); newRow.at(0)->setData(location.line(), LineRole);
newRow.at(0)->setData(location.column(), ColumnRole); newRow.at(0)->setData(location.column(), ColumnRole);
newRow.at(1)->setData(QmlProfilerStatisticsMainView::nameForType(type.rangeType())); newRow.at(1)->setData(QmlProfilerStatisticsMainView::nameForType(type.rangeType()));
newRow.at(2)->setData(event.duration); newRow.at(2)->setData(stats.duration);
newRow.at(3)->setData(event.calls); newRow.at(3)->setData(stats.calls);
newRow.at(4)->setData(type.data()); newRow.at(4)->setData(type.data());
if (event.isBindingLoop) { if (stats.isBindingLoop) {
foreach (QStandardItem *item, newRow) { foreach (QStandardItem *item, newRow) {
item->setBackground(colors()->noteBackground); item->setBackground(colors()->noteBackground);
item->setToolTip(tr("Part of binding loop.")); item->setToolTip(tr("Part of binding loop."));

View File

@@ -107,7 +107,6 @@ public:
~QmlProfilerStatisticsMainView(); ~QmlProfilerStatisticsMainView();
void setFieldViewable(Fields field, bool show); void setFieldViewable(Fields field, bool show);
void setShowAnonymousEvents( bool showThem );
QModelIndex selectedModelIndex() const; QModelIndex selectedModelIndex() const;
void copyTableToClipboard() const; void copyTableToClipboard() const;