2015-12-11 11:09:10 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-14 11:03:04 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-12-11 11:09:10 +01:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-14 11:03:04 +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.
|
2015-12-11 11:09:10 +01:00
|
|
|
**
|
2016-01-14 11:03:04 +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.
|
2015-12-11 11:09:10 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2015-12-11 11:09:10 +01:00
|
|
|
|
2016-05-02 12:18:57 +02:00
|
|
|
#include "qmlprofilerdatamodel.h"
|
|
|
|
|
#include "qmlprofilernotesmodel.h"
|
|
|
|
|
#include "qmlprofilereventtypes.h"
|
2016-05-04 18:54:59 +02:00
|
|
|
#include "qmleventlocation.h"
|
2015-12-11 11:09:10 +01:00
|
|
|
|
|
|
|
|
#include <QSet>
|
|
|
|
|
#include <QVector>
|
2016-04-26 16:38:56 +02:00
|
|
|
#include <QStack>
|
2015-12-11 11:09:10 +01:00
|
|
|
#include <QAbstractItemModel>
|
|
|
|
|
|
2016-04-26 10:21:00 +02:00
|
|
|
namespace QmlProfiler {
|
2015-12-11 11:09:10 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
struct FlameGraphData {
|
|
|
|
|
FlameGraphData(FlameGraphData *parent = 0, int typeIndex = -1, qint64 duration = 0);
|
|
|
|
|
~FlameGraphData();
|
|
|
|
|
|
|
|
|
|
qint64 duration;
|
|
|
|
|
qint64 calls;
|
|
|
|
|
int typeIndex;
|
|
|
|
|
|
|
|
|
|
FlameGraphData *parent;
|
|
|
|
|
QVector<FlameGraphData *> children;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class FlameGraphModel : public QAbstractItemModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
Q_ENUMS(Role)
|
|
|
|
|
public:
|
|
|
|
|
enum Role {
|
2016-05-02 12:18:57 +02:00
|
|
|
TypeIdRole = Qt::UserRole + 1, // Sort by data, not by displayed string
|
|
|
|
|
TypeRole,
|
|
|
|
|
DurationRole,
|
|
|
|
|
CallCountRole,
|
|
|
|
|
DetailsRole,
|
|
|
|
|
FilenameRole,
|
|
|
|
|
LineRole,
|
|
|
|
|
ColumnRole,
|
|
|
|
|
NoteRole,
|
|
|
|
|
TimePerCallRole,
|
|
|
|
|
TimeInPercentRole,
|
|
|
|
|
RangeTypeRole,
|
|
|
|
|
LocationRole,
|
2015-12-11 11:09:10 +01:00
|
|
|
MaxRole
|
|
|
|
|
};
|
|
|
|
|
|
2016-04-26 10:21:00 +02:00
|
|
|
FlameGraphModel(QmlProfilerModelManager *modelManager, QObject *parent = 0);
|
2015-12-11 11:09:10 +01:00
|
|
|
|
|
|
|
|
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
|
|
|
|
|
QModelIndex parent(const QModelIndex &child) const override;
|
2016-02-08 14:11:41 +01:00
|
|
|
Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
2015-12-11 11:09:10 +01:00
|
|
|
int columnCount(const QModelIndex &parent) const override;
|
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
|
|
|
|
|
|
public slots:
|
2016-04-26 16:38:56 +02:00
|
|
|
void loadEvent(const QmlEvent &event, const QmlEventType &type);
|
|
|
|
|
void finalize();
|
|
|
|
|
void onModelManagerStateChanged();
|
2015-12-11 11:09:10 +01:00
|
|
|
void loadData(qint64 rangeStart = -1, qint64 rangeEnd = -1);
|
|
|
|
|
void loadNotes(int typeId, bool emitSignal);
|
2016-04-26 16:38:56 +02:00
|
|
|
void clear();
|
2015-12-11 11:09:10 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
friend class FlameGraphRelativesModel;
|
|
|
|
|
friend class FlameGraphParentsModel;
|
|
|
|
|
friend class FlameGraphChildrenModel;
|
|
|
|
|
|
|
|
|
|
QVariant lookup(const FlameGraphData &data, int role) const;
|
2016-04-26 16:38:56 +02:00
|
|
|
FlameGraphData *pushChild(FlameGraphData *parent, const QmlEvent &data);
|
2015-12-11 11:09:10 +01:00
|
|
|
|
|
|
|
|
int m_selectedTypeIndex;
|
2016-04-26 16:38:56 +02:00
|
|
|
|
|
|
|
|
// used by binding loop detection
|
|
|
|
|
QStack<QmlEvent> m_callStack;
|
2015-12-11 11:09:10 +01:00
|
|
|
FlameGraphData m_stackBottom;
|
2016-04-26 16:38:56 +02:00
|
|
|
FlameGraphData *m_stackTop;
|
2015-12-11 11:09:10 +01:00
|
|
|
|
|
|
|
|
int m_modelId;
|
2016-04-26 10:21:00 +02:00
|
|
|
QmlProfilerModelManager *m_modelManager;
|
2015-12-11 11:09:10 +01:00
|
|
|
|
2016-05-02 12:18:57 +02:00
|
|
|
QList<RangeType> m_acceptedTypes;
|
2015-12-11 11:09:10 +01:00
|
|
|
QSet<int> m_typeIdsWithNotes;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2016-04-26 10:21:00 +02:00
|
|
|
} // namespace QmlProfiler
|