Mercurial > minori
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 |
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 | 3 |
114 | 4 #include "core/torrent.h" |
5 #include <QFrame> | |
6 #include <QAbstractListModel> | |
7 #include <QSortFilterProxyModel> | |
8 | |
9 class TorrentsPageListSortFilter final : public QSortFilterProxyModel { | |
10 Q_OBJECT | |
11 | |
12 public: | |
13 TorrentsPageListSortFilter(QObject* parent = nullptr); | |
14 | |
15 protected: | |
16 bool lessThan(const QModelIndex& l, const QModelIndex& r) const override; | |
17 }; | |
18 | |
19 class TorrentsPageListModel final : public QAbstractListModel { | |
20 Q_OBJECT | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
21 |
114 | 22 public: |
23 enum columns { | |
24 TL_TITLE, | |
25 TL_EPISODE, | |
26 TL_GROUP, | |
27 TL_SIZE, | |
28 TL_RESOLUTION, | |
29 TL_SEEDERS, | |
30 TL_LEECHERS, | |
31 TL_DOWNLOADERS, | |
32 TL_DESCRIPTION, | |
33 TL_FILENAME, | |
34 TL_RELEASEDATE, | |
35 | |
36 NB_COLUMNS | |
37 }; | |
38 | |
39 TorrentsPageListModel(QObject* parent); | |
40 ~TorrentsPageListModel() override = default; | |
41 int rowCount(const QModelIndex& parent = QModelIndex()) const override; | |
42 int columnCount(const QModelIndex& parent = QModelIndex()) const override; | |
43 bool setData(const QModelIndex& index, const QVariant& value, int role) override; | |
44 QVariant data(const QModelIndex& index, int role) const override; | |
45 QVariant headerData(const int section, const Qt::Orientation orientation, const int role) const override; | |
46 Qt::ItemFlags flags(const QModelIndex& index) const override; | |
47 | |
48 QByteArray DownloadTorrentList(); | |
49 void ParseTorrentList(const QByteArray& ba); | |
50 void RefreshTorrentList(); | |
51 | |
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 | 62 std::vector<TorrentModelItem> list; |
63 }; | |
64 | |
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 | 69 TorrentsPage(QWidget* parent = nullptr); |
114 | 70 void Refresh(); |
71 | |
72 private: | |
73 TorrentsPageListModel* model = nullptr; | |
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 |