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/quick3dlogicaldevice_p.h> |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | namespace Qt3DInput { |
9 | namespace Input { |
10 | namespace Quick { |
11 | |
12 | Quick3DLogicalDevice::Quick3DLogicalDevice(QObject *parent) |
13 | : QObject(parent) |
14 | { |
15 | } |
16 | |
17 | QQmlListProperty<QAxis> Quick3DLogicalDevice::qmlAxes() |
18 | { |
19 | using qt_size_type = qsizetype; |
20 | using ListContentType = QAxis; |
21 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *axes) { |
22 | Quick3DLogicalDevice *device = qobject_cast<Quick3DLogicalDevice *>(object: list->object); |
23 | device->parentLogicalDevice()->addAxis(axis: axes); |
24 | }; |
25 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
26 | Quick3DLogicalDevice *device = qobject_cast<Quick3DLogicalDevice *>(object: list->object); |
27 | return device->parentLogicalDevice()->axes().size(); |
28 | }; |
29 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
30 | Quick3DLogicalDevice *device = qobject_cast<Quick3DLogicalDevice *>(object: list->object); |
31 | return device->parentLogicalDevice()->axes().at(i: index); |
32 | }; |
33 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
34 | Quick3DLogicalDevice *device = qobject_cast<Quick3DLogicalDevice *>(object: list->object); |
35 | const auto axes = device->parentLogicalDevice()->axes(); |
36 | for (QAxis *axis : axes) |
37 | device->parentLogicalDevice()->removeAxis(axis); |
38 | }; |
39 | |
40 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
41 | } |
42 | |
43 | QQmlListProperty<QAction> Quick3DLogicalDevice::qmlActions() |
44 | { |
45 | using qt_size_type = qsizetype; |
46 | using ListContentType = QAction; |
47 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *action) { |
48 | Quick3DLogicalDevice *device = qobject_cast<Quick3DLogicalDevice *>(object: list->object); |
49 | device->parentLogicalDevice()->addAction(action); |
50 | }; |
51 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
52 | Quick3DLogicalDevice *device = qobject_cast<Quick3DLogicalDevice *>(object: list->object); |
53 | return device->parentLogicalDevice()->actions().size(); |
54 | }; |
55 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
56 | Quick3DLogicalDevice *device = qobject_cast<Quick3DLogicalDevice *>(object: list->object); |
57 | return device->parentLogicalDevice()->actions().at(i: index); |
58 | }; |
59 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
60 | Quick3DLogicalDevice *device = qobject_cast<Quick3DLogicalDevice *>(object: list->object); |
61 | const auto actions = device->parentLogicalDevice()->actions(); |
62 | for (QAction *action : actions) |
63 | device->parentLogicalDevice()->removeAction(action); |
64 | }; |
65 | |
66 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
67 | } |
68 | |
69 | |
70 | } // namespace Quick |
71 | } // namespace Input |
72 | } // namespace Qt3DInput |
73 | |
74 | QT_END_NAMESPACE |
75 | |
76 | #include "moc_quick3dlogicaldevice_p.cpp" |
77 | |