forked from qt-creator/qt-creator
QmlProfiler: Deduplicate dataChanged() slot in timeline models.
The same code was repeated all over the place. Change-Id: I70a8caa46c91a7b55fd7eecac32cdc53b5d94cfb Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -79,5 +79,24 @@ int AbstractTimelineModel::getBindingLoopDest(int index) const
|
||||
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:
|
||||
virtual int getEventType(int index) const = 0;
|
||||
virtual int getEventCategory(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 getStartTime(int index) const = 0;
|
||||
Q_INVOKABLE virtual qint64 getEndTime(int index) const = 0;
|
||||
@@ -106,6 +110,9 @@ signals:
|
||||
protected:
|
||||
QmlProfilerModelManager *m_modelManager;
|
||||
int m_modelId;
|
||||
|
||||
protected slots:
|
||||
void dataChanged();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -118,20 +118,6 @@ void PaintEventsModelProxy::clear()
|
||||
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)
|
||||
{
|
||||
return t1.startTime < t2.startTime;
|
||||
|
||||
@@ -108,8 +108,6 @@ public:
|
||||
|
||||
private slots:
|
||||
bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const;
|
||||
protected slots:
|
||||
void dataChanged();
|
||||
|
||||
private:
|
||||
class PaintEventsModelProxyPrivate;
|
||||
|
||||
@@ -130,20 +130,6 @@ void BasicTimelineModel::clear()
|
||||
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()
|
||||
{
|
||||
categorySpan.clear();
|
||||
|
||||
@@ -131,8 +131,6 @@ public:
|
||||
|
||||
private slots:
|
||||
bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const;
|
||||
protected slots:
|
||||
void dataChanged();
|
||||
|
||||
private:
|
||||
class BasicTimelineModelPrivate;
|
||||
|
||||
Reference in New Issue
Block a user