Create extension models through a factory

Like that we can drop the deferred setting of model manager and we can
announce the features right away on construction.

Change-Id: I8b4eb3e94046511b0e637084768e919649115e77
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2014-10-28 17:39:23 +01:00
committed by Ulf Hermann
parent b398ccb738
commit fd09a6bed2
9 changed files with 39 additions and 43 deletions

View File

@@ -25,16 +25,13 @@ namespace Internal {
using namespace QmlProfiler;
InputEventsModel::InputEventsModel(QObject *parent)
: AbstractTimelineModel(tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileInputEvents)),
InputEventsModel::InputEventsModel(QmlProfilerModelManager *manager, QObject *parent)
: AbstractTimelineModel(manager,
tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileInputEvents)),
QmlDebug::Event, QmlDebug::MaximumRangeType, parent),
m_keyTypeId(-1), m_mouseTypeId(-1)
{
}
quint64 InputEventsModel::features() const
{
return 1 << QmlDebug::ProfileInputEvents;
announceFeatures(1 << QmlDebug::ProfileInputEvents);
}
int InputEventsModel::typeId(int index) const

View File

@@ -32,8 +32,7 @@ protected:
bool accepted(const QmlProfiler::QmlProfilerDataModel::QmlEventTypeData &event) const;
public:
InputEventsModel(QObject *parent = 0);
quint64 features() const;
InputEventsModel(QmlProfiler::QmlProfilerModelManager *manager, QObject *parent = 0);
int typeId(int index) const;
QColor color(int index) const;

View File

@@ -27,16 +27,12 @@ namespace Internal {
using namespace QmlProfiler;
MemoryUsageModel::MemoryUsageModel(QObject *parent)
: AbstractTimelineModel(tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileMemory)),
MemoryUsageModel::MemoryUsageModel(QmlProfilerModelManager *manager, QObject *parent)
: AbstractTimelineModel(manager,
tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileMemory)),
QmlDebug::MemoryAllocation, QmlDebug::MaximumRangeType, parent)
{
}
quint64 MemoryUsageModel::features() const
{
// Will listen to all range events, too, to determine context.
return (1 << QmlDebug::ProfileMemory) | QmlDebug::Constants::QML_JS_RANGE_FEATURES;
announceFeatures((1 << QmlDebug::ProfileMemory) | QmlDebug::Constants::QML_JS_RANGE_FEATURES);
}
int MemoryUsageModel::rowMaxValue(int rowNumber) const

View File

@@ -46,8 +46,7 @@ public:
void update(qint64 amount);
};
MemoryUsageModel(QObject *parent = 0);
quint64 features() const;
MemoryUsageModel(QmlProfiler::QmlProfilerModelManager *manager, QObject *parent = 0);
int rowMaxValue(int rowNumber) const;

View File

@@ -25,16 +25,13 @@ namespace Internal {
using namespace QmlProfiler;
PixmapCacheModel::PixmapCacheModel(QObject *parent)
: AbstractTimelineModel(tr(QmlProfilerModelManager::featureName(QmlDebug::ProfilePixmapCache)),
PixmapCacheModel::PixmapCacheModel(QmlProfilerModelManager *manager, QObject *parent)
: AbstractTimelineModel(manager,
tr(QmlProfilerModelManager::featureName(QmlDebug::ProfilePixmapCache)),
QmlDebug::PixmapCacheEvent, QmlDebug::MaximumRangeType, parent)
{
m_maxCacheSize = 1;
}
quint64 PixmapCacheModel::features() const
{
return 1 << QmlDebug::ProfilePixmapCache;
announceFeatures(1 << QmlDebug::ProfilePixmapCache);
}
int PixmapCacheModel::rowMaxValue(int rowNumber) const

View File

@@ -85,8 +85,7 @@ public:
qint64 cacheSize;
};
PixmapCacheModel(QObject *parent = 0);
quint64 features() const;
PixmapCacheModel(QmlProfiler::QmlProfilerModelManager *manager, QObject *parent = 0);
int rowMaxValue(int rowNumber) const;

View File

@@ -18,6 +18,7 @@
#include "qmlprofilerextensionplugin.h"
#include "qmlprofilerextensionconstants.h"
#include <qmlprofiler/qmlprofilertimelinemodelfactory.h>
#include <licensechecker/licensecheckerplugin.h>
@@ -45,6 +46,21 @@
using namespace QmlProfilerExtension::Internal;
class ModelFactory : public QmlProfiler::QmlProfilerTimelineModelFactory {
Q_OBJECT
public:
QList<QmlProfiler::AbstractTimelineModel *> create(
QmlProfiler::QmlProfilerModelManager *manager)
{
QList<QmlProfiler::AbstractTimelineModel *> models;
models << new PixmapCacheModel(manager, this)
<< new SceneGraphTimelineModel(manager, this)
<< new MemoryUsageModel(manager, this)
<< new InputEventsModel(manager, this);
return models;
}
};
QmlProfilerExtensionPlugin::QmlProfilerExtensionPlugin()
{
// Create your members
@@ -72,12 +88,8 @@ bool QmlProfilerExtensionPlugin::initialize(const QStringList &arguments, QStrin
= ExtensionSystem::PluginManager::getObject<LicenseChecker::LicenseCheckerPlugin>();
if (licenseChecker && licenseChecker->hasValidLicense()) {
if (licenseChecker->enterpriseFeatures()) {
addAutoReleasedObject(new PixmapCacheModel);
addAutoReleasedObject(new SceneGraphTimelineModel);
addAutoReleasedObject(new MemoryUsageModel);
addAutoReleasedObject(new InputEventsModel);
}
if (licenseChecker->enterpriseFeatures())
addAutoReleasedObject(new ModelFactory);
} else {
qWarning() << "Invalid license, disabling QML Profiler Enterprise features";
}
@@ -107,3 +119,4 @@ void QmlProfilerExtensionPlugin::triggerAction()
tr("This is an action from QmlProfilerExtension."));
}
#include "qmlprofilerextensionplugin.moc"

View File

@@ -68,15 +68,12 @@ enum SceneGraphCategoryType {
Q_STATIC_ASSERT(sizeof(StageLabels) ==
SceneGraphTimelineModel::MaximumSceneGraphStage * sizeof(const char *));
SceneGraphTimelineModel::SceneGraphTimelineModel(QObject *parent)
: AbstractTimelineModel(tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileSceneGraph)),
SceneGraphTimelineModel::SceneGraphTimelineModel(QmlProfilerModelManager *manager, QObject *parent)
: AbstractTimelineModel(manager,
tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileSceneGraph)),
QmlDebug::SceneGraphFrame, QmlDebug::MaximumRangeType, parent)
{
}
quint64 SceneGraphTimelineModel::features() const
{
return 1 << QmlDebug::ProfileSceneGraph;
announceFeatures(1 << QmlDebug::ProfileSceneGraph);
}
int SceneGraphTimelineModel::row(int index) const

View File

@@ -77,8 +77,7 @@ public:
int glyphCount; // only used for one event type
};
SceneGraphTimelineModel(QObject *parent = 0);
quint64 features() const;
SceneGraphTimelineModel(QmlProfiler::QmlProfilerModelManager *manager, QObject *parent = 0);
int row(int index) const;
int typeId(int index) const;