annotate include/gui/pages/anime_list.h @ 95:8043152ef9d4

include: set classes as final where appropriate
author Paper <mrpapersonic@gmail.com>
date Wed, 01 Nov 2023 14:39:43 -0400
parents c69230dc2b5d
children 2004b41d4a59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
1 #ifndef __gui__pages__anime_list_h
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
2 #define __gui__pages__anime_list_h
85
c69230dc2b5d *: cleanup includes
Paper <mrpapersonic@gmail.com>
parents: 83
diff changeset
3
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
4 #include "core/anime.h"
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
5 #include <QAbstractListModel>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
6 #include <QSortFilterProxyModel>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
7 #include <QStyledItemDelegate>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
8 #include <QWidget>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
9 #include <vector>
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
10
85
c69230dc2b5d *: cleanup includes
Paper <mrpapersonic@gmail.com>
parents: 83
diff changeset
11 class QTreeView;
c69230dc2b5d *: cleanup includes
Paper <mrpapersonic@gmail.com>
parents: 83
diff changeset
12 class QTabBar;
c69230dc2b5d *: cleanup includes
Paper <mrpapersonic@gmail.com>
parents: 83
diff changeset
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
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
15 Q_OBJECT
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
16
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
17 public:
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
18 explicit AnimeListPageDelegate(QObject* parent);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
19
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
20 QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const override;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
21 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
22 };
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
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
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
25 Q_OBJECT
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
26
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
27 public:
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
28 AnimeListPageSortFilter(QObject* parent = nullptr);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
29
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
30 protected:
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
31 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
32 };
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
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
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
35 Q_OBJECT
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
36
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
37 public:
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
38 enum columns {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
39 AL_TITLE,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
40 AL_PROGRESS,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
41 AL_EPISODES,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
42 AL_SCORE,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
43 AL_AVG_SCORE,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
44 AL_TYPE,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
45 AL_SEASON,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
46 AL_STARTED,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
47 AL_COMPLETED,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
48 AL_UPDATED,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
49 AL_NOTES,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
50
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
51 NB_COLUMNS
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
52 };
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
53
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
54 AnimeListPageModel(QWidget* parent, Anime::ListStatus _status);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
55 ~AnimeListPageModel() override = default;
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
56 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
57 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
58 QVariant data(const QModelIndex& index, int role) const override;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
59 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
60 void RefreshList();
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
61 Anime::Anime* GetAnimeFromIndex(QModelIndex index);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
62
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
63 private:
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
64 Anime::ListStatus status;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
65 std::vector<Anime::Anime> list;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
66 };
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
67
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
68 /* todo: rename these to "page" or something more
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
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
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
71 Q_OBJECT
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
72
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
73 public:
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
74 AnimeListPage(QWidget* parent);
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
75 void Refresh();
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
76 void Reset();
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
77
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
78 protected:
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
79 void paintEvent(QPaintEvent*) override;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
80 void InitStyle(QStyleOptionTabWidgetFrame* option) const;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
81 void InitBasicStyle(QStyleOptionTabWidgetFrame* option) const;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
82 void SetupLayout();
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
83 void showEvent(QShowEvent*) override;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
84 void resizeEvent(QResizeEvent* e) override;
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
85 void RefreshList();
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
86 void RefreshTabs();
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
87 void UpdateAnime(int id);
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
88 void RemoveAnime(int id);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
89
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
90 private slots:
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
91 void DisplayColumnHeaderMenu();
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
92 void DisplayListMenu();
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
93 void ItemDoubleClicked();
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
94 void SetColumnDefaults();
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
95 int VisibleColumnsCount() const;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
96
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
97 private:
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
98 QTabBar* tab_bar;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
99 QTreeView* tree_view;
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
100 QRect panelRect;
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
101 std::array<AnimeListPageSortFilter*, 5> sort_models;
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
102 };
85
c69230dc2b5d *: cleanup includes
Paper <mrpapersonic@gmail.com>
parents: 83
diff changeset
103
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
104 #endif // __gui__pages__anime_list_h