Mercurial > minori
comparison src/gui/pages/anime_list.cc @ 83:d02fdf1d6708
*: huuuge update
1. make the now playing page function correctly
2. de-constructorfy many of our custom widgets,
allowing them to be changed on-the-fly from
the Now Playing page
3. ... :)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 24 Oct 2023 22:01:02 -0400 |
parents | 9b2b41f83a5e |
children | c912128af0eb |
comparison
equal
deleted
inserted
replaced
82:8b65c417c225 | 83:d02fdf1d6708 |
---|---|
9 * like a native tabbed widget. | 9 * like a native tabbed widget. |
10 **/ | 10 **/ |
11 #include "gui/pages/anime_list.h" | 11 #include "gui/pages/anime_list.h" |
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" | |
15 #include "core/session.h" | 14 #include "core/session.h" |
16 #include "core/strings.h" | 15 #include "core/strings.h" |
17 #include "core/time.h" | 16 #include "core/time.h" |
18 #include "gui/dialog/information.h" | 17 #include "gui/dialog/information.h" |
19 #include "gui/translate/anime.h" | 18 #include "gui/translate/anime.h" |
434 tree_view->setItemsExpandable(false); | 433 tree_view->setItemsExpandable(false); |
435 tree_view->setRootIsDecorated(false); | 434 tree_view->setRootIsDecorated(false); |
436 tree_view->setContextMenuPolicy(Qt::CustomContextMenu); | 435 tree_view->setContextMenuPolicy(Qt::CustomContextMenu); |
437 tree_view->setFrameShape(QFrame::NoFrame); | 436 tree_view->setFrameShape(QFrame::NoFrame); |
438 | 437 |
439 for (unsigned int i = 0; i < ARRAYSIZE(sort_models); i++) { | 438 for (unsigned int i = 0; i < sort_models.size(); i++) { |
440 tab_bar->addTab(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" + | 439 tab_bar->addTab(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" + |
441 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); | 440 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); |
442 sort_models[i] = new AnimeListPageSortFilter(tree_view); | 441 sort_models[i] = new AnimeListPageSortFilter(tree_view); |
443 sort_models[i]->setSourceModel(new AnimeListPageModel(this, Anime::ListStatuses[i])); | 442 sort_models[i]->setSourceModel(new AnimeListPageModel(this, Anime::ListStatuses[i])); |
444 sort_models[i]->setSortRole(Qt::UserRole); | 443 sort_models[i]->setSortRole(Qt::UserRole); |
474 setFocusPolicy(Qt::TabFocus); | 473 setFocusPolicy(Qt::TabFocus); |
475 setFocusProxy(tab_bar); | 474 setFocusProxy(tab_bar); |
476 } | 475 } |
477 | 476 |
478 void AnimeListPage::RefreshList() { | 477 void AnimeListPage::RefreshList() { |
479 for (unsigned int i = 0; i < ARRAYSIZE(sort_models); i++) | 478 for (unsigned int i = 0; i < sort_models.size(); i++) |
480 reinterpret_cast<AnimeListPageModel*>(sort_models[i]->sourceModel())->RefreshList(); | 479 reinterpret_cast<AnimeListPageModel*>(sort_models[i]->sourceModel())->RefreshList(); |
481 } | 480 } |
482 | 481 |
483 void AnimeListPage::RefreshTabs() { | 482 void AnimeListPage::RefreshTabs() { |
484 for (unsigned int i = 0; i < ARRAYSIZE(sort_models); i++) | 483 for (unsigned int i = 0; i < sort_models.size(); i++) |
485 tab_bar->setTabText(i, Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" + | 484 tab_bar->setTabText(i, Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])) + " (" + |
486 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); | 485 QString::number(Anime::db.GetListsAnimeAmount(Anime::ListStatuses[i])) + ")"); |
487 } | 486 } |
488 | 487 |
489 void AnimeListPage::Refresh() { | 488 void AnimeListPage::Refresh() { |
495 Ever. Why would you ever need to clear the anime list? | 494 Ever. Why would you ever need to clear the anime list? |
496 Also, this sucks. */ | 495 Also, this sucks. */ |
497 void AnimeListPage::Reset() { | 496 void AnimeListPage::Reset() { |
498 while (tab_bar->count()) | 497 while (tab_bar->count()) |
499 tab_bar->removeTab(0); | 498 tab_bar->removeTab(0); |
500 for (unsigned int i = 0; i < ARRAYSIZE(sort_models); i++) | 499 for (unsigned int i = 0; i < sort_models.size(); i++) |
501 delete sort_models[i]; | 500 delete sort_models[i]; |
502 } | 501 } |
503 | 502 |
504 #include "gui/pages/moc_anime_list.cpp" | 503 #include "gui/pages/moc_anime_list.cpp" |