Mercurial > minori
diff src/gui/pages/anime_list.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 | f31305b9f60a |
line wrap: on
line diff
--- a/src/gui/pages/anime_list.cc Sun Feb 18 16:02:14 2024 -0500 +++ b/src/gui/pages/anime_list.cc Mon Apr 01 02:43:44 2024 -0400 @@ -25,10 +25,10 @@ #include <QMenu> #include <QProgressBar> #include <QShortcut> -#include <QTreeView> #include <QStylePainter> #include <QStyledItemDelegate> #include <QThread> +#include <QTreeView> #include <set> @@ -111,7 +111,7 @@ case AL_TITLE: return Strings::ToQString(list[index.row()].GetUserPreferredTitle()); case AL_PROGRESS: return QString::number(list[index.row()].GetUserProgress()) + "/" + - QString::number(list[index.row()].GetEpisodes()); + QString::number(list[index.row()].GetEpisodes()); case AL_EPISODES: return list[index.row()].GetEpisodes(); case AL_SCORE: return Strings::ToQString(list[index.row()].GetUserPresentableScore()); case AL_TYPE: return Strings::ToQString(Translate::ToString(list[index.row()].GetFormat())); @@ -119,7 +119,8 @@ std::optional<unsigned int> year = list[index.row()].GetAirDate().GetYear(); if (!year) return "Unknown Unknown"; - return Strings::ToQString(Translate::ToLocalString(list[index.row()].GetSeason()) + " " + Strings::ToUtf8String(year.value())); + return Strings::ToQString(Translate::ToLocalString(list[index.row()].GetSeason()) + " " + + Strings::ToUtf8String(year.value())); } case AL_AVG_SCORE: return QString::number(list[index.row()].GetAudienceScore()) + "%"; case AL_STARTED: return list[index.row()].GetUserDateStarted().GetAsQDate(); @@ -218,9 +219,7 @@ } void AnimeListPage::UpdateAnime(int id) { - QThread* thread = QThread::create([this, id] { - Services::UpdateAnimeEntry(id); - }); + QThread* thread = QThread::create([this, id] { Services::UpdateAnimeEntry(id); }); connect(thread, &QThread::finished, this, &AnimeListPage::Refresh); connect(thread, &QThread::finished, thread, &QThread::deleteLater); @@ -244,7 +243,7 @@ if (i == AnimeListPageModel::AL_TITLE) continue; const auto column_name = - sort_models[tab_bar->currentIndex()]->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString(); + sort_models[tab_bar->currentIndex()]->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString(); QAction* action = menu->addAction(column_name, this, [this, i](const bool checked) { if (!checked && (VisibleColumnsCount() <= 1)) @@ -278,9 +277,9 @@ menu->setToolTipsVisible(true); AnimeListPageModel* source_model = - reinterpret_cast<AnimeListPageModel*>(sort_models[tab_bar->currentIndex()]->sourceModel()); + reinterpret_cast<AnimeListPageModel*>(sort_models[tab_bar->currentIndex()]->sourceModel()); const QItemSelection selection = - sort_models[tab_bar->currentIndex()]->mapSelectionToSource(tree_view->selectionModel()->selection()); + sort_models[tab_bar->currentIndex()]->mapSelectionToSource(tree_view->selectionModel()->selection()); std::set<Anime::Anime*> animes; for (const auto& index : selection.indexes()) { @@ -293,9 +292,8 @@ menu->addAction(tr("Information"), [this, animes] { for (auto& anime : animes) { - InformationDialog* dialog = new InformationDialog(*anime, [this, anime] { - UpdateAnime(anime->GetId()); - }, InformationDialog::PAGE_MAIN_INFO, this); + InformationDialog* dialog = new InformationDialog( + *anime, [this, anime] { UpdateAnime(anime->GetId()); }, InformationDialog::PAGE_MAIN_INFO, this); dialog->show(); dialog->raise(); @@ -305,9 +303,8 @@ menu->addSeparator(); menu->addAction(tr("Edit"), [this, animes] { for (auto& anime : animes) { - InformationDialog* dialog = new InformationDialog(*anime, [this, anime] { - UpdateAnime(anime->GetId()); - }, InformationDialog::PAGE_MY_LIST, this); + InformationDialog* dialog = new InformationDialog( + *anime, [this, anime] { UpdateAnime(anime->GetId()); }, InformationDialog::PAGE_MY_LIST, this); dialog->show(); dialog->raise(); @@ -325,20 +322,19 @@ void AnimeListPage::ItemDoubleClicked() { /* throw out any other garbage */ const QItemSelection selection = - sort_models[tab_bar->currentIndex()]->mapSelectionToSource(tree_view->selectionModel()->selection()); + sort_models[tab_bar->currentIndex()]->mapSelectionToSource(tree_view->selectionModel()->selection()); if (!selection.indexes().first().isValid()) { return; } AnimeListPageModel* source_model = - reinterpret_cast<AnimeListPageModel*>(sort_models[tab_bar->currentIndex()]->sourceModel()); + reinterpret_cast<AnimeListPageModel*>(sort_models[tab_bar->currentIndex()]->sourceModel()); const QModelIndex index = source_model->index(selection.indexes().first().row()); Anime::Anime* anime = source_model->GetAnimeFromIndex(index); - InformationDialog* dialog = new InformationDialog(*anime, [this, anime] { - UpdateAnime(anime->GetId()); - }, InformationDialog::PAGE_MAIN_INFO, this); + InformationDialog* dialog = new InformationDialog( + *anime, [this, anime] { UpdateAnime(anime->GetId()); }, InformationDialog::PAGE_MAIN_INFO, this); dialog->show(); dialog->raise(); @@ -353,7 +349,7 @@ void AnimeListPage::RefreshTabs() { for (unsigned int i = 0; i < sort_models.size(); i++) tab_bar->setTabText(i, Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" + - QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); + QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); } void AnimeListPage::Refresh() { @@ -449,7 +445,7 @@ for (unsigned int i = 0; i < sort_models.size(); i++) { tab_bar->addTab(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" + - QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); + QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); sort_models[i] = new AnimeListPageSortFilter(tree_view); sort_models[i]->setSourceModel(new AnimeListPageModel(this, Anime::ListStatuses[i])); sort_models[i]->setSortRole(Qt::UserRole); @@ -480,10 +476,10 @@ /* Enter & return keys */ connect(new QShortcut(Qt::Key_Return, tree_view, nullptr, nullptr, Qt::WidgetShortcut), &QShortcut::activated, this, - &AnimeListPage::ItemDoubleClicked); + &AnimeListPage::ItemDoubleClicked); connect(new QShortcut(Qt::Key_Enter, tree_view, nullptr, nullptr, Qt::WidgetShortcut), &QShortcut::activated, this, - &AnimeListPage::ItemDoubleClicked); + &AnimeListPage::ItemDoubleClicked); tree_view->header()->setStretchLastSection(false); tree_view->header()->setContextMenuPolicy(Qt::CustomContextMenu);