Mercurial > minori
diff src/gui/pages/torrents.cc @ 258:862d0d8619f6
*: HUUUGE changes
animia has been renamed to animone, so instead of thinking of a
health condition, you think of a beautiful flower :)
I've also edited some of the code for animone, but I have no idea
if it even works or not because I don't have a mac or windows
machine lying around. whoops!
... anyway, all of the changes divergent from Anisthesia are now
licensed under BSD. it's possible that I could even rewrite most
of the code to where I don't even have to keep the MIT license,
but that's thinking too far into the future
I've been slacking off on implementing the anime seasons page,
mostly out of laziness. I think I'd have to create another db file
specifically for the seasons
anyway, this code is being pushed *primarily* because the hard drive
it's on is failing! yay :)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 01 Apr 2024 02:43:44 -0400 |
parents | c130f47f6f48 |
children | dd211ff68b36 |
line wrap: on
line diff
--- a/src/gui/pages/torrents.cc Sun Feb 18 16:02:14 2024 -0500 +++ b/src/gui/pages/torrents.cc Mon Apr 01 02:43:44 2024 -0400 @@ -1,34 +1,34 @@ #include "gui/pages/torrents.h" -#include "core/strings.h" +#include "core/filesystem.h" #include "core/http.h" #include "core/session.h" -#include "core/filesystem.h" +#include "core/strings.h" #include "gui/widgets/text.h" #include "track/media.h" -#include <QHeaderView> -#include <QVBoxLayout> -#include <QToolBar> -#include <QTreeView> #include <QByteArray> #include <QDataStream> +#include <QDebug> +#include <QHeaderView> #include <QThread> -#include <QDebug> +#include <QToolBar> +#include <QTreeView> +#include <QVBoxLayout> +#include <algorithm> +#include <fstream> #include <iostream> #include <sstream> -#include <fstream> -#include <algorithm> +#include "anitomy/anitomy.h" #include "pugixml.hpp" -#include "anitomy/anitomy.h" /* This file is very, very similar to the anime list page. * * It differs from Taiga in that it uses tabs instead of * those "groups", but those are custom painted and a pain in the ass to * maintain over multiple platforms. -*/ + */ TorrentsPageListSortFilter::TorrentsPageListSortFilter(QObject* parent) : QSortFilterProxyModel(parent) { } @@ -86,14 +86,19 @@ void TorrentsPageListModel::ParseFeedDescription(const std::string& description, Torrent& torrent) { /* Parse description... */ - enum class Keys { SIZE, AUTHORIZED, SUBMITTER, COMMENT }; + enum class Keys { + SIZE, + AUTHORIZED, + SUBMITTER, + COMMENT + }; const std::unordered_map<std::string, Keys> KeyMap = { - {"Size", Keys::SIZE}, - {"Authorized", Keys::AUTHORIZED}, - {"Submitter", Keys::SUBMITTER}, - {"Comment", Keys::COMMENT} - }; + {"Size", Keys::SIZE }, + {"Authorized", Keys::AUTHORIZED}, + {"Submitter", Keys::SUBMITTER }, + {"Comment", Keys::COMMENT } + }; /* Parse size from description */ std::istringstream descstream(description); @@ -107,18 +112,13 @@ const std::string value = line.substr(line.find_first_not_of(": ", pos)); switch (KeyMap.at(key)) { - case Keys::COMMENT: - torrent.SetDescription(value); - break; - case Keys::SIZE: - torrent.SetSize(Strings::HumanReadableSizeToBytes(value)); - break; + case Keys::COMMENT: torrent.SetDescription(value); break; + case Keys::SIZE: torrent.SetSize(Strings::HumanReadableSizeToBytes(value)); break; case Keys::AUTHORIZED: if (torrent.GetGroup().empty() && value != "N/A") torrent.SetGroup(value); break; - default: - break; + default: break; } } } @@ -151,7 +151,8 @@ /* todo: patch Anitomy so that it doesn't use wide strings */ torrent.SetTitle(Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle))); - torrent.SetEpisode(Strings::RemoveLeadingChars(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)), '0')); + torrent.SetEpisode( + Strings::RemoveLeadingChars(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)), '0')); torrent.SetGroup(Strings::ToUtf8String(elements.get(anitomy::kElementReleaseGroup))); torrent.SetResolution(Strings::ToUtf8String(elements.get(anitomy::kElementVideoResolution))); } @@ -229,8 +230,7 @@ if (index.column() == 0) { switch (role) { - case Qt::EditRole: - return false; + case Qt::EditRole: return false; case Qt::CheckStateRole: item.SetChecked(value.toBool()); emit dataChanged(index, index); @@ -269,7 +269,7 @@ case TL_EPISODE: return Strings::ToInt(item.GetEpisode(), -1); /* We have to use this to work around some stupid * "conversion ambiguous" error on Linux - */ + */ case TL_SIZE: return QVariant::fromValue(item.GetSize()); default: return data(index, Qt::DisplayRole); } @@ -331,28 +331,22 @@ { /* this needs to be stored somewhere to replicate Taiga's "timer" feature */ - toolbar->addAction(QIcon(":/icons/16x16/arrow-circle-315.png"), tr("&Check new torrents"), [this] { - Refresh(); - }); + toolbar->addAction(QIcon(":/icons/16x16/arrow-circle-315.png"), tr("&Check new torrents"), + [this] { Refresh(); }); } toolbar->addSeparator(); { - toolbar->addAction(QIcon(":/icons/16x16/navigation-270-button.png"), tr("Download &marked torrents"), [this] { - DownloadSelection(); - }); + toolbar->addAction(QIcon(":/icons/16x16/navigation-270-button.png"), tr("Download &marked torrents"), + [this] { DownloadSelection(); }); } - { - toolbar->addAction(QIcon(":/icons/16x16/cross-button.png"), tr("&Discard all")); - } + { toolbar->addAction(QIcon(":/icons/16x16/cross-button.png"), tr("&Discard all")); } toolbar->addSeparator(); - { - toolbar->addAction(QIcon(":/icons/16x16/gear.png"), tr("&Settings")); - } + { toolbar->addAction(QIcon(":/icons/16x16/gear.png"), tr("&Settings")); } layout->addWidget(toolbar); } @@ -387,16 +381,16 @@ } // set column sizes - treeview->setColumnWidth(TorrentsPageListModel::TL_TITLE, 240); - treeview->setColumnWidth(TorrentsPageListModel::TL_EPISODE, 60); - treeview->setColumnWidth(TorrentsPageListModel::TL_GROUP, 100); - treeview->setColumnWidth(TorrentsPageListModel::TL_SIZE, 70); - treeview->setColumnWidth(TorrentsPageListModel::TL_RESOLUTION, 100); - treeview->setColumnWidth(TorrentsPageListModel::TL_SEEDERS, 20); - treeview->setColumnWidth(TorrentsPageListModel::TL_LEECHERS, 20); - treeview->setColumnWidth(TorrentsPageListModel::TL_DOWNLOADS, 20); + treeview->setColumnWidth(TorrentsPageListModel::TL_TITLE, 240); + treeview->setColumnWidth(TorrentsPageListModel::TL_EPISODE, 60); + treeview->setColumnWidth(TorrentsPageListModel::TL_GROUP, 100); + treeview->setColumnWidth(TorrentsPageListModel::TL_SIZE, 70); + treeview->setColumnWidth(TorrentsPageListModel::TL_RESOLUTION, 100); + treeview->setColumnWidth(TorrentsPageListModel::TL_SEEDERS, 20); + treeview->setColumnWidth(TorrentsPageListModel::TL_LEECHERS, 20); + treeview->setColumnWidth(TorrentsPageListModel::TL_DOWNLOADS, 20); treeview->setColumnWidth(TorrentsPageListModel::TL_DESCRIPTION, 200); - treeview->setColumnWidth(TorrentsPageListModel::TL_FILENAME, 200); + treeview->setColumnWidth(TorrentsPageListModel::TL_FILENAME, 200); treeview->setColumnWidth(TorrentsPageListModel::TL_RELEASEDATE, 190); treeview->header()->setStretchLastSection(false); @@ -423,7 +417,7 @@ connect(thread, &HTTP::GetThread::ReceivedData, this, [&](const QByteArray& ba) { /* This is to make sure we aren't in a different thread * messing around with GUI stuff - */ + */ treeview->setUpdatesEnabled(false); model->ParseTorrentList(ba); treeview->setUpdatesEnabled(true);