comparison src/gui/pages/anime_list.cpp @ 65:26721c28bf22

*: avoid usage of (to|from)StdString in Qt5 (and probably Qt6 as well) these functions are only available (or even usable) if Qt and Minori were built with the *same standard headers*, which may not be the case in some circumstances. hence, we'll use our own conversion functions, which we probably should use anyway.
author Paper <mrpapersonic@gmail.com>
date Sun, 01 Oct 2023 23:26:35 -0400
parents fe719c109dbc
children 2417121d894e
comparison
equal deleted inserted replaced
64:fe719c109dbc 65:26721c28bf22
12 #include "core/anime.h" 12 #include "core/anime.h"
13 #include "core/anime_db.h" 13 #include "core/anime_db.h"
14 #include "core/array.h" 14 #include "core/array.h"
15 #include "core/session.h" 15 #include "core/session.h"
16 #include "core/time.h" 16 #include "core/time.h"
17 #include "core/strings.h"
17 #include "gui/dialog/information.h" 18 #include "gui/dialog/information.h"
18 #include "gui/translate/anime.h" 19 #include "gui/translate/anime.h"
19 #include "services/services.h" 20 #include "services/services.h"
20 #include <QDebug> 21 #include <QDebug>
21 #include <QHBoxLayout> 22 #include <QHBoxLayout>
141 case AL_PROGRESS: 142 case AL_PROGRESS:
142 return QString::number(list[index.row()].GetUserProgress()) + "/" + 143 return QString::number(list[index.row()].GetUserProgress()) + "/" +
143 QString::number(list[index.row()].GetEpisodes()); 144 QString::number(list[index.row()].GetEpisodes());
144 case AL_EPISODES: return list[index.row()].GetEpisodes(); 145 case AL_EPISODES: return list[index.row()].GetEpisodes();
145 case AL_SCORE: return list[index.row()].GetUserScore(); 146 case AL_SCORE: return list[index.row()].GetUserScore();
146 case AL_TYPE: return QString::fromStdString(Translate::ToString(list[index.row()].GetFormat())); 147 case AL_TYPE: return Strings::ToQString(Translate::ToString(list[index.row()].GetFormat()));
147 case AL_SEASON: 148 case AL_SEASON:
148 return QString::fromStdString(Translate::ToString(list[index.row()].GetSeason())) + " " + 149 return Strings::ToQString(Translate::ToString(list[index.row()].GetSeason())) + " " +
149 QString::number(list[index.row()].GetAirDate().GetYear()); 150 QString::number(list[index.row()].GetAirDate().GetYear());
150 case AL_AVG_SCORE: return QString::number(list[index.row()].GetAudienceScore()) + "%"; 151 case AL_AVG_SCORE: return QString::number(list[index.row()].GetAudienceScore()) + "%";
151 case AL_STARTED: return list[index.row()].GetUserDateStarted().GetAsQDate(); 152 case AL_STARTED: return list[index.row()].GetUserDateStarted().GetAsQDate();
152 case AL_COMPLETED: return list[index.row()].GetUserDateCompleted().GetAsQDate(); 153 case AL_COMPLETED: return list[index.row()].GetUserDateCompleted().GetAsQDate();
153 case AL_UPDATED: { 154 case AL_UPDATED: {
439 tree_view->setRootIsDecorated(false); 440 tree_view->setRootIsDecorated(false);
440 tree_view->setContextMenuPolicy(Qt::CustomContextMenu); 441 tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
441 tree_view->setFrameShape(QFrame::NoFrame); 442 tree_view->setFrameShape(QFrame::NoFrame);
442 443
443 for (unsigned int i = 0; i < ARRAYSIZE(sort_models); i++) { 444 for (unsigned int i = 0; i < ARRAYSIZE(sort_models); i++) {
444 tab_bar->addTab(QString::fromStdString(Translate::ToString(Anime::ListStatuses[i])) + " (" + 445 tab_bar->addTab(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" +
445 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); 446 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")");
446 sort_models[i] = new AnimeListPageSortFilter(tree_view); 447 sort_models[i] = new AnimeListPageSortFilter(tree_view);
447 sort_models[i]->setSourceModel(new AnimeListPageModel(this, Anime::ListStatuses[i])); 448 sort_models[i]->setSourceModel(new AnimeListPageModel(this, Anime::ListStatuses[i]));
448 sort_models[i]->setSortRole(Qt::UserRole); 449 sort_models[i]->setSortRole(Qt::UserRole);
449 sort_models[i]->setSortCaseSensitivity(Qt::CaseInsensitive); 450 sort_models[i]->setSortCaseSensitivity(Qt::CaseInsensitive);
484 reinterpret_cast<AnimeListPageModel*>(sort_models[i]->sourceModel())->RefreshList(); 485 reinterpret_cast<AnimeListPageModel*>(sort_models[i]->sourceModel())->RefreshList();
485 } 486 }
486 487
487 void AnimeListPage::RefreshTabs() { 488 void AnimeListPage::RefreshTabs() {
488 for (unsigned int i = 0; i < ARRAYSIZE(sort_models); i++) 489 for (unsigned int i = 0; i < ARRAYSIZE(sort_models); i++)
489 tab_bar->setTabText(i, QString::fromStdString(Translate::ToString(Anime::ListStatuses[i])) + " (" + 490 tab_bar->setTabText(i, Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" +
490 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); 491 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")");
491 } 492 }
492 493
493 void AnimeListPage::Refresh() { 494 void AnimeListPage::Refresh() {
494 RefreshList(); 495 RefreshList();