Mercurial > minori
diff src/gui/pages/search.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/search.cc Sun Feb 18 16:02:14 2024 -0500 +++ b/src/gui/pages/search.cc Mon Apr 01 02:43:44 2024 -0400 @@ -1,30 +1,30 @@ #include "gui/pages/search.h" #include "core/anime.h" #include "core/anime_db.h" -#include "core/strings.h" +#include "core/filesystem.h" #include "core/http.h" #include "core/session.h" -#include "core/filesystem.h" -#include "gui/widgets/text.h" +#include "core/strings.h" #include "gui/dialog/information.h" -#include "track/media.h" #include "gui/translate/anime.h" +#include "gui/widgets/text.h" #include "services/services.h" +#include "track/media.h" +#include <QDate> #include <QHeaderView> -#include <QVBoxLayout> +#include <QMenu> #include <QToolBar> #include <QTreeView> -#include <QDate> -#include <QMenu> +#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" SearchPageListSortFilter::SearchPageListSortFilter(QObject* parent) : QSortFilterProxyModel(parent) { } @@ -37,10 +37,8 @@ case QMetaType::Int: case QMetaType::UInt: case QMetaType::LongLong: - case QMetaType::ULongLong: - return left.toInt() < right.toInt(); - case QMetaType::QDate: - return left.toDate() < right.toDate(); + case QMetaType::ULongLong: return left.toInt() < right.toInt(); + case QMetaType::QDate: return left.toDate() < right.toDate(); case QMetaType::QString: default: // meh return QString::compare(left.toString(), right.toString(), Qt::CaseInsensitive) < 0; @@ -117,7 +115,9 @@ case SR_TYPE: return Strings::ToQString(Translate::ToLocalString(anime.GetFormat())); case SR_EPISODES: return anime.GetEpisodes(); case SR_SCORE: return QString::number(anime.GetAudienceScore()) + "%"; - case SR_SEASON: return Strings::ToQString(Translate::ToLocalString(anime.GetSeason())) + " " + QString::number(anime.GetAirDate().GetYear().value_or(2000)); + case SR_SEASON: + return Strings::ToQString(Translate::ToLocalString(anime.GetSeason())) + " " + + QString::number(anime.GetAirDate().GetYear().value_or(2000)); default: return {}; } break; @@ -128,7 +128,7 @@ case SR_SEASON: return anime.GetAirDate().GetAsQDate(); /* We have to use this to work around some stupid * "conversion ambiguous" error on Linux - */ + */ default: return data(index, Qt::DisplayRole); } break; @@ -144,8 +144,7 @@ } break; } - case Qt::TextAlignmentRole: - return headerData(index.column(), Qt::Horizontal, Qt::TextAlignmentRole); + case Qt::TextAlignmentRole: return headerData(index.column(), Qt::Horizontal, Qt::TextAlignmentRole); } return QVariant(); } @@ -185,9 +184,12 @@ 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(); @@ -197,7 +199,7 @@ menu->addSeparator(); { QMenu* submenu = menu->addMenu(tr("Add to list...")); - submenu->addAction(tr("Currently watching"), [animes]{ + submenu->addAction(tr("Currently watching"), [animes] { for (auto& anime : animes) { if (!anime->IsInUserList()) anime->AddToUserList(); @@ -205,7 +207,7 @@ Services::UpdateAnimeEntry(anime->GetId()); } }); - submenu->addAction(tr("Completed"), [animes]{ + submenu->addAction(tr("Completed"), [animes] { for (auto& anime : animes) { if (!anime->IsInUserList()) anime->AddToUserList(); @@ -213,7 +215,7 @@ Services::UpdateAnimeEntry(anime->GetId()); } }); - submenu->addAction(tr("On hold"), [animes]{ + submenu->addAction(tr("On hold"), [animes] { for (auto& anime : animes) { if (!anime->IsInUserList()) anime->AddToUserList(); @@ -221,7 +223,7 @@ Services::UpdateAnimeEntry(anime->GetId()); } }); - submenu->addAction(tr("Dropped"), [animes]{ + submenu->addAction(tr("Dropped"), [animes] { for (auto& anime : animes) { if (!anime->IsInUserList()) anime->AddToUserList(); @@ -229,7 +231,7 @@ Services::UpdateAnimeEntry(anime->GetId()); } }); - submenu->addAction(tr("Plan to watch"), [animes]{ + submenu->addAction(tr("Plan to watch"), [animes] { for (auto& anime : animes) { if (!anime->IsInUserList()) anime->AddToUserList(); @@ -251,9 +253,12 @@ const QModelIndex index = model->index(selection.indexes().first().row()); Anime::Anime* anime = 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(); @@ -275,18 +280,18 @@ { QLineEdit* line_edit = new QLineEdit("", toolbar); - connect(line_edit, &QLineEdit::returnPressed, this, [this, line_edit]{ + connect(line_edit, &QLineEdit::returnPressed, this, [this, line_edit] { /* static thread here. */ static QThread* thread = nullptr; if (thread) return; - thread = QThread::create([this, line_edit]{ + thread = QThread::create([this, line_edit] { model->ParseSearch(Services::Search(Strings::ToUtf8String(line_edit->text()))); }); - connect(thread, &QThread::finished, this, []{ + connect(thread, &QThread::finished, this, [] { thread->deleteLater(); thread = nullptr; }); @@ -329,11 +334,11 @@ } // set column sizes - treeview->setColumnWidth(SearchPageListModel::SR_TITLE, 400); - treeview->setColumnWidth(SearchPageListModel::SR_TYPE, 60); + treeview->setColumnWidth(SearchPageListModel::SR_TITLE, 400); + treeview->setColumnWidth(SearchPageListModel::SR_TYPE, 60); treeview->setColumnWidth(SearchPageListModel::SR_EPISODES, 60); - treeview->setColumnWidth(SearchPageListModel::SR_SCORE, 60); - treeview->setColumnWidth(SearchPageListModel::SR_SEASON, 100); + treeview->setColumnWidth(SearchPageListModel::SR_SCORE, 60); + treeview->setColumnWidth(SearchPageListModel::SR_SEASON, 100); treeview->header()->setStretchLastSection(false);