2013-08-08 13:28:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2013-08-08 13:28:08 +02: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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2013-08-08 13:28:08 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** 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.
|
2013-08-08 13:28:08 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2013-08-08 13:28:08 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2014-02-18 17:32:20 +01:00
|
|
|
#ifndef QMLPROFILERDATAMODEL_H
|
|
|
|
|
#define QMLPROFILERDATAMODEL_H
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2015-09-10 16:03:21 +02:00
|
|
|
#include "qmlprofilermodelmanager.h"
|
|
|
|
|
|
2014-06-03 16:57:32 +02:00
|
|
|
#include <qmldebug/qmlprofilereventtypes.h>
|
2015-09-10 16:03:21 +02:00
|
|
|
#include <utils/fileinprojectfinder.h>
|
2013-09-02 14:04:12 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
namespace QmlProfiler {
|
|
|
|
|
|
2015-09-10 16:03:21 +02:00
|
|
|
class QMLPROFILER_EXPORT QmlProfilerDataModel : public QObject
|
2013-08-08 13:28:08 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2014-06-13 16:34:30 +02:00
|
|
|
struct QmlEventTypeData {
|
2015-11-13 15:31:32 +01:00
|
|
|
QmlEventTypeData(const QString &displayName = QString(),
|
|
|
|
|
const QmlDebug::QmlEventLocation &location = QmlDebug::QmlEventLocation(),
|
|
|
|
|
QmlDebug::Message message = QmlDebug::MaximumMessage,
|
|
|
|
|
QmlDebug::RangeType rangeType = QmlDebug::MaximumRangeType,
|
|
|
|
|
int detailType = -1, const QString &data = QString()) :
|
|
|
|
|
displayName(displayName), location(location), message(message), rangeType(rangeType),
|
|
|
|
|
detailType(detailType), data(data)
|
|
|
|
|
{}
|
|
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
QString displayName;
|
2014-06-13 16:34:30 +02:00
|
|
|
QmlDebug::QmlEventLocation location;
|
2014-06-03 16:57:32 +02:00
|
|
|
QmlDebug::Message message;
|
|
|
|
|
QmlDebug::RangeType rangeType;
|
|
|
|
|
int detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType
|
2014-06-13 16:34:30 +02:00
|
|
|
QString data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct QmlEventData {
|
2015-11-13 15:31:32 +01:00
|
|
|
QmlEventData(qint64 startTime = -1, qint64 duration = -1, int typeIndex = -1,
|
|
|
|
|
qint64 num0 = 0, qint64 num1 = 0, qint64 num2 = 0, qint64 num3 = 0,
|
|
|
|
|
qint64 num4 = 0) :
|
|
|
|
|
m_startTime(startTime), m_duration(duration), m_dataType(NumericData),
|
|
|
|
|
m_typeIndex(typeIndex)
|
|
|
|
|
{
|
|
|
|
|
m_numericData[0] = num0;
|
|
|
|
|
m_numericData[1] = num1;
|
|
|
|
|
m_numericData[2] = num2;
|
|
|
|
|
m_numericData[3] = num3;
|
|
|
|
|
m_numericData[4] = num4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlEventData(qint64 startTime, qint64 duration, int typeIndex, const QString &data)
|
|
|
|
|
: m_startTime(startTime), m_duration(duration), m_typeIndex(typeIndex)
|
|
|
|
|
{
|
|
|
|
|
assignStringData(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlEventData(const QmlEventData &other) :
|
|
|
|
|
m_startTime(other.m_startTime), m_duration(other.m_duration),
|
|
|
|
|
m_dataType(other.m_dataType), m_typeIndex(other.m_typeIndex)
|
|
|
|
|
{
|
|
|
|
|
assignData(other);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlEventData &operator=(const QmlEventData &other)
|
|
|
|
|
{
|
|
|
|
|
if (this != &other) {
|
|
|
|
|
if (m_dataType == StringData)
|
|
|
|
|
m_stringData.~QString();
|
|
|
|
|
|
|
|
|
|
m_startTime = other.m_startTime;
|
|
|
|
|
m_duration = other.m_duration;
|
|
|
|
|
m_typeIndex = other.m_typeIndex;
|
|
|
|
|
m_dataType = other.m_dataType;
|
|
|
|
|
assignData(other);
|
|
|
|
|
}
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~QmlEventData()
|
|
|
|
|
{
|
|
|
|
|
if (m_dataType == StringData)
|
|
|
|
|
m_stringData.~QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qint64 startTime() const { return m_startTime; }
|
|
|
|
|
void setStartTime(qint64 startTime) { m_startTime = startTime; }
|
|
|
|
|
|
|
|
|
|
qint64 duration() const { return m_duration; }
|
|
|
|
|
void setDuration(qint64 duration) { m_duration = duration; }
|
|
|
|
|
|
|
|
|
|
int typeIndex() const { return m_typeIndex; }
|
|
|
|
|
void setTypeIndex(int typeIndex) { m_typeIndex = typeIndex; }
|
|
|
|
|
|
|
|
|
|
qint64 numericData(int i) const { return m_dataType == NumericData ? m_numericData[i] : 0; }
|
|
|
|
|
void setNumericData(int i, qint64 data)
|
|
|
|
|
{
|
|
|
|
|
if (m_dataType == StringData)
|
|
|
|
|
m_stringData.~QString();
|
|
|
|
|
|
|
|
|
|
m_dataType = NumericData;
|
|
|
|
|
m_numericData[i] = data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString stringData() const
|
|
|
|
|
{
|
|
|
|
|
switch (m_dataType) {
|
|
|
|
|
case NumericData: return QString();
|
|
|
|
|
case StringData: return m_stringData;
|
|
|
|
|
default: return QString::fromUtf8(m_characterData, m_characterDataLength);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setStringData(const QString &data)
|
|
|
|
|
{
|
|
|
|
|
if (m_dataType == StringData)
|
|
|
|
|
m_stringData.~QString();
|
|
|
|
|
|
|
|
|
|
assignStringData(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
static const quint8 StringData = 254;
|
|
|
|
|
static const quint8 NumericData = 255;
|
|
|
|
|
|
|
|
|
|
qint64 m_startTime;
|
|
|
|
|
qint64 m_duration;
|
|
|
|
|
union {
|
|
|
|
|
qint64 m_numericData[5];
|
|
|
|
|
QString m_stringData;
|
|
|
|
|
char m_characterData[5 * sizeof(qint64) + 3];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
quint8 m_dataType;
|
|
|
|
|
quint8 m_characterDataLength;
|
|
|
|
|
};
|
|
|
|
|
qint32 m_typeIndex;
|
|
|
|
|
|
|
|
|
|
void assignData(const QmlEventData &other)
|
|
|
|
|
{
|
|
|
|
|
switch (m_dataType) {
|
|
|
|
|
case StringData:
|
|
|
|
|
new (&m_stringData) QString(other.m_stringData);
|
|
|
|
|
break;
|
|
|
|
|
case NumericData:
|
|
|
|
|
for (int i = 0; i < 5; ++i)
|
|
|
|
|
m_numericData[i] = other.m_numericData[i];
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
memcpy(m_characterData, other.m_characterData, m_characterDataLength);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void assignStringData(const QString &data)
|
|
|
|
|
{
|
|
|
|
|
QByteArray cdata = data.toUtf8();
|
|
|
|
|
if (cdata.length() <= (int)sizeof(m_characterData)) {
|
|
|
|
|
m_characterDataLength = cdata.length();
|
|
|
|
|
memcpy(m_characterData, cdata.constData(), m_characterDataLength);
|
|
|
|
|
} else {
|
|
|
|
|
m_dataType = StringData;
|
|
|
|
|
new (&m_stringData) QString(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-08-08 13:28:08 +02:00
|
|
|
};
|
|
|
|
|
|
2014-09-26 15:49:49 +02:00
|
|
|
struct QmlEventNoteData {
|
2015-11-13 15:31:32 +01:00
|
|
|
QmlEventNoteData(int typeIndex = -1, qint64 startTime = -1, qint64 duration = -1,
|
|
|
|
|
const QString &text = QString()) :
|
|
|
|
|
typeIndex(typeIndex), startTime(startTime), duration(duration), text(text)
|
|
|
|
|
{}
|
|
|
|
|
|
2014-09-26 15:49:49 +02:00
|
|
|
int typeIndex;
|
|
|
|
|
qint64 startTime;
|
|
|
|
|
qint64 duration;
|
|
|
|
|
QString text;
|
|
|
|
|
};
|
|
|
|
|
|
2015-09-10 16:03:21 +02:00
|
|
|
static QString formatTime(qint64 timestamp);
|
|
|
|
|
|
|
|
|
|
explicit QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinder,
|
|
|
|
|
QmlProfilerModelManager *parent);
|
|
|
|
|
~QmlProfilerDataModel();
|
2013-08-08 13:28:08 +02:00
|
|
|
|
|
|
|
|
const QVector<QmlEventData> &getEvents() const;
|
2014-06-13 16:34:30 +02:00
|
|
|
const QVector<QmlEventTypeData> &getEventTypes() const;
|
2014-09-26 15:49:49 +02:00
|
|
|
const QVector<QmlEventNoteData> &getEventNotes() const;
|
2014-10-14 16:44:45 +02:00
|
|
|
void setData(qint64 traceStart, qint64 traceEnd, const QVector<QmlEventTypeData> &types,
|
|
|
|
|
const QVector<QmlEventData> &events);
|
2014-09-26 15:49:49 +02:00
|
|
|
void setNoteData(const QVector<QmlEventNoteData> ¬es);
|
2015-09-10 17:11:21 +02:00
|
|
|
void processData();
|
2014-08-12 13:39:22 +02:00
|
|
|
|
2013-08-08 13:28:08 +02:00
|
|
|
int count() const;
|
2015-09-10 16:03:21 +02:00
|
|
|
void clear();
|
|
|
|
|
bool isEmpty() const;
|
2014-06-03 16:57:32 +02:00
|
|
|
void addQmlEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType, int bindingType,
|
2014-06-13 16:33:30 +02:00
|
|
|
qint64 startTime, qint64 duration, const QString &data,
|
2014-06-03 16:57:32 +02:00
|
|
|
const QmlDebug::QmlEventLocation &location, qint64 ndata1, qint64 ndata2,
|
|
|
|
|
qint64 ndata3, qint64 ndata4, qint64 ndata5);
|
2013-08-08 13:28:08 +02:00
|
|
|
qint64 lastTimeMark() const;
|
|
|
|
|
|
2015-09-10 16:03:21 +02:00
|
|
|
signals:
|
|
|
|
|
void changed();
|
2015-09-10 17:11:21 +02:00
|
|
|
void requestReload();
|
2015-09-10 16:03:21 +02:00
|
|
|
|
2014-02-18 17:32:20 +01:00
|
|
|
protected slots:
|
|
|
|
|
void detailsChanged(int requestId, const QString &newString);
|
2015-09-10 16:03:21 +02:00
|
|
|
void detailsDone();
|
2013-08-08 13:28:08 +02:00
|
|
|
|
2014-02-18 17:32:20 +01:00
|
|
|
private:
|
2014-02-18 18:25:57 +01:00
|
|
|
class QmlProfilerDataModelPrivate;
|
2015-09-10 16:03:21 +02:00
|
|
|
QmlProfilerDataModelPrivate *d_ptr;
|
2014-02-18 18:25:57 +01:00
|
|
|
Q_DECLARE_PRIVATE(QmlProfilerDataModel)
|
2013-08-08 13:28:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|