annotate src/include/anime.h @ 4:5af270662505

Set override functions as override
author Paper <mrpapersonic@gmail.com>
date Sat, 12 Aug 2023 12:08:16 -0400
parents 23d0d9319a00
children 1d82f6e04d7d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
1 #ifndef __anime_h
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
2 #define __anime_h
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
3 #include <vector>
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
4 #include <map>
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
5 #include "date.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
6 #include "window.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
7
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
8 enum AnimeWatchingStatus {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
9 CURRENT,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
10 PLANNING,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
11 COMPLETED,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
12 DROPPED,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
13 PAUSED,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
14 REPEATING
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
15 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
16
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
17 enum AnimeAiringStatus {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
18 FINISHED,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
19 RELEASING,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
20 NOT_YET_RELEASED,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
21 CANCELLED,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
22 HIATUS
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
23 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
24
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
25 enum AnimeFormat {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
26 TV,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
27 TV_SHORT,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
28 MOVIE,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
29 SPECIAL,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
30 OVA,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
31 ONA,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
32 MUSIC,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
33 MANGA,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
34 NOVEL,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
35 ONE_SHOT
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
36 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
37
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
38 enum AnimeSeason {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
39 UNKNOWN,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
40 WINTER,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
41 SPRING,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
42 SUMMER,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
43 FALL
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
44 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
45
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
46 class Anime {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
47 public:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
48 Anime();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
49 Anime(const Anime& a);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
50 /* List-specific data */
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
51 enum AnimeWatchingStatus status;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
52 int progress;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
53 int score;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
54 Date started;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
55 Date completed;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
56 int updated; /* this should be 64-bit */
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
57 std::wstring notes;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
58
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
59 /* Useful information */
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
60 int id;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
61 struct {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
62 std::wstring romaji;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
63 std::wstring english;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
64 std::wstring native;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
65 } title;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
66 int episodes;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
67 enum AnimeAiringStatus airing;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
68 Date air_date;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
69 std::vector<std::string> genres;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
70 std::vector<std::string> producers;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
71 enum AnimeFormat type;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
72 enum AnimeSeason season;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
73 int audience_score;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
74 std::wstring synopsis;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
75 int duration;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
76 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
77
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
78 /* This is a simple wrapper on a vector that provides
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
79 methods to make it easier to search the list. */
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
80 class AnimeList {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
81 public:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
82 AnimeList();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
83 AnimeList(const AnimeList& l);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
84 ~AnimeList();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
85 void Add(Anime& anime);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
86 void Insert(size_t pos, Anime& anime);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
87 void Delete(size_t index);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
88 void Clear();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
89 std::vector<Anime>::iterator begin() noexcept;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
90 std::vector<Anime>::iterator end() noexcept;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
91 std::vector<Anime>::const_iterator cbegin() noexcept;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
92 std::vector<Anime>::const_iterator cend() noexcept;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
93 size_t Size() const;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
94 Anime* AnimeById(int id);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
95 int GetAnimeIndex(Anime& anime) const;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
96 bool AnimeInList(int id);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
97 Anime& operator[](size_t index);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
98 const Anime& operator[](size_t index) const;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
99 std::wstring name;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
100
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
101 private:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
102 std::vector<Anime> anime_list;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
103 std::map<int, Anime*> anime_id_to_anime;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
104 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
105
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
106 class AnimeListWidgetModel : public QAbstractListModel {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
107 Q_OBJECT
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
108 public:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
109 enum columns {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
110 AL_TITLE,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
111 AL_PROGRESS,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
112 AL_SCORE,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
113 AL_AVG_SCORE,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
114 AL_TYPE,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
115 AL_SEASON,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
116 AL_STARTED,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
117 AL_COMPLETED,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
118 AL_UPDATED,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
119 AL_NOTES,
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
120
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
121 NB_COLUMNS
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
122 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
123
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
124 AnimeListWidgetModel(QWidget* parent, AnimeList* alist);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
125 ~AnimeListWidgetModel() override = default;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
126 //QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const;
4
5af270662505 Set override functions as override
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
127 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
5af270662505 Set override functions as override
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
128 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
5af270662505 Set override functions as override
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
129 QVariant data(const QModelIndex& index, int role) const override;
5af270662505 Set override functions as override
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
130 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override;
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
131 Anime* GetAnimeFromIndex(const QModelIndex& index);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
132 void UpdateAnime(Anime& anime);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
133
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
134 private:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
135 //void AddAnime(AnimeList& list);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
136 AnimeList& list;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
137 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
138
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
139 class AnimeListWidget : public QTreeView {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
140 Q_OBJECT
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
141 public:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
142 AnimeListWidget(QWidget* parent, AnimeList* alist);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
143
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
144 private slots:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
145 void DisplayColumnHeaderMenu();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
146 void DisplayListMenu();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
147 void ItemDoubleClicked();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
148 void SetColumnDefaults();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
149 int VisibleColumnsCount() const;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
150
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
151 private:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
152 AnimeListWidgetModel* model = nullptr;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
153 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
154
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
155 class AnimeListPage : public QTabWidget {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
156 public:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
157 AnimeListPage(QWidget* parent = nullptr);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
158 void SyncAnimeList();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
159 void FreeAnimeList();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
160 int GetTotalAnimeAmount();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
161 int GetTotalEpisodeAmount();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
162 int GetTotalWatchedAmount();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
163 int GetTotalPlannedAmount();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
164 double GetAverageScore();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
165 double GetScoreDeviation();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
166
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
167 private:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
168 std::vector<AnimeList> anime_lists;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
169 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
170
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
171 extern std::map<enum AnimeSeason, std::string> AnimeSeasonToStringMap;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
172 extern std::map<enum AnimeFormat, std::string> AnimeFormatToStringMap;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
173 extern std::map<enum AnimeWatchingStatus, std::string> AnimeWatchingToStringMap;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
174 extern std::map<enum AnimeAiringStatus, std::string> AnimeAiringToStringMap;
1
1ae666fdf9e2 *: initial commit
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
175 #endif // __anime_h