Commit 210e780c authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Deduplicate dataChanged() slot in timeline models.



The same code was repeated all over the place.

Change-Id: I70a8caa46c91a7b55fd7eecac32cdc53b5d94cfb
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent d9bb54b7
...@@ -79,5 +79,24 @@ int AbstractTimelineModel::getBindingLoopDest(int index) const ...@@ -79,5 +79,24 @@ int AbstractTimelineModel::getBindingLoopDest(int index) const
return -1; return -1;
} }
void AbstractTimelineModel::dataChanged()
{
switch (m_modelManager->state()) {
case QmlProfilerDataState::ProcessingData:
loadData();
break;
case QmlProfilerDataState::Empty:
clear();
break;
default:
break;
}
emit stateChanged();
emit dataAvailable();
emit emptyChanged();
emit expandedChanged();
}
} }
...@@ -79,6 +79,10 @@ public: ...@@ -79,6 +79,10 @@ public:
virtual int getEventType(int index) const = 0; virtual int getEventType(int index) const = 0;
virtual int getEventCategory(int index) const = 0; virtual int getEventCategory(int index) const = 0;
virtual int getEventRow(int index) const = 0; virtual int getEventRow(int index) const = 0;
virtual void loadData() = 0;
virtual void clear() = 0;
Q_INVOKABLE virtual qint64 getDuration(int index) const = 0; Q_INVOKABLE virtual qint64 getDuration(int index) const = 0;
Q_INVOKABLE virtual qint64 getStartTime(int index) const = 0; Q_INVOKABLE virtual qint64 getStartTime(int index) const = 0;
Q_INVOKABLE virtual qint64 getEndTime(int index) const = 0; Q_INVOKABLE virtual qint64 getEndTime(int index) const = 0;
...@@ -106,6 +110,9 @@ signals: ...@@ -106,6 +110,9 @@ signals:
protected: protected:
QmlProfilerModelManager *m_modelManager; QmlProfilerModelManager *m_modelManager;
int m_modelId; int m_modelId;
protected slots:
void dataChanged();
}; };
} }
......
...@@ -118,20 +118,6 @@ void PaintEventsModelProxy::clear() ...@@ -118,20 +118,6 @@ void PaintEventsModelProxy::clear()
m_modelManager->modelProxyCountUpdated(m_modelId, 0, 1); m_modelManager->modelProxyCountUpdated(m_modelId, 0, 1);
} }
void PaintEventsModelProxy::dataChanged()
{
if (m_modelManager->state() == QmlProfilerDataState::ProcessingData)
loadData();
if (m_modelManager->state() == QmlProfilerDataState::Empty)
clear();
emit stateChanged();
emit dataAvailable();
emit emptyChanged();
emit expandedChanged();
}
bool compareStartTimes(const PaintEventsModelProxy::QmlPaintEventData &t1, const PaintEventsModelProxy::QmlPaintEventData &t2) bool compareStartTimes(const PaintEventsModelProxy::QmlPaintEventData &t1, const PaintEventsModelProxy::QmlPaintEventData &t2)
{ {
return t1.startTime < t2.startTime; return t1.startTime < t2.startTime;
......
...@@ -108,8 +108,6 @@ public: ...@@ -108,8 +108,6 @@ public:
private slots: private slots:
bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const; bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const;
protected slots:
void dataChanged();
private: private:
class PaintEventsModelProxyPrivate; class PaintEventsModelProxyPrivate;
......
...@@ -130,20 +130,6 @@ void BasicTimelineModel::clear() ...@@ -130,20 +130,6 @@ void BasicTimelineModel::clear()
m_modelManager->modelProxyCountUpdated(m_modelId, 0, 1); m_modelManager->modelProxyCountUpdated(m_modelId, 0, 1);
} }
void BasicTimelineModel::dataChanged()
{
if (m_modelManager->state() == QmlProfilerDataState::ProcessingData)
loadData();
if (m_modelManager->state() == QmlProfilerDataState::Empty)
clear();
emit stateChanged();
emit dataAvailable();
emit emptyChanged();
emit expandedChanged();
}
void BasicTimelineModel::BasicTimelineModelPrivate::prepare() void BasicTimelineModel::BasicTimelineModelPrivate::prepare()
{ {
categorySpan.clear(); categorySpan.clear();
......
...@@ -131,8 +131,6 @@ public: ...@@ -131,8 +131,6 @@ public:
private slots: private slots:
bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const; bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const;
protected slots:
void dataChanged();
private: private:
class BasicTimelineModelPrivate; class BasicTimelineModelPrivate;
......
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