Skip to content
Extraits de code Groupes Projets
Vérifiée Valider f2baee99 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

ASS: Prepare the creation of ass karaoke lines

parent 1ee976fe
Branches
Aucune étiquette associée trouvée
1 requête de fusion!7Add the ASS sub document and the ASS tree
Ce commit fait partie de la requête de fusion !7. Les commentaires créés ici seront créés dans le contexte de cette requête de fusion.
...@@ -63,7 +63,7 @@ AssFactory::initFromStorage() noexcept ...@@ -63,7 +63,7 @@ AssFactory::initFromStorage() noexcept
for (const auto &styleLine : stylesContent) for (const auto &styleLine : stylesContent)
assStyles.push_back(std::make_shared<Style>(styleLine)); assStyles.push_back(std::make_shared<Style>(styleLine));
for (const auto &assLine : eventsContent) for (const auto &assLine : eventsContent)
assLines.push_back(std::make_shared<Line>(assLine)); assLines.push_back(std::make_shared<Line>(this, assLine));
} catch (const std::runtime_error &e) { } catch (const std::runtime_error &e) {
qCritical() << "Failed to create ASS style or events with error:" << e.what(); qCritical() << "Failed to create ASS style or events with error:" << e.what();
} }
...@@ -138,3 +138,13 @@ AssFactory::getInfoSection() const noexcept ...@@ -138,3 +138,13 @@ AssFactory::getInfoSection() const noexcept
{ {
return assInfo; return assInfo;
} }
bool
AssFactory::hasStyle(const QString &name) const noexcept
{
for (const auto &stylePtr : assStyles) {
if (stylePtr->getElementName() == name)
return true;
}
return false;
}
...@@ -59,6 +59,8 @@ public: ...@@ -59,6 +59,8 @@ public:
explicit AssFactory(const QString &); explicit AssFactory(const QString &);
~AssFactory() noexcept = default; ~AssFactory() noexcept = default;
bool hasStyle(const QString &) const noexcept;
SectionContent getInfoSection() const noexcept; SectionContent getInfoSection() const noexcept;
void getStyles(QVector<StylePtr> &) const noexcept; void getStyles(QVector<StylePtr> &) const noexcept;
void getLines(QVector<LinePtr> &) const noexcept; void getLines(QVector<LinePtr> &) const noexcept;
......
#include "Line.hh" #include "Line.hh"
#include "AssFactory.hh"
using namespace Vivy::Ass; using namespace Vivy::Ass;
Line::Line(const QString & /*unused*/) Line::Line(AssFactory *const factory, const QString &lineString)
: assFactory(factory)
{ {
enum LineIndex : int {
Layer = 0, // int
Start = 1, // time
End = 2, // time
Style = 3, // text
Name = 4, // text
MarginL = 5, // int
MarginR = 6, // int
MarginV = 7, // int
Effect = 8, // text
Text = 9, // text
PastLastCode
// NOTE: time is of the form: `h:mm:ss.cc`
};
static const QString lineHeader = "Dialogue: ";
if (!lineString.startsWith(lineHeader))
throw std::runtime_error(("invalid event line header: " + lineString).toStdString());
const QString lineContent = lineString.mid(lineString.indexOf(": ") + 2 /* strlen ": " */);
const QStringList content = lineContent.split(",", Qt::KeepEmptyParts, Qt::CaseInsensitive);
} }
void void
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
namespace Vivy::Ass namespace Vivy::Ass
{ {
class AssFactory;
class Line { class Line {
private: private:
quint64 start{ 0 }; quint64 start{ 0 };
...@@ -16,10 +18,11 @@ private: ...@@ -16,10 +18,11 @@ private:
QVector<Syl> content{}; QVector<Syl> content{};
StyleProperties styleProperties; StyleProperties styleProperties;
AssFactory *const assFactory;
public: public:
explicit Line() = default;
explicit Line(const Line &) = default; explicit Line(const Line &) = default;
explicit Line(const QString &); explicit Line(AssFactory *const, const QString &);
Line &operator=(const Line &) = delete; Line &operator=(const Line &) = delete;
~Line() noexcept = default; ~Line() noexcept = default;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter