Mercurial > minori
annotate include/gui/pages/torrents.h @ 254:d14f8e0e40c3
[UNFINISHED] *: update anime button
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Wed, 07 Feb 2024 07:57:37 -0500 |
| parents | 4d461ef7d424 |
| children | 862d0d8619f6 |
| 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> | |
|
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
183
diff
changeset
|
8 #include <QItemSelection> |
|
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
183
diff
changeset
|
9 |
|
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
183
diff
changeset
|
10 class QTreeView; |
| 114 | 11 |
| 12 class TorrentsPageListSortFilter final : public QSortFilterProxyModel { | |
| 13 Q_OBJECT | |
| 14 | |
| 15 public: | |
| 16 TorrentsPageListSortFilter(QObject* parent = nullptr); | |
| 17 | |
| 18 protected: | |
| 19 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; | |
| 20 }; | |
| 21 | |
| 22 class TorrentsPageListModel final : public QAbstractListModel { | |
| 23 Q_OBJECT | |
|
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
24 |
| 114 | 25 public: |
| 26 enum columns { | |
| 27 TL_TITLE, | |
| 28 TL_EPISODE, | |
| 29 TL_GROUP, | |
| 30 TL_SIZE, | |
| 31 TL_RESOLUTION, | |
| 32 TL_SEEDERS, | |
| 33 TL_LEECHERS, | |
|
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
230
diff
changeset
|
34 TL_DOWNLOADS, |
| 114 | 35 TL_DESCRIPTION, |
| 36 TL_FILENAME, | |
| 37 TL_RELEASEDATE, | |
| 38 | |
| 39 NB_COLUMNS | |
| 40 }; | |
| 41 | |
| 42 TorrentsPageListModel(QObject* parent); | |
| 43 ~TorrentsPageListModel() override = default; | |
| 44 int rowCount(const QModelIndex& parent = QModelIndex()) const override; | |
| 45 int columnCount(const QModelIndex& parent = QModelIndex()) const override; | |
| 46 bool setData(const QModelIndex& index, const QVariant& value, int role) override; | |
| 47 QVariant data(const QModelIndex& index, int role) const override; | |
| 48 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; | |
| 49 Qt::ItemFlags flags(const QModelIndex& index) const override; | |
| 50 | |
| 51 QByteArray DownloadTorrentList(); | |
|
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
183
diff
changeset
|
52 void DownloadTorrents(QItemSelection selection); |
|
183
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
118
diff
changeset
|
53 void ParseFeedDescription(const std::string& description, Torrent& torrent); |
| 114 | 54 void ParseTorrentList(const QByteArray& ba); |
| 55 void RefreshTorrentList(); | |
| 56 | |
| 57 private: | |
|
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
58 class TorrentModelItem : public Torrent { |
|
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
59 public: |
|
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
60 bool GetChecked() const { return _checked; }; |
|
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
61 void SetChecked(bool checked) { _checked = checked; }; |
|
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
62 |
|
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
63 private: |
|
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
64 bool _checked = false; |
|
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
65 }; |
|
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
66 |
| 114 | 67 std::vector<TorrentModelItem> list; |
| 68 }; | |
| 69 | |
| 70 class TorrentsPage final : public QFrame { | |
|
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
71 Q_OBJECT |
|
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
72 |
|
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
73 public: |
| 64 | 74 TorrentsPage(QWidget* parent = nullptr); |
|
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
183
diff
changeset
|
75 void DownloadSelection(); |
| 114 | 76 void Refresh(); |
| 77 | |
| 78 private: | |
| 79 TorrentsPageListModel* model = nullptr; | |
| 80 TorrentsPageListSortFilter* sort_model = nullptr; | |
|
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
183
diff
changeset
|
81 QTreeView* treeview = nullptr; |
|
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
82 }; |
|
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
83 |
|
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
84 #endif // __gui__pages__torrents_h |
