Mercurial > minori
annotate include/gui/pages/anime_list.h @ 108:2004b41d4a59
*: huge commit
1. WORKING LOCALIZATION + translation for Spanish and British English
2. idk like 2 changes for the dark theme :)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 05 Nov 2023 23:31:49 -0500 |
parents | 8043152ef9d4 |
children | ab191e28e69d |
rev | line source |
---|---|
10 | 1 #ifndef __gui__pages__anime_list_h |
2 #define __gui__pages__anime_list_h | |
85 | 3 |
10 | 4 #include "core/anime.h" |
5 #include <QAbstractListModel> | |
6 #include <QSortFilterProxyModel> | |
7 #include <QStyledItemDelegate> | |
8 #include <QWidget> | |
9 #include <vector> | |
10 | |
85 | 11 class QTreeView; |
12 class QTabBar; | |
13 | |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
14 class AnimeListPageSortFilter final : public QSortFilterProxyModel { |
63 | 15 Q_OBJECT |
10 | 16 |
17 public: | |
64 | 18 AnimeListPageSortFilter(QObject* parent = nullptr); |
10 | 19 |
20 protected: | |
21 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; | |
22 }; | |
23 | |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
24 class AnimeListPageModel final : public QAbstractListModel { |
63 | 25 Q_OBJECT |
10 | 26 |
27 public: | |
28 enum columns { | |
29 AL_TITLE, | |
30 AL_PROGRESS, | |
31 AL_EPISODES, | |
32 AL_SCORE, | |
33 AL_AVG_SCORE, | |
34 AL_TYPE, | |
35 AL_SEASON, | |
36 AL_STARTED, | |
37 AL_COMPLETED, | |
38 AL_UPDATED, | |
39 AL_NOTES, | |
40 | |
41 NB_COLUMNS | |
42 }; | |
43 | |
64 | 44 AnimeListPageModel(QWidget* parent, Anime::ListStatus _status); |
45 ~AnimeListPageModel() override = default; | |
10 | 46 int rowCount(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; | |
49 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; | |
50 void RefreshList(); | |
51 Anime::Anime* GetAnimeFromIndex(QModelIndex index); | |
52 | |
53 private: | |
54 Anime::ListStatus status; | |
55 std::vector<Anime::Anime> list; | |
56 }; | |
57 | |
58 /* todo: rename these to "page" or something more | |
59 sensible than "widget" */ | |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
60 class AnimeListPage final : public QWidget { |
63 | 61 Q_OBJECT |
10 | 62 |
63 public: | |
64 | 64 AnimeListPage(QWidget* parent); |
15 | 65 void Refresh(); |
10 | 66 void Reset(); |
67 | |
68 protected: | |
69 void paintEvent(QPaintEvent*) override; | |
70 void InitStyle(QStyleOptionTabWidgetFrame* option) const; | |
71 void InitBasicStyle(QStyleOptionTabWidgetFrame* option) const; | |
72 void SetupLayout(); | |
73 void showEvent(QShowEvent*) override; | |
74 void resizeEvent(QResizeEvent* e) override; | |
15 | 75 void RefreshList(); |
76 void RefreshTabs(); | |
77 | 77 void UpdateAnime(int id); |
78 void RemoveAnime(int id); | |
10 | 79 |
80 private slots: | |
81 void DisplayColumnHeaderMenu(); | |
82 void DisplayListMenu(); | |
83 void ItemDoubleClicked(); | |
84 void SetColumnDefaults(); | |
85 int VisibleColumnsCount() const; | |
86 | |
87 private: | |
88 QTabBar* tab_bar; | |
89 QTreeView* tree_view; | |
90 QRect panelRect; | |
83 | 91 std::array<AnimeListPageSortFilter*, 5> sort_models; |
10 | 92 }; |
85 | 93 |
9 | 94 #endif // __gui__pages__anime_list_h |