Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 201:8f6f8dd2eb23 | 202:71832ffe425a |
|---|---|
| 15 #include "core/strings.h" | 15 #include "core/strings.h" |
| 16 #include "core/time.h" | 16 #include "core/time.h" |
| 17 #include "gui/dialog/information.h" | 17 #include "gui/dialog/information.h" |
| 18 #include "gui/translate/anime.h" | 18 #include "gui/translate/anime.h" |
| 19 #include "services/services.h" | 19 #include "services/services.h" |
| 20 | |
| 21 #include <QDate> | |
| 20 #include <QDebug> | 22 #include <QDebug> |
| 21 #include <QHBoxLayout> | 23 #include <QHBoxLayout> |
| 22 #include <QHeaderView> | 24 #include <QHeaderView> |
| 23 #include <QMenu> | 25 #include <QMenu> |
| 24 #include <QProgressBar> | 26 #include <QProgressBar> |
| 25 #include <QShortcut> | 27 #include <QShortcut> |
| 26 #include <QTreeView> | 28 #include <QTreeView> |
| 27 #include <QStylePainter> | 29 #include <QStylePainter> |
| 28 #include <QStyledItemDelegate> | 30 #include <QStyledItemDelegate> |
| 29 #include <QThreadPool> | 31 #include <QThreadPool> |
| 32 | |
| 30 #include <set> | 33 #include <set> |
| 31 | 34 |
| 32 AnimeListPageSortFilter::AnimeListPageSortFilter(QObject* parent) : QSortFilterProxyModel(parent) { | 35 AnimeListPageSortFilter::AnimeListPageSortFilter(QObject* parent) : QSortFilterProxyModel(parent) { |
| 33 } | 36 } |
| 34 | 37 |
| 103 if (!index.isValid()) | 106 if (!index.isValid()) |
| 104 return QVariant(); | 107 return QVariant(); |
| 105 switch (role) { | 108 switch (role) { |
| 106 case Qt::DisplayRole: | 109 case Qt::DisplayRole: |
| 107 switch (index.column()) { | 110 switch (index.column()) { |
| 108 case AL_TITLE: return QString::fromUtf8(list[index.row()].GetUserPreferredTitle().c_str()); | 111 case AL_TITLE: return Strings::ToQString(list[index.row()].GetUserPreferredTitle()); |
| 109 case AL_PROGRESS: | 112 case AL_PROGRESS: |
| 110 return QString::number(list[index.row()].GetUserProgress()) + "/" + | 113 return QString::number(list[index.row()].GetUserProgress()) + "/" + |
| 111 QString::number(list[index.row()].GetEpisodes()); | 114 QString::number(list[index.row()].GetEpisodes()); |
| 112 case AL_EPISODES: return list[index.row()].GetEpisodes(); | 115 case AL_EPISODES: return list[index.row()].GetEpisodes(); |
| 113 case AL_SCORE: return list[index.row()].GetUserScore(); | 116 case AL_SCORE: return Strings::ToQString(list[index.row()].GetUserPresentableScore()); |
| 114 case AL_TYPE: return Strings::ToQString(Translate::ToString(list[index.row()].GetFormat())); | 117 case AL_TYPE: return Strings::ToQString(Translate::ToString(list[index.row()].GetFormat())); |
| 115 case AL_SEASON: | 118 case AL_SEASON: { |
| 116 return Strings::ToQString(Translate::ToString(list[index.row()].GetSeason())) + " " + | 119 std::optional<unsigned int> year = list[index.row()].GetAirDate().GetYear(); |
| 117 QString::number(list[index.row()].GetAirDate().GetYear()); | 120 if (!year) |
| 121 return "Unknown Unknown"; | |
| 122 return Strings::ToQString(Translate::ToLocalString(list[index.row()].GetSeason()) + " " + std::to_string(year.value())); | |
| 123 } | |
| 118 case AL_AVG_SCORE: return QString::number(list[index.row()].GetAudienceScore()) + "%"; | 124 case AL_AVG_SCORE: return QString::number(list[index.row()].GetAudienceScore()) + "%"; |
| 119 case AL_STARTED: return list[index.row()].GetUserDateStarted().GetAsQDate(); | 125 case AL_STARTED: return list[index.row()].GetUserDateStarted().GetAsQDate(); |
| 120 case AL_COMPLETED: return list[index.row()].GetUserDateCompleted().GetAsQDate(); | 126 case AL_COMPLETED: return list[index.row()].GetUserDateCompleted().GetAsQDate(); |
| 121 case AL_UPDATED: { | 127 case AL_UPDATED: { |
| 122 if (list[index.row()].GetUserTimeUpdated() == 0) | 128 if (list[index.row()].GetUserTimeUpdated() == 0) |
| 123 return QString("-"); | 129 return QString("-"); |
| 124 Time::Duration duration(Time::GetSystemTime() - list[index.row()].GetUserTimeUpdated()); | 130 Time::Duration duration(Time::GetSystemTime() - list[index.row()].GetUserTimeUpdated()); |
| 125 return QString::fromUtf8(duration.AsRelativeString().c_str()); | 131 return Strings::ToQString(duration.AsRelativeString()); |
| 126 } | 132 } |
| 127 case AL_NOTES: return QString::fromUtf8(list[index.row()].GetUserNotes().c_str()); | 133 case AL_NOTES: return Strings::ToQString(list[index.row()].GetUserNotes()); |
| 128 default: return ""; | 134 default: return ""; |
| 129 } | 135 } |
| 130 break; | 136 break; |
| 131 case Qt::UserRole: | 137 case Qt::UserRole: |
| 132 switch (index.column()) { | 138 switch (index.column()) { |
| 133 case AL_PROGRESS: return list[index.row()].GetUserProgress(); | 139 case AL_PROGRESS: return list[index.row()].GetUserProgress(); |
| 140 case AL_SCORE: return list[index.row()].GetUserScore(); | |
| 134 case AL_TYPE: return static_cast<int>(list[index.row()].GetFormat()); | 141 case AL_TYPE: return static_cast<int>(list[index.row()].GetFormat()); |
| 135 case AL_SEASON: return list[index.row()].GetAirDate().GetAsQDate(); | 142 case AL_SEASON: return list[index.row()].GetAirDate().GetAsQDate(); |
| 136 case AL_AVG_SCORE: return list[index.row()].GetAudienceScore(); | 143 case AL_AVG_SCORE: return list[index.row()].GetAudienceScore(); |
| 137 case AL_UPDATED: return QVariant::fromValue(list[index.row()].GetUserTimeUpdated()); | 144 case AL_UPDATED: return QVariant::fromValue(list[index.row()].GetUserTimeUpdated()); |
| 138 default: return data(index, Qt::DisplayRole); | 145 default: return data(index, Qt::DisplayRole); |
| 340 reinterpret_cast<AnimeListPageModel*>(sort_models[i]->sourceModel())->RefreshList(); | 347 reinterpret_cast<AnimeListPageModel*>(sort_models[i]->sourceModel())->RefreshList(); |
| 341 } | 348 } |
| 342 | 349 |
| 343 void AnimeListPage::RefreshTabs() { | 350 void AnimeListPage::RefreshTabs() { |
| 344 for (unsigned int i = 0; i < sort_models.size(); i++) | 351 for (unsigned int i = 0; i < sort_models.size(); i++) |
| 345 tab_bar->setTabText(i, Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" + | 352 tab_bar->setTabText(i, Strings::ToQString(Translate::ToString(Anime::ListStatuses[i]) + " (" + |
| 346 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); | 353 std::to_string(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")")); |
| 347 } | 354 } |
| 348 | 355 |
| 349 void AnimeListPage::Refresh() { | 356 void AnimeListPage::Refresh() { |
| 350 RefreshList(); | 357 RefreshList(); |
| 351 RefreshTabs(); | 358 RefreshTabs(); |
