1// Copyright (C) 2016 The Qt Company Ltd.
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 "quick3dmorphtarget_p.h"
5
6QT_BEGIN_NAMESPACE
7
8namespace Qt3DAnimation {
9namespace Quick {
10
11QQuick3DMorphTarget::QQuick3DMorphTarget(QObject *parent)
12 : QObject(parent)
13{
14}
15
16QQmlListProperty<Qt3DCore::QAttribute> QQuick3DMorphTarget::attributes()
17{
18 using qt_size_type = qsizetype;
19 using ListContentType = Qt3DCore::QAttribute;
20 auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *bar) {
21 QQuick3DMorphTarget *target = qobject_cast<QQuick3DMorphTarget *>(object: list->object);
22 if (target)
23 target->parentMorphTarget()->addAttribute(attribute: bar);
24 };
25 auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type {
26 QQuick3DMorphTarget *target = qobject_cast<QQuick3DMorphTarget *>(object: list->object);
27 if (target)
28 return target->parentMorphTarget()->attributeList().size();
29 return 0;
30 };
31 auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * {
32 QQuick3DMorphTarget *target = qobject_cast<QQuick3DMorphTarget *>(object: list->object);
33 if (target)
34 return qobject_cast<Qt3DCore::QAttribute *>(object: target->parentMorphTarget()->attributeList().at(i: index));
35 return nullptr;
36 };
37 auto clearFunction = [](QQmlListProperty<ListContentType> *list) {
38 QQuick3DMorphTarget *target = qobject_cast<QQuick3DMorphTarget *>(object: list->object);
39 if (target) {
40 QList<Qt3DCore::QAttribute *> emptyList;
41 target->parentMorphTarget()->setAttributes(emptyList);
42 }
43 };
44
45 return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
46}
47
48} // namespace Quick
49} // namespace Qt3DAnimation
50
51QT_END_NAMESPACE
52
53#include "moc_quick3dmorphtarget_p.cpp"
54

source code of qt3d/src/quick3d/quick3danimation/items/quick3dmorphtarget.cpp