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; using namespace QmlProfiler;
InputEventsModel::InputEventsModel(QObject *parent) InputEventsModel::InputEventsModel(QmlProfilerModelManager *manager, QObject *parent)
: AbstractTimelineModel(tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileInputEvents)), : AbstractTimelineModel(manager,
tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileInputEvents)),
QmlDebug::Event, QmlDebug::MaximumRangeType, parent), QmlDebug::Event, QmlDebug::MaximumRangeType, parent),
m_keyTypeId(-1), m_mouseTypeId(-1) m_keyTypeId(-1), m_mouseTypeId(-1)
{ {
} announceFeatures(1 << QmlDebug::ProfileInputEvents);
quint64 InputEventsModel::features() const
{
return 1 << QmlDebug::ProfileInputEvents;
} }
int InputEventsModel::typeId(int index) const int InputEventsModel::typeId(int index) const

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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