Commit a9a62259 authored by Sashmita Raghav's avatar Sashmita Raghav

Add functions to return pointer to model

parent e6843558
......@@ -8,6 +8,7 @@ set(kdenlive_SRCS
bin/filewatcher.cpp
bin/generators/generators.cpp
bin/model/markerlistmodel.cpp
bin/model/subtitlemodel.cpp
bin/projectclip.cpp
bin/projectfolder.cpp
bin/projectitemmodel.cpp
......
......@@ -5,6 +5,7 @@
SubtitleModel::SubtitleModel(std::weak_ptr<DocUndoStack> undo_stack, QObject *parent)
: QAbstractListModel(parent)
, m_undoStack(std::move(undo_stack))
{
}
......@@ -56,7 +57,7 @@ void SubtitleModel::parseSubtitle()
start = srtTime[0];
startPos= stringtoTime(start);
end = srtTime[2];
startPos= stringtoTime(start);
startPos = stringtoTime(start);
} else {
r++;
if (comment != "")
......@@ -131,7 +132,7 @@ void SubtitleModel::parseSubtitle()
} else {
QString EventDialogue;
QStringList dialogue;
start ="";end ="";comment="";
start = "";end = "";comment = "";
EventDialogue += line;
dialogue = EventDialogue.split(": ")[1].split(',');
QString remainingStr = "," + EventDialogue.split(": ")[1].section(',', maxSplit);
......@@ -159,8 +160,8 @@ void SubtitleModel::parseSubtitle()
GenTime SubtitleModel::stringtoTime(QString str)
{
QStringList total,secs;
int hours=0, mins=0, seconds=0, ms=0;
double total_sec=0;
double hours = 0, mins = 0, seconds = 0, ms = 0;
double total_sec = 0;
total = str.split(':');
hours = atoi(total[0].toStdString().c_str());
mins = atoi(total[1].toStdString().c_str());
......@@ -170,7 +171,7 @@ GenTime SubtitleModel::stringtoTime(QString str)
secs = total[2].split(','); //srt file
seconds = atoi(secs[0].toStdString().c_str());
ms = atoi(secs[1].toStdString().c_str());
total_sec= hours *3600 + mins *60 + seconds + ms * 0.001 ;
total_sec = hours *3600 + mins *60 + seconds + ms * 0.001 ;
GenTime pos= GenTime(total_sec);
return pos;
}
\ No newline at end of file
......@@ -38,6 +38,9 @@ private:
//To get subtitle file from effects parameter:
//std::unique_ptr<Mlt::Properties> m_asset;
//std::shared_ptr<AssetParameterModel> m_model;
protected:
/** @brief Helper function that retrieves a pointer to the subtitle model*/
static std::shared_ptr<SubtitleModel> getModel();
};
Q_DECLARE_METATYPE(SubtitleModel *)
......
......@@ -23,6 +23,7 @@
#include "bin/binplaylist.hpp"
#include "bin/clipcreator.hpp"
#include "bin/model/markerlistmodel.hpp"
#include "bin/model/subtitlemodel.hpp"
#include "bin/projectclip.h"
#include "bin/projectitemmodel.h"
#include "core.h"
......@@ -1771,3 +1772,8 @@ int KdenliveDoc::audioChannels() const
QString& KdenliveDoc::modifiedDecimalPoint() {
return m_modifiedDecimalPoint;
}
std::shared_ptr<SubtitleModel> KdenliveDoc::getSubtitleModel() const
{
return m_subtitleModel;
}
\ No newline at end of file
......@@ -44,6 +44,7 @@ class ProjectClip;
class MarkerListModel;
class Render;
class ProfileParam;
class SubtitleModel;
class QUndoGroup;
class QUndoCommand;
......@@ -162,11 +163,14 @@ public:
/** @brief Returns the number of audio channels for this project */
int audioChannels() const;
/**
* If the document used a decimal point different than “.”, it is stored in this property.
* @return Original decimal point, or an empty string if it was “.” already
*/
QString &modifiedDecimalPoint();
/** @brief Returns a pointer to the subtitle model */
std::shared_ptr<SubtitleModel> getSubtitleModel() const;
private:
QUrl m_url;
......@@ -197,6 +201,7 @@ private:
QMap<QString, QString> m_documentProperties;
QMap<QString, QString> m_documentMetadata;
std::shared_ptr<MarkerListModel> m_guideModel;
std::shared_ptr<SubtitleModel> m_subtitleModel;
QString m_modifiedDecimalPoint;
......@@ -264,4 +269,4 @@ signals:
void updateCompositionMode(int);
};
#endif
#endif
\ No newline at end of file
......@@ -27,6 +27,7 @@ the Free Software Foundation, either version 3 of the License, or
// Temporary for testing
#include "bin/model/markerlistmodel.hpp"
#include "bin/model/subtitlemodel.hpp"
#include "profiles/profilerepository.hpp"
#include "project/notesplugin.h"
......@@ -1079,3 +1080,8 @@ void ProjectManager::addAudioTracks(int tracksCount)
{
pCore->window()->getMainTimeline()->controller()->addTracks(0, tracksCount);
}
std::shared_ptr<SubtitleModel> ProjectManager::getSubtitleModel()
{
return current()->getSubtitleModel();
}
\ No newline at end of file
......@@ -30,6 +30,7 @@ class KAutoSaveFile;
class KJob;
class KdenliveDoc;
class MarkerListModel;
class SubtitleModel;
class NotesPlugin;
class Project;
class QAction;
......@@ -97,6 +98,11 @@ public:
*/
void addAudioTracks(int tracksCount);
/** @brief Return the current Subtitle Model
The method is virtual to allow mocking
*/
virtual std::shared_ptr<SubtitleModel> getSubtitleModel();
public slots:
void newFile(QString profileName, bool showProjectSettings = true);
void newFile(bool showProjectSettings = true);
......
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