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

ASS: The Syl get its duration from the passed string

parent b51e05ba
Branches
Aucune étiquette associée trouvée
1 requête de fusion!7Add the ASS sub document and the ASS tree
......@@ -6,10 +6,25 @@ using namespace Vivy::Ass;
Syl::Syl(Line *const line, const QString &lineString, ConstructMode mode) noexcept
: content(lineString)
, styleProperties(line->getStyleProperties())
, dur(line->getDuration())
, duration(line->getDuration())
, parentLine(line)
{
// Will override the `content`, but will be heavy anyway
if (mode == ConstructMode::ReadAssTags) {
const int textBegin = lineString.lastIndexOf('}') + 1;
content = (textBegin >= lineString.size()) ? "" : lineString.mid(textBegin);
duration = getDurationFromString(lineString);
}
}
quint64
Syl::getDurationFromString(const QString &line) noexcept
{
QRegExp re("\\\\(?:k|K|ko|kf)(\\d+)");
int pos = 0;
quint64 duration = 0;
while ((pos = re.indexIn(line, pos)) != -1) {
duration += re.cap(1).toUInt();
}
return duration;
}
......@@ -14,7 +14,7 @@ class Syl final {
private:
QString content;
StyleProperties styleProperties;
quint64 dur{ 0 };
quint64 duration{ 0 };
public:
Line *const parentLine;
......@@ -31,6 +31,9 @@ public:
Syl &operator=(const Syl &) = delete;
~Syl() noexcept = default;
private:
static quint64 getDurationFromString(const QString &) noexcept;
};
}
......
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