1 | // Copyright (C) 2014 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 <Qt3DQuickRender/private/quick3dtechniquefilter_p.h> |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | namespace Qt3DRender { |
9 | namespace Render { |
10 | namespace Quick { |
11 | |
12 | Quick3DTechniqueFilter::Quick3DTechniqueFilter(QObject *parent) |
13 | : QObject(parent) |
14 | { |
15 | } |
16 | |
17 | QQmlListProperty<QFilterKey> Quick3DTechniqueFilter::matchList() |
18 | { |
19 | using qt_size_type = qsizetype; |
20 | using ListContentType = QFilterKey; |
21 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *criterion) { |
22 | Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object); |
23 | if (filter) { |
24 | criterion->setParent(filter->parentTechniqueFilter()); |
25 | filter->parentTechniqueFilter()->addMatch(filterKey: criterion); |
26 | } |
27 | }; |
28 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
29 | Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object); |
30 | if (filter) |
31 | return filter->parentTechniqueFilter()->matchAll().size(); |
32 | return 0; |
33 | }; |
34 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
35 | Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object); |
36 | if (filter) |
37 | return filter->parentTechniqueFilter()->matchAll().at(i: index); |
38 | return nullptr; |
39 | }; |
40 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
41 | Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object); |
42 | if (filter) { |
43 | const auto criteria = filter->parentTechniqueFilter()->matchAll(); |
44 | for (QFilterKey *criterion : criteria) |
45 | filter->parentTechniqueFilter()->removeMatch(filterKey: criterion); |
46 | } |
47 | }; |
48 | |
49 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
50 | } |
51 | |
52 | QQmlListProperty<QParameter> Quick3DTechniqueFilter::parameterList() |
53 | { |
54 | using qt_size_type = qsizetype; |
55 | using ListContentType = QParameter; |
56 | auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *param) { |
57 | Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object); |
58 | techniqueFilter->parentTechniqueFilter()->addParameter(p: param); |
59 | }; |
60 | auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type { |
61 | Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object); |
62 | return techniqueFilter->parentTechniqueFilter()->parameters().size(); |
63 | }; |
64 | auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * { |
65 | Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object); |
66 | return techniqueFilter->parentTechniqueFilter()->parameters().at(i: index); |
67 | }; |
68 | auto clearFunction = [](QQmlListProperty<ListContentType> *list) { |
69 | Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object); |
70 | const auto parameters = techniqueFilter->parentTechniqueFilter()->parameters(); |
71 | for (QParameter *p : parameters) |
72 | techniqueFilter->parentTechniqueFilter()->removeParameter(p); |
73 | }; |
74 | |
75 | return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction); |
76 | } |
77 | |
78 | } // namespace Quick |
79 | } // namespace Render |
80 | } // namespace Qt3DRender |
81 | |
82 | QT_END_NAMESPACE |
83 | |
84 | #include "moc_quick3dtechniquefilter_p.cpp" |
85 | |