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 "qanimationclipdata.h"
5
6#include <QtCore/qlist.h>
7
8QT_BEGIN_NAMESPACE
9
10namespace Qt3DAnimation {
11
12class QAnimationClipDataPrivate
13{
14public:
15 QVector<QChannel> m_channels;
16 QString m_name;
17};
18
19/*!
20 \class Qt3DAnimation::QAnimationClipData
21 \inmodule Qt3DAnimation
22 \brief Class containing the animation data.
23*/
24QAnimationClipData::QAnimationClipData()
25 : d(new QAnimationClipDataPrivate)
26{
27}
28
29QAnimationClipData::QAnimationClipData(const QAnimationClipData &rhs)
30 : d(new QAnimationClipDataPrivate)
31{
32 *d = *(rhs.d);
33}
34
35QAnimationClipData &QAnimationClipData::operator=(const QAnimationClipData &rhs)
36{
37 if (this != &rhs)
38 *d = *(rhs.d);
39 return *this;
40}
41
42QAnimationClipData::~QAnimationClipData()
43{
44}
45
46void QAnimationClipData::setName(const QString &name)
47{
48 d->m_name = name;
49}
50
51QString QAnimationClipData::name() const
52{
53 return d->m_name;
54}
55
56int QAnimationClipData::channelCount() const
57{
58 return d->m_channels.size();
59}
60
61void QAnimationClipData::appendChannel(const QChannel &c)
62{
63 d->m_channels.append(t: c);
64}
65
66void QAnimationClipData::insertChannel(int index, const QChannel &c)
67{
68 d->m_channels.insert(i: index, t: c);
69}
70
71void QAnimationClipData::removeChannel(int index)
72{
73 d->m_channels.remove(i: index);
74}
75
76void QAnimationClipData::clearChannels()
77{
78 d->m_channels.clear();
79}
80
81bool QAnimationClipData::isValid() const noexcept
82{
83 // TODO: Perform more thorough checks
84 return !d->m_channels.isEmpty();
85}
86
87QAnimationClipData::const_iterator QAnimationClipData::begin() const noexcept
88{
89 return d->m_channels.cbegin().operator->();
90}
91
92QAnimationClipData::const_iterator QAnimationClipData::end() const noexcept
93{
94 return d->m_channels.cend().operator->();
95}
96
97
98bool operator==(const QAnimationClipData &lhs, const QAnimationClipData &rhs) noexcept
99{
100 return lhs.d->m_name == rhs.d->m_name &&
101 lhs.d->m_channels == rhs.d->m_channels;
102}
103
104bool operator!=(const QAnimationClipData &lhs, const QAnimationClipData &rhs) noexcept
105{
106 return lhs.d->m_name != rhs.d->m_name ||
107 lhs.d->m_channels != rhs.d->m_channels;
108}
109
110} // namespace Qt3DAnimation
111
112QT_END_NAMESPACE
113

source code of qt3d/src/animation/frontend/qanimationclipdata.cpp