Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
0d7dd3b6
Commit
0d7dd3b6
authored
Sep 28, 2021
by
Jean-Baptiste Mardelle
Browse files
Fix spacer track sometimes not allowing to reduce space
parent
e0edf3e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/timeline2/model/timelinefunctions.cpp
View file @
0d7dd3b6
...
...
@@ -341,6 +341,7 @@ int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<Timelin
std
::
unordered_set
<
int
>
groupsToRemove
;
int
firstCid
=
-
1
;
int
firstPosition
=
-
1
;
QMap
<
int
,
int
>
firstPositions
;
for
(
int
r
:
roots
)
{
if
(
timeline
->
isGroup
(
r
))
{
std
::
unordered_set
<
int
>
leaves
=
timeline
->
m_groups
->
getLeaves
(
r
);
...
...
@@ -352,6 +353,15 @@ int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<Timelin
leavesToRemove
.
insert
(
l
);
}
else
{
leavesToKeep
.
insert
(
l
);
int
tid
=
timeline
->
getItemTrackId
(
l
);
// Check space in all tracks
if
(
!
firstPositions
.
contains
(
tid
))
{
firstPositions
.
insert
(
tid
,
pos
);
}
else
{
if
(
pos
<
firstPositions
.
value
(
tid
))
{
firstPositions
.
insert
(
tid
,
pos
);
}
}
// Find first item
if
(
firstPosition
==
-
1
||
pos
<
firstPosition
)
{
firstCid
=
l
;
...
...
@@ -374,6 +384,15 @@ int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<Timelin
}
}
else
{
int
pos
=
timeline
->
getItemPosition
(
r
);
int
tid
=
timeline
->
getItemTrackId
(
r
);
// Check space in all tracks
if
(
!
firstPositions
.
contains
(
tid
))
{
firstPositions
.
insert
(
tid
,
pos
);
}
else
{
if
(
pos
<
firstPositions
.
value
(
tid
))
{
firstPositions
.
insert
(
tid
,
pos
);
}
}
if
(
firstPosition
==
-
1
||
pos
<
firstPosition
)
{
firstCid
=
r
;
firstPosition
=
pos
;
...
...
@@ -391,7 +410,7 @@ int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<Timelin
timeline
->
m_groups
->
ungroupItem
(
i
.
key
(),
undo
,
redo
);
}
timeline
->
requestSetSelection
(
roots
);
if
(
firstPosition
>
0
)
{
if
(
!
firstPosition
s
.
isEmpty
()
)
{
// Find minimum position, parse all tracks
if
(
trackId
>
-
1
)
{
// Easy, check blank size
...
...
@@ -404,7 +423,12 @@ int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<Timelin
auto
it
=
timeline
->
m_allTracks
.
cbegin
();
int
space
=
-
1
;
while
(
it
!=
timeline
->
m_allTracks
.
cend
())
{
int
spaceDuration
=
timeline
->
getTrackById_const
((
*
it
)
->
getId
())
->
getBlankSizeAtPos
(
firstPosition
-
1
);
int
tid
=
(
*
it
)
->
getId
();
if
(
!
firstPositions
.
contains
(
tid
))
{
++
it
;
continue
;
}
int
spaceDuration
=
(
*
it
)
->
getBlankSizeAtPos
(
firstPositions
.
value
(
tid
)
-
1
);
if
(
space
==
-
1
||
spaceDuration
<
space
)
{
space
=
spaceDuration
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment