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
5927cd3b
Commit
5927cd3b
authored
Oct 12, 2020
by
Sashmita Raghav
Browse files
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
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