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
5927cd3b
Commit
5927cd3b
authored
Oct 12, 2020
by
Sashmita Raghav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add function to export subtitle model items to JSON
parent
73716f89
Pipeline
#37457
canceled with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
src/bin/model/subtitlemodel.cpp
src/bin/model/subtitlemodel.cpp
+21
-0
src/bin/model/subtitlemodel.hpp
src/bin/model/subtitlemodel.hpp
+3
-0
No files found.
src/bin/model/subtitlemodel.cpp
View file @
5927cd3b
...
...
@@ -4,6 +4,10 @@
#include "project/projectmanager.h"
#include "timeline2/model/snapmodel.hpp"
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
SubtitleModel
::
SubtitleModel
(
std
::
weak_ptr
<
DocUndoStack
>
undo_stack
,
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
,
m_undoStack
(
std
::
move
(
undo_stack
))
...
...
@@ -355,3 +359,20 @@ void SubtitleModel::moveSubtitle(GenTime oldPos, GenTime newPos)
addSubtitle
(
newPos
,
endPos
,
subtitleText
);
return
;
}
QString
SubtitleModel
::
toJson
()
{
qDebug
()
<<
"to JSON"
;
QJsonArray
list
;
for
(
const
auto
&
subtitle
:
m_subtitleList
)
{
QJsonObject
currentSubtitle
;
currentSubtitle
.
insert
(
QLatin1String
(
"startPos"
),
QJsonValue
(
subtitle
.
first
.
seconds
()));
currentSubtitle
.
insert
(
QLatin1String
(
"dialogue"
),
QJsonValue
(
subtitle
.
second
.
first
));
currentSubtitle
.
insert
(
QLatin1String
(
"endPos"
),
QJsonValue
(
subtitle
.
second
.
second
.
seconds
()));
list
.
push_back
(
currentSubtitle
);
qDebug
()
<<
subtitle
.
first
.
seconds
();
}
QJsonDocument
jsonDoc
(
list
);
qDebug
()
<<
QString
(
jsonDoc
.
toJson
());
return
QString
(
jsonDoc
.
toJson
());
}
\ No newline at end of file
src/bin/model/subtitlemodel.hpp
View file @
5927cd3b
...
...
@@ -68,6 +68,9 @@ public:
*/
void
moveSubtitle
(
GenTime
oldPos
,
GenTime
newPos
);
/** @brief Exports the subtitle model to json */
QString
toJson
();
public
slots
:
/** @brief Function that parses through a subtitle file */
void
parseSubtitle
();
...
...
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