diff src/include/anime.h @ 6:1d82f6e04d7d

Update: add first parts to the settings dialog
author Paper <mrpapersonic@gmail.com>
date Wed, 16 Aug 2023 00:49:17 -0400
parents 5af270662505
children 07a9095eaeed
line wrap: on
line diff
--- a/src/include/anime.h	Sat Aug 12 13:10:34 2023 -0400
+++ b/src/include/anime.h	Wed Aug 16 00:49:17 2023 -0400
@@ -2,8 +2,11 @@
 #define __anime_h
 #include <vector>
 #include <map>
+#include <QStyledItemDelegate>
+#include <QProgressBar>
 #include "date.h"
 #include "window.h"
+#include "progress.h"
 
 enum AnimeWatchingStatus {
 	CURRENT,
@@ -54,14 +57,14 @@
 		Date started;
 		Date completed;
 		int updated; /* this should be 64-bit */
-		std::wstring notes;
+		std::string notes;
 
 		/* Useful information */
 		int id;
 		struct {
-			std::wstring romaji;
-			std::wstring english;
-			std::wstring native;
+			std::string romaji;
+			std::string english;
+			std::string native;
 		} title;
 		int episodes;
 		enum AnimeAiringStatus airing;
@@ -71,8 +74,10 @@
 		enum AnimeFormat type;
 		enum AnimeSeason season;
 		int audience_score;
-		std::wstring synopsis;
+		std::string synopsis;
 		int duration;
+		
+		std::string GetUserPreferredTitle();
 };
 
 /* This is a simple wrapper on a vector that provides 
@@ -96,19 +101,44 @@
 		bool AnimeInList(int id);
 		Anime& operator[](size_t index);
 		const Anime& operator[](size_t index) const;
-		std::wstring name;
+		std::string name;
 
-	private:
+	protected:
 		std::vector<Anime> anime_list;
 		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,
@@ -123,7 +153,6 @@
 
 		AnimeListWidgetModel(QWidget* parent, AnimeList* alist);
 		~AnimeListWidgetModel() override = default;
-		//QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const;
 		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;
@@ -150,6 +179,7 @@
 
 	private:
 		AnimeListWidgetModel* model = nullptr;
+		AnimeListWidgetSortFilter* sort_model = nullptr;
 };
 
 class AnimeListPage : public QTabWidget {