-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNoteFactory.cpp
executable file
·105 lines (76 loc) · 2.59 KB
/
NoteFactory.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "NoteFactory.h"
namespace NM {
//----------------NoteFactory----------------
NoteFactory::NoteFactory(QString & n)
: name(n)
{
}
unsigned int NoteFactory::getNewId() {
unsigned int i = QDateTime::currentDateTime().toTime_t();
while (NotesManager::getInstance().getNote(i)) {
i = QDateTime::currentDateTime().toTime_t();
}
return i;
}
//----------------ArticleFactory----------------
ArticleFactory::ArticleFactory(QString &n)
: NoteFactory(n)
{
}
Note * ArticleFactory::buildNote(const unsigned int id, const QString &title) {
return new NArticle(id, title);
}
Note * ArticleFactory::buildNewNote(const QString &title) {
NArticle *a = new NArticle(getNewId(), title);
a->setModified();
return a;
}
/*Note * ArticleFactory::buildNote(NArticle *n) {
NArticle *na = new NArticle(getNewId(), n->getTitle());
na->setText((n->getText()));
return na;
}*/
//----------------DocumentFactory----------------
DocumentFactory::DocumentFactory(QString & n)
: NoteFactory(n)
{
}
Note * DocumentFactory::buildNote(const unsigned int id, const QString &title) {
return new Document(id, title);
}
Note * DocumentFactory::buildNewNote(const QString &title) {
Document *d = new Document(getNewId(), title);
d->setModified();
return d;
}
//----------------MediaFactory----------------
MediaFactory::MediaFactory(QString &n)
: NoteFactory(n) {}
//----------------AudioFactory----------------
Note * AudioFactory::buildNote(const unsigned int id, const QString &title){
return new NAudio(id, title);
}
Note * AudioFactory::buildNewNote(const QString &title){
NAudio * a = new NAudio(getNewId(), title);
a->setModified();
return a;
}
//----------------ImageFactory----------------
Note * ImageFactory::buildNote(const unsigned int id, const QString &title){
return new NImage(id, title);
}
Note * ImageFactory::buildNewNote(const QString &title){
NImage * im = new NImage(getNewId(), title);
im->setModified();
return im;
}
//----------------VideoFactory----------------
Note * VideoFactory::buildNote(const unsigned int id, const QString &title){
return new NVideo(id, title);
}
Note * VideoFactory::buildNewNote(const QString &title){
NVideo * vi = new NVideo(getNewId(), title);
vi->setModified();
return vi;
}
}