forked from qt-creator/qt-creator
QmlProfiler: Move the data structs of the V8 model into the model class
QmlProfilerDataModel does it the same way and we don't pollute the namespace as much like this. Change-Id: Id1ed2c444cb2556fb8f1c886a754e51f3eae5772 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -35,24 +35,24 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
Q_DECLARE_TYPEINFO(QmlProfiler::QV8EventData, Q_MOVABLE_TYPE);
|
Q_DECLARE_TYPEINFO(QmlProfiler::QV8ProfilerDataModel::QV8EventData, Q_MOVABLE_TYPE);
|
||||||
Q_DECLARE_TYPEINFO(QmlProfiler::QV8EventSub, Q_MOVABLE_TYPE);
|
Q_DECLARE_TYPEINFO(QmlProfiler::QV8ProfilerDataModel::QV8EventSub, Q_MOVABLE_TYPE);
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
|
|
||||||
typedef QHash <QString, QV8EventSub *> EventHash;
|
typedef QHash <QString, QV8ProfilerDataModel::QV8EventSub *> EventHash;
|
||||||
|
|
||||||
static EventHash cloneEventHash(const EventHash &src)
|
static EventHash cloneEventHash(const EventHash &src)
|
||||||
{
|
{
|
||||||
EventHash result;
|
EventHash result;
|
||||||
const EventHash::ConstIterator cend = src.constEnd();
|
const EventHash::ConstIterator cend = src.constEnd();
|
||||||
for (EventHash::ConstIterator it = src.constBegin(); it != cend; ++it)
|
for (EventHash::ConstIterator it = src.constBegin(); it != cend; ++it)
|
||||||
result.insert(it.key(), new QV8EventSub(it.value()));
|
result.insert(it.key(), new QV8ProfilerDataModel::QV8EventSub(it.value()));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QV8EventData &QV8EventData::operator=(const QV8EventData &ref)
|
QV8ProfilerDataModel::QV8EventData &QV8ProfilerDataModel::QV8EventData::operator=(const QV8EventData &ref)
|
||||||
{
|
{
|
||||||
if (this == &ref)
|
if (this == &ref)
|
||||||
return *this;
|
return *this;
|
||||||
@@ -77,7 +77,7 @@ QV8EventData &QV8EventData::operator=(const QV8EventData &ref)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
QV8EventData::QV8EventData()
|
QV8ProfilerDataModel::QV8EventData::QV8EventData()
|
||||||
{
|
{
|
||||||
line = -1;
|
line = -1;
|
||||||
eventId = -1;
|
eventId = -1;
|
||||||
@@ -87,7 +87,7 @@ QV8EventData::QV8EventData()
|
|||||||
SelfTimeInPercent = 0;
|
SelfTimeInPercent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QV8EventData::~QV8EventData()
|
QV8ProfilerDataModel::QV8EventData::~QV8EventData()
|
||||||
{
|
{
|
||||||
qDeleteAll(parentHash.values());
|
qDeleteAll(parentHash.values());
|
||||||
parentHash.clear();
|
parentHash.clear();
|
||||||
@@ -137,7 +137,7 @@ bool QV8ProfilerDataModel::isEmpty() const
|
|||||||
return d->v8EventHash.isEmpty();
|
return d->v8EventHash.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
QV8EventData *QV8ProfilerDataModel::v8EventDescription(int eventId) const
|
QV8ProfilerDataModel::QV8EventData *QV8ProfilerDataModel::v8EventDescription(int eventId) const
|
||||||
{
|
{
|
||||||
foreach (QV8EventData *event, d->v8EventHash) {
|
foreach (QV8EventData *event, d->v8EventHash) {
|
||||||
if (event->eventId == eventId)
|
if (event->eventId == eventId)
|
||||||
@@ -151,7 +151,7 @@ qint64 QV8ProfilerDataModel::v8MeasuredTime() const
|
|||||||
return d->v8MeasuredTime;
|
return d->v8MeasuredTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QV8EventData *> QV8ProfilerDataModel::getV8Events() const
|
QList<QV8ProfilerDataModel::QV8EventData *> QV8ProfilerDataModel::getV8Events() const
|
||||||
{
|
{
|
||||||
return d->v8EventHash.values();
|
return d->v8EventHash.values();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,10 +41,14 @@
|
|||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
|
|
||||||
struct QV8EventSub;
|
class QV8ProfilerDataModel : public QmlProfilerBaseModel
|
||||||
|
|
||||||
struct QV8EventData
|
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
struct QV8EventSub;
|
||||||
|
|
||||||
|
struct QV8EventData
|
||||||
|
{
|
||||||
QV8EventData();
|
QV8EventData();
|
||||||
~QV8EventData();
|
~QV8EventData();
|
||||||
|
|
||||||
@@ -62,20 +66,16 @@ struct QV8EventData
|
|||||||
int eventId;
|
int eventId;
|
||||||
|
|
||||||
QV8EventData &operator=(const QV8EventData &ref);
|
QV8EventData &operator=(const QV8EventData &ref);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QV8EventSub {
|
struct QV8EventSub {
|
||||||
QV8EventSub(QV8EventData *from) : reference(from), totalTime(0) {}
|
QV8EventSub(QV8EventData *from) : reference(from), totalTime(0) {}
|
||||||
QV8EventSub(QV8EventSub *from) : reference(from->reference), totalTime(from->totalTime) {}
|
QV8EventSub(QV8EventSub *from) : reference(from->reference), totalTime(from->totalTime) {}
|
||||||
|
|
||||||
QV8EventData *reference;
|
QV8EventData *reference;
|
||||||
qint64 totalTime;
|
qint64 totalTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QV8ProfilerDataModel : public QmlProfilerBaseModel
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
QV8ProfilerDataModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent = 0);
|
QV8ProfilerDataModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent = 0);
|
||||||
~QV8ProfilerDataModel();
|
~QV8ProfilerDataModel();
|
||||||
|
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ class QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate
|
|||||||
public:
|
public:
|
||||||
QV8ProfilerEventsMainViewPrivate(QV8ProfilerEventsMainView *qq) : q(qq) {}
|
QV8ProfilerEventsMainViewPrivate(QV8ProfilerEventsMainView *qq) : q(qq) {}
|
||||||
|
|
||||||
void buildV8ModelFromList( const QList<QV8EventData *> &list );
|
void buildV8ModelFromList( const QList<QV8ProfilerDataModel::QV8EventData *> &list );
|
||||||
int getFieldCount();
|
int getFieldCount();
|
||||||
|
|
||||||
QString textForItem(QStandardItem *item, bool recursive) const;
|
QString textForItem(QStandardItem *item, bool recursive) const;
|
||||||
@@ -428,10 +428,11 @@ void QV8ProfilerEventsMainView::buildModel()
|
|||||||
collapseAll();
|
collapseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFromList(const QList<QV8EventData *> &list)
|
void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFromList(
|
||||||
|
const QList<QV8ProfilerDataModel::QV8EventData *> &list)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < list.count(); index++) {
|
for (int index = 0; index < list.count(); index++) {
|
||||||
QV8EventData *v8event = list.at(index);
|
QV8ProfilerDataModel::QV8EventData *v8event = list.at(index);
|
||||||
QList<QStandardItem *> newRow;
|
QList<QStandardItem *> newRow;
|
||||||
|
|
||||||
if (m_fieldShown[Name])
|
if (m_fieldShown[Name])
|
||||||
@@ -639,10 +640,10 @@ QV8ProfilerEventRelativesView::~QV8ProfilerEventRelativesView()
|
|||||||
|
|
||||||
void QV8ProfilerEventRelativesView::displayEvent(int index)
|
void QV8ProfilerEventRelativesView::displayEvent(int index)
|
||||||
{
|
{
|
||||||
QV8EventData *event = m_v8Model->v8EventDescription(index);
|
QV8ProfilerDataModel::QV8EventData *event = m_v8Model->v8EventDescription(index);
|
||||||
QTC_CHECK(event);
|
QTC_CHECK(event);
|
||||||
|
|
||||||
QList<QV8EventSub*> events;
|
QList<QV8ProfilerDataModel::QV8EventSub*> events;
|
||||||
if (m_type == ParentsView)
|
if (m_type == ParentsView)
|
||||||
events = event->parentHash.values();
|
events = event->parentHash.values();
|
||||||
else
|
else
|
||||||
@@ -656,13 +657,13 @@ void QV8ProfilerEventRelativesView::displayEvent(int index)
|
|||||||
sortByColumn(1);
|
sortByColumn(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QV8ProfilerEventRelativesView::rebuildTree(QList<QV8EventSub*> events)
|
void QV8ProfilerEventRelativesView::rebuildTree(QList<QV8ProfilerDataModel::QV8EventSub*> events)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
QStandardItem *topLevelItem = m_model->invisibleRootItem();
|
QStandardItem *topLevelItem = m_model->invisibleRootItem();
|
||||||
|
|
||||||
foreach (QV8EventSub *event, events) {
|
foreach (QV8ProfilerDataModel::QV8EventSub *event, events) {
|
||||||
QList<QStandardItem *> newRow;
|
QList<QStandardItem *> newRow;
|
||||||
newRow << new EventsViewItem(event->reference->displayName);
|
newRow << new EventsViewItem(event->reference->displayName);
|
||||||
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event->totalTime));
|
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event->totalTime));
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <qmldebug/qmlprofilereventtypes.h>
|
#include <qmldebug/qmlprofilereventtypes.h>
|
||||||
#include "qmlprofilermodelmanager.h"
|
#include "qmlprofilermodelmanager.h"
|
||||||
#include "qmlprofilereventsmodelproxy.h"
|
#include "qmlprofilereventsmodelproxy.h"
|
||||||
|
#include "qv8profilerdatamodel.h"
|
||||||
#include "qmlprofilertreeview.h"
|
#include "qmlprofilertreeview.h"
|
||||||
|
|
||||||
#include <analyzerbase/ianalyzertool.h>
|
#include <analyzerbase/ianalyzertool.h>
|
||||||
@@ -41,7 +42,6 @@
|
|||||||
#include "qmlprofilerviewmanager.h"
|
#include "qmlprofilerviewmanager.h"
|
||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
struct QV8EventSub;
|
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ public slots:
|
|||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void rebuildTree(QList<QV8EventSub*> events);
|
void rebuildTree(QList<QV8ProfilerDataModel::QV8EventSub*> events);
|
||||||
void updateHeader();
|
void updateHeader();
|
||||||
|
|
||||||
QV8ProfilerEventRelativesView::SubViewType m_type;
|
QV8ProfilerEventRelativesView::SubViewType m_type;
|
||||||
|
|||||||
Reference in New Issue
Block a user