diff src/include/anime.h @ 7:07a9095eaeed

Update Refactored some code, moved some around
author Paper <mrpapersonic@gmail.com>
date Thu, 24 Aug 2023 23:11:38 -0400
parents 1d82f6e04d7d
children
line wrap: on
line diff
--- a/src/include/anime.h	Wed Aug 16 00:49:17 2023 -0400
+++ b/src/include/anime.h	Thu Aug 24 23:11:38 2023 -0400
@@ -2,8 +2,6 @@
 #define __anime_h
 #include <vector>
 #include <map>
-#include <QStyledItemDelegate>
-#include <QProgressBar>
 #include "date.h"
 #include "window.h"
 #include "progress.h"
@@ -66,6 +64,7 @@
 			std::string english;
 			std::string native;
 		} title;
+		std::vector<std::string> synonyms;
 		int episodes;
 		enum AnimeAiringStatus airing;
 		Date air_date;
@@ -78,6 +77,7 @@
 		int duration;
 		
 		std::string GetUserPreferredTitle();
+		std::vector<std::string> GetTitleSynonyms();
 };
 
 /* This is a simple wrapper on a vector that provides 
@@ -86,6 +86,7 @@
 	public:
 		AnimeList();
 		AnimeList(const AnimeList& l);
+		AnimeList& operator=(const AnimeList& l);
 		~AnimeList();
 		void Add(Anime& anime);
 		void Insert(size_t pos, Anime& anime);
@@ -108,96 +109,6 @@
 		std::map<int, Anime*> anime_id_to_anime;
 };
 
-class AnimeListWidgetDelegate : public QStyledItemDelegate {
-    Q_OBJECT
-
-	public:
-		explicit AnimeListWidgetDelegate(QObject *parent);
-
-		QWidget *createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const override;
-		void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
-
-	protected:
-		AnimeProgressBar progress_bar;
-};
-
-class AnimeListWidgetSortFilter : public QSortFilterProxyModel
-{
-    Q_OBJECT
-
-	public:
-		AnimeListWidgetSortFilter(QObject *parent = nullptr);
-
-	protected:
-		bool lessThan(const QModelIndex &l, const QModelIndex &r) const override;
-};
-
-class AnimeListWidgetModel : public QAbstractListModel {
-	Q_OBJECT
-	public:
-		enum columns {
-			AL_TITLE,
-			AL_PROGRESS,
-			AL_EPISODES,
-			AL_SCORE,
-			AL_AVG_SCORE,
-			AL_TYPE,
-			AL_SEASON,
-			AL_STARTED,
-			AL_COMPLETED,
-			AL_UPDATED,
-			AL_NOTES,
-			
-			NB_COLUMNS
-		};
-
-		AnimeListWidgetModel(QWidget* parent, AnimeList* alist);
-		~AnimeListWidgetModel() override = default;
-		int rowCount(const QModelIndex& parent = QModelIndex()) const override;
-		int columnCount(const QModelIndex& parent = QModelIndex()) const override;
-		QVariant data(const QModelIndex& index, int role) const override;
-		QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override;
-		Anime* GetAnimeFromIndex(const QModelIndex& index);
-		void UpdateAnime(Anime& anime);
-
-	private:
-		//void AddAnime(AnimeList& list);
-		AnimeList& list;
-};
-
-class AnimeListWidget : public QTreeView {
-	Q_OBJECT
-	public:
-		AnimeListWidget(QWidget* parent, AnimeList* alist);
-
-	private slots:
-		void DisplayColumnHeaderMenu();
-		void DisplayListMenu();
-		void ItemDoubleClicked();
-		void SetColumnDefaults();
-		int VisibleColumnsCount() const;
-
-	private:
-		AnimeListWidgetModel* model = nullptr;
-		AnimeListWidgetSortFilter* sort_model = nullptr;
-};
-
-class AnimeListPage : public QTabWidget {
-	public:
-		AnimeListPage(QWidget* parent = nullptr);
-		void SyncAnimeList();
-		void FreeAnimeList();
-		int GetTotalAnimeAmount();
-		int GetTotalEpisodeAmount();
-		int GetTotalWatchedAmount();
-		int GetTotalPlannedAmount();
-		double GetAverageScore();
-		double GetScoreDeviation();
-
-	private:
-		std::vector<AnimeList> anime_lists;
-};
-
 extern std::map<enum AnimeSeason, std::string> AnimeSeasonToStringMap;
 extern std::map<enum AnimeFormat, std::string> AnimeFormatToStringMap;
 extern std::map<enum AnimeWatchingStatus, std::string> AnimeWatchingToStringMap;