Mercurial > minori
comparison include/gui/pages/torrents.h @ 114:ab191e28e69d
*: add initial torrent stuff
WOAH!
these checkboxes are a pain in my fucking ass
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Tue, 07 Nov 2023 08:03:42 -0500 |
| parents | 8043152ef9d4 |
| children | 39521c47c7a3 |
comparison
equal
deleted
inserted
replaced
| 113:32afe0e940bf | 114:ab191e28e69d |
|---|---|
| 1 #ifndef __gui__pages__torrents_h | 1 #ifndef __gui__pages__torrents_h |
| 2 #define __gui__pages__torrents_h | 2 #define __gui__pages__torrents_h |
| 3 | 3 |
| 4 #include <QWidget> | 4 #include "core/torrent.h" |
| 5 #include <QFrame> | |
| 6 #include <QAbstractListModel> | |
| 7 #include <QSortFilterProxyModel> | |
| 5 | 8 |
| 6 class TorrentsPage final : public QWidget { | 9 class TorrentModelItem : public Torrent { |
| 10 public: | |
| 11 bool GetChecked() const { return _checked; }; | |
| 12 void SetChecked(bool checked) { _checked = checked; }; | |
| 13 | |
| 14 private: | |
| 15 bool _checked = false; | |
| 16 }; | |
| 17 | |
| 18 class TorrentsPageListSortFilter final : public QSortFilterProxyModel { | |
| 19 Q_OBJECT | |
| 20 | |
| 21 public: | |
| 22 TorrentsPageListSortFilter(QObject* parent = nullptr); | |
| 23 | |
| 24 protected: | |
| 25 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; | |
| 26 }; | |
| 27 | |
| 28 class TorrentsPageListModel final : public QAbstractListModel { | |
| 29 Q_OBJECT | |
| 30 | |
| 31 public: | |
| 32 enum columns { | |
| 33 TL_TITLE, | |
| 34 TL_EPISODE, | |
| 35 TL_GROUP, | |
| 36 TL_SIZE, | |
| 37 TL_RESOLUTION, | |
| 38 TL_SEEDERS, | |
| 39 TL_LEECHERS, | |
| 40 TL_DOWNLOADERS, | |
| 41 TL_DESCRIPTION, | |
| 42 TL_FILENAME, | |
| 43 TL_RELEASEDATE, | |
| 44 | |
| 45 NB_COLUMNS | |
| 46 }; | |
| 47 | |
| 48 TorrentsPageListModel(QObject* parent); | |
| 49 ~TorrentsPageListModel() override = default; | |
| 50 int rowCount(const QModelIndex& parent = QModelIndex()) const override; | |
| 51 int columnCount(const QModelIndex& parent = QModelIndex()) const override; | |
| 52 bool setData(const QModelIndex& index, const QVariant& value, int role) override; | |
| 53 QVariant data(const QModelIndex& index, int role) const override; | |
| 54 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; | |
| 55 Qt::ItemFlags flags(const QModelIndex& index) const override; | |
| 56 | |
| 57 QByteArray DownloadTorrentList(); | |
| 58 void ParseTorrentList(const QByteArray& ba); | |
| 59 void RefreshTorrentList(); | |
| 60 | |
| 61 private: | |
| 62 std::vector<TorrentModelItem> list; | |
| 63 }; | |
| 64 | |
| 65 class TorrentsPage final : public QFrame { | |
| 7 Q_OBJECT | 66 Q_OBJECT |
| 8 | 67 |
| 9 public: | 68 public: |
| 10 TorrentsPage(QWidget* parent = nullptr); | 69 TorrentsPage(QWidget* parent = nullptr); |
| 70 void Refresh(); | |
| 71 | |
| 72 private: | |
| 73 TorrentsPageListModel* model = nullptr; | |
| 74 TorrentsPageListSortFilter* sort_model = nullptr; | |
| 11 }; | 75 }; |
| 12 | 76 |
| 13 #endif // __gui__pages__torrents_h | 77 #endif // __gui__pages__torrents_h |
