Mercurial > minori
comparison include/gui/pages/search.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 | c130f47f6f48 |
children | 3ec7804abf17 |
comparison
equal
deleted
inserted
replaced
257:699a20c57dc8 | 258:862d0d8619f6 |
---|---|
1 #ifndef __gui__pages__search_h | 1 #ifndef __gui__pages__search_h |
2 #define __gui__pages__search_h | 2 #define __gui__pages__search_h |
3 | 3 |
4 #include "core/anime.h" | 4 #include "core/anime.h" |
5 | 5 |
6 #include <QAbstractListModel> | |
6 #include <QFrame> | 7 #include <QFrame> |
7 #include <QAbstractListModel> | 8 #include <QItemSelection> |
8 #include <QSortFilterProxyModel> | 9 #include <QSortFilterProxyModel> |
9 #include <QItemSelection> | |
10 | 10 |
11 class QTreeView; | 11 class QTreeView; |
12 | 12 |
13 class SearchPageListSortFilter final : public QSortFilterProxyModel { | 13 class SearchPageListSortFilter final : public QSortFilterProxyModel { |
14 Q_OBJECT | 14 Q_OBJECT |
15 | 15 |
16 public: | 16 public: |
17 SearchPageListSortFilter(QObject* parent = nullptr); | 17 SearchPageListSortFilter(QObject* parent = nullptr); |
18 | 18 |
19 protected: | 19 protected: |
20 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; | 20 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; |
21 }; | 21 }; |
22 | 22 |
23 class SearchPageListModel final : public QAbstractListModel { | 23 class SearchPageListModel final : public QAbstractListModel { |
24 Q_OBJECT | 24 Q_OBJECT |
25 | 25 |
26 public: | 26 public: |
27 enum columns { | 27 enum columns { |
28 SR_TITLE, | 28 SR_TITLE, |
29 SR_TYPE, | 29 SR_TYPE, |
30 SR_EPISODES, | 30 SR_EPISODES, |
31 SR_SCORE, | 31 SR_SCORE, |
32 SR_SEASON, | 32 SR_SEASON, |
33 | 33 |
34 NB_COLUMNS | 34 NB_COLUMNS |
35 }; | 35 }; |
36 | 36 |
37 SearchPageListModel(QObject* parent); | 37 SearchPageListModel(QObject* parent); |
38 ~SearchPageListModel() override = default; | 38 ~SearchPageListModel() override = default; |
39 int rowCount(const QModelIndex& parent = QModelIndex()) const override; | 39 int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
40 int columnCount(const QModelIndex& parent = QModelIndex()) const override; | 40 int columnCount(const QModelIndex& parent = QModelIndex()) const override; |
41 QVariant data(const QModelIndex& index, int role) const override; | 41 QVariant data(const QModelIndex& index, int role) const override; |
42 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; | 42 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; |
43 Qt::ItemFlags flags(const QModelIndex& index) const override; | 43 Qt::ItemFlags flags(const QModelIndex& index) const override; |
44 | 44 |
45 void ParseSearch(const std::vector<int>& ids); | 45 void ParseSearch(const std::vector<int>& ids); |
46 Anime::Anime* GetAnimeFromIndex(const QModelIndex& index) const; | 46 Anime::Anime* GetAnimeFromIndex(const QModelIndex& index) const; |
47 | 47 |
48 private: | 48 private: |
49 std::vector<int> ids; | 49 std::vector<int> ids; |
50 }; | 50 }; |
51 | 51 |
52 class SearchPage final : public QFrame { | 52 class SearchPage final : public QFrame { |
53 Q_OBJECT | 53 Q_OBJECT |
54 | 54 |
55 public: | 55 public: |
56 SearchPage(QWidget* parent = nullptr); | 56 SearchPage(QWidget* parent = nullptr); |
57 void Search(const std::string& search); | 57 void Search(const std::string& search); |
58 void DisplayListMenu(); | 58 void DisplayListMenu(); |
59 void ItemDoubleClicked(); | 59 void ItemDoubleClicked(); |
60 | 60 |
61 private: | 61 private: |
62 SearchPageListModel* model = nullptr; | 62 SearchPageListModel* model = nullptr; |
63 SearchPageListSortFilter* sort_model = nullptr; | 63 SearchPageListSortFilter* sort_model = nullptr; |
64 QTreeView* treeview = nullptr; | 64 QTreeView* treeview = nullptr; |
65 }; | 65 }; |
66 #endif // __gui__pages__search_h | 66 #endif // __gui__pages__search_h |