summaryrefslogtreecommitdiff
path: root/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-09-24 18:23:01 +0200
committerUlf Hermann <ulf.hermann@digia.com>2014-10-15 10:34:05 +0200
commit3b5380def8ce707e36066c99e76ad82a40b04940 (patch)
treeed824b8b26c43d399422b9ec8f48cdcc4a3f22eb /src/plugins/qmlprofiler/qmlprofilertracefile.cpp
parent350615cc7111b8b5427d623ecfb6ea91f80ff96c (diff)
downloadqt-creator-3b5380def8ce707e36066c99e76ad82a40b04940.tar.gz
QmlProfiler: save and load notes
Change-Id: Id566bdd2c2a00b886779e04efbda5b49ed87a85d Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilertracefile.cpp')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertracefile.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
index 921fd6f5b4..c93b80206d 100644
--- a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
@@ -170,6 +170,11 @@ bool QmlProfilerFileReader::load(QIODevice *device)
break;
}
+ if (elementName == _("noteData")) {
+ loadNoteData(stream);
+ break;
+ }
+
if (elementName == _("v8profile")) {
if (m_v8Model)
m_v8Model->load(stream);
@@ -187,6 +192,7 @@ bool QmlProfilerFileReader::load(QIODevice *device)
return false;
} else {
m_qmlModel->setData(m_qmlEvents, m_ranges);
+ m_qmlModel->setNoteData(m_notes);
return true;
}
}
@@ -377,6 +383,41 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream)
}
}
+void QmlProfilerFileReader::loadNoteData(QXmlStreamReader &stream)
+{
+ QmlProfilerDataModel::QmlEventNoteData currentNote;
+ while (!stream.atEnd() && !stream.hasError()) {
+ QXmlStreamReader::TokenType token = stream.readNext();
+ const QStringRef elementName = stream.name();
+
+ switch (token) {
+ case QXmlStreamReader::StartElement: {
+ if (elementName == _("note")) {
+ QXmlStreamAttributes attrs = stream.attributes();
+ currentNote.startTime = attrs.value(_("startTime")).toString().toLongLong();
+ currentNote.duration = attrs.value(_("duration")).toString().toLongLong();
+ currentNote.typeIndex = attrs.value(_("eventIndex")).toString().toInt();
+ }
+ break;
+ }
+ case QXmlStreamReader::Characters: {
+ currentNote.text = stream.text().toString();
+ break;
+ }
+ case QXmlStreamReader::EndElement: {
+ if (elementName == _("note")) {
+ m_notes.append(currentNote);
+ } else if (elementName == _("noteData")) {
+ return;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+}
+
QmlProfilerFileWriter::QmlProfilerFileWriter(QObject *parent) :
QObject(parent),
m_startTime(0),
@@ -405,6 +446,11 @@ void QmlProfilerFileWriter::setQmlEvents(const QVector<QmlProfilerDataModel::Qml
m_ranges = events;
}
+void QmlProfilerFileWriter::setNotes(const QVector<QmlProfilerDataModel::QmlEventNoteData> &notes)
+{
+ m_notes = notes;
+}
+
void QmlProfilerFileWriter::save(QIODevice *device)
{
QXmlStreamWriter stream(device);
@@ -505,6 +551,18 @@ void QmlProfilerFileWriter::save(QIODevice *device)
}
stream.writeEndElement(); // profilerDataModel
+ stream.writeStartElement(_("noteData"));
+ for (int noteIndex = 0; noteIndex < m_notes.size(); ++noteIndex) {
+ const QmlProfilerDataModel::QmlEventNoteData &notes = m_notes[noteIndex];
+ stream.writeStartElement(_("note"));
+ stream.writeAttribute(_("startTime"), QString::number(notes.startTime));
+ stream.writeAttribute(_("duration"), QString::number(notes.duration));
+ stream.writeAttribute(_("eventIndex"), QString::number(notes.typeIndex));
+ stream.writeCharacters(notes.text);
+ stream.writeEndElement(); // note
+ }
+ stream.writeEndElement(); // noteData
+
m_v8Model->save(stream);
stream.writeEndElement(); // trace