Commit 4e7d4ff8 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Define a main feature for timeline models



They will be shown and hidden when that feature is enabled or disabled.

Change-Id: I42b67bd25729901262298553b118fe2624941789
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent 7344c276
......@@ -47,12 +47,10 @@ namespace Internal {
QmlProfilerAnimationsModel::QmlProfilerAnimationsModel(QmlProfilerModelManager *manager,
QObject *parent) :
QmlProfilerTimelineModel(manager,
tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileAnimations)),
QmlDebug::Event, QmlDebug::MaximumRangeType, parent)
QmlProfilerTimelineModel(manager, QmlDebug::Event, QmlDebug::MaximumRangeType,
QmlDebug::ProfileAnimations, parent)
{
m_maxGuiThreadAnimations = m_maxRenderThreadAnimations = 0;
announceFeatures(1 << QmlDebug::ProfileAnimations);
}
void QmlProfilerAnimationsModel::clear()
......
......@@ -51,10 +51,10 @@ namespace Internal {
QmlProfilerRangeModel::QmlProfilerRangeModel(QmlProfilerModelManager *manager,
QmlDebug::RangeType range, QObject *parent) :
QmlProfilerTimelineModel(manager, categoryLabel(range), QmlDebug::MaximumMessage, range, parent)
QmlProfilerTimelineModel(manager, QmlDebug::MaximumMessage, range,
QmlDebug::featureFromRangeType(range), parent)
{
m_expandedRowTypes << -1;
announceFeatures(1ULL << QmlDebug::featureFromRangeType(rangeType()));
}
void QmlProfilerRangeModel::clear()
......@@ -186,12 +186,6 @@ void QmlProfilerRangeModel::findBindingLoops()
}
QString QmlProfilerRangeModel::categoryLabel(QmlDebug::RangeType rangeType)
{
return QCoreApplication::translate("MainView",
QmlProfilerModelManager::featureName(QmlDebug::featureFromRangeType(rangeType)));
}
int QmlProfilerRangeModel::expandedRow(int index) const
{
return m_data[index].displayRowExpanded;
......@@ -237,7 +231,8 @@ QVariantMap QmlProfilerRangeModel::details(int index) const
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
modelManager()->qmlModel()->getEventTypes();
result.insert(QStringLiteral("displayName"), categoryLabel(rangeType()));
result.insert(QStringLiteral("displayName"),
tr(QmlProfilerModelManager::featureName(mainFeature())));
result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(duration(index)));
result.insert(tr("Details"), types[id].data);
......
......@@ -64,8 +64,6 @@ public:
QmlProfilerRangeModel(QmlProfilerModelManager *manager, QmlDebug::RangeType range,
QObject *parent = 0);
static QString categoryLabel(QmlDebug::RangeType categoryIndex);
Q_INVOKABLE int expandedRow(int index) const;
Q_INVOKABLE int collapsedRow(int index) const;
int bindingLoopDest(int index) const;
......
......@@ -33,14 +33,18 @@
namespace QmlProfiler {
QmlProfilerTimelineModel::QmlProfilerTimelineModel(QmlProfilerModelManager *modelManager,
const QString &displayName,
QmlDebug::Message message,
QmlDebug::RangeType rangeType, QObject *parent) :
TimelineModel(modelManager->registerModelProxy(), displayName, parent), m_message(message),
m_rangeType(rangeType), m_modelManager(modelManager)
QmlDebug::RangeType rangeType,
QmlDebug::ProfileFeature mainFeature,
QObject *parent) :
TimelineModel(modelManager->registerModelProxy(),
tr(QmlProfilerModelManager::featureName(mainFeature)), parent),
m_message(message), m_rangeType(rangeType), m_mainFeature(mainFeature),
m_modelManager(modelManager)
{
connect(modelManager, &QmlProfilerModelManager::stateChanged,
this, &QmlProfilerTimelineModel::dataChanged);
announceFeatures(1ULL << m_mainFeature);
}
QmlDebug::RangeType QmlProfilerTimelineModel::rangeType() const
......@@ -53,6 +57,11 @@ QmlDebug::Message QmlProfilerTimelineModel::message() const
return m_message;
}
QmlDebug::ProfileFeature QmlProfilerTimelineModel::mainFeature() const
{
return m_mainFeature;
}
bool QmlProfilerTimelineModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const
{
return (event.rangeType == m_rangeType && event.message == m_message);
......@@ -105,6 +114,11 @@ void QmlProfilerTimelineModel::dataChanged()
emit labelsChanged();
}
void QmlProfilerTimelineModel::onVisibleFeaturesChanged(quint64 features)
{
setHidden(!(features & (1ULL << m_mainFeature)));
}
int QmlProfilerTimelineModel::bindingLoopDest(int index) const
{
Q_UNUSED(index);
......
......@@ -45,14 +45,15 @@ class QMLPROFILER_EXPORT QmlProfilerTimelineModel : public Timeline::TimelineMod
Q_PROPERTY(QmlProfilerModelManager *modelManager READ modelManager CONSTANT)
public:
QmlProfilerTimelineModel(QmlProfilerModelManager *modelManager, const QString &displayName,
QmlProfilerTimelineModel(QmlProfilerModelManager *modelManager,
QmlDebug::Message message, QmlDebug::RangeType rangeType,
QObject *parent);
QmlDebug::ProfileFeature mainFeature, QObject *parent);
QmlProfilerModelManager *modelManager() const;
QmlDebug::RangeType rangeType() const;
QmlDebug::Message message() const;
QmlDebug::ProfileFeature mainFeature() const;
virtual bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const;
bool handlesTypeId(int typeId) const;
......@@ -63,6 +64,7 @@ public:
private slots:
void dataChanged();
void onVisibleFeaturesChanged(quint64 features);
protected:
void updateProgress(qint64 count, qint64 max) const;
......@@ -71,6 +73,7 @@ protected:
private:
const QmlDebug::Message m_message;
const QmlDebug::RangeType m_rangeType;
const QmlDebug::ProfileFeature m_mainFeature;
QmlProfilerModelManager *const m_modelManager;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment