Commit d7dfcab1 authored by Sashmita Raghav's avatar Sashmita Raghav
Browse files

Add signals and slot to subtitle model

parent 42147a4b
......@@ -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";
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= "";
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]
......@@ -27,11 +27,10 @@ class SubtitleModel:public QAbstractListModel
/* @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();
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;
void modelChanged();
/** @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();
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