aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2016-12-28 16:39:57 +0100
committerUlf Hermann <[email protected]>2017-02-15 12:38:21 +0000
commit5dd25c42cb4992316cf40ffa42e74f027cd8b7d0 (patch)
tree50217c276f8c15c862a67d01448c9c5715d63d91 /src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
parent00d424eadbc72d1293077c87bb30c7a1c7958d56 (diff)
QmlProfiler: Move event handling into model manager
This is the logical place to do it. Adding the event first to the QML model and then passing it back to the manager in order to have it dispatched to the other models is somewhat backwards. Change-Id: I64b1cb38f97331b62d83fa5ae49b9b2690810d40 Reviewed-by: Christian Kandeler <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp44
1 files changed, 38 insertions, 6 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
index 6a236a12f9d..ccb05f67497 100644
--- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
@@ -153,6 +153,8 @@ public:
QHash<ProfileFeature, QVector<EventLoader> > eventLoaders;
QVector<Finalizer> finalizers;
+
+ void dispatch(const QmlEvent &event, const QmlEventType &type);
};
@@ -204,6 +206,11 @@ uint QmlProfilerModelManager::numLoadedEvents() const
return d->numLoadedEvents;
}
+uint QmlProfilerModelManager::numLoadedEventTypes() const
+{
+ return d->model->eventTypes().count();
+}
+
int QmlProfilerModelManager::registerModelProxy()
{
return d->numRegisteredModels++;
@@ -219,11 +226,36 @@ int QmlProfilerModelManager::numRegisteredFinalizers() const
return d->finalizers.count();
}
-void QmlProfilerModelManager::dispatch(const QmlEvent &event, const QmlEventType &type)
+void QmlProfilerModelManager::addEvents(const QVector<QmlEvent> &events)
+{
+ d->model->addEvents(events);
+ const QVector<QmlEventType> &types = d->model->eventTypes();
+ for (const QmlEvent &event : events)
+ d->dispatch(event, types[event.typeIndex()]);
+}
+
+void QmlProfilerModelManager::addEvent(const QmlEvent &event)
+{
+ d->model->addEvent(event);
+ d->dispatch(event, d->model->eventType(event.typeIndex()));
+}
+
+void QmlProfilerModelManager::addEventTypes(const QVector<QmlEventType> &types)
+{
+ d->model->addEventTypes(types);
+}
+
+void QmlProfilerModelManager::addEventType(const QmlEventType &type)
+{
+ d->model->addEventType(type);
+}
+
+void QmlProfilerModelManager::QmlProfilerModelManagerPrivate::dispatch(const QmlEvent &event,
+ const QmlEventType &type)
{
- foreach (const EventLoader &loader, d->eventLoaders[type.feature()])
+ foreach (const EventLoader &loader, eventLoaders[type.feature()])
loader(event, type);
- ++d->numLoadedEvents;
+ ++numLoadedEvents;
}
void QmlProfilerModelManager::announceFeatures(quint64 features, EventLoader eventLoader,
@@ -373,13 +405,13 @@ void QmlProfilerModelManager::load(const QString &filename)
}, Qt::QueuedConnection);
connect(reader, &QmlProfilerFileReader::typesLoaded,
- d->model, &QmlProfilerDataModel::setEventTypes);
+ this, &QmlProfilerModelManager::addEventTypes);
connect(reader, &QmlProfilerFileReader::notesLoaded,
d->notesModel, &QmlProfilerNotesModel::setNotes);
connect(reader, &QmlProfilerFileReader::qmlEventsLoaded,
- d->model, &QmlProfilerDataModel::addEvents);
+ this, &QmlProfilerModelManager::addEvents);
connect(reader, &QmlProfilerFileReader::success, this, [this, reader]() {
d->traceTime->setTime(reader->traceStart(), reader->traceEnd());
@@ -464,7 +496,7 @@ void QmlProfilerModelManager::restrictToRange(qint64 startTime, qint64 endTime)
startAcquiring();
d->model->replayEvents(startTime, endTime,
- std::bind(&QmlProfilerModelManager::dispatch, this,
+ std::bind(&QmlProfilerModelManagerPrivate::dispatch, d,
std::placeholders::_1, std::placeholders::_2));
d->notesModel->setNotes(notes);
d->traceTime->restrictToRange(startTime, endTime);