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

DOCUMENT: Implement the loadSubDocument for VivyDocument

parent 0084ac43
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Ce commit fait partie de la requête de fusion !3. Les commentaires créés ici seront créés dans le contexte de cette requête de fusion.
src/Utils.h 0 → 100644
#ifndef VIVY_UTILS_H
#define VIVY_UTILS_H
#include <QString>
namespace Vivy
{
};
#endif // VIVY_UTILS_H
#include "VivyDocument.h"
#include <QStringList>
#include <QString>
#include <QFileInfo>
......@@ -11,6 +12,51 @@ VivyDocument::VivyDocument(const QString &name)
bool
VivyDocument::loadSubDocument(const QString &name) noexcept
{
QFileInfo file(name);
SubDocument type;
if (detectDocumentType(file, &type)) {
switch (type) {
case SubDocument::Audio:
audioFile = name;
break;
case SubDocument::Video:
videoFile = name;
break;
case SubDocument::ASS:
assFile = name;
break;
}
return true;
}
return false;
}
bool
VivyDocument::detectDocumentType(const QFileInfo &file, VivyDocument::SubDocument *type)
{
const QString suffix = file.suffix();
static QStringList audioFileSuffix = { "wave", "ogg", "mp3" };
static QStringList videoFileSuffix = { "mkv", "mp4" };
static QStringList assFileSuffix = { "ass", "vivy" };
if (audioFileSuffix.contains(suffix, Qt::CaseInsensitive)) {
*type = SubDocument::Audio;
return true;
}
if (videoFileSuffix.contains(suffix, Qt::CaseInsensitive)) {
*type = SubDocument::Video;
return true;
}
if (assFileSuffix.contains(suffix, Qt::CaseInsensitive)) {
*type = SubDocument::ASS;
return true;
}
return false;
}
......
......@@ -16,7 +16,7 @@ public:
ASS = (1 << 3),
};
static inline const QString filePrefix = "vivy";
static inline const QString filePrefix{ "vivy" };
private:
/* The document name */
......@@ -24,7 +24,7 @@ private:
QDir documentLocation{ QDir::currentPath() };
/* The type to get all fields, has audio, etc... */
int documentType = 0;
int documentType{ 0 };
/* Links to other files, they're not embeded inside the vivy file */
QString audioFile{};
......@@ -34,6 +34,8 @@ private:
/* Create an empty document */
VivyDocument(const QString &name);
static bool detectDocumentType(const QFileInfo &, SubDocument *);
public:
static VivyDocument *fromPath(const QString &path) noexcept;
static VivyDocument *newEmpty(const QString &name) 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