Commit 6f8acae6 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Remove QmlProfilerBaseModel



Now that the V8 model is gone we don't need a base model anymore.

Change-Id: I35aee0627f78f417ec9c971e1c7bbf70adfc7b27
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent f3888829
......@@ -8,7 +8,6 @@ SOURCES += \
localqmlprofilerrunner.cpp \
qmlprofileranimationsmodel.cpp \
qmlprofilerattachdialog.cpp \
qmlprofilerbasemodel.cpp \
qmlprofilerbindingloopsrenderpass.cpp \
qmlprofilerclientmanager.cpp \
qmlprofilerconfigwidget.cpp \
......@@ -39,8 +38,6 @@ HEADERS += \
qmlprofiler_global.h \
qmlprofileranimationsmodel.h \
qmlprofilerattachdialog.h \
qmlprofilerbasemodel.h \
qmlprofilerbasemodel_p.h \
qmlprofilerbindingloopsrenderpass.h \
qmlprofilerclientmanager.h \
qmlprofilerconfigwidget.h \
......
......@@ -23,7 +23,6 @@ QtcPlugin {
"qmlprofiler_global.h",
"qmlprofileranimationsmodel.h", "qmlprofileranimationsmodel.cpp",
"qmlprofilerattachdialog.cpp", "qmlprofilerattachdialog.h",
"qmlprofilerbasemodel.cpp", "qmlprofilerbasemodel.h", "qmlprofilerbasemodel_p.h",
"qmlprofilerbindingloopsrenderpass.cpp","qmlprofilerbindingloopsrenderpass.h",
"qmlprofilerclientmanager.cpp", "qmlprofilerclientmanager.h",
"qmlprofilerconfigwidget.cpp", "qmlprofilerconfigwidget.h",
......
......@@ -202,7 +202,7 @@ QVariantMap QmlProfilerAnimationsModel::details(int index) const
QVariantMap result;
result.insert(QStringLiteral("displayName"), displayName());
result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(duration(index)));
result.insert(tr("Duration"), QmlProfilerDataModel::formatTime(duration(index)));
result.insert(tr("Framerate"), QString::fromLatin1("%1 FPS").arg(m_data[index].framerate));
result.insert(tr("Animations"), QString::fromLatin1("%1").arg(m_data[index].animationcount));
result.insert(tr("Context"), tr(selectionId(index) == QmlDebug::GuiThread ? "GUI Thread" :
......
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qmlprofilerbasemodel.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilerbasemodel_p.h"
namespace QmlProfiler {
QmlProfilerBaseModel::QmlProfilerBaseModel(Utils::FileInProjectFinder *fileFinder,
QmlProfilerModelManager *manager,
QmlProfilerBaseModelPrivate *dd)
: QObject(manager)
, d_ptr(dd)
{
Q_D(QmlProfilerBaseModel);
d->modelManager = manager;
d->processingDone = false;
d->detailsRewriter = new QmlProfilerDetailsRewriter(this, fileFinder);
Q_ASSERT(d->modelManager);
d->modelId = d->modelManager->registerModelProxy();
connect(d->detailsRewriter, SIGNAL(rewriteDetailsString(int,QString)),
this, SLOT(detailsChanged(int,QString)));
connect(d->detailsRewriter, SIGNAL(eventDetailsChanged()),
this, SLOT(detailsDone()));
}
QmlProfilerBaseModel::~QmlProfilerBaseModel()
{
Q_D(QmlProfilerBaseModel);
delete d->detailsRewriter;
delete d;
}
void QmlProfilerBaseModel::clear()
{
Q_D(QmlProfilerBaseModel);
d->detailsRewriter->clearRequests();
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
d->processingDone = false;
emit changed();
}
bool QmlProfilerBaseModel::processingDone() const
{
Q_D(const QmlProfilerBaseModel);
return d->processingDone;
}
void QmlProfilerBaseModel::complete()
{
Q_D(QmlProfilerBaseModel);
d->detailsRewriter->reloadDocuments();
}
QString QmlProfilerBaseModel::formatTime(qint64 timestamp)
{
if (timestamp < 1e6)
return QString::number(timestamp/1e3f,'f',3) + trUtf8(" \xc2\xb5s");
if (timestamp < 1e9)
return QString::number(timestamp/1e6f,'f',3) + tr(" ms");
return QString::number(timestamp/1e9f,'f',3) + tr(" s");
}
void QmlProfilerBaseModel::detailsDone()
{
Q_D(QmlProfilerBaseModel);
emit changed();
d->processingDone = true;
d->modelManager->modelProxyCountUpdated(d->modelId, isEmpty() ? 0 : 1, 1);
d->modelManager->complete();
}
}
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLPROFILERBASEMODEL_H
#define QMLPROFILERBASEMODEL_H
#include "qmlprofiler_global.h"
#include "qmlprofilerdetailsrewriter.h"
#include <QObject>
namespace QmlProfiler {
class QmlProfilerModelManager;
class QMLPROFILER_EXPORT QmlProfilerBaseModel : public QObject {
Q_OBJECT
public:
virtual ~QmlProfilerBaseModel();
virtual void complete();
virtual void clear();
virtual bool isEmpty() const = 0;
bool processingDone() const;
static QString formatTime(qint64 timestamp);
protected slots:
virtual void detailsChanged(int requestId, const QString &newString) = 0;
virtual void detailsDone();
signals:
void changed();
protected:
class QmlProfilerBaseModelPrivate;
QmlProfilerBaseModelPrivate *d_ptr;
QmlProfilerBaseModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *manager,
QmlProfilerBaseModelPrivate *dd);
private:
Q_DECLARE_PRIVATE(QmlProfilerBaseModel)
};
}
#endif // QMLPROFILERBASEMODEL_H
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLPROFILERBASEMODEL_P_H
#define QMLPROFILERBASEMODEL_P_H
#include "qmlprofilerbasemodel.h"
namespace QmlProfiler {
class QmlProfilerBaseModel::QmlProfilerBaseModelPrivate {
public:
QmlProfilerBaseModelPrivate(QmlProfilerBaseModel *qq) : q_ptr(qq) {}
virtual ~QmlProfilerBaseModelPrivate() {}
QmlProfilerModelManager *modelManager;
int modelId;
bool processingDone;
Internal::QmlProfilerDetailsRewriter *detailsRewriter;
protected:
QmlProfilerBaseModel *q_ptr;
private:
Q_DECLARE_PUBLIC(QmlProfilerBaseModel)
};
}
#endif // QMLPROFILERBASEMODEL_P_H
......@@ -29,9 +29,10 @@
****************************************************************************/
#include "qmlprofilerdatamodel.h"
#include "qmlprofilerbasemodel_p.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilernotesmodel.h"
#include "qmlprofilerdetailsrewriter.h"
#include <qmldebug/qmlprofilereventtypes.h>
#include <utils/qtcassert.h>
#include <QUrl>
......@@ -40,17 +41,17 @@
namespace QmlProfiler {
class QmlProfilerDataModel::QmlProfilerDataModelPrivate :
public QmlProfilerBaseModel::QmlProfilerBaseModelPrivate
class QmlProfilerDataModel::QmlProfilerDataModelPrivate
{
public:
QmlProfilerDataModelPrivate(QmlProfilerDataModel *qq) : QmlProfilerBaseModelPrivate(qq) {}
QVector<QmlEventTypeData> eventTypes;
QVector<QmlEventData> eventList;
QVector<QmlEventNoteData> eventNotes;
QHash<QmlEventTypeData, int> eventTypeIds;
private:
Q_DECLARE_PUBLIC(QmlProfilerDataModel)
QmlProfilerModelManager *modelManager;
int modelId;
Internal::QmlProfilerDetailsRewriter *detailsRewriter;
};
QString getDisplayName(const QmlProfilerDataModel::QmlEventTypeData &event)
......@@ -91,15 +92,41 @@ QString getInitialDetails(const QmlProfilerDataModel::QmlEventTypeData &event)
return details;
}
QString QmlProfilerDataModel::formatTime(qint64 timestamp)
{
if (timestamp < 1e6)
return QString::number(timestamp/1e3f,'f',3) + trUtf8(" \xc2\xb5s");
if (timestamp < 1e9)
return QString::number(timestamp/1e6f,'f',3) + tr(" ms");
return QString::number(timestamp/1e9f,'f',3) + tr(" s");
}
QmlProfilerDataModel::QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinder,
QmlProfilerModelManager *parent)
: QmlProfilerBaseModel(fileFinder, parent, new QmlProfilerDataModelPrivate(this))
QmlProfilerModelManager *parent) :
QObject(parent), d_ptr(new QmlProfilerDataModelPrivate)
{
Q_D(QmlProfilerDataModel);
Q_ASSERT(parent);
d->modelManager = parent;
d->detailsRewriter = new QmlProfilerDetailsRewriter(this, fileFinder);
d->modelId = d->modelManager->registerModelProxy();
connect(d->detailsRewriter, SIGNAL(rewriteDetailsString(int,QString)),
this, SLOT(detailsChanged(int,QString)));
connect(d->detailsRewriter, SIGNAL(eventDetailsChanged()),
this, SLOT(detailsDone()));
// The document loading is very expensive.
d->modelManager->setProxyCountWeight(d->modelId, 4);
}
QmlProfilerDataModel::~QmlProfilerDataModel()
{
Q_D(QmlProfilerDataModel);
delete d->detailsRewriter;
delete d;
}
const QVector<QmlProfilerDataModel::QmlEventData> &QmlProfilerDataModel::getEvents() const
{
Q_D(const QmlProfilerDataModel);
......@@ -151,8 +178,9 @@ void QmlProfilerDataModel::clear()
d->eventTypes.clear();
d->eventTypeIds.clear();
d->eventNotes.clear();
// This call emits changed(). Don't emit it again here.
QmlProfilerBaseModel::clear();
d->detailsRewriter->clearRequests();
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
emit changed();
}
bool QmlProfilerDataModel::isEmpty() const
......@@ -223,7 +251,7 @@ void QmlProfilerDataModel::complete()
// Allow changed() event only after documents have been reloaded to avoid
// unnecessary updates of child models.
QmlProfilerBaseModel::complete();
d->detailsRewriter->reloadDocuments();
}
void QmlProfilerDataModel::addQmlEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType,
......@@ -280,4 +308,12 @@ void QmlProfilerDataModel::detailsChanged(int requestId, const QString &newStrin
event->data = newString;
}
void QmlProfilerDataModel::detailsDone()
{
Q_D(QmlProfilerDataModel);
emit changed();
d->modelManager->modelProxyCountUpdated(d->modelId, isEmpty() ? 0 : 1, 1);
d->modelManager->complete();
}
}
......@@ -31,12 +31,14 @@
#ifndef QMLPROFILERDATAMODEL_H
#define QMLPROFILERDATAMODEL_H
#include "qmlprofilermodelmanager.h"
#include <qmldebug/qmlprofilereventtypes.h>
#include "qmlprofilerbasemodel.h"
#include <utils/fileinprojectfinder.h>
namespace QmlProfiler {
class QMLPROFILER_EXPORT QmlProfilerDataModel : public QmlProfilerBaseModel
class QMLPROFILER_EXPORT QmlProfilerDataModel : public QObject
{
Q_OBJECT
public:
......@@ -67,7 +69,11 @@ public:
QString text;
};
explicit QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent = 0);
static QString formatTime(qint64 timestamp);
explicit QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinder,
QmlProfilerModelManager *parent);
~QmlProfilerDataModel();
const QVector<QmlEventData> &getEvents() const;
const QVector<QmlEventTypeData> &getEventTypes() const;
......@@ -77,20 +83,25 @@ public:
void setNoteData(const QVector<QmlEventNoteData> &notes);
int count() const;
virtual void clear();
virtual bool isEmpty() const;
virtual void complete();
void clear();
bool isEmpty() const;
void complete();
void addQmlEvent(QmlDebug::Message message, QmlDebug::RangeType rangeType, int bindingType,
qint64 startTime, qint64 duration, const QString &data,
const QmlDebug::QmlEventLocation &location, qint64 ndata1, qint64 ndata2,
qint64 ndata3, qint64 ndata4, qint64 ndata5);
qint64 lastTimeMark() const;
signals:
void changed();
protected slots:
void detailsChanged(int requestId, const QString &newString);
void detailsDone();
private:
class QmlProfilerDataModelPrivate;
QmlProfilerDataModelPrivate *d_ptr;
Q_DECLARE_PRIVATE(QmlProfilerDataModel)
};
......
......@@ -653,7 +653,7 @@ void QmlProfilerEventsMainView::parseModelProxy()
}
if (d->m_fieldShown[TotalTime]) {
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(stats.duration));
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.duration));
newRow.last()->setData(QVariant(stats.duration));
}
......@@ -663,22 +663,22 @@ void QmlProfilerEventsMainView::parseModelProxy()
}
if (d->m_fieldShown[TimePerCall]) {
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(stats.timePerCall));
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.timePerCall));
newRow.last()->setData(QVariant(stats.timePerCall));
}
if (d->m_fieldShown[MedianTime]) {
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(stats.medianTime));
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.medianTime));
newRow.last()->setData(QVariant(stats.medianTime));
}
if (d->m_fieldShown[MaxTime]) {
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(stats.maxTime));
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.maxTime));
newRow.last()->setData(QVariant(stats.maxTime));
}
if (d->m_fieldShown[MinTime]) {
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(stats.minTime));
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.minTime));
newRow.last()->setData(QVariant(stats.minTime));
}
......@@ -938,7 +938,7 @@ void QmlProfilerEventRelativesView::rebuildTree(
newRow << new EventsViewItem(type.displayName.isEmpty() ? tr("<bytecode>") :
type.displayName);
newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(type.rangeType));
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.duration));
newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(event.duration));
newRow << new EventsViewItem(QString::number(event.calls));
newRow << new EventsViewItem(type.data.isEmpty() ? tr("Source code not available") :
type.data);
......
......@@ -233,7 +233,7 @@ QVariantMap QmlProfilerRangeModel::details(int index) const
result.insert(QStringLiteral("displayName"),
tr(QmlProfilerModelManager::featureName(mainFeature())));
result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(duration(index)));
result.insert(tr("Duration"), QmlProfilerDataModel::formatTime(duration(index)));
result.insert(tr("Details"), types[id].data);
result.insert(tr("Location"), types[id].displayName);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment