annotate include/gui/pages/anime_list.h @ 9:5c0397762b53

INCOMPLETE: megacommit :)
author Paper <mrpapersonic@gmail.com>
date Sun, 10 Sep 2023 03:59:16 -0400
parents src/include/anime_list.h@07a9095eaeed
children 4b198a111713
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
1 #ifndef __gui__pages__anime_list_h
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
2 #define __gui__pages__anime_list_h
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
3 #include "core/anime.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
4 #include <QAbstractListModel>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
5 #include <QSortFilterProxyModel>
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include <QStyledItemDelegate>
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include <QTreeView>
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 #include <QWidget>
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
9 #include <vector>
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 class AnimeListWidgetDelegate : public QStyledItemDelegate {
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
12 Q_OBJECT
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 public:
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
15 explicit AnimeListWidgetDelegate(QObject* parent);
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
17 QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const override;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
18 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 };
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
21 class AnimeListWidgetSortFilter : public QSortFilterProxyModel {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
22 Q_OBJECT
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 public:
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
25 AnimeListWidgetSortFilter(QObject* parent = nullptr);
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 protected:
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
28 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override;
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 };
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 class AnimeListWidgetModel : public QAbstractListModel {
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 Q_OBJECT
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 public:
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 enum columns {
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 AL_TITLE,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 AL_PROGRESS,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 AL_EPISODES,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 AL_SCORE,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 AL_AVG_SCORE,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 AL_TYPE,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42 AL_SEASON,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43 AL_STARTED,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 AL_COMPLETED,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 AL_UPDATED,
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 AL_NOTES,
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
47 AL_ID, /* Note: This is only used in Qt::UserRole to make my life easier */
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
48
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 NB_COLUMNS
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50 };
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
51
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
52 AnimeListWidgetModel(QWidget* parent);
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 ~AnimeListWidgetModel() override = default;
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
54 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
55 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
56 QVariant data(const QModelIndex& index, int role) const override;
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
58 void UpdateAnime(int id);
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 };
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61 /* todo: rename these to "page" or something more
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
62 sensible than "widget" */
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63 class AnimeListWidget : public QWidget {
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 Q_OBJECT
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66 public:
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
67 AnimeListWidget(QWidget* parent);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
68 void UpdateAnimeList();
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
69 void Reset();
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
70
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71 protected:
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72 void paintEvent(QPaintEvent*) override;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
73 void InitStyle(QStyleOptionTabWidgetFrame* option) const;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
74 void InitBasicStyle(QStyleOptionTabWidgetFrame* option) const;
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75 void SetupLayout();
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 void showEvent(QShowEvent*) override;
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77 void resizeEvent(QResizeEvent* e) override;
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
78
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79 private slots:
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80 void DisplayColumnHeaderMenu();
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81 void DisplayListMenu();
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
82 void ItemDoubleClicked();
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83 void SetColumnDefaults();
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
84 int VisibleColumnsCount() const;
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
86 private:
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
87 QTabBar* tab_bar;
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
88 QTreeView* tree_view;
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
89 QRect panelRect;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
90 AnimeListWidgetSortFilter* sort_models[5];
7
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 };
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
92 #endif // __gui__pages__anime_list_h