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

LIB: Loading an ASS is working, only import Dialog Events for now

parent a08d7110
Aucune branche associée trouvée
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.
...@@ -24,8 +24,6 @@ Line::Line(AssFactory *const factory, const QString &lineString) ...@@ -24,8 +24,6 @@ Line::Line(AssFactory *const factory, const QString &lineString)
// NOTE: time is of the form: `h:mm:ss.cc` // NOTE: time is of the form: `h:mm:ss.cc`
}; };
qDebug() << "Try to create line for" << lineString;
static const QString lineHeader = "Dialogue: "; static const QString lineHeader = "Dialogue: ";
if (!lineString.startsWith(lineHeader)) if (!lineString.startsWith(lineHeader))
throw std::runtime_error(("invalid event line header: " + lineString).toStdString()); throw std::runtime_error(("invalid event line header: " + lineString).toStdString());
...@@ -61,7 +59,6 @@ Line::Line(AssFactory *const factory, const QString &lineString) ...@@ -61,7 +59,6 @@ Line::Line(AssFactory *const factory, const QString &lineString)
for (int i = 0; i < LineIndex::Text; ++i) for (int i = 0; i < LineIndex::Text; ++i)
contentList.removeFirst(); contentList.removeFirst();
___contentAsText = contentList.join(""); ___contentAsText = contentList.join("");
qDebug() << "The content text is" << ___contentAsText;
initSylFromString(___contentAsText); initSylFromString(___contentAsText);
} }
...@@ -75,13 +72,10 @@ Line::initSylFromString(const QString &line) noexcept ...@@ -75,13 +72,10 @@ Line::initSylFromString(const QString &line) noexcept
bool once = false; bool once = false;
try { try {
qDebug() << "Matching...";
QRegularExpressionMatchIterator it = re.globalMatch(line); QRegularExpressionMatchIterator it = re.globalMatch(line);
qDebug() << "Matched!";
while (it.hasNext()) { while (it.hasNext()) {
QRegularExpressionMatch match = it.next(); QRegularExpressionMatch match = it.next();
qDebug() << match.captured(1);
content.append(Syl(this, match.captured(1))); content.append(Syl(this, match.captured(1)));
once |= true; once |= true;
} }
...@@ -92,7 +86,6 @@ Line::initSylFromString(const QString &line) noexcept ...@@ -92,7 +86,6 @@ Line::initSylFromString(const QString &line) noexcept
} }
if (!once) { if (!once) {
qDebug() << "Use RAW for" << line;
content.clear(); content.clear();
content.append(Syl(this, line, Syl::ConstructMode::Raw)); content.append(Syl(this, line, Syl::ConstructMode::Raw));
} }
......
#include "Syl.hh" #include "Syl.hh"
#include "Line.hh" #include "Line.hh"
#include <QRegularExpression>
using namespace Vivy::Ass; using namespace Vivy::Ass;
Syl::Syl(Line *const line, const QString &lineString, ConstructMode mode) noexcept Syl::Syl(Line *const line, const QString &lineString, ConstructMode mode) noexcept
...@@ -20,12 +22,16 @@ Syl::Syl(Line *const line, const QString &lineString, ConstructMode mode) noexce ...@@ -20,12 +22,16 @@ Syl::Syl(Line *const line, const QString &lineString, ConstructMode mode) noexce
quint64 quint64
Syl::getDurationFromString(const QString &line) noexcept Syl::getDurationFromString(const QString &line) noexcept
{ {
QRegExp re("\\\\(?:k|K|ko|kf)(\\d+)"); QRegularExpression re("\\\\(?:k|K|ko|kf)(\\d+)");
int pos = 0; if (!re.isValid())
qFatal("The regex '%s' is not valid...", re.pattern().toStdString().c_str());
quint64 duration = 0; quint64 duration = 0;
while ((pos = re.indexIn(line, pos)) != -1) { QRegularExpressionMatchIterator it = re.globalMatch(line);
duration += re.cap(1).toUInt();
} while (it.hasNext())
duration += it.next().captured(1).toUInt();
return duration; return duration;
} }
......
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