-
Notifications
You must be signed in to change notification settings - Fork 2
/
VideoNoteFactory.cpp
65 lines (49 loc) · 1.36 KB
/
VideoNoteFactory.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
#include "VideoNoteFactory.h"
#include "Trash.h"
#include <QFile>
#include <QTextStream>
#include "TagManager.h"
/***
* VideoNoteFactory
*/
VideoNote* VideoNoteFactory::buildNote(const QString &path)
{
QFile fichier(path);
fichier.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream flux(&fichier);
QString fpath = flux.readLine();
QString title=flux.readLine();
QString tags = flux.readLine();
QStringList tagList = QStringList();
if(!tags.isEmpty())
tagList = tags.split("|||");
QString isDeleted = flux.readLine();
QString des =flux.readLine();
QString vpath = flux.readLine();
fichier.close();
VideoNote* a=new VideoNote(fpath,title,des,vpath);
for(QStringList::iterator it = tagList.begin(); it!=tagList.end(); ++it){
Tag* t = this->tm->getTag(*it);
// double binding method
tm->addTagToNote(t, a);
}
// We do this at the end so that all documents are properly loaded.
if(isDeleted == "isDeleted"){
// Trash will take care of all unbinding staff
Trash::getInstance()->recycle(a);
}
a->setModified(false);
return a;
}
VideoNote* VideoNoteFactory::buildNewNote()
{
return new VideoNote(generateNewFilePath());
}
QString VideoNoteFactory::getFolder()
{
return "VID/";
}
QString VideoNoteFactory::getExtension()
{
return ".vid";
}