Lab1
Loading...
Searching...
No Matches
note_repository.h
1#pragma once
2#include <QList>
3#include <QMap>
4#include <memory>
5#include "note.h"
6#include "schema.h"
7#include "istorage_strategy.h"
8#include <algorithm>
9#include <QObject>
10
11enum class SortType {
12 ByDateNewest,
13 ByDateOldest,
14 ByNameAZ,
15 ByNameZA
16};
17
27public:
32 explicit NoteRepository(std::unique_ptr<IStorageStrategy> strategy);
33
34 // Робота зі схемами
35 void addSchema(const Schema& schema);
36 const QList<Schema>& getSchemas() const;
37 void removeSchema(int index);
38 void updateSchema(int index, const Schema& schema);
39
40 // Робота з нотатками
41 void addNote(const Note& note);
42 QList<Note>& getNotes();
43 void removeNote(int index);
44 void updateNote(int index, const Note& note);
45 void sortNotes(SortType type);
46
47 // Статистика
48 void addUsageTime(int seconds);
49 QMap<QString, int> getUsageStats() const;
50
51 // Збереження/Завантаження
52 bool save(const QString& filePath);
53 bool load(const QString& filePath);
54
58 void setStrategy(std::unique_ptr<IStorageStrategy> newStrategy);
59
60private:
61 QList<Schema> m_schemas;
62 QList<Note> m_notes;
63 QMap<QString, int> m_usageStats;
64 std::unique_ptr<IStorageStrategy> m_strategy;
65};
Центральний репозиторій для керування даними (Repository Pattern).
Definition note_repository.h:26
void setStrategy(std::unique_ptr< IStorageStrategy > newStrategy)
Змінює стратегію збереження "на льоту".
Definition note_repository.cpp:112
Модель даних для однієї нотатки.
Definition note.h:19
Модель даних для шаблону (схеми) нотатки.
Definition schema.h:28