Mercurial > minori
annotate include/gui/pages/search.h @ 367:8d45d892be88 default tip
*: instead of pugixml, use Qt XML features
this means we have one extra Qt dependency though...
author | Paper <paper@tflc.us> |
---|---|
date | Sun, 17 Nov 2024 22:55:47 -0500 |
parents | f31305b9f60a |
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_SEARCH_H_ |
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
2 #define MINORI_GUI_PAGES_SEARCH_H_ |
250 | 3 |
4 #include "core/anime.h" | |
5 | |
258 | 6 #include <QAbstractListModel> |
250 | 7 #include <QFrame> |
258 | 8 #include <QItemSelection> |
250 | 9 #include <QSortFilterProxyModel> |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
10 #include <QThread> |
250 | 11 |
12 class QTreeView; | |
13 | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
14 class SearchPageSearchThread : public QThread { |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
15 Q_OBJECT |
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 public: |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
18 SearchPageSearchThread(QObject* parent = nullptr); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
19 void SetSearch(const std::string& search); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
20 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
21 protected: |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
22 void run() override; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
23 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
24 private: |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
25 std::string search_; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
26 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
27 signals: |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
28 void GotResults(const std::vector<int>& search); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
29 }; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
30 |
250 | 31 class SearchPageListSortFilter final : public QSortFilterProxyModel { |
258 | 32 Q_OBJECT |
250 | 33 |
258 | 34 public: |
35 SearchPageListSortFilter(QObject* parent = nullptr); | |
250 | 36 |
258 | 37 protected: |
38 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; | |
250 | 39 }; |
40 | |
41 class SearchPageListModel final : public QAbstractListModel { | |
258 | 42 Q_OBJECT |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
43 |
258 | 44 public: |
45 enum columns { | |
46 SR_TITLE, | |
47 SR_TYPE, | |
48 SR_EPISODES, | |
49 SR_SCORE, | |
50 SR_SEASON, | |
250 | 51 |
258 | 52 NB_COLUMNS |
53 }; | |
250 | 54 |
258 | 55 SearchPageListModel(QObject* parent); |
56 ~SearchPageListModel() override = default; | |
57 int rowCount(const QModelIndex& parent = QModelIndex()) const override; | |
58 int columnCount(const QModelIndex& parent = QModelIndex()) const override; | |
59 QVariant data(const QModelIndex& index, int role) const override; | |
60 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; | |
61 Qt::ItemFlags flags(const QModelIndex& index) const override; | |
250 | 62 |
258 | 63 void ParseSearch(const std::vector<int>& ids); |
64 Anime::Anime* GetAnimeFromIndex(const QModelIndex& index) const; | |
250 | 65 |
258 | 66 private: |
67 std::vector<int> ids; | |
250 | 68 }; |
69 | |
70 class SearchPage final : public QFrame { | |
258 | 71 Q_OBJECT |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
72 |
258 | 73 public: |
74 SearchPage(QWidget* parent = nullptr); | |
75 void Search(const std::string& search); | |
76 void DisplayListMenu(); | |
77 void ItemDoubleClicked(); | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
78 |
258 | 79 private: |
80 SearchPageListModel* model = nullptr; | |
81 SearchPageListSortFilter* sort_model = nullptr; | |
82 QTreeView* treeview = nullptr; | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
83 |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
84 SearchPageSearchThread thread_; |
250 | 85 }; |
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
86 #endif // MINORI_GUI_PAGES_SEARCH_H_ |