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>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
Q_DECLARE_TYPEINFO(QmlProfiler::QV8EventData, Q_MOVABLE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(QmlProfiler::QV8EventSub, Q_MOVABLE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(QmlProfiler::QV8ProfilerDataModel::QV8EventData, Q_MOVABLE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(QmlProfiler::QV8ProfilerDataModel::QV8EventSub, Q_MOVABLE_TYPE);
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
typedef QHash <QString, QV8EventSub *> EventHash;
|
||||
typedef QHash <QString, QV8ProfilerDataModel::QV8EventSub *> EventHash;
|
||||
|
||||
static EventHash cloneEventHash(const EventHash &src)
|
||||
{
|
||||
EventHash result;
|
||||
const EventHash::ConstIterator cend = src.constEnd();
|
||||
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;
|
||||
}
|
||||
|
||||
QV8EventData &QV8EventData::operator=(const QV8EventData &ref)
|
||||
QV8ProfilerDataModel::QV8EventData &QV8ProfilerDataModel::QV8EventData::operator=(const QV8EventData &ref)
|
||||
{
|
||||
if (this == &ref)
|
||||
return *this;
|
||||
@@ -77,7 +77,7 @@ QV8EventData &QV8EventData::operator=(const QV8EventData &ref)
|
||||
return *this;
|
||||
}
|
||||
|
||||
QV8EventData::QV8EventData()
|
||||
QV8ProfilerDataModel::QV8EventData::QV8EventData()
|
||||
{
|
||||
line = -1;
|
||||
eventId = -1;
|
||||
@@ -87,7 +87,7 @@ QV8EventData::QV8EventData()
|
||||
SelfTimeInPercent = 0;
|
||||
}
|
||||
|
||||
QV8EventData::~QV8EventData()
|
||||
QV8ProfilerDataModel::QV8EventData::~QV8EventData()
|
||||
{
|
||||
qDeleteAll(parentHash.values());
|
||||
parentHash.clear();
|
||||
@@ -137,7 +137,7 @@ bool QV8ProfilerDataModel::isEmpty() const
|
||||
return d->v8EventHash.isEmpty();
|
||||
}
|
||||
|
||||
QV8EventData *QV8ProfilerDataModel::v8EventDescription(int eventId) const
|
||||
QV8ProfilerDataModel::QV8EventData *QV8ProfilerDataModel::v8EventDescription(int eventId) const
|
||||
{
|
||||
foreach (QV8EventData *event, d->v8EventHash) {
|
||||
if (event->eventId == eventId)
|
||||
@@ -151,7 +151,7 @@ qint64 QV8ProfilerDataModel::v8MeasuredTime() const
|
||||
return d->v8MeasuredTime;
|
||||
}
|
||||
|
||||
QList<QV8EventData *> QV8ProfilerDataModel::getV8Events() const
|
||||
QList<QV8ProfilerDataModel::QV8EventData *> QV8ProfilerDataModel::getV8Events() const
|
||||
{
|
||||
return d->v8EventHash.values();
|
||||
}
|
||||
|
||||
@@ -41,10 +41,14 @@
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
struct QV8EventSub;
|
||||
|
||||
struct QV8EventData
|
||||
class QV8ProfilerDataModel : public QmlProfilerBaseModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct QV8EventSub;
|
||||
|
||||
struct QV8EventData
|
||||
{
|
||||
QV8EventData();
|
||||
~QV8EventData();
|
||||
|
||||
@@ -62,20 +66,16 @@ struct QV8EventData
|
||||
int eventId;
|
||||
|
||||
QV8EventData &operator=(const QV8EventData &ref);
|
||||
};
|
||||
};
|
||||
|
||||
struct QV8EventSub {
|
||||
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 QmlProfilerBaseModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QV8ProfilerDataModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent = 0);
|
||||
~QV8ProfilerDataModel();
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ class QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate
|
||||
public:
|
||||
QV8ProfilerEventsMainViewPrivate(QV8ProfilerEventsMainView *qq) : q(qq) {}
|
||||
|
||||
void buildV8ModelFromList( const QList<QV8EventData *> &list );
|
||||
void buildV8ModelFromList( const QList<QV8ProfilerDataModel::QV8EventData *> &list );
|
||||
int getFieldCount();
|
||||
|
||||
QString textForItem(QStandardItem *item, bool recursive) const;
|
||||
@@ -428,10 +428,11 @@ void QV8ProfilerEventsMainView::buildModel()
|
||||
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++) {
|
||||
QV8EventData *v8event = list.at(index);
|
||||
QV8ProfilerDataModel::QV8EventData *v8event = list.at(index);
|
||||
QList<QStandardItem *> newRow;
|
||||
|
||||
if (m_fieldShown[Name])
|
||||
@@ -639,10 +640,10 @@ QV8ProfilerEventRelativesView::~QV8ProfilerEventRelativesView()
|
||||
|
||||
void QV8ProfilerEventRelativesView::displayEvent(int index)
|
||||
{
|
||||
QV8EventData *event = m_v8Model->v8EventDescription(index);
|
||||
QV8ProfilerDataModel::QV8EventData *event = m_v8Model->v8EventDescription(index);
|
||||
QTC_CHECK(event);
|
||||
|
||||
QList<QV8EventSub*> events;
|
||||
QList<QV8ProfilerDataModel::QV8EventSub*> events;
|
||||
if (m_type == ParentsView)
|
||||
events = event->parentHash.values();
|
||||
else
|
||||
@@ -656,13 +657,13 @@ void QV8ProfilerEventRelativesView::displayEvent(int index)
|
||||
sortByColumn(1);
|
||||
}
|
||||
|
||||
void QV8ProfilerEventRelativesView::rebuildTree(QList<QV8EventSub*> events)
|
||||
void QV8ProfilerEventRelativesView::rebuildTree(QList<QV8ProfilerDataModel::QV8EventSub*> events)
|
||||
{
|
||||
clear();
|
||||
|
||||
QStandardItem *topLevelItem = m_model->invisibleRootItem();
|
||||
|
||||
foreach (QV8EventSub *event, events) {
|
||||
foreach (QV8ProfilerDataModel::QV8EventSub *event, events) {
|
||||
QList<QStandardItem *> newRow;
|
||||
newRow << new EventsViewItem(event->reference->displayName);
|
||||
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event->totalTime));
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilereventsmodelproxy.h"
|
||||
#include "qv8profilerdatamodel.h"
|
||||
#include "qmlprofilertreeview.h"
|
||||
|
||||
#include <analyzerbase/ianalyzertool.h>
|
||||
@@ -41,7 +42,6 @@
|
||||
#include "qmlprofilerviewmanager.h"
|
||||
|
||||
namespace QmlProfiler {
|
||||
struct QV8EventSub;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
@@ -148,7 +148,7 @@ public slots:
|
||||
void clear();
|
||||
|
||||
private:
|
||||
void rebuildTree(QList<QV8EventSub*> events);
|
||||
void rebuildTree(QList<QV8ProfilerDataModel::QV8EventSub*> events);
|
||||
void updateHeader();
|
||||
|
||||
QV8ProfilerEventRelativesView::SubViewType m_type;
|
||||
|
||||
Reference in New Issue
Block a user