comparison include/gui/pages/anime_list.h @ 64:fe719c109dbc

*: update 1. add media tracking ability, and it displays info on the `now playing` page 2. the `now playing` page now actually shows something 3. renamed every page class to be more accurate to what it is 4. ...
author Paper <mrpapersonic@gmail.com>
date Sun, 01 Oct 2023 23:15:43 -0400
parents 3d2decf093bb
children 6f7385bd334c
comparison
equal deleted inserted replaced
63:3d2decf093bb 64:fe719c109dbc
6 #include <QStyledItemDelegate> 6 #include <QStyledItemDelegate>
7 #include <QTreeView> 7 #include <QTreeView>
8 #include <QWidget> 8 #include <QWidget>
9 #include <vector> 9 #include <vector>
10 10
11 class AnimeListWidgetDelegate : public QStyledItemDelegate { 11 class AnimeListPageDelegate : public QStyledItemDelegate {
12 Q_OBJECT 12 Q_OBJECT
13 13
14 public: 14 public:
15 explicit AnimeListWidgetDelegate(QObject* parent); 15 explicit AnimeListPageDelegate(QObject* parent);
16 16
17 QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const override; 17 QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const override;
18 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; 18 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
19 }; 19 };
20 20
21 class AnimeListWidgetSortFilter : public QSortFilterProxyModel { 21 class AnimeListPageSortFilter : public QSortFilterProxyModel {
22 Q_OBJECT 22 Q_OBJECT
23 23
24 public: 24 public:
25 AnimeListWidgetSortFilter(QObject* parent = nullptr); 25 AnimeListPageSortFilter(QObject* parent = nullptr);
26 26
27 protected: 27 protected:
28 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; 28 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override;
29 }; 29 };
30 30
31 class AnimeListWidgetModel : public QAbstractListModel { 31 class AnimeListPageModel : public QAbstractListModel {
32 Q_OBJECT 32 Q_OBJECT
33 33
34 public: 34 public:
35 enum columns { 35 enum columns {
36 AL_TITLE, 36 AL_TITLE,
46 AL_NOTES, 46 AL_NOTES,
47 47
48 NB_COLUMNS 48 NB_COLUMNS
49 }; 49 };
50 50
51 AnimeListWidgetModel(QWidget* parent, Anime::ListStatus _status); 51 AnimeListPageModel(QWidget* parent, Anime::ListStatus _status);
52 ~AnimeListWidgetModel() override = default; 52 ~AnimeListPageModel() override = default;
53 int rowCount(const QModelIndex& parent = QModelIndex()) const override; 53 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
54 int columnCount(const QModelIndex& parent = QModelIndex()) const override; 54 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
55 QVariant data(const QModelIndex& index, int role) const override; 55 QVariant data(const QModelIndex& index, int role) const override;
56 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; 56 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override;
57 void UpdateAnime(int id); 57 void UpdateAnime(int id);
63 std::vector<Anime::Anime> list; 63 std::vector<Anime::Anime> list;
64 }; 64 };
65 65
66 /* todo: rename these to "page" or something more 66 /* todo: rename these to "page" or something more
67 sensible than "widget" */ 67 sensible than "widget" */
68 class AnimeListWidget : public QWidget { 68 class AnimeListPage : public QWidget {
69 Q_OBJECT 69 Q_OBJECT
70 70
71 public: 71 public:
72 AnimeListWidget(QWidget* parent); 72 AnimeListPage(QWidget* parent);
73 void Refresh(); 73 void Refresh();
74 void Reset(); 74 void Reset();
75 75
76 protected: 76 protected:
77 void paintEvent(QPaintEvent*) override; 77 void paintEvent(QPaintEvent*) override;
92 92
93 private: 93 private:
94 QTabBar* tab_bar; 94 QTabBar* tab_bar;
95 QTreeView* tree_view; 95 QTreeView* tree_view;
96 QRect panelRect; 96 QRect panelRect;
97 AnimeListWidgetSortFilter* sort_models[5]; 97 AnimeListPageSortFilter* sort_models[5];
98 }; 98 };
99 #endif // __gui__pages__anime_list_h 99 #endif // __gui__pages__anime_list_h