Commit 7fe395a1 authored by Sashmita Raghav's avatar Sashmita Raghav

Add basic functions for returning row count and all subtitles in list

parent 827c9e17
......@@ -7,13 +7,13 @@ SubtitleModel::SubtitleModel(std::weak_ptr<DocUndoStack> undo_stack, QObject *pa
: QAbstractListModel(parent)
, m_undoStack(std::move(undo_stack))
std::shared_ptr<SubtitleModel> SubtitleModel::getModel()
return pCore->projectManager()->getSubtitleModel();
void SubtitleModel::parseSubtitle()
//QModelIndex index;
......@@ -226,4 +226,21 @@ QVariant SubtitleModel::data(const QModelIndex& index, int role) const
return it->second.second.frames(pCore->getCurrentFps());
return QVariant();
int SubtitleModel::rowCount(const QModelIndex &parent) const
if (parent.isValid())
return 0;
return static_cast<int>(m_subtitleList.size());
QList<SubtitledTime> SubtitleModel::getAllSubtitles() const
QList<SubtitledTime> subtitle;
for (const auto &subtitles : m_subtitleList) {
SubtitledTime s(subtitles.first, subtitles.second.first, subtitles.second.second);
subtitle << s;
return subtitle;
\ No newline at end of file
#include "bin/bin.h"
#include "definitions.h"
#include "gentime.h"
#include "undohelper.hpp"
......@@ -34,7 +35,11 @@ public:
GenTime stringtoTime(QString str);
QVariant data(const QModelIndex &index, int role) const override;
QHash<int, QByteArray> roleNames() const override;// overide the same function of QAbstractListModel
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
/** @brief Returns all subtitles in the model */
QList<SubtitledTime> getAllSubtitles() const;
std::weak_ptr<DocUndoStack> m_undoStack;
std::map<GenTime, std::pair<QString, GenTime>> m_subtitleList;
......@@ -45,6 +50,7 @@ private:
/** @brief Helper function that retrieves a pointer to the subtitle model*/
static std::shared_ptr<SubtitleModel> getModel();
\ No newline at end of file
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