diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2015-11-28 16:25:58 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-11-29 18:35:26 +0000 |
commit | 1196a530f0865129a251921cf4b2e755500946ee (patch) | |
tree | 686c0ec391b323d6e48897869c9fe46e813bd40f /src/input/frontend | |
parent | 35c1ba9568524de1e31e63b3439982971904a1f1 (diff) |
Add API to handle QAxisSettings in QAbstractPhysicalDevice
Change-Id: I8d40a0fcd315f3408dfa734fa43c1cef664e3ec2
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/input/frontend')
-rw-r--r-- | src/input/frontend/frontend.pri | 3 | ||||
-rw-r--r-- | src/input/frontend/qabstractphysicaldevice.cpp | 40 | ||||
-rw-r--r-- | src/input/frontend/qabstractphysicaldevice.h | 21 | ||||
-rw-r--r-- | src/input/frontend/qabstractphysicaldevice_p.h | 74 |
4 files changed, 131 insertions, 7 deletions
diff --git a/src/input/frontend/frontend.pri b/src/input/frontend/frontend.pri index 0b23e541a..4ea952e96 100644 --- a/src/input/frontend/frontend.pri +++ b/src/input/frontend/frontend.pri @@ -20,7 +20,8 @@ HEADERS += \ $$PWD/qinputdeviceintegration.h \ $$PWD/qabstractphysicaldevice.h \ $$PWD/qinputdeviceintegrationfactory_p.h \ - $$PWD/qaxissetting.h + $$PWD/qaxissetting.h \ + $$PWD/qabstractphysicaldevice_p.h SOURCES += \ $$PWD/qinputaspect.cpp \ diff --git a/src/input/frontend/qabstractphysicaldevice.cpp b/src/input/frontend/qabstractphysicaldevice.cpp index a47b915fd..61236e215 100644 --- a/src/input/frontend/qabstractphysicaldevice.cpp +++ b/src/input/frontend/qabstractphysicaldevice.cpp @@ -35,14 +35,25 @@ ****************************************************************************/ #include "qabstractphysicaldevice.h" +#include "qabstractphysicaldevice_p.h" #include <Qt3DCore/private/qnode_p.h> QT_BEGIN_NAMESPACE namespace Qt3DInput { +QAbstractPhysicalDevicePrivate::QAbstractPhysicalDevicePrivate() + : m_axisSettings() +{ +} + QAbstractPhysicalDevice::QAbstractPhysicalDevice(Qt3DCore::QNode *parent) - : Qt3DCore::QNode(parent) + : Qt3DCore::QNode(*new QAbstractPhysicalDevicePrivate, parent) +{ +} + +QAbstractPhysicalDevice::QAbstractPhysicalDevice(QAbstractPhysicalDevicePrivate &dd, Qt3DCore::QNode *parent) + : Qt3DCore::QNode(dd, parent) { } @@ -51,6 +62,33 @@ QAbstractPhysicalDevice::~QAbstractPhysicalDevice() Q_ASSERT_X(Qt3DCore::QNodePrivate::get(this)->m_wasCleanedUp, Q_FUNC_INFO, "QNode::cleanup should have been called by now. A Qt3DInput::QAbstractPhysicalDevice subclass didn't call QNode::cleanup in its destructor"); } +void QAbstractPhysicalDevice::addAxisSetting(QAxisSetting *axisSetting) +{ + Q_D(QAbstractPhysicalDevice); + if (!d->m_axisSettings.contains(axisSetting)) + d->m_axisSettings.push_back(axisSetting); +} + +void QAbstractPhysicalDevice::removeAxisSetting(QAxisSetting *axisSetting) +{ + Q_D(QAbstractPhysicalDevice); + if (d->m_axisSettings.contains(axisSetting)) + d->m_axisSettings.removeOne(axisSetting); +} + +QVector<QAxisSetting *> QAbstractPhysicalDevice::axisSettings() const +{ + Q_D(const QAbstractPhysicalDevice); + return d->m_axisSettings; +} + +void QAbstractPhysicalDevice::copy(const QNode *ref) +{ + QNode::copy(ref); + const QAbstractPhysicalDevice *physicalDevice = static_cast<const QAbstractPhysicalDevice *>(ref); + d_func()->m_axisSettings = physicalDevice->axisSettings(); +} + } QT_END_NAMESPACE diff --git a/src/input/frontend/qabstractphysicaldevice.h b/src/input/frontend/qabstractphysicaldevice.h index 6d8d4d49d..7ddf8d1fe 100644 --- a/src/input/frontend/qabstractphysicaldevice.h +++ b/src/input/frontend/qabstractphysicaldevice.h @@ -34,18 +34,21 @@ ** ****************************************************************************/ -#ifndef QT3DINPUT_QAbstractPhysicalDevice -#define QT3DINPUT_QAbstractPhysicalDevice +#ifndef QT3DINPUT_QABSTRACTPHYSICALDEVICE +#define QT3DINPUT_QABSTRACTPHYSICALDEVICE #include <Qt3DInput/qt3dinput_global.h> #include <Qt3DCore/qnode.h> -#include <QObject> +#include <QtCore/qobject.h> +#include <QtCore/qvector.h> QT_BEGIN_NAMESPACE namespace Qt3DInput { +class QAxisSetting; class QInputAspect; +class QAbstractPhysicalDevicePrivate; class QT3DINPUTSHARED_EXPORT QAbstractPhysicalDevice : public Qt3DCore::QNode { @@ -64,7 +67,15 @@ public: virtual float axis(int axisIdentifier) const = 0; virtual bool button(int buttonIdentifier) const = 0; - // TODO: Add API to support AxisSettings + + void addAxisSetting(QAxisSetting *axisSetting); + void removeAxisSetting(QAxisSetting *axisSetting); + QVector<QAxisSetting *> axisSettings() const; + +protected: + QAbstractPhysicalDevice(QAbstractPhysicalDevicePrivate &dd, Qt3DCore::QNode *parent = 0); + Q_DECLARE_PRIVATE(QAbstractPhysicalDevice) + void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE; }; } // Qt3DInput @@ -72,5 +83,5 @@ public: QT_END_NAMESPACE -#endif // QT3DINPUT_QAbstractPhysicalDevice +#endif // QT3DINPUT_QABSTRACTPHYSICALDEVICE diff --git a/src/input/frontend/qabstractphysicaldevice_p.h b/src/input/frontend/qabstractphysicaldevice_p.h new file mode 100644 index 000000000..0ae7fd3eb --- /dev/null +++ b/src/input/frontend/qabstractphysicaldevice_p.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DINPUT_QABSTRACTPHYSICALDEVICE_P_H +#define QT3DINPUT_QABSTRACTPHYSICALDEVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <Qt3DCore/private/qnode_p.h> +#include <QtCore/qvector.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +class QAxisSetting; + +class QAbstractPhysicalDevicePrivate : public Qt3DCore::QNodePrivate +{ +public: + QAbstractPhysicalDevicePrivate(); + + Q_DECLARE_PUBLIC(QAbstractPhysicalDevice) + QVector<QAxisSetting *> m_axisSettings; +}; + +} + +QT_END_NAMESPACE + +#endif // QT3DINPUT_QABSTRACTPHYSICALDEVICE_P_H + |