Mercurial > minori
annotate include/gui/pages/search.h @ 250:c130f47f6f48
*: many many changes
e.g. the search page is actually implemented now!
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sun, 04 Feb 2024 21:17:17 -0500 |
parents | 8043152ef9d4 |
children | 862d0d8619f6 |
rev | line source |
---|---|
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
1 #ifndef __gui__pages__search_h |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
2 #define __gui__pages__search_h |
250 | 3 |
4 #include "core/anime.h" | |
5 | |
6 #include <QFrame> | |
7 #include <QAbstractListModel> | |
8 #include <QSortFilterProxyModel> | |
9 #include <QItemSelection> | |
10 | |
11 class QTreeView; | |
12 | |
13 class SearchPageListSortFilter final : public QSortFilterProxyModel { | |
14 Q_OBJECT | |
15 | |
16 public: | |
17 SearchPageListSortFilter(QObject* parent = nullptr); | |
18 | |
19 protected: | |
20 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; | |
21 }; | |
22 | |
23 class SearchPageListModel final : public QAbstractListModel { | |
24 Q_OBJECT | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
25 |
250 | 26 public: |
27 enum columns { | |
28 SR_TITLE, | |
29 SR_TYPE, | |
30 SR_EPISODES, | |
31 SR_SCORE, | |
32 SR_SEASON, | |
33 | |
34 NB_COLUMNS | |
35 }; | |
36 | |
37 SearchPageListModel(QObject* parent); | |
38 ~SearchPageListModel() override = default; | |
39 int rowCount(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; | |
42 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; | |
43 Qt::ItemFlags flags(const QModelIndex& index) const override; | |
44 | |
45 void ParseSearch(const std::vector<int>& ids); | |
46 Anime::Anime* GetAnimeFromIndex(const QModelIndex& index) const; | |
47 | |
48 private: | |
49 std::vector<int> ids; | |
50 }; | |
51 | |
52 class SearchPage final : public QFrame { | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
53 Q_OBJECT |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
54 |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
55 public: |
64 | 56 SearchPage(QWidget* parent = nullptr); |
250 | 57 void Search(const std::string& search); |
58 void DisplayListMenu(); | |
59 void ItemDoubleClicked(); | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
60 |
250 | 61 private: |
62 SearchPageListModel* model = nullptr; | |
63 SearchPageListSortFilter* sort_model = nullptr; | |
64 QTreeView* treeview = nullptr; | |
65 }; | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
66 #endif // __gui__pages__search_h |