annotate include/gui/pages/torrents.h @ 212:6b08fbd7f206

chore: merge branches
author Paper <mrpapersonic@gmail.com>
date Sun, 07 Jan 2024 09:54:50 -0500
parents 01d259b9c89f
children 2f5a9247e501
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
c69230dc2b5d *: cleanup includes
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
3
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
4 #include "core/torrent.h"
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
5 #include <QFrame>
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
6 #include <QAbstractListModel>
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
7 #include <QSortFilterProxyModel>
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
8
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
9 class TorrentsPageListSortFilter final : public QSortFilterProxyModel {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
10 Q_OBJECT
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
11
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
12 public:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
13 TorrentsPageListSortFilter(QObject* parent = nullptr);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
14
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
15 protected:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
16 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
17 };
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
18
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
19 class TorrentsPageListModel final : public QAbstractListModel {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
20 Q_OBJECT
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
22 public:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
23 enum columns {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
24 TL_TITLE,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
25 TL_EPISODE,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
26 TL_GROUP,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
27 TL_SIZE,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
28 TL_RESOLUTION,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
29 TL_SEEDERS,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
30 TL_LEECHERS,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
31 TL_DOWNLOADERS,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
32 TL_DESCRIPTION,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
33 TL_FILENAME,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
34 TL_RELEASEDATE,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
35
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
36 NB_COLUMNS
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
37 };
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
38
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
39 TorrentsPageListModel(QObject* parent);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
40 ~TorrentsPageListModel() override = default;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
41 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
42 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
43 bool setData(const QModelIndex& index, const QVariant& value, int role) override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
44 QVariant data(const QModelIndex& index, int role) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
45 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
46 Qt::ItemFlags flags(const QModelIndex& index) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
47
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
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
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
50 void ParseTorrentList(const QByteArray& ba);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
51 void RefreshTorrentList();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
52
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
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
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
63 std::vector<TorrentModelItem> list;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
64 };
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
65
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
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
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 54
diff changeset
70 TorrentsPage(QWidget* parent = nullptr);
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
71 void Refresh();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
72
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
73 private:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
74 TorrentsPageListModel* model = nullptr;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
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