diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2015-12-01 11:04:56 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-12-04 16:22:34 +0000 |
commit | 0cce8bfcd64b081c1e669720667b173175df5f82 (patch) | |
tree | 0e908ccabe04077718d77cccee29860669db3532 /src/input/frontend | |
parent | 10cd5430664b6e3a1c674a3f1df5b103d353bb4e (diff) |
Store logical device in QActionHandler
Change-Id: Iab92eb3974c335a16b01cb1455ddd219c36490cd
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input/frontend')
-rw-r--r-- | src/input/frontend/qactionhandler.cpp | 34 | ||||
-rw-r--r-- | src/input/frontend/qactionhandler.h | 9 | ||||
-rw-r--r-- | src/input/frontend/qactionhandler_p.h | 7 |
3 files changed, 46 insertions, 4 deletions
diff --git a/src/input/frontend/qactionhandler.cpp b/src/input/frontend/qactionhandler.cpp index 3f3ddb788..d8a6408f2 100644 --- a/src/input/frontend/qactionhandler.cpp +++ b/src/input/frontend/qactionhandler.cpp @@ -43,9 +43,20 @@ namespace Qt3DInput { QActionHandlerPrivate::QActionHandlerPrivate() : Qt3DCore::QComponentPrivate() + , m_logicalDevice(Q_NULLPTR) { } +void QActionHandlerPrivate::setupConnections() +{ + // TODO: Make connections to Actions contained in the logical device +} + +void QActionHandlerPrivate::removeConnections() +{ + // TODO: Tear down any old connections to the existing logical device +} + QActionHandler::QActionHandler(Qt3DCore::QNode *parent) : Qt3DCore::QComponent(*new QActionHandlerPrivate, parent) { @@ -62,12 +73,31 @@ QActionHandler::~QActionHandler() QNode::cleanup(); } +Qt3DInput::QLogicalDevice *QActionHandler::logicalDevice() const +{ + Q_D(const QActionHandler); + return d->m_logicalDevice; +} + +void QActionHandler::setLogicalDevice(Qt3DInput::QLogicalDevice *logicalDevice) +{ + Q_D(QActionHandler); + if (d->m_logicalDevice == logicalDevice) + return; + + if (d->m_logicalDevice) + d->removeConnections(); + d->m_logicalDevice = logicalDevice; + if (d->m_logicalDevice) + d->setupConnections(); + emit logicalDeviceChanged(logicalDevice); +} + void QActionHandler::copy(const QNode *ref) { QComponent::copy(ref); const QActionHandler *component = static_cast<const QActionHandler *>(ref); - - // TODO: Copy the component's members + d_func()->m_logicalDevice = qobject_cast<QLogicalDevice *>(QNode::clone(component->d_func()->m_logicalDevice)); } QT_END_NAMESPACE diff --git a/src/input/frontend/qactionhandler.h b/src/input/frontend/qactionhandler.h index df961cb38..e681e78af 100644 --- a/src/input/frontend/qactionhandler.h +++ b/src/input/frontend/qactionhandler.h @@ -45,19 +45,24 @@ QT_BEGIN_NAMESPACE namespace Qt3DInput { class QActionHandlerPrivate; +class QLogicalDevice; class QT3DINPUTSHARED_EXPORT QActionHandler : public Qt3DCore::QComponent { Q_OBJECT - // TODO: Add properties + Q_PROPERTY(Qt3DInput::QLogicalDevice* logicalDevice READ logicalDevice WRITE setLogicalDevice NOTIFY logicalDeviceChanged) public: - QActionHandler(Qt3DCore::QNode *parent = 0); + QActionHandler(Qt3DCore::QNode *parent = Q_NULLPTR); ~QActionHandler(); + Qt3DInput::QLogicalDevice *logicalDevice() const; + public Q_SLOTS: + void setLogicalDevice(Qt3DInput::QLogicalDevice *logicalDevice); Q_SIGNALS: + void logicalDeviceChanged(Qt3DInput::QLogicalDevice *logicalDevice); protected: Q_DECLARE_PRIVATE(QActionHandler) diff --git a/src/input/frontend/qactionhandler_p.h b/src/input/frontend/qactionhandler_p.h index 88bbc9b02..e23cb966b 100644 --- a/src/input/frontend/qactionhandler_p.h +++ b/src/input/frontend/qactionhandler_p.h @@ -54,12 +54,19 @@ QT_BEGIN_NAMESPACE namespace Qt3DInput { +class QLogicalDevice; + class QActionHandlerPrivate : public Qt3DCore::QComponentPrivate { public: QActionHandlerPrivate(); + Q_DECLARE_PUBLIC(QActionHandler) + + void setupConnections(); + void removeConnections(); + QLogicalDevice *m_logicalDevice; }; } |