Commit b550a1b3 authored by Sashmita Raghav's avatar Sashmita Raghav

Add functions to edit existing subtitles

parent 772823ac
......@@ -309,3 +309,15 @@ void SubtitleModel::editEndPos(GenTime startPos, GenTime oldEndPos, GenTime newE
emit model->dataChanged(model->index(row), model->index(row), QVector<int>() << EndPosRole);
void SubtitleModel::editSubtitle(GenTime startPos, QString newSubtitleText, GenTime endPos)
qDebug()<<"Editing existing subtitle in model";
auto model = getModel();
int row = static_cast<int>(std::distance(model->m_subtitleList.begin(), model->m_subtitleList.find(startPos)));
model->m_subtitleList[startPos].first = newSubtitleText ;
model->m_subtitleList[startPos].second = endPos;
emit model->dataChanged(model->index(row), model->index(row), QVector<int>() << SubtitleRole);
......@@ -52,6 +52,13 @@ public:
void editEndPos(GenTime startPos, GenTime oldEndPos, GenTime newEndPos);
/** @brief Edit subtitle , i.e. text and/or end time
@param startPos is start timing position of subtitles
@param newSubtitleText is (new) subtitle text
@param endPos defines the (new) position of the end time
void editSubtitle(GenTime startPos, QString newSubtitleText, GenTime endPos);
public slots:
/** @brief Function that parses through a subtitle file */
void parseSubtitle();
......@@ -3665,11 +3665,11 @@ void TimelineController::addTracks(int videoTracks, int audioTracks)
void TimelineController::editSubtitles(int startFrame, int oldEndFrame, int newEndFrame)
void TimelineController::editSubtitle(int startFrame, QString text, int endFrame)
qDebug()<<"Editing existing subtitle in controller at:"<<startFrame;
auto subtitleModel = pCore->projectManager()->current()->getSubtitleModel();
GenTime startPos(startFrame, pCore->getCurrentFps());
GenTime endpos(oldEndFrame, pCore->getCurrentFps());
GenTime newendPos(newEndFrame, pCore->getCurrentFps());
subtitleModel->editEndPos(startPos, endpos, newendPos);
GenTime endPos(endFrame, pCore->getCurrentFps());
subtitleModel->editSubtitle(startPos, text, endPos);
......@@ -556,8 +556,8 @@ public:
void addTracks(int videoTracks, int audioTracks);
/** @brief Get in/out of currently selected items */
QPoint selectionInOut() const;
/** @brief Edit the subtitle end timings */
void editSubtitles(int startFrame, int oldEndFrame, int newEndFrame);
/** @brief Edit the subtitle text and/or end timings */
Q_INVOKABLE void editSubtitle(int startFrame, QString text, int endFrame);
public slots:
void resetView();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment