Mercurial > minori
annotate include/gui/pages/anime_list.h @ 339:eac06513db86
dialog/about: add licenses button
otherwise we wouldn't be complying with most of the libraries
and external software we use
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 19 Jun 2024 14:02:11 -0400 |
parents | 1b5c04268d6a |
children |
rev | line source |
---|---|
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
1 #ifndef MINORI_GUI_PAGES_ANIME_LIST_H_ |
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
2 #define MINORI_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> | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
9 #include <QThread> |
10 | 10 #include <vector> |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
11 #include <queue> |
10 | 12 |
85 | 13 class QTreeView; |
14 class QTabBar; | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
15 class AnimeListPage; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
16 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
17 class AnimeListPageUpdateEntryThread final : public QThread { |
307
8769c5d50b06
pages/anime_list: don't call GUI functions in a non-GUI thread
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
18 Q_OBJECT |
8769c5d50b06
pages/anime_list: don't call GUI functions in a non-GUI thread
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
19 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
20 public: |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
307
diff
changeset
|
21 AnimeListPageUpdateEntryThread(QObject* parent = nullptr); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
22 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
23 void AddToQueue(int id); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
24 |
307
8769c5d50b06
pages/anime_list: don't call GUI functions in a non-GUI thread
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
25 signals: |
8769c5d50b06
pages/anime_list: don't call GUI functions in a non-GUI thread
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
26 void NeedRefresh(); |
8769c5d50b06
pages/anime_list: don't call GUI functions in a non-GUI thread
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
27 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
28 protected: |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
29 void run() override; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
30 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
31 private: |
320
1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents:
307
diff
changeset
|
32 std::mutex queue_mutex_; |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
33 std::queue<int> queue_; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
34 }; |
85 | 35 |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
36 class AnimeListPageSortFilter final : public QSortFilterProxyModel { |
258 | 37 Q_OBJECT |
10 | 38 |
258 | 39 public: |
40 AnimeListPageSortFilter(QObject* parent = nullptr); | |
10 | 41 |
258 | 42 protected: |
43 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; | |
10 | 44 }; |
45 | |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
46 class AnimeListPageModel final : public QAbstractListModel { |
258 | 47 Q_OBJECT |
10 | 48 |
258 | 49 public: |
50 enum columns { | |
51 AL_TITLE, | |
52 AL_PROGRESS, | |
53 AL_EPISODES, | |
54 AL_SCORE, | |
55 AL_AVG_SCORE, | |
56 AL_TYPE, | |
57 AL_SEASON, | |
58 AL_STARTED, | |
59 AL_COMPLETED, | |
60 AL_UPDATED, | |
61 AL_NOTES, | |
10 | 62 |
258 | 63 NB_COLUMNS |
64 }; | |
10 | 65 |
258 | 66 AnimeListPageModel(QObject* parent, Anime::ListStatus _status); |
67 ~AnimeListPageModel() override = default; | |
68 int rowCount(const QModelIndex& parent = QModelIndex()) const override; | |
69 int columnCount(const QModelIndex& parent = QModelIndex()) const override; | |
70 QVariant data(const QModelIndex& index, int role) const override; | |
71 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; | |
72 void RefreshList(); | |
73 Anime::Anime* GetAnimeFromIndex(QModelIndex index); | |
10 | 74 |
258 | 75 private: |
76 Anime::ListStatus status; | |
77 std::vector<Anime::Anime> list; | |
10 | 78 }; |
79 | |
95
8043152ef9d4
include: set classes as final where appropriate
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
80 class AnimeListPage final : public QWidget { |
258 | 81 Q_OBJECT |
10 | 82 |
258 | 83 public: |
291 | 84 AnimeListPage(QWidget* parent = nullptr); |
307
8769c5d50b06
pages/anime_list: don't call GUI functions in a non-GUI thread
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
85 |
8769c5d50b06
pages/anime_list: don't call GUI functions in a non-GUI thread
Paper <paper@paper.us.eu.org>
parents:
291
diff
changeset
|
86 public slots: |
258 | 87 void Refresh(); |
10 | 88 |
258 | 89 protected: |
90 void paintEvent(QPaintEvent*) override; | |
91 void InitStyle(QStyleOptionTabWidgetFrame* option) const; | |
92 void InitBasicStyle(QStyleOptionTabWidgetFrame* option) const; | |
93 void SetupLayout(); | |
94 void showEvent(QShowEvent*) override; | |
95 void resizeEvent(QResizeEvent* e) override; | |
96 void RefreshList(); | |
97 void RefreshTabs(); | |
98 void UpdateAnime(int id); | |
99 void RemoveAnime(int id); | |
10 | 100 |
258 | 101 private slots: |
102 void DisplayColumnHeaderMenu(); | |
103 void DisplayListMenu(); | |
104 void ItemDoubleClicked(); | |
105 void SetColumnDefaults(); | |
106 int VisibleColumnsCount() const; | |
10 | 107 |
258 | 108 private: |
109 QTabBar* tab_bar; | |
110 QTreeView* tree_view; | |
111 QRect panelRect; | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
112 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
113 AnimeListPageUpdateEntryThread update_entry_thread_; |
258 | 114 std::array<AnimeListPageSortFilter*, 5> sort_models; |
10 | 115 }; |
85 | 116 |
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
117 #endif // MINORI_GUI_PAGES_ANIME_LIST_H_ |