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 <Qt3DQuickRender/private/quick3dstateset_p.h>
5
6QT_BEGIN_NAMESPACE
7
8namespace Qt3DRender {
9namespace Render {
10namespace Quick {
11
12Quick3DStateSet::Quick3DStateSet(QObject *parent)
13 : QObject(parent)
14{
15}
16
17Quick3DStateSet::~Quick3DStateSet()
18{
19}
20
21QQmlListProperty<QRenderState> Quick3DStateSet::renderStateList()
22{
23 using qt_size_type = qsizetype;
24 using ListContentType = QRenderState;
25 auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *state) {
26 Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(object: list->object);
27 stateSet->parentStateSet()->addRenderState(state);
28 };
29 auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type {
30 Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(object: list->object);
31 return stateSet->parentStateSet()->renderStates().size();
32 };
33 auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * {
34 Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(object: list->object);
35 return stateSet->parentStateSet()->renderStates().at(i: index);
36 };
37 auto clearFunction = [](QQmlListProperty<ListContentType> *list) {
38 Quick3DStateSet *stateSet = qobject_cast<Quick3DStateSet *>(object: list->object);
39 const auto states = stateSet->parentStateSet()->renderStates();
40 for (QRenderState *s : states)
41 stateSet->parentStateSet()->removeRenderState(state: s);
42 };
43
44 return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
45}
46
47} // namespace Quick
48} // namespace Render
49} // namespace Qt3DRender
50
51QT_END_NAMESPACE
52
53#include "moc_quick3dstateset_p.cpp"
54
55

source code of qt3d/src/quick3d/quick3drender/items/quick3dstateset.cpp