diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2016-04-23 10:41:05 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-04-27 11:18:28 +0000 |
commit | b98358e4711de04d2f47f2dbbaab0352f469b69e (patch) | |
tree | 114f550cd719503fbe8ff64de561bfbbbd5dd308 /src/input/backend/qabstractphysicaldevicebackendnode.cpp | |
parent | 80bc99ab02173944b5ce968a30bc3431b10f5861 (diff) |
AbstractPhysicalDevice use new added/removed change types
Also implement missing notification sending from the frontend.
Change-Id: Iab9ff424496ee1db91101dc70f9b074ca093d2a6
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input/backend/qabstractphysicaldevicebackendnode.cpp')
-rw-r--r-- | src/input/backend/qabstractphysicaldevicebackendnode.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/input/backend/qabstractphysicaldevicebackendnode.cpp b/src/input/backend/qabstractphysicaldevicebackendnode.cpp index 4965214a4..c3f4aa8bb 100644 --- a/src/input/backend/qabstractphysicaldevicebackendnode.cpp +++ b/src/input/backend/qabstractphysicaldevicebackendnode.cpp @@ -49,6 +49,8 @@ #include <Qt3DInput/private/qinputaspect_p.h> #include <Qt3DCore/qnodepropertychange.h> +#include <Qt3DCore/qnodeaddedpropertychange.h> +#include <Qt3DCore/qnoderemovedpropertychange.h> #include <Qt3DCore/private/qabstractaspect_p.h> #include <cmath> @@ -182,17 +184,27 @@ void QAbstractPhysicalDeviceBackendNode::cleanup() void QAbstractPhysicalDeviceBackendNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) { Q_D(QAbstractPhysicalDeviceBackendNode); - Qt3DCore::QNodePropertyChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QNodePropertyChange>(e); - if (e->type() == Qt3DCore::NodeAdded) { - if (propertyChange->propertyName() == QByteArrayLiteral("axisSettings")) { - const Qt3DCore::QNodeId axisSettingId = propertyChange->value().value<Qt3DCore::QNodeId>(); + switch (e->type()) { + case Qt3DCore::NodeAdded: { + const auto change = qSharedPointerCast<Qt3DCore::QNodeAddedPropertyChange>(e); + if (change->propertyName() == QByteArrayLiteral("axisSettings")) { + const auto axisSettingId = change->addedNodeId(); Input::AxisSetting *axisSetting = d->getAxisSetting(axisSettingId); Q_FOREACH (int axisId, axisSetting->axes()) d->addAxisSetting(axisId, axisSettingId); } - } else if (e->type() == Qt3DCore::NodeRemoved) { - if (propertyChange->propertyName() == QByteArrayLiteral("axisSettings")) - d->removeAxisSetting(propertyChange->value().value<Qt3DCore::QNodeId>()); + break; + } + + case Qt3DCore::NodeRemoved: { + const auto change = qSharedPointerCast<Qt3DCore::QNodeRemovedPropertyChange>(e); + if (change->propertyName() == QByteArrayLiteral("axisSettings")) + d->removeAxisSetting(change->removedNodeId()); + break; + } + + default: + break; } QBackendNode::sceneChangeEvent(e); } |