Mercurial > minori
annotate include/gui/pages/torrents.h @ 315:34347fd2a2de
session: allow printing status messages
...!
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Tue, 11 Jun 2024 14:16:40 -0400 |
| parents | 3ec7804abf17 |
| 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_TORRENTS_H_ |
|
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
2 #define MINORI_GUI_PAGES_TORRENTS_H_ |
| 85 | 3 |
| 114 | 4 #include "core/torrent.h" |
| 258 | 5 #include <QAbstractListModel> |
| 114 | 6 #include <QFrame> |
| 258 | 7 #include <QItemSelection> |
| 114 | 8 #include <QSortFilterProxyModel> |
|
230
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 { | |
| 258 | 13 Q_OBJECT |
| 114 | 14 |
| 258 | 15 public: |
| 16 TorrentsPageListSortFilter(QObject* parent = nullptr); | |
| 114 | 17 |
| 258 | 18 protected: |
| 19 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; | |
| 114 | 20 }; |
| 21 | |
| 22 class TorrentsPageListModel final : public QAbstractListModel { | |
| 258 | 23 Q_OBJECT |
|
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
24 |
| 258 | 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, | |
| 34 TL_DOWNLOADS, | |
| 35 TL_DESCRIPTION, | |
| 36 TL_FILENAME, | |
| 37 TL_RELEASEDATE, | |
| 38 | |
| 39 NB_COLUMNS | |
| 40 }; | |
| 114 | 41 |
| 258 | 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; | |
| 114 | 50 |
| 258 | 51 QByteArray DownloadTorrentList(); |
| 52 void DownloadTorrents(QItemSelection selection); | |
| 53 void ParseFeedDescription(const std::string& description, Torrent& torrent); | |
| 54 void ParseTorrentList(const QByteArray& ba); | |
| 55 void RefreshTorrentList(); | |
| 114 | 56 |
| 258 | 57 private: |
| 58 class TorrentModelItem : public Torrent { | |
| 59 public: | |
| 60 bool GetChecked() const { return _checked; }; | |
| 61 void SetChecked(bool checked) { _checked = checked; }; | |
| 114 | 62 |
| 63 private: | |
| 258 | 64 bool _checked = false; |
| 65 }; | |
|
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
66 |
| 258 | 67 std::vector<TorrentModelItem> list; |
| 114 | 68 }; |
| 69 | |
| 70 class TorrentsPage 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 TorrentsPage(QWidget* parent = nullptr); | |
| 75 void DownloadSelection(); | |
| 76 void Refresh(); | |
| 114 | 77 |
| 258 | 78 private: |
| 79 TorrentsPageListModel* model = nullptr; | |
| 80 TorrentsPageListSortFilter* sort_model = nullptr; | |
| 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 |
|
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
84 #endif // MINORI_GUI_PAGES_TORRENTS_H_ |
