2014-10-28 19:01:43 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-10-28 19:01:43 +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-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.
|
2014-10-28 19:01:43 +01: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.
|
2014-10-28 19:01:43 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qmlprofilertimelinemodel.h"
|
|
|
|
|
|
|
|
|
|
namespace QmlProfiler {
|
|
|
|
|
|
|
|
|
|
QmlProfilerTimelineModel::QmlProfilerTimelineModel(QmlProfilerModelManager *modelManager,
|
2016-05-02 12:18:57 +02:00
|
|
|
Message message, RangeType rangeType,
|
|
|
|
|
ProfileFeature mainFeature, QObject *parent) :
|
2016-03-16 18:00:58 +01:00
|
|
|
TimelineModel(modelManager->registerModelProxy(), parent),
|
2015-06-30 14:37:47 +02:00
|
|
|
m_message(message), m_rangeType(rangeType), m_mainFeature(mainFeature),
|
|
|
|
|
m_modelManager(modelManager)
|
2014-10-28 19:01:43 +01:00
|
|
|
{
|
2016-03-16 18:00:58 +01:00
|
|
|
setDisplayName(tr(QmlProfilerModelManager::featureName(mainFeature)));
|
2015-04-14 15:17:30 +02:00
|
|
|
connect(modelManager, &QmlProfilerModelManager::stateChanged,
|
2014-10-28 19:01:43 +01:00
|
|
|
this, &QmlProfilerTimelineModel::dataChanged);
|
2015-06-30 15:55:33 +02:00
|
|
|
connect(modelManager, &QmlProfilerModelManager::visibleFeaturesChanged,
|
|
|
|
|
this, &QmlProfilerTimelineModel::onVisibleFeaturesChanged);
|
2015-06-30 14:37:47 +02:00
|
|
|
announceFeatures(1ULL << m_mainFeature);
|
2014-10-28 19:01:43 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-02 12:18:57 +02:00
|
|
|
RangeType QmlProfilerTimelineModel::rangeType() const
|
2014-10-28 19:01:43 +01:00
|
|
|
{
|
|
|
|
|
return m_rangeType;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-02 12:18:57 +02:00
|
|
|
Message QmlProfilerTimelineModel::message() const
|
2014-10-28 19:01:43 +01:00
|
|
|
{
|
|
|
|
|
return m_message;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-02 12:18:57 +02:00
|
|
|
ProfileFeature QmlProfilerTimelineModel::mainFeature() const
|
2015-06-30 14:37:47 +02:00
|
|
|
{
|
|
|
|
|
return m_mainFeature;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 11:50:59 +02:00
|
|
|
bool QmlProfilerTimelineModel::accepted(const QmlEventType &event) const
|
2014-10-28 19:01:43 +01:00
|
|
|
{
|
|
|
|
|
return (event.rangeType == m_rangeType && event.message == m_message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlProfilerTimelineModel::handlesTypeId(int typeIndex) const
|
|
|
|
|
{
|
|
|
|
|
if (typeIndex < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
2016-04-26 11:50:59 +02:00
|
|
|
return accepted(modelManager()->qmlModel()->eventTypes().at(typeIndex));
|
2014-10-28 19:01:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerTimelineModel::clear()
|
|
|
|
|
{
|
|
|
|
|
TimelineModel::clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProfilerModelManager *QmlProfilerTimelineModel::modelManager() const
|
|
|
|
|
{
|
|
|
|
|
return m_modelManager;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-28 16:19:17 +02:00
|
|
|
void QmlProfilerTimelineModel::announceFeatures(quint64 features)
|
2014-10-28 19:01:43 +01:00
|
|
|
{
|
2016-04-28 16:19:17 +02:00
|
|
|
m_modelManager->announceFeatures(
|
|
|
|
|
features, [this](const QmlEvent &event, const QmlEventType &type) {
|
|
|
|
|
loadEvent(event, type);
|
|
|
|
|
}, [this]() {
|
|
|
|
|
finalize();
|
|
|
|
|
});
|
2014-10-28 19:01:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerTimelineModel::dataChanged()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
switch (m_modelManager->state()) {
|
2015-09-10 13:51:54 +02:00
|
|
|
case QmlProfilerModelManager::Done:
|
2014-10-28 19:01:43 +01:00
|
|
|
emit emptyChanged();
|
|
|
|
|
break;
|
2015-09-10 13:51:54 +02:00
|
|
|
case QmlProfilerModelManager::ClearingData:
|
2014-10-28 19:01:43 +01:00
|
|
|
clear();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-10-30 14:59:57 +01:00
|
|
|
|
|
|
|
|
emit labelsChanged();
|
2014-10-28 19:01:43 +01:00
|
|
|
}
|
|
|
|
|
|
2015-06-30 14:37:47 +02:00
|
|
|
void QmlProfilerTimelineModel::onVisibleFeaturesChanged(quint64 features)
|
|
|
|
|
{
|
|
|
|
|
setHidden(!(features & (1ULL << m_mainFeature)));
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-28 19:01:43 +01:00
|
|
|
int QmlProfilerTimelineModel::bindingLoopDest(int index) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(index);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-13 17:53:00 +01:00
|
|
|
QVariantMap QmlProfilerTimelineModel::locationFromTypeId(int index) const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap result;
|
|
|
|
|
int id = typeId(index);
|
|
|
|
|
if (id < 0)
|
|
|
|
|
return result;
|
|
|
|
|
|
2016-04-26 11:50:59 +02:00
|
|
|
auto types = modelManager()->qmlModel()->eventTypes();
|
2015-11-13 17:53:00 +01:00
|
|
|
if (id >= types.length())
|
|
|
|
|
return result;
|
|
|
|
|
|
2016-05-02 12:18:57 +02:00
|
|
|
const QmlEventLocation &location = types.at(id).location;
|
2015-11-13 17:53:00 +01:00
|
|
|
|
|
|
|
|
result.insert(QStringLiteral("file"), location.filename);
|
|
|
|
|
result.insert(QStringLiteral("line"), location.line);
|
|
|
|
|
result.insert(QStringLiteral("column"), location.column);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 13:23:35 +02:00
|
|
|
} // namespace QmlProfiler
|