Mercurial > minori
annotate src/gui/pages/torrents.cc @ 221:53211cb1e7f5
library: add initial library stuff
nice
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 08 Jan 2024 13:21:08 -0500 |
parents | 01d259b9c89f |
children | 2f5a9247e501 |
rev | line source |
---|---|
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
1 #include "gui/pages/torrents.h" |
114 | 2 #include "core/strings.h" |
3 #include "core/http.h" | |
4 #include "core/session.h" | |
5 #include "gui/widgets/text.h" | |
6 #include "track/media.h" | |
178
bc8d2ccff09c
win32/dark: use existing STL classes for dwmapi
Paper <mrpapersonic@gmail.com>
parents:
154
diff
changeset
|
7 |
114 | 8 #include <QVBoxLayout> |
9 #include <QToolBar> | |
10 #include <QTreeView> | |
11 #include <QMainWindow> | |
12 #include <QByteArray> | |
13 #include <QDataStream> | |
14 #include <QThreadPool> | |
15 #include <QDebug> | |
178
bc8d2ccff09c
win32/dark: use existing STL classes for dwmapi
Paper <mrpapersonic@gmail.com>
parents:
154
diff
changeset
|
16 |
114 | 17 #include <iostream> |
18 #include <sstream> | |
19 #include <algorithm> | |
20 | |
178
bc8d2ccff09c
win32/dark: use existing STL classes for dwmapi
Paper <mrpapersonic@gmail.com>
parents:
154
diff
changeset
|
21 #include "pugixml.hpp" |
154 | 22 #include "anitomy/anitomy.h" |
23 | |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
117
diff
changeset
|
24 /* This file is very, very similar to the anime list page. |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
117
diff
changeset
|
25 |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
117
diff
changeset
|
26 It differs from Taiga in that it uses tabs instead of |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
117
diff
changeset
|
27 those "groups", but those are custom painted and a pain in the ass to |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
117
diff
changeset
|
28 maintain over multiple platforms. */ |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
117
diff
changeset
|
29 |
114 | 30 TorrentsPageListSortFilter::TorrentsPageListSortFilter(QObject* parent) : QSortFilterProxyModel(parent) { |
31 } | |
32 | |
33 bool TorrentsPageListSortFilter::lessThan(const QModelIndex& l, const QModelIndex& r) const { | |
34 QVariant left = sourceModel()->data(l, sortRole()); | |
35 QVariant right = sourceModel()->data(r, sortRole()); | |
36 | |
37 switch (left.userType()) { | |
38 case QMetaType::Int: | |
39 case QMetaType::UInt: | |
40 case QMetaType::LongLong: | |
41 case QMetaType::ULongLong: return left.toInt() < right.toInt(); | |
42 case QMetaType::QDate: return left.toDate() < right.toDate(); | |
43 case QMetaType::QString: | |
44 default: return QString::compare(left.toString(), right.toString(), Qt::CaseInsensitive) < 0; | |
45 } | |
46 } | |
47 | |
48 /* -------------------------------------------- */ | |
49 | |
50 TorrentsPageListModel::TorrentsPageListModel(QObject* parent) : QAbstractListModel(parent) { | |
51 } | |
52 | |
53 QByteArray TorrentsPageListModel::DownloadTorrentList() { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
54 return HTTP::Get(session.config.torrents.feed_link); |
114 | 55 } |
56 | |
183
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
57 void TorrentsPageListModel::ParseFeedDescription(const std::string& description, Torrent& torrent) { |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
58 /* Parse description... */ |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
59 enum class Keys { SIZE, AUTHORIZED, SUBMITTER, COMMENT }; |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
60 |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
61 const std::unordered_map<std::string, Keys> KeyMap = { |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
62 {"Size", Keys::SIZE}, |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
63 {"Authorized", Keys::AUTHORIZED}, |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
64 {"Submitter", Keys::SUBMITTER}, |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
65 {"Comment", Keys::COMMENT} |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
66 }; |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
67 |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
68 /* Parse size from description */ |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
69 std::istringstream descstream(description); |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
70 |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
71 for (std::string line; std::getline(descstream, line);) { |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
72 const size_t pos = line.find_first_of(':', 0); |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
73 if (pos == std::string::npos) |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
74 continue; |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
75 |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
76 const std::string key = line.substr(0, pos); |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
77 const std::string value = line.substr(line.find_first_not_of(": ", pos)); |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
78 |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
79 switch (KeyMap.at(key)) { |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
80 case Keys::COMMENT: |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
81 torrent.SetDescription(value); |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
82 break; |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
83 case Keys::SIZE: |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
84 torrent.SetSize(Strings::HumanReadableSizeToBytes(value)); |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
85 break; |
221
53211cb1e7f5
library: add initial library stuff
Paper <paper@paper.us.eu.org>
parents:
183
diff
changeset
|
86 case Keys::AUTHORIZED: |
53211cb1e7f5
library: add initial library stuff
Paper <paper@paper.us.eu.org>
parents:
183
diff
changeset
|
87 if (torrent.GetGroup().empty() && value != "N/A") |
53211cb1e7f5
library: add initial library stuff
Paper <paper@paper.us.eu.org>
parents:
183
diff
changeset
|
88 torrent.SetGroup(value); |
53211cb1e7f5
library: add initial library stuff
Paper <paper@paper.us.eu.org>
parents:
183
diff
changeset
|
89 break; |
183
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
90 default: |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
91 break; |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
92 } |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
93 } |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
94 } |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
95 |
114 | 96 void TorrentsPageListModel::ParseTorrentList(const QByteArray& ba) { |
97 std::istringstream stdstream(Strings::ToUtf8String(ba)); | |
98 | |
99 pugi::xml_document doc; | |
100 if (!doc.load(stdstream)) | |
101 return; // peace out | |
102 | |
103 /* my extra special dumb hack. */ | |
104 if (!rowCount(index(0))) { | |
105 beginInsertRows(QModelIndex(), 0, 0); | |
106 endInsertRows(); | |
107 } | |
108 | |
109 beginResetModel(); | |
110 | |
111 list.clear(); | |
112 /* this is just an rss parser; it should be in a separate class... */ | |
113 for (pugi::xml_node item : doc.child("rss").child("channel").children("item")) { | |
114 TorrentModelItem torrent; | |
115 torrent.SetFilename(item.child_value("title")); /* "title" == filename */ | |
116 { | |
154 | 117 anitomy::Anitomy anitomy; |
118 anitomy.Parse(Strings::ToWstring(torrent.GetFilename())); | |
119 | |
120 const auto& elements = anitomy.elements(); | |
121 | |
122 /* todo: patch Anitomy so that it doesn't use wide strings */ | |
123 torrent.SetTitle(Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle))); | |
124 torrent.SetEpisode(Strings::RemoveLeadingChars(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)), '0')); | |
125 torrent.SetGroup(Strings::ToUtf8String(elements.get(anitomy::kElementReleaseGroup))); | |
126 torrent.SetResolution(Strings::ToUtf8String(elements.get(anitomy::kElementVideoResolution))); | |
114 | 127 } |
128 | |
183
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
129 ParseFeedDescription(Strings::TextifySynopsis(item.child_value("description")), torrent); |
114 | 130 |
131 torrent.SetLink(item.child_value("link")); | |
132 torrent.SetGuid(item.child_value("guid")); | |
133 { | |
134 const QString date_str = Strings::ToQString(item.child_value("pubDate")); | |
135 torrent.SetDate(QDateTime::fromString(date_str, "ddd, dd MMM yyyy HH:mm:ss t")); | |
136 } | |
137 list.push_back(torrent); | |
138 } | |
139 | |
140 endResetModel(); | |
141 } | |
142 | |
143 void TorrentsPageListModel::RefreshTorrentList() { | |
144 ParseTorrentList(DownloadTorrentList()); | |
145 } | |
146 | |
147 int TorrentsPageListModel::rowCount(const QModelIndex& parent) const { | |
148 return list.size(); | |
149 (void)(parent); | |
150 } | |
151 | |
152 int TorrentsPageListModel::columnCount(const QModelIndex& parent) const { | |
153 return NB_COLUMNS; | |
154 (void)(parent); | |
155 } | |
156 | |
157 QVariant TorrentsPageListModel::headerData(const int section, const Qt::Orientation orientation, const int role) const { | |
158 switch (role) { | |
159 case Qt::DisplayRole: { | |
160 switch (section) { | |
161 case TL_TITLE: return tr("Anime title"); | |
162 case TL_EPISODE: return tr("Episode"); | |
163 case TL_GROUP: return tr("Group"); | |
164 case TL_SIZE: return tr("Size"); | |
165 case TL_RESOLUTION: return tr("Resolution"); /* this is named "Video" in Taiga */ | |
166 case TL_SEEDERS: return tr("Seeding"); /* named "S" in Taiga */ | |
167 case TL_LEECHERS: return tr("Leeching"); /* named "L" in Taiga */ | |
168 case TL_DOWNLOADERS: return tr("Downloading"); /* named "D" in Taiga */ | |
169 case TL_DESCRIPTION: return tr("Description"); | |
170 case TL_FILENAME: return tr("Filename"); | |
171 case TL_RELEASEDATE: return tr("Release date"); | |
172 default: return {}; | |
173 } | |
174 break; | |
175 } | |
176 case Qt::TextAlignmentRole: { | |
177 switch (section) { | |
178 case TL_FILENAME: | |
179 case TL_GROUP: | |
180 case TL_DESCRIPTION: | |
181 case TL_RESOLUTION: | |
182 case TL_TITLE: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); | |
183 case TL_SEEDERS: | |
184 case TL_LEECHERS: | |
185 case TL_DOWNLOADERS: | |
186 case TL_SIZE: | |
187 case TL_EPISODE: | |
188 case TL_RELEASEDATE: return QVariant(Qt::AlignRight | Qt::AlignVCenter); | |
189 default: return {}; | |
190 } | |
191 break; | |
192 } | |
193 } | |
194 return QAbstractListModel::headerData(section, orientation, role); | |
195 } | |
196 | |
197 bool TorrentsPageListModel::setData(const QModelIndex& index, const QVariant& value, int role) { | |
198 TorrentModelItem& item = list.at(index.row()); | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
199 |
114 | 200 if (index.column() == 0) { |
201 switch (role) { | |
202 case Qt::EditRole: | |
203 return false; | |
204 case Qt::CheckStateRole: | |
205 item.SetChecked(value.toBool()); | |
206 emit dataChanged(index, index); | |
207 return true; | |
208 } | |
209 } | |
210 | |
211 return QAbstractItemModel::setData(index, value, role); | |
212 } | |
213 | |
214 QVariant TorrentsPageListModel::data(const QModelIndex& index, int role) const { | |
215 if (!index.isValid()) | |
216 return QVariant(); | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
217 |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
218 const TorrentModelItem& item = list.at(index.row()); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
219 |
114 | 220 switch (role) { |
221 case Qt::DisplayRole: | |
222 switch (index.column()) { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
223 case TL_TITLE: return Strings::ToQString(item.GetTitle()); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
224 case TL_EPISODE: return Strings::ToQString(item.GetEpisode()); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
225 case TL_GROUP: return Strings::ToQString(item.GetGroup()); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
226 case TL_SIZE: return session.config.locale.GetLocale().formattedDataSize(item.GetSize()); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
227 case TL_RESOLUTION: return Strings::ToQString(item.GetResolution()); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
228 case TL_SEEDERS: return item.GetSeeders(); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
229 case TL_LEECHERS: return item.GetLeechers(); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
230 case TL_DOWNLOADERS: return item.GetDownloaders(); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
231 case TL_DESCRIPTION: return Strings::ToQString(item.GetDescription()); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
232 case TL_FILENAME: return Strings::ToQString(item.GetFilename()); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
233 case TL_RELEASEDATE: return item.GetDate(); |
114 | 234 default: return ""; |
235 } | |
236 break; | |
237 case Qt::UserRole: | |
238 switch (index.column()) { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
239 case TL_EPISODE: return Strings::ToInt(item.GetEpisode(), -1); |
117
2c1b6782e1d0
pages/torrents: work around conversion error on Linux
Paper <mrpapersonic@gmail.com>
parents:
116
diff
changeset
|
240 /* We have to use this to work around some stupid |
2c1b6782e1d0
pages/torrents: work around conversion error on Linux
Paper <mrpapersonic@gmail.com>
parents:
116
diff
changeset
|
241 "conversion ambiguous" error on Linux */ |
2c1b6782e1d0
pages/torrents: work around conversion error on Linux
Paper <mrpapersonic@gmail.com>
parents:
116
diff
changeset
|
242 case TL_SIZE: return QVariant::fromValue(item.GetSize()); |
114 | 243 default: return data(index, Qt::DisplayRole); |
244 } | |
245 break; | |
246 case Qt::SizeHintRole: { | |
247 switch (index.column()) { | |
248 default: { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
249 /* max horizontal size of 100, height size = size of current font */ |
114 | 250 const QString d = data(index, Qt::DisplayRole).toString(); |
251 const QFontMetrics metric = QFontMetrics(QFont()); | |
252 | |
253 return QSize(std::max(metric.horizontalAdvance(d), 100), metric.height()); | |
254 } | |
255 } | |
256 break; | |
257 } | |
258 case Qt::TextAlignmentRole: | |
259 switch (index.column()) { | |
260 case TL_FILENAME: | |
261 case TL_GROUP: | |
262 case TL_DESCRIPTION: | |
263 case TL_RESOLUTION: | |
264 case TL_TITLE: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); | |
265 case TL_SEEDERS: | |
266 case TL_LEECHERS: | |
267 case TL_DOWNLOADERS: | |
268 case TL_SIZE: | |
269 case TL_EPISODE: | |
270 case TL_RELEASEDATE: return QVariant(Qt::AlignRight | Qt::AlignVCenter); | |
271 default: return {}; | |
272 } | |
273 break; | |
274 } | |
275 return QVariant(); | |
276 } | |
277 | |
278 Qt::ItemFlags TorrentsPageListModel::flags(const QModelIndex& index) const { | |
279 if (!index.isValid()) | |
280 return Qt::NoItemFlags; | |
281 | |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
117
diff
changeset
|
282 return Qt::ItemIsEnabled | Qt::ItemIsSelectable; |
114 | 283 } |
284 | |
285 TorrentsPage::TorrentsPage(QWidget* parent) : QFrame(parent) { | |
286 setFrameShape(QFrame::Box); | |
287 setFrameShadow(QFrame::Sunken); | |
288 | |
289 QVBoxLayout* layout = new QVBoxLayout(this); | |
290 layout->setContentsMargins(0, 0, 0, 0); | |
291 layout->setSpacing(0); | |
292 | |
293 { | |
294 /* Toolbar */ | |
295 QToolBar* toolbar = new QToolBar(this); | |
296 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | |
297 toolbar->setIconSize(QSize(16, 16)); | |
298 toolbar->setMovable(false); | |
299 | |
300 { | |
301 /* this needs to be stored somewhere to replicate Taiga's | |
302 "timer" feature */ | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
303 toolbar->addAction(QIcon(":/icons/16x16/arrow-circle-315.png"), tr("&Check new torrents"), [this]{ |
114 | 304 QThreadPool::globalInstance()->start([this] { |
305 Refresh(); | |
306 }); | |
307 }); | |
308 } | |
309 | |
310 toolbar->addSeparator(); | |
311 | |
312 { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
313 toolbar->addAction(QIcon(":/icons/16x16/navigation-270-button.png"), tr("Download &marked torrents")); |
114 | 314 } |
315 | |
316 { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
317 toolbar->addAction(QIcon(":/icons/16x16/cross-button.png"), tr("&Discard all")); |
114 | 318 } |
319 | |
320 toolbar->addSeparator(); | |
321 | |
322 { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
323 toolbar->addAction(QIcon(":/icons/16x16/gear.png"), tr("&Settings")); |
114 | 324 } |
325 | |
326 layout->addWidget(toolbar); | |
327 } | |
328 | |
329 { | |
330 QFrame* line = new QFrame(this); | |
331 line->setFrameShape(QFrame::HLine); | |
332 line->setFrameShadow(QFrame::Sunken); | |
333 line->setLineWidth(1); | |
334 layout->addWidget(line); | |
335 } | |
336 | |
337 { | |
338 QTreeView* treeview = new QTreeView(this); | |
339 treeview->setUniformRowHeights(true); | |
340 treeview->setAllColumnsShowFocus(false); | |
341 treeview->setAlternatingRowColors(true); | |
342 treeview->setSortingEnabled(true); | |
343 treeview->setSelectionMode(QAbstractItemView::ExtendedSelection); | |
344 treeview->setItemsExpandable(false); | |
345 treeview->setRootIsDecorated(false); | |
346 treeview->setContextMenuPolicy(Qt::CustomContextMenu); | |
347 treeview->setFrameShape(QFrame::NoFrame); | |
348 | |
349 { | |
350 sort_model = new TorrentsPageListSortFilter(treeview); | |
351 model = new TorrentsPageListModel(treeview); | |
352 sort_model->setSourceModel(model); | |
353 sort_model->setSortRole(Qt::UserRole); | |
354 sort_model->setSortCaseSensitivity(Qt::CaseInsensitive); | |
355 treeview->setModel(sort_model); | |
356 } | |
357 | |
358 layout->addWidget(treeview); | |
359 } | |
360 } | |
361 | |
362 void TorrentsPage::Refresh() { | |
363 if (!model) | |
364 return; | |
365 model->RefreshTorrentList(); | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
366 } |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
367 |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
368 #include "gui/pages/moc_torrents.cpp" |