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
d7dfcab1
Commit
d7dfcab1
authored
Jul 18, 2020
by
Sashmita Raghav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add signals and slot to subtitle model
parent
42147a4b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
src/bin/model/subtitlemodel.cpp
src/bin/model/subtitlemodel.cpp
+16
-1
src/bin/model/subtitlemodel.hpp
src/bin/model/subtitlemodel.hpp
+8
-2
No files found.
src/bin/model/subtitlemodel.cpp
View file @
d7dfcab1
...
...
@@ -8,6 +8,21 @@ SubtitleModel::SubtitleModel(std::weak_ptr<DocUndoStack> undo_stack, QObject *pa
,
m_undoStack
(
std
::
move
(
undo_stack
))
,
m_lock
(
QReadWriteLock
::
Recursive
)
{
//qDebug()<< "subtitle constructor";
setup
();
}
void
SubtitleModel
::
setup
()
{
// We connect the signals of the abstractitemmodel to a more generic one.
connect
(
this
,
&
SubtitleModel
::
columnsMoved
,
this
,
&
SubtitleModel
::
modelChanged
);
connect
(
this
,
&
SubtitleModel
::
columnsRemoved
,
this
,
&
SubtitleModel
::
modelChanged
);
connect
(
this
,
&
SubtitleModel
::
columnsInserted
,
this
,
&
SubtitleModel
::
modelChanged
);
connect
(
this
,
&
SubtitleModel
::
rowsMoved
,
this
,
&
SubtitleModel
::
modelChanged
);
connect
(
this
,
&
SubtitleModel
::
rowsRemoved
,
this
,
&
SubtitleModel
::
modelChanged
);
connect
(
this
,
&
SubtitleModel
::
rowsInserted
,
this
,
&
SubtitleModel
::
modelChanged
);
connect
(
this
,
&
SubtitleModel
::
modelReset
,
this
,
&
SubtitleModel
::
modelChanged
);
connect
(
this
,
&
SubtitleModel
::
dataChanged
,
this
,
&
SubtitleModel
::
modelChanged
);
}
std
::
shared_ptr
<
SubtitleModel
>
SubtitleModel
::
getModel
()
...
...
@@ -22,8 +37,8 @@ void SubtitleModel::parseSubtitle()
//QString filename(m_asset->get(paramName.toUtf8().constData()));
QString
filePath
=
"path_to_subtitle_file.srt"
;
QString
start
,
end
,
comment
;
GenTime
startPos
,
endPos
;
QString
timeLine
;
GenTime
startPos
,
endPos
;
int
index
=
0
,
turn
=
0
,
r
=
0
;
/*
* turn = 0 -> Parse next subtitle line [srt] (or) Parse next section [ssa]
...
...
src/bin/model/subtitlemodel.hpp
View file @
d7dfcab1
...
...
@@ -27,11 +27,10 @@ class SubtitleModel:public QAbstractListModel
public:
/* @brief Construct a subtitle list bound to the timeline */
SubtitleModel
(
std
::
weak_ptr
<
DocUndoStack
>
undo_stack
,
QObject
*
parent
=
nullptr
);
explicit
SubtitleModel
(
std
::
weak_ptr
<
DocUndoStack
>
undo_stack
,
QObject
*
parent
=
nullptr
);
enum
{
SubtitleRole
=
Qt
::
UserRole
+
1
,
StartPosRole
,
EndPosRole
,
StartFrameRole
,
EndFrameRole
};
/** @brief Function that parses through a subtitle file */
void
parseSubtitle
();
void
addSubtitle
(
GenTime
start
,
GenTime
end
,
QString
str
);
GenTime
stringtoTime
(
QString
str
);
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
override
;
...
...
@@ -44,6 +43,9 @@ public:
/** @brief Registers a snap model to the subtitle model */
void
registerSnap
(
const
std
::
weak_ptr
<
SnapInterface
>
&
snapModel
);
public
slots
:
void
parseSubtitle
();
private:
std
::
weak_ptr
<
DocUndoStack
>
m_undoStack
;
std
::
map
<
GenTime
,
std
::
pair
<
QString
,
GenTime
>>
m_subtitleList
;
...
...
@@ -54,11 +56,15 @@ private:
std
::
vector
<
std
::
weak_ptr
<
SnapInterface
>>
m_regSnaps
;
mutable
QReadWriteLock
m_lock
;
signals:
void
modelChanged
();
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
);
void
setup
();
};
Q_DECLARE_METATYPE
(
SubtitleModel
*
)
...
...
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