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