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

@@ -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"