Commit 05e67c2c authored by Sashmita Raghav's avatar Sashmita Raghav
Browse files

Add functions to move subtitles in model

parent 1ad28e8d
......@@ -204,6 +204,11 @@ void SubtitleModel::addSubtitle(GenTime start, GenTime end, QString &str)
qDebug()<<"already present in model"<<"string :"<<m_subtitleList[start].first<<" start time "<<start.frames(pCore->getCurrentFps())<<"end time : "<< m_subtitleList[start].second.frames(pCore->getCurrentFps());
if(model->m_subtitleList.count(start) > 0 ){
qDebug()<<"Start time already in model";
editSubtitle(start, str, end);
auto it= model->m_subtitleList.lower_bound(start); // returns the key and its value *just* greater than start.
//Q_ASSERT(it->first < model->m_subtitleList.end()->second.second); // returns warning if added subtitle start time is less than last subtitle's end time
int insertRow= static_cast<int>(model->m_subtitleList.size());//converts the returned unsigned size() to signed int
......@@ -335,3 +340,18 @@ void SubtitleModel::removeSubtitle(GenTime pos)
void SubtitleModel::moveSubtitle(GenTime oldPos, GenTime newPos)
qDebug()<<"Moving Subtitle";
auto model = getModel();
if(model->m_subtitleList.count(oldPos) <= 0){
//is not present in model only
QString subtitleText = model->m_subtitleList[oldPos].first ;
GenTime endPos = model->m_subtitleList[oldPos].second;
addSubtitle(newPos, endPos, subtitleText);
......@@ -62,6 +62,12 @@ public:
/** @brief Remove subtitle at start position (pos) */
void removeSubtitle(GenTime pos);
/** @brief Move an existing subtitle
@param oldPos is original start position of subtitle
@param newPos is new start position of subtitle
void moveSubtitle(GenTime oldPos, GenTime newPos);
public slots:
/** @brief Function that parses through a subtitle file */
void parseSubtitle();
......@@ -3673,3 +3673,12 @@ void TimelineController::editSubtitle(int startFrame, QString text, int endFrame
GenTime endPos(endFrame, pCore->getCurrentFps());
subtitleModel->editSubtitle(startPos, text, endPos);
void TimelineController::moveSubtitle(int oldStartFrame, int newStartFrame)
qDebug()<<"Moving existing subtitle in controller from"<<oldStartFrame<<" to "<<newStartFrame;
auto subtitleModel = pCore->projectManager()->current()->getSubtitleModel();
GenTime oldStartPos(oldStartFrame, pCore->getCurrentFps());
GenTime newStartPos(newStartFrame, pCore->getCurrentFps());
subtitleModel->moveSubtitle(oldStartPos, newStartPos);
......@@ -558,6 +558,8 @@ public:
QPoint selectionInOut() const;
/** @brief Edit the subtitle text and/or end timings */
Q_INVOKABLE void editSubtitle(int startFrame, QString text, int endFrame);
/** @brief Move position of subtitle */
Q_INVOKABLE void moveSubtitle(int oldStartFrame, int newStartFrame);
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