summaryrefslogtreecommitdiff
path: root/src/plugins/qmlprofiler/qv8profilerdatamodel.h
diff options
context:
space:
mode:
authorChristiaan Janssen <christiaan.janssen@nokia.com>2012-02-24 10:47:17 +0100
committerChristiaan Janssen <christiaan.janssen@nokia.com>2012-03-14 11:38:25 +0100
commitb7304e2f2e533b767bcd1c02d8403e3d5fa63ddd (patch)
tree30bb48a69d7c6bd1c35bcdd359a757486f298368 /src/plugins/qmlprofiler/qv8profilerdatamodel.h
parentd207165f6aa89ee95bd41c41a49d68cfa0b46444 (diff)
downloadqt-creator-b7304e2f2e533b767bcd1c02d8403e3d5fa63ddd.tar.gz
QmlProfiler: Refactor
The code of the qmlprofiler client has become a bit too complex, this patch reorganizes the modules in a more sensible way, having the modules communicate with each other through a state machine instead of the excess of signals and slots from before. Change-Id: I76f7313779888a1bd07a1cdb1acbf2e47aacf42a Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'src/plugins/qmlprofiler/qv8profilerdatamodel.h')
-rw-r--r--src/plugins/qmlprofiler/qv8profilerdatamodel.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/plugins/qmlprofiler/qv8profilerdatamodel.h b/src/plugins/qmlprofiler/qv8profilerdatamodel.h
new file mode 100644
index 0000000000..6441a24702
--- /dev/null
+++ b/src/plugins/qmlprofiler/qv8profilerdatamodel.h
@@ -0,0 +1,79 @@
+#ifndef QV8PROFILERDATAMODEL_H
+#define QV8PROFILERDATAMODEL_H
+
+#include <QObject>
+#include <QHash>
+
+#include <QXmlStreamReader>
+#include <QXmlStreamWriter>
+
+namespace QmlProfiler {
+namespace Internal {
+
+class QmlProfilerDataModel;
+struct QV8EventSub;
+
+struct QV8EventData
+{
+ QV8EventData();
+ ~QV8EventData();
+
+ QString displayName;
+ QString eventHashStr;
+ QString filename;
+ QString functionName;
+ int line;
+ double totalTime; // given in milliseconds
+ double totalPercent;
+ double selfTime;
+ double selfPercent;
+ QHash <QString, QV8EventSub *> parentHash;
+ QHash <QString, QV8EventSub *> childrenHash;
+ int eventId;
+
+ QV8EventData &operator=(const QV8EventData &ref);
+};
+
+struct QV8EventSub {
+ QV8EventSub(QV8EventData *from) : reference(from), totalTime(0) {}
+ QV8EventSub(QV8EventSub *from) : reference(from->reference), totalTime(from->totalTime) {}
+
+ QV8EventData *reference;
+ qint64 totalTime;
+};
+
+class QV8ProfilerDataModel : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QV8ProfilerDataModel(QObject *parent, QmlProfilerDataModel *profilerDataModel);
+ ~QV8ProfilerDataModel();
+
+ void clear();
+ bool isEmpty() const;
+ QList<QV8EventData *> getV8Events() const;
+ QV8EventData *v8EventDescription(int eventId) const;
+
+ qint64 v8MeasuredTime() const;
+ void collectV8Statistics();
+
+ void save(QXmlStreamWriter &stream);
+ void load(QXmlStreamReader &stream);
+
+public slots:
+ void addV8Event(int depth,
+ const QString &function,
+ const QString &filename,
+ int lineNumber,
+ double totalTime,
+ double selfTime);
+
+private:
+ class QV8ProfilerDataModelPrivate;
+ QV8ProfilerDataModelPrivate *d;
+};
+
+} // namespace Internal
+} // namespace QmlProfiler
+
+#endif // QV8PROFILERDATAMODEL_H