Mercurial > minori
diff src/gui/pages/torrents.cc @ 116:254b1d2b7096
settings: add torrents page, make rss feed configurable
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 07 Nov 2023 13:52:13 -0500 |
parents | ab191e28e69d |
children | 2c1b6782e1d0 |
line wrap: on
line diff
--- a/src/gui/pages/torrents.cc Tue Nov 07 12:04:51 2023 -0500 +++ b/src/gui/pages/torrents.cc Tue Nov 07 13:52:13 2023 -0500 @@ -41,7 +41,7 @@ } QByteArray TorrentsPageListModel::DownloadTorrentList() { - return HTTP::Get("https://www.tokyotosho.info/rss.php?filter=1,11&zwnj=0"); + return HTTP::Get(session.config.torrents.feed_link); } void TorrentsPageListModel::ParseTorrentList(const QByteArray& ba) { @@ -173,38 +173,42 @@ QVariant TorrentsPageListModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) return QVariant(); + + const TorrentModelItem& item = list.at(index.row()); + switch (role) { case Qt::DisplayRole: switch (index.column()) { - case TL_TITLE: return Strings::ToQString(list.at(index.row()).GetTitle()); - case TL_EPISODE: return Strings::ToQString(list.at(index.row()).GetEpisode()); - case TL_GROUP: return Strings::ToQString(list.at(index.row()).GetGroup()); - case TL_SIZE: return session.config.locale.GetLocale().formattedDataSize(list.at(index.row()).GetSize()); - case TL_RESOLUTION: return Strings::ToQString(list.at(index.row()).GetResolution()); - case TL_SEEDERS: return list.at(index.row()).GetSeeders(); - case TL_LEECHERS: return list.at(index.row()).GetLeechers(); - case TL_DOWNLOADERS: return list.at(index.row()).GetDownloaders(); - case TL_DESCRIPTION: return Strings::ToQString(list.at(index.row()).GetDescription()); - case TL_FILENAME: return Strings::ToQString(list.at(index.row()).GetFilename()); - case TL_RELEASEDATE: return list.at(index.row()).GetDate(); + case TL_TITLE: return Strings::ToQString(item.GetTitle()); + case TL_EPISODE: return Strings::ToQString(item.GetEpisode()); + case TL_GROUP: return Strings::ToQString(item.GetGroup()); + case TL_SIZE: return session.config.locale.GetLocale().formattedDataSize(item.GetSize()); + case TL_RESOLUTION: return Strings::ToQString(item.GetResolution()); + case TL_SEEDERS: return item.GetSeeders(); + case TL_LEECHERS: return item.GetLeechers(); + case TL_DOWNLOADERS: return item.GetDownloaders(); + case TL_DESCRIPTION: return Strings::ToQString(item.GetDescription()); + case TL_FILENAME: return Strings::ToQString(item.GetFilename()); + case TL_RELEASEDATE: return item.GetDate(); default: return ""; } break; case Qt::UserRole: switch (index.column()) { - case TL_EPISODE: return Strings::ToInt(list.at(index.row()).GetEpisode(), -1); - case TL_SIZE: return list.at(index.row()).GetSize(); + case TL_EPISODE: return Strings::ToInt(item.GetEpisode(), -1); + case TL_SIZE: return item.GetSize(); default: return data(index, Qt::DisplayRole); } break; case Qt::CheckStateRole: switch (index.column()) { - case 0: return list.at(index.row()).GetChecked() ? Qt::Checked : Qt::Unchecked; + case 0: return item.GetChecked() ? Qt::Checked : Qt::Unchecked; default: return {}; } case Qt::SizeHintRole: { switch (index.column()) { default: { + /* max horizontal size of 100, height size = size of current font */ const QString d = data(index, Qt::DisplayRole).toString(); const QFontMetrics metric = QFontMetrics(QFont()); @@ -263,7 +267,7 @@ { /* this needs to be stored somewhere to replicate Taiga's "timer" feature */ - QAction* action = toolbar->addAction(QIcon(":/icons/16x16/arrow-circle-315.png"), tr("&Check new torrents"), [this]{ + toolbar->addAction(QIcon(":/icons/16x16/arrow-circle-315.png"), tr("&Check new torrents"), [this]{ QThreadPool::globalInstance()->start([this] { Refresh(); }); @@ -273,17 +277,17 @@ toolbar->addSeparator(); { - QAction* action = toolbar->addAction(QIcon(":/icons/16x16/navigation-270-button.png"), tr("Download &marked torrents")); + toolbar->addAction(QIcon(":/icons/16x16/navigation-270-button.png"), tr("Download &marked torrents")); } { - QAction* action = toolbar->addAction(QIcon(":/icons/16x16/cross-button.png"), tr("&Discard all")); + toolbar->addAction(QIcon(":/icons/16x16/cross-button.png"), tr("&Discard all")); } toolbar->addSeparator(); { - QAction* action = toolbar->addAction(QIcon(":/icons/16x16/gear.png"), tr("&Settings")); + toolbar->addAction(QIcon(":/icons/16x16/gear.png"), tr("&Settings")); } layout->addWidget(toolbar);