comparison include/gui/pages/anime_list.h @ 258:862d0d8619f6

*: HUUUGE changes animia has been renamed to animone, so instead of thinking of a health condition, you think of a beautiful flower :) I've also edited some of the code for animone, but I have no idea if it even works or not because I don't have a mac or windows machine lying around. whoops! ... anyway, all of the changes divergent from Anisthesia are now licensed under BSD. it's possible that I could even rewrite most of the code to where I don't even have to keep the MIT license, but that's thinking too far into the future I've been slacking off on implementing the anime seasons page, mostly out of laziness. I think I'd have to create another db file specifically for the seasons anyway, this code is being pushed *primarily* because the hard drive it's on is failing! yay :)
author Paper <paper@paper.us.eu.org>
date Mon, 01 Apr 2024 02:43:44 -0400
parents ab191e28e69d
children 3ec7804abf17
comparison
equal deleted inserted replaced
257:699a20c57dc8 258:862d0d8619f6
10 10
11 class QTreeView; 11 class QTreeView;
12 class QTabBar; 12 class QTabBar;
13 13
14 class AnimeListPageSortFilter final : public QSortFilterProxyModel { 14 class AnimeListPageSortFilter final : public QSortFilterProxyModel {
15 Q_OBJECT 15 Q_OBJECT
16 16
17 public: 17 public:
18 AnimeListPageSortFilter(QObject* parent = nullptr); 18 AnimeListPageSortFilter(QObject* parent = nullptr);
19 19
20 protected: 20 protected:
21 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; 21 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override;
22 }; 22 };
23 23
24 class AnimeListPageModel final : public QAbstractListModel { 24 class AnimeListPageModel final : public QAbstractListModel {
25 Q_OBJECT 25 Q_OBJECT
26 26
27 public: 27 public:
28 enum columns { 28 enum columns {
29 AL_TITLE, 29 AL_TITLE,
30 AL_PROGRESS, 30 AL_PROGRESS,
31 AL_EPISODES, 31 AL_EPISODES,
32 AL_SCORE, 32 AL_SCORE,
33 AL_AVG_SCORE, 33 AL_AVG_SCORE,
34 AL_TYPE, 34 AL_TYPE,
35 AL_SEASON, 35 AL_SEASON,
36 AL_STARTED, 36 AL_STARTED,
37 AL_COMPLETED, 37 AL_COMPLETED,
38 AL_UPDATED, 38 AL_UPDATED,
39 AL_NOTES, 39 AL_NOTES,
40 40
41 NB_COLUMNS 41 NB_COLUMNS
42 }; 42 };
43 43
44 AnimeListPageModel(QObject* parent, Anime::ListStatus _status); 44 AnimeListPageModel(QObject* parent, Anime::ListStatus _status);
45 ~AnimeListPageModel() override = default; 45 ~AnimeListPageModel() override = default;
46 int rowCount(const QModelIndex& parent = QModelIndex()) const override; 46 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
47 int columnCount(const QModelIndex& parent = QModelIndex()) const override; 47 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
48 QVariant data(const QModelIndex& index, int role) const override; 48 QVariant data(const QModelIndex& index, int role) const override;
49 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; 49 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override;
50 void RefreshList(); 50 void RefreshList();
51 Anime::Anime* GetAnimeFromIndex(QModelIndex index); 51 Anime::Anime* GetAnimeFromIndex(QModelIndex index);
52 52
53 private: 53 private:
54 Anime::ListStatus status; 54 Anime::ListStatus status;
55 std::vector<Anime::Anime> list; 55 std::vector<Anime::Anime> list;
56 }; 56 };
57 57
58 /* todo: rename these to "page" or something more 58 /* todo: rename these to "page" or something more
59 sensible than "widget" */ 59 sensible than "widget" */
60 class AnimeListPage final : public QWidget { 60 class AnimeListPage final : public QWidget {
61 Q_OBJECT 61 Q_OBJECT
62 62
63 public: 63 public:
64 AnimeListPage(QWidget* parent); 64 AnimeListPage(QWidget* parent);
65 void Refresh(); 65 void Refresh();
66 66
67 protected: 67 protected:
68 void paintEvent(QPaintEvent*) override; 68 void paintEvent(QPaintEvent*) override;
69 void InitStyle(QStyleOptionTabWidgetFrame* option) const; 69 void InitStyle(QStyleOptionTabWidgetFrame* option) const;
70 void InitBasicStyle(QStyleOptionTabWidgetFrame* option) const; 70 void InitBasicStyle(QStyleOptionTabWidgetFrame* option) const;
71 void SetupLayout(); 71 void SetupLayout();
72 void showEvent(QShowEvent*) override; 72 void showEvent(QShowEvent*) override;
73 void resizeEvent(QResizeEvent* e) override; 73 void resizeEvent(QResizeEvent* e) override;
74 void RefreshList(); 74 void RefreshList();
75 void RefreshTabs(); 75 void RefreshTabs();
76 void UpdateAnime(int id); 76 void UpdateAnime(int id);
77 void RemoveAnime(int id); 77 void RemoveAnime(int id);
78 78
79 private slots: 79 private slots:
80 void DisplayColumnHeaderMenu(); 80 void DisplayColumnHeaderMenu();
81 void DisplayListMenu(); 81 void DisplayListMenu();
82 void ItemDoubleClicked(); 82 void ItemDoubleClicked();
83 void SetColumnDefaults(); 83 void SetColumnDefaults();
84 int VisibleColumnsCount() const; 84 int VisibleColumnsCount() const;
85 85
86 private: 86 private:
87 QTabBar* tab_bar; 87 QTabBar* tab_bar;
88 QTreeView* tree_view; 88 QTreeView* tree_view;
89 QRect panelRect; 89 QRect panelRect;
90 std::array<AnimeListPageSortFilter*, 5> sort_models; 90 std::array<AnimeListPageSortFilter*, 5> sort_models;
91 }; 91 };
92 92
93 #endif // __gui__pages__anime_list_h 93 #endif // __gui__pages__anime_list_h