About
Contact
QtCreator
KDevelop
Solarized
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 "private/qanimationgroupjob_p.h"
5
6
QT_BEGIN_NAMESPACE
7
8
QAnimationGroupJob
::
QAnimationGroupJob
()
9
{
10
m_isGroup
=
true
;
11
}
12
13
void
QAnimationGroupJob
::
ungroupChild
(
QAbstractAnimationJob
*
animation
)
14
{
15
Q_ASSERT
(
animation
);
16
Q_ASSERT
(
animation
->
m_group
==
this
);
17
m_children
.
remove
(
n:
animation
);
18
animation
->
m_group
=
nullptr
;
19
}
20
21
void
QAnimationGroupJob
::
handleAnimationRemoved
(
QAbstractAnimationJob
*
animation
)
22
{
23
resetUncontrolledAnimationFinishTime
(
anim:
animation
);
24
if
(
m_children
.
isEmpty
()) {
25
m_currentTime
=
0
;
26
stop
();
27
}
28
}
29
30
QAnimationGroupJob
::
~QAnimationGroupJob
()
31
{
32
while
(
QAbstractAnimationJob
*
animation
=
m_children
.
first
()) {
33
ungroupChild
(
animation
);
34
handleAnimationRemoved
(
animation
);
35
delete
animation
;
36
}
37
}
38
39
void
QAnimationGroupJob
::
topLevelAnimationLoopChanged
()
40
{
41
for
(
QAbstractAnimationJob
*
animation
:
m_children
)
42
animation
->
fireTopLevelAnimationLoopChanged
();
43
}
44
45
void
QAnimationGroupJob
::
appendAnimation
(
QAbstractAnimationJob
*
animation
)
46
{
47
if
(
QAnimationGroupJob
*
oldGroup
=
animation
->
m_group
)
48
oldGroup
->
removeAnimation
(
animation
);
49
50
Q_ASSERT
(!
animation
->
isInList
());
51
52
m_children
.
append
(
n:
animation
);
53
animation
->
m_group
=
this
;
54
animationInserted
(
animation
);
55
}
56
57
void
QAnimationGroupJob
::
prependAnimation
(
QAbstractAnimationJob
*
animation
)
58
{
59
if
(
QAnimationGroupJob
*
oldGroup
=
animation
->
m_group
)
60
oldGroup
->
removeAnimation
(
animation
);
61
62
Q_ASSERT
(!
animation
->
isInList
());
63
64
m_children
.
prepend
(
n:
animation
);
65
animation
->
m_group
=
this
;
66
animationInserted
(
animation
);
67
}
68
69
void
QAnimationGroupJob
::
removeAnimation
(
QAbstractAnimationJob
*
animation
)
70
{
71
QAbstractAnimationJob
*
prev
=
m_children
.
prev
(
current:
animation
);
72
QAbstractAnimationJob
*
next
=
m_children
.
next
(
current:
animation
);
73
ungroupChild
(
animation
);
74
animationRemoved
(
animation
,
prev
,
next
);
75
}
76
77
void
QAnimationGroupJob
::
clear
()
78
{
79
while
(
QAbstractAnimationJob
*
child
=
m_children
.
first
()) {
80
removeAnimation
(
animation:
child
);
81
delete
child
;
82
}
83
84
Q_ASSERT
(
m_children
.
isEmpty
());
85
}
86
87
void
QAnimationGroupJob
::
resetUncontrolledAnimationsFinishTime
()
88
{
89
for
(
QAbstractAnimationJob
*
animation
:
m_children
) {
90
if
(
animation
->
duration
() == -
1
||
animation
->
loopCount
() <
0
) {
91
resetUncontrolledAnimationFinishTime
(
anim:
animation
);
92
}
93
}
94
}
95
96
void
QAnimationGroupJob
::
resetUncontrolledAnimationFinishTime
(
QAbstractAnimationJob
*
anim
)
97
{
98
setUncontrolledAnimationFinishTime
(
anim
,
time:
-
1
);
99
}
100
101
void
QAnimationGroupJob
::
setUncontrolledAnimationFinishTime
(
QAbstractAnimationJob
*
anim
,
int
time
)
102
{
103
anim
->
m_uncontrolledFinishTime
=
time
;
104
}
105
106
void
QAnimationGroupJob
::
uncontrolledAnimationFinished
(
QAbstractAnimationJob
*
animation
)
107
{
108
Q_UNUSED
(
animation
);
109
}
110
111
void
QAnimationGroupJob
::
animationRemoved
(
QAbstractAnimationJob
*
anim
,
QAbstractAnimationJob
* ,
QAbstractAnimationJob
* )
112
{
113
handleAnimationRemoved
(
animation:
anim
);
114
}
115
116
void
QAnimationGroupJob
::
debugChildren
(
QDebug
d
)
const
117
{
118
int
indentLevel
=
1
;
119
const
QAnimationGroupJob
*
group
=
this
;
120
while
((
group
=
group
->
m_group
))
121
++
indentLevel
;
122
123
QByteArray
ind
(
indentLevel
,
' '
);
124
for
(
const
QAbstractAnimationJob
*
child
:
m_children
)
125
d
<<
"\n"
<<
ind
.
constData
()
<<
child
;
126
}
127
128
QT_END_NAMESPACE
129