-
Notifications
You must be signed in to change notification settings - Fork 2
/
ImageNoteFactory.cpp
70 lines (51 loc) · 1.42 KB
/
ImageNoteFactory.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
67
68
#include "ImageNoteFactory.h"
#include <QFile>
#include <QTextStream>
#include "Article.h"
#include "Trash.h"
#include "TagManager.h"
/***
* ImageNoteFactory
*/
ImageNote* ImageNoteFactory::buildNote(const QString &path)
{
QFile fichier(path);
if(!fichier.open(QIODevice::ReadOnly | QIODevice::Text))
return 0;
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 ipath = flux.readLine();
fichier.close(); qDebug()<<fpath;
ImageNote* a=new ImageNote(fpath,title,des,ipath);
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;
}
ImageNote* ImageNoteFactory::buildNewNote()
{
return new ImageNote(generateNewFilePath());
}
QString ImageNoteFactory::getFolder()
{
return "IMG/";
}
QString ImageNoteFactory::getExtension()
{
return ".img";
}