Mercurial > minori
annotate include/gui/pages/torrents.h @ 198:bc1ae1810855
dep/animia: switch from using classes to global functions
the old idea was ok, but sort of hackish; this method doesn't use classes
at all, and this way (especially important!) we can do wayland stuff AND x11
at the same time, which wasn't really possible without stupid workarounds in
the other method
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 24 Dec 2023 02:59:42 -0500 |
parents | 01d259b9c89f |
children | 2f5a9247e501 |
rev | line source |
---|---|
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
1 #ifndef __gui__pages__torrents_h |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
2 #define __gui__pages__torrents_h |
85 | 3 |
114 | 4 #include "core/torrent.h" |
5 #include <QFrame> | |
6 #include <QAbstractListModel> | |
7 #include <QSortFilterProxyModel> | |
8 | |
9 class TorrentsPageListSortFilter final : public QSortFilterProxyModel { | |
10 Q_OBJECT | |
11 | |
12 public: | |
13 TorrentsPageListSortFilter(QObject* parent = nullptr); | |
14 | |
15 protected: | |
16 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; | |
17 }; | |
18 | |
19 class TorrentsPageListModel final : public QAbstractListModel { | |
20 Q_OBJECT | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
21 |
114 | 22 public: |
23 enum columns { | |
24 TL_TITLE, | |
25 TL_EPISODE, | |
26 TL_GROUP, | |
27 TL_SIZE, | |
28 TL_RESOLUTION, | |
29 TL_SEEDERS, | |
30 TL_LEECHERS, | |
31 TL_DOWNLOADERS, | |
32 TL_DESCRIPTION, | |
33 TL_FILENAME, | |
34 TL_RELEASEDATE, | |
35 | |
36 NB_COLUMNS | |
37 }; | |
38 | |
39 TorrentsPageListModel(QObject* parent); | |
40 ~TorrentsPageListModel() override = default; | |
41 int rowCount(const QModelIndex& parent = QModelIndex()) const override; | |
42 int columnCount(const QModelIndex& parent = QModelIndex()) const override; | |
43 bool setData(const QModelIndex& index, const QVariant& value, int role) override; | |
44 QVariant data(const QModelIndex& index, int role) const override; | |
45 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; | |
46 Qt::ItemFlags flags(const QModelIndex& index) const override; | |
47 | |
48 QByteArray DownloadTorrentList(); | |
183
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
118
diff
changeset
|
49 void ParseFeedDescription(const std::string& description, Torrent& torrent); |
114 | 50 void ParseTorrentList(const QByteArray& ba); |
51 void RefreshTorrentList(); | |
52 | |
53 private: | |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
54 class TorrentModelItem : public Torrent { |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
55 public: |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
56 bool GetChecked() const { return _checked; }; |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
57 void SetChecked(bool checked) { _checked = checked; }; |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
58 |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
59 private: |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
60 bool _checked = false; |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
61 }; |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
62 |
114 | 63 std::vector<TorrentModelItem> list; |
64 }; | |
65 | |
66 class TorrentsPage final : public QFrame { | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
67 Q_OBJECT |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
68 |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
69 public: |
64 | 70 TorrentsPage(QWidget* parent = nullptr); |
114 | 71 void Refresh(); |
72 | |
73 private: | |
74 TorrentsPageListModel* model = nullptr; | |
75 TorrentsPageListSortFilter* sort_model = nullptr; | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
76 }; |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
77 |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
78 #endif // __gui__pages__torrents_h |