Mercurial > minori
annotate src/gui/pages/torrents.cc @ 218:c39ad2a8587d
strings: include cstdint
oops
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 07 Jan 2024 13:28:00 -0500 |
parents | 01d259b9c89f |
children | 53211cb1e7f5 |
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; |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
86 default: |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
87 break; |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
88 } |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
89 } |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
90 } |
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
91 |
114 | 92 void TorrentsPageListModel::ParseTorrentList(const QByteArray& ba) { |
93 std::istringstream stdstream(Strings::ToUtf8String(ba)); | |
94 | |
95 pugi::xml_document doc; | |
96 if (!doc.load(stdstream)) | |
97 return; // peace out | |
98 | |
99 /* my extra special dumb hack. */ | |
100 if (!rowCount(index(0))) { | |
101 beginInsertRows(QModelIndex(), 0, 0); | |
102 endInsertRows(); | |
103 } | |
104 | |
105 beginResetModel(); | |
106 | |
107 list.clear(); | |
108 /* this is just an rss parser; it should be in a separate class... */ | |
109 for (pugi::xml_node item : doc.child("rss").child("channel").children("item")) { | |
110 TorrentModelItem torrent; | |
111 torrent.SetFilename(item.child_value("title")); /* "title" == filename */ | |
112 { | |
154 | 113 anitomy::Anitomy anitomy; |
114 anitomy.Parse(Strings::ToWstring(torrent.GetFilename())); | |
115 | |
116 const auto& elements = anitomy.elements(); | |
117 | |
118 /* todo: patch Anitomy so that it doesn't use wide strings */ | |
119 torrent.SetTitle(Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle))); | |
120 torrent.SetEpisode(Strings::RemoveLeadingChars(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)), '0')); | |
121 torrent.SetGroup(Strings::ToUtf8String(elements.get(anitomy::kElementReleaseGroup))); | |
122 torrent.SetResolution(Strings::ToUtf8String(elements.get(anitomy::kElementVideoResolution))); | |
114 | 123 } |
124 | |
183
01d259b9c89f
pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents:
178
diff
changeset
|
125 ParseFeedDescription(Strings::TextifySynopsis(item.child_value("description")), torrent); |
114 | 126 |
127 torrent.SetLink(item.child_value("link")); | |
128 torrent.SetGuid(item.child_value("guid")); | |
129 { | |
130 const QString date_str = Strings::ToQString(item.child_value("pubDate")); | |
131 torrent.SetDate(QDateTime::fromString(date_str, "ddd, dd MMM yyyy HH:mm:ss t")); | |
132 } | |
133 list.push_back(torrent); | |
134 } | |
135 | |
136 endResetModel(); | |
137 } | |
138 | |
139 void TorrentsPageListModel::RefreshTorrentList() { | |
140 ParseTorrentList(DownloadTorrentList()); | |
141 } | |
142 | |
143 int TorrentsPageListModel::rowCount(const QModelIndex& parent) const { | |
144 return list.size(); | |
145 (void)(parent); | |
146 } | |
147 | |
148 int TorrentsPageListModel::columnCount(const QModelIndex& parent) const { | |
149 return NB_COLUMNS; | |
150 (void)(parent); | |
151 } | |
152 | |
153 QVariant TorrentsPageListModel::headerData(const int section, const Qt::Orientation orientation, const int role) const { | |
154 switch (role) { | |
155 case Qt::DisplayRole: { | |
156 switch (section) { | |
157 case TL_TITLE: return tr("Anime title"); | |
158 case TL_EPISODE: return tr("Episode"); | |
159 case TL_GROUP: return tr("Group"); | |
160 case TL_SIZE: return tr("Size"); | |
161 case TL_RESOLUTION: return tr("Resolution"); /* this is named "Video" in Taiga */ | |
162 case TL_SEEDERS: return tr("Seeding"); /* named "S" in Taiga */ | |
163 case TL_LEECHERS: return tr("Leeching"); /* named "L" in Taiga */ | |
164 case TL_DOWNLOADERS: return tr("Downloading"); /* named "D" in Taiga */ | |
165 case TL_DESCRIPTION: return tr("Description"); | |
166 case TL_FILENAME: return tr("Filename"); | |
167 case TL_RELEASEDATE: return tr("Release date"); | |
168 default: return {}; | |
169 } | |
170 break; | |
171 } | |
172 case Qt::TextAlignmentRole: { | |
173 switch (section) { | |
174 case TL_FILENAME: | |
175 case TL_GROUP: | |
176 case TL_DESCRIPTION: | |
177 case TL_RESOLUTION: | |
178 case TL_TITLE: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); | |
179 case TL_SEEDERS: | |
180 case TL_LEECHERS: | |
181 case TL_DOWNLOADERS: | |
182 case TL_SIZE: | |
183 case TL_EPISODE: | |
184 case TL_RELEASEDATE: return QVariant(Qt::AlignRight | Qt::AlignVCenter); | |
185 default: return {}; | |
186 } | |
187 break; | |
188 } | |
189 } | |
190 return QAbstractListModel::headerData(section, orientation, role); | |
191 } | |
192 | |
193 bool TorrentsPageListModel::setData(const QModelIndex& index, const QVariant& value, int role) { | |
194 TorrentModelItem& item = list.at(index.row()); | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
195 |
114 | 196 if (index.column() == 0) { |
197 switch (role) { | |
198 case Qt::EditRole: | |
199 return false; | |
200 case Qt::CheckStateRole: | |
201 item.SetChecked(value.toBool()); | |
202 emit dataChanged(index, index); | |
203 return true; | |
204 } | |
205 } | |
206 | |
207 return QAbstractItemModel::setData(index, value, role); | |
208 } | |
209 | |
210 QVariant TorrentsPageListModel::data(const QModelIndex& index, int role) const { | |
211 if (!index.isValid()) | |
212 return QVariant(); | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
213 |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
214 const TorrentModelItem& item = list.at(index.row()); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
215 |
114 | 216 switch (role) { |
217 case Qt::DisplayRole: | |
218 switch (index.column()) { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
219 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
|
220 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
|
221 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
|
222 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
|
223 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
|
224 case TL_SEEDERS: return item.GetSeeders(); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
225 case TL_LEECHERS: return item.GetLeechers(); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
226 case TL_DOWNLOADERS: return item.GetDownloaders(); |
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
227 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
|
228 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
|
229 case TL_RELEASEDATE: return item.GetDate(); |
114 | 230 default: return ""; |
231 } | |
232 break; | |
233 case Qt::UserRole: | |
234 switch (index.column()) { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
235 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
|
236 /* 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
|
237 "conversion ambiguous" error on Linux */ |
2c1b6782e1d0
pages/torrents: work around conversion error on Linux
Paper <mrpapersonic@gmail.com>
parents:
116
diff
changeset
|
238 case TL_SIZE: return QVariant::fromValue(item.GetSize()); |
114 | 239 default: return data(index, Qt::DisplayRole); |
240 } | |
241 break; | |
242 case Qt::SizeHintRole: { | |
243 switch (index.column()) { | |
244 default: { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
245 /* max horizontal size of 100, height size = size of current font */ |
114 | 246 const QString d = data(index, Qt::DisplayRole).toString(); |
247 const QFontMetrics metric = QFontMetrics(QFont()); | |
248 | |
249 return QSize(std::max(metric.horizontalAdvance(d), 100), metric.height()); | |
250 } | |
251 } | |
252 break; | |
253 } | |
254 case Qt::TextAlignmentRole: | |
255 switch (index.column()) { | |
256 case TL_FILENAME: | |
257 case TL_GROUP: | |
258 case TL_DESCRIPTION: | |
259 case TL_RESOLUTION: | |
260 case TL_TITLE: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); | |
261 case TL_SEEDERS: | |
262 case TL_LEECHERS: | |
263 case TL_DOWNLOADERS: | |
264 case TL_SIZE: | |
265 case TL_EPISODE: | |
266 case TL_RELEASEDATE: return QVariant(Qt::AlignRight | Qt::AlignVCenter); | |
267 default: return {}; | |
268 } | |
269 break; | |
270 } | |
271 return QVariant(); | |
272 } | |
273 | |
274 Qt::ItemFlags TorrentsPageListModel::flags(const QModelIndex& index) const { | |
275 if (!index.isValid()) | |
276 return Qt::NoItemFlags; | |
277 | |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
117
diff
changeset
|
278 return Qt::ItemIsEnabled | Qt::ItemIsSelectable; |
114 | 279 } |
280 | |
281 TorrentsPage::TorrentsPage(QWidget* parent) : QFrame(parent) { | |
282 setFrameShape(QFrame::Box); | |
283 setFrameShadow(QFrame::Sunken); | |
284 | |
285 QVBoxLayout* layout = new QVBoxLayout(this); | |
286 layout->setContentsMargins(0, 0, 0, 0); | |
287 layout->setSpacing(0); | |
288 | |
289 { | |
290 /* Toolbar */ | |
291 QToolBar* toolbar = new QToolBar(this); | |
292 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | |
293 toolbar->setIconSize(QSize(16, 16)); | |
294 toolbar->setMovable(false); | |
295 | |
296 { | |
297 /* this needs to be stored somewhere to replicate Taiga's | |
298 "timer" feature */ | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
299 toolbar->addAction(QIcon(":/icons/16x16/arrow-circle-315.png"), tr("&Check new torrents"), [this]{ |
114 | 300 QThreadPool::globalInstance()->start([this] { |
301 Refresh(); | |
302 }); | |
303 }); | |
304 } | |
305 | |
306 toolbar->addSeparator(); | |
307 | |
308 { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
309 toolbar->addAction(QIcon(":/icons/16x16/navigation-270-button.png"), tr("Download &marked torrents")); |
114 | 310 } |
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/cross-button.png"), tr("&Discard all")); |
114 | 314 } |
315 | |
316 toolbar->addSeparator(); | |
317 | |
318 { | |
116
254b1d2b7096
settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents:
114
diff
changeset
|
319 toolbar->addAction(QIcon(":/icons/16x16/gear.png"), tr("&Settings")); |
114 | 320 } |
321 | |
322 layout->addWidget(toolbar); | |
323 } | |
324 | |
325 { | |
326 QFrame* line = new QFrame(this); | |
327 line->setFrameShape(QFrame::HLine); | |
328 line->setFrameShadow(QFrame::Sunken); | |
329 line->setLineWidth(1); | |
330 layout->addWidget(line); | |
331 } | |
332 | |
333 { | |
334 QTreeView* treeview = new QTreeView(this); | |
335 treeview->setUniformRowHeights(true); | |
336 treeview->setAllColumnsShowFocus(false); | |
337 treeview->setAlternatingRowColors(true); | |
338 treeview->setSortingEnabled(true); | |
339 treeview->setSelectionMode(QAbstractItemView::ExtendedSelection); | |
340 treeview->setItemsExpandable(false); | |
341 treeview->setRootIsDecorated(false); | |
342 treeview->setContextMenuPolicy(Qt::CustomContextMenu); | |
343 treeview->setFrameShape(QFrame::NoFrame); | |
344 | |
345 { | |
346 sort_model = new TorrentsPageListSortFilter(treeview); | |
347 model = new TorrentsPageListModel(treeview); | |
348 sort_model->setSourceModel(model); | |
349 sort_model->setSortRole(Qt::UserRole); | |
350 sort_model->setSortCaseSensitivity(Qt::CaseInsensitive); | |
351 treeview->setModel(sort_model); | |
352 } | |
353 | |
354 layout->addWidget(treeview); | |
355 } | |
356 } | |
357 | |
358 void TorrentsPage::Refresh() { | |
359 if (!model) | |
360 return; | |
361 model->RefreshTorrentList(); | |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
362 } |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
363 |
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
364 #include "gui/pages/moc_torrents.cpp" |