From da80f3ffc733e19968b582699d4e4657ce7601fc Mon Sep 17 00:00:00 2001 From: Colin Ogilvie Date: Mon, 11 Jan 2016 12:14:44 +0000 Subject: Start at implementing QAbstractAction Input Change-Id: I392dd326cb0bf1b8c12b72d8554a866156d43e76 Reviewed-by: Sean Harmer --- src/input/backend/action.cpp | 4 +- src/input/frontend/frontend.pri | 6 ++- src/input/frontend/qabstractactioninput.cpp | 54 +++++++++++++++++++++ src/input/frontend/qabstractactioninput.h | 60 ++++++++++++++++++++++++ src/input/frontend/qaction.cpp | 14 +++--- src/input/frontend/qaction.h | 8 ++-- src/input/frontend/qactioninput.cpp | 4 +- src/input/frontend/qactioninput.h | 5 +- src/quick3d/quick3dinput/items/quick3daction.cpp | 14 +++--- src/quick3d/quick3dinput/items/quick3daction_p.h | 14 +++--- 10 files changed, 151 insertions(+), 32 deletions(-) create mode 100644 src/input/frontend/qabstractactioninput.cpp create mode 100644 src/input/frontend/qabstractactioninput.h diff --git a/src/input/backend/action.cpp b/src/input/backend/action.cpp index 97dc33d73..e9956559c 100644 --- a/src/input/backend/action.cpp +++ b/src/input/backend/action.cpp @@ -36,7 +36,7 @@ #include "action_p.h" #include -#include +#include #include QT_BEGIN_NAMESPACE @@ -57,7 +57,7 @@ void Action::updateFromPeer(Qt3DCore::QNode *peer) QAction *action = static_cast(peer); m_enabled = action->isEnabled(); m_name = action->name(); - Q_FOREACH (QActionInput *input, action->inputs()) + Q_FOREACH (QAbstractActionInput *input, action->inputs()) m_inputs.push_back(input->id()); } diff --git a/src/input/frontend/frontend.pri b/src/input/frontend/frontend.pri index 9d90c567f..4a6559a05 100644 --- a/src/input/frontend/frontend.pri +++ b/src/input/frontend/frontend.pri @@ -24,7 +24,8 @@ HEADERS += \ $$PWD/qaxissetting.h \ $$PWD/qabstractphysicaldevice_p.h \ $$PWD/qaxisactionhandler_p.h \ - $$PWD/qaxisactionhandler.h + $$PWD/qaxisactionhandler.h \ + $$PWD/qabstractactioninput.h SOURCES += \ $$PWD/qinputaspect.cpp \ @@ -44,6 +45,7 @@ SOURCES += \ $$PWD/qabstractphysicaldevice.cpp \ $$PWD/qinputdeviceintegrationfactory.cpp \ $$PWD/qaxissetting.cpp \ - $$PWD/qaxisactionhandler.cpp + $$PWD/qaxisactionhandler.cpp \ + $$PWD/qabstractactioninput.cpp INCLUDEPATH += $$PWD diff --git a/src/input/frontend/qabstractactioninput.cpp b/src/input/frontend/qabstractactioninput.cpp new file mode 100644 index 000000000..4933a8dda --- /dev/null +++ b/src/input/frontend/qabstractactioninput.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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$ +****************************************************************************/ + +#include "qabstractactioninput.h" +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +QAbstractActionInput::QAbstractActionInput(Qt3DCore::QNodePrivate &dd, Qt3DCore::QNode *parent) + : Qt3DCore::QNode(dd, parent) +{ +} + +QAbstractActionInput::~QAbstractActionInput() +{ +} + +} // Qt3DInput + +QT_END_NAMESPACE diff --git a/src/input/frontend/qabstractactioninput.h b/src/input/frontend/qabstractactioninput.h new file mode 100644 index 000000000..6644820a8 --- /dev/null +++ b/src/input/frontend/qabstractactioninput.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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_QABSTRACTACTIONINPUT_H +#define QT3DINPUT_QABSTRACTACTIONINPUT_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + +class QNodePrivate; + +class QT3DINPUTSHARED_EXPORT QAbstractActionInput : public Qt3DCore::QNode +{ + Q_OBJECT +public: + explicit QAbstractActionInput(Qt3DCore::QNodePrivate &dd, Qt3DCore::QNode *parent = 0); + ~QAbstractActionInput(); +}; + +} // Qt3DInput + +QT_END_NAMESPACE + +#endif // QT3DINPUT_QABSTRACTACTIONINPUT_H diff --git a/src/input/frontend/qaction.cpp b/src/input/frontend/qaction.cpp index e41917542..62b294357 100644 --- a/src/input/frontend/qaction.cpp +++ b/src/input/frontend/qaction.cpp @@ -37,7 +37,7 @@ #include "qaction.h" #include #include -#include +#include QT_BEGIN_NAMESPACE @@ -51,7 +51,7 @@ public: {} QString m_name; - QVector m_inputs; + QVector m_inputs; }; QAction::QAction(Qt3DCore::QNode *parent) @@ -79,7 +79,7 @@ QString QAction::name() const return d->m_name; } -void QAction::addInput(QActionInput *input) +void QAction::addInput(QAbstractActionInput *input) { Q_D(QAction); if (!d->m_inputs.contains(input)) { @@ -97,7 +97,7 @@ void QAction::addInput(QActionInput *input) } } -void QAction::removeInput(QActionInput *input) +void QAction::removeInput(QAbstractActionInput *input) { Q_D(QAction); if (d->m_inputs.contains(input)) { @@ -113,7 +113,7 @@ void QAction::removeInput(QActionInput *input) } } -QVector QAction::inputs() const +QVector QAction::inputs() const { Q_D(const QAction); return d->m_inputs; @@ -124,8 +124,8 @@ void QAction::copy(const Qt3DCore::QNode *ref) QNode::copy(ref); const QAction *action = static_cast(ref); d_func()->m_name = action->d_func()->m_name; - Q_FOREACH (QActionInput *input, action->inputs()) - d_func()->m_inputs.append(qobject_cast(QNode::clone(input))); + Q_FOREACH (QAbstractActionInput *input, action->inputs()) + d_func()->m_inputs.append(qobject_cast(QNode::clone(input))); } } // Qt3DInput diff --git a/src/input/frontend/qaction.h b/src/input/frontend/qaction.h index 80c0a264d..0f70305bc 100644 --- a/src/input/frontend/qaction.h +++ b/src/input/frontend/qaction.h @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE namespace Qt3DInput { class QActionPrivate; -class QActionInput; +class QAbstractActionInput; class QT3DINPUTSHARED_EXPORT QAction : public Qt3DCore::QNode { @@ -57,12 +57,12 @@ public: QString name() const; - void addInput(QActionInput *input); - void removeInput(QActionInput *input); - QVector inputs() const; public Q_SLOTS: void setName(const QString &name); + void addInput(QAbstractActionInput *input); + void removeInput(QAbstractActionInput *input); + QVector inputs() const; Q_SIGNALS: void nameChanged(const QString &name); diff --git a/src/input/frontend/qactioninput.cpp b/src/input/frontend/qactioninput.cpp index 252e858a4..08de69b82 100644 --- a/src/input/frontend/qactioninput.cpp +++ b/src/input/frontend/qactioninput.cpp @@ -36,6 +36,7 @@ #include "qactioninput.h" #include #include +#include QT_BEGIN_NAMESPACE @@ -54,8 +55,9 @@ public: }; QActionInput::QActionInput(Qt3DCore::QNode *parent) - : Qt3DCore::QNode(*new QActionInputPrivate(), parent) + : Qt3DInput::QAbstractActionInput(*new QActionInputPrivate(), parent) { + } QActionInput::~QActionInput() diff --git a/src/input/frontend/qactioninput.h b/src/input/frontend/qactioninput.h index 1b895832d..79a05540d 100644 --- a/src/input/frontend/qactioninput.h +++ b/src/input/frontend/qactioninput.h @@ -39,6 +39,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -47,7 +48,7 @@ namespace Qt3DInput { class QAbstractPhysicalDevice; class QActionInputPrivate; -class QT3DINPUTSHARED_EXPORT QActionInput : public Qt3DCore::QNode +class QT3DINPUTSHARED_EXPORT QActionInput : public Qt3DInput::QAbstractActionInput { Q_OBJECT Q_PROPERTY(Qt3DInput::QAbstractPhysicalDevice *sourceDevice READ sourceDevice WRITE setSourceDevice NOTIFY sourceDeviceChanged) @@ -80,4 +81,4 @@ private: QT_END_NAMESPACE -#endif // QACTIONINPUT_H +#endif // QT3DINPUT_QACTIONINPUT_H diff --git a/src/quick3d/quick3dinput/items/quick3daction.cpp b/src/quick3d/quick3dinput/items/quick3daction.cpp index 140d62cc9..ad13270fa 100644 --- a/src/quick3d/quick3dinput/items/quick3daction.cpp +++ b/src/quick3d/quick3dinput/items/quick3daction.cpp @@ -47,37 +47,37 @@ Quick3DAction::Quick3DAction(QObject *parent) { } -QQmlListProperty Quick3DAction::qmlActionInputs() +QQmlListProperty Quick3DAction::qmlActionInputs() { - return QQmlListProperty(this, 0, + return QQmlListProperty(this, 0, &Quick3DAction::appendActionInput, &Quick3DAction::actionInputCount, &Quick3DAction::actionInputAt, &Quick3DAction::clearActionInputs); } -void Quick3DAction::appendActionInput(QQmlListProperty *list, QActionInput *input) +void Quick3DAction::appendActionInput(QQmlListProperty *list, QAbstractActionInput *input) { Quick3DAction *action = qobject_cast(list->object); action->parentAction()->addInput(input); } -QActionInput *Quick3DAction::actionInputAt(QQmlListProperty *list, int index) +QAbstractActionInput *Quick3DAction::actionInputAt(QQmlListProperty *list, int index) { Quick3DAction *action = qobject_cast(list->object); return action->parentAction()->inputs().at(index); } -int Quick3DAction::actionInputCount(QQmlListProperty *list) +int Quick3DAction::actionInputCount(QQmlListProperty *list) { Quick3DAction *action = qobject_cast(list->object); return action->parentAction()->inputs().count(); } -void Quick3DAction::clearActionInputs(QQmlListProperty *list) +void Quick3DAction::clearActionInputs(QQmlListProperty *list) { Quick3DAction *action = qobject_cast(list->object); - Q_FOREACH (QActionInput *input, action->parentAction()->inputs()) + Q_FOREACH (QAbstractActionInput *input, action->parentAction()->inputs()) action->parentAction()->removeInput(input); } diff --git a/src/quick3d/quick3dinput/items/quick3daction_p.h b/src/quick3d/quick3dinput/items/quick3daction_p.h index 040418628..9c3360f23 100644 --- a/src/quick3d/quick3dinput/items/quick3daction_p.h +++ b/src/quick3d/quick3dinput/items/quick3daction_p.h @@ -50,7 +50,7 @@ #include #include -#include +#include #include QT_BEGIN_NAMESPACE @@ -62,18 +62,18 @@ namespace Quick { class QT3DQUICKINPUTSHARED_PRIVATE_EXPORT Quick3DAction : public QObject { Q_OBJECT - Q_PROPERTY(QQmlListProperty inputs READ qmlActionInputs CONSTANT) + Q_PROPERTY(QQmlListProperty inputs READ qmlActionInputs CONSTANT) public: explicit Quick3DAction(QObject *parent = Q_NULLPTR); inline QAction *parentAction() const { return qobject_cast(parent()); } - QQmlListProperty qmlActionInputs(); + QQmlListProperty qmlActionInputs(); private: - static void appendActionInput(QQmlListProperty *list, QActionInput *input); - static QActionInput *actionInputAt(QQmlListProperty *list, int index); - static int actionInputCount(QQmlListProperty *list); - static void clearActionInputs(QQmlListProperty *list); + static void appendActionInput(QQmlListProperty *list, QAbstractActionInput *input); + static QAbstractActionInput *actionInputAt(QQmlListProperty *list, int index); + static int actionInputCount(QQmlListProperty *list); + static void clearActionInputs(QQmlListProperty *list); }; } // namespace Quick -- cgit v1.2.3