QmlProfiler: Remove SingleCategoryTimelineModel

All models are single-category now, so we can merge that into the base
class.

Change-Id: I4eab43ac2b4a77402121f004097e51a29b379aa4
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-06-12 16:01:04 +02:00
parent 3ea13b9b12
commit c7c4be9cb2
12 changed files with 55 additions and 205 deletions

View File

@@ -32,8 +32,10 @@
namespace QmlProfiler { namespace QmlProfiler {
AbstractTimelineModel::AbstractTimelineModel(AbstractTimelineModelPrivate *dd, const QString &name,
QObject *parent) : AbstractTimelineModel::AbstractTimelineModel(AbstractTimelineModelPrivate *dd,
const QString &name, const QString &label, QmlDebug::Message message,
QmlDebug::RangeType rangeType, QObject *parent) :
QObject(parent), d_ptr(dd) QObject(parent), d_ptr(dd)
{ {
Q_D(AbstractTimelineModel); Q_D(AbstractTimelineModel);
@@ -41,6 +43,10 @@ AbstractTimelineModel::AbstractTimelineModel(AbstractTimelineModelPrivate *dd, c
d->name = name; d->name = name;
d->modelId = 0; d->modelId = 0;
d->modelManager = 0; d->modelManager = 0;
d->expanded = false;
d->title = label;
d->message = message;
d->rangeType = rangeType;
} }
AbstractTimelineModel::~AbstractTimelineModel() AbstractTimelineModel::~AbstractTimelineModel()
@@ -193,5 +199,31 @@ void AbstractTimelineModel::dataChanged()
emit expandedChanged(); emit expandedChanged();
} }
bool AbstractTimelineModel::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const
{
Q_D(const AbstractTimelineModel);
return (event.rangeType == d->rangeType && event.message == d->message);
}
bool AbstractTimelineModel::expanded() const
{
Q_D(const AbstractTimelineModel);
return d->expanded;
}
void AbstractTimelineModel::setExpanded(bool expanded)
{
Q_D(AbstractTimelineModel);
if (expanded != d->expanded) {
d->expanded = expanded;
emit expandedChanged();
}
}
const QString AbstractTimelineModel::title() const
{
Q_D(const AbstractTimelineModel);
return d->title;
}
} }

View File

@@ -66,12 +66,13 @@ public:
int findFirstIndexNoParents(qint64 startTime) const; int findFirstIndexNoParents(qint64 startTime) const;
int findLastIndex(qint64 endTime) const; int findLastIndex(qint64 endTime) const;
int count() const; int count() const;
bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const;
bool expanded() const;
void setExpanded(bool expanded);
const QString title() const;
// Methods that have to be implemented by child models // Methods that have to be implemented by child models
virtual bool expanded() const = 0;
virtual void setExpanded(bool expanded) = 0;
virtual int rowCount() const = 0; virtual int rowCount() const = 0;
virtual const QString title() const = 0;
Q_INVOKABLE virtual int getEventId(int index) const = 0; Q_INVOKABLE virtual int getEventId(int index) const = 0;
Q_INVOKABLE virtual QColor getColor(int index) const = 0; Q_INVOKABLE virtual QColor getColor(int index) const = 0;
virtual const QVariantList getLabels() const = 0; virtual const QVariantList getLabels() const = 0;
@@ -119,7 +120,8 @@ protected:
} }
explicit AbstractTimelineModel(AbstractTimelineModelPrivate *dd, const QString &name, explicit AbstractTimelineModel(AbstractTimelineModelPrivate *dd, const QString &name,
QObject *parent = 0); const QString &label, QmlDebug::Message message,
QmlDebug::RangeType rangeType, QObject *parent);
AbstractTimelineModelPrivate *d_ptr; AbstractTimelineModelPrivate *d_ptr;
protected slots: protected slots:

View File

@@ -50,6 +50,10 @@ public:
QString name; QString name;
QmlProfilerModelManager *modelManager; QmlProfilerModelManager *modelManager;
int modelId; int modelId;
bool expanded;
QString title;
QmlDebug::Message message;
QmlDebug::RangeType rangeType;
protected: protected:
AbstractTimelineModel *q_ptr; AbstractTimelineModel *q_ptr;

View File

@@ -31,7 +31,6 @@ SOURCES += \
qmlprofilerpainteventsmodelproxy.cpp \ qmlprofilerpainteventsmodelproxy.cpp \
sortedtimelinemodel.cpp \ sortedtimelinemodel.cpp \
qmlprofilerbasemodel.cpp \ qmlprofilerbasemodel.cpp \
singlecategorytimelinemodel.cpp \
qmlprofilerdatamodel.cpp qmlprofilerdatamodel.cpp
HEADERS += \ HEADERS += \
@@ -65,8 +64,6 @@ HEADERS += \
sortedtimelinemodel.h \ sortedtimelinemodel.h \
qmlprofilerbasemodel.h \ qmlprofilerbasemodel.h \
abstracttimelinemodel_p.h \ abstracttimelinemodel_p.h \
singlecategorytimelinemodel.h \
singlecategorytimelinemodel_p.h \
qmlprofilerdatamodel.h \ qmlprofilerdatamodel.h \
qmlprofilerbasemodel_p.h qmlprofilerbasemodel_p.h

View File

@@ -50,8 +50,6 @@ QtcPlugin {
"qmlprofilerviewmanager.cpp", "qmlprofilerviewmanager.h", "qmlprofilerviewmanager.cpp", "qmlprofilerviewmanager.h",
"qv8profilerdatamodel.cpp", "qv8profilerdatamodel.h", "qv8profilerdatamodel.cpp", "qv8profilerdatamodel.h",
"qv8profilereventview.h", "qv8profilereventview.cpp", "qv8profilereventview.h", "qv8profilereventview.cpp",
"singlecategorytimelinemodel.h", "singlecategorytimelinemodel_p.h",
"singlecategorytimelinemodel.cpp",
"sortedtimelinemodel.h", "sortedtimelinemodel.cpp", "sortedtimelinemodel.h", "sortedtimelinemodel.cpp",
"timelinemodelaggregator.cpp", "timelinemodelaggregator.h", "timelinemodelaggregator.cpp", "timelinemodelaggregator.h",
"timelinerenderer.cpp", "timelinerenderer.h", "timelinerenderer.cpp", "timelinerenderer.h",

View File

@@ -31,7 +31,7 @@
#include "qmlprofilermodelmanager.h" #include "qmlprofilermodelmanager.h"
#include "qmlprofilerdatamodel.h" #include "qmlprofilerdatamodel.h"
#include "sortedtimelinemodel.h" #include "sortedtimelinemodel.h"
#include "singlecategorytimelinemodel_p.h" #include "abstracttimelinemodel_p.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QCoreApplication> #include <QCoreApplication>
@@ -48,7 +48,7 @@ namespace Internal {
class PaintEventsModelProxy::PaintEventsModelProxyPrivate : class PaintEventsModelProxy::PaintEventsModelProxyPrivate :
public SortedTimelineModel<QmlPaintEventData, public SortedTimelineModel<QmlPaintEventData,
SingleCategoryTimelineModel::SingleCategoryTimelineModelPrivate> AbstractTimelineModel::AbstractTimelineModelPrivate>
{ {
public: public:
@@ -61,7 +61,7 @@ private:
}; };
PaintEventsModelProxy::PaintEventsModelProxy(QObject *parent) PaintEventsModelProxy::PaintEventsModelProxy(QObject *parent)
: SingleCategoryTimelineModel(new PaintEventsModelProxyPrivate, : AbstractTimelineModel(new PaintEventsModelProxyPrivate,
QLatin1String("PaintEventsModelProxy"), tr("Painting"), QLatin1String("PaintEventsModelProxy"), tr("Painting"),
QmlDebug::Event, QmlDebug::MaximumRangeType, parent) QmlDebug::Event, QmlDebug::MaximumRangeType, parent)
{ {
@@ -83,7 +83,7 @@ void PaintEventsModelProxy::clear()
bool PaintEventsModelProxy::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const bool PaintEventsModelProxy::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const
{ {
return SingleCategoryTimelineModel::eventAccepted(event) && return AbstractTimelineModel::eventAccepted(event) &&
event.detailType== QmlDebug::AnimationFrame; event.detailType== QmlDebug::AnimationFrame;
} }

View File

@@ -32,7 +32,7 @@
#define QMLPROFILERPAINTEVENTSMODELPROXY_H #define QMLPROFILERPAINTEVENTSMODELPROXY_H
#include <QObject> #include <QObject>
#include "singlecategorytimelinemodel.h" #include "abstracttimelinemodel.h"
#include <qmldebug/qmlprofilereventtypes.h> #include <qmldebug/qmlprofilereventtypes.h>
#include <qmldebug/qmlprofilereventlocation.h> #include <qmldebug/qmlprofilereventlocation.h>
//#include <QHash> //#include <QHash>
@@ -48,7 +48,7 @@ class QmlProfilerModelManager;
namespace Internal { namespace Internal {
class PaintEventsModelProxy : public SingleCategoryTimelineModel class PaintEventsModelProxy : public AbstractTimelineModel
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@@ -31,7 +31,7 @@
#include "qmlprofilermodelmanager.h" #include "qmlprofilermodelmanager.h"
#include "qmlprofilerdatamodel.h" #include "qmlprofilerdatamodel.h"
#include "sortedtimelinemodel.h" #include "sortedtimelinemodel.h"
#include "singlecategorytimelinemodel_p.h" #include "abstracttimelinemodel_p.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QVector> #include <QVector>
@@ -47,7 +47,7 @@ namespace Internal {
class RangeTimelineModel::RangeTimelineModelPrivate : class RangeTimelineModel::RangeTimelineModelPrivate :
public SortedTimelineModel<RangeTimelineModel::QmlRangeEventStartInstance, public SortedTimelineModel<RangeTimelineModel::QmlRangeEventStartInstance,
SingleCategoryTimelineModel::SingleCategoryTimelineModelPrivate> AbstractTimelineModel::AbstractTimelineModelPrivate>
{ {
public: public:
// convenience functions // convenience functions
@@ -65,7 +65,7 @@ private:
}; };
RangeTimelineModel::RangeTimelineModel(QmlDebug::RangeType rangeType, QObject *parent) RangeTimelineModel::RangeTimelineModel(QmlDebug::RangeType rangeType, QObject *parent)
: SingleCategoryTimelineModel(new RangeTimelineModelPrivate, : AbstractTimelineModel(new RangeTimelineModelPrivate,
QLatin1String("RangeTimelineModel"), categoryLabel(rangeType), QLatin1String("RangeTimelineModel"), categoryLabel(rangeType),
QmlDebug::MaximumMessage, rangeType, parent) QmlDebug::MaximumMessage, rangeType, parent)
{ {

View File

@@ -31,7 +31,7 @@
#ifndef QMLPROFILERTIMELINEMODELPROXY_H #ifndef QMLPROFILERTIMELINEMODELPROXY_H
#define QMLPROFILERTIMELINEMODELPROXY_H #define QMLPROFILERTIMELINEMODELPROXY_H
#include "singlecategorytimelinemodel.h" #include "abstracttimelinemodel.h"
#include <qmldebug/qmlprofilereventtypes.h> #include <qmldebug/qmlprofilereventtypes.h>
#include <qmldebug/qmlprofilereventlocation.h> #include <qmldebug/qmlprofilereventlocation.h>
#include <QVariantList> #include <QVariantList>
@@ -43,7 +43,7 @@ class QmlProfilerModelManager;
namespace Internal { namespace Internal {
class RangeTimelineModel : public SingleCategoryTimelineModel class RangeTimelineModel : public AbstractTimelineModel
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@@ -1,76 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "singlecategorytimelinemodel.h"
#include "singlecategorytimelinemodel_p.h"
namespace QmlProfiler {
SingleCategoryTimelineModel::SingleCategoryTimelineModel(SingleCategoryTimelineModelPrivate *dd,
const QString &name, const QString &label, QmlDebug::Message message,
QmlDebug::RangeType rangeType, QObject *parent) :
AbstractTimelineModel(dd, name, parent)
{
Q_D(SingleCategoryTimelineModel);
d->expanded = false;
d->title = label;
d->message = message;
d->rangeType = rangeType;
}
/////////////////// QML interface
bool SingleCategoryTimelineModel::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const
{
Q_D(const SingleCategoryTimelineModel);
return (event.rangeType == d->rangeType && event.message == d->message);
}
bool SingleCategoryTimelineModel::expanded() const
{
Q_D(const SingleCategoryTimelineModel);
return d->expanded;
}
void SingleCategoryTimelineModel::setExpanded(bool expanded)
{
Q_D(SingleCategoryTimelineModel);
if (expanded != d->expanded) {
d->expanded = expanded;
emit expandedChanged();
}
}
const QString SingleCategoryTimelineModel::title() const
{
Q_D(const SingleCategoryTimelineModel);
return d->title;
}
}

View File

@@ -1,59 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef SINGLECATEGORYTIMELINEMODEL_H
#define SINGLECATEGORYTIMELINEMODEL_H
#include <qmldebug/qmlprofilereventtypes.h>
#include "abstracttimelinemodel.h"
namespace QmlProfiler {
class QMLPROFILER_EXPORT SingleCategoryTimelineModel : public AbstractTimelineModel
{
Q_OBJECT
public:
bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const;
bool expanded() const;
void setExpanded(bool expanded);
int getEventType(int index) const;
const QString title() const;
protected:
class SingleCategoryTimelineModelPrivate;
SingleCategoryTimelineModel(SingleCategoryTimelineModelPrivate *dd, const QString &name,
const QString &label, QmlDebug::Message message,
QmlDebug::RangeType rangeType, QObject *parent);
Q_DECLARE_PRIVATE(SingleCategoryTimelineModel)
};
}
#endif // SINGLECATEGORYTIMELINEMODEL_H

View File

@@ -1,48 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** 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 Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef SINGLECATEGORYTIMELINEMODEL_P_H
#define SINGLECATEGORYTIMELINEMODEL_P_H
#include "singlecategorytimelinemodel.h"
#include "abstracttimelinemodel_p.h"
namespace QmlProfiler {
class SingleCategoryTimelineModel::SingleCategoryTimelineModelPrivate :
public AbstractTimelineModel::AbstractTimelineModelPrivate {
public:
bool expanded;
QString title;
QmlDebug::Message message;
QmlDebug::RangeType rangeType;
};
}
#endif // SINGLECATEGORYTIMELINEMODEL_P_H