forked from qt-creator/qt-creator
Timeline: Add stash() and restore() methods to notes model
Those are needed when manipulating the model in a way that may change the indices, like restricting to a range or filtering by categories. Change-Id: I9f218d269cf23104c306960ef77c0fc41591daa1 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -179,6 +179,14 @@ void TimelineNotesModel::resetModified()
|
|||||||
d->modified = false;
|
d->modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TimelineNotesModel::stash()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimelineNotesModel::restore()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void TimelineNotesModel::removeTimelineModel(const TimelineModel *timelineModel)
|
void TimelineNotesModel::removeTimelineModel(const TimelineModel *timelineModel)
|
||||||
{
|
{
|
||||||
Q_D(TimelineNotesModel);
|
Q_D(TimelineNotesModel);
|
||||||
|
@@ -61,7 +61,9 @@ public:
|
|||||||
bool isModified() const;
|
bool isModified() const;
|
||||||
void resetModified();
|
void resetModified();
|
||||||
|
|
||||||
void clear();
|
virtual void stash();
|
||||||
|
virtual void restore();
|
||||||
|
virtual void clear();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const TimelineModel *timelineModelByModelId(int modelId) const;
|
const TimelineModel *timelineModelByModelId(int modelId) const;
|
||||||
|
@@ -536,7 +536,7 @@ void QmlProfilerModelManager::save(const QString &filename)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->notesModel->saveData();
|
d->notesModel->stash();
|
||||||
|
|
||||||
QmlProfilerFileWriter *writer = new QmlProfilerFileWriter(this);
|
QmlProfilerFileWriter *writer = new QmlProfilerFileWriter(this);
|
||||||
writer->setTraceTime(traceTime()->startTime(), traceTime()->endTime(),
|
writer->setTraceTime(traceTime()->startTime(), traceTime()->endTime(),
|
||||||
@@ -713,7 +713,7 @@ void QmlProfilerModelManager::clear()
|
|||||||
|
|
||||||
void QmlProfilerModelManager::restrictToRange(qint64 startTime, qint64 endTime)
|
void QmlProfilerModelManager::restrictToRange(qint64 startTime, qint64 endTime)
|
||||||
{
|
{
|
||||||
d->notesModel->saveData();
|
d->notesModel->stash();
|
||||||
const QVector<QmlNote> notes = d->notesModel->notes();
|
const QVector<QmlNote> notes = d->notesModel->notes();
|
||||||
d->notesModel->clear();
|
d->notesModel->clear();
|
||||||
|
|
||||||
|
@@ -83,7 +83,7 @@ int QmlProfilerNotesModel::addQmlNote(int typeId, int collapsedRow, qint64 start
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QmlProfilerNotesModel::loadData()
|
void QmlProfilerNotesModel::restore()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
QSignalBlocker blocker(this);
|
QSignalBlocker blocker(this);
|
||||||
@@ -97,7 +97,7 @@ void QmlProfilerNotesModel::loadData()
|
|||||||
emit changed(-1, -1, -1);
|
emit changed(-1, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerNotesModel::saveData()
|
void QmlProfilerNotesModel::stash()
|
||||||
{
|
{
|
||||||
// Keep notes that are outside the given range, overwrite the ones inside the range.
|
// Keep notes that are outside the given range, overwrite the ones inside the range.
|
||||||
m_notes = Utils::filtered(m_notes, [](const QmlNote ¬e) {
|
m_notes = Utils::filtered(m_notes, [](const QmlNote ¬e) {
|
||||||
|
@@ -37,12 +37,12 @@ class QMLPROFILER_EXPORT QmlProfilerNotesModel : public Timeline::TimelineNotesM
|
|||||||
public:
|
public:
|
||||||
QmlProfilerNotesModel(QObject *parent);
|
QmlProfilerNotesModel(QObject *parent);
|
||||||
|
|
||||||
void loadData();
|
void restore() override;
|
||||||
void saveData();
|
void stash() override;
|
||||||
|
|
||||||
const QVector<QmlNote> ¬es() const;
|
const QVector<QmlNote> ¬es() const;
|
||||||
void setNotes(const QVector<QmlNote> ¬es);
|
void setNotes(const QVector<QmlNote> ¬es);
|
||||||
void clear();
|
void clear() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVector<QmlNote> m_notes;
|
QVector<QmlNote> m_notes;
|
||||||
|
@@ -108,7 +108,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
|
|||||||
case QmlProfilerModelManager::Empty:
|
case QmlProfilerModelManager::Empty:
|
||||||
d->m_modelProxy->setModels(d->m_suspendedModels);
|
d->m_modelProxy->setModels(d->m_suspendedModels);
|
||||||
d->m_suspendedModels.clear();
|
d->m_suspendedModels.clear();
|
||||||
d->m_modelManager->notesModel()->loadData();
|
d->m_modelManager->notesModel()->restore();
|
||||||
break;
|
break;
|
||||||
case QmlProfilerModelManager::ClearingData:
|
case QmlProfilerModelManager::ClearingData:
|
||||||
d->m_zoomControl->clear();
|
d->m_zoomControl->clear();
|
||||||
|
@@ -87,7 +87,7 @@ int FlameGraphModelTest::generateData(QmlProfilerModelManager *manager)
|
|||||||
manager->finalize();
|
manager->finalize();
|
||||||
|
|
||||||
manager->notesModel()->setNotes(QVector<QmlNote>({QmlNote(0, 2, 1, 20, "dings")}));
|
manager->notesModel()->setNotes(QVector<QmlNote>({QmlNote(0, 2, 1, 20, "dings")}));
|
||||||
manager->notesModel()->loadData();
|
manager->notesModel()->restore();
|
||||||
|
|
||||||
return rangeModelId;
|
return rangeModelId;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user