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
92dc2891
Commit
92dc2891
authored
Jun 15, 2020
by
Sashmita Raghav
Browse files
Add function to append subtitles to list
parent
a9a62259
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/bin/model/subtitlemodel.cpp
View file @
92dc2891
...
...
@@ -174,4 +174,20 @@ GenTime SubtitleModel::stringtoTime(QString str)
total_sec
=
hours
*
3600
+
mins
*
60
+
seconds
+
ms
*
0.001
;
GenTime
pos
=
GenTime
(
total_sec
);
return
pos
;
}
void
SubtitleModel
::
addSubtitle
(
GenTime
start
,
GenTime
end
,
QString
str
)
{
auto
model
=
getModel
();
//gets model shared ptr
Q_ASSERT
(
model
->
m_subtitleList
.
count
(
start
)
==
0
);
//returns warning if sub at start time position already exists ,i.e. count !=0
auto
it
=
model
->
m_subtitleList
.
lower_bound
(
start
);
// returns the key and its value *just* greater than start.
Q_ASSERT
(
it
->
first
<
model
->
m_subtitleList
.
end
()
->
second
.
second
);
// returns warning if added subtitle start time is less than last subtitle's end time
int
insertRow
=
static_cast
<
int
>
(
model
->
m_subtitleList
.
size
());
//converts the returned unsigned size() to signed int
/* For adding it in the middle of the list */
if
(
it
!=
model
->
m_subtitleList
.
end
())
{
// check if the subtitle greater than added subtitle is not the same as the last one
insertRow
=
static_cast
<
int
>
(
std
::
distance
(
model
->
m_subtitleList
.
begin
(),
it
));
}
model
->
beginInsertRows
(
QModelIndex
(),
insertRow
,
insertRow
);
model
->
m_subtitleList
[
start
]
=
{
str
,
end
};
model
->
endInsertRows
();
}
\ No newline at end of file
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