annotate 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
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 AnimeListPageSortFilter final : public QSortFilterProxyModel {
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
15 Q_OBJECT
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
16
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
17 public:
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
18 AnimeListPageSortFilter(QObject* parent = nullptr);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
19
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
20 protected:
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
21 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override;
10
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 AnimeListPageModel final : public QAbstractListModel {
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
25 Q_OBJECT
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
26
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
27 public:
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
28 enum columns {
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
29 AL_TITLE,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
30 AL_PROGRESS,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
31 AL_EPISODES,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
32 AL_SCORE,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
33 AL_AVG_SCORE,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
34 AL_TYPE,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
35 AL_SEASON,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
36 AL_STARTED,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
37 AL_COMPLETED,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
38 AL_UPDATED,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
39 AL_NOTES,
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
40
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
41 NB_COLUMNS
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
42 };
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
43
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
44 AnimeListPageModel(QObject* parent, Anime::ListStatus _status);
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
45 ~AnimeListPageModel() override = default;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
46 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
47 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
48 QVariant data(const QModelIndex& index, int role) const override;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
49 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
50 void RefreshList();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
51 Anime::Anime* GetAnimeFromIndex(QModelIndex index);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
52
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
53 private:
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
54 Anime::ListStatus status;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
55 std::vector<Anime::Anime> list;
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
56 };
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
57
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
58 /* todo: rename these to "page" or something more
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
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 {
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
61 Q_OBJECT
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
62
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
63 public:
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
64 AnimeListPage(QWidget* parent);
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
65 void Refresh();
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
66
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
67 protected:
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
68 void paintEvent(QPaintEvent*) override;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
69 void InitStyle(QStyleOptionTabWidgetFrame* option) const;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
70 void InitBasicStyle(QStyleOptionTabWidgetFrame* option) const;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
71 void SetupLayout();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
72 void showEvent(QShowEvent*) override;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
73 void resizeEvent(QResizeEvent* e) override;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
74 void RefreshList();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
75 void RefreshTabs();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
76 void UpdateAnime(int id);
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
77 void RemoveAnime(int id);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
78
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
79 private slots:
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
80 void DisplayColumnHeaderMenu();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
81 void DisplayListMenu();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
82 void ItemDoubleClicked();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
83 void SetColumnDefaults();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
84 int VisibleColumnsCount() const;
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
85
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
86 private:
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
87 QTabBar* tab_bar;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
88 QTreeView* tree_view;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
89 QRect panelRect;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 114
diff changeset
90 std::array<AnimeListPageSortFilter*, 5> sort_models;
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
91 };
85
c69230dc2b5d *: cleanup includes
Paper <mrpapersonic@gmail.com>
parents: 83
diff changeset
92
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
93 #endif // __gui__pages__anime_list_h