QmlProfiler: Remove accepted() methods

The only place where we used them was handlesTypeId(), and there it was
wrong. Each QmlProfilerTimelineModel has exactly one main feature it
subscribes to. It might additionally accept events of some auxiliary
features for context, but it doesn't really "handle" the respective
types in the sense that you could, for example, attach notes to them.
Therefore, just checking for the main feature is the right thing to do.

Change-Id: If0c00444084b957f3b99d3456cdbf703ae4afc3d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Ulf Hermann
2018-05-11 17:12:17 +02:00
parent 3ce528d6af
commit 9685711cb3
14 changed files with 1 additions and 55 deletions

View File

@@ -175,12 +175,6 @@ void InputEventsModel::clear()
QmlProfilerTimelineModel::clear();
}
bool InputEventsModel::accepted(const QmlEventType &type) const
{
return QmlProfilerTimelineModel::accepted(type) &&
(type.detailType() == Mouse || type.detailType() == Key);
}
InputEventsModel::InputEvent::InputEvent(InputEventType type, int a, int b) :
type(type), a(a), b(b)
{

View File

@@ -44,7 +44,6 @@ public:
InputEventsModel(QmlProfilerModelManager *manager, Timeline::TimelineModelAggregator *parent);
bool accepted(const QmlEventType &type) const override;
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
void finalize() override;
void clear() override;

View File

@@ -141,12 +141,6 @@ QVariantMap MemoryUsageModel::details(int index) const
return result;
}
bool MemoryUsageModel::accepted(const QmlEventType &type) const
{
return QmlProfilerTimelineModel::accepted(type)
|| (type.rangeType() != MaximumRangeType && type.rangeType() != Compiling);
}
void MemoryUsageModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
{
if (type.message() != MemoryAllocation) {

View File

@@ -66,7 +66,6 @@ public:
QVariantList labels() const override;
QVariantMap details(int index) const override;
bool accepted(const QmlEventType &type) const override;
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
void finalize() override;
void clear() override;

View File

@@ -55,11 +55,6 @@ void QmlProfilerAnimationsModel::clear()
QmlProfilerTimelineModel::clear();
}
bool QmlProfilerAnimationsModel::accepted(const QmlEventType &type) const
{
return QmlProfilerTimelineModel::accepted(type) && type.detailType() == AnimationFrame;
}
void QmlProfilerAnimationsModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
{
Q_UNUSED(type);

View File

@@ -64,7 +64,6 @@ public:
QVariantList labels() const override;
QVariantMap details(int index) const override;
bool accepted(const QmlEventType &type) const override;
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
void finalize() override;
void clear() override;

View File

@@ -65,17 +65,12 @@ ProfileFeature QmlProfilerTimelineModel::mainFeature() const
return m_mainFeature;
}
bool QmlProfilerTimelineModel::accepted(const QmlEventType &type) const
{
return (type.rangeType() == m_rangeType && type.message() == m_message);
}
bool QmlProfilerTimelineModel::handlesTypeId(int typeIndex) const
{
if (typeIndex < 0)
return false;
return accepted(modelManager()->eventType(typeIndex));
return modelManager()->eventType(typeIndex).feature() == m_mainFeature;
}
QmlProfilerModelManager *QmlProfilerTimelineModel::modelManager() const

View File

@@ -50,7 +50,6 @@ public:
Message message() const;
ProfileFeature mainFeature() const;
virtual bool accepted(const QmlEventType &type) const;
bool handlesTypeId(int typeId) const override;
QVariantMap locationFromTypeId(int index) const;

View File

@@ -63,15 +63,6 @@ void InputEventsModelTest::initTestCase()
manager.finalize();
}
void InputEventsModelTest::testAccepted()
{
QVERIFY(!model.accepted(QmlEventType()));
QVERIFY(!model.accepted(QmlEventType(Event)));
QVERIFY(!model.accepted(QmlEventType(Event, MaximumRangeType)));
QVERIFY(model.accepted(QmlEventType(Event, MaximumRangeType, Key)));
QVERIFY(model.accepted(QmlEventType(Event, MaximumRangeType, Mouse)));
}
void InputEventsModelTest::testTypeId()
{
for (int i = 0; i < 10; ++i) {

View File

@@ -40,7 +40,6 @@ public:
private slots:
void initTestCase();
void testAccepted();
void testTypeId();
void testColor();
void testLabels();

View File

@@ -228,14 +228,6 @@ void MemoryUsageModelTest::testRelativeHeight()
QCOMPARE(model.relativeHeight(i), heights[i]);
}
void MemoryUsageModelTest::testAccepted()
{
QVERIFY(!model.accepted(QmlEventType()));
QVERIFY(!model.accepted(QmlEventType(MaximumMessage, MaximumRangeType, HeapPage)));
QVERIFY(model.accepted(QmlEventType(MemoryAllocation, MaximumRangeType, HeapPage)));
QVERIFY(model.accepted(QmlEventType(MaximumMessage, Javascript)));
}
void MemoryUsageModelTest::cleanupTestCase()
{
manager.clearAll();

View File

@@ -49,7 +49,6 @@ private slots:
void testCollapsedRow();
void testLocation();
void testRelativeHeight();
void testAccepted();
void cleanupTestCase();
private:

View File

@@ -56,14 +56,6 @@ void QmlProfilerAnimationsModelTest::initTestCase()
manager.finalize();
}
void QmlProfilerAnimationsModelTest::testAccepted()
{
QVERIFY(!model.accepted(QmlEventType()));
QVERIFY(!model.accepted(QmlEventType(Event)));
QVERIFY(!model.accepted(QmlEventType(Event, MaximumRangeType)));
QVERIFY(model.accepted(QmlEventType(Event, MaximumRangeType, AnimationFrame)));
}
void QmlProfilerAnimationsModelTest::testRowMaxValue()
{
QCOMPARE(model.rowMaxValue(0), 0);

View File

@@ -40,7 +40,6 @@ public:
private slots:
void initTestCase();
void testAccepted();
void testRowMaxValue();
void testRowNumbers();
void testTypeId();