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
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>
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
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 class TorrentsPageListSortFilter final : public QSortFilterProxyModel {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
13 Q_OBJECT
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 public:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
16 TorrentsPageListSortFilter(QObject* parent = nullptr);
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 protected:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
19 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
20 };
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
21
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
22 class TorrentsPageListModel final : public QAbstractListModel {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
23 Q_OBJECT
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
25 public:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
26 enum columns {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
27 TL_TITLE,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
28 TL_EPISODE,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
29 TL_GROUP,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
30 TL_SIZE,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
31 TL_RESOLUTION,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
32 TL_SEEDERS,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
33 TL_LEECHERS,
236
4d461ef7d424 HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents: 230
diff changeset
34 TL_DOWNLOADS,
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
35 TL_DESCRIPTION,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
36 TL_FILENAME,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
37 TL_RELEASEDATE,
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 NB_COLUMNS
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
40 };
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
41
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
42 TorrentsPageListModel(QObject* parent);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
43 ~TorrentsPageListModel() override = default;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
44 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
45 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
46 bool setData(const QModelIndex& index, const QVariant& value, int role) override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
47 QVariant data(const QModelIndex& index, int role) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
48 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
49 Qt::ItemFlags flags(const QModelIndex& index) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
50
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
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
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
54 void ParseTorrentList(const QByteArray& ba);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
55 void RefreshTorrentList();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
56
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
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
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
67 std::vector<TorrentModelItem> list;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
68 };
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
69
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
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
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 54
diff changeset
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
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
76 void Refresh();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
77
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
78 private:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
79 TorrentsPageListModel* model = nullptr;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
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