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,
|
2018-03-28 15:40:13 +02:00
|
|
|
ProfileFeature mainFeature,
|
|
|
|
|
Timeline::TimelineModelAggregator *parent) :
|
|
|
|
|
TimelineModel(parent), m_message(message), m_rangeType(rangeType), m_mainFeature(mainFeature),
|
2015-06-30 14:37:47 +02:00
|
|
|
m_modelManager(modelManager)
|
2014-10-28 19:01:43 +01:00
|
|
|
{
|
2016-03-16 18:00:58 +01:00
|
|
|
setDisplayName(tr(QmlProfilerModelManager::featureName(mainFeature)));
|
2018-03-27 15:58:43 +02:00
|
|
|
connect(modelManager, &QmlProfilerModelManager::typeDetailsFinished,
|
|
|
|
|
this, &Timeline::TimelineModel::labelsChanged);
|
|
|
|
|
connect(modelManager, &QmlProfilerModelManager::typeDetailsFinished,
|
|
|
|
|
this, &Timeline::TimelineModel::detailsChanged);
|
2015-06-30 15:55:33 +02:00
|
|
|
connect(modelManager, &QmlProfilerModelManager::visibleFeaturesChanged,
|
|
|
|
|
this, &QmlProfilerTimelineModel::onVisibleFeaturesChanged);
|
2018-04-05 09:47:33 +02:00
|
|
|
|
|
|
|
|
m_modelManager->registerFeatures(1ULL << m_mainFeature,
|
|
|
|
|
std::bind(&QmlProfilerTimelineModel::loadEvent, this,
|
|
|
|
|
std::placeholders::_1, std::placeholders::_2),
|
|
|
|
|
std::bind(&QmlProfilerTimelineModel::initialize, this),
|
|
|
|
|
std::bind(&QmlProfilerTimelineModel::finalize, this),
|
|
|
|
|
std::bind(&QmlProfilerTimelineModel::clear, this));
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-28 19:01:43 +01:00
|
|
|
bool QmlProfilerTimelineModel::handlesTypeId(int typeIndex) const
|
|
|
|
|
{
|
|
|
|
|
if (typeIndex < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
2018-05-11 17:12:17 +02:00
|
|
|
return modelManager()->eventType(typeIndex).feature() == m_mainFeature;
|
2014-10-28 19:01:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProfilerModelManager *QmlProfilerTimelineModel::modelManager() const
|
|
|
|
|
{
|
|
|
|
|
return m_modelManager;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-30 14:37:47 +02:00
|
|
|
void QmlProfilerTimelineModel::onVisibleFeaturesChanged(quint64 features)
|
|
|
|
|
{
|
|
|
|
|
setHidden(!(features & (1ULL << m_mainFeature)));
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
2018-03-28 09:42:28 +02:00
|
|
|
const QmlProfilerModelManager *manager = modelManager();
|
|
|
|
|
if (id >= manager->numEventTypes())
|
2015-11-13 17:53:00 +01:00
|
|
|
return result;
|
|
|
|
|
|
2018-03-28 09:42:28 +02:00
|
|
|
QmlEventLocation location = manager->eventType(id).location();
|
2015-11-13 17:53:00 +01:00
|
|
|
|
2016-06-06 18:04:53 +02:00
|
|
|
result.insert(QStringLiteral("file"), location.filename());
|
|
|
|
|
result.insert(QStringLiteral("line"), location.line());
|
|
|
|
|
result.insert(QStringLiteral("column"), location.column());
|
2015-11-13 17:53:00 +01:00
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-05 09:47:33 +02:00
|
|
|
void QmlProfilerTimelineModel::initialize()
|
|
|
|
|
{
|
2018-05-30 11:23:32 +02:00
|
|
|
setHidden(!(modelManager()->visibleFeatures() & (1ULL << m_mainFeature)));
|
2018-04-05 09:47:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProfilerTimelineModel::finalize()
|
|
|
|
|
{
|
|
|
|
|
emit contentChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 13:23:35 +02:00
|
|
|
} // namespace QmlProfiler
|