Mercurial > minori
annotate include/gui/pages/anime_list.h @ 101:c537996cf67b
*: multitude of config changes
1. theme is now configurable from the settings menu
(but you have to restart for it to apply)
2. config is now stored in an INI file, with no method of
conversion from json (this repo is private-ish anyway)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Fri, 03 Nov 2023 14:06:02 -0400 |
parents | 8043152ef9d4 |
children | 2004b41d4a59 |
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 AnimeListPageDelegate final : public QStyledItemDelegate { |
63 | 15 Q_OBJECT |
10 | 16 |
17 public: | |
64 | 18 explicit AnimeListPageDelegate(QObject* parent); |
10 | 19 |
20 QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const override; | |
21 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; | |
22 }; | |
23 | |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
24 class AnimeListPageSortFilter final : public QSortFilterProxyModel { |
63 | 25 Q_OBJECT |
10 | 26 |
27 public: | |
64 | 28 AnimeListPageSortFilter(QObject* parent = nullptr); |
10 | 29 |
30 protected: | |
31 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; | |
32 }; | |
33 | |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
34 class AnimeListPageModel final : public QAbstractListModel { |
63 | 35 Q_OBJECT |
10 | 36 |
37 public: | |
38 enum columns { | |
39 AL_TITLE, | |
40 AL_PROGRESS, | |
41 AL_EPISODES, | |
42 AL_SCORE, | |
43 AL_AVG_SCORE, | |
44 AL_TYPE, | |
45 AL_SEASON, | |
46 AL_STARTED, | |
47 AL_COMPLETED, | |
48 AL_UPDATED, | |
49 AL_NOTES, | |
50 | |
51 NB_COLUMNS | |
52 }; | |
53 | |
64 | 54 AnimeListPageModel(QWidget* parent, Anime::ListStatus _status); |
55 ~AnimeListPageModel() override = default; | |
10 | 56 int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
57 int columnCount(const QModelIndex& parent = QModelIndex()) const override; | |
58 QVariant data(const QModelIndex& index, int role) const override; | |
59 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; | |
60 void RefreshList(); | |
61 Anime::Anime* GetAnimeFromIndex(QModelIndex index); | |
62 | |
63 private: | |
64 Anime::ListStatus status; | |
65 std::vector<Anime::Anime> list; | |
66 }; | |
67 | |
68 /* todo: rename these to "page" or something more | |
69 sensible than "widget" */ | |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
70 class AnimeListPage final : public QWidget { |
63 | 71 Q_OBJECT |
10 | 72 |
73 public: | |
64 | 74 AnimeListPage(QWidget* parent); |
15 | 75 void Refresh(); |
10 | 76 void Reset(); |
77 | |
78 protected: | |
79 void paintEvent(QPaintEvent*) override; | |
80 void InitStyle(QStyleOptionTabWidgetFrame* option) const; | |
81 void InitBasicStyle(QStyleOptionTabWidgetFrame* option) const; | |
82 void SetupLayout(); | |
83 void showEvent(QShowEvent*) override; | |
84 void resizeEvent(QResizeEvent* e) override; | |
15 | 85 void RefreshList(); |
86 void RefreshTabs(); | |
77 | 87 void UpdateAnime(int id); |
88 void RemoveAnime(int id); | |
10 | 89 |
90 private slots: | |
91 void DisplayColumnHeaderMenu(); | |
92 void DisplayListMenu(); | |
93 void ItemDoubleClicked(); | |
94 void SetColumnDefaults(); | |
95 int VisibleColumnsCount() const; | |
96 | |
97 private: | |
98 QTabBar* tab_bar; | |
99 QTreeView* tree_view; | |
100 QRect panelRect; | |
83 | 101 std::array<AnimeListPageSortFilter*, 5> sort_models; |
10 | 102 }; |
85 | 103 |
9 | 104 #endif // __gui__pages__anime_list_h |