Commit 772823ac authored by Sashmita Raghav's avatar Sashmita Raghav

Add function to edit end timings of each subtitle

parent 4c318e7c
......@@ -299,3 +299,13 @@ void SubtitleModel::addSnapPoint(GenTime startpos)
// Update the list of snapModel known to be valid
std::swap(m_regSnaps, validSnapModels);
}
void SubtitleModel::editEndPos(GenTime startPos, GenTime oldEndPos, GenTime newEndPos)
{
auto model = getModel();
if(oldEndPos == newEndPos) return;
int row = static_cast<int>(std::distance(model->m_subtitleList.begin(), model->m_subtitleList.find(startPos)));
model->m_subtitleList[startPos].second = newEndPos;
emit model->dataChanged(model->index(row), model->index(row), QVector<int>() << EndPosRole);
return;
}
......@@ -44,6 +44,13 @@ public:
/** @brief Registers a snap model to the subtitle model */
void registerSnap(const std::weak_ptr<SnapInterface> &snapModel);
/** @brief Edit subtitle end timing
@param startPos is start timing position of subtitles
@param oldPos is the old position of the end time
@param pos defines the new position of the end time
*/
void editEndPos(GenTime startPos, GenTime oldEndPos, GenTime newEndPos);
public slots:
/** @brief Function that parses through a subtitle file */
......
......@@ -25,6 +25,7 @@
#include "bin/bin.h"
#include "bin/clipcreator.hpp"
#include "bin/model/markerlistmodel.hpp"
#include "bin/model/subtitlemodel.hpp"
#include "bin/projectclip.h"
#include "bin/projectfolder.h"
#include "bin/projectitemmodel.h"
......@@ -3663,3 +3664,12 @@ void TimelineController::addTracks(int videoTracks, int audioTracks)
undo();
}
}
void TimelineController::editSubtitles(int startFrame, int oldEndFrame, int newEndFrame)
{
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);
}
......@@ -556,6 +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);
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