diff options
author | Colin Ogilvie <colin.ogilvie@kdab.com> | 2016-01-11 12:14:44 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-01-12 18:38:12 +0000 |
commit | da80f3ffc733e19968b582699d4e4657ce7601fc (patch) | |
tree | 016771d37e5c77e19c246ddcaabc178c0f1ae131 /src | |
parent | e97d8c471fe6bff4764cc903f074284466ae058e (diff) |
Start at implementing QAbstractAction Input
Change-Id: I392dd326cb0bf1b8c12b72d8554a866156d43e76
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/input/backend/action.cpp | 4 | ||||
-rw-r--r-- | src/input/frontend/frontend.pri | 6 | ||||
-rw-r--r-- | src/input/frontend/qabstractactioninput.cpp | 54 | ||||
-rw-r--r-- | src/input/frontend/qabstractactioninput.h | 60 | ||||
-rw-r--r-- | src/input/frontend/qaction.cpp | 14 | ||||
-rw-r--r-- | src/input/frontend/qaction.h | 8 | ||||
-rw-r--r-- | src/input/frontend/qactioninput.cpp | 4 | ||||
-rw-r--r-- | src/input/frontend/qactioninput.h | 5 | ||||
-rw-r--r-- | src/quick3d/quick3dinput/items/quick3daction.cpp | 14 | ||||
-rw-r--r-- | src/quick3d/quick3dinput/items/quick3daction_p.h | 14 |
10 files changed, 151 insertions, 32 deletions
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 <Qt3DInput/qaction.h> -#include <Qt3DInput/qactioninput.h> +#include <Qt3DInput/qabstractactioninput.h> #include <Qt3DCore/qscenepropertychange.h> QT_BEGIN_NAMESPACE @@ -57,7 +57,7 @@ void Action::updateFromPeer(Qt3DCore::QNode *peer) QAction *action = static_cast<QAction *>(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 <Qt3DCore/private/qnode_p.h> + +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 <Qt3DInput/qt3dinput_global.h> +#include <Qt3DCore/qnode.h> + +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 <Qt3DCore/private/qnode_p.h> #include <Qt3DCore/qscenepropertychange.h> -#include <Qt3DInput/qactioninput.h> +#include <Qt3DInput/qabstractactioninput.h> QT_BEGIN_NAMESPACE @@ -51,7 +51,7 @@ public: {} QString m_name; - QVector<QActionInput *> m_inputs; + QVector<QAbstractActionInput *> 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<QActionInput *> QAction::inputs() const +QVector<QAbstractActionInput *> 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<const QAction *>(ref); d_func()->m_name = action->d_func()->m_name; - Q_FOREACH (QActionInput *input, action->inputs()) - d_func()->m_inputs.append(qobject_cast<QActionInput *>(QNode::clone(input))); + Q_FOREACH (QAbstractActionInput *input, action->inputs()) + d_func()->m_inputs.append(qobject_cast<QAbstractActionInput *>(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<QActionInput *> inputs() const; public Q_SLOTS: void setName(const QString &name); + void addInput(QAbstractActionInput *input); + void removeInput(QAbstractActionInput *input); + QVector<QAbstractActionInput *> 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 <Qt3DCore/private/qnode_p.h> #include <Qt3DInput/qabstractphysicaldevice.h> +#include <Qt3DInput/QAbstractActionInput> 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 <Qt3DInput/qt3dinput_global.h> #include <Qt3DCore/qnode.h> +#include <Qt3DInput/qabstractactioninput.h> 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<QActionInput> Quick3DAction::qmlActionInputs() +QQmlListProperty<QAbstractActionInput> Quick3DAction::qmlActionInputs() { - return QQmlListProperty<QActionInput>(this, 0, + return QQmlListProperty<QAbstractActionInput>(this, 0, &Quick3DAction::appendActionInput, &Quick3DAction::actionInputCount, &Quick3DAction::actionInputAt, &Quick3DAction::clearActionInputs); } -void Quick3DAction::appendActionInput(QQmlListProperty<QActionInput> *list, QActionInput *input) +void Quick3DAction::appendActionInput(QQmlListProperty<QAbstractActionInput> *list, QAbstractActionInput *input) { Quick3DAction *action = qobject_cast<Quick3DAction *>(list->object); action->parentAction()->addInput(input); } -QActionInput *Quick3DAction::actionInputAt(QQmlListProperty<QActionInput> *list, int index) +QAbstractActionInput *Quick3DAction::actionInputAt(QQmlListProperty<QAbstractActionInput> *list, int index) { Quick3DAction *action = qobject_cast<Quick3DAction *>(list->object); return action->parentAction()->inputs().at(index); } -int Quick3DAction::actionInputCount(QQmlListProperty<QActionInput> *list) +int Quick3DAction::actionInputCount(QQmlListProperty<QAbstractActionInput> *list) { Quick3DAction *action = qobject_cast<Quick3DAction *>(list->object); return action->parentAction()->inputs().count(); } -void Quick3DAction::clearActionInputs(QQmlListProperty<QActionInput> *list) +void Quick3DAction::clearActionInputs(QQmlListProperty<QAbstractActionInput> *list) { Quick3DAction *action = qobject_cast<Quick3DAction *>(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 <Qt3DQuickInput/private/qt3dquickinput_global_p.h> #include <Qt3DInput/QAction> -#include <Qt3DInput/QActionInput> +#include <Qt3DInput/QAbstractActionInput> #include <QQmlListProperty> QT_BEGIN_NAMESPACE @@ -62,18 +62,18 @@ namespace Quick { class QT3DQUICKINPUTSHARED_PRIVATE_EXPORT Quick3DAction : public QObject { Q_OBJECT - Q_PROPERTY(QQmlListProperty<Qt3DInput::QActionInput> inputs READ qmlActionInputs CONSTANT) + Q_PROPERTY(QQmlListProperty<Qt3DInput::QAbstractActionInput> inputs READ qmlActionInputs CONSTANT) public: explicit Quick3DAction(QObject *parent = Q_NULLPTR); inline QAction *parentAction() const { return qobject_cast<QAction *>(parent()); } - QQmlListProperty<QActionInput> qmlActionInputs(); + QQmlListProperty<QAbstractActionInput> qmlActionInputs(); private: - static void appendActionInput(QQmlListProperty<QActionInput> *list, QActionInput *input); - static QActionInput *actionInputAt(QQmlListProperty<QActionInput> *list, int index); - static int actionInputCount(QQmlListProperty<QActionInput> *list); - static void clearActionInputs(QQmlListProperty<QActionInput> *list); + static void appendActionInput(QQmlListProperty<QAbstractActionInput> *list, QAbstractActionInput *input); + static QAbstractActionInput *actionInputAt(QQmlListProperty<QAbstractActionInput> *list, int index); + static int actionInputCount(QQmlListProperty<QAbstractActionInput> *list); + static void clearActionInputs(QQmlListProperty<QAbstractActionInput> *list); }; } // namespace Quick |