1 | // Copyright (C) 2016 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 <Qt3DRender/qtexture.h> |
5 | |
6 | #include <Qt3DQuickRender/private/quick3dlayerfilter_p.h> |
7 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | namespace Qt3DRender { |
11 | |
12 | namespace Render { |
13 | |
14 | namespace Quick { |
15 | |
16 | Quick3DLayerFilter::Quick3DLayerFilter(QObject *parent) |
17 | : QObject(parent) |
18 | { |
19 | } |
20 | |
21 | QQmlListProperty<QLayer> Quick3DLayerFilter::qmlLayers() |
22 | { |
23 | using qt_size_type = qsizetype; |
24 | using ListContentType = QLayer; |
25 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *layer) { |
26 | Quick3DLayerFilter *filter = qobject_cast<Quick3DLayerFilter *>(object: list->object); |
27 | if (filter) { |
28 | filter->parentFilter()->addLayer(layer); |
29 | } |
30 | }; |
31 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
32 | Quick3DLayerFilter *filter = qobject_cast<Quick3DLayerFilter *>(object: list->object); |
33 | if (filter) |
34 | return filter->parentFilter()->layers().size(); |
35 | return 0; |
36 | }; |
37 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
38 | Quick3DLayerFilter *filter = qobject_cast<Quick3DLayerFilter *>(object: list->object); |
39 | if (filter) |
40 | return filter->parentFilter()->layers().at(i: index); |
41 | return nullptr; |
42 | }; |
43 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
44 | Quick3DLayerFilter *filter = qobject_cast<Quick3DLayerFilter *>(object: list->object); |
45 | if (filter) { |
46 | const auto layers = filter->parentFilter()->layers(); |
47 | for (QLayer *layer : layers) |
48 | filter->parentFilter()->removeLayer(layer); |
49 | } |
50 | }; |
51 | |
52 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
53 | } |
54 | |
55 | } // Quick |
56 | |
57 | } // namespace Render |
58 | |
59 | } // Qt3D |
60 | |
61 | QT_END_NAMESPACE |
62 | |
63 | #include "moc_quick3dlayerfilter_p.cpp" |
64 |