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
a9a62259
Commit
a9a62259
authored
Jun 15, 2020
by
Sashmita Raghav
Browse files
Add functions to return pointer to model
parent
e6843558
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/bin/CMakeLists.txt
View file @
a9a62259
...
...
@@ -8,6 +8,7 @@ set(kdenlive_SRCS
bin/filewatcher.cpp
bin/generators/generators.cpp
bin/model/markerlistmodel.cpp
bin/model/subtitlemodel.cpp
bin/projectclip.cpp
bin/projectfolder.cpp
bin/projectitemmodel.cpp
...
...
src/bin/model/subtitlemodel.cpp
View file @
a9a62259
...
...
@@ -5,6 +5,7 @@
SubtitleModel
::
SubtitleModel
(
std
::
weak_ptr
<
DocUndoStack
>
undo_stack
,
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
,
m_undoStack
(
std
::
move
(
undo_stack
))
{
}
...
...
@@ -56,7 +57,7 @@ void SubtitleModel::parseSubtitle()
start
=
srtTime
[
0
];
startPos
=
stringtoTime
(
start
);
end
=
srtTime
[
2
];
startPos
=
stringtoTime
(
start
);
startPos
=
stringtoTime
(
start
);
}
else
{
r
++
;
if
(
comment
!=
""
)
...
...
@@ -131,7 +132,7 @@ void SubtitleModel::parseSubtitle()
}
else
{
QString
EventDialogue
;
QStringList
dialogue
;
start
=
""
;
end
=
""
;
comment
=
""
;
start
=
""
;
end
=
""
;
comment
=
""
;
EventDialogue
+=
line
;
dialogue
=
EventDialogue
.
split
(
": "
)[
1
].
split
(
','
);
QString
remainingStr
=
","
+
EventDialogue
.
split
(
": "
)[
1
].
section
(
','
,
maxSplit
);
...
...
@@ -159,8 +160,8 @@ void SubtitleModel::parseSubtitle()
GenTime
SubtitleModel
::
stringtoTime
(
QString
str
)
{
QStringList
total
,
secs
;
int
hours
=
0
,
mins
=
0
,
seconds
=
0
,
ms
=
0
;
double
total_sec
=
0
;
double
hours
=
0
,
mins
=
0
,
seconds
=
0
,
ms
=
0
;
double
total_sec
=
0
;
total
=
str
.
split
(
':'
);
hours
=
atoi
(
total
[
0
].
toStdString
().
c_str
());
mins
=
atoi
(
total
[
1
].
toStdString
().
c_str
());
...
...
@@ -170,7 +171,7 @@ GenTime SubtitleModel::stringtoTime(QString str)
secs
=
total
[
2
].
split
(
','
);
//srt file
seconds
=
atoi
(
secs
[
0
].
toStdString
().
c_str
());
ms
=
atoi
(
secs
[
1
].
toStdString
().
c_str
());
total_sec
=
hours
*
3600
+
mins
*
60
+
seconds
+
ms
*
0.001
;
total_sec
=
hours
*
3600
+
mins
*
60
+
seconds
+
ms
*
0.001
;
GenTime
pos
=
GenTime
(
total_sec
);
return
pos
;
}
\ No newline at end of file
src/bin/model/subtitlemodel.hpp
View file @
a9a62259
...
...
@@ -38,6 +38,9 @@ private:
//To get subtitle file from effects parameter:
//std::unique_ptr<Mlt::Properties> m_asset;
//std::shared_ptr<AssetParameterModel> m_model;
protected:
/** @brief Helper function that retrieves a pointer to the subtitle model*/
static
std
::
shared_ptr
<
SubtitleModel
>
getModel
();
};
Q_DECLARE_METATYPE
(
SubtitleModel
*
)
...
...
src/doc/kdenlivedoc.cpp
View file @
a9a62259
...
...
@@ -23,6 +23,7 @@
#include "bin/binplaylist.hpp"
#include "bin/clipcreator.hpp"
#include "bin/model/markerlistmodel.hpp"
#include "bin/model/subtitlemodel.hpp"
#include "bin/projectclip.h"
#include "bin/projectitemmodel.h"
#include "core.h"
...
...
@@ -1771,3 +1772,8 @@ int KdenliveDoc::audioChannels() const
QString
&
KdenliveDoc
::
modifiedDecimalPoint
()
{
return
m_modifiedDecimalPoint
;
}
std
::
shared_ptr
<
SubtitleModel
>
KdenliveDoc
::
getSubtitleModel
()
const
{
return
m_subtitleModel
;
}
\ No newline at end of file
src/doc/kdenlivedoc.h
View file @
a9a62259
...
...
@@ -44,6 +44,7 @@ class ProjectClip;
class
MarkerListModel
;
class
Render
;
class
ProfileParam
;
class
SubtitleModel
;
class
QUndoGroup
;
class
QUndoCommand
;
...
...
@@ -162,11 +163,14 @@ public:
/** @brief Returns the number of audio channels for this project */
int
audioChannels
()
const
;
/**
* If the document used a decimal point different than “.”, it is stored in this property.
* @return Original decimal point, or an empty string if it was “.” already
*/
QString
&
modifiedDecimalPoint
();
/** @brief Returns a pointer to the subtitle model */
std
::
shared_ptr
<
SubtitleModel
>
getSubtitleModel
()
const
;
private:
QUrl
m_url
;
...
...
@@ -197,6 +201,7 @@ private:
QMap
<
QString
,
QString
>
m_documentProperties
;
QMap
<
QString
,
QString
>
m_documentMetadata
;
std
::
shared_ptr
<
MarkerListModel
>
m_guideModel
;
std
::
shared_ptr
<
SubtitleModel
>
m_subtitleModel
;
QString
m_modifiedDecimalPoint
;
...
...
@@ -264,4 +269,4 @@ signals:
void
updateCompositionMode
(
int
);
};
#endif
#endif
\ No newline at end of file
src/project/projectmanager.cpp
View file @
a9a62259
...
...
@@ -27,6 +27,7 @@ the Free Software Foundation, either version 3 of the License, or
// Temporary for testing
#include "bin/model/markerlistmodel.hpp"
#include "bin/model/subtitlemodel.hpp"
#include "profiles/profilerepository.hpp"
#include "project/notesplugin.h"
...
...
@@ -1079,3 +1080,8 @@ void ProjectManager::addAudioTracks(int tracksCount)
{
pCore
->
window
()
->
getMainTimeline
()
->
controller
()
->
addTracks
(
0
,
tracksCount
);
}
std
::
shared_ptr
<
SubtitleModel
>
ProjectManager
::
getSubtitleModel
()
{
return
current
()
->
getSubtitleModel
();
}
\ No newline at end of file
src/project/projectmanager.h
View file @
a9a62259
...
...
@@ -30,6 +30,7 @@ class KAutoSaveFile;
class
KJob
;
class
KdenliveDoc
;
class
MarkerListModel
;
class
SubtitleModel
;
class
NotesPlugin
;
class
Project
;
class
QAction
;
...
...
@@ -97,6 +98,11 @@ public:
*/
void
addAudioTracks
(
int
tracksCount
);
/** @brief Return the current Subtitle Model
The method is virtual to allow mocking
*/
virtual
std
::
shared_ptr
<
SubtitleModel
>
getSubtitleModel
();
public
slots
:
void
newFile
(
QString
profileName
,
bool
showProjectSettings
=
true
);
void
newFile
(
bool
showProjectSettings
=
true
);
...
...
Write
Preview
Supports
Markdown
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