-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotesManager.h
executable file
·95 lines (76 loc) · 2.76 KB
/
NotesManager.h
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
#ifndef NOTESMANAGER_H
#define NOTESMANAGER_H
#include <QString>
#include <QSet>
#include <QMap>
#include <QDir>
#include <QFile>
#include <QStringList>
#include <QDebug>
#include <QTextStream>
#include <QtXml>
#include <QPalette>
#include "Note.h"
#include "NoteFactory.h"
#include "NotesExporter.h"
#include "TagManager.h"
#include "Tag.h"
namespace NM {
class Note;
class NoteFactory;
class NotesManager {
QSet<Note*> notes;
QSet<Note*> corbeille;
static NotesManager* nmInstance;
QMap<QString, NoteFactory*> factories;
QString path; //chemin par défaut des workspace
QDir workspace; //
protected :
NotesManager();
~NotesManager();
public :
static NotesManager & getInstance ();
static void releaseInstance ();
unsigned int getNbNotes () const {return notes.size();}
const QDir getWorkspace () const {return workspace;}
Note * getNote(unsigned int id);
const QSet<Note*> returnSetNotes() const {return notes;}
//load un workspace par défaut situé dans ../Ressources/workspace1
void loadWorkspace (QString fold);
void addArticle (Note *n);
void operator <<(Note *n);
Note & getNewNote(const QString & fact);
Note & getNewNArticle();
Note & getNewDocument();
Note & getNewNImage();
Note & getNewNAudio();
Note & getNewNVideo();
void save(Note *note) const;
void saveWorkspace();
void deleteNote(Note *n);
Note* restoreNote(unsigned int id);
void createNoteFromNode(const QDomNode n);
//void createDocFromNode(const QDomNode n);
class Iterator {
friend class NotesManager;
QSet<Note*>::iterator i;
public :
Iterator(QSet<Note*> &s) {i=s.begin();}
Iterator(QSet<Note*>::iterator j) {i = j;}
Note * operator*() {return *(i);}
Iterator operator++() {i++; return *this;}
Iterator operator++(int) {Iterator j(i); i++; return j;}
Iterator operator--() {i--; return i;}
Iterator operator--(int) {Iterator j(i); i--; return j;}
bool operator==(QSet<Note*>::iterator j) {return i==j;}
bool operator!=(QSet<Note*>::iterator j) {return i!=j;}
bool operator!=(Iterator j) {return (*i)!=(*j);}
};
//fonctions de l'itérateur
Iterator begin() {return Iterator(notes);}
Iterator end() {Iterator i(notes.end()); return i;}
Iterator corbeille_begin() {return Iterator(corbeille);}
Iterator corbeille_end() {Iterator i(corbeille.end()); return i;}
};
}
#endif // NOTESMANAGER_H