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 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | namespace Qt3DAnimation { |
11 | |
12 | class QAnimationClipDataPrivate |
13 | { |
14 | public: |
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 | */ |
24 | QAnimationClipData::QAnimationClipData() |
25 | : d(new QAnimationClipDataPrivate) |
26 | { |
27 | } |
28 | |
29 | QAnimationClipData::QAnimationClipData(const QAnimationClipData &rhs) |
30 | : d(new QAnimationClipDataPrivate) |
31 | { |
32 | *d = *(rhs.d); |
33 | } |
34 | |
35 | QAnimationClipData &QAnimationClipData::operator=(const QAnimationClipData &rhs) |
36 | { |
37 | if (this != &rhs) |
38 | *d = *(rhs.d); |
39 | return *this; |
40 | } |
41 | |
42 | QAnimationClipData::~QAnimationClipData() |
43 | { |
44 | } |
45 | |
46 | void QAnimationClipData::setName(const QString &name) |
47 | { |
48 | d->m_name = name; |
49 | } |
50 | |
51 | QString QAnimationClipData::name() const |
52 | { |
53 | return d->m_name; |
54 | } |
55 | |
56 | int QAnimationClipData::channelCount() const |
57 | { |
58 | return d->m_channels.size(); |
59 | } |
60 | |
61 | void QAnimationClipData::appendChannel(const QChannel &c) |
62 | { |
63 | d->m_channels.append(t: c); |
64 | } |
65 | |
66 | void QAnimationClipData::insertChannel(int index, const QChannel &c) |
67 | { |
68 | d->m_channels.insert(i: index, t: c); |
69 | } |
70 | |
71 | void QAnimationClipData::removeChannel(int index) |
72 | { |
73 | d->m_channels.remove(i: index); |
74 | } |
75 | |
76 | void QAnimationClipData::clearChannels() |
77 | { |
78 | d->m_channels.clear(); |
79 | } |
80 | |
81 | bool QAnimationClipData::isValid() const noexcept |
82 | { |
83 | // TODO: Perform more thorough checks |
84 | return !d->m_channels.isEmpty(); |
85 | } |
86 | |
87 | QAnimationClipData::const_iterator QAnimationClipData::begin() const noexcept |
88 | { |
89 | return d->m_channels.cbegin().operator->(); |
90 | } |
91 | |
92 | QAnimationClipData::const_iterator QAnimationClipData::end() const noexcept |
93 | { |
94 | return d->m_channels.cend().operator->(); |
95 | } |
96 | |
97 | |
98 | bool 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 | |
104 | bool 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 | |
112 | QT_END_NAMESPACE |
113 |