| 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/quick3daxis_p.h> |
| 5 | |
| 6 | QT_BEGIN_NAMESPACE |
| 7 | |
| 8 | namespace Qt3DInput { |
| 9 | namespace Input { |
| 10 | namespace Quick { |
| 11 | |
| 12 | Quick3DAxis::Quick3DAxis(QObject *parent) |
| 13 | : QObject(parent) |
| 14 | { |
| 15 | } |
| 16 | |
| 17 | QQmlListProperty<QAbstractAxisInput> Quick3DAxis::qmlAxisInputs() |
| 18 | { |
| 19 | using qt_size_type = qsizetype; |
| 20 | using ListContentType = QAbstractAxisInput; |
| 21 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *input) { |
| 22 | Quick3DAxis *axis = qobject_cast<Quick3DAxis *>(object: list->object); |
| 23 | axis->parentAxis()->addInput(input); |
| 24 | }; |
| 25 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
| 26 | Quick3DAxis *axis = qobject_cast<Quick3DAxis *>(object: list->object); |
| 27 | return axis->parentAxis()->inputs().size(); |
| 28 | }; |
| 29 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
| 30 | Quick3DAxis *axis = qobject_cast<Quick3DAxis *>(object: list->object); |
| 31 | return axis->parentAxis()->inputs().at(i: index); |
| 32 | }; |
| 33 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
| 34 | Quick3DAxis *axis = qobject_cast<Quick3DAxis *>(object: list->object); |
| 35 | const auto inputs = axis->parentAxis()->inputs(); |
| 36 | for (QAbstractAxisInput *input : inputs) |
| 37 | axis->parentAxis()->removeInput(input); |
| 38 | }; |
| 39 | |
| 40 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
| 41 | } |
| 42 | |
| 43 | |
| 44 | } // namespace Quick |
| 45 | } // namespace Input |
| 46 | } // namespace Qt3DInput |
| 47 | |
| 48 | QT_END_NAMESPACE |
| 49 | |
| 50 | #include "moc_quick3daxis_p.cpp" |
| 51 |
