annotate 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
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 TorrentModelItem : public Torrent {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
10 public:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
11 bool GetChecked() const { return _checked; };
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
12 void SetChecked(bool checked) { _checked = checked; };
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
13
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
14 private:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
15 bool _checked = false;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
16 };
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 class TorrentsPageListSortFilter final : public QSortFilterProxyModel {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
19 Q_OBJECT
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 public:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
22 TorrentsPageListSortFilter(QObject* parent = nullptr);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
23
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
24 protected:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
25 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
26 };
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
27
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
28 class TorrentsPageListModel final : public QAbstractListModel {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
29 Q_OBJECT
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
31 public:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
32 enum columns {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
33 TL_TITLE,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
34 TL_EPISODE,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
35 TL_GROUP,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
36 TL_SIZE,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
37 TL_RESOLUTION,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
38 TL_SEEDERS,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
39 TL_LEECHERS,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
40 TL_DOWNLOADERS,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
41 TL_DESCRIPTION,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
42 TL_FILENAME,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
43 TL_RELEASEDATE,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
44
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
45 NB_COLUMNS
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
46 };
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 TorrentsPageListModel(QObject* parent);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
49 ~TorrentsPageListModel() override = default;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
50 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
51 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
52 bool setData(const QModelIndex& index, const QVariant& value, int role) override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
53 QVariant data(const QModelIndex& index, int role) const override;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
54 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
55 Qt::ItemFlags flags(const QModelIndex& index) const override;
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 QByteArray DownloadTorrentList();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
58 void ParseTorrentList(const QByteArray& ba);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
59 void RefreshTorrentList();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
60
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
61 private:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
62 std::vector<TorrentModelItem> list;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
63 };
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 class TorrentsPage final : public QFrame {
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66 Q_OBJECT
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
67
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
68 public:
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 54
diff changeset
69 TorrentsPage(QWidget* parent = nullptr);
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
70 void Refresh();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
71
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
72 private:
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
73 TorrentsPageListModel* model = nullptr;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
74 TorrentsPageListSortFilter* sort_model = nullptr;
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75 };
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 #endif // __gui__pages__torrents_h