diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-10-28 17:39:23 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2014-11-21 14:50:30 +0200 |
commit | fd09a6bed2b8b7c574e6a561f8c091de1af87d2b (patch) | |
tree | 57346ca622ba1c1b67c2e1d9a90b6d584cc05539 | |
parent | b398ccb7387f9020f46284a139c677167b381501 (diff) |
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>
9 files changed, 39 insertions, 43 deletions
diff --git a/plugins/qmlprofilerextension/inputeventsmodel.cpp b/plugins/qmlprofilerextension/inputeventsmodel.cpp index 59fc1448d2..68800be9c9 100644 --- a/plugins/qmlprofilerextension/inputeventsmodel.cpp +++ b/plugins/qmlprofilerextension/inputeventsmodel.cpp @@ -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 diff --git a/plugins/qmlprofilerextension/inputeventsmodel.h b/plugins/qmlprofilerextension/inputeventsmodel.h index d85865733b..0af38e93b5 100644 --- a/plugins/qmlprofilerextension/inputeventsmodel.h +++ b/plugins/qmlprofilerextension/inputeventsmodel.h @@ -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; diff --git a/plugins/qmlprofilerextension/memoryusagemodel.cpp b/plugins/qmlprofilerextension/memoryusagemodel.cpp index 7fdc08c051..5f6204a68e 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.cpp +++ b/plugins/qmlprofilerextension/memoryusagemodel.cpp @@ -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 diff --git a/plugins/qmlprofilerextension/memoryusagemodel.h b/plugins/qmlprofilerextension/memoryusagemodel.h index 2d8d535ecd..6ade0365bd 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.h +++ b/plugins/qmlprofilerextension/memoryusagemodel.h @@ -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; diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.cpp b/plugins/qmlprofilerextension/pixmapcachemodel.cpp index 21ffb912c2..c3bfc19f4c 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.cpp +++ b/plugins/qmlprofilerextension/pixmapcachemodel.cpp @@ -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 diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.h b/plugins/qmlprofilerextension/pixmapcachemodel.h index 7b932ed825..5c0160e9bb 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.h +++ b/plugins/qmlprofilerextension/pixmapcachemodel.h @@ -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; diff --git a/plugins/qmlprofilerextension/qmlprofilerextensionplugin.cpp b/plugins/qmlprofilerextension/qmlprofilerextensionplugin.cpp index 20c9e2017f..be7dee83c8 100644 --- a/plugins/qmlprofilerextension/qmlprofilerextensionplugin.cpp +++ b/plugins/qmlprofilerextension/qmlprofilerextensionplugin.cpp @@ -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" diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp index 1ae51244cb..d0d497e0a2 100644 --- a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp +++ b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp @@ -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 diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.h b/plugins/qmlprofilerextension/scenegraphtimelinemodel.h index 1dbbe969c3..204815d9f7 100644 --- a/plugins/qmlprofilerextension/scenegraphtimelinemodel.h +++ b/plugins/qmlprofilerextension/scenegraphtimelinemodel.h @@ -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; |