annotate include/gui/pages/torrents.h @ 170:c8375765f0fc

window: make threading somewhat sane
author Paper <mrpapersonic@gmail.com>
date Tue, 21 Nov 2023 11:04:13 -0500
parents 39521c47c7a3
children 01d259b9c89f
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();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
49 void ParseTorrentList(const QByteArray& ba);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
50 void RefreshTorrentList();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
51
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 95
diff changeset
52 private:
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
53 class TorrentModelItem : public Torrent {
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
54 public:
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
55 bool GetChecked() const { return _checked; };
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
56 void SetChecked(bool checked) { _checked = checked; };
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
57
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
58 private:
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
59 bool _checked = false;
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
60 };
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 114
diff changeset
61
114
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