Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Kdenlive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
259
Issues
259
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Multimedia
Kdenlive
Commits
e8c67715
Commit
e8c67715
authored
Jun 30, 2020
by
Sashmita Raghav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add functions to add the start time of each subtitle line as snaps
parent
7fe395a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
2 deletions
+43
-2
src/bin/model/subtitlemodel.cpp
src/bin/model/subtitlemodel.cpp
+32
-0
src/bin/model/subtitlemodel.hpp
src/bin/model/subtitlemodel.hpp
+11
-2
No files found.
src/bin/model/subtitlemodel.cpp
View file @
e8c67715
...
...
@@ -6,6 +6,7 @@
SubtitleModel
::
SubtitleModel
(
std
::
weak_ptr
<
DocUndoStack
>
undo_stack
,
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
,
m_undoStack
(
std
::
move
(
undo_stack
))
,
m_lock
(
QReadWriteLock
::
Recursive
)
{
}
...
...
@@ -190,6 +191,7 @@ void SubtitleModel::addSubtitle(GenTime start, GenTime end, QString str)
model
->
beginInsertRows
(
QModelIndex
(),
insertRow
,
insertRow
);
model
->
m_subtitleList
[
start
]
=
{
str
,
end
};
model
->
endInsertRows
();
model
->
addSnapPoint
(
start
);
}
QHash
<
int
,
QByteArray
>
SubtitleModel
::
roleNames
()
const
...
...
@@ -243,4 +245,34 @@ QList<SubtitledTime> SubtitleModel::getAllSubtitles() const
subtitle
<<
s
;
}
return
subtitle
;
}
void
SubtitleModel
::
registerSnap
(
const
std
::
weak_ptr
<
SnapInterface
>
&
snapModel
)
{
// make sure ptr is valid
if
(
auto
ptr
=
snapModel
.
lock
())
{
// ptr is valid, we store it
m_regSnaps
.
push_back
(
snapModel
);
for
(
const
auto
&
subtitle
:
m_subtitleList
)
{
qDebug
()
<<
" REGISTERING SUBTITLE: "
<<
subtitle
.
first
.
frames
(
pCore
->
getCurrentFps
());
ptr
->
addPoint
(
subtitle
.
first
.
frames
(
pCore
->
getCurrentFps
()));
}
}
else
{
qDebug
()
<<
"Error: added snapmodel for subtitle is null"
;
Q_ASSERT
(
false
);
}
}
void
SubtitleModel
::
addSnapPoint
(
GenTime
startpos
)
{
std
::
vector
<
std
::
weak_ptr
<
SnapInterface
>>
validSnapModels
;
for
(
const
auto
&
snapModel
:
m_regSnaps
)
{
if
(
auto
ptr
=
snapModel
.
lock
())
{
validSnapModels
.
push_back
(
snapModel
);
ptr
->
addPoint
(
startpos
.
frames
(
pCore
->
getCurrentFps
()));
}
}
// Update the list of snapModel known to be valid
std
::
swap
(
m_regSnaps
,
validSnapModels
);
}
\ No newline at end of file
src/bin/model/subtitlemodel.hpp
View file @
e8c67715
...
...
@@ -15,6 +15,7 @@
#include <mlt++/MltProperties.h>
class
DocUndoStack
;
class
SnapInterface
;
class
AssetParameterModel
;
/* @brief This class is the model for a list of subtitles.
...
...
@@ -39,18 +40,26 @@ public:
/** @brief Returns all subtitles in the model */
QList
<
SubtitledTime
>
getAllSubtitles
()
const
;
/** @brief Registers a snap model to the subtitle model */
void
registerSnap
(
const
std
::
weak_ptr
<
SnapInterface
>
&
snapModel
);
private:
std
::
weak_ptr
<
DocUndoStack
>
m_undoStack
;
std
::
map
<
GenTime
,
std
::
pair
<
QString
,
GenTime
>>
m_subtitleList
;
//To get subtitle file from effects parameter:
//std::unique_ptr<Mlt::Properties> m_asset;
//std::shared_ptr<AssetParameterModel> m_model;
std
::
vector
<
std
::
weak_ptr
<
SnapInterface
>>
m_regSnaps
;
mutable
QReadWriteLock
m_lock
;
protected:
/** @brief Helper function that retrieves a pointer to the subtitle model*/
static
std
::
shared_ptr
<
SubtitleModel
>
getModel
();
/** @brief Add start time as snap in the registered snap model */
void
addSnapPoint
(
GenTime
startpos
);
};
Q_DECLARE_METATYPE
(
SubtitleModel
*
)
#endif // SUBTITLEMODEL_HPP
\ 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