diff src/gui/pages/anime_list.cc @ 202:71832ffe425a

animia: re-add kvm fd source this is all being merged from my wildly out-of-date laptop. SORRY! in other news, I edited the CI file to install the wayland client as well, so the linux CI build might finally get wayland stuff.
author Paper <paper@paper.us.eu.org>
date Tue, 02 Jan 2024 06:05:06 -0500
parents bc1ae1810855
children 7cf53145de11
line wrap: on
line diff
--- a/src/gui/pages/anime_list.cc	Sun Nov 19 19:13:28 2023 -0500
+++ b/src/gui/pages/anime_list.cc	Tue Jan 02 06:05:06 2024 -0500
@@ -17,6 +17,8 @@
 #include "gui/dialog/information.h"
 #include "gui/translate/anime.h"
 #include "services/services.h"
+
+#include <QDate>
 #include <QDebug>
 #include <QHBoxLayout>
 #include <QHeaderView>
@@ -27,6 +29,7 @@
 #include <QStylePainter>
 #include <QStyledItemDelegate>
 #include <QThreadPool>
+
 #include <set>
 
 AnimeListPageSortFilter::AnimeListPageSortFilter(QObject* parent) : QSortFilterProxyModel(parent) {
@@ -105,16 +108,19 @@
 	switch (role) {
 		case Qt::DisplayRole:
 			switch (index.column()) {
-				case AL_TITLE: return QString::fromUtf8(list[index.row()].GetUserPreferredTitle().c_str());
+				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());
 				case AL_EPISODES: return list[index.row()].GetEpisodes();
-				case AL_SCORE: return list[index.row()].GetUserScore();
+				case AL_SCORE: return Strings::ToQString(list[index.row()].GetUserPresentableScore());
 				case AL_TYPE: return Strings::ToQString(Translate::ToString(list[index.row()].GetFormat()));
-				case AL_SEASON:
-					return Strings::ToQString(Translate::ToString(list[index.row()].GetSeason())) + " " +
-						   QString::number(list[index.row()].GetAirDate().GetYear());
+				case AL_SEASON: {
+					std::optional<unsigned int> year = list[index.row()].GetAirDate().GetYear();
+					if (!year)
+						return "Unknown Unknown";
+					return Strings::ToQString(Translate::ToLocalString(list[index.row()].GetSeason()) + " " + std::to_string(year.value()));
+				}
 				case AL_AVG_SCORE: return QString::number(list[index.row()].GetAudienceScore()) + "%";
 				case AL_STARTED: return list[index.row()].GetUserDateStarted().GetAsQDate();
 				case AL_COMPLETED: return list[index.row()].GetUserDateCompleted().GetAsQDate();
@@ -122,15 +128,16 @@
 					if (list[index.row()].GetUserTimeUpdated() == 0)
 						return QString("-");
 					Time::Duration duration(Time::GetSystemTime() - list[index.row()].GetUserTimeUpdated());
-					return QString::fromUtf8(duration.AsRelativeString().c_str());
+					return Strings::ToQString(duration.AsRelativeString());
 				}
-				case AL_NOTES: return QString::fromUtf8(list[index.row()].GetUserNotes().c_str());
+				case AL_NOTES: return Strings::ToQString(list[index.row()].GetUserNotes());
 				default: return "";
 			}
 			break;
 		case Qt::UserRole:
 			switch (index.column()) {
 				case AL_PROGRESS: return list[index.row()].GetUserProgress();
+				case AL_SCORE: return list[index.row()].GetUserScore();
 				case AL_TYPE: return static_cast<int>(list[index.row()].GetFormat());
 				case AL_SEASON: return list[index.row()].GetAirDate().GetAsQDate();
 				case AL_AVG_SCORE: return list[index.row()].GetAudienceScore();
@@ -342,8 +349,8 @@
 
 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])) + ")");
+		tab_bar->setTabText(i, Strings::ToQString(Translate::ToString(Anime::ListStatuses[i]) + " (" +
+								   std::to_string(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"));
 }
 
 void AnimeListPage::Refresh() {