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 "quick3danimationgroup_p.h"
5
6#include <Qt3DAnimation/qabstractanimation.h>
7
8QT_BEGIN_NAMESPACE
9
10namespace Qt3DAnimation {
11namespace Quick {
12
13QQuick3DAnimationGroup::QQuick3DAnimationGroup(QObject *parent)
14 : QObject(parent)
15{
16}
17
18QQmlListProperty<Qt3DAnimation::QAbstractAnimation> QQuick3DAnimationGroup::animations()
19{
20 using qt_size_type = qsizetype;
21 using ListContentType = Qt3DAnimation::QAbstractAnimation;
22 auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *animation) {
23 QQuick3DAnimationGroup *animationGroup = qobject_cast<QQuick3DAnimationGroup *>(object: list->object);
24 if (animationGroup)
25 animationGroup->parentAnimationGroup()->addAnimation(animation);
26 };
27 auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type {
28 QQuick3DAnimationGroup *animationGroup = qobject_cast<QQuick3DAnimationGroup *>(object: list->object);
29 if (animationGroup)
30 return animationGroup->parentAnimationGroup()->animationList().size();
31 return 0;
32 };
33 auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * {
34 QQuick3DAnimationGroup *animationGroup = qobject_cast<QQuick3DAnimationGroup *>(object: list->object);
35 if (animationGroup) {
36 return qobject_cast<Qt3DAnimation::QAbstractAnimation *>(
37 object: animationGroup->parentAnimationGroup()->animationList().at(i: index));
38 }
39 return nullptr;
40 };
41 auto clearFunction = [](QQmlListProperty<ListContentType> *list) {
42 QQuick3DAnimationGroup *animationGroup = qobject_cast<QQuick3DAnimationGroup *>(object: list->object);
43 if (animationGroup) {
44 QList<Qt3DAnimation::QAbstractAnimation *> emptyList;
45 animationGroup->parentAnimationGroup()->setAnimations(emptyList);
46 }
47 };
48
49 return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
50}
51
52
53} // namespace Quick
54} // namespace Qt3DAnimation
55
56QT_END_NAMESPACE
57
58#include "moc_quick3danimationgroup_p.cpp"
59

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