comparison include/gui/pages/torrents.h @ 258:862d0d8619f6

*: HUUUGE changes animia has been renamed to animone, so instead of thinking of a health condition, you think of a beautiful flower :) I've also edited some of the code for animone, but I have no idea if it even works or not because I don't have a mac or windows machine lying around. whoops! ... anyway, all of the changes divergent from Anisthesia are now licensed under BSD. it's possible that I could even rewrite most of the code to where I don't even have to keep the MIT license, but that's thinking too far into the future I've been slacking off on implementing the anime seasons page, mostly out of laziness. I think I'd have to create another db file specifically for the seasons anyway, this code is being pushed *primarily* because the hard drive it's on is failing! yay :)
author Paper <paper@paper.us.eu.org>
date Mon, 01 Apr 2024 02:43:44 -0400
parents 4d461ef7d424
children 3ec7804abf17
comparison
equal deleted inserted replaced
257:699a20c57dc8 258:862d0d8619f6
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 "core/torrent.h" 4 #include "core/torrent.h"
5 #include <QAbstractListModel>
5 #include <QFrame> 6 #include <QFrame>
6 #include <QAbstractListModel> 7 #include <QItemSelection>
7 #include <QSortFilterProxyModel> 8 #include <QSortFilterProxyModel>
8 #include <QItemSelection>
9 9
10 class QTreeView; 10 class QTreeView;
11 11
12 class TorrentsPageListSortFilter final : public QSortFilterProxyModel { 12 class TorrentsPageListSortFilter final : public QSortFilterProxyModel {
13 Q_OBJECT 13 Q_OBJECT
14 14
15 public: 15 public:
16 TorrentsPageListSortFilter(QObject* parent = nullptr); 16 TorrentsPageListSortFilter(QObject* parent = nullptr);
17 17
18 protected: 18 protected:
19 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; 19 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override;
20 }; 20 };
21 21
22 class TorrentsPageListModel final : public QAbstractListModel { 22 class TorrentsPageListModel final : public QAbstractListModel {
23 Q_OBJECT 23 Q_OBJECT
24 24
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 };
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();
52 void DownloadTorrents(QItemSelection selection);
53 void ParseFeedDescription(const std::string& description, Torrent& torrent);
54 void ParseTorrentList(const QByteArray& ba);
55 void RefreshTorrentList();
56
57 private:
58 class TorrentModelItem : public Torrent {
25 public: 59 public:
26 enum columns { 60 bool GetChecked() const { return _checked; };
27 TL_TITLE, 61 void SetChecked(bool checked) { _checked = checked; };
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 };
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();
52 void DownloadTorrents(QItemSelection selection);
53 void ParseFeedDescription(const std::string& description, Torrent& torrent);
54 void ParseTorrentList(const QByteArray& ba);
55 void RefreshTorrentList();
56 62
57 private: 63 private:
58 class TorrentModelItem : public Torrent { 64 bool _checked = false;
59 public: 65 };
60 bool GetChecked() const { return _checked; };
61 void SetChecked(bool checked) { _checked = checked; };
62 66
63 private: 67 std::vector<TorrentModelItem> list;
64 bool _checked = false;
65 };
66
67 std::vector<TorrentModelItem> list;
68 }; 68 };
69 69
70 class TorrentsPage final : public QFrame { 70 class TorrentsPage final : public QFrame {
71 Q_OBJECT 71 Q_OBJECT
72 72
73 public: 73 public:
74 TorrentsPage(QWidget* parent = nullptr); 74 TorrentsPage(QWidget* parent = nullptr);
75 void DownloadSelection(); 75 void DownloadSelection();
76 void Refresh(); 76 void Refresh();
77 77
78 private: 78 private:
79 TorrentsPageListModel* model = nullptr; 79 TorrentsPageListModel* model = nullptr;
80 TorrentsPageListSortFilter* sort_model = nullptr; 80 TorrentsPageListSortFilter* sort_model = nullptr;
81 QTreeView* treeview = nullptr; 81 QTreeView* treeview = nullptr;
82 }; 82 };
83 83
84 #endif // __gui__pages__torrents_h 84 #endif // __gui__pages__torrents_h