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