| 1 | // Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include <Qt3DQuickInput/private/quick3daction_p.h> |
| 5 | |
| 6 | QT_BEGIN_NAMESPACE |
| 7 | |
| 8 | namespace Qt3DInput { |
| 9 | namespace Input { |
| 10 | namespace Quick { |
| 11 | |
| 12 | Quick3DAction::Quick3DAction(QObject *parent) |
| 13 | : QObject(parent) |
| 14 | { |
| 15 | } |
| 16 | |
| 17 | QQmlListProperty<QAbstractActionInput> Quick3DAction::qmlActionInputs() |
| 18 | { |
| 19 | using qt_size_type = qsizetype; |
| 20 | auto appendFunction = [](QQmlListProperty<QAbstractActionInput> *list, QAbstractActionInput *input) { |
| 21 | Quick3DAction *action = qobject_cast<Quick3DAction *>(object: list->object); |
| 22 | action->parentAction()->addInput(input); |
| 23 | }; |
| 24 | auto countFunction = [](QQmlListProperty<QAbstractActionInput> *list) -> qt_size_type { |
| 25 | Quick3DAction *action = qobject_cast<Quick3DAction *>(object: list->object); |
| 26 | return action->parentAction()->inputs().size(); |
| 27 | }; |
| 28 | auto atFunction = [](QQmlListProperty<QAbstractActionInput> *list, qt_size_type index) -> QAbstractActionInput * { |
| 29 | Quick3DAction *action = qobject_cast<Quick3DAction *>(object: list->object); |
| 30 | return action->parentAction()->inputs().at(i: index); |
| 31 | }; |
| 32 | auto clearFunction = [](QQmlListProperty<QAbstractActionInput> *list) { |
| 33 | Quick3DAction *action = qobject_cast<Quick3DAction *>(object: list->object); |
| 34 | const auto inputs = action->parentAction()->inputs(); |
| 35 | for (QAbstractActionInput *input : inputs) |
| 36 | action->parentAction()->removeInput(input); |
| 37 | }; |
| 38 | |
| 39 | return QQmlListProperty<QAbstractActionInput>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
| 40 | } |
| 41 | |
| 42 | |
| 43 | } // namespace Quick |
| 44 | } // namespace Input |
| 45 | } // namespace Qt3DInput |
| 46 | |
| 47 | QT_END_NAMESPACE |
| 48 | |
| 49 | #include "moc_quick3daction_p.cpp" |
| 50 |
