summaryrefslogtreecommitdiffstats
path: root/src/quick3d/quick3dinput/items/quick3daction.cpp
blob: bb6e89e69f43292c5293f46bf3d61d38806694f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include <Qt3DQuickInput/private/quick3daction_p.h>

QT_BEGIN_NAMESPACE

namespace Qt3DInput {
namespace Input {
namespace Quick {

Quick3DAction::Quick3DAction(QObject *parent)
    : QObject(parent)
{
}

QQmlListProperty<QAbstractActionInput> Quick3DAction::qmlActionInputs()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    using qt_size_type = qsizetype;
#else
    using qt_size_type = int;
#endif

    auto appendFunction = [](QQmlListProperty<QAbstractActionInput> *list, QAbstractActionInput *input) {
        Quick3DAction *action = qobject_cast<Quick3DAction *>(list->object);
        action->parentAction()->addInput(input);
    };
    auto countFunction = [](QQmlListProperty<QAbstractActionInput> *list) -> qt_size_type {
        Quick3DAction *action = qobject_cast<Quick3DAction *>(list->object);
        return action->parentAction()->inputs().size();
    };
    auto atFunction = [](QQmlListProperty<QAbstractActionInput> *list, qt_size_type index) -> QAbstractActionInput * {
        Quick3DAction *action = qobject_cast<Quick3DAction *>(list->object);
        return action->parentAction()->inputs().at(index);
    };
    auto clearFunction = [](QQmlListProperty<QAbstractActionInput> *list) {
        Quick3DAction *action = qobject_cast<Quick3DAction *>(list->object);
        const auto inputs = action->parentAction()->inputs();
        for (QAbstractActionInput *input : inputs)
            action->parentAction()->removeInput(input);
    };

    return QQmlListProperty<QAbstractActionInput>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
}


} // namespace Quick
} // namespace Input
} // namespace Qt3DInput

QT_END_NAMESPACE

#include "moc_quick3daction_p.cpp"