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
2e78912e
Commit
2e78912e
authored
Feb 23, 2022
by
Jean-Baptiste Mardelle
Browse files
Various fixes for remove space in subtitle track
parent
66cf639f
Pipeline
#141448
passed with stage
in 7 minutes
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/model/subtitlemodel.cpp
View file @
2e78912e
...
...
@@ -486,7 +486,7 @@ std::unordered_set<int> SubtitleModel::getItemsInRange(int startFrame, int endFr
// Outside range
continue
;
}
if
(
subtitles
.
first
>=
startTime
||
subtitles
.
second
.
second
>
=
startTime
)
{
if
(
subtitles
.
first
>=
startTime
||
subtitles
.
second
.
second
>
startTime
)
{
int
sid
=
getIdForStartPos
(
subtitles
.
first
);
if
(
sid
>
-
1
)
{
matching
.
emplace
(
sid
);
...
...
@@ -1204,33 +1204,27 @@ QDomElement SubtitleModel::toXml(int sid, QDomDocument &document)
return
container
;
}
int
SubtitleModel
::
getBlankSizeAtPos
(
int
pos
)
const
bool
SubtitleModel
::
isBlankAt
(
int
pos
)
const
{
GenTime
matchPos
(
pos
,
pCore
->
getCurrentFps
());
std
::
unordered_set
<
int
>
matching
;
GenTime
min
;
GenTime
max
;
for
(
const
auto
&
subtitles
:
m_subtitleList
)
{
if
(
subtitles
.
first
>
matchPos
&&
(
max
==
GenTime
()
||
subtitles
.
first
<
max
))
{
// Outside range
max
=
subtitles
.
first
;
if
(
subtitles
.
first
>
matchPos
)
{
continue
;
}
if
(
subtitles
.
second
.
second
<
matchPos
&&
(
min
==
GenTime
()
||
subtitles
.
second
.
second
>
min
)
)
{
min
=
subtitles
.
second
.
second
;
if
(
subtitles
.
second
.
second
>
matchPos
)
{
return
false
;
}
}
return
max
.
frames
(
pCore
->
getCurrentFps
())
-
min
.
frames
(
pCore
->
getCurrentFps
())
;
return
true
;
;
}
int
SubtitleModel
::
getBlankStart
(
int
pos
)
const
{
GenTime
matchPos
(
pos
,
pCore
->
getCurrentFps
());
std
::
unordered_set
<
int
>
matching
;
bool
found
=
false
;
GenTime
min
;
for
(
const
auto
&
subtitles
:
m_subtitleList
)
{
if
(
subtitles
.
second
.
second
<
matchPos
&&
(
min
==
GenTime
()
||
subtitles
.
second
.
second
>
min
))
{
if
(
subtitles
.
second
.
second
<
=
matchPos
&&
(
min
==
GenTime
()
||
subtitles
.
second
.
second
>
min
))
{
min
=
subtitles
.
second
.
second
;
found
=
true
;
}
...
...
src/bin/model/subtitlemodel.hpp
View file @
2e78912e
...
...
@@ -127,10 +127,10 @@ public:
void
allSnaps
(
std
::
vector
<
int
>
&
snaps
);
/** @brief Returns an xml representation of the subtitle with id \@sid */
QDomElement
toXml
(
int
sid
,
QDomDocument
&
document
);
/** @brief Returns the size of the space between subtitles */
int
getBlankSizeAtPos
(
int
pos
)
const
;
/** @brief Returns the position of the first blank frame before a position */
int
getBlankStart
(
int
pos
)
const
;
/** @brief Returns true is track is empty at pos */
bool
isBlankAt
(
int
pos
)
const
;
/** @brief Switch a subtitle's grab state */
void
switchGrab
(
int
sid
);
/** @brief Ungrab all items */
...
...
@@ -152,6 +152,7 @@ public slots:
private:
std
::
shared_ptr
<
TimelineItemModel
>
m_timeline
;
std
::
weak_ptr
<
DocUndoStack
>
m_undoStack
;
/** @brief A list of subtitles as: start time, text, end time */
std
::
map
<
GenTime
,
std
::
pair
<
QString
,
GenTime
>>
m_subtitleList
;
QString
scriptInfoSection
,
styleSection
,
eventSection
;
...
...
src/timeline2/model/timelinefunctions.cpp
View file @
2e78912e
...
...
@@ -2080,6 +2080,9 @@ bool TimelineFunctions::requestDeleteBlankAt(const std::shared_ptr<TimelineItemM
}
else
{
if
(
trackId
==
-
2
)
{
// Subtitle track
if
(
!
timeline
->
getSubtitleModel
()
->
isBlankAt
(
position
))
{
return
false
;
}
spaceStart
=
timeline
->
getSubtitleModel
()
->
getBlankStart
(
position
);
}
else
{
if
(
!
timeline
->
getTrackById_const
(
trackId
)
->
isBlankAt
(
position
))
{
...
...
Write
Preview
Markdown
is supported
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