forked from felixmt/LO21
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Audio.cpp
66 lines (57 loc) · 2 KB
/
Audio.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "Audio.h"
#include <QString>
#include <QFile>
#include <QTextStream>
#include <iostream>
void Audio::save()
{
if (this->isModified()) {
// Création d'un objet QFile
QString completePath = notePath + this->getFilename() + (QString)".aud";
QFile file(completePath);
//On ouvre notre fichier en écriture et on vÈrifie l'ouverture
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
std::cout <<"Erreur sauvegarde d'un enregistrement audio : impossible d'ouvrir un fichier en écriture"; //A FAIRE : Gestion des exceptions
QTextStream flux(&file);
flux<<this->getTitle() << "\n";
flux<<this->getAud();
file.close();
std::cout << "Une sauvegarde d'un enregistrement audio' a été effectuée sur le chemin suivant:" << qPrintable(completePath)<<"/n";
}
}
void Audio::load(QString& path)
{
QFile fichier(path);
fichier.open(QIODevice::ReadOnly | QIODevice::Text);
//A FAIRE : Vérifier la bonne ouverture du fichier et gérer les exceptions
QTextStream flux(&fichier);
QString title=flux.readLine();
this->setTitle(title);
QString text=flux.readAll();
this->setAud(text);
QString fname = path.mid(0,path.size()-4);
this->setFilename(fname);
fichier.close();
}
QString Audio::exportText() {
textContent = this->getTitle() + "\n\n" + this->getAud() + "\n";
return textContent;
}
QString Audio::exportHtml(bool appartenanceDoc)
{
Note::exportHtml(appartenanceDoc);
html += "<p><audio controls><source src=\"" + aud + "\" /><p>"+ title +"</p></audio></p></body></html>";
if(!appartenanceDoc)
html += "</body></html>";
return html;
}
QString Audio::exportLatex(bool appartenanceDoc)
{
if(!appartenanceDoc)
Note::exportLatex(appartenanceDoc);
latex += "\\subsection{"+title+"}\n";
latex += aud + "\n \\newline \n";
if(!appartenanceDoc)
latex += "\n \\end{document}";
return latex;
}