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
7fe395a1
Commit
7fe395a1
authored
Jun 30, 2020
by
Sashmita Raghav
Browse files
Add basic functions for returning row count and all subtitles in list
parent
827c9e17
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/model/subtitlemodel.cpp
View file @
7fe395a1
...
...
@@ -7,13 +7,13 @@ SubtitleModel::SubtitleModel(std::weak_ptr<DocUndoStack> undo_stack, QObject *pa
:
QAbstractListModel
(
parent
)
,
m_undoStack
(
std
::
move
(
undo_stack
))
{
}
std
::
shared_ptr
<
SubtitleModel
>
SubtitleModel
::
getModel
()
{
return
pCore
->
projectManager
()
->
getSubtitleModel
();
}
void
SubtitleModel
::
parseSubtitle
()
{
//QModelIndex index;
...
...
@@ -226,4 +226,21 @@ QVariant SubtitleModel::data(const QModelIndex& index, int role) const
return
it
->
second
.
second
.
frames
(
pCore
->
getCurrentFps
());
}
return
QVariant
();
}
int
SubtitleModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
if
(
parent
.
isValid
())
return
0
;
return
static_cast
<
int
>
(
m_subtitleList
.
size
());
}
QList
<
SubtitledTime
>
SubtitleModel
::
getAllSubtitles
()
const
{
QList
<
SubtitledTime
>
subtitle
;
for
(
const
auto
&
subtitles
:
m_subtitleList
)
{
SubtitledTime
s
(
subtitles
.
first
,
subtitles
.
second
.
first
,
subtitles
.
second
.
second
);
subtitle
<<
s
;
}
return
subtitle
;
}
\ No newline at end of file
src/bin/model/subtitlemodel.hpp
View file @
7fe395a1
#ifndef SUBTITLEMODEL_HPP
#define SUBTITLEMODEL_HPP
#include "bin/bin.h"
#include "definitions.h"
#include "gentime.h"
#include "undohelper.hpp"
...
...
@@ -34,7 +35,11 @@ public:
GenTime
stringtoTime
(
QString
str
);
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
override
;
QHash
<
int
,
QByteArray
>
roleNames
()
const
override
;
// overide the same function of QAbstractListModel
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
/** @brief Returns all subtitles in the model */
QList
<
SubtitledTime
>
getAllSubtitles
()
const
;
private:
std
::
weak_ptr
<
DocUndoStack
>
m_undoStack
;
std
::
map
<
GenTime
,
std
::
pair
<
QString
,
GenTime
>>
m_subtitleList
;
...
...
@@ -45,6 +50,7 @@ private:
protected:
/** @brief Helper function that retrieves a pointer to the subtitle model*/
static
std
::
shared_ptr
<
SubtitleModel
>
getModel
();
};
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